Merge commit '13.0-RC1~2'
This commit is contained in:
@@ -19,6 +19,7 @@ add_files(
|
||||
error_widget.h
|
||||
fios_widget.h
|
||||
framerate_widget.h
|
||||
game_widget.h
|
||||
genworld_widget.h
|
||||
goal_widget.h
|
||||
graph_widget.h
|
||||
@@ -26,6 +27,7 @@ add_files(
|
||||
highscore_widget.h
|
||||
industry_widget.h
|
||||
intro_widget.h
|
||||
league_widget.h
|
||||
link_graph_legend_widget.h
|
||||
main_widget.h
|
||||
misc_widget.h
|
||||
|
||||
@@ -38,7 +38,6 @@ enum AIConfigWidgets {
|
||||
WID_AIC_DECREASE, ///< Decrease the number of AIs.
|
||||
WID_AIC_INCREASE, ///< Increase the number of AIs.
|
||||
WID_AIC_NUMBER, ///< Number of AIs.
|
||||
WID_AIC_GAMELIST, ///< List with current selected GameScript.
|
||||
WID_AIC_LIST, ///< List with currently selected AIs.
|
||||
WID_AIC_SCROLLBAR, ///< Scrollbar to scroll through the selected AIs.
|
||||
WID_AIC_MOVE_UP, ///< Move up button.
|
||||
|
||||
@@ -30,6 +30,7 @@ enum AirportPickerWidgets {
|
||||
WID_AP_COVERAGE_LABEL, ///< Label if you want to see the coverage.
|
||||
WID_AP_BTN_DONTHILIGHT, ///< Don't show the coverage button.
|
||||
WID_AP_BTN_DOHILIGHT, ///< Show the coverage button.
|
||||
WID_AP_ACCEPTANCE, ///< Acceptance info.
|
||||
};
|
||||
|
||||
#endif /* WIDGETS_AIRPORT_WIDGET_H */
|
||||
|
||||
@@ -68,9 +68,9 @@ enum CompanyFinancesWidgets {
|
||||
WID_CF_SEL_MAXLOAN, ///< Selection of maxloan column.
|
||||
WID_CF_BALANCE_VALUE, ///< Bank balance value.
|
||||
WID_CF_LOAN_VALUE, ///< Loan.
|
||||
WID_CF_LOAN_LINE, ///< Line for summing bank balance and loan.
|
||||
WID_CF_TOTAL_VALUE, ///< Total.
|
||||
WID_CF_MAXLOAN_GAP, ///< Gap above max loan widget.
|
||||
WID_CF_BALANCE_LINE, ///< Available cash.
|
||||
WID_CF_OWN_VALUE, ///< Own funds, not including loan.
|
||||
WID_CF_INTEREST_RATE, ///< Loan interest rate.
|
||||
WID_CF_MAXLOAN_VALUE, ///< Max loan widget.
|
||||
WID_CF_SEL_BUTTONS, ///< Selection of buttons.
|
||||
WID_CF_INCREASE_LOAN, ///< Increase loan.
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "../strings_func.h"
|
||||
#include "../window_func.h"
|
||||
#include "../guitimer_func.h"
|
||||
#include "../zoom_func.h"
|
||||
#include "dropdown_type.h"
|
||||
|
||||
#include "dropdown_widget.h"
|
||||
@@ -20,26 +21,27 @@
|
||||
#include "../safeguards.h"
|
||||
|
||||
|
||||
void DropDownListItem::Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const
|
||||
void DropDownListItem::Draw(const Rect &r, bool sel, Colours bg_colour) const
|
||||
{
|
||||
int c1 = _colour_gradient[bg_colour][3];
|
||||
int c2 = _colour_gradient[bg_colour][7];
|
||||
|
||||
int mid = top + this->Height(0) / 2;
|
||||
GfxFillRect(left + 1, mid - 2, right - 1, mid - 2, c1);
|
||||
GfxFillRect(left + 1, mid - 1, right - 1, mid - 1, c2);
|
||||
int mid = CenterBounds(r.top, r.bottom, 0);
|
||||
GfxFillRect(r.left, mid - WidgetDimensions::scaled.bevel.bottom, r.right, mid - 1, c1);
|
||||
GfxFillRect(r.left, mid, r.right, mid + WidgetDimensions::scaled.bevel.top - 1, c2);
|
||||
}
|
||||
|
||||
uint DropDownListStringItem::Width() const
|
||||
{
|
||||
char buffer[512];
|
||||
GetString(buffer, this->String(), lastof(buffer));
|
||||
return GetStringBoundingBox(buffer).width;
|
||||
return GetStringBoundingBox(buffer).width + WidgetDimensions::scaled.dropdowntext.Horizontal();
|
||||
}
|
||||
|
||||
void DropDownListStringItem::Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const
|
||||
void DropDownListStringItem::Draw(const Rect &r, bool sel, Colours bg_colour) const
|
||||
{
|
||||
DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, Center(top, bottom - top), this->String(), sel ? TC_WHITE : TC_BLACK);
|
||||
Rect ir = r.Shrink(WidgetDimensions::scaled.dropdowntext);
|
||||
DrawString(ir.left, ir.right, r.top, this->String(), sel ? TC_WHITE : TC_BLACK);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,19 +79,21 @@ DropDownListIconItem::DropDownListIconItem(SpriteID sprite, PaletteID pal, Strin
|
||||
|
||||
uint DropDownListIconItem::Height(uint width) const
|
||||
{
|
||||
return std::max(this->dim.height, DropDownListParamStringItem::Height(width));
|
||||
return std::max(this->dim.height, (uint)FONT_HEIGHT_NORMAL);
|
||||
}
|
||||
|
||||
uint DropDownListIconItem::Width() const
|
||||
{
|
||||
return DropDownListStringItem::Width() + this->dim.width + WD_FRAMERECT_LEFT;
|
||||
return DropDownListParamStringItem::Width() + this->dim.width + WidgetDimensions::scaled.hsep_wide;
|
||||
}
|
||||
|
||||
void DropDownListIconItem::Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const
|
||||
void DropDownListIconItem::Draw(const Rect &r, bool sel, Colours bg_colour) const
|
||||
{
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
DrawSprite(this->sprite, this->pal, rtl ? right - this->dim.width - WD_FRAMERECT_RIGHT : left + WD_FRAMERECT_LEFT, CenterBounds(top, bottom, this->sprite_y));
|
||||
DrawString(left + WD_FRAMERECT_LEFT + (rtl ? 0 : (this->dim.width + WD_FRAMERECT_LEFT)), right - WD_FRAMERECT_RIGHT - (rtl ? (this->dim.width + WD_FRAMERECT_RIGHT) : 0), CenterBounds(top, bottom, FONT_HEIGHT_NORMAL), this->String(), sel ? TC_WHITE : TC_BLACK);
|
||||
Rect ir = r.Shrink(WidgetDimensions::scaled.dropdowntext);
|
||||
Rect tr = ir.Indent(this->dim.width + WidgetDimensions::scaled.hsep_normal, rtl);
|
||||
DrawSprite(this->sprite, this->pal, ir.WithWidth(this->dim.width, rtl).left, CenterBounds(r.top, r.bottom, this->sprite_y));
|
||||
DrawString(tr.left, tr.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL), this->String(), sel ? TC_WHITE : TC_BLACK);
|
||||
}
|
||||
|
||||
void DropDownListIconItem::SetDimension(Dimension d)
|
||||
@@ -156,7 +160,7 @@ struct DropdownWindow : Window {
|
||||
|
||||
uint items_width = size.width - (scroll ? NWidgetScrollbar::GetVerticalDimension().width : 0);
|
||||
NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_DM_ITEMS);
|
||||
nwi->SetMinimalSizeAbsolute(items_width, size.height + 4);
|
||||
nwi->SetMinimalSizeAbsolute(items_width, size.height + WidgetDimensions::scaled.fullbevel.Vertical() * 2);
|
||||
nwi->colour = wi_colour;
|
||||
|
||||
nwi = this->GetWidget<NWidgetCore>(WID_DM_SCROLL);
|
||||
@@ -226,9 +230,9 @@ struct DropdownWindow : Window {
|
||||
{
|
||||
if (GetWidgetFromPos(this, _cursor.pos.x - this->left, _cursor.pos.y - this->top) < 0) return false;
|
||||
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_DM_ITEMS);
|
||||
int y = _cursor.pos.y - this->top - nwi->pos_y - 2;
|
||||
int width = nwi->current_x - 4;
|
||||
const Rect &r = this->GetWidget<NWidgetBase>(WID_DM_ITEMS)->GetCurrentRect().Shrink(WidgetDimensions::scaled.fullbevel);
|
||||
int y = _cursor.pos.y - this->top - r.top - WidgetDimensions::scaled.fullbevel.top;
|
||||
int width = r.Width();
|
||||
int pos = this->vscroll->GetPosition();
|
||||
|
||||
for (const auto &item : this->list) {
|
||||
@@ -255,22 +259,23 @@ struct DropdownWindow : Window {
|
||||
|
||||
Colours colour = this->GetWidget<NWidgetCore>(widget)->colour;
|
||||
|
||||
int y = r.top + 2;
|
||||
Rect ir = r.Shrink(WidgetDimensions::scaled.fullbevel).Shrink(RectPadding::zero, WidgetDimensions::scaled.fullbevel);
|
||||
int y = ir.top;
|
||||
int pos = this->vscroll->GetPosition();
|
||||
for (const auto &item : this->list) {
|
||||
int item_height = item->Height(r.right - r.left + 1);
|
||||
int item_height = item->Height(ir.Width());
|
||||
|
||||
/* Skip items that are scrolled up */
|
||||
if (--pos >= 0) continue;
|
||||
|
||||
if (y + item_height < r.bottom) {
|
||||
if (y + item_height - 1 <= ir.bottom) {
|
||||
bool selected = (this->selected_index == item->result);
|
||||
if (selected) GfxFillRect(r.left + 2, y, r.right - 1, y + item_height - 1, PC_BLACK);
|
||||
if (selected) GfxFillRect(ir.left, y, ir.right, y + item_height - 1, PC_BLACK);
|
||||
|
||||
item->Draw(r.left, r.right, y, y + item_height, selected, colour);
|
||||
item->Draw({ir.left, y, ir.right, y + item_height - 1}, selected, colour);
|
||||
|
||||
if (item->masked) {
|
||||
GfxFillRect(r.left + 1, y, r.right - 1, y + item_height - 1, _colour_gradient[colour][5], FILLRECT_CHECKER);
|
||||
GfxFillRect(ir.left, y, ir.right, y + item_height - 1, _colour_gradient[colour][5], FILLRECT_CHECKER);
|
||||
}
|
||||
}
|
||||
y += item_height;
|
||||
@@ -414,7 +419,7 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button
|
||||
int top = w->top + wi_rect.bottom + 1;
|
||||
|
||||
/* The preferred width equals the calling widget */
|
||||
uint width = wi_rect.right - wi_rect.left + 1;
|
||||
uint width = wi_rect.Width();
|
||||
|
||||
/* Longest item in the list, if auto_width is enabled */
|
||||
uint max_item_width = 0;
|
||||
@@ -424,9 +429,11 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button
|
||||
|
||||
for (const auto &item : list) {
|
||||
height += item->Height(width);
|
||||
if (auto_width) max_item_width = std::max(max_item_width, item->Width() + 5);
|
||||
if (auto_width) max_item_width = std::max(max_item_width, item->Width());
|
||||
}
|
||||
|
||||
if (auto_width) max_item_width += WidgetDimensions::scaled.fullbevel.Horizontal();
|
||||
|
||||
/* Scrollbar needed? */
|
||||
bool scroll = false;
|
||||
|
||||
@@ -434,12 +441,12 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button
|
||||
bool above = false;
|
||||
|
||||
/* Available height below (or above, if the dropdown is placed above the widget). */
|
||||
uint available_height = std::max(_screen.height - top - 4, 0);
|
||||
uint available_height = std::max(GetMainViewBottom() - top - (int)WidgetDimensions::scaled.fullbevel.Vertical() * 2, 0);
|
||||
|
||||
/* If the dropdown doesn't fully fit below the widget... */
|
||||
if (height > available_height) {
|
||||
|
||||
uint available_height_above = std::max(w->top + wi_rect.top - GetMainViewTop() - 4, 0);
|
||||
uint available_height_above = std::max(w->top + wi_rect.top - GetMainViewTop() - (int)WidgetDimensions::scaled.fullbevel.Vertical() * 2, 0);
|
||||
|
||||
/* Put the dropdown above if there is more available space. */
|
||||
if (available_height_above > available_height) {
|
||||
@@ -465,7 +472,7 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button
|
||||
|
||||
/* Set the top position if needed. */
|
||||
if (above) {
|
||||
top = w->top + wi_rect.top - height - 4;
|
||||
top = w->top + wi_rect.top - height - WidgetDimensions::scaled.fullbevel.Vertical() * 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,9 +518,9 @@ void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button,
|
||||
|
||||
if (width != 0) {
|
||||
if (_current_text_dir == TD_RTL) {
|
||||
wi_rect.left = wi_rect.right + 1 - width;
|
||||
wi_rect.left = wi_rect.right + 1 - ScaleGUITrad(width);
|
||||
} else {
|
||||
wi_rect.right = wi_rect.left + width - 1;
|
||||
wi_rect.right = wi_rect.left + ScaleGUITrad(width) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
virtual bool Selectable() const { return false; }
|
||||
virtual uint Height(uint width) const { return GetMinButtonSize(FONT_HEIGHT_NORMAL); }
|
||||
virtual uint Width() const { return 0; }
|
||||
virtual void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const;
|
||||
virtual void Draw(const Rect &r, bool sel, Colours bg_colour) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
|
||||
bool Selectable() const override { return true; }
|
||||
uint Width() const override;
|
||||
void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const override;
|
||||
void Draw(const Rect &r, bool sel, Colours bg_colour) const override;
|
||||
virtual StringID String() const { return this->string; }
|
||||
|
||||
static bool NatSortFunc(std::unique_ptr<const DropDownListItem> const &first, std::unique_ptr<const DropDownListItem> const &second);
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
|
||||
uint Height(uint width) const override;
|
||||
uint Width() const override;
|
||||
void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const override;
|
||||
void Draw(const Rect &r, bool sel, Colours bg_colour) const override;
|
||||
void SetDimension(Dimension d);
|
||||
};
|
||||
|
||||
|
||||
28
src/widgets/game_widget.h
Normal file
28
src/widgets/game_widget.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file ai_widget.h Types related to the ai widgets. */
|
||||
|
||||
#ifndef WIDGETS_GS_WIDGET_H
|
||||
#define WIDGETS_GS_WIDGET_H
|
||||
|
||||
#include "../textfile_type.h"
|
||||
|
||||
/** Widgets of the #GSConfigWindow class. */
|
||||
enum GSConfigWidgets {
|
||||
WID_GSC_BACKGROUND, ///< Window background.
|
||||
WID_GSC_GSLIST, ///< List with current selected Game Script.
|
||||
WID_GSC_SETTINGS, ///< Panel to draw the Game Script settings on
|
||||
WID_GSC_SCROLLBAR, ///< Scrollbar to scroll through the selected AIs.
|
||||
WID_GSC_CHANGE, ///< Select another Game Script button.
|
||||
WID_GSC_TEXTFILE, ///< Open GS readme, changelog (+1) or license (+2).
|
||||
WID_GSC_CONTENT_DOWNLOAD = WID_GSC_TEXTFILE + TFT_END, ///< Download content button.
|
||||
WID_GSC_ACCEPT, ///< Accept ("Close") button
|
||||
WID_GSC_RESET, ///< Reset button.
|
||||
};
|
||||
|
||||
#endif /* WIDGETS_GS_WIDGET_H */
|
||||
@@ -60,6 +60,10 @@ enum GenerateLandscapeWidgets {
|
||||
WID_GL_WATER_SE, ///< SE 'Water'/'Freeform'.
|
||||
WID_GL_WATER_SW, ///< SW 'Water'/'Freeform'.
|
||||
|
||||
WID_GL_AI_BUTTON, ///< 'AI Settings' button.
|
||||
WID_GL_GS_BUTTON, ///< 'Game Script Settings' button.
|
||||
WID_GL_NEWGRF_BUTTON, ///< 'NewGRF Settings' button.
|
||||
|
||||
WID_GL_CLIMATE_SEL_LABEL, ///< NWID_SELECTION for snow or desert coverage label
|
||||
WID_GL_CLIMATE_SEL_SELECTOR, ///< NWID_SELECTION for snow or desert coverage selector
|
||||
};
|
||||
|
||||
@@ -51,11 +51,6 @@ enum CargoPaymentRatesWidgets {
|
||||
WID_CPR_MATRIX_SCROLLBAR,///< Cargo list scrollbar.
|
||||
};
|
||||
|
||||
/** Widget of the #CompanyLeagueWindow class. */
|
||||
enum CompanyLeagueWidgets {
|
||||
WID_CL_BACKGROUND, ///< Background of the window.
|
||||
};
|
||||
|
||||
/** Widget of the #PerformanceRatingDetailWindow class. */
|
||||
enum PerformanceRatingDetailsWidgets {
|
||||
WID_PRD_SCORE_FIRST, ///< First entry in the score list.
|
||||
|
||||
@@ -17,6 +17,7 @@ enum GroupListWidgets {
|
||||
WID_GL_GROUP_BY_DROPDOWN, ///< Group by dropdown list.
|
||||
WID_GL_SORT_BY_ORDER, ///< Sort order.
|
||||
WID_GL_SORT_BY_DROPDOWN, ///< Sort by dropdown list.
|
||||
WID_GL_FILTER_BY_CARGO, ///< Filter vehicles by cargo type.
|
||||
WID_GL_LIST_VEHICLE, ///< List of the vehicles.
|
||||
WID_GL_LIST_VEHICLE_SCROLLBAR, ///< Scrollbar for the list.
|
||||
WID_GL_AVAILABLE_VEHICLES, ///< Available vehicles.
|
||||
|
||||
@@ -32,6 +32,7 @@ enum SelectGameIntroWidgets {
|
||||
WID_SGI_GRF_SETTINGS, ///< NewGRF button.
|
||||
WID_SGI_CONTENT_DOWNLOAD, ///< Content Download button.
|
||||
WID_SGI_AI_SETTINGS, ///< AI button.
|
||||
WID_SGI_GS_SETTINGS, ///< Game Script button.
|
||||
WID_SGI_TUTORIAL, ///< Tutorial button.
|
||||
WID_SGI_EXIT, ///< Exit button.
|
||||
};
|
||||
|
||||
24
src/widgets/league_widget.h
Normal file
24
src/widgets/league_widget.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file league_widget.h Types related to the graph widgets. */
|
||||
|
||||
#ifndef WIDGETS_LEAGUE_WIDGET_H
|
||||
#define WIDGETS_LEAGUE_WIDGET_H
|
||||
|
||||
/** Widget of the #PerformanceLeagueWindow class. */
|
||||
enum PerformanceLeagueWidgets {
|
||||
WID_PLT_BACKGROUND, ///< Background of the window.
|
||||
};
|
||||
|
||||
/** Widget of the #ScriptLeagueWindow class. */
|
||||
enum ScriptLeagueWidgets {
|
||||
WID_SLT_CAPTION, ///< Caption of the window.
|
||||
WID_SLT_BACKGROUND, ///< Background of the window.
|
||||
};
|
||||
|
||||
#endif /* WIDGETS_LEAGUE_WIDGET_H */
|
||||
@@ -14,8 +14,9 @@
|
||||
|
||||
/** Widgets of the #NetworkContentDownloadStatusWindow class. */
|
||||
enum NetworkContentDownloadStatusWidgets {
|
||||
WID_NCDS_BACKGROUND, ///< Background of the window.
|
||||
WID_NCDS_CANCELOK, ///< (Optional) Cancel/OK button.
|
||||
WID_NCDS_PROGRESS_BAR, ///< Simple progress bar.
|
||||
WID_NCDS_PROGRESS_TEXT, ///< Text explaining what is happening.
|
||||
WID_NCDS_CANCELOK, ///< (Optional) Cancel/OK button.
|
||||
};
|
||||
|
||||
/** Widgets of the #NetworkContentListWindow class. */
|
||||
|
||||
@@ -95,8 +95,9 @@ enum ClientListWidgets {
|
||||
|
||||
/** Widgets of the #NetworkJoinStatusWindow class. */
|
||||
enum NetworkJoinStatusWidgets {
|
||||
WID_NJS_BACKGROUND, ///< Background of the window.
|
||||
WID_NJS_CANCELOK, ///< Cancel / OK button.
|
||||
WID_NJS_PROGRESS_BAR, ///< Simple progress bar.
|
||||
WID_NJS_PROGRESS_TEXT, ///< Text explaining what is happening.
|
||||
WID_NJS_CANCELOK, ///< Cancel / OK button.
|
||||
};
|
||||
|
||||
/** Widgets of the #NetworkCompanyPasswordWindow class. */
|
||||
|
||||
@@ -38,6 +38,8 @@ enum SpriteAlignerWidgets {
|
||||
WID_SA_LIST, ///< Queried sprite list.
|
||||
WID_SA_SCROLLBAR, ///< Scrollbar for sprite list.
|
||||
WID_SA_RESET_REL, ///< Reset relative sprite offset
|
||||
WID_SA_CENTRE, ///< Toggle centre sprite.
|
||||
WID_SA_CROSSHAIR, ///< Toggle crosshair.
|
||||
};
|
||||
|
||||
#endif /* WIDGETS_NEWGRF_DEBUG_WIDGET_H */
|
||||
|
||||
@@ -51,7 +51,8 @@ enum BuildRoadStationWidgets {
|
||||
WID_BROS_STATION_Y, ///< Drive-through station in y-direction.
|
||||
WID_BROS_LT_OFF, ///< Turn off area highlight.
|
||||
WID_BROS_LT_ON, ///< Turn on area highlight.
|
||||
WID_BROS_INFO, ///< Station acceptance info.
|
||||
WID_BROS_INFO, ///< Station acceptance toggle.
|
||||
WID_BROS_ACCEPTANCE, ///< Station acceptance.
|
||||
};
|
||||
|
||||
#endif /* WIDGETS_ROAD_WIDGET_H */
|
||||
|
||||
@@ -25,7 +25,9 @@ enum GameOptionsWidgets {
|
||||
WID_GO_BUILD_CONFIRMATION, ///< Enable build confirmation dialog.
|
||||
WID_GO_WINDOWS_TITLEBARS, ///< Titlebars for all windows.
|
||||
WID_GO_MOUSE_CURSOR, ///< Show mouse cursor.
|
||||
WID_GO_GUI_ZOOM_DROPDOWN, ///< Dropdown for the GUI zoom level.
|
||||
WID_GO_GUI_SCALE, ///< GUI Scale slider.
|
||||
WID_GO_GUI_SCALE_AUTO, ///< Autodetect GUI scale button.
|
||||
WID_GO_GUI_SCALE_BEVEL_BUTTON, ///< Toggle for chunky bevels.
|
||||
WID_GO_BASE_GRF_DROPDOWN, ///< Use to select a base GRF.
|
||||
WID_GO_BASE_GRF_STATUS, ///< Info about missing files etc.
|
||||
WID_GO_BASE_GRF_TEXTFILE, ///< Open base GRF readme, changelog (+1) or license (+2).
|
||||
@@ -36,13 +38,14 @@ enum GameOptionsWidgets {
|
||||
WID_GO_BASE_SFX_DESCRIPTION = WID_GO_BASE_SFX_TEXTFILE + TFT_END, ///< Description of selected base SFX.
|
||||
WID_GO_BASE_MUSIC_DROPDOWN, ///< Use to select a base music set.
|
||||
WID_GO_BASE_MUSIC_VOLUME, ///< Change music volume.
|
||||
WID_GO_BASE_MUSIC_JUKEBOX, ///< Open the jukebox.
|
||||
WID_GO_BASE_MUSIC_STATUS, ///< Info about corrupted files etc.
|
||||
WID_GO_BASE_MUSIC_TEXTFILE, ///< Open base music readme, changelog (+1) or license (+2).
|
||||
WID_GO_BASE_MUSIC_DESCRIPTION = WID_GO_BASE_MUSIC_TEXTFILE + TFT_END, ///< Description of selected base music set.
|
||||
WID_GO_FONT_ZOOM_DROPDOWN, ///< Dropdown for the font zoom level.
|
||||
WID_GO_VIDEO_ACCEL_BUTTON, ///< Toggle for video acceleration.
|
||||
WID_GO_VIDEO_VSYNC_BUTTON, ///< Toggle for video vsync.
|
||||
WID_GO_REFRESH_RATE_DROPDOWN, ///< Dropdown for all available refresh rates.
|
||||
WID_GO_VIDEO_DRIVER_INFO, ///< Label showing details about the current video driver.
|
||||
};
|
||||
|
||||
/** Widgets of the #GameSettingsWindow class. */
|
||||
|
||||
@@ -19,47 +19,74 @@
|
||||
static const int SLIDER_WIDTH = 3;
|
||||
|
||||
/**
|
||||
* Draw a volume slider widget with know at given value
|
||||
* @param r Rectangle to draw the widget in
|
||||
* Draw a slider widget with knob at given value
|
||||
* @param r Rectangle to draw the widget in
|
||||
* @param min_value Minimum value of slider
|
||||
* @param max_value Maximum value of slider
|
||||
* @param value Value to put the slider at
|
||||
* @param labels List of positions and labels to draw along the slider.
|
||||
*/
|
||||
void DrawVolumeSliderWidget(Rect r, byte value)
|
||||
void DrawSliderWidget(Rect r, int min_value, int max_value, int value, const std::map<int, StringID> &labels)
|
||||
{
|
||||
/* Draw a wedge indicating low to high volume level. */
|
||||
/* Allow space for labels. We assume they are in the small font. */
|
||||
if (labels.size() > 0) r.bottom -= FONT_HEIGHT_SMALL + WidgetDimensions::scaled.hsep_normal;
|
||||
|
||||
max_value -= min_value;
|
||||
|
||||
/* Draw a wedge indicating low to high value. */
|
||||
const int ha = (r.bottom - r.top) / 5;
|
||||
int wx1 = r.left, wx2 = r.right;
|
||||
const int sw = ScaleGUITrad(SLIDER_WIDTH);
|
||||
const int t = WidgetDimensions::scaled.bevel.top; /* Thickness of lines */
|
||||
int wx1 = r.left + sw / 2;
|
||||
int wx2 = r.right - sw / 2;
|
||||
if (_current_text_dir == TD_RTL) std::swap(wx1, wx2);
|
||||
const uint shadow = _colour_gradient[COLOUR_GREY][3];
|
||||
const uint fill = _colour_gradient[COLOUR_GREY][6];
|
||||
const uint light = _colour_gradient[COLOUR_GREY][7];
|
||||
const std::vector<Point> wedge{ Point{wx1, r.bottom - ha}, Point{wx2, r.top + ha}, Point{wx2, r.bottom - ha} };
|
||||
GfxFillPolygon(wedge, fill);
|
||||
GfxDrawLine(wedge[0].x, wedge[0].y, wedge[2].x, wedge[2].y, light);
|
||||
GfxDrawLine(wedge[1].x, wedge[1].y, wedge[2].x, wedge[2].y, _current_text_dir == TD_RTL ? shadow : light);
|
||||
GfxDrawLine(wedge[0].x, wedge[0].y, wedge[1].x, wedge[1].y, shadow);
|
||||
GfxDrawLine(wedge[0].x, wedge[0].y, wedge[2].x, wedge[2].y, light, t);
|
||||
GfxDrawLine(wedge[1].x, wedge[1].y, wedge[2].x, wedge[2].y, _current_text_dir == TD_RTL ? shadow : light, t);
|
||||
GfxDrawLine(wedge[0].x, wedge[0].y, wedge[1].x, wedge[1].y, shadow, t);
|
||||
|
||||
/* Draw a slider handle indicating current volume level. */
|
||||
const int sw = ScaleGUITrad(SLIDER_WIDTH);
|
||||
if (_current_text_dir == TD_RTL) value = 127 - value;
|
||||
const int x = r.left + (value * (r.right - r.left - sw) / 127);
|
||||
int x;
|
||||
for (auto label : labels) {
|
||||
x = label.first - min_value;
|
||||
if (_current_text_dir == TD_RTL) x = max_value - x;
|
||||
x = r.left + (x * (r.right - r.left - sw) / max_value) + sw / 2;
|
||||
GfxDrawLine(x, r.bottom - ha + 1, x, r.bottom + (label.second == STR_NULL ? 0 : WidgetDimensions::scaled.hsep_normal), shadow, t);
|
||||
if (label.second != STR_NULL) {
|
||||
Dimension d = GetStringBoundingBox(label.second, FS_SMALL);
|
||||
x = Clamp(x - d.width / 2, r.left, r.right - d.width);
|
||||
DrawString(x, x + d.width, r.bottom + 1 + WidgetDimensions::scaled.hsep_normal, label.second, TC_BLACK, SA_CENTER, false, FS_SMALL);
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw a slider handle indicating current value. */
|
||||
value -= min_value;
|
||||
if (_current_text_dir == TD_RTL) value = max_value - value;
|
||||
x = r.left + (value * (r.right - r.left - sw) / max_value);
|
||||
DrawFrameRect(x, r.top, x + sw, r.bottom, COLOUR_GREY, FR_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle click on a volume slider widget to change the value
|
||||
* Handle click on a slider widget to change the value
|
||||
* @param r Rectangle of the widget
|
||||
* @param pt Clicked point
|
||||
* @param value[in,out] Volume value to modify
|
||||
* @return True if the volume setting was modified
|
||||
* @param value[in,out] Value to modify
|
||||
* @return True if the value setting was modified
|
||||
*/
|
||||
bool ClickVolumeSliderWidget(Rect r, Point pt, byte &value)
|
||||
bool ClickSliderWidget(Rect r, Point pt, int min_value, int max_value, int &value)
|
||||
{
|
||||
const int sw = ScaleGUITrad(SLIDER_WIDTH);
|
||||
byte new_vol = Clamp((pt.x - r.left - sw / 2) * 127 / (r.right - r.left - sw), 0, 127);
|
||||
if (_current_text_dir == TD_RTL) new_vol = 127 - new_vol;
|
||||
max_value -= min_value;
|
||||
|
||||
if (new_vol != value) {
|
||||
value = new_vol;
|
||||
const int sw = ScaleGUITrad(SLIDER_WIDTH);
|
||||
int new_value = Clamp((pt.x - r.left - sw / 2) * max_value / (r.right - r.left - sw), 0, max_value);
|
||||
if (_current_text_dir == TD_RTL) new_value = max_value - new_value;
|
||||
new_value += min_value;
|
||||
|
||||
if (new_value != value) {
|
||||
value = new_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,17 @@
|
||||
#include "../window_type.h"
|
||||
#include "../gfx_func.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
void DrawVolumeSliderWidget(Rect r, byte value);
|
||||
bool ClickVolumeSliderWidget(Rect r, Point pt, byte &value);
|
||||
void DrawSliderWidget(Rect r, int min_value, int max_value, int value, const std::map<int, StringID> &labels);
|
||||
bool ClickSliderWidget(Rect r, Point pt, int min_value, int max_value, int &value);
|
||||
|
||||
inline bool ClickSliderWidget(Rect r, Point pt, int min_value, int max_value, byte &value)
|
||||
{
|
||||
int tmp_value = value;
|
||||
if (!ClickSliderWidget(r, pt, min_value, max_value, tmp_value)) return false;
|
||||
value = tmp_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /* WIDGETS_SLIDER_TYPE_H */
|
||||
|
||||
@@ -49,6 +49,7 @@ enum TownFoundingWidgets {
|
||||
WID_TF_NEW_TOWN, ///< Create a new town.
|
||||
WID_TF_RANDOM_TOWN, ///< Randomly place a town.
|
||||
WID_TF_MANY_RANDOM_TOWNS, ///< Randomly place many towns.
|
||||
WID_TF_EXPAND_ALL_TOWNS, ///< Make all towns grow slightly.
|
||||
WID_TF_TOWN_NAME_EDITBOX, ///< Editor for the town name.
|
||||
WID_TF_TOWN_NAME_RANDOM, ///< Generate a random town name.
|
||||
WID_TF_SIZE_SMALL, ///< Selection for a small town.
|
||||
|
||||
@@ -27,6 +27,7 @@ enum VehicleViewWidgets {
|
||||
WID_VV_SELECT_REFIT_TURN, ///< Selection widget between 'refit' and 'turn around' buttons.
|
||||
WID_VV_TURN_AROUND, ///< Turn this vehicle around.
|
||||
WID_VV_FORCE_PROCEED, ///< Force this vehicle to pass a signal at danger.
|
||||
WID_VV_HONK_HORN, ///< Honk the vehicles horn (not drawn on UI, only used for hotkey).
|
||||
};
|
||||
|
||||
/** Widgets of the #RefitWindow class. */
|
||||
@@ -69,6 +70,8 @@ enum VehicleListWidgets {
|
||||
WID_VL_GROUP_BY_PULLDOWN, ///< Group by dropdown list.
|
||||
WID_VL_SORT_ORDER, ///< Sort order.
|
||||
WID_VL_SORT_BY_PULLDOWN, ///< Sort by dropdown list.
|
||||
WID_VL_FILTER_BY_CARGO, ///< Cargo filter dropdown list.
|
||||
WID_VL_FILTER_BY_CARGO_SEL, ///< Cargo filter dropdown list panel selector.
|
||||
WID_VL_LIST, ///< List of the vehicles.
|
||||
WID_VL_SCROLLBAR, ///< Scrollbar for the list.
|
||||
WID_VL_HIDE_BUTTONS, ///< Selection to hide the buttons.
|
||||
|
||||
Reference in New Issue
Block a user