[jasper/world/studio] Use FilePickerPopup for ObjSet TileSheet
This commit is contained in:
parent
cf765d2745
commit
4bcbcf76d6
@ -25,10 +25,12 @@ WorldObjectSetEditorImGui::WorldObjectSetEditorImGui(
|
||||
studio::StudioContext &ctx,
|
||||
ox::StringParam path):
|
||||
Editor(std::move(path)),
|
||||
m_sctx(ctx),
|
||||
m_itemPath(itemPath()),
|
||||
m_doc(*readObj<WorldObjectSet>(keelCtx(m_sctx), itemPath()).unwrapThrow()),
|
||||
m_tileSheet(readObj<ngfx::TileSheet>(keelCtx(m_sctx), m_doc.tilesheet).unwrapThrow()),
|
||||
m_sctx{ctx},
|
||||
m_itemPath{itemPath()},
|
||||
m_doc{*readObj<WorldObjectSet>(keelCtx(m_sctx), itemPath()).unwrapThrow()},
|
||||
m_tileSheet{readObj<ngfx::TileSheet>(keelCtx(m_sctx), m_doc.tilesheet)
|
||||
.or_value(keel::AssetRef<ngfx::TileSheet>{})},
|
||||
m_tsPicker{"Tile Sheet Chooser", keelCtx(m_sctx), ngfx::FileExt_nts},
|
||||
m_addPalPopup{"Palette Chooser", keelCtx(m_sctx), ngfx::FileExt_npal} {
|
||||
auto &kctx = keelCtx(m_sctx);
|
||||
auto const [tsPath, err] = getPath(kctx, m_doc.tilesheet);
|
||||
@ -69,6 +71,7 @@ void WorldObjectSetEditorImGui::draw(studio::StudioContext&) noexcept {
|
||||
}
|
||||
ImGui::EndChild();
|
||||
drawAddPalettePopup();
|
||||
drawTileSheetPicker();
|
||||
}
|
||||
|
||||
void WorldObjectSetEditorImGui::onActivated() noexcept {
|
||||
@ -93,13 +96,17 @@ void WorldObjectSetEditorImGui::buildPaletteDisplayNameList() noexcept {
|
||||
|
||||
void WorldObjectSetEditorImGui::drawTileSheetSelector() noexcept {
|
||||
auto constexpr tsFlags = ImGuiInputTextFlags_ReadOnly;
|
||||
ig::InputText("Tile Sheet", m_tilesheetPath, tsFlags);
|
||||
ig::InputTextWithHint("##Tile Sheet", "Path to Tile Sheet", m_tilesheetPath, tsFlags);
|
||||
if (ig::DragDropTarget const d; d) {
|
||||
auto const [fr, err] = ig::getDragDropPayload<studio::FileRef>("FileRef");
|
||||
if (!err && endsWith(fr.path, ngfx::FileExt_ng)) {
|
||||
std::ignore = setTileSheet(fr.path);
|
||||
oxLogError(setTileSheet(fr.path));
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Browse")) {
|
||||
m_tsPicker.open();
|
||||
}
|
||||
}
|
||||
|
||||
void WorldObjectSetEditorImGui::drawObjSelector() noexcept {
|
||||
@ -314,6 +321,12 @@ void WorldObjectSetEditorImGui::drawAddPalettePopup() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
void WorldObjectSetEditorImGui::drawTileSheetPicker() noexcept {
|
||||
if (auto ts = m_tsPicker.draw(m_sctx)) {
|
||||
oxLogError(setTileSheet(*ts));
|
||||
}
|
||||
}
|
||||
|
||||
void WorldObjectSetEditorImGui::addPalette(ox::StringViewCR path) noexcept {
|
||||
auto const [uuid, err] = keel::pathToUuid(
|
||||
keelCtx(m_sctx.tctx), path);
|
||||
|
@ -24,6 +24,7 @@ class WorldObjectSetEditorImGui: public studio::Editor {
|
||||
size_t m_selectedObj{};
|
||||
size_t m_selectedPal{};
|
||||
ox::String m_tilesheetPath{};
|
||||
studio::FilePickerPopup m_tsPicker;
|
||||
studio::FilePickerPopup m_addPalPopup;
|
||||
CollisionView m_colView{m_sctx};
|
||||
struct {
|
||||
@ -63,6 +64,8 @@ class WorldObjectSetEditorImGui: public studio::Editor {
|
||||
|
||||
void drawAddPalettePopup() noexcept;
|
||||
|
||||
void drawTileSheetPicker() noexcept;
|
||||
|
||||
void addPalette(ox::StringViewCR path) noexcept;
|
||||
|
||||
void showAddPalette() noexcept;
|
||||
|
Loading…
x
Reference in New Issue
Block a user