mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Simplify some calls to DrawStringMultiLine(). (#13643)
Sometimes the bottom is passed as UINT16_MAX for no reason. In this case just pass the rect. Other times it's to extend the window height; in that case just extend the rect itself.pull/13642/head
parent
b264a4864b
commit
4ac81656ee
|
@ -901,6 +901,9 @@ public:
|
|||
bool first = true;
|
||||
bool has_accept = false;
|
||||
|
||||
/* Use all the available space past the rect, so that we can enlarge the window if needed. */
|
||||
ir.bottom = INT_MAX;
|
||||
|
||||
if (i->prod_level == PRODLEVEL_CLOSURE) {
|
||||
DrawString(ir, STR_INDUSTRY_VIEW_INDUSTRY_ANNOUNCED_CLOSURE);
|
||||
ir.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_wide;
|
||||
|
@ -1008,10 +1011,7 @@ public:
|
|||
ir.top += WidgetDimensions::scaled.vsep_wide;
|
||||
|
||||
StartTextRefStackUsage(ind->grf_prop.grffile, 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. */
|
||||
ir.top = DrawStringMultiLine(ir.left, ir.right, ir.top, UINT16_MAX, message, TC_BLACK);
|
||||
ir.top = DrawStringMultiLine(ir, message, TC_BLACK);
|
||||
StopTextRefStackUsage();
|
||||
}
|
||||
}
|
||||
|
@ -1021,7 +1021,7 @@ public:
|
|||
if (!i->text.empty()) {
|
||||
SetDParamStr(0, i->text);
|
||||
ir.top += WidgetDimensions::scaled.vsep_wide;
|
||||
ir.top = DrawStringMultiLine(ir.left, ir.right, ir.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
|
||||
ir.top = DrawStringMultiLine(ir, STR_JUST_RAW_STRING, TC_BLACK);
|
||||
}
|
||||
|
||||
/* Return required bottom position, the last pixel row plus some padding. */
|
||||
|
|
|
@ -326,7 +326,7 @@ public:
|
|||
|
||||
if (!lt->header.empty()) {
|
||||
SetDParamStr(0, lt->header);
|
||||
ir.top = DrawStringMultiLine(ir.left, ir.right, ir.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK) + WidgetDimensions::scaled.vsep_wide;
|
||||
ir.top = DrawStringMultiLine(ir, STR_JUST_RAW_STRING, TC_BLACK) + WidgetDimensions::scaled.vsep_wide;
|
||||
}
|
||||
|
||||
int icon_y_offset = (this->line_height - this->icon_size.height) / 2;
|
||||
|
@ -354,7 +354,7 @@ public:
|
|||
if (!lt->footer.empty()) {
|
||||
ir.top += WidgetDimensions::scaled.vsep_wide;
|
||||
SetDParamStr(0, lt->footer);
|
||||
ir.top = DrawStringMultiLine(ir.left, ir.right, ir.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
|
||||
ir.top = DrawStringMultiLine(ir, STR_JUST_RAW_STRING, TC_BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -234,6 +234,7 @@ public:
|
|||
|
||||
Rect tr = r;
|
||||
const int bottom = tr.bottom;
|
||||
/* Use all the available space past the rect, so that we can enlarge the window if needed. */
|
||||
tr.bottom = INT16_MAX;
|
||||
tr.top = DrawBadgeNameList(tr, spec->badges, GSF_OBJECTS);
|
||||
|
||||
|
@ -247,9 +248,6 @@ public:
|
|||
StringID message = GetGRFStringID(spec->grf_prop.grfid, GRFSTR_MISC_GRF_TEXT + callback_res);
|
||||
if (message != STR_NULL && message != STR_UNDEFINED) {
|
||||
StartTextRefStackUsage(spec->grf_prop.grffile, 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. */
|
||||
tr.top = DrawStringMultiLine(tr, message, TC_ORANGE);
|
||||
StopTextRefStackUsage();
|
||||
}
|
||||
|
|
|
@ -548,17 +548,17 @@ struct GameOptionsWindow : Window {
|
|||
switch (widget) {
|
||||
case WID_GO_BASE_GRF_DESCRIPTION:
|
||||
SetDParamStr(0, BaseGraphics::GetUsedSet()->GetDescription(GetCurrentLanguageIsoCode()));
|
||||
DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
|
||||
DrawStringMultiLine(r, STR_JUST_RAW_STRING, TC_BLACK);
|
||||
break;
|
||||
|
||||
case WID_GO_BASE_SFX_DESCRIPTION:
|
||||
SetDParamStr(0, BaseSounds::GetUsedSet()->GetDescription(GetCurrentLanguageIsoCode()));
|
||||
DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
|
||||
DrawStringMultiLine(r, STR_JUST_RAW_STRING, TC_BLACK);
|
||||
break;
|
||||
|
||||
case WID_GO_BASE_MUSIC_DESCRIPTION:
|
||||
SetDParamStr(0, BaseMusic::GetUsedSet()->GetDescription(GetCurrentLanguageIsoCode()));
|
||||
DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
|
||||
DrawStringMultiLine(r, STR_JUST_RAW_STRING, TC_BLACK);
|
||||
break;
|
||||
|
||||
case WID_GO_GUI_SCALE:
|
||||
|
|
Loading…
Reference in New Issue