From deacd4ab98fb3e71282f2466c3a62003d806c834 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 31 May 2024 01:19:55 -0500 Subject: [PATCH] [nostalgia/core/studio] Fix PaletteEditor add/remove color commands --- .../core/src/studio/paletteeditor/paletteeditor.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/nostalgia/modules/core/src/studio/paletteeditor/paletteeditor.cpp b/src/nostalgia/modules/core/src/studio/paletteeditor/paletteeditor.cpp index 1a4acd05..89357485 100644 --- a/src/nostalgia/modules/core/src/studio/paletteeditor/paletteeditor.cpp +++ b/src/nostalgia/modules/core/src/studio/paletteeditor/paletteeditor.cpp @@ -68,7 +68,7 @@ ox::Error DuplicatePageCommand::redo() noexcept { ox::Error DuplicatePageCommand::undo() noexcept { m_page = std::move(m_pal.pages[m_dstIdx]); - return m_pal.pages.erase(static_cast(m_dstIdx)).error; + return m_pal.pages.erase(m_dstIdx).error; } size_t DuplicatePageCommand::insertIdx() const noexcept { @@ -86,7 +86,7 @@ int RemovePageCommand::commandId() const noexcept { ox::Error RemovePageCommand::redo() noexcept { m_page = std::move(colors(m_pal, m_idx)); - return m_pal.pages.erase(static_cast(m_idx)).error; + return m_pal.pages.erase(m_idx).error; } ox::Error RemovePageCommand::undo() noexcept { @@ -105,15 +105,17 @@ int AddColorCommand::commandId() const noexcept { } ox::Error AddColorCommand::redo() noexcept { + m_pal.colorInfo.emplace(m_idx, ox::sfmt("Color {}", m_pal.colorInfo.size() + 1)); for (auto &page : m_pal.pages) { - page.emplace(static_cast(m_idx), m_color); + page.emplace(m_idx, m_color); } return {}; } ox::Error AddColorCommand::undo() noexcept { + oxReturnError(m_pal.colorInfo.erase(m_idx)); for (auto &page : m_pal.pages) { - oxReturnError(page.erase(static_cast(m_idx))); + oxReturnError(page.erase(m_idx)); } return {}; } @@ -136,6 +138,8 @@ int RemoveColorCommand::commandId() const noexcept { } ox::Error RemoveColorCommand::redo() noexcept { + m_colorInfo = std::move(m_pal.colorInfo[m_idx]); + oxReturnError(m_pal.colorInfo.erase(m_idx)); for (auto &page : m_pal.pages) { oxReturnError(page.erase(m_idx)); } @@ -143,6 +147,7 @@ ox::Error RemoveColorCommand::redo() noexcept { } ox::Error RemoveColorCommand::undo() noexcept { + m_pal.colorInfo.emplace(m_idx, std::move(m_colorInfo)); for (size_t p = 0; auto &page : m_pal.pages) { page.emplace(m_idx, m_colors[p]); ++p;