From 500c01271349635cc5bca9c6b52749a0105f28da Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 9 Dec 2023 17:12:04 -0600 Subject: [PATCH] [nostalgia/core/studio] Cleanup TileSheetEditor constructor --- .../modules/core/src/studio/tilesheeteditormodel.cpp | 10 ++++------ .../modules/core/src/studio/tilesheeteditormodel.hpp | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.cpp index 08d68245..20b22c20 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.cpp @@ -566,12 +566,10 @@ class PaletteChangeCommand: public TileSheetCommand { TileSheetEditorModel::TileSheetEditorModel(turbine::Context &ctx, ox::StringView path): m_ctx(ctx), - m_path(path) { - oxRequireT(img, readObj(keelCtx(m_ctx), m_path)); - m_img = *img; - if (m_img.defaultPalette) { - oxThrowError(readObj(keelCtx(m_ctx), m_img.defaultPalette).moveTo(&m_pal)); - } + m_path(path), + m_img(*readObj(keelCtx(m_ctx), m_path).unwrapThrow()), + // ignore failure to load palette + m_pal(readObj(keelCtx(m_ctx), m_img.defaultPalette).value) { m_pal.updated.connect(this, &TileSheetEditorModel::markUpdated); m_undoStack.changeTriggered.connect(this, &TileSheetEditorModel::markUpdatedCmdId); } diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.hpp b/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.hpp index e6941b5c..c8d500d8 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.hpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditormodel.hpp @@ -24,14 +24,14 @@ class TileSheetEditorModel: public ox::SignalHandler { private: static const Palette s_defaultPalette; + turbine::Context &m_ctx; + ox::String m_path; TileSheet m_img; TileSheet::SubSheetIdx m_activeSubsSheetIdx; keel::AssetRef m_pal; studio::UndoStack m_undoStack; class DrawCommand *m_ongoingDrawCommand = nullptr; bool m_updated = false; - turbine::Context &m_ctx; - ox::String m_path; bool m_selectionOngoing = false; ox::Point m_selectionOrigin = {-1, -1}; ox::Bounds m_selectionBounds = {{-1, -1}, {-1, -1}};