[jasper/world/studio/worldobjectseteditor] Fix file drops to check file type
This commit is contained in:
parent
92a549ad38
commit
bcd62cd622
@ -11,10 +11,9 @@
|
|||||||
|
|
||||||
namespace jasper::world {
|
namespace jasper::world {
|
||||||
|
|
||||||
AddPalette::AddPalette(WorldObjectSet &doc, ox::FileAddress palAddr, keel::Context &kctx) noexcept:
|
AddPalette::AddPalette(WorldObjectSet &doc, ox::FileAddress palAddr) noexcept:
|
||||||
m_doc{doc},
|
m_doc{doc},
|
||||||
m_palAddr{std::move(palAddr)},
|
m_palAddr{std::move(palAddr)} {
|
||||||
m_kctx{kctx} {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error AddPalette::redo() noexcept {
|
ox::Error AddPalette::redo() noexcept {
|
||||||
|
@ -16,9 +16,8 @@ class AddPalette: public studio::UndoCommand {
|
|||||||
private:
|
private:
|
||||||
WorldObjectSet &m_doc;
|
WorldObjectSet &m_doc;
|
||||||
ox::FileAddress m_palAddr;
|
ox::FileAddress m_palAddr;
|
||||||
keel::Context &m_kctx;
|
|
||||||
public:
|
public:
|
||||||
AddPalette(WorldObjectSet &doc, ox::FileAddress palAddr, keel::Context &kctx) noexcept;
|
AddPalette(WorldObjectSet &doc, ox::FileAddress palAddr) noexcept;
|
||||||
ox::Error redo() noexcept override;
|
ox::Error redo() noexcept override;
|
||||||
ox::Error undo() noexcept override;
|
ox::Error undo() noexcept override;
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
|
@ -94,7 +94,7 @@ void WorldObjectSetEditorImGui::drawTileSheetSelector() noexcept {
|
|||||||
ig::InputText("Tile Sheet", m_tilesheetPath, tsFlags);
|
ig::InputText("Tile Sheet", m_tilesheetPath, tsFlags);
|
||||||
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) {
|
if (!err && endsWith(fr.path, ncore::FileExt_ng)) {
|
||||||
std::ignore = setTileSheet(fr.path);
|
std::ignore = setTileSheet(fr.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,12 +284,12 @@ 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) {
|
if (!err && endsWith(fr.path, ncore::FileExt_npal)) {
|
||||||
auto const [uuid, err] = keel::pathToUuid(
|
auto const [uuid, err] = keel::pathToUuid(
|
||||||
keelCtx(m_sctx), fr.path);
|
keelCtx(m_sctx), fr.path);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
auto const uuidUrl = ox::sfmt("uuid://{}", uuid.toString());
|
auto const uuidUrl = ox::sfmt("uuid://{}", uuid.toString());
|
||||||
std::ignore = pushCommand<AddPalette>(m_doc, ox::FileAddress{uuidUrl}, keelCtx(m_sctx));
|
std::ignore = pushCommand<AddPalette>(m_doc, ox::FileAddress{uuidUrl});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ void WorldObjectSetEditorImGui::drawAddPalettePopup() noexcept {
|
|||||||
keelCtx(m_sctx.tctx), palettes[m_addPalPopup.selectedIdx]);
|
keelCtx(m_sctx.tctx), palettes[m_addPalPopup.selectedIdx]);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
auto const uuidUrl = ox::sfmt("uuid://{}", uuid.toString());
|
auto const uuidUrl = ox::sfmt("uuid://{}", uuid.toString());
|
||||||
std::ignore = pushCommand<AddPalette>(m_doc, ox::FileAddress{uuidUrl}, keelCtx(m_sctx));
|
std::ignore = pushCommand<AddPalette>(m_doc, ox::FileAddress{uuidUrl});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user