Skip to content

Commit 69010b8

Browse files
committed
[frontend] Support CTRL+S, CTRL+SHIFT+S keyboard shortcuts
Save, Save As respectively
1 parent 198d0d2 commit 69010b8

File tree

9 files changed

+59
-2
lines changed

9 files changed

+59
-2
lines changed

source/frontend/editors/BblmEditor.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ class BblmEditor : public frontend::StudioWindow, public IEditor {
4949
setName("BBLM Editor: " + m_path);
5050
m_sheet.Draw([&]() { m_grid.Draw(); });
5151
m_history.update(m_grid.m_blm);
52+
if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_S, ImGuiInputFlags_Repeat)) {
53+
saveButton();
54+
} else if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_S,
55+
ImGuiInputFlags_Repeat)) {
56+
saveAsButton();
57+
}
5258
}
5359
ImGuiID buildDock(ImGuiID root_id) override {
5460
// ImGui::DockBuilderDockWindow("Properties", root_id);

source/frontend/editors/BdofEditor.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ class BdofEditor : public frontend::StudioWindow, public IEditor {
8181
}
8282

8383
m_history.update(m_grid.m_dof);
84+
if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_S, ImGuiInputFlags_Repeat)) {
85+
saveButton();
86+
} else if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_S,
87+
ImGuiInputFlags_Repeat)) {
88+
saveAsButton();
89+
}
8490
}
8591
ImGuiID buildDock(ImGuiID root_id) override {
8692
// ImGui::DockBuilderDockWindow("Properties", root_id);

source/frontend/editors/BfgEditor.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ class BfgEditor : public frontend::StudioWindow, public IEditor {
122122
ImGui::End();
123123

124124
m_history.update(m_bfg);
125+
if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_S, ImGuiInputFlags_Repeat)) {
126+
saveButton();
127+
} else if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_S,
128+
ImGuiInputFlags_Repeat)) {
129+
saveAsButton();
130+
}
125131
}
126132
ImGuiID buildDock(ImGuiID root_id) override {
127133
ImGuiID next = root_id;

source/frontend/editors/BlightEditor.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ class BlightEditor : public frontend::StudioWindow, public IEditor {
174174
ImGui::End();
175175

176176
m_history.update(m_blight);
177+
if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_S, ImGuiInputFlags_Repeat)) {
178+
saveButton();
179+
} else if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_S,
180+
ImGuiInputFlags_Repeat)) {
181+
saveAsButton();
182+
}
177183
}
178184
ImGuiID buildDock(ImGuiID root_id) override {
179185
ImGuiID next = root_id;

source/frontend/editors/BlmapEditor.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ class BlmapEditor : public frontend::StudioWindow, public IEditor {
126126
ImGui::End();
127127

128128
m_history.update(m_blmap);
129+
if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_S, ImGuiInputFlags_Repeat)) {
130+
saveButton();
131+
} else if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_S,
132+
ImGuiInputFlags_Repeat)) {
133+
saveAsButton();
134+
}
129135
}
130136
ImGuiID buildDock(ImGuiID root_id) override {
131137
ImGuiID next = root_id;

source/frontend/editors/JpaEditor.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,13 @@ class JpaEditor : public frontend::StudioWindow, public IEditor {
375375
ImGui::End();
376376

377377
// m_history.update(m_jpa);
378+
379+
if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_S, ImGuiInputFlags_Repeat)) {
380+
saveButton();
381+
} else if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_S,
382+
ImGuiInputFlags_Repeat)) {
383+
saveAsButton();
384+
}
378385
}
379386

380387
ImGuiID buildDock(ImGuiID root_id) override {

source/frontend/editors/RarcEditor.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ class RarcEditor : public frontend::StudioWindow, public IEditor {
8181
void draw_() override {
8282
setName("RARC Editor: " + m_path);
8383
m_sheet.Draw([&]() { m_grid.Draw(m_rarc, this); });
84+
if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_S, ImGuiInputFlags_Repeat)) {
85+
saveButton();
86+
} else if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_S,
87+
ImGuiInputFlags_Repeat)) {
88+
saveAsButton();
89+
}
8490
}
8591
ImGuiID buildDock(ImGuiID root_id) override {
8692
// ImGui::DockBuilderDockWindow("Properties", root_id);

source/frontend/legacy_editor/EditorWindow.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ void BRRESEditor::draw_() {
280280
} else if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_Y,
281281
ImGuiInputFlags_Repeat)) {
282282
mHistory.redo(*mRoot, mSelection);
283+
} else if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_S,
284+
ImGuiInputFlags_Repeat)) {
285+
saveButton();
286+
} else if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_S,
287+
ImGuiInputFlags_Repeat)) {
288+
saveAsButton();
283289
}
284290
}
285291

@@ -430,6 +436,12 @@ void BMDEditor::draw_() {
430436
} else if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_Y,
431437
ImGuiInputFlags_Repeat)) {
432438
mHistory.redo(*mRoot, mSelection);
439+
} else if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_S,
440+
ImGuiInputFlags_Repeat)) {
441+
saveButton();
442+
} else if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_S,
443+
ImGuiInputFlags_Repeat)) {
444+
saveAsButton();
433445
}
434446
}
435447
void BMDEditor::saveAsImpl(std::string path) {

source/frontend/root.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,13 @@ void RootWindow::drawFileMenu() {
264264
mFileHost.openFile();
265265
}
266266
#endif
267-
if (ImGui::MenuItem("Save"_j)) {
267+
auto saveStr = "Save"_j + std::string(" (Ctrl+S)");
268+
if (ImGui::MenuItem(saveStr.c_str())) {
268269
saveButton();
269270
}
270271
#if !defined(__EMSCRIPTEN__)
271-
if (ImGui::MenuItem("Save As"_j)) {
272+
auto saveAsStr = "Save As"_j + std::string(" (Ctrl+Shift+S)");
273+
if (ImGui::MenuItem(saveAsStr.c_str())) {
272274
saveAsButton();
273275
}
274276
#endif

0 commit comments

Comments
 (0)