mirror of https://github.com/OpenTTD/OpenTTD.git
Change: Use standard dimensions instead of custom widths.
This commit is contained in:
parent
9666e46739
commit
920e588334
|
@ -49,10 +49,6 @@
|
|||
|
||||
|
||||
/** Company GUI constants. */
|
||||
static const uint EXP_LINESPACE = 2; ///< Amount of vertical space for a horizontal (sub-)total line.
|
||||
static const uint EXP_BLOCKSPACE = 10; ///< Amount of vertical space between two blocks of numbers.
|
||||
static const int EXP_INDENT = 10; ///< Amount of horizontal space for an indented line.
|
||||
|
||||
static void DoSelectCompanyManagerFace(Window *parent);
|
||||
static void ShowCompanyInfrastructure(CompanyID company);
|
||||
|
||||
|
@ -122,15 +118,15 @@ static const ExpensesList _expenses_list_types[] = {
|
|||
static uint GetTotalCategoriesHeight()
|
||||
{
|
||||
/* There's an empty line and blockspace on the year row */
|
||||
uint total_height = FONT_HEIGHT_NORMAL + EXP_BLOCKSPACE;
|
||||
uint total_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
|
||||
|
||||
for (uint i = 0; i < lengthof(_expenses_list_types); i++) {
|
||||
/* Title + expense list + total line + total + blockspace after category */
|
||||
total_height += FONT_HEIGHT_NORMAL + _expenses_list_types[i].GetHeight() + EXP_LINESPACE + FONT_HEIGHT_NORMAL + EXP_BLOCKSPACE;
|
||||
total_height += FONT_HEIGHT_NORMAL + _expenses_list_types[i].GetHeight() + WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
|
||||
}
|
||||
|
||||
/* Total income */
|
||||
total_height += EXP_LINESPACE + FONT_HEIGHT_NORMAL + EXP_BLOCKSPACE;
|
||||
total_height += WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
|
||||
|
||||
return total_height;
|
||||
}
|
||||
|
@ -159,7 +155,7 @@ static uint GetMaxCategoriesWidth()
|
|||
*/
|
||||
static void DrawCategory(const Rect &r, int start_y, ExpensesList list)
|
||||
{
|
||||
Rect tr = r.Indent(EXP_INDENT, _current_text_dir == TD_RTL);
|
||||
Rect tr = r.Indent(WidgetDimensions::scaled.hsep_indent, _current_text_dir == TD_RTL);
|
||||
|
||||
tr.top = start_y;
|
||||
ExpensesType et;
|
||||
|
@ -179,7 +175,7 @@ static void DrawCategory(const Rect &r, int start_y, ExpensesList list)
|
|||
static void DrawCategories(const Rect &r)
|
||||
{
|
||||
/* Start with an empty space in the year row, plus the blockspace under the year. */
|
||||
int y = r.top + FONT_HEIGHT_NORMAL + EXP_BLOCKSPACE;
|
||||
int y = r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
|
||||
|
||||
for (uint i = 0; i < lengthof(_expenses_list_types); i++) {
|
||||
/* Draw category title and advance y */
|
||||
|
@ -191,14 +187,14 @@ static void DrawCategories(const Rect &r)
|
|||
y += _expenses_list_types[i].GetHeight();
|
||||
|
||||
/* Advance y by the height of the total and associated total line */
|
||||
y += EXP_LINESPACE + FONT_HEIGHT_NORMAL;
|
||||
y += WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL;
|
||||
|
||||
/* Advance y by a blockspace after this category block */
|
||||
y += EXP_BLOCKSPACE;
|
||||
y += WidgetDimensions::scaled.vsep_wide;
|
||||
}
|
||||
|
||||
/* Draw total profit/loss */
|
||||
y += EXP_LINESPACE;
|
||||
y += WidgetDimensions::scaled.vsep_normal;
|
||||
DrawString(r.left, r.right, y, STR_FINANCES_NET_PROFIT, TC_FROMSTRING, SA_LEFT);
|
||||
}
|
||||
|
||||
|
@ -243,7 +239,7 @@ static Money DrawYearCategory (const Rect &r, int start_y, ExpensesList list, co
|
|||
|
||||
/* Draw the total at the bottom of the category. */
|
||||
GfxFillRect(r.left, y, r.right, y, PC_BLACK);
|
||||
y += EXP_LINESPACE;
|
||||
y += WidgetDimensions::scaled.vsep_normal;
|
||||
if (sum != 0) DrawPrice(sum, r.left, r.right, y, TC_WHITE);
|
||||
|
||||
/* Return the sum for the yearly total. */
|
||||
|
@ -266,19 +262,19 @@ static void DrawYearColumn(const Rect &r, int year, const Money (*tbl)[EXPENSES_
|
|||
/* Year header */
|
||||
SetDParam(0, year);
|
||||
DrawString(r.left, r.right, y, STR_FINANCES_YEAR, TC_FROMSTRING, SA_RIGHT, true);
|
||||
y += FONT_HEIGHT_NORMAL + EXP_BLOCKSPACE;
|
||||
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
|
||||
|
||||
/* Categories */
|
||||
for (uint i = 0; i < lengthof(_expenses_list_types); i++) {
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
sum += DrawYearCategory(r, y, _expenses_list_types[i], tbl);
|
||||
/* Expense list + expense category title + expense category total + blockspace after category */
|
||||
y += _expenses_list_types[i].GetHeight() + EXP_LINESPACE + FONT_HEIGHT_NORMAL + EXP_BLOCKSPACE;
|
||||
y += _expenses_list_types[i].GetHeight() + WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_wide;
|
||||
}
|
||||
|
||||
/* Total income. */
|
||||
GfxFillRect(r.left, y, r.right, y, PC_BLACK);
|
||||
y += EXP_LINESPACE;
|
||||
y += WidgetDimensions::scaled.vsep_normal;
|
||||
DrawPrice(sum, r.left, r.right, y, TC_WHITE);
|
||||
}
|
||||
|
||||
|
@ -2002,7 +1998,7 @@ struct CompanyInfrastructureWindow : Window
|
|||
|
||||
/* Set height of the total line. */
|
||||
if (widget == WID_CI_TOTAL) {
|
||||
size->height = _settings_game.economy.infrastructure_maintenance ? std::max(size->height, EXP_LINESPACE + FONT_HEIGHT_NORMAL) : 0;
|
||||
size->height = _settings_game.economy.infrastructure_maintenance ? std::max<uint>(size->height, WidgetDimensions::scaled.vsep_normal + FONT_HEIGHT_NORMAL) : 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2108,7 +2104,7 @@ struct CompanyInfrastructureWindow : Window
|
|||
if (_settings_game.economy.infrastructure_maintenance) {
|
||||
Rect tr = r.WithWidth(this->total_width, _current_text_dir == TD_RTL);
|
||||
GfxFillRect(tr.left, y, tr.right, y, PC_WHITE);
|
||||
y += EXP_LINESPACE;
|
||||
y += WidgetDimensions::scaled.vsep_normal;
|
||||
SetDParam(0, this->GetTotalMaintenanceCost() * 12); // Convert to per year
|
||||
DrawString(tr.left, tr.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL, TC_FROMSTRING, SA_RIGHT);
|
||||
}
|
||||
|
|
|
@ -1507,8 +1507,6 @@ private:
|
|||
|
||||
std::map<uint, std::vector<std::unique_ptr<ButtonCommon>>> buttons; ///< Per line which buttons are available.
|
||||
|
||||
static const int CLIENT_OFFSET_LEFT = 12; ///< Offset of client entries compared to company entries.
|
||||
|
||||
/**
|
||||
* Chat button on a Company is clicked.
|
||||
* @param w The instance of this window.
|
||||
|
@ -1851,7 +1849,7 @@ public:
|
|||
uint text_right = matrix.right - (rtl ? d.width + WidgetDimensions::scaled.hsep_wide : 0);
|
||||
|
||||
Dimension d2 = GetSpriteSize(SPR_PLAYER_SELF);
|
||||
uint offset_x = CLIENT_OFFSET_LEFT - d2.width - ScaleGUITrad(3);
|
||||
uint offset_x = WidgetDimensions::scaled.hsep_indent - d2.width - ScaleGUITrad(3);
|
||||
|
||||
uint player_icon_x = rtl ? text_right - offset_x - d2.width : text_left + offset_x;
|
||||
|
||||
|
|
|
@ -728,7 +728,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
|||
switch (widget) {
|
||||
case WID_NS_FILE_LIST:
|
||||
{
|
||||
Dimension d = maxdim(GetSpriteSize(SPR_SQUARE), GetSpriteSize(SPR_WARNING_SIGN));
|
||||
Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN));
|
||||
resize->height = std::max<uint>(d.height + 2U, FONT_HEIGHT_NORMAL);
|
||||
size->height = std::max(size->height, padding.height + 6 * resize->height);
|
||||
break;
|
||||
|
@ -736,7 +736,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
|||
|
||||
case WID_NS_AVAIL_LIST:
|
||||
{
|
||||
Dimension d = maxdim(GetSpriteSize(SPR_SQUARE), GetSpriteSize(SPR_WARNING_SIGN));
|
||||
Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN));
|
||||
resize->height = std::max<uint>(d.height + 2U, FONT_HEIGHT_NORMAL);
|
||||
size->height = std::max(size->height, padding.height + 8 * resize->height);
|
||||
break;
|
||||
|
|
|
@ -1159,7 +1159,7 @@ struct MessageHistoryWindow : Window {
|
|||
/* Months are off-by-one, so it's actually 8. Not using
|
||||
* month 12 because the 1 is usually less wide. */
|
||||
SetDParam(0, ConvertYMDToDate(ORIGINAL_MAX_YEAR, 7, 30));
|
||||
this->date_width = GetStringBoundingBox(STR_SHORT_DATE).width + ScaleGUITrad(5);
|
||||
this->date_width = GetStringBoundingBox(STR_SHORT_DATE).width + WidgetDimensions::scaled.hsep_wide;
|
||||
|
||||
size->height = 4 * resize->height + WidgetDimensions::scaled.framerect.Vertical(); // At least 4 lines are visible.
|
||||
size->width = std::max(200u, size->width); // At least 200 pixels wide.
|
||||
|
|
|
@ -789,7 +789,6 @@ void ShowGameOptions()
|
|||
}
|
||||
|
||||
static int SETTING_HEIGHT = 11; ///< Height of a single setting in the tree view in pixels
|
||||
static const int LEVEL_WIDTH = 15; ///< Indenting width of a sub-page in pixels
|
||||
|
||||
/**
|
||||
* Flags for #SettingEntry
|
||||
|
|
|
@ -1227,7 +1227,7 @@ void SmallMapWindow::RebuildColourIndexIfNecessary()
|
|||
bool rtl = _current_text_dir == TD_RTL;
|
||||
uint i = 0; // Row counter for industry legend.
|
||||
uint row_height = FONT_HEIGHT_SMALL;
|
||||
int padding = ScaleGUITrad(1);
|
||||
int padding = WidgetDimensions::scaled.hsep_normal;
|
||||
|
||||
Rect origin = r.WithWidth(this->column_width, rtl).Shrink(WidgetDimensions::scaled.framerect).WithHeight(row_height);
|
||||
Rect text = origin.Indent(this->legend_width + WidgetDimensions::scaled.hsep_normal, rtl);
|
||||
|
|
|
@ -1762,7 +1762,7 @@ struct StationViewWindow : public Window {
|
|||
}
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
Rect text = r.Indent(column * this->expand_shrink_width, rtl).Indent(this->expand_shrink_width, !rtl);
|
||||
Rect text = r.Indent(column * WidgetDimensions::scaled.hsep_indent, rtl).Indent(this->expand_shrink_width, !rtl);
|
||||
Rect shrink = r.WithWidth(this->expand_shrink_width, !rtl);
|
||||
|
||||
DrawString(text.left, text.right, y, str);
|
||||
|
@ -1840,7 +1840,7 @@ struct StationViewWindow : public Window {
|
|||
SetDParam(1, lg != nullptr ? lg->Monthly((*lg)[ge->node].Supply()) : 0);
|
||||
SetDParam(2, STR_CARGO_RATING_APPALLING + (ge->rating >> 5));
|
||||
SetDParam(3, ToPercent8(ge->rating));
|
||||
DrawString(tr.Indent(6, rtl), STR_STATION_VIEW_CARGO_SUPPLY_RATING);
|
||||
DrawString(tr.Indent(WidgetDimensions::scaled.hsep_indent, rtl), STR_STATION_VIEW_CARGO_SUPPLY_RATING);
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
}
|
||||
return CeilDiv(tr.top - r.top - WidgetDimensions::scaled.framerect.top, FONT_HEIGHT_NORMAL);
|
||||
|
|
|
@ -182,7 +182,6 @@ struct CargoSummaryItem {
|
|||
|
||||
static const uint TRAIN_DETAILS_MIN_INDENT = 32; ///< Minimum indent level in the train details window
|
||||
static const uint TRAIN_DETAILS_MAX_INDENT = 72; ///< Maximum indent level in the train details window; wider than this and we start on a new line
|
||||
static const int TRAIN_DETAILS_LIST_INDENT = 10; ///< Indent for list items in the Total Cargo window
|
||||
|
||||
/** Container for the cargo summary information. */
|
||||
typedef std::vector<CargoSummaryItem> CargoSummary;
|
||||
|
@ -454,7 +453,7 @@ void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16 vsc
|
|||
y += line_height;
|
||||
|
||||
/* Indent the total cargo capacity details */
|
||||
Rect ir = r.Indent(TRAIN_DETAILS_LIST_INDENT, rtl);
|
||||
Rect ir = r.Indent(WidgetDimensions::scaled.hsep_indent, rtl);
|
||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||
if (max_cargo[i] > 0 && --vscroll_pos < 0 && vscroll_pos > -vscroll_cap) {
|
||||
SetDParam(0, i); // {CARGO} #1
|
||||
|
|
Loading…
Reference in New Issue