[nostalgia/core/studio] Fix PaletteEditor add/remove color commands
Some checks failed
Build / build (push) Failing after 30s

This commit is contained in:
Gary Talent 2024-05-31 01:19:55 -05:00
parent dd5d1bfbf5
commit deacd4ab98

View File

@ -68,7 +68,7 @@ ox::Error DuplicatePageCommand::redo() noexcept {
ox::Error DuplicatePageCommand::undo() noexcept { ox::Error DuplicatePageCommand::undo() noexcept {
m_page = std::move(m_pal.pages[m_dstIdx]); m_page = std::move(m_pal.pages[m_dstIdx]);
return m_pal.pages.erase(static_cast<std::size_t>(m_dstIdx)).error; return m_pal.pages.erase(m_dstIdx).error;
} }
size_t DuplicatePageCommand::insertIdx() const noexcept { size_t DuplicatePageCommand::insertIdx() const noexcept {
@ -86,7 +86,7 @@ int RemovePageCommand::commandId() const noexcept {
ox::Error RemovePageCommand::redo() noexcept { ox::Error RemovePageCommand::redo() noexcept {
m_page = std::move(colors(m_pal, m_idx)); m_page = std::move(colors(m_pal, m_idx));
return m_pal.pages.erase(static_cast<std::size_t>(m_idx)).error; return m_pal.pages.erase(m_idx).error;
} }
ox::Error RemovePageCommand::undo() noexcept { ox::Error RemovePageCommand::undo() noexcept {
@ -105,15 +105,17 @@ int AddColorCommand::commandId() const noexcept {
} }
ox::Error AddColorCommand::redo() 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) { for (auto &page : m_pal.pages) {
page.emplace(static_cast<size_t>(m_idx), m_color); page.emplace(m_idx, m_color);
} }
return {}; return {};
} }
ox::Error AddColorCommand::undo() noexcept { ox::Error AddColorCommand::undo() noexcept {
oxReturnError(m_pal.colorInfo.erase(m_idx));
for (auto &page : m_pal.pages) { for (auto &page : m_pal.pages) {
oxReturnError(page.erase(static_cast<std::size_t>(m_idx))); oxReturnError(page.erase(m_idx));
} }
return {}; return {};
} }
@ -136,6 +138,8 @@ int RemoveColorCommand::commandId() const noexcept {
} }
ox::Error RemoveColorCommand::redo() 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) { for (auto &page : m_pal.pages) {
oxReturnError(page.erase(m_idx)); oxReturnError(page.erase(m_idx));
} }
@ -143,6 +147,7 @@ ox::Error RemoveColorCommand::redo() noexcept {
} }
ox::Error RemoveColorCommand::undo() 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) { for (size_t p = 0; auto &page : m_pal.pages) {
page.emplace(m_idx, m_colors[p]); page.emplace(m_idx, m_colors[p]);
++p; ++p;