command palette: "add chip" menu
This commit is contained in:
parent
4f83fc2e93
commit
7e9edb59f7
5 changed files with 47 additions and 1 deletions
|
|
@ -62,6 +62,9 @@ void FurnaceGUI::drawPalette() {
|
|||
case CMDPAL_TYPE_INSTRUMENT_CHANGE:
|
||||
hint="Search instruments (to change to)...";
|
||||
break;
|
||||
case CMDPAL_TYPE_ADD_CHIP:
|
||||
hint="Search chip (to add)...";
|
||||
break;
|
||||
}
|
||||
|
||||
if (ImGui::InputTextWithHint("##CommandPaletteSearch",hint,&paletteQuery) || paletteFirstFrame) {
|
||||
|
|
@ -99,13 +102,22 @@ void FurnaceGUI::drawPalette() {
|
|||
|
||||
case CMDPAL_TYPE_SAMPLES:
|
||||
for (int i=0; i<e->song.sampleLen; i++) {
|
||||
logD("ins #%x: %s", i, e->song.sample[i]->name.c_str());
|
||||
if (matchFuzzy(e->song.sample[i]->name.c_str(),paletteQuery.c_str())) {
|
||||
paletteSearchResults.push_back(i);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CMDPAL_TYPE_ADD_CHIP:
|
||||
for (int i=0; availableSystems[i]; i++) {
|
||||
int ds=availableSystems[i];
|
||||
const char* sysname=getSystemName((DivSystem)ds);
|
||||
if (matchFuzzy(sysname,paletteQuery.c_str())) {
|
||||
paletteSearchResults.push_back(ds);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
logE("invalid command palette type");
|
||||
ImGui::CloseCurrentPopup();
|
||||
|
|
@ -127,6 +139,15 @@ void FurnaceGUI::drawPalette() {
|
|||
navigated=true;
|
||||
}
|
||||
|
||||
if (paletteSearchResults.size()>0 && curPaletteChoice<0) {
|
||||
curPaletteChoice=0;
|
||||
navigated=true;
|
||||
}
|
||||
if (curPaletteChoice>=(int)paletteSearchResults.size()) {
|
||||
curPaletteChoice=paletteSearchResults.size()-1;
|
||||
navigated=true;
|
||||
}
|
||||
|
||||
for (int i=0; i<(int)paletteSearchResults.size(); i++) {
|
||||
bool current=(i==curPaletteChoice);
|
||||
int id=paletteSearchResults[i];
|
||||
|
|
@ -150,6 +171,9 @@ void FurnaceGUI::drawPalette() {
|
|||
case CMDPAL_TYPE_SAMPLES:
|
||||
s=e->song.sample[id]->name.c_str();
|
||||
break;
|
||||
case CMDPAL_TYPE_ADD_CHIP:
|
||||
s=getSystemName((DivSystem)id);
|
||||
break;
|
||||
default:
|
||||
logE("invalid command palette type");
|
||||
break;
|
||||
|
|
@ -203,6 +227,21 @@ void FurnaceGUI::drawPalette() {
|
|||
doChangeIns(i-1);
|
||||
break;
|
||||
|
||||
case CMDPAL_TYPE_ADD_CHIP:
|
||||
if (i!=DIV_SYSTEM_NULL) {
|
||||
if (!e->addSystem((DivSystem)i)) {
|
||||
showError("cannot add chip! ("+e->getLastError()+")");
|
||||
} else {
|
||||
MARK_MODIFIED;
|
||||
}
|
||||
ImGui::CloseCurrentPopup();
|
||||
if (e->song.autoSystem) {
|
||||
autoDetectSystem();
|
||||
}
|
||||
updateWindowTitle();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
logE("invalid command palette type");
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue