strings_func.h File Reference

Functions related to OTTD's strings. More...

#include "strings_type.h"
#include "string_type.h"

Go to the source code of this file.

Data Structures

struct  StringIDCompare
 Key comparison function for std::map. More...

Functions

char * InlineString (char *buf, StringID string)
char * GetString (char *buffr, StringID string, const char *last)
char * GetStringWithArgs (char *buffr, uint string, int64 *argv, const int64 *argve, const char *last, WChar *argt=NULL)
 The highest 8 bits of string contain the "case index".
const char * GetStringPtr (StringID string)
void InjectDParam (uint amount)
 Shift the string parameters in the global string parameter array by amount positions, making room at the beginning.
static void SetDParamX (uint64 *s, uint n, uint64 v)
 Set a string parameter v at index n in a given array s.
static void SetDParam (uint n, uint64 v)
 Set a string parameter v at index n in the global string parameter array.
void SetDParamStr (uint n, const char *str)
 This function is used to "bind" a C string to a OpenTTD dparam slot.
static uint64 GetDParamX (const uint64 *s, uint n)
 Get the current string parameter at index n from parameter array s.
static uint64 GetDParam (uint n)
 Get the current string parameter at index n from the global string parameter array.
static void CopyInDParam (int offs, const uint64 *src, int num)
 Copy num string parameters from array src into the global string parameter array.
static void CopyOutDParam (uint64 *dst, int offs, int num)
 Copy num string parameters from the global string parameter array to the dst array.
void InitializeLanguagePacks ()
 Make a list of the available language packs.
const char * GetCurrentLanguageIsoCode ()
 Get the ISO language code of the currently loaded language.
int CDECL StringIDSorter (const StringID *a, const StringID *b)
void CheckForMissingGlyphsInLoadedLanguagePack ()
 Check whether the currently loaded language pack uses characters that the currently loaded font does not support.
int strnatcmp (const char *s1, const char *s2)
 Compares two strings using case insensitive natural sort.

Variables

TextDirection _current_text_dir
 Text direction of the currently selected language.

Detailed Description

Functions related to OTTD's strings.

Definition in file strings_func.h.


Function Documentation

void CheckForMissingGlyphsInLoadedLanguagePack (  ) 

Check whether the currently loaded language pack uses characters that the currently loaded font does not support.

If this is the case an error message will be shown in English. The error message will not be localized because that would mean it might use characters that are not in the font, which is the whole reason this check has been added.

Definition at line 1781 of file strings.cpp.

References _current_text_dir, FindMissingGlyphs(), INVALID_STRING_ID, LanguagePackHeader::isocode, LoadStringWidthTable(), SetDParamStr(), SetFallbackFont(), ShowErrorMessage(), TD_LTR, UninitFreeType(), Utf8Encode(), LanguagePackHeader::winlangid, WL_ERROR, and WL_WARNING.

Referenced by GameOptionsWindow::OnDropdownSelect().

static void CopyInDParam ( int  offs,
const uint64 *  src,
int  num 
) [inline, static]

Copy num string parameters from array src into the global string parameter array.

Parameters:
offs Index in the global array to copy the first string parameter to.
src Source array of string parameters.
num Number of string parameters to copy.

Definition at line 81 of file strings_func.h.

References _decode_parameters.

Referenced by DrawNewsString(), NewsWindow::DrawWidget(), ErrmsgWindow::DrawWidget(), QueryWindow::SetStringParameters(), ErrmsgWindow::SetStringParameters(), NewsWindow::UpdateWidgetSize(), and ErrmsgWindow::UpdateWidgetSize().

static void CopyOutDParam ( uint64 *  dst,
int  offs,
int  num 
) [inline, static]

Copy num string parameters from the global string parameter array to the dst array.

Parameters:
dst Destination array of string parameters.
offs Index in the global array to copy the first string parameter from.
num Number of string parameters to copy.

Definition at line 93 of file strings_func.h.

References _decode_parameters.

Referenced by AddNewsItem().

const char* GetCurrentLanguageIsoCode (  ) 

Get the ISO language code of the currently loaded language.

Returns:
the ISO code.

Definition at line 1720 of file strings.cpp.

References LanguagePackHeader::isocode.

Referenced by GameOptionsWindow::DrawWidget(), and GameOptionsWindow::UpdateWidgetSize().

