[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:
@@ -130,18 +130,23 @@ void WorldObjectSetEditorImGui::loadObj() noexcept {
|
||||
}
|
||||
auto const&obj = activeObj();
|
||||
auto &nameBuff = m_objEditor.nameBuff;
|
||||
ox::strncpy(nameBuff.data(), obj.name.data(), nameBuff.size());
|
||||
nameBuff = obj.name;
|
||||
m_objEditor.palette = obj.palBank;
|
||||
m_objEditor.frames = obj.frames;
|
||||
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 h = 0;
|
||||
if (m_subsheet) {
|
||||
w = m_subsheet->columns;
|
||||
h = m_subsheet->rows;
|
||||
if (m_visibleSubsheet) {
|
||||
w = m_visibleSubsheet->columns;
|
||||
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(
|
||||
m_doc.tilesheet,
|
||||
m_doc.palettes[obj.palBank],
|
||||
@@ -165,11 +170,11 @@ void WorldObjectSetEditorImGui::drawObjEditor() noexcept {
|
||||
ig::IndentStackItem const indent1{10};
|
||||
ImGui::NewLine();
|
||||
auto &nameBuff = m_objEditor.nameBuff;
|
||||
if (ImGui::InputText("Name", nameBuff.data(), nameBuff.size())) {
|
||||
if (ig::InputText("Name", nameBuff)) {
|
||||
std::ignore = pushCommand<EditObjectName>(
|
||||
m_doc,
|
||||
m_selectedObj,
|
||||
ox::String(nameBuff.data(), ox::strnlen(nameBuff.data(), nameBuff.size())));
|
||||
ox::String{nameBuff});
|
||||
}
|
||||
// SubSheet Selector
|
||||
{
|
||||
@@ -200,7 +205,7 @@ void WorldObjectSetEditorImGui::drawObjEditor() noexcept {
|
||||
ImGui::EndChild();
|
||||
}
|
||||
// collision map
|
||||
if (m_subsheet) {
|
||||
if (m_visibleSubsheet) {
|
||||
ImGui::NewLine();
|
||||
ImGui::Text("Collision Map:");
|
||||
ig::IndentStackItem const indent2{30};
|
||||
@@ -208,8 +213,8 @@ void WorldObjectSetEditorImGui::drawObjEditor() noexcept {
|
||||
auto const&fb = m_colView.framebuffer();
|
||||
uintptr_t const buffId = fb.color.id;
|
||||
auto const scale = static_cast<float>(m_colView.scale());
|
||||
auto const width = static_cast<float>(m_subsheet->columns * ncore::TileWidth);
|
||||
auto const height = static_cast<float>(m_subsheet->rows * ncore::TileHeight);
|
||||
auto const width = static_cast<float>(m_visibleSubsheet->columns * ncore::TileWidth);
|
||||
auto const height = static_cast<float>(m_visibleSubsheet->rows * ncore::TileHeight);
|
||||
auto const horzPct = width / 240.f;
|
||||
auto const vertPct = height / 160.f;
|
||||
auto const imageSz = ImVec2{width * scale, height * scale};
|
||||
|
@@ -19,7 +19,7 @@ class WorldObjectSetEditorImGui: public studio::Editor {
|
||||
ox::String m_itemPath;
|
||||
WorldObjectSet m_doc;
|
||||
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;
|
||||
size_t m_selectedObj{};
|
||||
size_t m_selectedPal{};
|
||||
@@ -30,7 +30,7 @@ class WorldObjectSetEditorImGui: public studio::Editor {
|
||||
} m_addPalPopup;
|
||||
CollisionView m_colView{m_sctx};
|
||||
struct {
|
||||
ox::Buffer nameBuff = ox::Buffer(256);
|
||||
ox::IString<256> nameBuff;
|
||||
int frames{};
|
||||
int interval{};
|
||||
size_t palette{};
|
||||
|
Reference in New Issue
Block a user