ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
tra_file.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22  //=============================================================================
23  //
24  // This unit provides functions for reading compiled translation file.
25  //
26  //=============================================================================
27 
28 #ifndef AGS_SHARED_GAME_TRA_FILE_H
29 #define AGS_SHARED_GAME_TRA_FILE_H
30 
31 #include "ags/shared/util/error.h"
32 #include "ags/shared/util/stream.h"
33 #include "ags/shared/util/string_types.h"
34 
35 namespace AGS3 {
36 namespace AGS {
37 namespace Shared {
38 
39 enum TraFileErrorType {
40  kTraFileErr_NoError,
41  kTraFileErr_SignatureFailed,
42  kTraFileErr_FormatNotSupported,
43  kTraFileErr_GameIDMismatch,
44  kTraFileErr_UnexpectedEOF,
45  kTraFileErr_UnknownBlockType,
46  kTraFileErr_BlockDataOverlapping,
47 };
48 
49 enum TraFileBlock {
50  kTraFblk_None = 0,
51  kTraFblk_Dict = 1,
52  kTraFblk_GameID = 2,
53  kTraFblk_TextOpts = 3,
54  // End of data tag
55  kTraFile_EOF = -1
56 };
57 
58 String GetTraFileErrorText(TraFileErrorType err);
59 String GetTraBlockName(TraFileBlock id);
60 
61 typedef TypedCodeError<TraFileErrorType, GetTraFileErrorText> TraFileError;
62 
63 
64 struct Translation {
65  // Game identifiers, for matching the translation file with the game
66  int GameUid = 0;
67  String GameName;
68  // Translation dictionary in source/dest pairs
69  StringMap Dict;
70  // Localization parameters
71  int NormalFont = -1; // replacement for normal font, or -1 for default
72  int SpeechFont = -1; // replacement for speech font, or -1 for default
73  int RightToLeft = -1; // r2l text mode (0, 1), or -1 for default
74  StringMap StrOptions; // to store extended options with string values
75 };
76 
77 
78 // Parses translation data and tests whether it matches the given game
79 HError TestTraGameID(int game_uid, const String &game_name, Stream *in);
80 // Reads full translation data from the provided stream
81 HError ReadTraData(Translation &tra, Stream *in);
82 // Writes all translation data to the stream
83 void WriteTraData(const Translation &tra, Stream *out);
84 
85 } // namespace Shared
86 } // namespace AGS
87 } // namespace AGS3
88 
89 #endif
Definition: achievements_tables.h:27
Definition: tra_file.h:64
Definition: string.h:62
Definition: stream.h:52
Definition: error.h:110
Definition: ags.h:40