static uint64 GetDParam ( uint  n  )  [inline, static]

Get the current string parameter at index n from the global string parameter array.

Parameters:
n Index of the string parameter.
Returns:
Value of the requested string parameter.

Definition at line 67 of file strings_func.h.

References _decode_parameters, and lengthof.

static uint64 GetDParamX ( const uint64 *  s,
uint  n 
) [inline, static]

Get the current string parameter at index n from parameter array s.

Parameters:
s Array of string parameters.
n Index of the string parameter.
Returns:
Value of the requested string parameter.

Definition at line 57 of file strings_func.h.

char* GetStringWithArgs ( char *  buffr,
uint  string,
int64 *  argv,
const int64 *  argve,
const char *  last,
WChar *  argt 
)

The highest 8 bits of string contain the "case index".

These 8 bits will only be set when FormatString wants to print the string in a different case. No one else except FormatString should set those bits, therefore string CANNOT be StringID, but uint32.

Parameters:
buffr Pointer to a string buffer where the formatted string should be written to.
string 
argv Array with arguments for the string.
argve Pointer just past the end of argv.
last Pointer just past the end of buffr.
argt Array to be filled with the type of parameters.
Returns:
Pointer to the final zero byte of the formatted string.

Definition at line 147 of file strings.cpp.

References _langtab_num, error(), FormatString(), GB(), GetGRFStringID(), GetGRFStringPtr(), GetInt32(), GetStringWithArgs(), and HasBit().

Referenced by FormatString(), GetStringWithArgs(), and GetTownName().

void InitializeLanguagePacks (  ) 

Make a list of the available language packs.

put the data in _dynlang struct.

< Matching the language in the configuartion file or the current locale

< Using pt_PT for pt_BR locale when pt_BR is not available

< Fallback when no locale-matching language has been found

Definition at line 1672 of file strings.cpp.

References _config_language_file, SmallVector< T, S >::Begin(), SmallVector< T, S >::End(), LanguageMetadata::file, FOR_ALL_SEARCHPATHS, GetCurrentLocale(), GetLanguageList(), LANG_DIR, SmallVector< T, S >::Length(), lengthof, and usererror().

void InjectDParam ( uint  amount  ) 

Shift the string parameters in the global string parameter array by amount positions, making room at the beginning.

Parameters:
amount Number of positions to shift.

Definition at line 228 of file strings.cpp.

References lengthof.

Referenced by Subsidy::AwardTo().

static void SetDParam ( uint  n,
uint64  v 
) [inline, static]

Set a string parameter v at index n in the global string parameter array.

Parameters:
n Index of the string parameter.
v Value of the string parameter.

Definition at line 41 of file strings_func.h.

References _decode_parameters, and lengthof.

