#pragma once #include "GameScriptColor.h" enum class DisplayStringOptions : size_t { CENTER, OUTLINE, NUM_OPTIONS }; static const std::unordered_map kDisplayStringOptionNames { {"CENTER", DisplayStringOptions::CENTER}, {"SHADOW", DisplayStringOptions::OUTLINE} }; using FlagArray = std::array(DisplayStringOptions::NUM_OPTIONS)>; // Used to store data used to render the string. // This is separate from GameScriptDisplayString because the lifetimes // of the classes differ slightly. class UserDisplayString { public: UserDisplayString(std::string const& key, int x, int y, D3DCOLOR col, FlagArray const & flags, bool translated); private: UserDisplayString() = default; std::string m_key{}; D3DCOLOR m_color{ 0xFFFFFFFF }; FlagArray m_flags{}; int m_x{ 0 }; int m_y{ 0 }; bool m_deleteWhenZero{ false }; //seconds float m_timeRemaining{ 0.0f }; bool m_isInfinite{ false }; bool m_isTranslated{ false }; friend class GameScript; friend class GameScriptDisplayString; }; using DisplayStringIDType = uintptr_t; using SetItemCallback = std::function; using RemoveItemCallback = std::function; using GetItemCallback = std::function>(DisplayStringIDType)>; class GameScriptDisplayString { private: DisplayStringIDType m_id{ 0 }; public: GameScriptDisplayString(); ~GameScriptDisplayString(); DisplayStringIDType GetID() const; static void Register(sol::state* state); void SetPos(int x, int y); std::tuple GetPos() const; void SetCol(GameScriptColor const&); GameScriptColor GetCol(); void SetKey(std::string const&); std::string GetKey() const; static SetItemCallback s_setItemCallback; static RemoveItemCallback s_removeItemCallback; static GetItemCallback s_getItemCallback; // Creating a GameScriptDisplayString requires us to add an identifier // to a data structure. We use callbacks so this class doesn't have // to know about said data structure. static void SetCallbacks(SetItemCallback cba, RemoveItemCallback cbr, GetItemCallback cbg) { s_setItemCallback = cba; s_removeItemCallback = cbr; s_getItemCallback = cbg; } };