GUI: add an effect list window

This commit is contained in:
tildearrow 2022-04-19 18:44:05 -05:00
parent b6026e76c5
commit d4380e1524
11 changed files with 161 additions and 65 deletions

View file

@ -393,6 +393,7 @@ src/gui/debugWindow.cpp
src/gui/doAction.cpp
src/gui/editing.cpp
src/gui/editControls.cpp
src/gui/effectList.cpp
src/gui/insEdit.cpp
src/gui/log.cpp
src/gui/mixer.cpp

View file

@ -41,7 +41,7 @@ void process(void* u, float** in, float** out, int inChans, int outChans, unsign
((DivEngine*)u)->nextBuf(in,out,inChans,outChans,size);
}
const char* DivEngine::getEffectDesc(unsigned char effect, int chan) {
const char* DivEngine::getEffectDesc(unsigned char effect, int chan, bool notNull) {
switch (effect) {
case 0x00:
return "00xy: Arpeggio";
@ -116,14 +116,13 @@ const char* DivEngine::getEffectDesc(unsigned char effect, int chan) {
default:
if ((effect&0xf0)==0x90) {
return "9xxx: Set sample offset*256";
}
else if (chan>=0 && chan<chans) {
} else if (chan>=0 && chan<chans) {
const char* ret=disCont[dispatchOfChan[chan]].dispatch->getEffectName(effect);
if (ret!=NULL) return ret;
}
break;
}
return "Invalid effect";
return notNull?"Invalid effect":NULL;
}
void DivEngine::walkSong(int& loopOrder, int& loopRow, int& loopEnd) {

View file

@ -402,7 +402,7 @@ class DivEngine {
int getTotalChannelCount();
// get effect description
const char* getEffectDesc(unsigned char effect, int chan);
const char* getEffectDesc(unsigned char effect, int chan, bool notNull=false);
// get channel type
// - 0: FM

View file

@ -213,6 +213,9 @@ void FurnaceGUI::doAction(int what) {
case GUI_ACTION_WINDOW_LOG:
nextWindow=GUI_WINDOW_LOG;
break;
case GUI_ACTION_WINDOW_EFFECT_LIST:
nextWindow=GUI_WINDOW_EFFECT_LIST;
break;
case GUI_ACTION_COLLAPSE_WINDOW:
collapseWindow=true;
@ -285,6 +288,12 @@ void FurnaceGUI::doAction(int what) {
case GUI_WINDOW_REGISTER_VIEW:
regViewOpen=false;
break;
case GUI_WINDOW_LOG:
logOpen=false;
break;
case GUI_WINDOW_EFFECT_LIST:
effectListOpen=false;
break;
default:
break;
}

73
src/gui/effectList.cpp Normal file
View file

@ -0,0 +1,73 @@
#include "gui.h"
#include "guiConst.h"
#include <imgui.h>
void FurnaceGUI::drawEffectList() {
if (nextWindow==GUI_WINDOW_EFFECT_LIST) {
effectListOpen=true;
ImGui::SetNextWindowFocus();
nextWindow=GUI_WINDOW_NOTHING;
}
if (!effectListOpen) return;
if (ImGui::Begin("Effect List",&effectListOpen)) {
ImGui::Text("System at cursor: %s",e->getSystemName(e->sysOfChan[cursor.xCoarse]));
if (ImGui::BeginTable("effectList",2)) {
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableNextColumn();
ImGui::Text("Name");
ImGui::TableNextColumn();
ImGui::Text("Description");
const char* prevName=NULL;
for (int i=0; i<256; i++) {
const char* name=e->getEffectDesc(i,cursor.xCoarse);
if (name==prevName) {
continue;
}
prevName=name;
if (name!=NULL) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::PushFont(patFont);
if (i<0x10) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[fxColors[i]]);
} else if (i<0x20) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY]);
} else if (i<0x30) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY]);
} else if (i<0x48) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY]);
} else if (i<0x90) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_INVALID]);
} else if (i<0xa0) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_MISC]);
} else if (i<0xc0) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_INVALID]);
} else if (i<0xd0) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_SPEED]);
} else if (i<0xe0) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_INVALID]);
} else {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[extFxColors[i-0xe0]]);
}
ImGui::Text("%c%c%c%c",name[0],name[1],name[2],name[3]);
ImGui::PopStyleColor();
ImGui::PopFont();
ImGui::TableNextColumn();
if (strlen(name)>6) {
ImGui::TextWrapped("%s",&name[6]);
} else {
ImGui::Text("ERROR");
}
}
}
ImGui::EndTable();
}
}
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_EFFECT_LIST;
ImGui::End();
}

View file

