#pragma once

#include "overlays.h"
#include <map>

namespace rsx
{
	namespace overlays
	{
		enum cursor_offset : u32
		{
			cell_gem = 0, // CELL_GEM_MAX_NUM = 4 Move controllers
			last = 4
		};

		class cursor_item
		{
		public:
			cursor_item();

			void set_expiration(u64 expiration_time);
			bool set_position(u16 x, u16 y);
			bool set_color(color4f color);

			bool update_visibility(u64 time);
			bool visible() const;

			compiled_resource get_compiled();

		private:
			bool m_visible = false;
			overlay_element m_cross_h{};
			overlay_element m_cross_v{};
			u64 m_expiration_time = 0;
			u16 m_x = 0;
			u16 m_y = 0;
		};

		class cursor_manager final : public overlay
		{
		public:
			void update() override;
			compiled_resource get_compiled() override;

			void update_cursor(u32 id, u16 x, u16 y, const color4f& color, u64 duration_us, bool force_update);

		private:
			shared_mutex m_mutex;
			std::map<u32, cursor_item> m_cursors;
		};

		void set_cursor(u32 id, u16 x, u16 y, const color4f& color, u64 duration_us, bool force_update);

	} // namespace overlays
} // namespace rsx