Referenced by AdvertiseIndustryOpening(), AgeVehicle(), AircraftEntersTerminal(), Subsidy::AwardTo(), CcBuildIndustry(), ChangeIndustryProduction(), NetworkChatWindow::ChatTabCompletionNextItem(), CheckAllowRemoveRoad(), CheckCompanyHasMoney(), ClientNetworkGameSocketHandler::CheckConnection(), CheckforTownRating(), CheckIfAuthorityAllowsNewStation(), CheckOrders(), CheckTrainCollision(), CheckTrainsLengths(), CmdBuildAirport(), CmdBuildBridge(), CmdBuildIndustry(), CmdCompanyCtrl(), CmdDecreaseLoan(), CmdFoundTown(), CmdIncreaseLoan(), CompanyCheckBankrupt(), CrashAirplane(), Disaster_CoalMine_Init(), DisasterTick_Aircraft(), DisasterTick_Big_Ufo(), DisasterTick_Zeppeliner(), DoCommandPInternal(), CargoesField::Draw(), DrawAircraftDetails(), StationViewWindow::DrawCargoRatings(), NetworkContentListWindow::DrawDetails(), DrawEngineList(), SelectCompanyManagerFaceWindow::DrawFaceStringLabel(), BaseGraphWindow::DrawGraph(), IndustryViewWindow::DrawInfo(), DrawOrderString(), DrawPrice(), TownAuthorityWindow::DrawRatings(), DrawRoadVehDetails(), NetworkGameWindow::DrawServerLine(), SettingEntry::DrawSetting(), DrawShipDetails(), SmallMapWindow::DrawTowns(), DrawTrainDetails(), DepotWindow::DrawVehicleInDepot(), BaseVehicleListWindow::DrawVehicleListItems(), DrawVehiclePurchaseInfo(), DrawVehicleRefitWindow(), StationViewWindow::DrawWaitingCargo(), VehicleViewWindow::DrawWidget(), VehicleDetailsWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), TownViewWindow::DrawWidget(), TownAuthorityWindow::DrawWidget(), ScenarioEditorToolbarWindow::DrawWidget(), TimetableWindow::DrawWidget(), SubsidyListWindow::DrawWidget(), StatusBarWindow::DrawWidget(), SelectStationWindow< T >::DrawWidget(), CompanyStationsWindow::DrawWidget(), SmallMapWindow::DrawWidget(), SignListWindow::DrawWidget(), BuildRailStationWindow::DrawWidget(), OrdersWindow::DrawWidget(), BuildObjectWindow::DrawWidget(), MessageHistoryWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), SpriteAlignerWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), NetworkContentDownloadStatusWindow::DrawWidget(), MusicWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), TooltipsWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), VehicleGroupWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), CompanyLeagueWindow::DrawWidget(), PaymentRatesGraphWindow::DrawWidget(), GraphLegendWindow::DrawWidget(), GenerateProgressWindow::DrawWidget(), SaveLoadWindow::DrawWidget(), EnginePreviewWindow::DrawWidget(), BuyCompanyWindow::DrawWidget(), CompanyWindow::DrawWidget(), CompanyFinancesWindow::DrawWidget(), CheatWindow::DrawWidget(), BuildBridgeWindow::DrawWidget(), ReplaceVehicleWindow::DrawWidget(), BuildAirportWindow::DrawWidget(), AISettingsWindow::DrawWidget(), AIListWindow::DrawWidget(), DrawYearColumn(), EngineNameSorter(), FloodVehicle(), GenerateCompanyName(), GenerateDefaultSaveName(), GeneratePresidentName(), RefitWindow::GetCapacityString(), IndustryDirectoryWindow::GetIndustryString(), AIVehicle::GetName(), AITown::GetName(), AISign::GetName(), AIIndustry::GetName(), AIGroup::GetName(), AIEventEnginePreview::GetName(), AIEngine::GetName(), AICompany::GetName(), AIBaseStation::GetName(), GetNameOfOwner(), AICompany::GetPresidentName(), GetSaveLoadErrorString(), BaseGraphWindow::GetYLabelWidth(), VehicleGroupWindow::GroupNameSorter(), Vehicle::HandlePathfindingResult(), IndustryDirectoryWindow::IndustryNameSorter(), IndustryProductionCallback(), IndustryTypeNameSorter(), NetworkHandlePauseChange(), NewVehicleAvailable(), WaypointWindow::OnClick(), VehicleDetailsWindow::OnClick(), TownViewWindow::OnClick(), TimetableWindow::OnClick(), StationViewWindow::OnClick(), CustomCurrencyWindow::OnClick(), GameSettingsWindow::OnClick(), OrdersWindow::OnClick(), NewGRFParametersWindow::OnClick(), NetworkStartServerWindow::OnClick(), IndustryViewWindow::OnClick(), CreateScenarioWindow::OnClick(), GenerateLandscapeWindow::OnClick(), DepotWindow::OnClick(), CompanyWindow::OnClick(), SelectCompanyManagerFaceWindow::OnClick(), CheatWindow::OnClick(), BuildVehicleWindow::OnClick(), AISettingsWindow::OnClick(), GenerateLandscapeWindow::OnDropdownSelect(), SmallMapWindow::OnInit(), LandInfoWindow::OnInit(), IndustryCargoesWindow::OnInit(), SelectCompanyManagerFaceWindow::OnInit(), HighScoreWindow::OnPaint(), EndGameWindow::OnPaint(), ReplaceVehicleWindow::OnPaint(), BuildAirportWindow::OnPaint(), BuildIndustryWindow::OnPlaceObject(), DepotWindow::OnRightClick(), ReportNewsProductionChangeIndustry(), RoadVehArrivesAt(), SaveHighScoreValue(), SetArrivalDepartParams(), SetDParamStr(), NIHelper::SetObjectAtStringParameters(), NIHelper::SetSimpleStringParameters(), WaypointWindow::SetStringParameters(), ExtraViewportWindow::SetStringParameters(), VehicleViewWindow::SetStringParameters(), VehicleDetailsWindow::SetStringParameters(), VehicleListWindow::SetStringParameters(), RefitWindow::SetStringParameters(), TownDirectoryWindow::SetStringParameters(), TownViewWindow::SetStringParameters(), TownAuthorityWindow::SetStringParameters(), TimetableWindow::SetStringParameters(), StationViewWindow::SetStringParameters(), CompanyStationsWindow::SetStringParameters(), SmallMapWindow::SetStringParameters(), SignWindow::SetStringParameters(), SignListWindow::SetStringParameters(), CustomCurrencyWindow::SetStringParameters(), GameDifficultyWindow::SetStringParameters(), GameOptionsWindow::SetStringParameters(), BuildSignalWindow::SetStringParameters(), BuildRailStationWindow::SetStringParameters(), BuildRailToolbarWindow::SetStringParameters(), OskWindow::SetStringParameters(), OrdersWindow::SetStringParameters(), BuildObjectWindow::SetStringParameters(), NewsWindow::SetStringParameters(), NewGRFWindow::SetStringParameters(), NewGRFParametersWindow::SetStringParameters(), SpriteAlignerWindow::SetStringParameters(), NetworkStartServerWindow::SetStringParameters(), NetworkGameWindow::SetStringParameters(), MusicTrackSelectionWindow::SetStringParameters(), QueryWindow::SetStringParameters(), QueryStringWindow::SetStringParameters(), SelectGameWindow::SetStringParameters(), IndustryCargoesWindow::SetStringParameters(), IndustryDirectoryWindow::SetStringParameters(), IndustryViewWindow::SetStringParameters(), BuildIndustryWindow::SetStringParameters(), VehicleGroupWindow::SetStringParameters(), CreateScenarioWindow::SetStringParameters(), GenerateLandscapeWindow::SetStringParameters(), DepotWindow::SetStringParameters(), SetDateWindow::SetStringParameters(), BuyCompanyWindow::SetStringParameters(), CompanyWindow::SetStringParameters(), SelectCompanyLiveryWindow::SetStringParameters(), CompanyFinancesWindow::SetStringParameters(), BuildVehicleWindow::SetStringParameters(), ReplaceVehicleWindow::SetStringParameters(), BuildAirportWindow::SetStringParameters(), AIDebugWindow::SetStringParameters(), AIConfigWindow::SetStringParameters(), SetTimetableParams(), ShipArrivesAt(), ShowAdditionalText(), ShowCostOrIncomeAnimation(), ShowEstimatedCostOrIncome(), ShowFeederIncomeAnimation(), ShowFillingPercent(), ShowNewGRFError(), ShowNewGrfVehicleError(), ShowRejectOrAcceptNews(), SignList::SignNameFilter(), SignList::SignNameSorter(), CompanyStationsWindow::StationNameSorter(), ToolbarScenDatePanel(), TownDirectoryWindow::TownNameSorter(), TrainDetailsCapacityTab(), TrainDetailsCargoTab(), TrainDetailsInfoTab(), TrainEnterStation(), UpdateFillingPercent(), Waypoint::UpdateVirtCoord(), Town::UpdateVirtCoord(), Station::UpdateVirtCoord(), Sign::UpdateVirtCoord(), VehicleDetailsWindow::UpdateWidgetSize(), TownDirectoryWindow::UpdateWidgetSize(), TownAuthorityWindow::UpdateWidgetSize(), ScenarioEditorToolbarWindow::UpdateWidgetSize(), TimetableWindow::UpdateWidgetSize(), StatusBarWindow::UpdateWidgetSize(), SelectStationWindow< T >::UpdateWidgetSize(), SignListWindow::UpdateWidgetSize(), CustomCurrencyWindow::UpdateWidgetSize(), GameDifficultyWindow::UpdateWidgetSize(), GameOptionsWindow::UpdateWidgetSize(), BuildRailStationWindow::UpdateWidgetSize(), MessageHistoryWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), NetworkJoinStatusWindow::UpdateWidgetSize(), NetworkGameWindow::UpdateWidgetSize(), MusicTrackSelectionWindow::UpdateWidgetSize(), TooltipsWindow::UpdateWidgetSize(), SelectGameWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), PerformanceRatingDetailWindow::UpdateWidgetSize(), CompanyLeagueWindow::UpdateWidgetSize(), PaymentRatesGraphWindow::UpdateWidgetSize(), BaseGraphWindow::UpdateWidgetSize(), GenerateProgressWindow::UpdateWidgetSize(), CreateScenarioWindow::UpdateWidgetSize(), GenerateLandscapeWindow::UpdateWidgetSize(), EnginePreviewWindow::UpdateWidgetSize(), DepotWindow::UpdateWidgetSize(), SetDateWindow::UpdateWidgetSize(), BuyCompanyWindow::UpdateWidgetSize(), CompanyWindow::UpdateWidgetSize(), CompanyFinancesWindow::UpdateWidgetSize(), CheatWindow::UpdateWidgetSize(), BuildBridgeWindow::UpdateWidgetSize(), ReplaceVehicleWindow::UpdateWidgetSize(), BuildAirportWindow::UpdateWidgetSize(), VehicleEnterDepot(), and VehicleNameSorter().

