summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/build_vehicle_gui.cpp2
-rw-r--r--src/industry_gui.cpp6
-rw-r--r--src/newgrf_industries.cpp2
-rw-r--r--src/newgrf_industrytiles.cpp2
-rw-r--r--src/newgrf_text.cpp16
-rw-r--r--src/newgrf_text.h2
-rw-r--r--src/object_gui.cpp2
7 files changed, 22 insertions, 10 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 605c71ebb..29486744d 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -740,7 +740,7 @@ static uint ShowAdditionalText(int left, int right, int y, EngineID engine)
/* STR_BLACK_STRING is used to start the string with {BLACK} */
SetDParam(0, GetGRFStringID(GetEngineGRFID(engine), 0xD000 + callback));
- PrepareTextRefStackUsage(0);
+ StartTextRefStackUsage(0);
uint result = DrawStringMultiLine(left, right, y, INT32_MAX, STR_BLACK_STRING);
StopTextRefStackUsage();
return result;
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index b50eddd91..e0d5cd4e7 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -74,7 +74,7 @@ static void GetCargoSuffix(uint cargo, CargoSuffixType cst, const Industry *ind,
if (HasBit(indspec->callback_mask, CBM_IND_CARGO_SUFFIX)) {
uint16 callback = GetIndustryCallback(CBID_INDUSTRY_CARGO_SUFFIX, 0, (cst << 8) | cargo, const_cast<Industry *>(ind), ind_type, (cst != CST_FUND) ? ind->location.tile : INVALID_TILE);
if (GB(callback, 0, 8) != 0xFF) {
- PrepareTextRefStackUsage(6);
+ StartTextRefStackUsage(6);
GetString(suffix, GetGRFStringID(indspec->grf_prop.grffile->grfid, 0xD000 + callback), suffix_last);
StopTextRefStackUsage();
}
@@ -458,7 +458,7 @@ public:
if (callback_res != CALLBACK_FAILED) { // Did it fail?
str = GetGRFStringID(indsp->grf_prop.grffile->grfid, 0xD000 + callback_res); // No. here's the new string
if (str != STR_UNDEFINED) {
- PrepareTextRefStackUsage(6);
+ StartTextRefStackUsage(6);
DrawStringMultiLine(left, right, y, bottom, str);
StopTextRefStackUsage();
}
@@ -788,7 +788,7 @@ public:
if (message != STR_NULL && message != STR_UNDEFINED) {
y += WD_PAR_VSEP_WIDE;
- PrepareTextRefStackUsage(6);
+ StartTextRefStackUsage(6);
/* Use all the available space left from where we stand up to the
* end of the window. We ALSO enlarge the window if needed, so we
* can 'go' wild with the bottom of the window. */
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index 35f853712..5cf9eb6ae 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -551,7 +551,7 @@ CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uin
/* Copy some parameters from the registers to the error message text ref. stack */
SwitchToErrorRefStack();
- PrepareTextRefStackUsage(4);
+ StartTextRefStackUsage(4);
SwitchToNormalRefStack();
switch (result) {
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index a69d655cb..efaa5c3f6 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -310,7 +310,7 @@ CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind
/* Copy some parameters from the registers to the error message text ref. stack */
SwitchToErrorRefStack();
- PrepareTextRefStackUsage(4);
+ StartTextRefStackUsage(4);
SwitchToNormalRefStack();
switch (callback_res) {
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index 6213b419e..6cc361f61 100644
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -955,10 +955,22 @@ void RestoreTextRefStackBackup(struct TextRefStack *backup)
}
/**
- * Prepare the TTDP compatible string code parsing
+ * Start using the TTDP compatible string code parsing.
+ *
+ * On start a number of values is copied on the #TextRefStack.
+ * You can then use #GetString() and the normal string drawing functions,
+ * and they will use the #TextRefStack for NewGRF string codes.
+ *
+ * However, when you want to draw a string multiple times using the same stack,
+ * you have to call #RewindTextRefStack() between draws.
+ *
+ * After you are done with drawing, you must disable usage of the #TextRefStack
+ * by calling #StopTextRefStackUsage(), so NewGRF string codes operate on the
+ * normal string parameters again.
+ *
* @param numEntries number of entries to copy from the registers
*/
-void PrepareTextRefStackUsage(byte numEntries)
+void StartTextRefStackUsage(byte numEntries)
{
extern TemporaryStorageArray<int32, 0x110> _temp_store;
diff --git a/src/newgrf_text.h b/src/newgrf_text.h
index ac0c79130..a09a20ce9 100644
--- a/src/newgrf_text.h
+++ b/src/newgrf_text.h
@@ -34,7 +34,7 @@ void CleanUpGRFText(struct GRFText *grftext);
bool CheckGrfLangID(byte lang_id, byte grf_version);
-void PrepareTextRefStackUsage(byte numEntries);
+void StartTextRefStackUsage(byte numEntries);
void StopTextRefStackUsage();
void SwitchToNormalRefStack();
void SwitchToErrorRefStack();
diff --git a/src/object_gui.cpp b/src/object_gui.cpp
index e31a82ec5..1bb7d8ce8 100644
--- a/src/object_gui.cpp
+++ b/src/object_gui.cpp
@@ -236,7 +236,7 @@ public:
if (callback_res != CALLBACK_FAILED) {
StringID message = GetGRFStringID(spec->grf_prop.grffile->grfid, 0xD000 + callback_res);
if (message != STR_NULL && message != STR_UNDEFINED) {
- PrepareTextRefStackUsage(6);
+ StartTextRefStackUsage(6);
/* Use all the available space left from where we stand up to the
* end of the window. We ALSO enlarge the window if needed, so we
* can 'go' wild with the bottom of the window. */