Merge tag '13.0-beta2' into jgrpp

# Conflicts:
#	src/cheat_gui.cpp
#	src/company_gui.cpp
#	src/console_gui.cpp
#	src/depot_gui.cpp
#	src/error_gui.cpp
#	src/gfx.cpp
#	src/graph_gui.cpp
#	src/group_gui.cpp
#	src/lang/english.txt
#	src/lang/korean.txt
#	src/lang/polish.txt
#	src/misc_gui.cpp
#	src/network/network_content_gui.h
#	src/newgrf_debug_gui.cpp
#	src/order_gui.cpp
#	src/rail_gui.cpp
#	src/road_gui.cpp
#	src/settings_gui.cpp
#	src/settings_type.h
#	src/station_gui.cpp
#	src/subsidy_gui.cpp
#	src/table/settings/gui_settings.ini
#	src/timetable_gui.cpp
#	src/town_gui.cpp
#	src/train_cmd.cpp
#	src/vehicle_gui.cpp
#	src/viewport.cpp
#	src/water_cmd.cpp
#	src/widgets/dropdown.cpp
#	src/window_gui.h
This commit is contained in:
Jonathan G Rennison
2022-12-04 20:25:38 +00:00
172 changed files with 3061 additions and 2809 deletions

View File

@@ -19,6 +19,9 @@
#include "core/smallmap_type.hpp"
#include "string_type.h"
#include <algorithm>
#include <functional>
/**
* Flags to describe the look of the frame
*/
@@ -41,7 +44,6 @@ struct WidgetDimensions {
RectPadding fullbevel; ///< Always-scaled bevel border.
RectPadding framerect; ///< Offsets within frame area.
RectPadding frametext; ///< Offsets within a text frame area.
RectPadding textpanel; ///< Text panel?
RectPadding matrix; ///< Offsets within a matrix cell.
RectPadding shadebox;
RectPadding stickybox;
@@ -51,6 +53,7 @@ struct WidgetDimensions {
RectPadding closebox;
RectPadding captiontext; ///< Offsets of text within a caption.
RectPadding dropdowntext; ///< Offsets of text within a dropdown widget.
RectPadding modalpopup; ///< Padding for a modal popup.
int pressed; ///< Offset for contents of depressed widget.
int vsep_normal; ///< Normal vertical spacing.
@@ -63,117 +66,6 @@ struct WidgetDimensions {
static WidgetDimensions scaled; ///< Widget dimensions scaled for current zoom level.
};
/** Distances used in drawing widgets. */
enum WidgetDrawDistances {
/* WWT_IMGBTN(_2) */
WD_IMGBTN_LEFT = 1, ///< Left offset of the image in the button.
WD_IMGBTN_RIGHT = 2, ///< Right offset of the image in the button.
WD_IMGBTN_TOP = 1, ///< Top offset of image in the button.
WD_IMGBTN_BOTTOM = 2, ///< Bottom offset of image in the button.
/* WWT_INSET */
WD_INSET_LEFT = 2, ///< Left offset of string.
WD_INSET_RIGHT = 2, ///< Right offset of string.
WD_INSET_TOP = 1, ///< Top offset of string.
WD_VSCROLLBAR_LEFT = 2, ///< Left offset of vertical scrollbar.
WD_VSCROLLBAR_RIGHT = 2, ///< Right offset of vertical scrollbar.
WD_VSCROLLBAR_TOP = 3, ///< Top offset of vertical scrollbar.
WD_VSCROLLBAR_BOTTOM = 3, ///< Bottom offset of vertical scrollbar.
WD_HSCROLLBAR_LEFT = 3, ///< Left offset of horizontal scrollbar.
WD_HSCROLLBAR_RIGHT = 3, ///< Right offset of horizontal scrollbar.
WD_HSCROLLBAR_TOP = 2, ///< Top offset of horizontal scrollbar.
WD_HSCROLLBAR_BOTTOM = 2, ///< Bottom offset of horizontal scrollbar.
/* Size of the pure frame bevel without any padding. */
WD_BEVEL_LEFT = 1, ///< Width of left bevel border.
WD_BEVEL_RIGHT = 1, ///< Width of right bevel border.
WD_BEVEL_TOP = 1, ///< Height of top bevel border.
WD_BEVEL_BOTTOM = 1, ///< Height of bottom bevel border.
/* FrameRect widgets, all text buttons, panel, editbox */
WD_FRAMERECT_LEFT = 2, ///< Offset at left to draw the frame rectangular area
WD_FRAMERECT_RIGHT = 2, ///< Offset at right to draw the frame rectangular area
WD_FRAMERECT_TOP = 1, ///< Offset at top to draw the frame rectangular area
WD_FRAMERECT_BOTTOM = 1, ///< Offset at bottom to draw the frame rectangular area
/* Extra space at top/bottom of text panels */
WD_TEXTPANEL_TOP = 6, ///< Offset at top to draw above the text
WD_TEXTPANEL_BOTTOM = 6, ///< Offset at bottom to draw below the text
/* WWT_FRAME */
WD_FRAMETEXT_LEFT = 6, ///< Left offset of the text of the frame.
WD_FRAMETEXT_RIGHT = 6, ///< Right offset of the text of the frame.
WD_FRAMETEXT_TOP = 6, ///< Top offset of the text of the frame
WD_FRAMETEXT_BOTTOM = 6, ///< Bottom offset of the text of the frame
/* WWT_MATRIX */
WD_MATRIX_LEFT = 2, ///< Offset at left of a matrix cell.
WD_MATRIX_RIGHT = 2, ///< Offset at right of a matrix cell.
WD_MATRIX_TOP = 3, ///< Offset at top of a matrix cell.
WD_MATRIX_BOTTOM = 1, ///< Offset at bottom of a matrix cell.
/* WWT_SHADEBOX */
WD_SHADEBOX_WIDTH = 12, ///< Width of a standard shade box widget.
WD_SHADEBOX_LEFT = 2, ///< Left offset of shade sprite.
WD_SHADEBOX_RIGHT = 2, ///< Right offset of shade sprite.
WD_SHADEBOX_TOP = 3, ///< Top offset of shade sprite.
WD_SHADEBOX_BOTTOM = 3, ///< Bottom offset of shade sprite.
/* WWT_STICKYBOX */
WD_STICKYBOX_WIDTH = 12, ///< Width of a standard sticky box widget.
WD_STICKYBOX_LEFT = 2, ///< Left offset of sticky sprite.
WD_STICKYBOX_RIGHT = 2, ///< Right offset of sticky sprite.
WD_STICKYBOX_TOP = 3, ///< Top offset of sticky sprite.
WD_STICKYBOX_BOTTOM = 3, ///< Bottom offset of sticky sprite.
/* WWT_DEBUGBOX */
WD_DEBUGBOX_WIDTH = 12, ///< Width of a standard debug box widget.
WD_DEBUGBOX_LEFT = 2, ///< Left offset of debug sprite.
WD_DEBUGBOX_RIGHT = 2, ///< Right offset of debug sprite.
WD_DEBUGBOX_TOP = 3, ///< Top offset of debug sprite.
WD_DEBUGBOX_BOTTOM = 3, ///< Bottom offset of debug sprite.
/* WWT_DEFSIZEBOX */
WD_DEFSIZEBOX_WIDTH = 12, ///< Width of a standard defsize box widget.
WD_DEFSIZEBOX_LEFT = 2, ///< Left offset of defsize sprite.
WD_DEFSIZEBOX_RIGHT = 2, ///< Right offset of defsize sprite.
WD_DEFSIZEBOX_TOP = 3, ///< Top offset of defsize sprite.
WD_DEFSIZEBOX_BOTTOM = 3, ///< Bottom offset of defsize sprite.
/* WWT_RESIZEBOX */
WD_RESIZEBOX_WIDTH = 12, ///< Width of a resize box widget.
WD_RESIZEBOX_LEFT = 3, ///< Left offset of resize sprite.
WD_RESIZEBOX_RIGHT = 2, ///< Right offset of resize sprite.
WD_RESIZEBOX_TOP = 3, ///< Top offset of resize sprite.
WD_RESIZEBOX_BOTTOM = 2, ///< Bottom offset of resize sprite.
/* WWT_CLOSEBOX */
WD_CLOSEBOX_WIDTH = 11, ///< Width of a close box widget.
WD_CLOSEBOX_LEFT = 2, ///< Left offset of closebox string.
WD_CLOSEBOX_RIGHT = 1, ///< Right offset of closebox string.
WD_CLOSEBOX_TOP = 2, ///< Top offset of closebox string.
WD_CLOSEBOX_BOTTOM = 2, ///< Bottom offset of closebox string.
/* WWT_CAPTION */
WD_CAPTION_HEIGHT = 14, ///< Height of a title bar.
WD_CAPTIONTEXT_LEFT = 2, ///< Offset of the caption text at the left.
WD_CAPTIONTEXT_RIGHT = 2, ///< Offset of the caption text at the right.
WD_CAPTIONTEXT_TOP = 2, ///< Offset of the caption text at the top.
WD_CAPTIONTEXT_BOTTOM = 2, ///< Offset of the caption text at the bottom.
/* Dropdown widget. */
WD_DROPDOWN_HEIGHT = 12, ///< Height of a drop down widget.
WD_DROPDOWNTEXT_LEFT = 2, ///< Left offset of the dropdown widget string.
WD_DROPDOWNTEXT_RIGHT = 2, ///< Right offset of the dropdown widget string.
WD_DROPDOWNTEXT_TOP = 1, ///< Top offset of the dropdown widget string.
WD_DROPDOWNTEXT_BOTTOM = 1, ///< Bottom offset of the dropdown widget string.
WD_PAR_VSEP_NORMAL = 2, ///< Normal amount of vertical space between two paragraphs of text.
WD_PAR_VSEP_WIDE = 8, ///< Large amount of vertical space between two paragraphs of text.
};
/* widget.cpp */
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags);
@@ -379,6 +271,8 @@ private:
inline void operator delete[](void *ptr) { NOT_REACHED(); }
};
typedef std::vector<const Vehicle *> VehicleList;
/**
* Data structure for an opened window
*/
@@ -871,11 +765,20 @@ public:
/**
* The user clicked on a vehicle while HT_VEHICLE has been set.
* @param v clicked vehicle. It is guaranteed to be v->IsPrimaryVehicle() == true
* @return True if the click is handled, false if it is ignored.
* @param v clicked vehicle
* @return true if the click is handled, false if it is ignored
* @pre v->IsPrimaryVehicle() == true
*/
virtual bool OnVehicleSelect(const struct Vehicle *v) { return false; }
/**
* The user clicked on a vehicle while HT_VEHICLE has been set.
* @param v clicked vehicle
* @return True if the click is handled, false if it is ignored
* @pre v->IsPrimaryVehicle() == true
*/
virtual bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end) { return false; }
/**
* The user clicked on a template vehicle while HT_VEHICLE has been set.
* @param v clicked vehicle. It is guaranteed to be v->IsPrimaryVehicle() == true
@@ -1031,6 +934,19 @@ public:
static Iterate<T, IM_ARBITRARY> IterateUnordered(window_base_t<T> *from = _first_window) { return Iterate<T, IM_ARBITRARY>(from); }
};
/**
* Generic helper function that checks if all elements of the range are equal with respect to the given predicate.
* @param begin The start of the range.
* @param end The end of the range.
* @param pred The predicate to use.
* @return True if all elements are equal, false otherwise.
*/
template <class It, class Pred>
inline bool AllEqual(It begin, It end, Pred pred)
{
return std::adjacent_find(begin, end, std::not_fn(pred)) == end;
}
/**
* Get the nested widget with number \a widnum from the nested widget tree.
* @tparam NWID Type of the nested widget.