mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
1 Commits
cd5d13a692
...
d47951a0a6
Author | SHA1 | Date |
---|---|---|
|
d47951a0a6 |
|
@ -90,7 +90,7 @@ template <> SQInteger PushClassName<AIInfo, ScriptType::AI>(HSQUIRRELVM vm) { sq
|
|||
/* Remove the link to the real instance, else it might get deleted by RegisterAI() */
|
||||
sq_setinstanceup(vm, 2, nullptr);
|
||||
/* Register the AI to the base system */
|
||||
info->GetScanner()->RegisterScript(std::unique_ptr<AIInfo>{info});
|
||||
info->GetScanner()->RegisterScript(info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -136,21 +136,22 @@ bool AIInfo::CanLoadFromVersion(int version) const
|
|||
/* static */ SQInteger AILibrary::Constructor(HSQUIRRELVM vm)
|
||||
{
|
||||
/* Create a new library */
|
||||
auto library = std::make_unique<AILibrary>();
|
||||
AILibrary *library = new AILibrary();
|
||||
|
||||
SQInteger res = ScriptInfo::Constructor(vm, *library);
|
||||
if (res != 0) {
|
||||
delete library;
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Cache the category */
|
||||
if (!library->CheckMethod("GetCategory") || !library->engine->CallStringMethod(library->SQ_instance, "GetCategory", &library->category, MAX_GET_OPS)) {
|
||||
delete library;
|
||||
return SQ_ERROR;
|
||||
}
|
||||
|
||||
/* Register the Library to the base system */
|
||||
ScriptScanner *scanner = library->GetScanner();
|
||||
scanner->RegisterScript(std::move(library));
|
||||
library->GetScanner()->RegisterScript(library);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ void AIScannerInfo::Initialize()
|
|||
{
|
||||
ScriptScanner::Initialize("AIScanner");
|
||||
|
||||
ScriptAllocatorScope alloc_scope(this->engine.get());
|
||||
ScriptAllocatorScope alloc_scope(this->engine);
|
||||
|
||||
/* Create the dummy AI */
|
||||
this->main_script = "%_dummy";
|
||||
|
|
|
@ -22,10 +22,9 @@
|
|||
|
||||
#include "safeguards.h"
|
||||
|
||||
/** Default unscaled heights for the different sizes of fonts. */
|
||||
/* static */ const int FontCache::DEFAULT_FONT_HEIGHT[FS_END] = {10, 6, 18, 10};
|
||||
/** Default unscaled ascenders for the different sizes of fonts. */
|
||||
/* static */ const int FontCache::DEFAULT_FONT_ASCENDER[FS_END] = {8, 5, 15, 8};
|
||||
/** Default heights for the different sizes of fonts. */
|
||||
static const int _default_font_height[FS_END] = {10, 6, 18, 10};
|
||||
static const int _default_font_ascender[FS_END] = { 8, 5, 15, 8};
|
||||
|
||||
FontCacheSettings _fcsettings;
|
||||
|
||||
|
@ -33,7 +32,8 @@ FontCacheSettings _fcsettings;
|
|||
* Create a new font cache.
|
||||
* @param fs The size of the font.
|
||||
*/
|
||||
FontCache::FontCache(FontSize fs) : parent(FontCache::Get(fs)), fs(fs)
|
||||
FontCache::FontCache(FontSize fs) : parent(FontCache::Get(fs)), fs(fs), height(_default_font_height[fs]),
|
||||
ascender(_default_font_ascender[fs]), descender(_default_font_ascender[fs] - _default_font_height[fs])
|
||||
{
|
||||
assert(this->parent == nullptr || this->fs == this->parent->fs);
|
||||
FontCache::caches[this->fs] = this;
|
||||
|
@ -50,7 +50,7 @@ FontCache::~FontCache()
|
|||
|
||||
int FontCache::GetDefaultFontHeight(FontSize fs)
|
||||
{
|
||||
return FontCache::DEFAULT_FONT_HEIGHT[fs];
|
||||
return _default_font_height[fs];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,9 +23,9 @@ protected:
|
|||
static FontCache *caches[FS_END]; ///< All the font caches.
|
||||
FontCache *parent; ///< The parent of this font cache.
|
||||
const FontSize fs; ///< The size of the font.
|
||||
int height = 0; ///< The height of the font.
|
||||
int ascender = 0; ///< The ascender value of the font.
|
||||
int descender = 0; ///< The descender value of the font.
|
||||
int height; ///< The height of the font.
|
||||
int ascender; ///< The ascender value of the font.
|
||||
int descender; ///< The descender value of the font.
|
||||
|
||||
public:
|
||||
FontCache(FontSize fs);
|
||||
|
@ -33,11 +33,6 @@ public:
|
|||
|
||||
static void InitializeFontCaches();
|
||||
|
||||
/** Default unscaled font heights. */
|
||||
static const int DEFAULT_FONT_HEIGHT[FS_END];
|
||||
/** Default unscaled font ascenders. */
|
||||
static const int DEFAULT_FONT_ASCENDER[FS_END];
|
||||
|
||||
static int GetDefaultFontHeight(FontSize fs);
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,26 +43,26 @@ SpriteFontCache::SpriteFontCache(FontSize fs) : FontCache(fs)
|
|||
}
|
||||
|
||||
/**
|
||||
* Get SpriteID associated with a character.
|
||||
* @param key Character to find.
|
||||
* @return SpriteID for character, or 0 if not present.
|
||||
* Get SpriteID associated with a GlyphID.
|
||||
* @param key Glyph to find.
|
||||
* @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);
|
||||
if (found == std::end(this->char_map)) return 0;
|
||||
const auto found = this->glyph_to_spriteid_map.find(key & ~SPRITE_GLYPH);
|
||||
if (found == std::end(this->glyph_to_spriteid_map)) return 0;
|
||||
return found->second;
|
||||
}
|
||||
|
||||
void SpriteFontCache::SetUnicodeGlyph(char32_t key, SpriteID sprite)
|
||||
{
|
||||
this->char_map[key] = sprite;
|
||||
this->glyph_to_spriteid_map[key] = sprite;
|
||||
}
|
||||
|
||||
void SpriteFontCache::InitializeUnicodeGlyphMap()
|
||||
{
|
||||
/* Clear out existing glyph map if it exists */
|
||||
this->char_map.clear();
|
||||
this->glyph_to_spriteid_map.clear();
|
||||
|
||||
SpriteID base;
|
||||
switch (this->fs) {
|
||||
|
@ -103,14 +103,14 @@ void SpriteFontCache::ClearFontCache()
|
|||
|
||||
const Sprite *SpriteFontCache::GetGlyph(GlyphID key)
|
||||
{
|
||||
SpriteID sprite = static_cast<SpriteID>(key & ~SPRITE_GLYPH);
|
||||
SpriteID sprite = this->GetUnicodeGlyph(static_cast<char32_t>(key & ~SPRITE_GLYPH));
|
||||
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
||||
return GetSprite(sprite, SpriteType::Font);
|
||||
}
|
||||
|
||||
uint SpriteFontCache::GetGlyphWidth(GlyphID key)
|
||||
{
|
||||
SpriteID sprite = static_cast<SpriteID>(key & ~SPRITE_GLYPH);
|
||||
SpriteID sprite = this->GetUnicodeGlyph(static_cast<char32_t>(key & ~SPRITE_GLYPH));
|
||||
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
||||
return SpriteExists(sprite) ? GetSprite(sprite, SpriteType::Font)->width + ScaleFontTrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ GlyphID SpriteFontCache::MapCharToGlyph(char32_t key, [[maybe_unused]] bool allo
|
|||
assert(IsPrintable(key));
|
||||
SpriteID sprite = this->GetUnicodeGlyph(key);
|
||||
if (sprite == 0) return 0;
|
||||
return SPRITE_GLYPH | sprite;
|
||||
return SPRITE_GLYPH | key;
|
||||
}
|
||||
|
||||
bool SpriteFontCache::GetDrawGlyphShadow()
|
||||
|
|
|
@ -28,8 +28,8 @@ public:
|
|||
bool IsBuiltInFont() override { return true; }
|
||||
|
||||
private:
|
||||
std::unordered_map<char32_t, SpriteID> char_map{}; ///< Mapping of characters to sprite IDs.
|
||||
SpriteID GetUnicodeGlyph(char32_t key);
|
||||
std::unordered_map<GlyphID, SpriteID> glyph_to_spriteid_map{}; ///< Mapping of glyphs to sprite IDs.
|
||||
SpriteID GetUnicodeGlyph(GlyphID key);
|
||||
};
|
||||
|
||||
#endif /* SPRITEFONTCACHE_H */
|
||||
|
|
|
@ -78,7 +78,7 @@ template <> SQInteger PushClassName<GameInfo, ScriptType::GS>(HSQUIRRELVM vm) {
|
|||
/* Remove the link to the real instance, else it might get deleted by RegisterGame() */
|
||||
sq_setinstanceup(vm, 2, nullptr);
|
||||
/* Register the Game to the base system */
|
||||
info->GetScanner()->RegisterScript(std::unique_ptr<GameInfo>{info});
|
||||
info->GetScanner()->RegisterScript(info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -106,21 +106,22 @@ bool GameInfo::CanLoadFromVersion(int version) const
|
|||
/* static */ SQInteger GameLibrary::Constructor(HSQUIRRELVM vm)
|
||||
{
|
||||
/* Create a new library */
|
||||
auto library = std::make_unique<GameLibrary>();
|
||||
GameLibrary *library = new GameLibrary();
|
||||
|
||||
SQInteger res = ScriptInfo::Constructor(vm, *library);
|
||||
if (res != 0) {
|
||||
delete library;
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Cache the category */
|
||||
if (!library->CheckMethod("GetCategory") || !library->engine->CallStringMethod(library->SQ_instance, "GetCategory", &library->category, MAX_GET_OPS)) {
|
||||
delete library;
|
||||
return SQ_ERROR;
|
||||
}
|
||||
|
||||
/* Register the Library to the base system */
|
||||
ScriptScanner *scanner = library->GetScanner();
|
||||
scanner->RegisterScript(std::move(library));
|
||||
library->GetScanner()->RegisterScript(library);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -92,8 +92,8 @@ GameLibrary *GameScannerLibrary::FindLibrary(const std::string &library, int ver
|
|||
std::string library_name = fmt::format("{}.{}", library, version);
|
||||
|
||||
/* Check if the library + version exists */
|
||||
auto it = this->info_list.find(library_name);
|
||||
ScriptInfoList::iterator it = this->info_list.find(library_name);
|
||||
if (it == this->info_list.end()) return nullptr;
|
||||
|
||||
return static_cast<GameLibrary *>(it->second);
|
||||
return static_cast<GameLibrary *>((*it).second);
|
||||
}
|
||||
|
|
|
@ -267,7 +267,6 @@ STR_UNITS_YEARS :{NUM}{NBSP}jaar
|
|||
STR_UNITS_PERIODS :{NUM}{NBSP}period{P "" en}
|
||||
|
||||
STR_LIST_SEPARATOR :,{SPACE}
|
||||
STR_TRUNCATION_ELLIPSIS :...
|
||||
|
||||
# Common window strings
|
||||
STR_LIST_FILTER_TITLE :{BLACK}Filter:
|
||||
|
|
|
@ -267,7 +267,6 @@ STR_UNITS_YEARS :{NUM}{NBSP}year
|
|||
STR_UNITS_PERIODS :{NUM}{NBSP}period{P "" s}
|
||||
|
||||
STR_LIST_SEPARATOR :,{SPACE}
|
||||
STR_TRUNCATION_ELLIPSIS :...
|
||||
|
||||
# Common window strings
|
||||
STR_LIST_FILTER_TITLE :{BLACK}Filter:
|
||||
|
|
|
@ -268,7 +268,6 @@ STR_UNITS_YEARS :{NUM}{NBSP}ano{
|
|||
STR_UNITS_PERIODS :{NUM}{NBSP}período{P "" s}
|
||||
|
||||
STR_LIST_SEPARATOR :,{SPACE}
|
||||
STR_TRUNCATION_ELLIPSIS :...
|
||||
|
||||
# Common window strings
|
||||
STR_LIST_FILTER_TITLE :{BLACK}Filtrar:
|
||||
|
@ -1303,9 +1302,6 @@ STR_CONFIG_SETTING_INTEREST_RATE_HELPTEXT :A taxa de inter
|
|||
STR_CONFIG_SETTING_RUNNING_COSTS :Custos de explotación: {STRING}
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS_HELPTEXT :Establece o nivel de mantemento e custo de operación de vehículos e infraestrutura
|
||||
###length 3
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS_LOW :Baixo
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS_MEDIUM :Medio
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS_HIGH :Alto
|
||||
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_SPEED :Velocidade de construción: {STRING}
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_SPEED_HELPTEXT :Limita a cantidade de accións construtivas das IAs
|
||||
|
@ -1328,9 +1324,6 @@ STR_CONFIG_SETTING_SUBSIDY_DURATION_DISABLED :Sen subvención
|
|||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS :Custos de construción: {STRING}
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS_HELPTEXT :Fixa o nivel de custos de construción e compra
|
||||
###length 3
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS_LOW :Baixo
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS_MEDIUM :Medio
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS_HIGH :Alto
|
||||
|
||||
STR_CONFIG_SETTING_RECESSIONS :Recesións económicas: {STRING}
|
||||
STR_CONFIG_SETTING_RECESSIONS_HELPTEXT :Se está activado, a economía pode entrar en recesión periódicamente. Durante unha recesión tódalas producións son significativamente máis baixas (volvendo ao nivel anterior cando a recesión remata)
|
||||
|
@ -2086,9 +2079,9 @@ STR_CONFIG_SETTING_DISTRIBUTION_ARMOURED_HELPTEXT :A clase de merc
|
|||
STR_CONFIG_SETTING_DISTRIBUTION_DEFAULT :Xeito de distribución para outros tipos de mercadoría: {STRING}
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_DEFAULT_HELPTEXT :"Asimétrico" significa que calquera cantidade de mercadorías pode ser enviada en calquera dirección. "Manual" significa que non haberá distribución automática para estas mercadorías
|
||||
###length 3
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_MANUAL :Manual
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_ASYMMETRIC :Asimétrica
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_SYMMETRIC :Simétrica
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_MANUAL :manual
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_ASYMMETRIC :asimétrica
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_SYMMETRIC :simétrica
|
||||
|
||||
STR_CONFIG_SETTING_LINKGRAPH_ACCURACY :Precisión da distribución: {STRING}
|
||||
STR_CONFIG_SETTING_LINKGRAPH_ACCURACY_HELPTEXT :Canto máis alto sexa o valor, máis tempo de CPU levará o cálculo de distribución. Se leva demasiado tempo podes experimentar retraso. Se sen embargo o fixas nun valor baixo, a distribución será imprecisa, e pode que a carga non sexa enviada aos destinos que ti queres
|
||||
|
|
|
@ -739,7 +739,7 @@ STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK :{BLACK}Clique n
|
|||
STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK :{BLACK}Clique numa faixa para a remover da lista (apenas Personalização 1 ou Personalização 2)
|
||||
|
||||
# Highscore window
|
||||
STR_HIGHSCORE_TOP_COMPANIES :{BIG_FONT}{BLACK}As melhores empresas
|
||||
STR_HIGHSCORE_TOP_COMPANIES :{BIG_FONT}{BLACK}Melhores empresas
|
||||
STR_HIGHSCORE_POSITION :{BIG_FONT}{BLACK}{COMMA}.
|
||||
STR_HIGHSCORE_PERFORMANCE_TITLE_BUSINESSMAN :Negociante
|
||||
STR_HIGHSCORE_PERFORMANCE_TITLE_ENTREPRENEUR :Empresário
|
||||
|
@ -749,7 +749,7 @@ STR_HIGHSCORE_PERFORMANCE_TITLE_MAGNATE :Magnata
|
|||
STR_HIGHSCORE_PERFORMANCE_TITLE_MOGUL :Grande magnata
|
||||
STR_HIGHSCORE_PERFORMANCE_TITLE_TYCOON_OF_THE_CENTURY :Magnata do século
|
||||
STR_HIGHSCORE_NAME :{PRESIDENT_NAME}, {COMPANY}
|
||||
STR_HIGHSCORE_STATS :{BIG_FONT}"{STRING}" ({COMMA})
|
||||
STR_HIGHSCORE_STATS :{BIG_FONT}'{STRING}' ({COMMA})
|
||||
STR_HIGHSCORE_COMPANY_ACHIEVES_STATUS :{BIG_FONT}{BLACK}{COMPANY} conquista o estatuto de '{STRING}'!
|
||||
STR_HIGHSCORE_PRESIDENT_OF_COMPANY_ACHIEVES_STATUS :{BIG_FONT}{WHITE}{PRESIDENT_NAME} de {COMPANY} conquista o estatuto de '{STRING}'!
|
||||
|
||||
|
@ -3117,8 +3117,8 @@ STR_INDUSTRY_CARGOES_SELECT_INDUSTRY_TOOLTIP :{BLACK}Selecion
|
|||
# Land area window
|
||||
STR_LAND_AREA_INFORMATION_CAPTION :{WHITE}Informações do Terreno
|
||||
STR_LAND_AREA_INFORMATION_LOCATION_TOOLTIP :{BLACK}Centrar visualização na localização do mosaico. Ctrl+Clique para abrir uma nova janela de visualização nesse mosaico.
|
||||
STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A :{BLACK}Custo de desobstrução: {LTBLUE}N/D
|
||||
STR_LAND_AREA_INFORMATION_COST_TO_CLEAR :{BLACK}Custo de desobstrução: {RED}{CURRENCY_LONG}
|
||||
STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A :{BLACK}Custo para limpar: {LTBLUE}N/D
|
||||
STR_LAND_AREA_INFORMATION_COST_TO_CLEAR :{BLACK}Custo para limpar: {RED}{CURRENCY_LONG}
|
||||
STR_LAND_AREA_INFORMATION_REVENUE_WHEN_CLEARED :{BLACK}Receitas apuradas: {LTBLUE}{CURRENCY_LONG}
|
||||
STR_LAND_AREA_INFORMATION_OWNER_N_A :N/D
|
||||
STR_LAND_AREA_INFORMATION_OWNER :{BLACK}Proprietário: {LTBLUE}{STRING}
|
||||
|
@ -3126,7 +3126,7 @@ STR_LAND_AREA_INFORMATION_ROAD_OWNER :{BLACK}Dono da
|
|||
STR_LAND_AREA_INFORMATION_TRAM_OWNER :{BLACK}Dono da linha de eléctrico: {LTBLUE}{STRING}
|
||||
STR_LAND_AREA_INFORMATION_RAIL_OWNER :{BLACK}Dono da linha férrea: {LTBLUE}{STRING}
|
||||
STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY :{BLACK}Autoridade local: {LTBLUE}{STRING}
|
||||
STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE :Nenhuma
|
||||
STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE :Nenhum
|
||||
STR_LAND_AREA_INFORMATION_LANDINFO_COORDS :{BLACK}Coordenadas: {LTBLUE}{NUM} x {NUM} x {NUM}
|
||||
STR_LAND_AREA_INFORMATION_LANDINFO_INDEX :{BLACK}Índice do mosaico: {LTBLUE}{NUM} ({HEX})
|
||||
STR_LAND_AREA_INFORMATION_BUILD_DATE :{BLACK}Construído/renovado: {LTBLUE}{DATE_LONG}
|
||||
|
@ -3685,9 +3685,9 @@ STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER :{BLACK}No inver
|
|||
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED_GENERAL :{ORANGE}{STRING}{GREEN} fo{G 0 i i i ram ram} entregue{G 0 "" "" "" s s}
|
||||
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED :{ORANGE}{CARGO_TINY} / {CARGO_LONG}{RED} (ainda necessário)
|
||||
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED :{ORANGE}{CARGO_TINY} / {CARGO_LONG}{GREEN} (entregue)
|
||||
STR_TOWN_VIEW_TOWN_GROWS_EVERY :{BLACK}A localidade cresce a cada {ORANGE}{UNITS_DAYS_OR_SECONDS}
|
||||
STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED :{BLACK}A localidade cresce a cada {ORANGE}{UNITS_DAYS_OR_SECONDS} (financiada)
|
||||
STR_TOWN_VIEW_TOWN_GROW_STOPPED :{BLACK}A localidade {RED}não{BLACK} está a crescer
|
||||
STR_TOWN_VIEW_TOWN_GROWS_EVERY :{BLACK}Localidade cresce a cada {ORANGE}{UNITS_DAYS_OR_SECONDS}
|
||||
STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED :{BLACK}Localidade cresce a cada {ORANGE}{UNITS_DAYS_OR_SECONDS} (financiada)
|
||||
STR_TOWN_VIEW_TOWN_GROW_STOPPED :{BLACK}Localidade {RED}não{BLACK} está a crescer
|
||||
STR_TOWN_VIEW_NOISE_IN_TOWN :{BLACK}Limite de ruído na localidade: {ORANGE}{COMMA}{BLACK} máx: {ORANGE}{COMMA}
|
||||
STR_TOWN_VIEW_CENTER_TOOLTIP :{BLACK}Centrar visualização na localização da localidade. Ctrl+Clique para abrir um novo visualizador na localização da localidade
|
||||
STR_TOWN_VIEW_LOCAL_AUTHORITY_BUTTON :{BLACK}Autoridade Local
|
||||
|
@ -3700,7 +3700,7 @@ STR_TOWN_VIEW_EXPAND_BUILDINGS_BUTTON :{BLACK}Expandir
|
|||
STR_TOWN_VIEW_EXPAND_BUILDINGS_TOOLTIP :{BLACK}Aumentar os edifícios da localidade
|
||||
STR_TOWN_VIEW_EXPAND_ROADS_BUTTON :{BLACK}Expandir estradas
|
||||
STR_TOWN_VIEW_EXPAND_ROADS_TOOLTIP :{BLACK}Aumentar as estradas da localidade
|
||||
STR_TOWN_VIEW_DELETE_BUTTON :{BLACK}Remover
|
||||
STR_TOWN_VIEW_DELETE_BUTTON :{BLACK}Apagar
|
||||
STR_TOWN_VIEW_DELETE_TOOLTIP :{BLACK}Remover completamente esta localidade
|
||||
|
||||
STR_TOWN_VIEW_RENAME_TOWN_BUTTON :Renomear Localidade
|
||||
|
@ -3943,7 +3943,7 @@ STR_FINANCES_INFRASTRUCTURE_BUTTON :{BLACK}Infraest
|
|||
STR_COMPANY_VIEW_CAPTION :{WHITE}{COMPANY} {BLACK}{COMPANY_NUM}
|
||||
STR_COMPANY_VIEW_PRESIDENT_MANAGER_TITLE :{WHITE}{PRESIDENT_NAME}{}{GOLD}(Presidente)
|
||||
|
||||
STR_COMPANY_VIEW_INAUGURATED_TITLE :{GOLD}Inaugurada em: {WHITE}{NUM}
|
||||
STR_COMPANY_VIEW_INAUGURATED_TITLE :{GOLD}Inaugurado: {WHITE}{NUM}
|
||||
STR_COMPANY_VIEW_INAUGURATED_TITLE_WALLCLOCK :{GOLD}Inaugurada: {WHITE}{NUM} (período {NUM})
|
||||
STR_COMPANY_VIEW_COLOUR_SCHEME_TITLE :{GOLD}Cores:
|
||||
STR_COMPANY_VIEW_VEHICLES_TITLE :{GOLD}Veículos:
|
||||
|
|
|
@ -268,7 +268,6 @@ STR_UNITS_YEARS :{NUM}{NBSP}año
|
|||
STR_UNITS_PERIODS :{NUM}{NBSP}período{P "" s}
|
||||
|
||||
STR_LIST_SEPARATOR :,{SPACE}
|
||||
STR_TRUNCATION_ELLIPSIS :...
|
||||
|
||||
# Common window strings
|
||||
STR_LIST_FILTER_TITLE :{BLACK}Filtrar:
|
||||
|
|
|
@ -24,12 +24,10 @@
|
|||
#include "api/script_event.hpp"
|
||||
#include "api/script_log.hpp"
|
||||
|
||||
#include "../company_type.h"
|
||||
#include "../company_base.h"
|
||||
#include "../company_func.h"
|
||||
#include "../fileio_func.h"
|
||||
#include "../goal_type.h"
|
||||
#include "../league_type.h"
|
||||
#include "../signs_type.h"
|
||||
#include "../story_type.h"
|
||||
#include "../misc/endian_buffer.hpp"
|
||||
|
||||
#include "../safeguards.h"
|
||||
|
|
|
@ -44,7 +44,10 @@ bool ScriptScanner::AddFile(const std::string &filename, size_t, const std::stri
|
|||
return true;
|
||||
}
|
||||
|
||||
ScriptScanner::ScriptScanner() = default;
|
||||
ScriptScanner::ScriptScanner() :
|
||||
engine(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void ScriptScanner::ResetEngine()
|
||||
{
|
||||
|
@ -55,7 +58,7 @@ void ScriptScanner::ResetEngine()
|
|||
|
||||
void ScriptScanner::Initialize(std::string_view name)
|
||||
{
|
||||
this->engine = std::make_unique<Squirrel>(name);
|
||||
this->engine = new Squirrel(name);
|
||||
|
||||
this->RescanDir();
|
||||
|
||||
|
@ -65,6 +68,8 @@ void ScriptScanner::Initialize(std::string_view name)
|
|||
ScriptScanner::~ScriptScanner()
|
||||
{
|
||||
this->Reset();
|
||||
|
||||
delete this->engine;
|
||||
}
|
||||
|
||||
void ScriptScanner::RescanDir()
|
||||
|
@ -78,12 +83,15 @@ void ScriptScanner::RescanDir()
|
|||
|
||||
void ScriptScanner::Reset()
|
||||
{
|
||||
for (const auto &item : this->info_list) {
|
||||
delete item.second;
|
||||
}
|
||||
|
||||
this->info_list.clear();
|
||||
this->info_single_list.clear();
|
||||
this->info_vector.clear();
|
||||
}
|
||||
|
||||
void ScriptScanner::RegisterScript(std::unique_ptr<ScriptInfo> &&info)
|
||||
void ScriptScanner::RegisterScript(ScriptInfo *info)
|
||||
{
|
||||
std::string script_original_name = this->GetScriptName(*info);
|
||||
std::string script_name = fmt::format("{}.{}", script_original_name, info->GetVersion());
|
||||
|
@ -91,6 +99,7 @@ void ScriptScanner::RegisterScript(std::unique_ptr<ScriptInfo> &&info)
|
|||
/* Check if GetShortName follows the rules */
|
||||
if (info->GetShortName().size() != 4) {
|
||||
Debug(script, 0, "The script '{}' returned a string from GetShortName() which is not four characters. Unable to load the script.", info->GetName());
|
||||
delete info;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -102,6 +111,7 @@ void ScriptScanner::RegisterScript(std::unique_ptr<ScriptInfo> &&info)
|
|||
#else
|
||||
if (it->second->GetMainScript() == info->GetMainScript()) {
|
||||
#endif
|
||||
delete info;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -110,20 +120,20 @@ void ScriptScanner::RegisterScript(std::unique_ptr<ScriptInfo> &&info)
|
|||
Debug(script, 1, " 2: {}", info->GetMainScript());
|
||||
Debug(script, 1, "The first is taking precedence.");
|
||||
|
||||
delete info;
|
||||
return;
|
||||
}
|
||||
|
||||
ScriptInfo *script_info = this->info_vector.emplace_back(std::move(info)).get();
|
||||
this->info_list[script_name] = script_info;
|
||||
this->info_list[script_name] = info;
|
||||
|
||||
if (!script_info->IsDeveloperOnly() || _settings_client.gui.ai_developer_tools) {
|
||||
if (!info->IsDeveloperOnly() || _settings_client.gui.ai_developer_tools) {
|
||||
/* Add the script to the 'unique' script list, where only the highest version
|
||||
* of the script is registered. */
|
||||
auto it = this->info_single_list.find(script_original_name);
|
||||
if (it == this->info_single_list.end()) {
|
||||
this->info_single_list[script_original_name] = script_info;
|
||||
} else if (it->second->GetVersion() < script_info->GetVersion()) {
|
||||
it->second = script_info;
|
||||
this->info_single_list[script_original_name] = info;
|
||||
} else if (it->second->GetVersion() < info->GetVersion()) {
|
||||
it->second = info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -185,17 +195,17 @@ struct ScriptFileChecksumCreator : FileScanner {
|
|||
* @param info The script to get the shortname and md5 sum from.
|
||||
* @return True iff they're the same.
|
||||
*/
|
||||
static bool IsSameScript(const ContentInfo &ci, bool md5sum, const ScriptInfo &info, Subdirectory dir)
|
||||
static bool IsSameScript(const ContentInfo &ci, bool md5sum, ScriptInfo *info, Subdirectory dir)
|
||||
{
|
||||
uint32_t id = 0;
|
||||
auto str = std::string_view{info.GetShortName()}.substr(0, 4);
|
||||
auto str = std::string_view{info->GetShortName()}.substr(0, 4);
|
||||
for (size_t j = 0; j < str.size(); j++) id |= static_cast<uint8_t>(str[j]) << (8 * j);
|
||||
|
||||
if (id != ci.unique_id) return false;
|
||||
if (!md5sum) return true;
|
||||
|
||||
ScriptFileChecksumCreator checksum(dir);
|
||||
const auto &tar_filename = info.GetTarFile();
|
||||
const auto &tar_filename = info->GetTarFile();
|
||||
TarList::iterator iter;
|
||||
if (!tar_filename.empty() && (iter = _tar_list[dir].find(tar_filename)) != _tar_list[dir].end()) {
|
||||
/* The main script is in a tar file, so find all files that
|
||||
|
@ -214,7 +224,7 @@ static bool IsSameScript(const ContentInfo &ci, bool md5sum, const ScriptInfo &i
|
|||
/* There'll always be at least 1 path separator character in a script
|
||||
* main script name as the search algorithm requires the main script to
|
||||
* be in a subdirectory of the script directory; so <dir>/<path>/main.nut. */
|
||||
const std::string &main_script = info.GetMainScript();
|
||||
const std::string &main_script = info->GetMainScript();
|
||||
std::string path = main_script.substr(0, main_script.find_last_of(PATHSEPCHAR));
|
||||
checksum.Scan(".nut", path);
|
||||
}
|
||||
|
@ -225,7 +235,7 @@ static bool IsSameScript(const ContentInfo &ci, bool md5sum, const ScriptInfo &i
|
|||
bool ScriptScanner::HasScript(const ContentInfo &ci, bool md5sum)
|
||||
{
|
||||
for (const auto &item : this->info_list) {
|
||||
if (IsSameScript(ci, md5sum, *item.second, this->GetDirectory())) return true;
|
||||
if (IsSameScript(ci, md5sum, item.second, this->GetDirectory())) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -233,7 +243,7 @@ bool ScriptScanner::HasScript(const ContentInfo &ci, bool md5sum)
|
|||
std::optional<std::string_view> ScriptScanner::FindMainScript(const ContentInfo &ci, bool md5sum)
|
||||
{
|
||||
for (const auto &item : this->info_list) {
|
||||
if (IsSameScript(ci, md5sum, *item.second, this->GetDirectory())) return item.second->GetMainScript();
|
||||
if (IsSameScript(ci, md5sum, item.second, this->GetDirectory())) return item.second->GetMainScript();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "../fileio_func.h"
|
||||
#include "../string_func.h"
|
||||
|
||||
using ScriptInfoList = std::map<std::string, class ScriptInfo *, CaseInsensitiveComparator>; ///< Type for the list of scripts.
|
||||
typedef std::map<std::string, class ScriptInfo *, CaseInsensitiveComparator> ScriptInfoList; ///< Type for the list of scripts.
|
||||
|
||||
/** Scanner to help finding scripts. */
|
||||
class ScriptScanner : public FileScanner {
|
||||
|
@ -26,7 +26,7 @@ public:
|
|||
/**
|
||||
* Get the engine of the main squirrel handler (it indexes all available scripts).
|
||||
*/
|
||||
class Squirrel *GetEngine() { return this->engine.get(); }
|
||||
class Squirrel *GetEngine() { return this->engine; }
|
||||
|
||||
/**
|
||||
* Get the current main script the ScanDir is currently tracking.
|
||||
|
@ -51,7 +51,7 @@ public:
|
|||
/**
|
||||
* Register a ScriptInfo to the scanner.
|
||||
*/
|
||||
void RegisterScript(std::unique_ptr<class ScriptInfo> &&info);
|
||||
void RegisterScript(class ScriptInfo *info);
|
||||
|
||||
/**
|
||||
* Get the list of registered scripts to print on the console.
|
||||
|
@ -84,13 +84,11 @@ public:
|
|||
void RescanDir();
|
||||
|
||||
protected:
|
||||
std::unique_ptr<class Squirrel> engine; ///< The engine we're scanning with.
|
||||
class Squirrel *engine; ///< The engine we're scanning with.
|
||||
std::string main_script; ///< The full path of the script.
|
||||
std::string tar_file; ///< If, which tar file the script was in.
|
||||
|
||||
std::vector<std::unique_ptr<ScriptInfo>> info_vector;
|
||||
|
||||
ScriptInfoList info_list; ///< The list of all script.
|
||||
ScriptInfoList info_list; ///< The list of all script.
|
||||
ScriptInfoList info_single_list; ///< The list of all unique script. The best script (highest version) is shown.
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,10 +12,12 @@
|
|||
|
||||
#include <queue>
|
||||
|
||||
#include "../command_type.h"
|
||||
#include "../company_type.h"
|
||||
#include "../rail_type.h"
|
||||
#include "../signs_func.h"
|
||||
#include "../vehicle_func.h"
|
||||
#include "../road_type.h"
|
||||
#include "../group.h"
|
||||
#include "../goal_type.h"
|
||||
#include "../story_type.h"
|
||||
|
||||
#include "script_types.hpp"
|
||||
#include "script_log_types.hpp"
|
||||
|
|
|
@ -401,40 +401,6 @@ static void CancelIMEComposition(HWND hwnd)
|
|||
HandleTextInput({}, true);
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER) && defined(NTDDI_WIN10_RS4)
|
||||
/* We only use WinRT functions on Windows 10 or later. Unfortunately, newer Windows SDKs are now
|
||||
* linking the two functions below directly instead of using dynamic linking as previously.
|
||||
* To avoid any runtime linking errors on Windows 7 or older, we stub in our own dynamic
|
||||
* linking trampoline. */
|
||||
|
||||
static LibraryLoader _combase("combase.dll");
|
||||
|
||||
extern "C" int32_t __stdcall WINRT_IMPL_RoOriginateLanguageException(int32_t error, void *message, void *languageException) noexcept
|
||||
{
|
||||
typedef BOOL(WINAPI *PFNRoOriginateLanguageException)(int32_t, void *, void *);
|
||||
static PFNRoOriginateLanguageException RoOriginateLanguageException = _combase.GetFunction("RoOriginateLanguageException");
|
||||
|
||||
if (RoOriginateLanguageException != nullptr) {
|
||||
return RoOriginateLanguageException(error, message, languageException);
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int32_t __stdcall WINRT_IMPL_RoGetActivationFactory(void *classId, winrt::guid const &iid, void **factory) noexcept
|
||||
{
|
||||
typedef BOOL(WINAPI *PFNRoGetActivationFactory)(void *, winrt::guid const &, void **);
|
||||
static PFNRoGetActivationFactory RoGetActivationFactory = _combase.GetFunction("RoGetActivationFactory");
|
||||
|
||||
if (RoGetActivationFactory != nullptr) {
|
||||
return RoGetActivationFactory(classId, iid, factory);
|
||||
} else {
|
||||
*factory = nullptr;
|
||||
return winrt::impl::error_class_not_available;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool IsDarkModeEnabled()
|
||||
{
|
||||
/* Only build if SDK is Windows 10 1803 or later. */
|
||||
|
|
Loading…
Reference in New Issue