woah it works so god

This commit is contained in:
Eknous-P 2024-03-22 15:20:24 +04:00
parent aa99375eda
commit 955862c877
5 changed files with 68 additions and 11 deletions

View file

@ -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

View file

@ -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);

View file

@ -240,6 +240,7 @@ const char* chanNames[]={
"Wavetable",
"Sample",
"Square",
"Triangle",
"Channel", // if neither
"Channels"
};

View file

@ -23,15 +23,6 @@
#include <fmt/printf.h>
#include <imgui.h>
void FurnaceGUI::drawSystemChannelInfo(const DivSysDef* whichDef) {
for (int i=0; i<whichDef->channels; i++) {
ImGui::PushStyleColor(ImGuiCol_Button,ImGui::GetColorU32(uiColors[whichDef->chanTypes[i]+GUI_COLOR_CHANNEL_FM]));
ImGui::SmallButton("##ChanTypeColorThing");
if (i<whichDef->channels-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();

View file

@ -18,6 +18,9 @@
*/
#include "gui.h"
#include "guiConst.h"
#include "misc/cpp/imgui_stdlib.h"
#include <fmt/printf.h>
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; i<whichDef->channels; i++) {
ImGui::PushStyleColor(ImGuiCol_Button,ImGui::GetColorU32(uiColors[whichDef->chanTypes[i]+GUI_COLOR_CHANNEL_FM]));
ImGui::SmallButton("##ChanTypeColorThing");
if (i<whichDef->channels-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; i<whichDef->channels; 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());
}