annotate src/newgrf_text.h @ 18957:f7df1757f6d9 draft

(svn r23812) -Fix [FS#4977] (r23804): custom ActionB messages were broken
author yexo <yexo@openttd.org>
date Sun, 15 Jan 2012 19:29:49 +0000
parents 6af38106a773
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
1 /* $Id$ */
10560
cd9f6490e2c3 (svn r14817) -Cleanup: unify the place where the @file header is placed
smatz <smatz@openttd.org>
parents: 8656
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11346
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11346
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11346
diff changeset
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11346
diff changeset
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11346
diff changeset
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11346
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 11346
diff changeset
9
10560
cd9f6490e2c3 (svn r14817) -Cleanup: unify the place where the @file header is placed
smatz <smatz@openttd.org>
parents: 8656
diff changeset
10 /** @file newgrf_text.h Header of Action 04 "universal holder" structure and functions */
cd9f6490e2c3 (svn r14817) -Cleanup: unify the place where the @file header is placed
smatz <smatz@openttd.org>
parents: 8656
diff changeset
11
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
12 #ifndef NEWGRF_TEXT_H
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
13 #define NEWGRF_TEXT_H
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
14
16483
4a73d307d9f2 (svn r21207) -Codechange: replace the magic 0x00DE constant with something less magic
rubidium <rubidium@openttd.org>
parents: 16478
diff changeset
15 #include "string_type.h"
14258
a899d4e5ee1a (svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header
rubidium <rubidium@openttd.org>
parents: 13084
diff changeset
16 #include "strings_type.h"
16484
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
17 #include "core/smallvec_type.hpp"
18957
f7df1757f6d9 (svn r23812) -Fix [FS#4977] (r23804): custom ActionB messages were broken
yexo <yexo@openttd.org>
parents: 18198
diff changeset
18 #include "table/control_codes.h"
14258
a899d4e5ee1a (svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header
rubidium <rubidium@openttd.org>
parents: 13084
diff changeset
19
16483
4a73d307d9f2 (svn r21207) -Codechange: replace the magic 0x00DE constant with something less magic
rubidium <rubidium@openttd.org>
parents: 16478
diff changeset
20 /** This character, the thorn ('รพ'), indicates a unicode string to NFO. */
4a73d307d9f2 (svn r21207) -Codechange: replace the magic 0x00DE constant with something less magic
rubidium <rubidium@openttd.org>
parents: 16478
diff changeset
21 static const WChar NFO_UTF8_IDENTIFIER = 0x00DE;
4a73d307d9f2 (svn r21207) -Codechange: replace the magic 0x00DE constant with something less magic
rubidium <rubidium@openttd.org>
parents: 16478
diff changeset
22
18145
767865264a2b (svn r22970) -Fix [FS#4769]: strip newlines from NewGRF strings that should not have newlines, e.g. the NewGRF's name
rubidium <rubidium@openttd.org>
parents: 17839
diff changeset
23 StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid, bool new_scheme, bool allow_newlines, const char *text_to_add, StringID def_string);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
24 StringID GetGRFStringID(uint32 grfid, uint16 stringid);
15589
242de7f74e70 (svn r20249) -Codechange: change the newgrf name/description from a char* to a GRFText* to make translations possible
yexo <yexo@openttd.org>
parents: 14961
diff changeset
25 const char *GetGRFStringFromGRFText(const struct GRFText *text);
8445
cfc312cfe346 (svn r12015) -Fix [FS#1716] (Revert r11422): Patch in FS#1430 avoided instead of fixed the problem. GetStringWithArgs() discards information that SCC_GENDER_LIST needs to work. Now use pointers to retrieve GRF strings, so that GetStringPtr() will work correctly. This is advantageous as now no buffer copy is made when using all GRF strings.
peter1138 <peter1138@openttd.org>
parents: 7750
diff changeset
26 const char *GetGRFStringPtr(uint16 stringid);
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 5475
diff changeset
27 void CleanUpStrings();
11346
1b8ff09217a8 (svn r15696) -Codechange: move the NewGRF language ID into the language file instead of maintaining a table in the code.
rubidium <rubidium@openttd.org>
parents: 10560
diff changeset
28 void SetCurrentGrfLangID(byte language_id);
18957
f7df1757f6d9 (svn r23812) -Fix [FS#4977] (r23804): custom ActionB messages were broken
yexo <yexo@openttd.org>
parents: 18198
diff changeset
29 char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newlines, const char *str, int *olen = NULL, StringControlCode byte80 = SCC_NEWGRF_PRINT_WORD_STRING_ID);
15589
242de7f74e70 (svn r20249) -Codechange: change the newgrf name/description from a char* to a GRFText* to make translations possible
yexo <yexo@openttd.org>
parents: 14961
diff changeset
30 struct GRFText *DuplicateGRFText(struct GRFText *orig);
242de7f74e70 (svn r20249) -Codechange: change the newgrf name/description from a char* to a GRFText* to make translations possible
yexo <yexo@openttd.org>
parents: 14961
diff changeset
31 void AddGRFTextToList(struct GRFText **list, struct GRFText *text_to_add);
18145
767865264a2b (svn r22970) -Fix [FS#4769]: strip newlines from NewGRF strings that should not have newlines, e.g. the NewGRF's name
rubidium <rubidium@openttd.org>
parents: 17839
diff changeset
32 void AddGRFTextToList(struct GRFText **list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add);
15589
242de7f74e70 (svn r20249) -Codechange: change the newgrf name/description from a char* to a GRFText* to make translations possible
yexo <yexo@openttd.org>
parents: 14961
diff changeset
33 void AddGRFTextToList(struct GRFText **list, const char *text_to_add);
242de7f74e70 (svn r20249) -Codechange: change the newgrf name/description from a char* to a GRFText* to make translations possible
yexo <yexo@openttd.org>
parents: 14961
diff changeset
34 void CleanUpGRFText(struct GRFText *grftext);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
35
6873
608145365c5d (svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros <maedhros@openttd.org>
parents: 6348
diff changeset
36 bool CheckGrfLangID(byte lang_id, byte grf_version);
608145365c5d (svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros <maedhros@openttd.org>
parents: 6348
diff changeset
37
17837
b6608baed897 (svn r22628) -Codechange: Allow passing the textref stack values to use to StartTextRefStackUsage() instead of always using the temporary NewGRF registers.
frosch <frosch@openttd.org>
parents: 17836
diff changeset
38 void StartTextRefStackUsage(byte numEntries, const uint32 *values = NULL);
7616
b1b321279552 (svn r11145) -Codechange: add support for "decoding" TTDPs string codes wrt to registers 0x100 to 0x10F.
rubidium <rubidium@openttd.org>
parents: 6873
diff changeset
39 void StopTextRefStackUsage();
7750
2df30880f88b (svn r11287) -Codechange: add support for pushing paramaters into NewIndustries' error messages. Patch by Csaboka.
rubidium <rubidium@openttd.org>
parents: 7616
diff changeset
40 void RewindTextRefStack();
16702
9ef2e68ef3c6 (svn r21435) -Fix: NewGRF strings that referenced a value that was set by a string command later in the string failed
yexo <yexo@openttd.org>
parents: 16491
diff changeset
41 bool UsingNewGRFTextStack();
9ef2e68ef3c6 (svn r21435) -Fix: NewGRF strings that referenced a value that was set by a string command later in the string failed
yexo <yexo@openttd.org>
parents: 16491
diff changeset
42 struct TextRefStack *CreateTextRefStackBackup();
9ef2e68ef3c6 (svn r21435) -Fix: NewGRF strings that referenced a value that was set by a string command later in the string failed
yexo <yexo@openttd.org>
parents: 16491
diff changeset
43 void RestoreTextRefStackBackup(struct TextRefStack *backup);
18198
6af38106a773 (svn r23027) -Fix: in some cases NewGRF string arguments were popped twice from the newgrf textstack
yexo <yexo@openttd.org>
parents: 18145
diff changeset
44 uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const char **str, int64 *argv, bool modify_argv);
7616
b1b321279552 (svn r11145) -Codechange: add support for "decoding" TTDPs string codes wrt to registers 0x100 to 0x10F.
rubidium <rubidium@openttd.org>
parents: 6873
diff changeset
45
13084
bf8ef2376932 (svn r17584) -Codechange: split the NewGRF StringID mapping in a 'global' part and a part that's for NewGRF strings
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
46 StringID TTDPStringIDToOTTDStringIDMapping(StringID string);
bf8ef2376932 (svn r17584) -Codechange: split the NewGRF StringID mapping in a 'global' part and a part that's for NewGRF strings
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
47
16484
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
48 /** Mapping of language data between a NewGRF and OpenTTD. */
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
49 struct LanguageMap {
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
50 /** Mapping between NewGRF and OpenTTD IDs. */
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
51 struct Mapping {
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
52 byte newgrf_id; ///< NewGRF's internal ID for a case/gender.
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
53 byte openttd_id; ///< OpenTTD's internal ID for a case/gender.
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
54 };
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
55
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
56 /* We need a vector and can't use SmallMap due to the fact that for "setting" a
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
57 * gender of a string or requesting a case for a substring we want to map from
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
58 * the NewGRF's internal ID to OpenTTD's ID whereas for the choice lists we map
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
59 * the genders/cases/plural OpenTTD IDs to the NewGRF's internal IDs. In this
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
60 * case a NewGRF developer/translator might want a different translation for
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
61 * both cases. Thus we are basically implementing a multi-map. */
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
62 SmallVector<Mapping, 1> gender_map; ///< Mapping of NewGRF and OpenTTD IDs for genders.
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
63 SmallVector<Mapping, 1> case_map; ///< Mapping of NewGRF and OpenTTD IDs for cases.
16491
e7e3274c8dc0 (svn r21216) -Feature: [NewGRF] Allow specifying a "choice list" for plurals
rubidium <rubidium@openttd.org>
parents: 16487
diff changeset
64 int plural_form; ///< The plural form used for this language.
16485
d10cc518045a (svn r21209) -Feature: [NewGRF] Allow setting the gender of the current string or select the case of the next substring
rubidium <rubidium@openttd.org>
parents: 16484
diff changeset
65
d10cc518045a (svn r21209) -Feature: [NewGRF] Allow setting the gender of the current string or select the case of the next substring
rubidium <rubidium@openttd.org>
parents: 16484
diff changeset
66 int GetMapping(int newgrf_id, bool gender) const;
16487
b3050ee750d3 (svn r21211) -Feature: [NewGRF] Allow specifying a "choice list" for cases and genders
rubidium <rubidium@openttd.org>
parents: 16485
diff changeset
67 int GetReverseMapping(int openttd_id, bool gender) const;
16485
d10cc518045a (svn r21209) -Feature: [NewGRF] Allow setting the gender of the current string or select the case of the next substring
rubidium <rubidium@openttd.org>
parents: 16484
diff changeset
68 static const LanguageMap *GetLanguageMap(uint32 grfid, uint8 language_id);
16484
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
69 };
92174638bc84 (svn r21208) -Add: [NewGRF] Mapping information w.r.t. a translation's case and gender names
rubidium <rubidium@openttd.org>
parents: 16483
diff changeset
70
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
71 #endif /* NEWGRF_TEXT_H */