Data Structures | Functions | Variables

game_text.cpp File Reference

Implementation of handling translated strings. More...

#include "../stdafx.h"
#include "../language.h"
#include "../strgen/strgen.h"
#include "../debug.h"
#include "../fileio_func.h"
#include "../script/squirrel_class.hpp"
#include "../strings_func.h"
#include "game_text.hpp"
#include "game.hpp"
#include "table/strings.h"
#include <exception>
#include <stdarg.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 strgen_warning (const char *s,...)
void CDECL strgen_error (const char *s,...)
void NORETURN CDECL strgen_fatal (const char *s,...)
LanguageStringsReadRawLanguageStrings (const char *file)
 Read all the raw language strings from the given file.
static void GetBasePath (char *buffer, size_t length)
GameStringsLoadTranslations ()
 Load all translations that we know of.
const char * GetGameStringPtr (uint id)
 Get the string pointer of a particular game string.
void RegisterGameTranslation (Squirrel *engine)
 Register the current translation to the Squirrel engine.
void ReconsiderGameScriptLanguage ()
 Reconsider the game script language, so we use the right one.

Variables

GameStrings_current_data = NULL
 The currently loaded game strings.

Detailed Description

Implementation of handling translated strings.

Definition in file game_text.cpp.


Function Documentation

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 323 of file game_text.cpp.

References GameStrings::cur_language, SmallVector< T, S >::Length(), and LanguageStrings::lines.

Referenced by GetStringWithArgs().

GameStrings* LoadTranslations (  ) 

Load all translations that we know of.

Returns:
Container with all (compiled) translations.

Definition at line 265 of file game_text.cpp.

References SmallVector< T, S >::Append(), GameStrings::Compile(), FioCheckFileExists(), GAME_DIR, GameStrings::raw_strings, ReadRawLanguageStrings(), LanguageScanner::Scan(), seprintf(), and strecpy().

Referenced by RegisterGameTranslation().

LanguageStrings* ReadRawLanguageStrings ( const char *  file  ) 

Read all the raw language strings from the given file.

Parameters:
file The file to read from.
Returns:
The raw strings, or NULL upon error.

Definition at line 88 of file game_text.cpp.

References SmallVector< T, S >::Append(), FioFOpenFile(), GAME_DIR, and LanguageStrings::lines.

Referenced by LanguageScanner::AddFile(), and LoadTranslations().

void RegisterGameTranslation ( Squirrel engine  ) 

Register the current translation to the Squirrel engine.

Parameters:
engine The engine to update/

Definition at line 333 of file game_text.cpp.

References SmallVector< T, S >::Begin(), SmallVector< T, S >::End(), Squirrel::GetVM(), LoadTranslations(), ReconsiderGameScriptLanguage(), and GameStrings::string_names.

Referenced by GameInstance::RegisterAPI().


Variable Documentation

The currently loaded game strings.

Definition at line 316 of file game_text.cpp.