From 9b1275e704073eef63efaad92e3ce6bd45634336 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Mon, 21 Feb 2022 20:00:21 -0600 Subject: [PATCH] [nostalgia/core/studio] Add support for TileSheetEditor unsaved changes status --- src/nostalgia/core/studio/tilesheeteditor-imgui.cpp | 9 ++++++++- src/nostalgia/core/studio/tilesheeteditor-imgui.hpp | 8 ++------ src/nostalgia/core/studio/tilesheeteditormodel.hpp | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp b/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp index 22dc27b7..12aeaf7d 100644 --- a/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp @@ -17,6 +17,7 @@ TileSheetEditorImGui::TileSheetEditorImGui(Context *ctx, const ox::String &path) m_itemPath = path; const auto lastSlash = std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset(); m_itemName = m_itemPath.substr(lastSlash + 1); + undoStack()->changeTriggered.connect(this, &TileSheetEditorImGui::markUnsavedChanges); } ox::String TileSheetEditorImGui::itemName() const noexcept { @@ -142,4 +143,10 @@ void TileSheetEditorImGui::drawPalettePicker() noexcept { } } -} \ No newline at end of file +ox::Error TileSheetEditorImGui::markUnsavedChanges() noexcept { + oxDebug("markUnsavedChanges"); + setUnsavedChanges(true); + return OxError(0); +} + +} diff --git a/src/nostalgia/core/studio/tilesheeteditor-imgui.hpp b/src/nostalgia/core/studio/tilesheeteditor-imgui.hpp index f63d6547..2d62ab55 100644 --- a/src/nostalgia/core/studio/tilesheeteditor-imgui.hpp +++ b/src/nostalgia/core/studio/tilesheeteditor-imgui.hpp @@ -69,16 +69,12 @@ class TileSheetEditorImGui: public studio::Editor { void drawPalettePicker() noexcept; - // slots - public: - ox::Error colorSelected() noexcept; - - ox::Error setColorTable() noexcept; - // slots private: ox::Error updateAfterClicked() noexcept; + ox::Error markUnsavedChanges() noexcept; + }; } diff --git a/src/nostalgia/core/studio/tilesheeteditormodel.hpp b/src/nostalgia/core/studio/tilesheeteditormodel.hpp index 8e7b2255..28d1458d 100644 --- a/src/nostalgia/core/studio/tilesheeteditormodel.hpp +++ b/src/nostalgia/core/studio/tilesheeteditormodel.hpp @@ -121,7 +121,7 @@ class TileSheetEditorModel: public ox::SignalHandler { public: TileSheetEditorModel(Context *ctx, const ox::String &path); - ~TileSheetEditorModel() = default; + ~TileSheetEditorModel() override = default; void cut();