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

#pragma once

#include <studio/undocommand.hpp>

#include <nostalgia/gfx/palette.hpp>

namespace nostalgia::gfx {

class UpdateColorCommand: public studio::UndoCommand {
	private:
		Palette &m_pal;
		size_t const m_page = 0;
		size_t const m_idx{};
		PaletteColor m_altColor{};

	public:
		UpdateColorCommand(
				Palette &pal,
				size_t page,
				size_t idx,
				Color16 newColor);

		~UpdateColorCommand() noexcept override = default;

		[[nodiscard]]
		bool mergeWith(UndoCommand &cmd) noexcept final;

		[[nodiscard]]
		int commandId() const noexcept final;

		ox::Error redo() noexcept final;

		ox::Error undo() noexcept final;

	private:
		void swap() noexcept;

};

}
