summaryrefslogtreecommitdiff
path: root/src/newgrf_text.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-07-31 09:33:39 +0000
committeryexo <yexo@openttd.org>2010-07-31 09:33:39 +0000
commitd3c1be9abd2507fc5e77e5310e97bc1f31c28e65 (patch)
treebec0ca8eec0327145cc2b575795d9f154ac24404 /src/newgrf_text.cpp
parent1ca16aa979fab1d7a60fb40def0374433362d265 (diff)
downloadopenttd-d3c1be9abd2507fc5e77e5310e97bc1f31c28e65.tar.xz
(svn r20249) -Codechange: change the newgrf name/description from a char* to a GRFText* to make translations possible
Diffstat (limited to 'src/newgrf_text.cpp')
-rw-r--r--src/newgrf_text.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index c22a855cf..ccbdb37de 100644
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -126,6 +126,16 @@ public:
}
/**
+ * Create a copy of this GRFText.
+ * @param orig the grftext to copy
+ * @return an exact copy of the given text
+ */
+ static GRFText *Copy(GRFText *orig)
+ {
+ return GRFText::New(orig->langid, orig->text);
+ }
+
+ /**
* Helper allocation function to disallow something.
* Don't allow simple 'news'; they wouldn't have enough memory.
* @param size the amount of space not to allocate
@@ -353,6 +363,50 @@ void AddGRFTextToList(GRFText **list, GRFText *text_to_add)
}
/**
+ * Add a string to a GRFText list.
+ * @param list The list where the text should be added to.
+ * @param langid The language of the new text.
+ * @param grfid The grfid where this string is defined.
+ * @param text_to_add The text to add to the list.
+ * @note All text-codes will be translated.
+ */
+void AddGRFTextToList(struct GRFText **list, byte langid, uint32 grfid, const char *text_to_add)
+{
+ char *translatedtext = TranslateTTDPatchCodes(grfid, text_to_add);
+ GRFText *newtext = GRFText::New(langid, translatedtext);
+ free(translatedtext);
+
+ AddGRFTextToList(list, newtext);
+}
+
+/**
+ * Add a GRFText to a GRFText list. The text should not contain any text-codes.
+ * The text will be added as a 'default language'-text.
+ * @param list The list where the text should be added to.
+ * @param text_to_add The text to add to the list.
+ */
+void AddGRFTextToList(struct GRFText **list, const char *text_to_add)
+{
+ AddGRFTextToList(list, GRFText::New(0x7F, text_to_add));
+}
+
+/**
+ * Create a copy of this GRFText list.
+ * @param orig The GRFText list to copy.
+ * @return A duplicate of the given GRFText.
+ */
+GRFText *DuplicateGRFText(GRFText *orig)
+{
+ GRFText *newtext = NULL;
+ GRFText **ptext = &newtext;
+ for (; orig != NULL; orig = orig->next) {
+ *ptext = GRFText::Copy(orig);
+ ptext = &(*ptext)->next;
+ }
+ return newtext;
+}
+
+/**
* Add the new read string into our structure.
*/
StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool new_scheme, const char *text_to_add, StringID def_string)