Merge commit '13.0-RC1~2'

This commit is contained in:
2023-02-25 04:49:57 +00:00
603 changed files with 26913 additions and 18390 deletions

View File

@@ -11,7 +11,10 @@
#define WINDOW_GUI_H
#include <list>
#include <algorithm>
#include <functional>
#include "vehiclelist.h"
#include "vehicle_type.h"
#include "viewport_type.h"
#include "company_type.h"
@@ -34,114 +37,45 @@ enum FrameFlags {
DECLARE_ENUM_AS_BIT_SET(FrameFlags)
/** 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.
struct WidgetDimensions {
RectPadding imgbtn;
RectPadding inset;
RectPadding vscrollbar;
RectPadding hscrollbar;
RectPadding bevel; ///< Widths of bevel border.
RectPadding fullbevel; ///< Always-scaled bevel border.
RectPadding framerect; ///< Offsets within frame area.
RectPadding frametext; ///< Offsets within a text frame area.
RectPadding matrix; ///< Offsets within a matrix cell.
RectPadding shadebox;
RectPadding stickybox;
RectPadding debugbox;
RectPadding defsizebox;
RectPadding resizebox;
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.
/* 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.
int pressed; ///< Offset for contents of depressed widget.
int vsep_normal; ///< Normal vertical spacing.
int vsep_wide; ///< Wide vertical spacing.
int hsep_normal; ///< Normal horizontal spacing.
int hsep_wide; ///< Wide horizontal spacing.
int hsep_indent; ///< Width of identation for tree layouts.
WD_SCROLLBAR_LEFT = 2, ///< Left offset of scrollbar.
WD_SCROLLBAR_RIGHT = 2, ///< Right offset of scrollbar.
WD_SCROLLBAR_TOP = 2, ///< Top offset of scrollbar.
WD_SCROLLBAR_BOTTOM = 2, ///< Bottom offset of 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.
static const WidgetDimensions unscaled; ///< Unscaled widget dimensions.
static WidgetDimensions scaled; ///< Widget dimensions scaled for current zoom level.
};
/* widget.cpp */
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags);
static inline void DrawFrameRect(const Rect &r, Colours colour, FrameFlags flags)
{
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, flags);
}
void DrawCaption(const Rect &r, Colours colour, Owner owner, TextColour text_colour, StringID str, StringAlignment align, const NWidgetCore *widget, const Window *window);
/* window.cpp */
@@ -342,6 +276,7 @@ public:
const QueryString *GetQueryString(uint widnum) const;
QueryString *GetQueryString(uint widnum);
void UpdateQueryStringSize();
virtual const char *GetFocusedText() const;
virtual const char *GetCaret() const;
@@ -750,11 +685,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 cancelled a tile highlight mode that has been set.
*/
@@ -879,6 +823,19 @@ public:
using IterateFromFront = AllWindows<true>; //!< Iterate all windows in Z order from front to back.
};
/**
* 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.