1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-16 08:52:40 +01:00

Add: [NewGRF] All callbacks returning D0xx strings, have now the option to return any string id via register 0x100.

This commit is contained in:
frosch
2025-05-06 17:28:51 +02:00
committed by frosch
parent 84bc78fd8f
commit c6fa5022cb
11 changed files with 114 additions and 54 deletions

View File

@@ -240,13 +240,16 @@ public:
std::array<int32_t, 6> regs100;
uint16_t callback_res = GetObjectCallback(CBID_OBJECT_FUND_MORE_TEXT, 0, 0, spec, nullptr, INVALID_TILE, regs100, _object_gui.sel_view);
if (callback_res != CALLBACK_FAILED && callback_res != 0x400) {
if (callback_res > 0x400) {
std::string str;
if (callback_res == 0x40F) {
str = GetGRFStringWithTextStack(spec->grf_prop.grffile, static_cast<GRFStringID>(regs100[0]), std::span{regs100}.subspan(1));
} else if (callback_res > 0x400) {
ErrorUnknownCallbackResult(spec->grf_prop.grfid, CBID_OBJECT_FUND_MORE_TEXT, callback_res);
} else {
std::string str = GetGRFStringWithTextStack(spec->grf_prop.grffile, GRFSTR_MISC_GRF_TEXT + callback_res, regs100);
if (!str.empty()) {
tr.top = DrawStringMultiLine(tr, str, TC_ORANGE);
}
str = GetGRFStringWithTextStack(spec->grf_prop.grffile, GRFSTR_MISC_GRF_TEXT + callback_res, regs100);
}
if (!str.empty()) {
tr.top = DrawStringMultiLine(tr, str, TC_ORANGE);
}
}
}