void SetDParamStr ( uint  n,
const char *  str 
)

This function is used to "bind" a C string to a OpenTTD dparam slot.

Parameters:
n slot of the string
str string to bind

Definition at line 219 of file strings.cpp.

References SetDParam().

Referenced by Subsidy::AwardTo(), CheckForMissingGlyphsInLoadedLanguagePack(), CmdCompanyCtrl(), CmdFoundTown(), CompanyCheckBankrupt(), DrawCargoListText(), NetworkContentListWindow::DrawDetails(), IndustryViewWindow::DrawInfo(), GameOptionsWindow::DrawWidget(), NewsWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), NetworkContentDownloadStatusWindow::DrawWidget(), NetworkChatWindow::DrawWidget(), MusicWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), LandInfoWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), SaveLoadWindow::DrawWidget(), AIConfigWindow::DrawWidget(), AISettingsWindow::DrawWidget(), AIListWindow::DrawWidget(), GenerateCompanyName(), IndustryDirectoryWindow::GetIndustryString(), GetSaveLoadErrorString(), IndustryProductionCallback(), MakeScreenshot(), CustomCurrencyWindow::OnClick(), NetworkStartServerWindow::OnClick(), NetworkGameWindow::OnClick(), LandInfoWindow::OnInit(), IConsoleWindow::OnPaint(), SaveFileError(), CustomCurrencyWindow::SetStringParameters(), GameOptionsWindow::SetStringParameters(), NewGRFWindow::SetStringParameters(), SpriteAlignerWindow::SetStringParameters(), NetworkLobbyWindow::SetStringParameters(), AboutWindow::SetStringParameters(), AIDebugWindow::SetStringParameters(), ShowNewGRFError(), ShowNewGrfVehicleError(), ShowRefitOptionsList(), GameOptionsWindow::UpdateWidgetSize(), NewGRFWindow::UpdateWidgetSize(), NetworkChatWindow::UpdateWidgetSize(), MusicWindow::UpdateWidgetSize(), MusicTrackSelectionWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), and WarnCorruptSprite().

