Merge branch 'master' into jgrpp
# Conflicts: # src/build_vehicle_gui.cpp # src/engine.cpp # src/engine_func.h # src/group_gui.cpp # src/lang/english.txt # src/newgrf.cpp # src/saveload/oldloader_sl.cpp # src/timetable_cmd.cpp # src/timetable_cmd.h # src/timetable_gui.cpp
This commit is contained in:
@@ -84,6 +84,9 @@ private:
|
||||
Scrollbar *vscroll;
|
||||
uint displayed_actions_on_previous_painting; ///< Actions that were available on the previous call to OnPaint()
|
||||
|
||||
Dimension icon_size; ///< Dimensions of company icon
|
||||
Dimension exclusive_size; ///< Dimensions of exlusive icon
|
||||
|
||||
/**
|
||||
* Get the position of the Nth set bit.
|
||||
*
|
||||
@@ -121,6 +124,12 @@ public:
|
||||
this->vscroll->SetCapacity((this->GetWidget<NWidgetBase>(WID_TA_COMMAND_LIST)->current_y - WidgetDimensions::scaled.framerect.Vertical()) / FONT_HEIGHT_NORMAL);
|
||||
}
|
||||
|
||||
void OnInit() override
|
||||
{
|
||||
this->icon_size = GetSpriteSize(SPR_COMPANY_ICON);
|
||||
this->exclusive_size = GetSpriteSize(SPR_EXCLUSIVE_TRANSPORT);
|
||||
}
|
||||
|
||||
void OnPaint() override
|
||||
{
|
||||
int numact;
|
||||
@@ -149,26 +158,22 @@ public:
|
||||
{
|
||||
Rect r = this->GetWidget<NWidgetBase>(WID_TA_RATING_INFO)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
|
||||
|
||||
DrawString(r, STR_LOCAL_AUTHORITY_COMPANY_RATINGS);
|
||||
r.top += FONT_HEIGHT_NORMAL;
|
||||
int text_y_offset = (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2;
|
||||
int icon_y_offset = (this->resize.step_height - this->icon_size.height) / 2;
|
||||
int exclusive_y_offset = (this->resize.step_height - this->exclusive_size.height) / 2;
|
||||
|
||||
Dimension icon_size = GetSpriteSize(SPR_COMPANY_ICON);
|
||||
int icon_width = icon_size.width;
|
||||
int icon_y_offset = (FONT_HEIGHT_NORMAL - icon_size.height) / 2;
|
||||
|
||||
Dimension exclusive_size = GetSpriteSize(SPR_EXCLUSIVE_TRANSPORT);
|
||||
int exclusive_width = exclusive_size.width;
|
||||
int exclusive_y_offset = (FONT_HEIGHT_NORMAL - exclusive_size.height) / 2;
|
||||
DrawString(r.left, r.right, r.top + text_y_offset, STR_LOCAL_AUTHORITY_COMPANY_RATINGS);
|
||||
r.top += this->resize.step_height;
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
Rect text = r.Indent(icon_width + WidgetDimensions::scaled.hsep_normal + exclusive_width + WidgetDimensions::scaled.hsep_normal, rtl);
|
||||
uint icon_left = r.WithWidth(icon_width, rtl).left;
|
||||
uint exclusive_left = r.Indent(icon_width + WidgetDimensions::scaled.hsep_normal, rtl).WithWidth(exclusive_width, rtl).left;
|
||||
Rect icon = r.WithWidth(this->icon_size.width, rtl);
|
||||
Rect exclusive = r.Indent(this->icon_size.width + WidgetDimensions::scaled.hsep_normal, rtl).WithWidth(this->exclusive_size.width, rtl);
|
||||
Rect text = r.Indent(this->icon_size.width + WidgetDimensions::scaled.hsep_normal + this->exclusive_size.width + WidgetDimensions::scaled.hsep_normal, rtl);
|
||||
|
||||
/* Draw list of companies */
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if ((HasBit(this->town->have_ratings, c->index) || this->town->exclusivity == c->index)) {
|
||||
DrawCompanyIcon(c->index, icon_left, text.top + icon_y_offset);
|
||||
DrawCompanyIcon(c->index, icon.left, text.top + icon_y_offset);
|
||||
|
||||
SetDParam(0, c->index);
|
||||
SetDParam(1, c->index);
|
||||
@@ -185,11 +190,11 @@ public:
|
||||
|
||||
SetDParam(2, str);
|
||||
if (this->town->exclusivity == c->index) {
|
||||
DrawSprite(SPR_EXCLUSIVE_TRANSPORT, COMPANY_SPRITE_COLOUR(c->index), exclusive_left, r.top + exclusive_y_offset);
|
||||
DrawSprite(SPR_EXCLUSIVE_TRANSPORT, COMPANY_SPRITE_COLOUR(c->index), exclusive.left, text.top + exclusive_y_offset);
|
||||
}
|
||||
|
||||
DrawString(text, STR_LOCAL_AUTHORITY_COMPANY_RATING);
|
||||
text.top += FONT_HEIGHT_NORMAL;
|
||||
DrawString(text.left, text.right, text.top + text_y_offset, STR_LOCAL_AUTHORITY_COMPANY_RATING);
|
||||
text.top += this->resize.step_height;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,8 +351,8 @@ public:
|
||||
break;
|
||||
|
||||
case WID_TA_RATING_INFO:
|
||||
resize->height = FONT_HEIGHT_NORMAL;
|
||||
size->height = 9 * FONT_HEIGHT_NORMAL + padding.height;
|
||||
resize->height = std::max({this->icon_size.height + WidgetDimensions::scaled.vsep_normal, this->exclusive_size.height + WidgetDimensions::scaled.vsep_normal, (uint)FONT_HEIGHT_NORMAL});
|
||||
size->height = 9 * resize->height + padding.height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1217,7 +1222,9 @@ static const NWidgetPart _nested_found_town_widgets[] = {
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_RANDOM_TOWN), SetMinimalSize(156, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_FOUND_TOWN_RANDOM_TOWN_BUTTON, STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP), SetPadding(0, 2, 1, 2),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_MANY_RANDOM_TOWNS), SetMinimalSize(156, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_FOUND_TOWN_MANY_RANDOM_TOWNS, STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP), SetPadding(0, 2, 0, 2),
|
||||
SetDataTip(STR_FOUND_TOWN_MANY_RANDOM_TOWNS, STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP), SetPadding(0, 2, 1, 2),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_EXPAND_ALL_TOWNS), SetMinimalSize(156, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_FOUND_TOWN_EXPAND_ALL_TOWNS, STR_FOUND_TOWN_EXPAND_ALL_TOWNS_TOOLTIP), SetPadding(0, 2, 0, 2),
|
||||
/* Town name selection. */
|
||||
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(156, 14), SetPadding(0, 2, 0, 2), SetDataTip(STR_FOUND_TOWN_NAME_TITLE, STR_NULL),
|
||||
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_TF_TOWN_NAME_EDITBOX), SetMinimalSize(156, 12), SetPadding(0, 2, 3, 2),
|
||||
@@ -1311,7 +1318,7 @@ public:
|
||||
void UpdateButtons(bool check_availability)
|
||||
{
|
||||
if (check_availability && _game_mode != GM_EDITOR) {
|
||||
this->SetWidgetsDisabledState(true, WID_TF_RANDOM_TOWN, WID_TF_MANY_RANDOM_TOWNS, WID_TF_SIZE_LARGE, WIDGET_LIST_END);
|
||||
this->SetWidgetsDisabledState(true, WID_TF_RANDOM_TOWN, WID_TF_MANY_RANDOM_TOWNS, WID_TF_EXPAND_ALL_TOWNS, WID_TF_SIZE_LARGE, WIDGET_LIST_END);
|
||||
this->SetWidgetsDisabledState(_settings_game.economy.found_town != TF_CUSTOM_LAYOUT,
|
||||
WID_TF_LAYOUT_ORIGINAL, WID_TF_LAYOUT_BETTER, WID_TF_LAYOUT_GRID2, WID_TF_LAYOUT_GRID3, WID_TF_LAYOUT_RANDOM, WIDGET_LIST_END);
|
||||
if (_settings_game.economy.found_town != TF_CUSTOM_LAYOUT) town_layout = _settings_game.economy.town_layout;
|
||||
@@ -1377,6 +1384,12 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_TF_EXPAND_ALL_TOWNS:
|
||||
for (Town *t : Town::Iterate()) {
|
||||
DoCommand(0, t->index, 0, DC_EXEC, CMD_EXPAND_TOWN);
|
||||
}
|
||||
break;
|
||||
|
||||
case WID_TF_SIZE_SMALL: case WID_TF_SIZE_MEDIUM: case WID_TF_SIZE_LARGE: case WID_TF_SIZE_RANDOM:
|
||||
this->town_size = (TownSize)(widget - WID_TF_SIZE_SMALL);
|
||||
this->UpdateButtons(false);
|
||||
|
Reference in New Issue
Block a user