Mercurial > hg > openttd
changeset 17836:e20af6605036 draft
(svn r22627) -Codechange: Rename PrepareTextRefStackUsage() to StartTextRefStackUsage() to make it more obvious that you must call StopTextRefStackUsage() at some point. Also extent the documentation.
author | frosch <frosch@openttd.org> |
---|---|
date | Sun, 03 Jul 2011 13:49:29 +0000 |
parents | b783f0c424cb |
children | b6608baed897 |
files | src/build_vehicle_gui.cpp src/industry_gui.cpp src/newgrf_industries.cpp src/newgrf_industrytiles.cpp src/newgrf_text.cpp src/newgrf_text.h src/object_gui.cpp |
diffstat | 7 files changed, 22 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -740,7 +740,7 @@ /* 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;
--- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -74,7 +74,7 @@ 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 @@ 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 @@ 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. */
--- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -551,7 +551,7 @@ /* Copy some parameters from the registers to the error message text ref. stack */ SwitchToErrorRefStack(); - PrepareTextRefStackUsage(4); + StartTextRefStackUsage(4); SwitchToNormalRefStack(); switch (result) {
--- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -310,7 +310,7 @@ /* Copy some parameters from the registers to the error message text ref. stack */ SwitchToErrorRefStack(); - PrepareTextRefStackUsage(4); + StartTextRefStackUsage(4); SwitchToNormalRefStack(); switch (callback_res) {
--- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -955,10 +955,22 @@ } /** - * 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;
--- a/src/newgrf_text.h +++ b/src/newgrf_text.h @@ -34,7 +34,7 @@ bool CheckGrfLangID(byte lang_id, byte grf_version); -void PrepareTextRefStackUsage(byte numEntries); +void StartTextRefStackUsage(byte numEntries); void StopTextRefStackUsage(); void SwitchToNormalRefStack(); void SwitchToErrorRefStack();
--- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -236,7 +236,7 @@ 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. */