GUI: colored channe names

This commit is contained in:
tildearrow 2021-12-23 17:09:33 -05:00
parent 5bef7934d7
commit 830e880a57
4 changed files with 81 additions and 2 deletions

View File

@ -226,6 +226,20 @@ const char* chanShortNames[11][17]={
{"F1", "O1", "O2", "O3", "O4", "F3", "F4", "S1", "S2", "S3", "P1", "P2", "P3", "P4", "P5", "P6"}, // YM2610 (extended channel 2)
};
const int chanTypes[11][17]={
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}, // YMU759
{0, 0, 0, 0, 0, 0, 1, 1, 1, 2}, // Genesis
{0, 0, 5, 5, 5, 5, 0, 0, 0, 1, 1, 1, 2}, // Genesis (extended channel 3)
{1, 1, 1, 2}, // SMS
{1, 1, 3, 2}, // GB
{3, 3, 3, 3, 3, 3}, // PCE
{1, 1, 3, 2, 4}, // NES
{2, 2, 2}, // C64
{0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4}, // Arcade
{0, 0, 0, 0, 1, 1, 1, 4, 4, 4, 4, 4, 4}, // YM2610
{0, 5, 5, 5, 5, 0, 0, 1, 1, 1, 4, 4, 4, 4, 4, 4}, // YM2610 (extended channel 2)
};
const char* DivEngine::getChannelName(int chan) {
switch (song.system) {
case DIV_SYSTEM_NULL: case DIV_SYSTEM_YMU759:
@ -304,6 +318,45 @@ const char* DivEngine::getChannelShortName(int chan) {
return "??";
}
int DivEngine::getChannelType(int chan) {
switch (song.system) {
case DIV_SYSTEM_NULL: case DIV_SYSTEM_YMU759:
return chanTypes[0][chan];
break;
case DIV_SYSTEM_GENESIS:
return chanTypes[1][chan];
break;
case DIV_SYSTEM_GENESIS_EXT:
return chanTypes[2][chan];
break;
case DIV_SYSTEM_SMS:
return chanTypes[3][chan];
break;
case DIV_SYSTEM_GB:
return chanTypes[4][chan];
break;
case DIV_SYSTEM_PCE:
return chanTypes[5][chan];
break;
case DIV_SYSTEM_NES:
return chanTypes[6][chan];
break;
case DIV_SYSTEM_C64_6581: case DIV_SYSTEM_C64_8580:
return chanTypes[7][chan];
break;
case DIV_SYSTEM_ARCADE:
return chanTypes[8][chan];
break;
case DIV_SYSTEM_YM2610:
return chanTypes[9][chan];
break;
case DIV_SYSTEM_YM2610_EXT:
return chanTypes[10][chan];
break;
}
return 1;
}
int DivEngine::getMaxVolume() {
switch (song.system) {
case DIV_SYSTEM_PCE:

View File

@ -173,6 +173,15 @@ class DivEngine {
// get sys channel count
int getChannelCount(DivSystem sys);
// get channel type
// - 0: FM
// - 1: pulse
// - 2: noise
// - 3: wave/other
// - 4: PCM
// - 5: FM operator
int getChannelType(int ch);
// get sys name
const char* getSystemName(DivSystem sys);

View File

@ -1023,9 +1023,22 @@ void FurnaceGUI::drawPattern() {
for (int i=0; i<chans; i++) {
ImGui::TableNextColumn();
snprintf(chanID,256," %s##_CH%d",e->getChannelName(i),i);
if (ImGui::Selectable(chanID,!e->isChannelMuted(i),ImGuiSelectableFlags_NoPadWithHalfSpacing,ImVec2(0.0f,lineHeight+1.0f*dpiScale))) {
bool muted=e->isChannelMuted(i);
ImVec4 chanHead=muted?uiColors[GUI_COLOR_CHANNEL_MUTED]:uiColors[GUI_COLOR_CHANNEL_FM+e->getChannelType(i)];
ImVec4 chanHeadActive=chanHead;
ImVec4 chanHeadHover=chanHead;
chanHead.x*=0.25; chanHead.y*=0.25; chanHead.z*=0.25;
chanHeadActive.x*=0.8; chanHeadActive.y*=0.8; chanHeadActive.z*=0.8;
chanHeadHover.x*=0.4; chanHeadHover.y*=0.4; chanHeadHover.z*=0.4;
ImGui::PushStyleColor(ImGuiCol_Header,chanHead);
ImGui::PushStyleColor(ImGuiCol_HeaderActive,chanHeadActive);
ImGui::PushStyleColor(ImGuiCol_HeaderHovered,chanHeadHover);
if (muted) ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_CHANNEL_MUTED]);
if (ImGui::Selectable(chanID,!muted,ImGuiSelectableFlags_NoPadWithHalfSpacing,ImVec2(0.0f,lineHeight+1.0f*dpiScale))) {
e->toggleMute(i);
}
if (muted) ImGui::PopStyleColor();
ImGui::PopStyleColor(3);
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
e->toggleSolo(i);
}
@ -2471,10 +2484,12 @@ FurnaceGUI::FurnaceGUI():
uiColors[GUI_COLOR_BACKGROUND]=ImVec4(0.1f,0.1f,0.1f,1.0f);
uiColors[GUI_COLOR_FRAME_BACKGROUND]=ImVec4(0.0f,0.0f,0.0f,0.85f);
uiColors[GUI_COLOR_CHANNEL_FM]=ImVec4(0.2f,0.8f,1.0f,1.0f);
uiColors[GUI_COLOR_CHANNEL_PULSE]=ImVec4(0.3f,1.0f,0.2f,1.0f);
uiColors[GUI_COLOR_CHANNEL_PULSE]=ImVec4(0.4f,1.0f,0.2f,1.0f);
uiColors[GUI_COLOR_CHANNEL_NOISE]=ImVec4(0.8f,0.8f,0.8f,1.0f);
uiColors[GUI_COLOR_CHANNEL_PCM]=ImVec4(1.0f,0.9f,0.2f,1.0f);
uiColors[GUI_COLOR_CHANNEL_WAVE]=ImVec4(1.0f,0.5f,0.2f,1.0f);
uiColors[GUI_COLOR_CHANNEL_OP]=ImVec4(0.2f,0.4f,1.0f,1.0f);
uiColors[GUI_COLOR_CHANNEL_MUTED]=ImVec4(0.5f,0.5f,0.5f,1.0f);
uiColors[GUI_COLOR_PATTERN_CURSOR]=ImVec4(0.1f,0.3f,0.5f,1.0f);
uiColors[GUI_COLOR_PATTERN_CURSOR_HOVER]=ImVec4(0.2f,0.4f,0.6f,1.0f);
uiColors[GUI_COLOR_PATTERN_CURSOR_ACTIVE]=ImVec4(0.2f,0.5f,0.7f,1.0f);

View File

@ -16,6 +16,8 @@ enum FurnaceGUIColors {
GUI_COLOR_CHANNEL_NOISE,
GUI_COLOR_CHANNEL_WAVE,
GUI_COLOR_CHANNEL_PCM,
GUI_COLOR_CHANNEL_OP,
GUI_COLOR_CHANNEL_MUTED,
GUI_COLOR_PATTERN_CURSOR,
GUI_COLOR_PATTERN_CURSOR_HOVER,
GUI_COLOR_PATTERN_CURSOR_ACTIVE,