mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-26 13:44:16 +01:00
Codechange: Preprocess text ref stack parameters. (#13642)
NewGRF text ref stack is now processed in advance, creating parameters as necessary, and then encoding this into an EncodedString.
This commit is contained in:
@@ -104,9 +104,7 @@ static void GetCargoSuffix(uint cargo, CargoSuffixType cst, const Industry *ind,
|
||||
if (indspec->grf_prop.grffile->grf_version < 8) {
|
||||
if (GB(callback, 0, 8) == 0xFF) return;
|
||||
if (callback < 0x400) {
|
||||
StartTextRefStackUsage(indspec->grf_prop.grffile, 6);
|
||||
suffix.text = GetString(GetGRFStringID(indspec->grf_prop.grfid, GRFSTR_MISC_GRF_TEXT + callback));
|
||||
StopTextRefStackUsage();
|
||||
suffix.text = GetGRFStringWithTextStack(indspec->grf_prop.grffile, GRFSTR_MISC_GRF_TEXT + callback, 6);
|
||||
suffix.display = CSD_CARGO_AMOUNT_TEXT;
|
||||
return;
|
||||
}
|
||||
@@ -120,16 +118,12 @@ static void GetCargoSuffix(uint cargo, CargoSuffixType cst, const Industry *ind,
|
||||
return;
|
||||
}
|
||||
if (callback < 0x400) {
|
||||
StartTextRefStackUsage(indspec->grf_prop.grffile, 6);
|
||||
suffix.text = GetString(GetGRFStringID(indspec->grf_prop.grfid, GRFSTR_MISC_GRF_TEXT + callback));
|
||||
StopTextRefStackUsage();
|
||||
suffix.text = GetGRFStringWithTextStack(indspec->grf_prop.grffile, GRFSTR_MISC_GRF_TEXT + callback, 6);
|
||||
suffix.display = CSD_CARGO_AMOUNT_TEXT;
|
||||
return;
|
||||
}
|
||||
if (callback >= 0x800 && callback < 0xC00) {
|
||||
StartTextRefStackUsage(indspec->grf_prop.grffile, 6);
|
||||
suffix.text = GetString(GetGRFStringID(indspec->grf_prop.grfid, GRFSTR_MISC_GRF_TEXT + callback - 0x800));
|
||||
StopTextRefStackUsage();
|
||||
suffix.text = GetGRFStringWithTextStack(indspec->grf_prop.grffile, GRFSTR_MISC_GRF_TEXT + callback - 0x800, 6);
|
||||
suffix.display = CSD_CARGO_TEXT;
|
||||
return;
|
||||
}
|
||||
@@ -604,11 +598,9 @@ public:
|
||||
if (callback_res > 0x400) {
|
||||
ErrorUnknownCallbackResult(indsp->grf_prop.grfid, CBID_INDUSTRY_FUND_MORE_TEXT, callback_res);
|
||||
} else {
|
||||
StringID str = GetGRFStringID(indsp->grf_prop.grfid, GRFSTR_MISC_GRF_TEXT + callback_res); // No. here's the new string
|
||||
if (str != STR_UNDEFINED) {
|
||||
StartTextRefStackUsage(indsp->grf_prop.grffile, 6);
|
||||
std::string str = GetGRFStringWithTextStack(indsp->grf_prop.grffile, GRFSTR_MISC_GRF_TEXT + callback_res, 6);
|
||||
if (!str.empty()) {
|
||||
DrawStringMultiLine(ir, str, TC_YELLOW);
|
||||
StopTextRefStackUsage();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1006,13 +998,10 @@ public:
|
||||
if (callback_res > 0x400) {
|
||||
ErrorUnknownCallbackResult(ind->grf_prop.grfid, CBID_INDUSTRY_WINDOW_MORE_TEXT, callback_res);
|
||||
} else {
|
||||
StringID message = GetGRFStringID(ind->grf_prop.grfid, GRFSTR_MISC_GRF_TEXT + callback_res);
|
||||
if (message != STR_NULL && message != STR_UNDEFINED) {
|
||||
std::string str = GetGRFStringWithTextStack(ind->grf_prop.grffile, GRFSTR_MISC_GRF_TEXT + callback_res, 6);
|
||||
if (!str.empty()) {
|
||||
ir.top += WidgetDimensions::scaled.vsep_wide;
|
||||
|
||||
StartTextRefStackUsage(ind->grf_prop.grffile, 6);
|
||||
ir.top = DrawStringMultiLine(ir, message, TC_BLACK);
|
||||
StopTextRefStackUsage();
|
||||
ir.top = DrawStringMultiLine(ir, str, TC_YELLOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user