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

#pragma once

#include <ox/std/def.hpp>

#include <keel/typeconv.hpp>

#include <nostalgia/core/context.hpp>
#include <nostalgia/core/palette.hpp>
#include <nostalgia/core/tilesheet.hpp>

namespace nostalgia::core {

// Type converters

class NostalgiaPaletteToPaletteV1Converter: public keel::Converter<NostalgiaPalette, PaletteV1> {
	ox::Error convert(keel::Context&, NostalgiaPalette &src, PaletteV1 &dst) const noexcept final;
};

class PaletteV1ToPaletteV2Converter: public keel::Converter<PaletteV1, PaletteV2> {
	ox::Error convert(keel::Context&, PaletteV1 &src, PaletteV2 &dst) const noexcept final;
};

class TileSheetV1ToTileSheetV2Converter: public keel::Converter<TileSheetV1, TileSheetV2> {
	ox::Error convert(keel::Context&, TileSheetV1 &src, TileSheetV2 &dst) const noexcept final;
};

class TileSheetV2ToTileSheetV3Converter: public keel::Converter<TileSheetV2, TileSheetV3> {
		static void convertSubsheet(
				TileSheetV2::SubSheet &src,
				TileSheetV3::SubSheet &dst,
				SubSheetId &idIt) noexcept;
		ox::Error convert(keel::Context&, TileSheetV2 &src, TileSheetV3 &dst) const noexcept final;
};

class TileSheetV3ToTileSheetV4Converter: public keel::Converter<TileSheetV3, TileSheetV4> {
	static void convertSubsheet(
			TileSheetV3::SubSheet &src,
			TileSheetV4::SubSheet &dst,
			SubSheetId &idIt) noexcept;
	ox::Error convert(keel::Context&, TileSheetV3 &src, TileSheetV4 &dst) const noexcept final;
};

class TileSheetToCompactTileSheetConverter: public keel::Converter<TileSheet, CompactTileSheet> {
		ox::Error convert(keel::Context&, TileSheet &src, CompactTileSheet &dst) const noexcept final;
};

}
