[nostalgia/core/studio] Make TileSheetEditor reload when the current palette is updated
This commit is contained in:
parent
11cb4d5a44
commit
4c6e053e81
@ -294,6 +294,10 @@ void SheetData::load(const studio::Context *ctx, QString ngPath, QString palPath
|
|||||||
updatePixels(ng.get());
|
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 {
|
void SheetData::save(const studio::Context *ctx, QString ngPath) const {
|
||||||
auto ng = toNostalgiaGraphic();
|
auto ng = toNostalgiaGraphic();
|
||||||
ctx->project->writeObj(ngPath, ng.get());
|
ctx->project->writeObj(ngPath, ng.get());
|
||||||
@ -512,6 +516,11 @@ QWidget *TileSheetEditor::setupColorPicker(QWidget *parent) {
|
|||||||
m_colorPicker.palette->addItem(name);
|
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) {
|
m_ctx->project->subscribe(studio::ProjectEvent::FileDeleted, m_colorPicker.palette, [this](QString path) {
|
||||||
if (path.startsWith(PaletteDir) && path.endsWith(FileExt_npal)) {
|
if (path.startsWith(PaletteDir) && path.endsWith(FileExt_npal)) {
|
||||||
auto name = paletteName(path);
|
auto name = paletteName(path);
|
||||||
|
@ -61,6 +61,8 @@ class SheetData: public QObject {
|
|||||||
|
|
||||||
void load(const studio::Context *ctx, QString ngPath, QString palPath = "");
|
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 save(const studio::Context *ctx, QString ngPath) const;
|
||||||
|
|
||||||
void setPalette(const NostalgiaPalette *pal);
|
void setPalette(const NostalgiaPalette *pal);
|
||||||
@ -129,7 +131,7 @@ class TileSheetEditor: public studio::Editor {
|
|||||||
|
|
||||||
virtual ~TileSheetEditor();
|
virtual ~TileSheetEditor();
|
||||||
|
|
||||||
QString itemName() override;
|
QString itemName() const override;
|
||||||
|
|
||||||
void exportFile() override;
|
void exportFile() override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user