mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
4 Commits
cf22c39d64
...
1c6a143d5a
Author | SHA1 | Date |
---|---|---|
|
1c6a143d5a | |
|
7546c1acab | |
|
a6143eea21 | |
|
3c44d5ba5a |
|
@ -43,26 +43,26 @@ SpriteFontCache::SpriteFontCache(FontSize fs) : FontCache(fs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get SpriteID associated with a GlyphID.
|
* Get SpriteID associated with a character.
|
||||||
* @param key Glyph to find.
|
* @param key Character to find.
|
||||||
* @return SpriteID of glyph, or 0 if not present.
|
* @return SpriteID for character, or 0 if not present.
|
||||||
*/
|
*/
|
||||||
SpriteID SpriteFontCache::GetUnicodeGlyph(GlyphID key)
|
SpriteID SpriteFontCache::GetUnicodeGlyph(char32_t key)
|
||||||
{
|
{
|
||||||
const auto found = this->glyph_to_spriteid_map.find(key & ~SPRITE_GLYPH);
|
const auto found = this->char_map.find(key);
|
||||||
if (found == std::end(this->glyph_to_spriteid_map)) return 0;
|
if (found == std::end(this->char_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->glyph_to_spriteid_map[key] = sprite;
|
this->char_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->glyph_to_spriteid_map.clear();
|
this->char_map.clear();
|
||||||
|
|
||||||
SpriteID base;
|
SpriteID base;
|
||||||
switch (this->fs) {
|
switch (this->fs) {
|
||||||
|
|
|
@ -28,8 +28,8 @@ public:
|
||||||
bool IsBuiltInFont() override { return true; }
|
bool IsBuiltInFont() override { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<GlyphID, SpriteID> glyph_to_spriteid_map{}; ///< Mapping of glyphs to sprite IDs.
|
std::unordered_map<char32_t, SpriteID> char_map{}; ///< Mapping of characters to sprite IDs.
|
||||||
SpriteID GetUnicodeGlyph(GlyphID key);
|
SpriteID GetUnicodeGlyph(char32_t key);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SPRITEFONTCACHE_H */
|
#endif /* SPRITEFONTCACHE_H */
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
* \li AICargo::CC_POTABLE
|
* \li AICargo::CC_POTABLE
|
||||||
* \li AICargo::CC_NON_POTABLE
|
* \li AICargo::CC_NON_POTABLE
|
||||||
* \li AIVehicleList_Waypoint
|
* \li AIVehicleList_Waypoint
|
||||||
|
* \li AIBaseStation::GetBaseStationID
|
||||||
*
|
*
|
||||||
* Other changes:
|
* Other changes:
|
||||||
* \li AIBridge::GetBridgeID renamed to AIBridge::GetBridgeType
|
* \li AIBridge::GetBridgeID renamed to AIBridge::GetBridgeType
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
* \li GSCargo::CC_NON_POTABLE
|
* \li GSCargo::CC_NON_POTABLE
|
||||||
* \li GSVehicleList_Waypoint
|
* \li GSVehicleList_Waypoint
|
||||||
* \li GSBaseStation::GetOwner
|
* \li GSBaseStation::GetOwner
|
||||||
|
* \li GSBaseStation::GetBaseStationID
|
||||||
*
|
*
|
||||||
* Other changes:
|
* Other changes:
|
||||||
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
|
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
|
||||||
|
|
|
@ -34,6 +34,12 @@
|
||||||
return ScriptCompany::ToScriptCompanyID(::BaseStation::Get(station_id)->owner);
|
return ScriptCompany::ToScriptCompanyID(::BaseStation::Get(station_id)->owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ StationID ScriptBaseStation::GetBaseStationID(TileIndex tile)
|
||||||
|
{
|
||||||
|
if (!::IsValidTile(tile) || !::IsTileType(tile, MP_STATION) || ::BaseStation::GetByTile(tile) == nullptr) return StationID::Invalid();
|
||||||
|
return ::GetStationIndex(tile);
|
||||||
|
}
|
||||||
|
|
||||||
/* static */ std::optional<std::string> ScriptBaseStation::GetName(StationID station_id)
|
/* static */ std::optional<std::string> ScriptBaseStation::GetName(StationID station_id)
|
||||||
{
|
{
|
||||||
if (!IsValidBaseStation(station_id)) return std::nullopt;
|
if (!IsValidBaseStation(station_id)) return std::nullopt;
|
||||||
|
|
|
@ -42,6 +42,15 @@ public:
|
||||||
*/
|
*/
|
||||||
static ScriptCompany::CompanyID GetOwner(StationID station_id);
|
static ScriptCompany::CompanyID GetOwner(StationID station_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the StationID of a tile, if there is a basestation.
|
||||||
|
* @param tile The tile to find the StationID of.
|
||||||
|
* @pre IsValidTile(tile).
|
||||||
|
* @return StationID of the basestation.
|
||||||
|
* @post Use IsValidBaseStation() to see if the basestation is valid.
|
||||||
|
*/
|
||||||
|
static StationID GetBaseStationID(TileIndex tile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of a basestation.
|
* Get the name of a basestation.
|
||||||
* @param station_id The basestation to get the name of.
|
* @param station_id The basestation to get the name of.
|
||||||
|
|
|
@ -24,10 +24,12 @@
|
||||||
#include "api/script_event.hpp"
|
#include "api/script_event.hpp"
|
||||||
#include "api/script_log.hpp"
|
#include "api/script_log.hpp"
|
||||||
|
|
||||||
#include "../company_base.h"
|
#include "../company_type.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"
|
||||||
|
|
|
@ -12,12 +12,10 @@
|
||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
#include "../signs_func.h"
|
#include "../command_type.h"
|
||||||
#include "../vehicle_func.h"
|
#include "../company_type.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"
|
||||||
|
|
Loading…
Reference in New Issue