[jasper/world] Fix issues with selecting a non-leaf node subsheet in WorldObjectSetEditor
All checks were successful
Build / build (push) Successful in 3m44s
All checks were successful
Build / build (push) Successful in 3m44s
This commit is contained in:
parent
f55ede08b2
commit
21f7ce7885
@ -130,18 +130,23 @@ void WorldObjectSetEditorImGui::loadObj() noexcept {
|
|||||||
}
|
}
|
||||||
auto const&obj = activeObj();
|
auto const&obj = activeObj();
|
||||||
auto &nameBuff = m_objEditor.nameBuff;
|
auto &nameBuff = m_objEditor.nameBuff;
|
||||||
ox::strncpy(nameBuff.data(), obj.name.data(), nameBuff.size());
|
nameBuff = obj.name;
|
||||||
m_objEditor.palette = obj.palBank;
|
m_objEditor.palette = obj.palBank;
|
||||||
m_objEditor.frames = obj.frames;
|
m_objEditor.frames = obj.frames;
|
||||||
m_objEditor.interval = obj.intervalMs;
|
m_objEditor.interval = obj.intervalMs;
|
||||||
m_subsheet = getSubsheet(*m_tileSheet, obj.subsheetId);
|
m_visibleSubsheet = getSubsheet(*m_tileSheet, obj.subsheetId);
|
||||||
|
auto const subsheetId = !m_visibleSubsheet || m_visibleSubsheet->subsheets.empty() ?
|
||||||
|
obj.subsheetId : m_visibleSubsheet->subsheets[0].id;
|
||||||
|
m_visibleSubsheet = getSubsheet(*m_tileSheet, subsheetId);
|
||||||
int w = 0;
|
int w = 0;
|
||||||
int h = 0;
|
int h = 0;
|
||||||
if (m_subsheet) {
|
if (m_visibleSubsheet) {
|
||||||
w = m_subsheet->columns;
|
w = m_visibleSubsheet->columns;
|
||||||
h = m_subsheet->rows;
|
h = m_visibleSubsheet->rows;
|
||||||
}
|
}
|
||||||
auto const idx = getTileIdx(*m_tileSheet, obj.subsheetId).or_value(0);
|
auto const idx = getTileIdx(
|
||||||
|
*m_tileSheet,
|
||||||
|
subsheetId).or_value(0);
|
||||||
oxLogError(m_colView.setup(
|
oxLogError(m_colView.setup(
|
||||||
m_doc.tilesheet,
|
m_doc.tilesheet,
|
||||||
m_doc.palettes[obj.palBank],
|
m_doc.palettes[obj.palBank],
|
||||||
@ -165,11 +170,11 @@ void WorldObjectSetEditorImGui::drawObjEditor() noexcept {
|
|||||||
ig::IndentStackItem const indent1{10};
|
ig::IndentStackItem const indent1{10};
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
auto &nameBuff = m_objEditor.nameBuff;
|
auto &nameBuff = m_objEditor.nameBuff;
|
||||||
if (ImGui::InputText("Name", nameBuff.data(), nameBuff.size())) {
|
if (ig::InputText("Name", nameBuff)) {
|
||||||
std::ignore = pushCommand<EditObjectName>(
|
std::ignore = pushCommand<EditObjectName>(
|
||||||
m_doc,
|
m_doc,
|
||||||
m_selectedObj,
|
m_selectedObj,
|
||||||
ox::String(nameBuff.data(), ox::strnlen(nameBuff.data(), nameBuff.size())));
|
ox::String{nameBuff});
|
||||||
}
|
}
|
||||||
// SubSheet Selector
|
// SubSheet Selector
|
||||||
{
|
{
|
||||||
@ -200,7 +205,7 @@ void WorldObjectSetEditorImGui::drawObjEditor() noexcept {
|
|||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
// collision map
|
// collision map
|
||||||
if (m_subsheet) {
|
if (m_visibleSubsheet) {
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
ImGui::Text("Collision Map:");
|
ImGui::Text("Collision Map:");
|
||||||
ig::IndentStackItem const indent2{30};
|
ig::IndentStackItem const indent2{30};
|
||||||
@ -208,8 +213,8 @@ void WorldObjectSetEditorImGui::drawObjEditor() noexcept {
|
|||||||
auto const&fb = m_colView.framebuffer();
|
auto const&fb = m_colView.framebuffer();
|
||||||
uintptr_t const buffId = fb.color.id;
|
uintptr_t const buffId = fb.color.id;
|
||||||
auto const scale = static_cast<float>(m_colView.scale());
|
auto const scale = static_cast<float>(m_colView.scale());
|
||||||
auto const width = static_cast<float>(m_subsheet->columns * ncore::TileWidth);
|
auto const width = static_cast<float>(m_visibleSubsheet->columns * ncore::TileWidth);
|
||||||
auto const height = static_cast<float>(m_subsheet->rows * ncore::TileHeight);
|
auto const height = static_cast<float>(m_visibleSubsheet->rows * ncore::TileHeight);
|
||||||
auto const horzPct = width / 240.f;
|
auto const horzPct = width / 240.f;
|
||||||
auto const vertPct = height / 160.f;
|
auto const vertPct = height / 160.f;
|
||||||
auto const imageSz = ImVec2{width * scale, height * scale};
|
auto const imageSz = ImVec2{width * scale, height * scale};
|
||||||
|
@ -19,7 +19,7 @@ class WorldObjectSetEditorImGui: public studio::Editor {
|
|||||||
ox::String m_itemPath;
|
ox::String m_itemPath;
|
||||||
WorldObjectSet m_doc;
|
WorldObjectSet m_doc;
|
||||||
keel::AssetRef<ncore::TileSheet> m_tileSheet;
|
keel::AssetRef<ncore::TileSheet> m_tileSheet;
|
||||||
ncore::TileSheet::SubSheet const*m_subsheet = nullptr;
|
ncore::TileSheet::SubSheet const*m_visibleSubsheet = nullptr;
|
||||||
ox::Vector<ox::String> m_paletteDisplayNames;
|
ox::Vector<ox::String> m_paletteDisplayNames;
|
||||||
size_t m_selectedObj{};
|
size_t m_selectedObj{};
|
||||||
size_t m_selectedPal{};
|
size_t m_selectedPal{};
|
||||||
@ -30,7 +30,7 @@ class WorldObjectSetEditorImGui: public studio::Editor {
|
|||||||
} m_addPalPopup;
|
} m_addPalPopup;
|
||||||
CollisionView m_colView{m_sctx};
|
CollisionView m_colView{m_sctx};
|
||||||
struct {
|
struct {
|
||||||
ox::Buffer nameBuff = ox::Buffer(256);
|
ox::IString<256> nameBuff;
|
||||||
int frames{};
|
int frames{};
|
||||||
int interval{};
|
int interval{};
|
||||||
size_t palette{};
|
size_t palette{};
|
||||||
|
@ -11,12 +11,22 @@
|
|||||||
|
|
||||||
namespace jasper::world {
|
namespace jasper::world {
|
||||||
|
|
||||||
inline void ensureInVec(ox::Vector<ox::FileAddress> &vec, ox::FileAddress const&val) {
|
static void ensureInVec(ox::Vector<ox::FileAddress> &vec, ox::FileAddress const&val) {
|
||||||
if (!vec.contains(val)) {
|
if (!vec.contains(val)) {
|
||||||
vec.emplace_back(val);
|
vec.emplace_back(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the root subsheet is not a leaf node, it will return the
|
||||||
|
// tile count of the first leaf node that it finds.
|
||||||
|
[[nodiscard]]
|
||||||
|
static uint8_t subsheetTileCnt(ncore::TileSheet::SubSheet const&ss) noexcept {
|
||||||
|
if (ss.subsheets.empty()) {
|
||||||
|
return static_cast<uint8_t>(ss.size());
|
||||||
|
}
|
||||||
|
return subsheetTileCnt(ss.subsheets[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
WorldStaticLoader::WorldStaticLoader(keel::Context &kctx, WorldStatic &worldStatic, WorldDoc const&doc):
|
WorldStaticLoader::WorldStaticLoader(keel::Context &kctx, WorldStatic &worldStatic, WorldDoc const&doc):
|
||||||
m_kctx{kctx},
|
m_kctx{kctx},
|
||||||
@ -155,7 +165,7 @@ ox::Result<uint8_t> WorldStaticLoader::setupTileResrc(DocObjRef const&docObjRef)
|
|||||||
.tilesheetIdx = static_cast<uint16_t>(*subsheetOffset),
|
.tilesheetIdx = static_cast<uint16_t>(*subsheetOffset),
|
||||||
.cbbIdx = m_cbbIt,
|
.cbbIdx = m_cbbIt,
|
||||||
.tilesheetId = tsIdx,
|
.tilesheetId = tsIdx,
|
||||||
.tileCnt = static_cast<uint8_t>(subsheet->size()),
|
.tileCnt = subsheetTileCnt(*subsheet),
|
||||||
.frames = obj->frames,
|
.frames = obj->frames,
|
||||||
});
|
});
|
||||||
m_cbbIt += refSet.tileCnt;
|
m_cbbIt += refSet.tileCnt;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user