Merge pull request #1160 from YohananDiamond/command-palette

undefined

WAHAHA nice one GitHub
see? that's why I hate JavaScript. couldn't you throw exception on out of bounds/undefined result, like EVERY normal language?
This commit is contained in:
tildearrow 2024-02-07 02:53:33 -05:00 committed by GitHub
commit a6aa4b66d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 465 additions and 98 deletions

View file

@ -2264,6 +2264,17 @@ int FurnaceGUI::load(String path) {
return 0;
}
void FurnaceGUI::openRecentFile(String path) {
if (modified) {
nextFile=path;
showWarning("Unsaved changes! Save changes before opening file?",GUI_WARN_OPEN_DROP);
} else {
if (load(path)>0) {
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
}
}
}
void FurnaceGUI::pushRecentFile(String path) {
if (path.empty()) return;
if (path.find(backupPath)==0) return;
@ -4126,10 +4137,8 @@ bool FurnaceGUI::loop() {
} else {
recentFile.erase(i);
i--;
if (load(item)>0) {
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
}
}
openRecentFile(item);
}
}
if (recentFile.empty()) {
@ -4382,6 +4391,8 @@ bool FurnaceGUI::loop() {
ImGui::EndMenu();
}
if (ImGui::BeginMenu(settings.capitalMenuBar?"Window":"window")) {
if (ImGui::MenuItem("command palette",BIND_FOR(GUI_ACTION_COMMAND_PALETTE)))
displayPalette=true;
if (ImGui::MenuItem("song information",BIND_FOR(GUI_ACTION_WINDOW_SONG_INFO),songInfoOpen)) songInfoOpen=!songInfoOpen;
if (ImGui::MenuItem("subsongs",BIND_FOR(GUI_ACTION_WINDOW_SUBSONGS),subSongsOpen)) subSongsOpen=!subSongsOpen;
if (ImGui::MenuItem("speed",BIND_FOR(GUI_ACTION_WINDOW_SPEED),speedOpen)) speedOpen=!speedOpen;
@ -5437,6 +5448,15 @@ bool FurnaceGUI::loop() {
}
}
if (displayPalette) {
paletteSearchResults.clear();
paletteQuery="";
paletteFirstFrame=true;
curPaletteChoice=0;
displayPalette=false;
ImGui::OpenPopup("Command Palette");
}
if (displayExport) {
displayExport=false;
ImGui::OpenPopup("Export");
@ -5483,6 +5503,14 @@ bool FurnaceGUI::loop() {
ImGui::EndPopup();
}
ImVec2 wsize=ImVec2(canvasW*0.9,canvasH*0.4);
ImGui::SetNextWindowPos(ImVec2((canvasW-wsize.x)*0.5,50*dpiScale));
ImGui::SetNextWindowSize(wsize,ImGuiCond_Always);
if (ImGui::BeginPopup("Command Palette",ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings)) {
drawPalette();
ImGui::EndPopup();
}
if (ImGui::BeginPopupModal("Export",NULL,ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollWithMouse|ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::SetWindowPos(ImVec2(((canvasW)-ImGui::GetWindowSize().x)*0.5,((canvasH)-ImGui::GetWindowSize().y)*0.5));
drawExport();
@ -7289,6 +7317,7 @@ FurnaceGUI::FurnaceGUI():
oldWantCaptureKeyboard(false),
displayMacroMenu(false),
displayNew(false),
displayPalette(false),
fullScreen(false),
preserveChanPos(false),
wantScrollList(false),
@ -7409,6 +7438,8 @@ FurnaceGUI::FurnaceGUI():
oldBar(-1),
curGroove(-1),
exitDisabledTimer(0),
curPaletteChoice(0),
curPaletteType(0),
soloTimeout(0.0f),
exportFadeOut(5.0),
patExtraButtons(false),