From 955862c877f8210e5fb57eeba22c9605bd814f7b Mon Sep 17 00:00:00 2001 From: Eknous-P Date: Fri, 22 Mar 2024 15:20:24 +0400 Subject: [PATCH] woah it works so god --- CMakeLists.txt | 2 +- src/gui/gui.h | 1 + src/gui/guiConst.cpp | 1 + src/gui/sysManager.cpp | 12 +--- .../{sysPartNumber.cpp => sysMiscInfo.cpp} | 63 +++++++++++++++++++ 5 files changed, 68 insertions(+), 11 deletions(-) rename src/gui/{sysPartNumber.cpp => sysMiscInfo.cpp} (79%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44e751627..742f21045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -839,7 +839,7 @@ src/gui/subSongs.cpp src/gui/sysConf.cpp src/gui/sysEx.cpp src/gui/sysManager.cpp -src/gui/sysPartNumber.cpp +src/gui/sysMiscInfo.cpp src/gui/sysPicker.cpp src/gui/tutorial.cpp src/gui/util.cpp diff --git a/src/gui/gui.h b/src/gui/gui.h index c11496768..62f02389f 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2613,6 +2613,7 @@ class FurnaceGUI { void drawTutorial(); void drawXYOsc(); void drawSystemChannelInfo(const DivSysDef* whichDef); + void drawSystemChannelInfoText(const DivSysDef* whichDef); void parseKeybinds(); void promptKey(int which); diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index 36cf8e6cd..1e19d0afb 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -240,6 +240,7 @@ const char* chanNames[]={ "Wavetable", "Sample", "Square", + "Triangle", "Channel", // if neither "Channels" }; diff --git a/src/gui/sysManager.cpp b/src/gui/sysManager.cpp index f55233770..f98034a9a 100644 --- a/src/gui/sysManager.cpp +++ b/src/gui/sysManager.cpp @@ -23,15 +23,6 @@ #include #include -void FurnaceGUI::drawSystemChannelInfo(const DivSysDef* whichDef) { - for (int i=0; ichannels; i++) { - ImGui::PushStyleColor(ImGuiCol_Button,ImGui::GetColorU32(uiColors[whichDef->chanTypes[i]+GUI_COLOR_CHANNEL_FM])); - ImGui::SmallButton("##ChanTypeColorThing"); - if (ichannels-1) ImGui::SameLine(); - ImGui::PopStyleColor(); - } -} - void FurnaceGUI::drawSysManager() { if (nextWindow==GUI_WINDOW_SYS_MANAGER) { sysManagerOpen=true; @@ -100,9 +91,10 @@ void FurnaceGUI::drawSysManager() { if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary) && isNotCollapsed && settings.chipManagerTooltip) { if (e->song.system[i]!=DIV_SYSTEM_NULL) { const DivSysDef* sysDef=e->getSystemDef(e->song.system[i]); - if (ImGui::BeginTooltip()) { // why not SetTooltip()? so i can wrap the text + if (ImGui::BeginTooltip()) { ImGui::PushTextWrapPos(ImGui::GetCursorPos().x+420); // arbitrary constant ImGui::TextWrapped("%s",sysDef->description); + drawSystemChannelInfoText(sysDef); ImGui::PopTextWrapPos(); if (settings.sysTooltipChannelColors) drawSystemChannelInfo(sysDef); ImGui::EndTooltip(); diff --git a/src/gui/sysPartNumber.cpp b/src/gui/sysMiscInfo.cpp similarity index 79% rename from src/gui/sysPartNumber.cpp rename to src/gui/sysMiscInfo.cpp index 1ce6e2f38..c6ea7d8b7 100644 --- a/src/gui/sysPartNumber.cpp +++ b/src/gui/sysMiscInfo.cpp @@ -18,6 +18,9 @@ */ #include "gui.h" +#include "guiConst.h" +#include "misc/cpp/imgui_stdlib.h" +#include const char* FurnaceGUI::getSystemPartNumber(DivSystem sys, DivConfig& flags) { switch (sys) { @@ -284,3 +287,63 @@ const char* FurnaceGUI::getSystemPartNumber(DivSystem sys, DivConfig& flags) { break; } } + +void FurnaceGUI::drawSystemChannelInfo(const DivSysDef* whichDef) { + for (int i=0; ichannels; i++) { + ImGui::PushStyleColor(ImGuiCol_Button,ImGui::GetColorU32(uiColors[whichDef->chanTypes[i]+GUI_COLOR_CHANNEL_FM])); + ImGui::SmallButton("##ChanTypeColorThing"); + if (ichannels-1) ImGui::SameLine(); + ImGui::PopStyleColor(); + } +} + +void FurnaceGUI::drawSystemChannelInfoText(const DivSysDef* whichDef) { + String info=""; + unsigned char chanCount[8]={0,0,0,0,0,0,0,0}; + for (int i=0; ichannels; i++) { + switch (whichDef->chanInsType[i][0]) { + case DIV_INS_STD: // square + switch (whichDef->chanTypes[i]) { + case DIV_CH_NOISE: + chanCount[2]++; + break; + default: // DIV_CH_PULSE ? + chanCount[5]++; + break; + } + break; + case DIV_INS_NES: + if (whichDef->chanTypes[i]==DIV_CH_WAVE) { + chanCount[6]++; // trianlge + } else { + chanCount[whichDef->chanTypes[i]]++; + } + break; + case DIV_INS_C64: + case DIV_INS_TIA: + case DIV_INS_PET: + case DIV_INS_SU: + chanCount[7]++; + break; + default: + chanCount[whichDef->chanTypes[i]]++; + break; + } + } + for (int i=0; i<8; i++) { + if (chanCount[i]==0) continue; + if (info.length()!=0) { + info+=", "; + } + if (i==7) { + if (chanCount[i]>1) { + info+=fmt::sprintf("%d %s",chanCount[i],chanNames[8]); + } else { + info+=fmt::sprintf("%d %s",chanCount[i],chanNames[7]); + } + continue; + } + info+=fmt::sprintf("%d x %s",chanCount[i],chanNames[i]); + } + ImGui::Text("%s",info.c_str()); +}