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

#include "renamepagecommand.hpp"

namespace nostalgia::gfx {

RenamePageCommand::RenamePageCommand(Palette &pal, size_t const page, ox::StringParam name) noexcept:
		m_pal(pal),
		m_page(page),
		m_name{std::move(name)} {}

int RenamePageCommand::commandId() const noexcept {
	return static_cast<int>(PaletteEditorCommandId::RenamePage);
}

ox::Error RenamePageCommand::redo() noexcept {
	std::swap(m_pal.pages[m_page].name, m_name);
	return {};
}

ox::Error RenamePageCommand::undo() noexcept {
	std::swap(m_pal.pages[m_page].name, m_name);
	return {};
}

}