[jasper/world/studio] Integrate new FilePickerPopup
Some checks failed
Build / build (push) Failing after 1m7s
Some checks failed
Build / build (push) Failing after 1m7s
This commit is contained in:
parent
67c796ec04
commit
bd461ebeeb
@ -6,7 +6,6 @@
|
||||
|
||||
#include <ox/std/array.hpp>
|
||||
|
||||
#include <nostalgia/gfx/context.hpp>
|
||||
#include <nostalgia/gfx/tilesheet.hpp>
|
||||
|
||||
namespace jasper::world {
|
||||
|
@ -75,11 +75,11 @@ constexpr ox::Point fbPtToTileAddr(
|
||||
WorldEditorImGui::WorldEditorImGui(studio::StudioContext &sctx, ox::StringParam path):
|
||||
Editor(std::move(path)),
|
||||
m_sctx{sctx},
|
||||
m_objSetPicker{"Object Set Chooser", keelCtx(m_sctx), FileExt_jwob},
|
||||
m_doc{*keel::readObj<WorldDoc>(keelCtx(m_sctx), itemPath()).unwrapThrow()} {
|
||||
OX_THROW_ERROR(m_loader.loadWorldStatic());
|
||||
OX_THROW_ERROR(m_view.setupWorld());
|
||||
OX_THROW_ERROR(loadObjectSets());
|
||||
m_objSetPicker.filePicked.connect(this, &WorldEditorImGui::addObjSet);
|
||||
m_sctx.project->fileUpdated.connect(this, &WorldEditorImGui::handleDepUpdate);
|
||||
m_loader.resourcesUpdated.connect(&m_view, &WorldEditorView::setupWorld);
|
||||
m_loader.tileUpdated.connect(&m_view, &WorldEditorView::setupTile);
|
||||
@ -103,7 +103,9 @@ void WorldEditorImGui::draw(studio::StudioContext&) noexcept {
|
||||
ImGui::Separator();
|
||||
drawResources();
|
||||
}
|
||||
m_objSetPicker.draw();
|
||||
if (auto o = m_objSetPicker.draw(m_sctx)) {
|
||||
oxLogError(addObjSet(*o));
|
||||
}
|
||||
drawPropEditor();
|
||||
}
|
||||
|
||||
@ -187,7 +189,7 @@ ox::Error WorldEditorImGui::saveItem() noexcept {
|
||||
void WorldEditorImGui::drawObjSetSelector() noexcept {
|
||||
ig::IDStackItem const idStackItem("ObjSetSelector");
|
||||
if (ig::PushButton("+", SqrBtnSize)) {
|
||||
m_objSetPicker.show();
|
||||
m_objSetPicker.open();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ig::PushButton("-", SqrBtnSize)) {
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <ox/std/smallmap.hpp>
|
||||
|
||||
#include <studio/filepickerpopup.hpp>
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <jasper/world/consts.hpp>
|
||||
@ -21,7 +22,7 @@ class WorldEditorImGui: public studio::Editor {
|
||||
ox::Optional<studio::Selection> m_selection;
|
||||
uint8_t m_activeLayer{};
|
||||
studio::StudioContext &m_sctx;
|
||||
studio::ig::FilePicker m_objSetPicker{m_sctx, "Choose Object Set", FileExt_jwob};
|
||||
studio::FilePickerPopup m_objSetPicker;
|
||||
WorldDoc m_doc;
|
||||
struct ObjSetRef {
|
||||
ox::String name;
|
||||
|
@ -28,7 +28,8 @@ WorldObjectSetEditorImGui::WorldObjectSetEditorImGui(
|
||||
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_tileSheet(readObj<ngfx::TileSheet>(keelCtx(m_sctx), m_doc.tilesheet).unwrapThrow()),
|
||||
m_addPalPopup{"Palette Chooser", keelCtx(m_sctx), ngfx::FileExt_npal} {
|
||||
auto &kctx = keelCtx(m_sctx);
|
||||
auto const [tsPath, err] = getPath(kctx, m_doc.tilesheet);
|
||||
if (!err) {
|
||||
@ -308,19 +309,8 @@ void WorldObjectSetEditorImGui::drawPaletteListItems() noexcept {
|
||||
}
|
||||
|
||||
void WorldObjectSetEditorImGui::drawAddPalettePopup() noexcept {
|
||||
if (!m_addPalPopup.show) {
|
||||
return;
|
||||
}
|
||||
auto constexpr popupName = ox::CStringView("Add Palette");
|
||||
auto constexpr popupSz = ImVec2{285.f, 0};
|
||||
ig::IDStackItem const idStackItem{"AddPalette"};
|
||||
if (ig::BeginPopup(m_sctx.tctx, popupName, m_addPalPopup.show, popupSz)) {
|
||||
auto const&palettes = m_sctx.project->fileList(ngfx::FileExt_npal);
|
||||
ig::ComboBox("Palette", palettes, m_addPalPopup.selectedIdx);
|
||||
if (ig::PopupControlsOkCancel(popupSz.x, m_addPalPopup.show) == ig::PopupResponse::OK) {
|
||||
addPalette(palettes[m_addPalPopup.selectedIdx]);
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
if (auto o = m_addPalPopup.draw(m_sctx)) {
|
||||
addPalette(*o);
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,8 +328,7 @@ void WorldObjectSetEditorImGui::addPalette(ox::StringViewCR path) noexcept {
|
||||
}
|
||||
|
||||
void WorldObjectSetEditorImGui::showAddPalette() noexcept {
|
||||
m_addPalPopup.show = true;
|
||||
m_addPalPopup.selectedIdx = 0;
|
||||
m_addPalPopup.open();
|
||||
}
|
||||
|
||||
void WorldObjectSetEditorImGui::rmSelectedPalette() noexcept {
|
||||
|
@ -24,10 +24,7 @@ class WorldObjectSetEditorImGui: public studio::Editor {
|
||||
size_t m_selectedObj{};
|
||||
size_t m_selectedPal{};
|
||||
ox::String m_tilesheetPath{};
|
||||
struct {
|
||||
bool show{};
|
||||
size_t selectedIdx{};
|
||||
} m_addPalPopup;
|
||||
studio::FilePickerPopup m_addPalPopup;
|
||||
CollisionView m_colView{m_sctx};
|
||||
struct {
|
||||
ox::IString<256> nameBuff;
|
||||
|
Loading…
x
Reference in New Issue
Block a user