/*
 * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
 */

#include "commands.hpp"

#include "removepagecommand.hpp"

namespace nostalgia::gfx {

RemovePageCommand::RemovePageCommand(Palette &pal, size_t const idx) noexcept:
	m_pal(pal),
	m_idx(idx) {}

int RemovePageCommand::commandId() const noexcept {
	return static_cast<int>(PaletteEditorCommandId::RemovePage);
}

ox::Error RemovePageCommand::redo() noexcept {
	m_page = std::move(m_pal.pages[m_idx]);
	return m_pal.pages.erase(m_idx).error;
}

ox::Error RemovePageCommand::undo() noexcept {
	m_pal.pages.emplace(m_idx, std::move(m_page));
	return {};
}

}