@ -2523,6 +2523,7 @@ bool FurnaceGUI::loop() {
ImGui::EndMenu();
}
if (ImGui::BeginMenu("help")) {
if (ImGui::MenuItem("effect list",BIND_FOR(GUI_ACTION_WINDOW_EFFECT_LIST),effectListOpen)) effectListOpen=!effectListOpen;
if (ImGui::MenuItem("debug menu",BIND_FOR(GUI_ACTION_WINDOW_DEBUG))) debugOpen=!debugOpen;
if (ImGui::MenuItem("panic",BIND_FOR(GUI_ACTION_PANIC))) e->syncReset();
if (ImGui::MenuItem("about...",BIND_FOR(GUI_ACTION_WINDOW_ABOUT))) {
@ -2581,7 +2582,7 @@ bool FurnaceGUI::loop() {
default: // effect
int actualCursor=((cursor.xFine+1)&(~1));
if (p->data[cursor.y][actualCursor]>-1) {
info=e->getEffectDesc(p->data[cursor.y][actualCursor],cursor.xCoarse);
info=e->getEffectDesc(p->data[cursor.y][actualCursor],cursor.xCoarse,true);
hasInfo=true;
}
break;
@ -2626,6 +2627,7 @@ bool FurnaceGUI::loop() {
drawChannels();
drawRegView();
drawLog();
drawEffectList();
if (inspectorOpen) ImGui::ShowMetricsWindow(&inspectorOpen);
@ -3234,6 +3236,7 @@ bool FurnaceGUI::init() {
channelsOpen=e->getConfBool("channelsOpen",false);
regViewOpen=e->getConfBool("regViewOpen",false);
logOpen=e->getConfBool("logOpen",false);
effectListOpen=e->getConfBool("effectListOpen",false);
tempoView=e->getConfBool("tempoView",true);
waveHex=e->getConfBool("waveHex",false);
@ -3404,6 +3407,7 @@ bool FurnaceGUI::finish() {
e->setConf("channelsOpen",channelsOpen);
e->setConf("regViewOpen",regViewOpen);
e->setConf("logOpen",logOpen);
e->setConf("effectListOpen",effectListOpen);
// commit last window size
e->setConf("lastWindowWidth",scrW);
@ -3510,6 +3514,7 @@ FurnaceGUI::FurnaceGUI():
channelsOpen(false),
regViewOpen(false),
logOpen(false),
effectListOpen(false),
/*
editControlsDocked(false),
ordersDocked(false),
@ -3534,6 +3539,8 @@ FurnaceGUI::FurnaceGUI():
notesDocked(false),
channelsDocked(false),
regViewDocked(false),
logDocked(false),
effectListDocked(false),
*/
selecting(false),
curNibble(false),

View file

@ -225,7 +225,8 @@ enum FurnaceGUIWindows {
GUI_WINDOW_NOTES,
GUI_WINDOW_CHANNELS,
GUI_WINDOW_REGISTER_VIEW,
GUI_WINDOW_LOG
GUI_WINDOW_LOG,
GUI_WINDOW_EFFECT_LIST
};
enum FurnaceGUIFileDialogs {
@ -323,6 +324,7 @@ enum FurnaceGUIActions {
GUI_ACTION_WINDOW_CHANNELS,
GUI_ACTION_WINDOW_REGISTER_VIEW,
GUI_ACTION_WINDOW_LOG,
GUI_ACTION_WINDOW_EFFECT_LIST,
GUI_ACTION_COLLAPSE_WINDOW,
GUI_ACTION_CLOSE_WINDOW,
@ -915,13 +917,13 @@ class FurnaceGUI {
bool editControlsOpen, ordersOpen, insListOpen, songInfoOpen, patternOpen, insEditOpen;
bool waveListOpen, waveEditOpen, sampleListOpen, sampleEditOpen, aboutOpen, settingsOpen;
bool mixerOpen, debugOpen, inspectorOpen, oscOpen, volMeterOpen, statsOpen, compatFlagsOpen;
bool pianoOpen, notesOpen, channelsOpen, regViewOpen, logOpen;
bool pianoOpen, notesOpen, channelsOpen, regViewOpen, logOpen, effectListOpen;
/* there ought to be a better way...
bool editControlsDocked, ordersDocked, insListDocked, songInfoDocked, patternDocked, insEditDocked;
bool waveListDocked, waveEditDocked, sampleListDocked, sampleEditDocked, aboutDocked, settingsDocked;
bool mixerDocked, debugDocked, inspectorDocked, oscDocked, volMeterDocked, statsDocked, compatFlagsDocked;
bool pianoDocked, notesDocked, channelsDocked, regViewDocked;
bool pianoDocked, notesDocked, channelsDocked, regViewDocked, logDocked, effectListDocked;
*/
SelectionPoint selStart, selEnd, cursor;
@ -1128,6 +1130,7 @@ class FurnaceGUI {
void drawDebug();
void drawNewSong();
void drawLog();
void drawEffectList();
void parseKeybinds();
void promptKey(int which);

View file

@ -18,8 +18,8 @@
*/
// guiConst: constants used in the GUI like arrays, strings and other stuff
#include "guiConst.h"
#include "gui.h"
#include "guiConst.h"
#include "../engine/song.h"
const int opOrder[4]={
@ -138,6 +138,60 @@ const char* resampleStrats[]={
"best possible"
};
const FurnaceGUIColors fxColors[16]={
GUI_COLOR_PATTERN_EFFECT_MISC, // 00
GUI_COLOR_PATTERN_EFFECT_PITCH, // 01
GUI_COLOR_PATTERN_EFFECT_PITCH, // 02
GUI_COLOR_PATTERN_EFFECT_PITCH, // 03
GUI_COLOR_PATTERN_EFFECT_PITCH, // 04
GUI_COLOR_PATTERN_EFFECT_VOLUME, // 05
GUI_COLOR_PATTERN_EFFECT_VOLUME, // 06
GUI_COLOR_PATTERN_EFFECT_VOLUME, // 07
GUI_COLOR_PATTERN_EFFECT_PANNING, // 08
GUI_COLOR_PATTERN_EFFECT_SPEED, // 09
GUI_COLOR_PATTERN_EFFECT_VOLUME, // 0A
GUI_COLOR_PATTERN_EFFECT_SONG, // 0B
GUI_COLOR_PATTERN_EFFECT_TIME, // 0C
GUI_COLOR_PATTERN_EFFECT_SONG, // 0D
GUI_COLOR_PATTERN_EFFECT_INVALID, // 0E
GUI_COLOR_PATTERN_EFFECT_SPEED, // 0F
};
const FurnaceGUIColors extFxColors[32]={
GUI_COLOR_PATTERN_EFFECT_MISC, // E0
GUI_COLOR_PATTERN_EFFECT_PITCH, // E1
GUI_COLOR_PATTERN_EFFECT_PITCH, // E2
GUI_COLOR_PATTERN_EFFECT_MISC, // E3
GUI_COLOR_PATTERN_EFFECT_MISC, // E4
GUI_COLOR_PATTERN_EFFECT_PITCH, // E5
GUI_COLOR_PATTERN_EFFECT_INVALID, // E6
GUI_COLOR_PATTERN_EFFECT_INVALID, // E7
GUI_COLOR_PATTERN_EFFECT_INVALID, // E8
GUI_COLOR_PATTERN_EFFECT_INVALID, // E9
GUI_COLOR_PATTERN_EFFECT_MISC, // EA
GUI_COLOR_PATTERN_EFFECT_MISC, // EB
GUI_COLOR_PATTERN_EFFECT_TIME, // EC
GUI_COLOR_PATTERN_EFFECT_TIME, // ED
GUI_COLOR_PATTERN_EFFECT_SONG, // EE
GUI_COLOR_PATTERN_EFFECT_SONG, // EF
GUI_COLOR_PATTERN_EFFECT_SPEED, // F0
GUI_COLOR_PATTERN_EFFECT_PITCH, // F1
GUI_COLOR_PATTERN_EFFECT_PITCH, // F2
GUI_COLOR_PATTERN_EFFECT_VOLUME, // F3
GUI_COLOR_PATTERN_EFFECT_VOLUME, // F4
GUI_COLOR_PATTERN_EFFECT_INVALID, // F5
GUI_COLOR_PATTERN_EFFECT_INVALID, // F6
GUI_COLOR_PATTERN_EFFECT_INVALID, // F7
GUI_COLOR_PATTERN_EFFECT_VOLUME, // F8
GUI_COLOR_PATTERN_EFFECT_VOLUME, // F9
GUI_COLOR_PATTERN_EFFECT_VOLUME, // FA
GUI_COLOR_PATTERN_EFFECT_INVALID, // FB
GUI_COLOR_PATTERN_EFFECT_INVALID, // FC
GUI_COLOR_PATTERN_EFFECT_INVALID, // FD
GUI_COLOR_PATTERN_EFFECT_INVALID, // FE
GUI_COLOR_PATTERN_EFFECT_SONG, // FF
};
#define D FurnaceGUIActionDef
#define NOT_AN_ACTION -1
@ -193,6 +247,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={
D("WINDOW_CHANNELS", "Channels", 0),
D("WINDOW_REGISTER_VIEW", "Register View", 0),
D("WINDOW_LOG", "Log Viewer", 0),
D("EFFECT_LIST", "Effect List", 0),
D("COLLAPSE_WINDOW", "Collapse/expand current window", 0),
D("CLOSE_WINDOW", "Close current window", FURKMOD_SHIFT|SDLK_ESCAPE),

View file

@ -46,4 +46,6 @@ extern const int availableSystems[];
extern const FurnaceGUIActionDef guiActions[];
extern const FurnaceGUIColorDef guiColors[];
extern const int altValues[24];
extern const int vgmVersions[6];
extern const int vgmVersions[6];
extern const FurnaceGUIColors fxColors[16];
extern const FurnaceGUIColors extFxColors[32];

View file

@ -92,5 +92,6 @@ void FurnaceGUI::drawLog() {
ImGui::EndTable();
}
}
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_LOG;
ImGui::End();
}

View file

@ -27,60 +27,6 @@
#include "guiConst.h"
#include <fmt/printf.h>
const FurnaceGUIColors fxColors[16]={
GUI_COLOR_PATTERN_EFFECT_MISC, // 00
GUI_COLOR_PATTERN_EFFECT_PITCH, // 01
GUI_COLOR_PATTERN_EFFECT_PITCH, // 02
GUI_COLOR_PATTERN_EFFECT_PITCH, // 03
GUI_COLOR_PATTERN_EFFECT_PITCH, // 04
GUI_COLOR_PATTERN_EFFECT_VOLUME, // 05
GUI_COLOR_PATTERN_EFFECT_VOLUME, // 06
GUI_COLOR_PATTERN_EFFECT_VOLUME, // 07
GUI_COLOR_PATTERN_EFFECT_PANNING, // 08
GUI_COLOR_PATTERN_EFFECT_SPEED, // 09
GUI_COLOR_PATTERN_EFFECT_VOLUME, // 0A
GUI_COLOR_PATTERN_EFFECT_SONG, // 0B
GUI_COLOR_PATTERN_EFFECT_TIME, // 0C
GUI_COLOR_PATTERN_EFFECT_SONG, // 0D
GUI_COLOR_PATTERN_EFFECT_INVALID, // 0E
GUI_COLOR_PATTERN_EFFECT_SPEED, // 0F
};
const FurnaceGUIColors extFxColors[32]={
GUI_COLOR_PATTERN_EFFECT_MISC, // E0
GUI_COLOR_PATTERN_EFFECT_PITCH, // E1
GUI_COLOR_PATTERN_EFFECT_PITCH, // E2
GUI_COLOR_PATTERN_EFFECT_MISC, // E3
GUI_COLOR_PATTERN_EFFECT_MISC, // E4
GUI_COLOR_PATTERN_EFFECT_PITCH, // E5
GUI_COLOR_PATTERN_EFFECT_INVALID, // E6
GUI_COLOR_PATTERN_EFFECT_INVALID, // E7
GUI_COLOR_PATTERN_EFFECT_INVALID, // E8
GUI_COLOR_PATTERN_EFFECT_INVALID, // E9
GUI_COLOR_PATTERN_EFFECT_MISC, // EA
GUI_COLOR_PATTERN_EFFECT_MISC, // EB
GUI_COLOR_PATTERN_EFFECT_TIME, // EC
GUI_COLOR_PATTERN_EFFECT_TIME, // ED
GUI_COLOR_PATTERN_EFFECT_SONG, // EE
GUI_COLOR_PATTERN_EFFECT_SONG, // EF
GUI_COLOR_PATTERN_EFFECT_SPEED, // F0
GUI_COLOR_PATTERN_EFFECT_PITCH, // F1
GUI_COLOR_PATTERN_EFFECT_PITCH, // F2
GUI_COLOR_PATTERN_EFFECT_VOLUME, // F3
GUI_COLOR_PATTERN_EFFECT_VOLUME, // F4
GUI_COLOR_PATTERN_EFFECT_INVALID, // F5
GUI_COLOR_PATTERN_EFFECT_INVALID, // F6
GUI_COLOR_PATTERN_EFFECT_INVALID, // F7
GUI_COLOR_PATTERN_EFFECT_VOLUME, // F8
GUI_COLOR_PATTERN_EFFECT_VOLUME, // F9
GUI_COLOR_PATTERN_EFFECT_VOLUME, // FA
GUI_COLOR_PATTERN_EFFECT_INVALID, // FB
GUI_COLOR_PATTERN_EFFECT_INVALID, // FC
GUI_COLOR_PATTERN_EFFECT_INVALID, // FD
GUI_COLOR_PATTERN_EFFECT_INVALID, // FE
GUI_COLOR_PATTERN_EFFECT_SONG, // FF
};
inline float randRange(float min, float max) {
return min+((float)rand()/(float)RAND_MAX)*(max-min);
}