[jasper/world/studio] Cleanup
This commit is contained in:
parent
f678c8f8fc
commit
a1a2b4154e
@ -269,11 +269,11 @@ void WorldObjectSetEditorImGui::drawSubSheetNode(ncore::TileSheet::SubSheet cons
|
|||||||
void WorldObjectSetEditorImGui::drawPaletteList() noexcept {
|
void WorldObjectSetEditorImGui::drawPaletteList() noexcept {
|
||||||
ig::IDStackItem const idStackItem{"PaletteList"};
|
ig::IDStackItem const idStackItem{"PaletteList"};
|
||||||
if (ig::PushButton("+", btnSize)) {
|
if (ig::PushButton("+", btnSize)) {
|
||||||
addPalette();
|
showAddPalette();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ig::PushButton("-", btnSize)) {
|
if (ig::PushButton("-", btnSize)) {
|
||||||
rmPalette();
|
rmSelectedPalette();
|
||||||
}
|
}
|
||||||
constexpr auto flags = ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody;
|
constexpr auto flags = ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody;
|
||||||
if (ImGui::BeginTable("Subsheets", 1, flags)) {
|
if (ImGui::BeginTable("Subsheets", 1, flags)) {
|
||||||
@ -285,12 +285,7 @@ void WorldObjectSetEditorImGui::drawPaletteList() noexcept {
|
|||||||
if (ig::DragDropTarget const d; d) {
|
if (ig::DragDropTarget const d; d) {
|
||||||
auto const [fr, err] = ig::getDragDropPayload<studio::FileRef>("FileRef");
|
auto const [fr, err] = ig::getDragDropPayload<studio::FileRef>("FileRef");
|
||||||
if (!err && endsWith(fr.path, ncore::FileExt_npal)) {
|
if (!err && endsWith(fr.path, ncore::FileExt_npal)) {
|
||||||
auto const [uuid, err] = keel::pathToUuid(
|
addPalette(fr.path);
|
||||||
keelCtx(m_sctx), fr.path);
|
|
||||||
if (!err) {
|
|
||||||
auto const uuidUrl = ox::sfmt("uuid://{}", uuid.toString());
|
|
||||||
std::ignore = pushCommand<AddPalette>(m_doc, ox::FileAddress{uuidUrl});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,23 +317,31 @@ void WorldObjectSetEditorImGui::drawAddPalettePopup() noexcept {
|
|||||||
auto const&palettes = m_sctx.project->fileList(ncore::FileExt_npal);
|
auto const&palettes = m_sctx.project->fileList(ncore::FileExt_npal);
|
||||||
ig::ComboBox("Palette", palettes, m_addPalPopup.selectedIdx);
|
ig::ComboBox("Palette", palettes, m_addPalPopup.selectedIdx);
|
||||||
if (ig::PopupControlsOkCancel(popupSz.x, m_addPalPopup.show) == ig::PopupResponse::OK) {
|
if (ig::PopupControlsOkCancel(popupSz.x, m_addPalPopup.show) == ig::PopupResponse::OK) {
|
||||||
auto [uuid, err] = keel::pathToUuid(
|
addPalette(palettes[m_addPalPopup.selectedIdx]);
|
||||||
keelCtx(m_sctx.tctx), palettes[m_addPalPopup.selectedIdx]);
|
|
||||||
if (!err) {
|
|
||||||
auto const uuidUrl = ox::sfmt("uuid://{}", uuid.toString());
|
|
||||||
std::ignore = pushCommand<AddPalette>(m_doc, ox::FileAddress{uuidUrl});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldObjectSetEditorImGui::addPalette() noexcept {
|
void WorldObjectSetEditorImGui::addPalette(ox::StringViewCR path) noexcept {
|
||||||
|
auto const [uuid, err] = keel::pathToUuid(
|
||||||
|
keelCtx(m_sctx.tctx), path);
|
||||||
|
if (!err) {
|
||||||
|
auto const uuidUrl = ox::sfmt("uuid://{}", uuid.toString());
|
||||||
|
ox::FileAddress addr{uuidUrl};
|
||||||
|
auto const idx = ox::findIdx(m_doc.palettes.begin(), m_doc.palettes.end(), addr);
|
||||||
|
if (idx.error) {
|
||||||
|
std::ignore = pushCommand<AddPalette>(m_doc, std::move(addr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldObjectSetEditorImGui::showAddPalette() noexcept {
|
||||||
m_addPalPopup.show = true;
|
m_addPalPopup.show = true;
|
||||||
m_addPalPopup.selectedIdx = 0;
|
m_addPalPopup.selectedIdx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldObjectSetEditorImGui::rmPalette() noexcept {
|
void WorldObjectSetEditorImGui::rmSelectedPalette() noexcept {
|
||||||
std::ignore = pushCommand<RmPalette>(m_doc, m_selectedPal);
|
std::ignore = pushCommand<RmPalette>(m_doc, m_selectedPal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,9 +66,11 @@ class WorldObjectSetEditorImGui: public studio::Editor {
|
|||||||
|
|
||||||
void drawAddPalettePopup() noexcept;
|
void drawAddPalettePopup() noexcept;
|
||||||
|
|
||||||
void addPalette() noexcept;
|
void addPalette(ox::StringViewCR path) noexcept;
|
||||||
|
|
||||||
void rmPalette() noexcept;
|
void showAddPalette() noexcept;
|
||||||
|
|
||||||
|
void rmSelectedPalette() noexcept;
|
||||||
|
|
||||||
ox::Error setTileSheet(ox::StringViewCR path) noexcept;
|
ox::Error setTileSheet(ox::StringViewCR path) noexcept;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user