[jasper/world/studio] Fix WorldObjectSetEditor to reload tilesheet when it changes
All checks were successful
Build / build (push) Successful in 3m53s
All checks were successful
Build / build (push) Successful in 3m53s
This commit is contained in:
parent
a1a2b4154e
commit
97cf03fbb7
@ -34,7 +34,8 @@ WorldObjectSetEditorImGui::WorldObjectSetEditorImGui(
|
|||||||
if (!err) {
|
if (!err) {
|
||||||
m_tilesheetPath = tsPath;
|
m_tilesheetPath = tsPath;
|
||||||
}
|
}
|
||||||
loadObj();
|
std::ignore = loadObj();
|
||||||
|
m_tileSheet.updated.connect(this, &WorldObjectSetEditorImGui::loadObj);
|
||||||
undoStack()->changeTriggered.connect(this, &WorldObjectSetEditorImGui::handleCmd);
|
undoStack()->changeTriggered.connect(this, &WorldObjectSetEditorImGui::handleCmd);
|
||||||
buildPaletteDisplayNameList();
|
buildPaletteDisplayNameList();
|
||||||
}
|
}
|
||||||
@ -106,7 +107,7 @@ void WorldObjectSetEditorImGui::drawObjSelector() noexcept {
|
|||||||
auto cmd = ox::make_unique<AddObject>(m_doc);
|
auto cmd = ox::make_unique<AddObject>(m_doc);
|
||||||
m_selectedObj = cmd->insertIdx();
|
m_selectedObj = cmd->insertIdx();
|
||||||
std::ignore = undoStack()->push(std::move(cmd));
|
std::ignore = undoStack()->push(std::move(cmd));
|
||||||
loadObj();
|
std::ignore = loadObj();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ig::PushButton("-", btnSize)) {
|
if (ig::PushButton("-", btnSize)) {
|
||||||
@ -115,13 +116,13 @@ void WorldObjectSetEditorImGui::drawObjSelector() noexcept {
|
|||||||
if (ig::ListBox("Objects", [this](size_t i) -> ox::CStringView {
|
if (ig::ListBox("Objects", [this](size_t i) -> ox::CStringView {
|
||||||
return m_doc.objects[i].name;
|
return m_doc.objects[i].name;
|
||||||
}, m_doc.objects.size(), m_selectedObj)) {
|
}, m_doc.objects.size(), m_selectedObj)) {
|
||||||
loadObj();
|
std::ignore = loadObj();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldObjectSetEditorImGui::loadObj() noexcept {
|
ox::Error WorldObjectSetEditorImGui::loadObj() noexcept {
|
||||||
if (m_selectedObj >= m_doc.objects.size()) {
|
if (m_selectedObj >= m_doc.objects.size()) {
|
||||||
return;
|
return ox::Error{1};
|
||||||
}
|
}
|
||||||
auto const&obj = activeObj();
|
auto const&obj = activeObj();
|
||||||
auto &nameBuff = m_objEditor.nameBuff;
|
auto &nameBuff = m_objEditor.nameBuff;
|
||||||
@ -144,13 +145,13 @@ void WorldObjectSetEditorImGui::loadObj() noexcept {
|
|||||||
subsheetId).or_value(0);
|
subsheetId).or_value(0);
|
||||||
auto const&palAddr = m_doc.palettes.size() > obj.palBank ?
|
auto const&palAddr = m_doc.palettes.size() > obj.palBank ?
|
||||||
m_doc.palettes[obj.palBank] : ox::FileAddress{};
|
m_doc.palettes[obj.palBank] : ox::FileAddress{};
|
||||||
oxLogError(m_colView.setup(
|
return m_colView.setup(
|
||||||
m_doc.tilesheet,
|
m_doc.tilesheet,
|
||||||
palAddr,
|
palAddr,
|
||||||
w,
|
w,
|
||||||
h,
|
h,
|
||||||
static_cast<uint_t>(tileIdx),
|
static_cast<uint_t>(tileIdx),
|
||||||
obj.collisionMap));
|
obj.collisionMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
@ -351,14 +352,15 @@ ox::Error WorldObjectSetEditorImGui::setTileSheet(ox::StringViewCR path) noexcep
|
|||||||
auto const uuidUrl = ox::sfmt("uuid://{}", uuid.toString());
|
auto const uuidUrl = ox::sfmt("uuid://{}", uuid.toString());
|
||||||
std::ignore = pushCommand<ChangeTileSheet>
|
std::ignore = pushCommand<ChangeTileSheet>
|
||||||
(keelCtx(m_sctx), m_doc, ox::FileAddress{uuidUrl}, m_tilesheetPath);
|
(keelCtx(m_sctx), m_doc, ox::FileAddress{uuidUrl}, m_tilesheetPath);
|
||||||
loadObj();
|
return loadObj();
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error WorldObjectSetEditorImGui::handleCmd(studio::UndoCommand const*cmd) noexcept {
|
ox::Error WorldObjectSetEditorImGui::handleCmd(studio::UndoCommand const*cmd) noexcept {
|
||||||
if (dynamic_cast<ChangeTileSheet const*>(cmd)) {
|
if (dynamic_cast<ChangeTileSheet const*>(cmd)) {
|
||||||
auto &kctx = keelCtx(m_sctx.tctx);
|
auto &kctx = keelCtx(m_sctx.tctx);
|
||||||
|
std::ignore = m_tileSheet.updated.disconnectObject(this);
|
||||||
oxLogError(readObj<ncore::TileSheet>(kctx, m_doc.tilesheet).moveTo(m_tileSheet));
|
oxLogError(readObj<ncore::TileSheet>(kctx, m_doc.tilesheet).moveTo(m_tileSheet));
|
||||||
|
m_tileSheet.updated.connect(this, &WorldObjectSetEditorImGui::loadObj);
|
||||||
} else if (
|
} else if (
|
||||||
dynamic_cast<AddPalette const*>(cmd) ||
|
dynamic_cast<AddPalette const*>(cmd) ||
|
||||||
dynamic_cast<RmPalette const*>(cmd)) {
|
dynamic_cast<RmPalette const*>(cmd)) {
|
||||||
@ -367,8 +369,7 @@ ox::Error WorldObjectSetEditorImGui::handleCmd(studio::UndoCommand const*cmd) no
|
|||||||
auto const&obj = activeObj();
|
auto const&obj = activeObj();
|
||||||
m_objEditor.palette = obj.palBank;
|
m_objEditor.palette = obj.palBank;
|
||||||
}
|
}
|
||||||
loadObj();
|
return loadObj();
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error WorldObjectSetEditorImGui::saveItem() noexcept {
|
ox::Error WorldObjectSetEditorImGui::saveItem() noexcept {
|
||||||
|
@ -54,7 +54,7 @@ class WorldObjectSetEditorImGui: public studio::Editor {
|
|||||||
|
|
||||||
void drawObjSelector() noexcept;
|
void drawObjSelector() noexcept;
|
||||||
|
|
||||||
void loadObj() noexcept;
|
ox::Error loadObj() noexcept;
|
||||||
|
|
||||||
void drawObjEditor() noexcept;
|
void drawObjEditor() noexcept;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user