diff --git a/src/nostalgia/core/studio/tilesheeteditor.cpp b/src/nostalgia/core/studio/tilesheeteditor.cpp index cf63d1798..a0744677e 100644 --- a/src/nostalgia/core/studio/tilesheeteditor.cpp +++ b/src/nostalgia/core/studio/tilesheeteditor.cpp @@ -294,6 +294,10 @@ void SheetData::load(const studio::Context *ctx, QString ngPath, QString palPath updatePixels(ng.get()); } +void SheetData::reload(const studio::Context *ctx) { + load(ctx, m_tilesheetPath, m_currentPalettePath); +} + void SheetData::save(const studio::Context *ctx, QString ngPath) const { auto ng = toNostalgiaGraphic(); ctx->project->writeObj(ngPath, ng.get()); @@ -512,6 +516,11 @@ QWidget *TileSheetEditor::setupColorPicker(QWidget *parent) { m_colorPicker.palette->addItem(name); } }); + m_ctx->project->subscribe(studio::ProjectEvent::FileUpdated, m_colorPicker.palette, [this](QString path) { + if (path == m_sheetData.palettePath()) { + m_sheetData.reload(m_ctx); + } + }); m_ctx->project->subscribe(studio::ProjectEvent::FileDeleted, m_colorPicker.palette, [this](QString path) { if (path.startsWith(PaletteDir) && path.endsWith(FileExt_npal)) { auto name = paletteName(path); diff --git a/src/nostalgia/core/studio/tilesheeteditor.hpp b/src/nostalgia/core/studio/tilesheeteditor.hpp index 355bb08ed..70365faf0 100644 --- a/src/nostalgia/core/studio/tilesheeteditor.hpp +++ b/src/nostalgia/core/studio/tilesheeteditor.hpp @@ -61,6 +61,8 @@ class SheetData: public QObject { void load(const studio::Context *ctx, QString ngPath, QString palPath = ""); + void reload(const studio::Context *ctx); + void save(const studio::Context *ctx, QString ngPath) const; void setPalette(const NostalgiaPalette *pal); @@ -129,7 +131,7 @@ class TileSheetEditor: public studio::Editor { virtual ~TileSheetEditor(); - QString itemName() override; + QString itemName() const override; void exportFile() override;