OpenTTD Source: src/game/game_text.cpp File Reference

OpenTTD Source 14.0-beta1

Data Structures | Functions | Variables
game_text.cpp File Reference
`#include "../stdafx.h"`
`#include "../strgen/strgen.h"`
`#include "../debug.h"`
`#include "../fileio_func.h"`
`#include "../tar_type.h"`
`#include "../script/squirrel_class.hpp"`
`#include "../strings_func.h"`
`#include "game_text.hpp"`
`#include "game.hpp"`
`#include "game_info.hpp"`
`#include "table/strings.h"`
`#include "table/strgen_tables.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | StringListReader
| A reader that simply reads using fopen. More...
struct | TranslationWriter
| Class for writing an encoded language. More...
struct | StringNameWriter
| Class for writing the string IDs. More...
class | LanguageScanner
| Scanner to find language files in a GameScript directory. More...

## Functions
void CDECL | StrgenWarningI (const std::string &msg)
void CDECL | StrgenErrorI (const std::string &msg)
void CDECL | StrgenFatalI (const std::string &msg)
LanguageStrings | ReadRawLanguageStrings (const std::string &file)
| Read all the raw language strings from the given file. More...
GameStrings * | LoadTranslations ()
| Load all translations that we know of. More...
static StringParam::ParamType | GetParamType (const CmdStruct *cs)
static void | ExtractStringParams (const StringData &data, StringParamsList &params)
const char * | GetGameStringPtr (uint id)
| Get the string pointer of a particular game string. More...
const StringParams & | GetGameStringParams (uint id)
| Get the string parameters of a particular game string. More...
const std::string & | GetGameStringName (uint id)
| Get the name of a particular game string. More...
void | RegisterGameTranslation (Squirrel *engine)
| Register the current translation to the Squirrel engine. More...
void | ReconsiderGameScriptLanguage ()
| Reconsider the game script language, so we use the right one.

## Variables
GameStrings * | _current_data = nullptr
| The currently loaded game strings.

## Detailed Description

Implementation of handling translated strings.

Definition in file game_text.cpp.

## Function Documentation

## ◆ GetGameStringName()

const std::string& GetGameStringName | ( | uint | id | ) |

Get the name of a particular game string.

Parameters

  id | The ID of the game string.

Returns
  The name of the string.

Definition at line 345 of file game_text.cpp.

References _current_data, and GameStrings::string_names.

## ◆ GetGameStringParams()

const StringParams& GetGameStringParams | ( | uint | id | ) |

Get the string parameters of a particular game string.

Parameters

  id | The ID of the game string.

Returns
  The string parameters.

Definition at line 331 of file game_text.cpp.

References _current_data, and GameStrings::string_params.

## ◆ GetGameStringPtr()

const char* GetGameStringPtr | ( | uint | id | ) |

Get the string pointer of a particular game string.

Parameters

  id | The ID of the game string.

Returns
  The encoded string.

Definition at line 320 of file game_text.cpp.

References _current_data, GameStrings::cur_language, and LanguageStrings::lines.

## ◆ LoadTranslations()

GameStrings* LoadTranslations | ( |  | ) |

Load all translations that we know of.

Returns
  Container with all (compiled) translations.

Definition at line 204 of file game_text.cpp.

References Game::GetInfo(), and ScriptInfo::GetMainScript().

Referenced by RegisterGameTranslation().

## ◆ ReadRawLanguageStrings()

LanguageStrings ReadRawLanguageStrings | ( | const std::string & | file | ) |

Read all the raw language strings from the given file.

Parameters

  file | The file to read from.

Returns
  The raw strings, or nullptr upon error.

Definition at line 49 of file game_text.cpp.

References FioFOpenFile(), and GAME_DIR.

Referenced by LanguageScanner::AddFile().

## ◆ RegisterGameTranslation()

void RegisterGameTranslation | ( | Squirrel * | engine | ) |

Register the current translation to the Squirrel engine.

Parameters

  engine | The engine to update/

Definition at line 358 of file game_text.cpp.

References _current_data, Squirrel::GetVM(), LoadTranslations(), ReconsiderGameScriptLanguage(), and GameStrings::string_names.

Referenced by GameInstance::RegisterAPI().