1
0
Fork 0

Compare commits

..

1 Commits

Author SHA1 Message Date
SamuXarick cf22c39d64
Merge 3c44d5ba5a into 1d38cbafcb 2025-07-13 23:10:26 +00:00
4 changed files with 17 additions and 17 deletions

View File

@ -43,26 +43,26 @@ SpriteFontCache::SpriteFontCache(FontSize fs) : FontCache(fs)
} }
/** /**
* Get SpriteID associated with a character. * Get SpriteID associated with a GlyphID.
* @param key Character to find. * @param key Glyph to find.
* @return SpriteID for character, or 0 if not present. * @return SpriteID of glyph, or 0 if not present.
*/ */
SpriteID SpriteFontCache::GetUnicodeGlyph(char32_t key) SpriteID SpriteFontCache::GetUnicodeGlyph(GlyphID key)
{ {
const auto found = this->char_map.find(key); const auto found = this->glyph_to_spriteid_map.find(key & ~SPRITE_GLYPH);
if (found == std::end(this->char_map)) return 0; if (found == std::end(this->glyph_to_spriteid_map)) return 0;
return found->second; return found->second;
} }
void SpriteFontCache::SetUnicodeGlyph(char32_t key, SpriteID sprite) void SpriteFontCache::SetUnicodeGlyph(char32_t key, SpriteID sprite)
{ {
this->char_map[key] = sprite; this->glyph_to_spriteid_map[key] = sprite;
} }
void SpriteFontCache::InitializeUnicodeGlyphMap() void SpriteFontCache::InitializeUnicodeGlyphMap()
{ {
/* Clear out existing glyph map if it exists */ /* Clear out existing glyph map if it exists */
this->char_map.clear(); this->glyph_to_spriteid_map.clear();
SpriteID base; SpriteID base;
switch (this->fs) { switch (this->fs) {

View File

@ -28,8 +28,8 @@ public:
bool IsBuiltInFont() override { return true; } bool IsBuiltInFont() override { return true; }
private: private:
std::unordered_map<char32_t, SpriteID> char_map{}; ///< Mapping of characters to sprite IDs. std::unordered_map<GlyphID, SpriteID> glyph_to_spriteid_map{}; ///< Mapping of glyphs to sprite IDs.
SpriteID GetUnicodeGlyph(char32_t key); SpriteID GetUnicodeGlyph(GlyphID key);
}; };
#endif /* SPRITEFONTCACHE_H */ #endif /* SPRITEFONTCACHE_H */

View File

@ -24,12 +24,10 @@
#include "api/script_event.hpp" #include "api/script_event.hpp"
#include "api/script_log.hpp" #include "api/script_log.hpp"
#include "../company_type.h" #include "../company_base.h"
#include "../company_func.h"
#include "../fileio_func.h" #include "../fileio_func.h"
#include "../goal_type.h"
#include "../league_type.h" #include "../league_type.h"
#include "../signs_type.h"
#include "../story_type.h"
#include "../misc/endian_buffer.hpp" #include "../misc/endian_buffer.hpp"
#include "../safeguards.h" #include "../safeguards.h"

View File

@ -12,10 +12,12 @@
#include <queue> #include <queue>
#include "../command_type.h" #include "../signs_func.h"
#include "../company_type.h" #include "../vehicle_func.h"
#include "../rail_type.h"
#include "../road_type.h" #include "../road_type.h"
#include "../group.h"
#include "../goal_type.h"
#include "../story_type.h"
#include "script_types.hpp" #include "script_types.hpp"
#include "script_log_types.hpp" #include "script_log_types.hpp"