[nostalgia/core/studio] Cleanup

This commit is contained in:
Gary Talent 2022-12-17 14:05:35 -06:00
parent 9b36381b00
commit 716b3d6022
2 changed files with 14 additions and 15 deletions

View File

@ -20,7 +20,7 @@ ox::Result<PaletteEditorImGui*> PaletteEditorImGui::make(Context *ctx, const ox:
const auto lastSlash = std::find(out->m_itemPath.rbegin(), out->m_itemPath.rend(), '/').offset(); const auto lastSlash = std::find(out->m_itemPath.rbegin(), out->m_itemPath.rend(), '/').offset();
out->m_itemName = out->m_itemPath.substr(lastSlash + 1); out->m_itemName = out->m_itemPath.substr(lastSlash + 1);
oxRequire(pal, core::readObj<Palette>(out->m_ctx, out->m_itemPath)); oxRequire(pal, core::readObj<Palette>(out->m_ctx, out->m_itemPath));
out->m_pal = *pal.get(); out->m_pal = *pal;
return out.release(); return out.release();
} }
@ -45,20 +45,20 @@ void PaletteEditorImGui::draw(core::Context*) noexcept {
{ {
const auto sz = ImVec2(70, 24); const auto sz = ImVec2(70, 24);
if (ImGui::Button("Add", sz)) { if (ImGui::Button("Add", sz)) {
undoStack()->push(new AddColorCommand(&m_pal, 0, m_pal.colors.size())); undoStack()->push(ox::make<AddColorCommand>(&m_pal, 0, m_pal.colors.size()));
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::BeginDisabled(m_selectedRow >= m_pal.colors.size()); ImGui::BeginDisabled(m_selectedRow >= m_pal.colors.size());
{ {
if (ImGui::Button("Remove", sz)) { if (ImGui::Button("Remove", sz)) {
undoStack()->push(new RemoveColorCommand(&m_pal, m_pal.colors[static_cast<std::size_t>(m_selectedRow)], m_selectedRow)); undoStack()->push(ox::make<RemoveColorCommand>(&m_pal, m_pal.colors[static_cast<std::size_t>(m_selectedRow)], m_selectedRow));
m_selectedRow = ox::min(m_pal.colors.size() - 1, m_selectedRow); m_selectedRow = ox::min(m_pal.colors.size() - 1, m_selectedRow);
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::BeginDisabled(m_selectedRow <= 0); ImGui::BeginDisabled(m_selectedRow <= 0);
{ {
if (ImGui::Button("Move Up", sz)) { if (ImGui::Button("Move Up", sz)) {
undoStack()->push(new MoveColorCommand(&m_pal, m_selectedRow, -1)); undoStack()->push(ox::make<MoveColorCommand>(&m_pal, m_selectedRow, -1));
--m_selectedRow; --m_selectedRow;
} }
} }
@ -67,7 +67,7 @@ void PaletteEditorImGui::draw(core::Context*) noexcept {
ImGui::BeginDisabled(m_selectedRow >= m_pal.colors.size() - 1); ImGui::BeginDisabled(m_selectedRow >= m_pal.colors.size() - 1);
{ {
if (ImGui::Button("Move Down", sz)) { if (ImGui::Button("Move Down", sz)) {
undoStack()->push(new MoveColorCommand(&m_pal, m_selectedRow, 1)); undoStack()->push(ox::make<MoveColorCommand>(&m_pal, m_selectedRow, 1));
++m_selectedRow; ++m_selectedRow;
} }
} }
@ -127,7 +127,7 @@ void PaletteEditorImGui::draw(core::Context*) noexcept {
ImGui::InputInt("Blue", &b, 1, 5); ImGui::InputInt("Blue", &b, 1, 5);
const auto newColor = color16(r, g, b, a); const auto newColor = color16(r, g, b, a);
if (c != newColor) { if (c != newColor) {
undoStack()->push(new UpdateColorCommand(&m_pal, m_selectedRow, c, newColor)); undoStack()->push(ox::make<UpdateColorCommand>(&m_pal, m_selectedRow, c, newColor));
} }
} }
ImGui::EndChild(); ImGui::EndChild();

View File

@ -197,11 +197,10 @@ void TileSheetEditorImGui::drawSubsheetSelector(TileSheet::SubSheet *subsheet, T
const auto flags = ImGuiTreeNodeFlags_SpanFullWidth const auto flags = ImGuiTreeNodeFlags_SpanFullWidth
| ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnArrow
| ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_DefaultOpen
| (subsheet->subsheets.size() ? 0 : ImGuiTreeNodeFlags_Leaf) | (subsheet->subsheets.empty() ? ImGuiTreeNodeFlags_Leaf : 0)
| (rowSelected ? ImGuiTreeNodeFlags_Selected : 0); | (rowSelected ? ImGuiTreeNodeFlags_Selected : 0);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
const auto open = ImGui::TreeNodeEx(lbl.c_str(), flags); const auto open = ImGui::TreeNodeEx(lbl.c_str(), flags);
Str newName = subsheet->name.c_str();
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::IsItemClicked()) { if (ImGui::IsItemClicked()) {
model()->setActiveSubsheet(*path); model()->setActiveSubsheet(*path);
@ -209,16 +208,16 @@ void TileSheetEditorImGui::drawSubsheetSelector(TileSheet::SubSheet *subsheet, T
if (ImGui::IsMouseDoubleClicked(0) && ImGui::IsItemHovered()) { if (ImGui::IsMouseDoubleClicked(0) && ImGui::IsItemHovered()) {
showSubsheetEditor(); showSubsheetEditor();
} }
if (subsheet->subsheets.size()) { if (subsheet->subsheets.empty()) {
ImGui::TableNextColumn();
ImGui::Text("--");
ImGui::TableNextColumn();
ImGui::Text("--");
} else {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text("%d", subsheet->columns); ImGui::Text("%d", subsheet->columns);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text("%d", subsheet->rows); ImGui::Text("%d", subsheet->rows);
} else {
ImGui::TableNextColumn();
ImGui::Text("--");
ImGui::TableNextColumn();
ImGui::Text("--");
} }
if (open) { if (open) {
for (auto i = 0ul; auto &child : subsheet->subsheets) { for (auto i = 0ul; auto &child : subsheet->subsheets) {
@ -287,7 +286,7 @@ void TileSheetEditorImGui::drawTileSheet(const geo::Vec2 &fbSize) noexcept {
glViewport(0, 0, fbSizei.width, fbSizei.height); glViewport(0, 0, fbSizei.width, fbSizei.height);
m_tileSheetEditor.draw(); m_tileSheetEditor.draw();
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
uintptr_t buffId = m_framebuffer.color.id; const uintptr_t buffId = m_framebuffer.color.id;
ImGui::Image( ImGui::Image(
reinterpret_cast<void*>(buffId), reinterpret_cast<void*>(buffId),
static_cast<ImVec2>(fbSize), static_cast<ImVec2>(fbSize),