Merge 1.9.0-beta2

This commit is contained in:
Pavel Stupnikov
2019-02-14 00:47:22 +03:00
1364 changed files with 22213 additions and 10721 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: ai_widget.h 24900 2013-01-08 22:46:42Z planetmaker $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: airport_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: autoreplace_widget.h 27683 2016-12-08 20:21:39Z frosch $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: bootstrap_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: bridge_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: build_vehicle_widget.h 26811 2014-09-11 17:10:38Z alberth $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+2 -2
View File
@@ -1,4 +1,4 @@
/* $Id: cheat_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
@@ -12,7 +12,7 @@
#ifndef WIDGETS_CHEAT_WIDGET_H
#define WIDGETS_CHEAT_WIDGET_H
/** Widgets of the #CheatWindow class.. */
/** Widgets of the #CheatWindow class. */
enum CheatWidgets {
WID_C_PANEL, ///< Panel where all cheats are shown in.
};
+6 -1
View File
@@ -1,4 +1,4 @@
/* $Id: company_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
@@ -92,10 +92,15 @@ enum SelectCompanyLiveryWidgets {
WID_SCL_CLASS_ROAD, ///< Class road.
WID_SCL_CLASS_SHIP, ///< Class ship.
WID_SCL_CLASS_AIRCRAFT, ///< Class aircraft.
WID_SCL_GROUPS_RAIL, ///< Rail groups.
WID_SCL_GROUPS_ROAD, ///< Road groups.
WID_SCL_GROUPS_SHIP, ///< Ship groups.
WID_SCL_GROUPS_AIRCRAFT, ///< Aircraft groups.
WID_SCL_SPACER_DROPDOWN, ///< Spacer for dropdown.
WID_SCL_PRI_COL_DROPDOWN, ///< Dropdown for primary colour.
WID_SCL_SEC_COL_DROPDOWN, ///< Dropdown for secondary colour.
WID_SCL_MATRIX, ///< Matrix.
WID_SCL_MATRIX_SCROLLBAR, ///< Matrix scrollbar.
};
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: console_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: date_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: depot_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: dock_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+46 -36
View File
@@ -1,4 +1,4 @@
/* $Id: dropdown.cpp 27820 2017-03-23 20:07:59Z peter1138 $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
@@ -14,6 +14,7 @@
#include "../string_func.h"
#include "../strings_func.h"
#include "../window_func.h"
#include "../guitimer_func.h"
#include "dropdown_type.h"
#include "dropdown_widget.h"
@@ -102,6 +103,7 @@ struct DropdownWindow : Window {
bool drag_mode;
bool instant_close; ///< Close the window when the mouse button is raised.
int scrolling; ///< If non-zero, auto-scroll the item list (one time).
GUITimer scrolling_timer; ///< Timer for auto-scroll of the item list.
Point position; ///< Position of the topleft corner of the window.
Scrollbar *vscroll;
@@ -116,7 +118,6 @@ struct DropdownWindow : Window {
* @param size Size of the dropdown menu window.
* @param wi_colour Colour of the parent widget.
* @param scroll Dropdown menu has a scrollbar.
* @param widget Widgets of the dropdown menu window.
*/
DropdownWindow(Window *parent, const DropDownList *list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll)
: Window(&_dropdown_desc)
@@ -161,6 +162,7 @@ struct DropdownWindow : Window {
this->click_delay = 0;
this->drag_mode = true;
this->instant_close = instant_close;
this->scrolling_timer = GUITimer(MILLISECONDS_PER_TICK);
}
~DropdownWindow()
@@ -187,7 +189,7 @@ struct DropdownWindow : Window {
/**
* Find the dropdown item under the cursor.
* @param value [out] Selected item, if function returns \c true.
* @param[out] value Selected item, if function returns \c true.
* @return Cursor points to a dropdown item.
*/
bool GetDropDownItem(int &value)
@@ -260,8 +262,11 @@ struct DropdownWindow : Window {
}
}
virtual void OnTick()
virtual void OnRealtimeTick(uint delta_ms)
{
if (!this->scrolling_timer.Elapsed(delta_ms)) return;
this->scrolling_timer.SetInterval(MILLISECONDS_PER_TICK);
if (this->scrolling != 0) {
int pos = this->vscroll->GetPosition();
@@ -352,8 +357,8 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
/* Longest item in the list, if auto_width is enabled */
uint max_item_width = 0;
/* Total length of list */
int height = 0;
/* Total height of list */
uint height = 0;
for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) {
const DropDownListItem *item = *it;
@@ -361,53 +366,58 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
if (auto_width) max_item_width = max(max_item_width, item->Width() + 5);
}
/* Check if the status bar is visible, as we don't want to draw over it */
int screen_bottom = GetMainViewBottom();
/* Scrollbar needed? */
bool scroll = false;
/* Check if the dropdown will fully fit below the widget */
if (top + height + 4 >= screen_bottom) {
/* If not, check if it will fit above the widget */
int screen_top = GetMainViewTop();
if (w->top + wi_rect.top > screen_top + height) {
top = w->top + wi_rect.top - height - 4;
} else {
/* If it doesn't fit above the widget, we need to enable a scrollbar... */
int avg_height = height / (int)list->Length();
scroll = true;
/* Is it better to place the dropdown above the widget? */
bool above = false;
/* ... and choose whether to put the list above or below the widget. */
bool put_above = false;
int available_height = screen_bottom - w->top - wi_rect.bottom;
if (w->top + wi_rect.top - screen_top > available_height) {
// Put it above.
available_height = w->top + wi_rect.top - screen_top;
put_above = true;
}
/* Available height below (or above, if the dropdown is placed above the widget). */
uint available_height = (uint)max(GetMainViewBottom() - top - 4, 0);
/* If the dropdown doesn't fully fit below the widget... */
if (height > available_height) {
uint available_height_above = (uint)max(w->top + wi_rect.top - GetMainViewTop() - 4, 0);
/* Put the dropdown above if there is more available space. */
if (available_height_above > available_height) {
above = true;
available_height = available_height_above;
}
/* If the dropdown doesn't fully fit, we need a dropdown. */
if (height > available_height) {
scroll = true;
uint avg_height = height / list->Length();
/* Check at least there is space for one item. */
assert(available_height >= avg_height);
/* And lastly, fit the list... */
int rows = available_height / avg_height;
/* Fit the list. */
uint rows = available_height / avg_height;
height = rows * avg_height;
/* Add space for the scroll bar if we automatically determined
* the width of the list. */
/* Add space for the scrollbar. */
max_item_width += NWidgetScrollbar::GetVerticalDimension().width;
}
/* ... and set the top position if needed. */
if (put_above) {
top = w->top + wi_rect.top - height - 4;
}
/* Set the top position if needed. */
if (above) {
top = w->top + wi_rect.top - height - 4;
}
}
if (auto_width) width = max(width, max_item_width);
Point dw_pos = { w->left + (_current_text_dir == TD_RTL ? wi_rect.right + 1 - (int)width : wi_rect.left), top};
Dimension dw_size = {width, (uint)height};
new DropdownWindow(w, list, selected, button, instant_close, dw_pos, dw_size, wi_colour, scroll);
Dimension dw_size = {width, height};
DropdownWindow *dropdown = new DropdownWindow(w, list, selected, button, instant_close, dw_pos, dw_size, wi_colour, scroll);
/* The dropdown starts scrolling downwards when opening it towards
* the top and holding down the mouse button. It can be fooled by
* opening the dropdown scrolled to the very bottom. */
if (above && scroll) dropdown->vscroll->UpdatePosition(INT_MAX);
}
/**
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: dropdown_func.h 18809 2010-01-15 16:41:15Z rubidium $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: dropdown_type.h 26088 2013-11-24 15:17:53Z rubidium $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: dropdown_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: engine_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: error_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+2 -1
View File
@@ -1,4 +1,4 @@
/* $Id: fios_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
@@ -17,6 +17,7 @@ enum SaveLoadWidgets {
WID_SL_CAPTION, ///< Caption of the window.
WID_SL_SORT_BYNAME, ///< Sort by name button.
WID_SL_SORT_BYDATE, ///< Sort by date button.
WID_SL_FILTER, ///< Filter list of files
WID_SL_BACKGROUND, ///< Background of window.
WID_SL_FILE_BACKGROUND, ///< Background of file selection.
WID_SL_HOME_BUTTON, ///< Home button.
+33
View File
@@ -0,0 +1,33 @@
/* $Id$ */
/*
* 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 framerate_widget.h Types related to the framerate windows widgets. */
#ifndef WIDGETS_FRAMERATE_WIDGET_H
#define WIDGETS_FRAMERATE_WIDGET_H
/** Widgets of the #FramerateWindow class. */
enum FramerateWindowWidgets {
WID_FRW_CAPTION,
WID_FRW_RATE_GAMELOOP,
WID_FRW_RATE_DRAWING,
WID_FRW_RATE_FACTOR,
WID_FRW_INFO_DATA_POINTS,
WID_FRW_TIMES_NAMES,
WID_FRW_TIMES_CURRENT,
WID_FRW_TIMES_AVERAGE,
};
/** Widgets of the #FrametimeGraphWindow class. */
enum FrametimeGraphWindowWidgets {
WID_FGW_CAPTION,
WID_FGW_GRAPH,
};
#endif /* WIDGETS_FRAMERATE_WIDGET_H */
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: genworld_widget.h 26885 2014-09-21 12:25:04Z rubidium $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,5 +1,5 @@
/* $Id: goal_widget.h 25623 2013-07-21 15:59:07Z zuu $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: graph_widget.h 23735 2012-01-03 20:26:05Z rubidium $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+2 -1
View File
@@ -1,4 +1,4 @@
/* $Id: group_widget.h 27822 2017-03-24 07:33:31Z peter1138 $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
@@ -31,6 +31,7 @@ enum GroupListWidgets {
WID_GL_CREATE_GROUP, ///< Create group button.
WID_GL_DELETE_GROUP, ///< Delete group button.
WID_GL_RENAME_GROUP, ///< Rename group button.
WID_GL_LIVERY_GROUP, ///< Group livery button.
WID_GL_REPLACE_PROTECTION, ///< Replace protection button.
WID_GL_INFO, ///< Group info.
};
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: highscore_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: industry_widget.h 24763 2012-11-25 15:24:02Z alberth $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: intro_widget.h 27732 2017-01-14 18:30:26Z frosch $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: link_graph_legend_widget.h 25331 2013-06-08 12:37:36Z zuu $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: main_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: misc_widget.h 25816 2013-10-06 11:29:14Z frosch $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+3 -1
View File
@@ -1,4 +1,4 @@
/* $Id: music_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
@@ -14,9 +14,11 @@
/** Widgets of the #MusicTrackSelectionWindow class. */
enum MusicTrackSelectionWidgets {
WID_MTS_CAPTION, ///< Window caption.
WID_MTS_LIST_LEFT, ///< Left button.
WID_MTS_PLAYLIST, ///< Playlist.
WID_MTS_LIST_RIGHT, ///< Right button.
WID_MTS_MUSICSET, ///< Music set selection.
WID_MTS_ALL, ///< All button.
WID_MTS_OLD, ///< Old button.
WID_MTS_NEW, ///< New button.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: network_chat_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: network_content_widget.h 25024 2013-02-18 19:30:24Z frosch $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: network_widget.h 24769 2012-11-27 21:35:52Z frosch $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: newgrf_debug_widget.h 27174 2015-03-01 08:17:14Z alberth $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: newgrf_widget.h 26613 2014-05-24 19:15:57Z alberth $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: news_widget.h 24842 2012-12-23 21:06:37Z frosch $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: object_widget.h 24178 2012-04-24 20:01:34Z frosch $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: order_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: osk_widget.h 24900 2013-01-08 22:46:42Z planetmaker $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: rail_widget.h 25464 2013-06-25 20:22:08Z frosch $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: road_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: settings_widget.h 26990 2014-10-11 13:22:37Z peter1138 $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: sign_widget.h 27020 2014-10-15 18:31:37Z rubidium $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: smallmap_widget.h 25262 2013-05-19 14:36:35Z rubidium $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: station_widget.h 25365 2013-06-09 13:08:52Z fonsinchen $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: statusbar_widget.h 24663 2012-11-05 19:45:45Z frosch $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,5 +1,5 @@
/* $Id: story_widget.h 26442 2014-04-03 10:54:37Z planetmaker $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: subsidy_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: terraform_widget.h 24900 2013-01-08 22:46:42Z planetmaker $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: timetable_widget.h 23947 2012-02-14 17:04:06Z michi_cc $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+2 -2
View File
@@ -1,4 +1,4 @@
/* $Id: toolbar_widget.h 27671 2016-10-30 17:36:57Z frosch $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
@@ -35,7 +35,7 @@ enum ToolbarNormalWidgets {
WID_TN_TRAINS = WID_TN_VEHICLE_START, ///< Train menu.
WID_TN_ROADVEHS, ///< Road vehicle menu.
WID_TN_SHIPS, ///< Ship menu.
WID_TN_AIRCRAFTS, ///< Aircraft menu.
WID_TN_AIRCRAFT, ///< Aircraft menu.
WID_TN_ZOOM_IN, ///< Zoom in the main viewport.
WID_TN_ZOOM_OUT, ///< Zoom out the main viewport.
WID_TN_BUILDING_TOOLS_START, ///< Helper for the offset of the building tools
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: town_widget.h 25094 2013-03-17 15:41:40Z alberth $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: transparency_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: tree_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: vehicle_widget.h 24997 2013-02-14 17:11:42Z rubidium $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: viewport_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
+1 -1
View File
@@ -1,4 +1,4 @@
/* $Id: waypoint_widget.h 23600 2011-12-19 20:46:17Z truebrain $ */
/* $Id$ */
/*
* This file is part of OpenTTD.