[jasper/world/studio/worldobjectseteditor] Fix file drops to check file type

This commit is contained in:
Gary Talent 2025-01-19 17:01:23 -06:00
parent 92a549ad38
commit bcd62cd622
3 changed files with 7 additions and 9 deletions

View File

@ -11,10 +11,9 @@
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_palAddr{std::move(palAddr)},
m_kctx{kctx} {
m_palAddr{std::move(palAddr)} {
}
ox::Error AddPalette::redo() noexcept {

View File

@ -16,9 +16,8 @@ class AddPalette: public studio::UndoCommand {
private:
WorldObjectSet &m_doc;
ox::FileAddress m_palAddr;
keel::Context &m_kctx;
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 undo() noexcept override;
[[nodiscard]]

View File

@ -94,7 +94,7 @@ void WorldObjectSetEditorImGui::drawTileSheetSelector() noexcept {
ig::InputText("Tile Sheet", m_tilesheetPath, tsFlags);
if (ig::DragDropTarget const d; d) {
auto const [fr, err] = ig::getDragDropPayload<studio::FileRef>("FileRef");
if (!err) {
if (!err && endsWith(fr.path, ncore::FileExt_ng)) {
std::ignore = setTileSheet(fr.path);
}
}
@ -284,12 +284,12 @@ void WorldObjectSetEditorImGui::drawPaletteList() noexcept {
}
if (ig::DragDropTarget const d; d) {
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(
keelCtx(m_sctx), fr.path);
if (!err) {
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]);
if (!err) {
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();