static void SetDParamX ( uint64 *  s,
uint  n,
uint64  v 
) [inline, static]

Set a string parameter v at index n in a given array s.

Parameters:
s Array of string parameters.
n Index of the string parameter.
v Value of the string parameter.

Definition at line 31 of file strings_func.h.

int strnatcmp ( const char *  s1,
const char *  s2 
)

Compares two strings using case insensitive natural sort.

Parameters:
s1 First string to compare.
s2 Second string to compare.
Returns:
Less than zero if s1 < s2, zero if s1 == s2, greater than zero if s1 > s2.

Definition at line 572 of file string.cpp.

References _current_collator, DRAW_STRING_BUFFER, and lengthof.

Referenced by CargoSpecNameSorter(), EngineNameSorter(), VehicleGroupWindow::GroupNameSorter(), IndustryDirectoryWindow::IndustryNameSorter(), IndustryTypeNameSorter(), NewGRFWindow::NameSorter(), NetworkContentListWindow::NameSorter(), NetworkGameWindow::NGameNameSorter(), SignList::SignNameSorter(), TownDirectoryWindow::TownNameSorter(), NetworkContentListWindow::TypeSorter(), and VehicleNameSorter().


Generated on Fri Mar 18 23:17:54 2011 for OpenTTD by  doxygen 1.6.1