/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

#pragma once

#include <magic_enum.hpp>

namespace OpenVulkano::Scene
{
	class FontAtlasType
	{
	public:
		enum Type : int16_t
		{
			SDF = 0,
			MSDF,
			BITMAP,
			BITMAP_SUBPIXEL,
			UNKNOWN
		};

		static constexpr std::string_view DEFAULT_FG_SHADERS[] = { "Shader/sdfText", "Shader/msdfText", "Shader/text",
			                                                       "Shader/subpixelText" };

		static constexpr uint32_t CHANNEL_COUNT[] = { 1, 4, 1, 4, 0 };

		constexpr FontAtlasType(Type type) : m_type(type) {}

		[[nodiscard]] constexpr Type GetType() const { return m_type; }

		[[nodiscard]] constexpr auto GetName() const { return magic_enum::enum_name(m_type); }

		[[nodiscard]] constexpr const std::string_view& GetDefaultFragmentShader() const
		{
			return DEFAULT_FG_SHADERS[static_cast<int>(m_type)];
		}

		[[nodiscard]] constexpr uint32_t GetChannelCount() const { return CHANNEL_COUNT[static_cast<int>(m_type)]; }

		[[nodiscard]] constexpr bool IsSDF() const { return m_type == SDF || m_type == MSDF; }

		[[nodiscard]] constexpr bool IsBitmap() const { return m_type == BITMAP || m_type == BITMAP_SUBPIXEL; }

		[[nodiscard]] constexpr operator Type() const { return m_type; }

		[[nodiscard]] constexpr auto operator<=>(const FontAtlasType rhs) const { return m_type <=> rhs.m_type; }
		[[nodiscard]] constexpr auto operator<=>(const Type rhs) const { return m_type <=> rhs; }

	private:
		Type m_type;
	};
}