Merge branch upstream/master

This commit is contained in:
Sergii Pylypenko
2021-11-28 03:16:36 +02:00
326 changed files with 9186 additions and 8099 deletions
+2
View File
@@ -44,6 +44,8 @@ add_files(
screenshot_widget.h
settings_widget.h
sign_widget.h
slider.cpp
slider_func.h
smallmap_widget.h
station_widget.h
statusbar_widget.h
+5 -12
View File
@@ -72,13 +72,7 @@ StringID DropDownListCharStringItem::String() const
DropDownListIconItem::DropDownListIconItem(SpriteID sprite, PaletteID pal, StringID string, int result, bool masked) : DropDownListParamStringItem(string, result, masked), sprite(sprite), pal(pal)
{
this->dim = GetSpriteSize(sprite);
if (this->dim.height < (uint)FONT_HEIGHT_NORMAL) {
this->sprite_y = (FONT_HEIGHT_NORMAL - dim.height) / 2;
this->text_y = 0;
} else {
this->sprite_y = 0;
this->text_y = (dim.height - FONT_HEIGHT_NORMAL) / 2;
}
this->sprite_y = dim.height;
}
uint DropDownListIconItem::Height(uint width) const
@@ -94,8 +88,8 @@ uint DropDownListIconItem::Width() const
void DropDownListIconItem::Draw(int left, int right, int top, int bottom, 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, Center(top, bottom - top, this->dim.height));
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), Center(top, bottom - top), this->String(), sel ? TC_WHITE : TC_BLACK);
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);
}
void DropDownListIconItem::SetDimension(Dimension d)
@@ -162,7 +156,7 @@ struct DropdownWindow : Window {
uint items_width = size.width - (scroll ? NWidgetScrollbar::GetVerticalDimension().width : 0);
NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_DM_ITEMS);
nwi->SetMinimalSize(items_width, size.height + 4);
nwi->SetMinimalSizeAbsolute(items_width, size.height + 4);
nwi->colour = wi_colour;
nwi = this->GetWidget<NWidgetCore>(WID_DM_SCROLL);
@@ -564,8 +558,7 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt
*/
int HideDropDownMenu(Window *pw)
{
Window *w;
FOR_ALL_WINDOWS_FROM_BACK(w) {
for (Window *w : Window::IterateFromBack()) {
if (w->window_class != WC_DROPDOWN_MENU) continue;
DropdownWindow *dw = dynamic_cast<DropdownWindow*>(w);
-1
View File
@@ -85,7 +85,6 @@ class DropDownListIconItem : public DropDownListParamStringItem {
PaletteID pal;
Dimension dim;
uint sprite_y;
uint text_y;
public:
DropDownListIconItem(SpriteID sprite, PaletteID pal, StringID string, int result, bool masked);
+10 -9
View File
@@ -71,9 +71,6 @@ enum NetworkStartServerWidgets {
WID_NSS_SPECTATORS_TXT, ///< 'Max spectators' text.
WID_NSS_SPECTATORS_BTNU, ///< 'Max spectators' uparrow.
WID_NSS_LANGUAGE_LABEL, ///< Label for 'language spoken'.
WID_NSS_LANGUAGE_BTN, ///< 'Language spoken' droplist button.
WID_NSS_GENERATE_GAME, ///< New game button.
WID_NSS_LOAD_GAME, ///< Load game button.
WID_NSS_PLAY_SCENARIO, ///< Play scenario button.
@@ -99,12 +96,16 @@ enum NetworkLobbyWidgets {
/** Widgets of the #NetworkClientListWindow class. */
enum ClientListWidgets {
WID_CL_PANEL, ///< Panel of the window.
};
/** Widgets of the #NetworkClientListPopupWindow class. */
enum ClientListPopupWidgets {
WID_CLP_PANEL, ///< Panel of the window.
WID_CL_PANEL, ///< Panel of the window.
WID_CL_SERVER_SELECTOR, ///< Selector to hide the server frame.
WID_CL_SERVER_NAME, ///< Server name.
WID_CL_SERVER_NAME_EDIT, ///< Edit button for server name.
WID_CL_SERVER_VISIBILITY, ///< Server visibility.
WID_CL_CLIENT_NAME, ///< Client name.
WID_CL_CLIENT_NAME_EDIT, ///< Edit button for client name.
WID_CL_MATRIX, ///< Company/client list.
WID_CL_SCROLLBAR, ///< Scrollbar for company/client list.
WID_CL_COMPANY_JOIN, ///< Used for QueryWindow when a company has a password.
};
/** Widgets of the #NetworkJoinStatusWindow class. */
+4
View File
@@ -33,14 +33,17 @@ enum GameOptionsWidgets {
WID_GO_BASE_GRF_TEXTFILE, ///< Open base GRF readme, changelog (+1) or license (+2).
WID_GO_BASE_GRF_DESCRIPTION = WID_GO_BASE_GRF_TEXTFILE + TFT_END, ///< Description of selected base GRF.
WID_GO_BASE_SFX_DROPDOWN, ///< Use to select a base SFX.
WID_GO_BASE_SFX_VOLUME, ///< Change sound effects volume.
WID_GO_BASE_SFX_TEXTFILE, ///< Open base SFX readme, changelog (+1) or license (+2).
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_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.
};
@@ -52,6 +55,7 @@ enum GameSettingsWidgets {
WID_GS_HELP_TEXT, ///< Information area to display help text of the selected option.
WID_GS_EXPAND_ALL, ///< Expand all button.
WID_GS_COLLAPSE_ALL, ///< Collapse all button.
WID_GS_RESET_ALL, ///< Reset all button.
WID_GS_RESTRICT_CATEGORY, ///< Label upfront to the category drop-down box to restrict the list of settings to show
WID_GS_RESTRICT_TYPE, ///< Label upfront to the type drop-down box to restrict the list of settings to show
WID_GS_RESTRICT_DROPDOWN, ///< The drop down box to restrict the list of settings
+70
View File
@@ -0,0 +1,70 @@
/*
* 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 slider.cpp Implementation of the horizontal slider widget. */
#include "../stdafx.h"
#include "../window_gui.h"
#include "../window_func.h"
#include "../strings_func.h"
#include "../zoom_func.h"
#include "slider_func.h"
#include "../safeguards.h"
/**
* Draw a volume slider widget with know at given value
* @param r Rectangle to draw the widget in
* @param value Value to put the slider at
*/
void DrawVolumeSliderWidget(Rect r, byte value)
{
static const int slider_width = 3;
/* Draw a wedge indicating low to high volume level. */
const int ha = (r.bottom - r.top) / 5;
int wx1 = r.left, wx2 = r.right;
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);
/* 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);
DrawFrameRect(x, r.top, x + sw, r.bottom, COLOUR_GREY, FR_NONE);
}
/**
* Handle click on a volume 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
*/
bool ClickVolumeSliderWidget(Rect r, Point pt, byte &value)
{
byte new_vol = Clamp((pt.x - r.left) * 127 / (r.right - r.left), 0, 127);
if (_current_text_dir == TD_RTL) new_vol = 127 - new_vol;
/* Clamp to make sure min and max are properly settable */
if (new_vol > 124) new_vol = 127;
if (new_vol < 3) new_vol = 0;
if (new_vol != value) {
value = new_vol;
return true;
}
return false;
}
+21
View File
@@ -0,0 +1,21 @@
/*
* 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 slider_type.h Types related to the horizontal slider widget. */
#ifndef WIDGETS_SLIDER_TYPE_H
#define WIDGETS_SLIDER_TYPE_H
#include "../window_type.h"
#include "../gfx_func.h"
void DrawVolumeSliderWidget(Rect r, byte value);
bool ClickVolumeSliderWidget(Rect r, Point pt, byte &value);
#endif /* WIDGETS_SLIDER_TYPE_H */