Merge branch 'master' into jgrpp

# Conflicts:
#	src/build_vehicle_gui.cpp
#	src/cheat_gui.cpp
#	src/company_gui.cpp
#	src/error_gui.cpp
#	src/fios_gui.cpp
#	src/gfx_func.h
#	src/graph_gui.cpp
#	src/group_gui.cpp
#	src/misc_gui.cpp
#	src/newgrf_debug_gui.cpp
#	src/order_gui.cpp
#	src/road_gui.cpp
#	src/roadveh_gui.cpp
#	src/settings_gui.cpp
#	src/ship_gui.cpp
#	src/station_gui.cpp
#	src/statusbar_gui.cpp
#	src/subsidy_gui.cpp
#	src/timetable_gui.cpp
#	src/town_gui.cpp
#	src/train_gui.cpp
#	src/tree_gui.cpp
#	src/vehicle_gui.cpp
#	src/widget.cpp
#	src/widgets/dropdown.cpp
#	src/window_gui.h
This commit is contained in:
Jonathan G Rennison
2022-12-04 13:53:36 +00:00
53 changed files with 1478 additions and 1416 deletions

View File

@@ -66,8 +66,9 @@ void ShowNewGRFError()
}
}
static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint right, uint bottom, bool show_params)
static void ShowNewGRFInfo(const GRFConfig *c, const Rect &r, bool show_params)
{
Rect tr = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
if (c->error != nullptr) {
char message[512];
SetDParamStr(0, c->error->custom_message); // is skipped by built-in messages
@@ -79,34 +80,34 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint right, uint
GetString(message, c->error->message != STR_NULL ? c->error->message : STR_JUST_RAW_STRING, lastof(message));
SetDParamStr(0, message);
y = DrawStringMultiLine(x, right, y, bottom, c->error->severity);
tr.top = DrawStringMultiLine(tr, c->error->severity);
}
/* Draw filename or not if it is not known (GRF sent over internet) */
if (c->filename != nullptr) {
SetDParamStr(0, c->filename);
y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_FILENAME);
tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_FILENAME);
}
/* Prepare and draw GRF ID */
char buff[256];
seprintf(buff, lastof(buff), "%08X", BSWAP32(c->ident.grfid));
SetDParamStr(0, buff);
y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_GRF_ID);
tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_GRF_ID);
if ((_settings_client.gui.newgrf_developer_tools || _settings_client.gui.newgrf_show_old_versions) && c->version != 0) {
SetDParam(0, c->version);
y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_VERSION);
tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_VERSION);
}
if ((_settings_client.gui.newgrf_developer_tools || _settings_client.gui.newgrf_show_old_versions) && c->min_loadable_version != 0) {
SetDParam(0, c->min_loadable_version);
y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_MIN_VERSION);
tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_MIN_VERSION);
}
/* Prepare and draw MD5 sum */
md5sumToString(buff, lastof(buff), c->ident.md5sum);
SetDParamStr(0, buff);
y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_MD5SUM);
tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_MD5SUM);
/* Show GRF parameter list */
if (show_params) {
@@ -117,7 +118,7 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint right, uint
} else {
SetDParam(0, STR_NEWGRF_SETTINGS_PARAMETER_NONE);
}
y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_PARAMETER);
tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_PARAMETER);
/* Draw the palette of the NewGRF */
if (c->palette & GRFP_BLT_32BPP) {
@@ -125,21 +126,21 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint right, uint
} else {
SetDParam(0, (c->palette & GRFP_USE_WINDOWS) ? STR_NEWGRF_SETTINGS_PALETTE_LEGACY : STR_NEWGRF_SETTINGS_PALETTE_DEFAULT);
}
y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_PALETTE);
tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_PALETTE);
}
/* Show flags */
if (c->status == GCS_NOT_FOUND) y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_NOT_FOUND);
if (c->status == GCS_DISABLED) y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_DISABLED);
if (HasBit(c->flags, GCF_INVALID)) y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_INCOMPATIBLE);
if (HasBit(c->flags, GCF_COMPATIBLE)) y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_COMPATIBLE_LOADED);
if (c->status == GCS_NOT_FOUND) tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_NOT_FOUND);
if (c->status == GCS_DISABLED) tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_DISABLED);
if (HasBit(c->flags, GCF_INVALID)) tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_INCOMPATIBLE);
if (HasBit(c->flags, GCF_COMPATIBLE)) tr.top = DrawStringMultiLine(tr, STR_NEWGRF_COMPATIBLE_LOADED);
/* Draw GRF info if it exists */
if (!StrEmpty(c->GetDescription())) {
SetDParamStr(0, c->GetDescription());
y = DrawStringMultiLine(x, right, y, bottom, STR_BLACK_RAW_STRING);
tr.top = DrawStringMultiLine(tr, STR_BLACK_RAW_STRING);
} else {
y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_NO_INFO);
tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_NO_INFO);
}
}
@@ -252,18 +253,17 @@ struct NewGRFParametersWindow : public Window {
if (par_info == nullptr) return;
const char *desc = GetGRFStringFromGRFText(par_info->desc);
if (desc == nullptr) return;
DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_TEXTPANEL_TOP, r.bottom - WD_TEXTPANEL_BOTTOM, desc, TC_BLACK);
DrawStringMultiLine(r.Shrink(WD_FRAMERECT_LEFT, WD_TEXTPANEL_TOP, WD_FRAMERECT_RIGHT, WD_TEXTPANEL_BOTTOM), desc, TC_BLACK);
return;
} else if (widget != WID_NP_BACKGROUND) {
return;
}
Rect ir = r.Shrink(WD_FRAMERECT_LEFT, 0, WD_FRAMERECT_RIGHT, 0);
bool rtl = _current_text_dir == TD_RTL;
uint buttons_left = rtl ? r.right - SETTING_BUTTON_WIDTH - 3 : r.left + 4;
uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : SETTING_BUTTON_WIDTH + 8);
uint text_right = r.right - (rtl ? SETTING_BUTTON_WIDTH + 8 : WD_FRAMERECT_RIGHT);
uint buttons_left = rtl ? ir.right - SETTING_BUTTON_WIDTH - 3 : ir.left + 4;
Rect tr = r.Indent(SETTING_BUTTON_WIDTH + 8, rtl);
int y = r.top;
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
@@ -273,13 +273,13 @@ struct NewGRFParametersWindow : public Window {
bool selected = (i == this->clicked_row);
if (par_info->type == PTYPE_BOOL) {
DrawBoolButton(buttons_left, y + button_y_offset, current_value != 0, this->editable);
DrawBoolButton(buttons_left, ir.top + button_y_offset, current_value != 0, this->editable);
SetDParam(2, par_info->GetValue(this->grf_config) == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
} else if (par_info->type == PTYPE_UINT_ENUM) {
if (par_info->complete_labels) {
DrawDropDownButton(buttons_left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && this->clicked_dropdown, this->editable);
DrawDropDownButton(buttons_left, ir.top + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && this->clicked_dropdown, this->editable);
} else {
DrawArrowButtons(buttons_left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, this->editable && current_value > par_info->min_value, this->editable && current_value < par_info->max_value);
DrawArrowButtons(buttons_left, ir.top + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, this->editable && current_value > par_info->min_value, this->editable && current_value < par_info->max_value);
}
SetDParam(2, STR_JUST_INT);
SetDParam(3, current_value);
@@ -301,8 +301,8 @@ struct NewGRFParametersWindow : public Window {
SetDParam(1, i + 1);
}
DrawString(text_left, text_right, y + text_y_offset, STR_NEWGRF_PARAMETERS_SETTING, selected ? TC_WHITE : TC_LIGHT_BLUE);
y += this->line_height;
DrawString(tr.left, tr.right, ir.top + text_y_offset, STR_NEWGRF_PARAMETERS_SETTING, selected ? TC_WHITE : TC_LIGHT_BLUE);
ir.top += this->line_height;
}
}
@@ -729,13 +729,13 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
{
Dimension d = maxdim(GetSpriteSize(SPR_SQUARE), GetSpriteSize(SPR_WARNING_SIGN));
resize->height = std::max(d.height + 2U, FONT_HEIGHT_NORMAL + 2U);
size->height = std::max(size->height, WD_FRAMERECT_TOP + 6 * resize->height + WD_FRAMERECT_BOTTOM);
size->height = std::max(size->height, padding.height + 6 * resize->height);
break;
}
case WID_NS_AVAIL_LIST:
resize->height = std::max(12, FONT_HEIGHT_NORMAL + 2);
size->height = std::max(size->height, WD_FRAMERECT_TOP + 8 * resize->height + WD_FRAMERECT_BOTTOM);
size->height = std::max(size->height, padding.height + 8 * resize->height);
break;
case WID_NS_NEWGRF_INFO_TITLE: {
@@ -830,10 +830,11 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
{
switch (widget) {
case WID_NS_FILE_LIST: {
GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
const Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
GfxFillRect(br, PC_BLACK);
Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
uint step_height = this->GetWidget<NWidgetBase>(WID_NS_FILE_LIST)->resize_y;
uint y = r.top + WD_FRAMERECT_TOP;
Dimension square = GetSpriteSize(SPR_SQUARE);
Dimension warning = GetSpriteSize(SPR_WARNING_SIGN);
int square_offset_y = (step_height - square.height) / 2;
@@ -841,10 +842,10 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
bool rtl = _current_text_dir == TD_RTL;
uint text_left = rtl ? r.left + WD_FRAMERECT_LEFT : r.left + square.width + 15;
uint text_right = rtl ? r.right - square.width - 15 : r.right - WD_FRAMERECT_RIGHT;
uint square_left = rtl ? r.right - square.width - 5 : r.left + 5;
uint warning_left = rtl ? r.right - square.width - warning.width - 10 : r.left + square.width + 10;
uint text_left = rtl ? tr.left : tr.left + square.width + 13;
uint text_right = rtl ? tr.right - square.width - 13 : tr.right;
uint square_left = rtl ? tr.right - square.width - 3 : tr.left + 3;
uint warning_left = rtl ? tr.right - square.width - warning.width - 8 : tr.left + square.width + 8;
int i = 0;
for (const GRFConfig *c = this->actives; c != nullptr; c = c->next, i++) {
@@ -854,35 +855,36 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
PaletteID pal = this->GetPalette(c);
if (h) {
GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 1, PC_DARK_BLUE);
GfxFillRect(br.left, tr.top, br.right, tr.top + step_height - 1, PC_DARK_BLUE);
} else if (i == this->active_over) {
/* Get index of current selection. */
int active_sel_pos = 0;
for (GRFConfig *c = this->actives; c != nullptr && c != this->active_sel; c = c->next, active_sel_pos++) {}
if (active_sel_pos != this->active_over) {
uint top = this->active_over < active_sel_pos ? y + 1 : y + step_height - 2;
GfxFillRect(r.left + WD_FRAMERECT_LEFT, top - 1, r.right - WD_FRAMERECT_RIGHT, top + 1, PC_GREY);
uint top = this->active_over < active_sel_pos ? tr.top + 1 : tr.top + step_height - 2;
GfxFillRect(tr.left, top - 1, tr.right, top + 1, PC_GREY);
}
}
DrawSprite(SPR_SQUARE, pal, square_left, y + square_offset_y);
if (c->error != nullptr) DrawSprite(SPR_WARNING_SIGN, 0, warning_left, y + warning_offset_y);
DrawSprite(SPR_SQUARE, pal, square_left, tr.top + square_offset_y);
if (c->error != nullptr) DrawSprite(SPR_WARNING_SIGN, 0, warning_left, tr.top + warning_offset_y);
uint txtoffset = c->error == nullptr ? 0 : warning.width;
DrawString(text_left + (rtl ? 0 : txtoffset), text_right - (rtl ? txtoffset : 0), y + offset_y, text, h ? TC_WHITE : TC_ORANGE);
y += step_height;
DrawString(text_left + (rtl ? 0 : txtoffset), text_right - (rtl ? txtoffset : 0), tr.top + offset_y, text, h ? TC_WHITE : TC_ORANGE);
tr.top += step_height;
}
}
if (i == this->active_over && this->vscroll->IsVisible(i)) { // Highlight is after the last GRF entry.
GfxFillRect(r.left + WD_FRAMERECT_LEFT, y, r.right - WD_FRAMERECT_RIGHT, y + 2, PC_GREY);
GfxFillRect(tr.left, tr.top, tr.right, tr.top + 2, PC_GREY);
}
break;
}
case WID_NS_AVAIL_LIST: {
GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, this->active_over == -2 ? PC_DARK_GREY : PC_BLACK);
const Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
GfxFillRect(br, this->active_over == -2 ? PC_DARK_GREY : PC_BLACK);
Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
uint step_height = this->GetWidget<NWidgetBase>(WID_NS_AVAIL_LIST)->resize_y;
int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
uint y = r.top + WD_FRAMERECT_TOP;
uint min_index = this->vscroll2->GetPosition();
uint max_index = std::min(min_index + this->vscroll2->GetCapacity(), (uint)this->avails.size());
@@ -891,16 +893,16 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
bool h = (c == this->avail_sel);
const char *text = c->GetName();
if (h) GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 1, PC_DARK_BLUE);
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y + offset_y, text, h ? TC_WHITE : TC_SILVER);
y += step_height;
if (h) GfxFillRect(br.left, tr.top, br.right, tr.top + step_height - 1, PC_DARK_BLUE);
DrawString(tr.left, tr.right, tr.top + offset_y, text, h ? TC_WHITE : TC_SILVER);
tr.top += step_height;
}
break;
}
case WID_NS_NEWGRF_INFO_TITLE:
/* Create the nice grayish rectangle at the details top. */
GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_DARK_BLUE);
GfxFillRect(r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM), PC_DARK_BLUE);
DrawString(r.left, r.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), STR_NEWGRF_SETTINGS_INFO_TITLE, TC_FROMSTRING, SA_HOR_CENTER);
break;
@@ -908,7 +910,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
const GRFConfig *selected = this->active_sel;
if (selected == nullptr) selected = this->avail_sel;
if (selected != nullptr) {
ShowNewGRFInfo(selected, r.left + WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, r.right - WD_FRAMERECT_RIGHT, r.bottom - WD_FRAMERECT_BOTTOM, this->show_params);
ShowNewGRFInfo(selected, r, this->show_params);
}
break;
}
@@ -1615,13 +1617,13 @@ public:
this->acs->SetupSmallestSize(w, init_array);
this->inf->SetupSmallestSize(w, init_array);
uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right;
uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right;
uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right;
uint min_avs_width = this->avs->smallest_x + this->avs->padding.Horizontal();
uint min_acs_width = this->acs->smallest_x + this->acs->padding.Horizontal();
uint min_inf_width = this->inf->smallest_x + this->inf->padding.Horizontal();
uint min_avs_height = this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom;
uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
uint min_inf_height = this->inf->smallest_y + this->inf->padding_top + this->inf->padding_bottom;
uint min_avs_height = this->avs->smallest_y + this->avs->padding.Vertical();
uint min_acs_height = this->acs->smallest_y + this->acs->padding.Vertical();
uint min_inf_height = this->inf->smallest_y + this->inf->padding.Vertical();
/* Smallest window is in two column mode. */
this->smallest_x = std::max(min_avs_width, min_acs_width) + INTER_COLUMN_SPACING + min_inf_width;
@@ -1651,9 +1653,9 @@ public:
{
this->StoreSizePosition(sizing, x, y, given_width, given_height);
uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right;
uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right;
uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right;
uint min_avs_width = this->avs->smallest_x + this->avs->padding.Horizontal();
uint min_acs_width = this->acs->smallest_x + this->acs->padding.Horizontal();
uint min_inf_width = this->inf->smallest_x + this->inf->padding.Horizontal();
uint min_list_width = std::max(min_avs_width, min_acs_width); // Smallest width of the lists such that they have equal width (incl padding).
uint avs_extra_width = min_list_width - min_avs_width; // Additional width needed for avs to reach min_list_width.
@@ -1689,10 +1691,10 @@ public:
avs_width = ComputeMaxSize(this->avs->smallest_x, this->avs->smallest_x + avs_width, this->avs->GetHorizontalStepSize(sizing));
uint acs_width = given_width - // Remaining space, including horizontal padding.
inf_width - this->inf->padding_left - this->inf->padding_right -
avs_width - this->avs->padding_left - this->avs->padding_right - 2 * INTER_COLUMN_SPACING;
inf_width - this->inf->padding.Horizontal() -
avs_width - this->avs->padding.Horizontal() - 2 * INTER_COLUMN_SPACING;
acs_width = ComputeMaxSize(min_acs_width, acs_width, this->acs->GetHorizontalStepSize(sizing)) -
this->acs->padding_left - this->acs->padding_right;
this->acs->padding.Horizontal();
/* Never use fill_y on these; the minimal size is chosen, so that the 3 column view looks nice */
uint avs_height = ComputeMaxSize(this->avs->smallest_y, given_height, this->avs->resize_y);
@@ -1700,25 +1702,25 @@ public:
/* Assign size and position to the children. */
if (rtl) {
x += this->inf->padding_left;
this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING;
x += this->inf->padding.left;
this->inf->AssignSizePosition(sizing, x, y + this->inf->padding.top, inf_width, inf_height, rtl);
x += inf_width + this->inf->padding.right + INTER_COLUMN_SPACING;
} else {
x += this->avs->padding_left;
this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl);
x += avs_width + this->avs->padding_right + INTER_COLUMN_SPACING;
x += this->avs->padding.left;
this->avs->AssignSizePosition(sizing, x, y + this->avs->padding.top, avs_width, avs_height, rtl);
x += avs_width + this->avs->padding.right + INTER_COLUMN_SPACING;
}
x += this->acs->padding_left;
this->acs->AssignSizePosition(sizing, x, y + this->acs->padding_top, acs_width, acs_height, rtl);
x += acs_width + this->acs->padding_right + INTER_COLUMN_SPACING;
x += this->acs->padding.left;
this->acs->AssignSizePosition(sizing, x, y + this->acs->padding.top, acs_width, acs_height, rtl);
x += acs_width + this->acs->padding.right + INTER_COLUMN_SPACING;
if (rtl) {
x += this->avs->padding_left;
this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl);
x += this->avs->padding.left;
this->avs->AssignSizePosition(sizing, x, y + this->avs->padding.top, avs_width, avs_height, rtl);
} else {
x += this->inf->padding_left;
this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
x += this->inf->padding.left;
this->inf->AssignSizePosition(sizing, x, y + this->inf->padding.top, inf_width, inf_height, rtl);
}
} else {
/* Two columns, all space in extra_width goes to both lists. Since the lists are underneath each other,
@@ -1728,8 +1730,8 @@ public:
uint acs_width = ComputeMaxSize(this->acs->smallest_x, this->acs->smallest_x + acs_extra_width + extra_width,
this->acs->GetHorizontalStepSize(sizing));
uint min_avs_height = (!this->editable) ? 0 : this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom + INTER_LIST_SPACING;
uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
uint min_avs_height = (!this->editable) ? 0 : this->avs->smallest_y + this->avs->padding.Vertical() + INTER_LIST_SPACING;
uint min_acs_height = this->acs->smallest_y + this->acs->padding.Vertical();
uint extra_height = given_height - min_acs_height - min_avs_height;
/* Never use fill_y on these; instead use the INTER_LIST_SPACING as filler */
@@ -1739,29 +1741,29 @@ public:
/* Assign size and position to the children. */
if (rtl) {
x += this->inf->padding_left;
this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING;
x += this->inf->padding.left;
this->inf->AssignSizePosition(sizing, x, y + this->inf->padding.top, inf_width, inf_height, rtl);
x += inf_width + this->inf->padding.right + INTER_COLUMN_SPACING;
this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, y + this->acs->padding_top, acs_width, acs_height, rtl);
this->acs->AssignSizePosition(sizing, x + this->acs->padding.left, y + this->acs->padding.top, acs_width, acs_height, rtl);
if (this->editable) {
this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
this->avs->AssignSizePosition(sizing, x + this->avs->padding.left, y + given_height - avs_height - this->avs->padding.bottom, avs_width, avs_height, rtl);
} else {
this->avs->AssignSizePosition(sizing, 0, 0, this->avs->smallest_x, this->avs->smallest_y, rtl);
}
} else {
this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, y + this->acs->padding_top, acs_width, acs_height, rtl);
this->acs->AssignSizePosition(sizing, x + this->acs->padding.left, y + this->acs->padding.top, acs_width, acs_height, rtl);
if (this->editable) {
this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
this->avs->AssignSizePosition(sizing, x + this->avs->padding.left, y + given_height - avs_height - this->avs->padding.bottom, avs_width, avs_height, rtl);
} else {
this->avs->AssignSizePosition(sizing, 0, 0, this->avs->smallest_x, this->avs->smallest_y, rtl);
}
uint dx = this->acs->current_x + this->acs->padding_left + this->acs->padding_right;
uint dx = this->acs->current_x + this->acs->padding.Horizontal();
if (this->editable) {
dx = std::max(dx, this->avs->current_x + this->avs->padding_left + this->avs->padding_right);
dx = std::max(dx, this->avs->current_x + this->avs->padding.Horizontal());
}
x += dx + INTER_COLUMN_SPACING + this->inf->padding_left;
this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
x += dx + INTER_COLUMN_SPACING + this->inf->padding.left;
this->inf->AssignSizePosition(sizing, x, y + this->inf->padding.top, inf_width, inf_height, rtl);
}
}
}
@@ -2113,20 +2115,21 @@ struct SavePresetWindow : public Window {
{
switch (widget) {
case WID_SVP_PRESET_LIST: {
GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
const Rect br = r.Shrink(WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM);
GfxFillRect(br, PC_BLACK);
uint step_height = this->GetWidget<NWidgetBase>(WID_SVP_PRESET_LIST)->resize_y;
int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
uint y = r.top + WD_FRAMERECT_TOP;
Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
uint min_index = this->vscroll->GetPosition();
uint max_index = std::min(min_index + this->vscroll->GetCapacity(), (uint)this->presets.size());
for (uint i = min_index; i < max_index; i++) {
if ((int)i == this->selected) GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 2, PC_DARK_BLUE);
if ((int)i == this->selected) GfxFillRect(br.left, tr.top, br.right, tr.top + step_height - 1, PC_DARK_BLUE);
const char *text = this->presets[i].c_str();
DrawString(r.left + WD_FRAMERECT_LEFT, r.right, y + offset_y, text, ((int)i == this->selected) ? TC_WHITE : TC_SILVER);
y += step_height;
DrawString(tr.left, tr.right, tr.top + offset_y, text, ((int)i == this->selected) ? TC_WHITE : TC_SILVER);
tr.top += step_height;
}
break;
}