[nostalgia/studio] Get save working
This commit is contained in:
@@ -39,14 +39,14 @@ StudioUI::StudioUI(core::Context *ctx) noexcept {
|
||||
if (!err) {
|
||||
oxIgnoreError(openProject(config.projectPath));
|
||||
for (const auto &f : config.openFiles) {
|
||||
auto err = openFile(f);
|
||||
if (err) {
|
||||
oxErrorf("Could not open editor: {}\n", err.msg);
|
||||
auto openFileErr = openFile(f);
|
||||
if (openFileErr) {
|
||||
oxErrorf("Could not open editor: {}\n", toStr(openFileErr));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (err.msg) {
|
||||
oxErrf("Could not open studio config file: {}\n", err.msg);
|
||||
if (toStr(err)) {
|
||||
oxErrf("Could not open studio config file: {}\n", toStr(err));
|
||||
} else {
|
||||
oxErrf("Could not open studio config file: {} ({}:{})\n", err.errCode, err.file, err.line);
|
||||
}
|
||||
@@ -83,7 +83,8 @@ void StudioUI::drawMenu() noexcept {
|
||||
if (ImGui::MenuItem("Open Project...", "Ctrl+O")) {
|
||||
m_taskRunner.add(new FileDialogManager(this, &StudioUI::openProject));
|
||||
}
|
||||
if (ImGui::MenuItem("Save", "Ctrl+S", false, m_saveEnabled)) {
|
||||
if (ImGui::MenuItem("Save", "Ctrl+S", false, m_acitveEditor && m_acitveEditor->unsavedChanges())) {
|
||||
m_acitveEditor->save();
|
||||
}
|
||||
if (ImGui::MenuItem("Quit", "Ctrl+Q")) {
|
||||
oxIgnoreError(core::shutdown(m_ctx));
|
||||
@@ -92,14 +93,14 @@ void StudioUI::drawMenu() noexcept {
|
||||
}
|
||||
if (ImGui::BeginMenu("Edit")) {
|
||||
auto undoStack = m_acitveEditor ? m_acitveEditor->undoStack() : nullptr;
|
||||
if (ImGui::MenuItem("Undo", "Ctrl+Z", false, undoStack)) {
|
||||
if (ImGui::MenuItem("Undo", "Ctrl+Z", false, undoStack && undoStack->canUndo())) {
|
||||
m_acitveEditor->undoStack()->undo();
|
||||
}
|
||||
if (ImGui::MenuItem("Redo", "Ctrl+Y", false, undoStack)) {
|
||||
if (ImGui::MenuItem("Redo", "Ctrl+Y", false, undoStack && undoStack->canRedo())) {
|
||||
m_acitveEditor->undoStack()->redo();
|
||||
}
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Copy", "Ctrl+N")) {
|
||||
if (ImGui::MenuItem("Copy", "Ctrl+C")) {
|
||||
}
|
||||
if (ImGui::MenuItem("Cut", "Ctrl+X")) {
|
||||
}
|
||||
@@ -139,7 +140,11 @@ void StudioUI::drawToolbar() noexcept {
|
||||
m_taskRunner.add(new FileDialogManager(this, &StudioUI::openProject));
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Button("Save##MainToolbar##MainWindow", ImVec2(BtnWidth, BtnHeight));
|
||||
if (ImGui::Button("Save##MainToolbar##MainWindow", ImVec2(BtnWidth, BtnHeight))) {
|
||||
if (m_acitveEditor) {
|
||||
m_acitveEditor->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user