Merge remote-tracking branch 'upstream/master'

This commit is contained in:
dP
2025-05-14 18:41:13 +05:00
994 changed files with 38759 additions and 34518 deletions

View File

@@ -12,6 +12,7 @@
#include "landscape.h"
#include "error.h"
#include "gui.h"
#include "gfx_layout.h"
#include "command_func.h"
#include "company_func.h"
#include "town.h"
@@ -64,11 +65,11 @@ static const NWidgetPart _nested_land_info_widgets[] = {
NWidget(WWT_PANEL, COLOUR_GREY, WID_LI_BACKGROUND), SetMinimalSize(64, 32), EndContainer(),
};
static WindowDesc _land_info_desc(__FILE__, __LINE__,
static WindowDesc _land_info_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_LAND_INFO, WC_NONE,
0,
std::begin(_nested_land_info_widgets), std::end(_nested_land_info_widgets)
_nested_land_info_widgets
);
class LandInfoWindow : public Window {
@@ -111,27 +112,27 @@ public:
}
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
if (widget != WID_LI_BACKGROUND) return;
size->height = WidgetDimensions::scaled.frametext.Vertical();
size.height = WidgetDimensions::scaled.frametext.Vertical();
for (size_t i = 0; i < this->landinfo_data.size(); i++) {
uint width = GetStringBoundingBox(this->landinfo_data[i]).width + WidgetDimensions::scaled.frametext.Horizontal();
size->width = std::max(size->width, width);
size.width = std::max(size.width, width);
size->height += GetCharacterHeight(FS_NORMAL) + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal);
size.height += GetCharacterHeight(FS_NORMAL) + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal);
}
if (!this->cargo_acceptance.empty()) {
uint width = GetStringBoundingBox(this->cargo_acceptance).width + WidgetDimensions::scaled.frametext.Horizontal();
size->width = std::max(size->width, std::min(static_cast<uint>(ScaleGUITrad(300)), width));
size.width = std::max(size.width, std::min(static_cast<uint>(ScaleGUITrad(300)), width));
SetDParamStr(0, cargo_acceptance);
size->height += GetStringHeight(STR_JUST_RAW_STRING, size->width - WidgetDimensions::scaled.frametext.Horizontal());
size.height += GetStringHeight(STR_JUST_RAW_STRING, size.width - WidgetDimensions::scaled.frametext.Horizontal());
}
}
LandInfoWindow(Tile tile, Tile end_tile) : Window(&_land_info_desc), tile(tile), end_tile(end_tile)
LandInfoWindow(Tile tile, Tile end_tile) : Window(_land_info_desc), tile(tile), end_tile(end_tile)
{
this->InitNested();
CLRBITS(this->flags, WF_WHITE_BORDER);
@@ -141,7 +142,7 @@ public:
#else
# define LANDINFOD_LEVEL 1
#endif
Debug(misc, LANDINFOD_LEVEL, "TILE: 0x{:x} ({},{})", (TileIndex)tile, TileX(tile), TileY(tile));
Debug(misc, LANDINFOD_LEVEL, "TILE: {0} (0x{0:x}) ({1},{2})", (TileIndex)tile, TileX(tile), TileY(tile));
Debug(misc, LANDINFOD_LEVEL, "type = 0x{:x}", tile.type());
Debug(misc, LANDINFOD_LEVEL, "height = 0x{:x}", tile.height());
Debug(misc, LANDINFOD_LEVEL, "m1 = 0x{:x}", tile.m1());
@@ -233,15 +234,16 @@ public:
this->landinfo_data.push_back(GetString(str));
/* Location */
std::stringstream tile_ss;
tile_ss << "0x" << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << tile.base(); // 0x%.4X
SetDParam(0, TileX(tile));
SetDParam(1, TileY(tile));
SetDParam(2, GetTileZ(tile));
SetDParamStr(3, tile_ss.str());
this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_LANDINFO_COORDS));
/* Tile index */
SetDParam(0, tile);
SetDParam(1, tile);
this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_LANDINFO_INDEX));
/* Local authority */
SetDParam(0, STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE);
if (t != nullptr) {
@@ -336,29 +338,9 @@ public:
/* CityMania code end */
/* Cargo acceptance is displayed in a extra multiline */
std::stringstream line;
line << GetString(STR_LAND_AREA_INFORMATION_CARGO_ACCEPTED);
bool found = false;
for (const CargoSpec *cs : _sorted_cargo_specs) {
CargoID cid = cs->Index();
if (acceptance[cid] > 0) {
/* Add a comma between each item. */
if (found) line << ", ";
found = true;
/* If the accepted value is less than 8, show it in 1/8:ths */
if (acceptance[cid] < 8) {
SetDParam(0, acceptance[cid]);
SetDParam(1, cs->name);
line << GetString(STR_LAND_AREA_INFORMATION_CARGO_EIGHTS);
} else {
line << GetString(cs->name);
}
}
}
if (found) {
this->cargo_acceptance = line.str();
auto line = BuildCargoAcceptanceString(acceptance, STR_LAND_AREA_INFORMATION_CARGO_ACCEPTED);
if (line.has_value()) {
this->cargo_acceptance = std::move(*line);
} else {
this->cargo_acceptance.clear();
}
@@ -432,14 +414,14 @@ static constexpr NWidgetPart _nested_about_widgets[] = {
EndContainer(),
};
static WindowDesc _about_desc(__FILE__, __LINE__,
static WindowDesc _about_desc(
WDP_CENTER, nullptr, 0, 0,
WC_GAME_OPTIONS, WC_NONE,
0,
std::begin(_nested_about_widgets), std::end(_nested_about_widgets)
_nested_about_widgets
);
static const char * const _credits[] = {
static const std::initializer_list<const std::string_view> _credits = {
"Original design by Chris Sawyer",
"Original graphics by Simon Foster",
"",
@@ -511,7 +493,7 @@ struct AboutWindow : public Window {
int line_height; ///< The height of a single line
static const int num_visible_lines = 19; ///< The number of lines visible simultaneously
AboutWindow() : Window(&_about_desc)
AboutWindow() : Window(_about_desc)
{
this->InitNested(WN_GAME_OPTIONS_ABOUT);
@@ -524,7 +506,7 @@ struct AboutWindow : public Window {
if (widget == WID_A_COPYRIGHT) SetDParamStr(0, _openttd_revision_year);
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
if (widget != WID_A_SCROLLING_TEXT) return;
@@ -534,10 +516,10 @@ struct AboutWindow : public Window {
d.height = this->line_height * num_visible_lines;
d.width = 0;
for (uint i = 0; i < lengthof(_credits); i++) {
d.width = std::max(d.width, GetStringBoundingBox(_credits[i]).width);
for (const auto &str : _credits) {
d.width = std::max(d.width, GetStringBoundingBox(str).width);
}
*size = maxdim(*size, d);
size = maxdim(size, d);
}
void DrawWidget(const Rect &r, WidgetID widget) const override
@@ -547,9 +529,9 @@ struct AboutWindow : public Window {
int y = this->text_position;
/* Show all scrolling _credits */
for (uint i = 0; i < lengthof(_credits); i++) {
for (const auto &str : _credits) {
if (y >= r.top + 7 && y < r.bottom - this->line_height) {
DrawString(r.left, r.right, y, _credits[i], TC_BLACK, SA_LEFT | SA_FORCE);
DrawString(r.left, r.right, y, str, TC_BLACK, SA_LEFT | SA_FORCE);
}
y += this->line_height;
}
@@ -563,7 +545,7 @@ struct AboutWindow : public Window {
IntervalTimer<TimerWindow> scroll_interval = {std::chrono::milliseconds(2100) / GetCharacterHeight(FS_NORMAL), [this](uint count) {
this->text_position -= count;
/* If the last text has scrolled start a new from the start */
if (this->text_position < (int)(this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->pos_y - lengthof(_credits) * this->line_height)) {
if (this->text_position < (int)(this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->pos_y - std::size(_credits) * this->line_height)) {
this->text_position = this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->pos_y + this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->current_y;
}
this->SetWidgetDirty(WID_A_SCROLLING_TEXT);
@@ -691,21 +673,21 @@ static constexpr NWidgetPart _nested_tooltips_widgets[] = {
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_TT_BACKGROUND),
};
static WindowDesc _tool_tips_desc(__FILE__, __LINE__,
static WindowDesc _tool_tips_desc(
WDP_MANUAL, nullptr, 0, 0, // Coordinates and sizes are not used,
WC_TOOLTIPS, WC_NONE,
WDF_NO_FOCUS | WDF_NO_CLOSE,
std::begin(_nested_tooltips_widgets), std::end(_nested_tooltips_widgets)
_nested_tooltips_widgets
);
/** Window for displaying a tooltip. */
struct TooltipsWindow : public Window
{
StringID string_id; ///< String to display as tooltip.
std::vector<StringParameterBackup> params; ///< The string parameters.
std::vector<StringParameterData> params; ///< The string parameters.
TooltipCloseCondition close_cond; ///< Condition for closing the window.
TooltipsWindow(Window *parent, StringID str, uint paramcount, TooltipCloseCondition close_tooltip) : Window(&_tool_tips_desc)
TooltipsWindow(Window *parent, StringID str, uint paramcount, TooltipCloseCondition close_tooltip) : Window(_tool_tips_desc)
{
this->parent = parent;
this->string_id = str;
@@ -737,17 +719,17 @@ struct TooltipsWindow : public Window
return pt;
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
if (widget != WID_TT_BACKGROUND) return;
CopyInDParam(this->params);
size->width = std::min<uint>(GetStringBoundingBox(this->string_id).width, ScaleGUITrad(194));
size->height = GetStringHeight(this->string_id, size->width);
size.width = std::min<uint>(GetStringBoundingBox(this->string_id).width, ScaleGUITrad(194));
size.height = GetStringHeight(this->string_id, size.width);
/* Increase slightly to have some space around the box. */
size->width += WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.fullbevel.Horizontal();
size->height += WidgetDimensions::scaled.framerect.Vertical() + WidgetDimensions::scaled.fullbevel.Vertical();
size.width += WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.fullbevel.Horizontal();
size.height += WidgetDimensions::scaled.framerect.Vertical() + WidgetDimensions::scaled.fullbevel.Vertical();
}
void DrawWidget(const Rect &r, WidgetID widget) const override
@@ -815,6 +797,25 @@ static int GetCaretWidth()
return GetCharacterWidth(FS_NORMAL, '_');
}
/**
* Reposition edit text box rect based on textbuf length can caret position.
* @param r Initial rect of edit text box.
* @param tb The Textbuf being processed.
* @return Updated rect.
*/
static Rect ScrollEditBoxTextRect(Rect r, const Textbuf &tb)
{
const int linewidth = tb.pixels + GetCaretWidth();
const int boxwidth = r.Width();
if (linewidth <= boxwidth) return r;
/* Extend to cover whole string. This is left-aligned, adjusted by caret position. */
r = r.WithWidth(linewidth, false);
/* Slide so that the caret is at the centre unless limited by bounds of the line, i.e. near either end. */
return r.Translate(-std::clamp(tb.caretxoffs - (boxwidth / 2), 0, linewidth - boxwidth), 0);
}
void QueryString::DrawEditBox(const Window *w, WidgetID wid) const
{
const NWidgetLeaf *wi = w->GetWidget<NWidgetLeaf>(wid);
@@ -831,7 +832,7 @@ void QueryString::DrawEditBox(const Window *w, WidgetID wid) const
DrawFrameRect(cr, wi->colour, wi->IsLowered() ? FR_LOWERED : FR_NONE);
DrawSpriteIgnorePadding(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT, PAL_NONE, cr, SA_CENTER);
if (this->text.bytes == 1) GfxFillRect(cr.Shrink(WidgetDimensions::scaled.bevel), _colour_gradient[wi->colour & 0xF][2], FILLRECT_CHECKER);
if (this->text.bytes == 1) GfxFillRect(cr.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(wi->colour, SHADE_DARKER), FILLRECT_CHECKER);
DrawFrameRect(fr, wi->colour, FR_LOWERED | FR_DARKENED);
GfxFillRect(fr.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK);
@@ -840,24 +841,29 @@ void QueryString::DrawEditBox(const Window *w, WidgetID wid) const
/* Limit the drawing of the string inside the widget boundaries */
DrawPixelInfo dpi;
if (!FillDrawPixelInfo(&dpi, fr)) return;
/* Keep coordinates relative to the window. */
dpi.left += fr.left;
dpi.top += fr.top;
AutoRestoreBackup dpi_backup(_cur_dpi, &dpi);
/* We will take the current widget length as maximum width, with a small
* space reserved at the end for the caret to show */
const Textbuf *tb = &this->text;
int delta = std::min(0, (fr.right - fr.left) - tb->pixels - GetCaretWidth());
if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs;
fr = ScrollEditBoxTextRect(fr, *tb);
/* If we have a marked area, draw a background highlight. */
if (tb->marklength != 0) GfxFillRect(delta + tb->markxoffs, 0, delta + tb->markxoffs + tb->marklength - 1, fr.bottom - fr.top, PC_GREY);
if (tb->marklength != 0) GfxFillRect(fr.left + tb->markxoffs, fr.top, fr.left + tb->markxoffs + tb->marklength - 1, fr.bottom, PC_GREY);
DrawString(delta, tb->pixels, 0, tb->buf, TC_YELLOW);
DrawString(fr.left, fr.right, CenterBounds(fr.top, fr.bottom, GetCharacterHeight(FS_NORMAL)), tb->buf, TC_YELLOW);
bool focussed = w->IsWidgetGloballyFocused(wid) || IsOSKOpenedFor(w, wid);
if (focussed && tb->caret) {
int caret_width = GetStringBoundingBox("_").width;
DrawString(tb->caretxoffs + delta, tb->caretxoffs + delta + caret_width, 0, "_", TC_WHITE);
int caret_width = GetCaretWidth();
if (rtl) {
DrawString(fr.right - tb->pixels + tb->caretxoffs - caret_width, fr.right - tb->pixels + tb->caretxoffs, CenterBounds(fr.top, fr.bottom, GetCharacterHeight(FS_NORMAL)), "_", TC_WHITE);
} else {
DrawString(fr.left + tb->caretxoffs, fr.left + tb->caretxoffs + caret_width, CenterBounds(fr.top, fr.bottom, GetCharacterHeight(FS_NORMAL)), "_", TC_WHITE);
}
}
}
@@ -881,10 +887,9 @@ Point QueryString::GetCaretPosition(const Window *w, WidgetID wid) const
/* Clamp caret position to be inside out current width. */
const Textbuf *tb = &this->text;
int delta = std::min(0, (r.right - r.left) - tb->pixels - GetCaretWidth());
if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs;
r = ScrollEditBoxTextRect(r, *tb);
Point pt = {r.left + tb->caretxoffs + delta, r.top};
Point pt = {r.left + tb->caretxoffs, r.top};
return pt;
}
@@ -910,14 +915,13 @@ Rect QueryString::GetBoundingRect(const Window *w, WidgetID wid, const char *fro
/* Clamp caret position to be inside our current width. */
const Textbuf *tb = &this->text;
int delta = std::min(0, r.Width() - tb->pixels - GetCaretWidth());
if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs;
r = ScrollEditBoxTextRect(r, *tb);
/* Get location of first and last character. */
Point p1 = GetCharPosInString(tb->buf, from, FS_NORMAL);
Point p2 = from != to ? GetCharPosInString(tb->buf, to, FS_NORMAL) : p1;
const auto p1 = GetCharPosInString(tb->buf, from, FS_NORMAL);
const auto p2 = from != to ? GetCharPosInString(tb->buf, to, FS_NORMAL) : p1;
return { Clamp(r.left + p1.x + delta, r.left, r.right), r.top, Clamp(r.left + p2.x + delta, r.left, r.right), r.bottom };
return { Clamp(r.left + p1.left, r.left, r.right), r.top, Clamp(r.left + p2.right, r.left, r.right), r.bottom };
}
/**
@@ -943,10 +947,9 @@ ptrdiff_t QueryString::GetCharAtPosition(const Window *w, WidgetID wid, const Po
/* Clamp caret position to be inside our current width. */
const Textbuf *tb = &this->text;
int delta = std::min(0, r.Width() - tb->pixels - GetCaretWidth());
if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs;
r = ScrollEditBoxTextRect(r, *tb);
return ::GetCharAtPosition(tb->buf, pt.x - delta - r.left);
return ::GetCharAtPosition(tb->buf, pt.x - r.left);
}
void QueryString::ClickEditBox(Window *w, Point pt, WidgetID wid, int click_count, bool focus_changed)
@@ -983,9 +986,8 @@ struct QueryStringWindow : public Window
{
QueryString editbox; ///< Editbox.
QueryStringFlags flags; ///< Flags controlling behaviour of the window.
Dimension warning_size; ///< How much space to use for the warning text
QueryStringWindow(StringID str, StringID caption, uint max_bytes, uint max_chars, WindowDesc *desc, Window *parent, CharSetFilter afilter, QueryStringFlags flags) :
QueryStringWindow(StringID str, StringID caption, uint max_bytes, uint max_chars, WindowDesc &desc, Window *parent, CharSetFilter afilter, QueryStringFlags flags) :
Window(desc), editbox(max_bytes, max_chars)
{
this->editbox.text.Assign(str);
@@ -1000,48 +1002,19 @@ struct QueryStringWindow : public Window
this->flags = flags;
this->InitNested(WN_QUERY_STRING);
this->UpdateWarningStringSize();
this->parent = parent;
this->SetFocusedWidget(WID_QS_TEXT);
}
void UpdateWarningStringSize()
{
if (this->flags & QSF_PASSWORD) {
assert(this->nested_root->smallest_x > 0);
this->warning_size.width = this->nested_root->current_x - WidgetDimensions::scaled.frametext.Horizontal() - WidgetDimensions::scaled.framerect.Horizontal();
this->warning_size.height = GetStringHeight(STR_WARNING_PASSWORD_SECURITY, this->warning_size.width);
this->warning_size.height += WidgetDimensions::scaled.frametext.Vertical() + WidgetDimensions::scaled.framerect.Vertical();
} else {
this->warning_size = Dimension{ 0, 0 };
}
this->ReInit();
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
if (widget == WID_QS_DEFAULT && (this->flags & QSF_ENABLE_DEFAULT) == 0) {
/* We don't want this widget to show! */
fill->width = 0;
resize->width = 0;
size->width = 0;
}
if (widget == WID_QS_WARNING) {
*size = this->warning_size;
}
}
void DrawWidget(const Rect &r, WidgetID widget) const override
{
if (widget != WID_QS_WARNING) return;
if (this->flags & QSF_PASSWORD) {
DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.framerect).Shrink(WidgetDimensions::scaled.frametext),
STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
fill.width = 0;
resize.width = 0;
size.width = 0;
}
}
@@ -1082,7 +1055,7 @@ struct QueryStringWindow : public Window
if (!this->editbox.handled && this->parent != nullptr) {
Window *parent = this->parent;
this->parent = nullptr; // so parent doesn't try to close us again
parent->OnQueryTextFinished(nullptr);
parent->OnQueryTextFinished(std::nullopt);
}
this->Window::Close();
}
@@ -1094,9 +1067,8 @@ static constexpr NWidgetPart _nested_query_string_widgets[] = {
NWidget(WWT_CAPTION, COLOUR_GREY, WID_QS_CAPTION), SetDataTip(STR_JUST_STRING, STR_NULL), SetTextStyle(TC_WHITE),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QS_TEXT), SetMinimalSize(256, 12), SetFill(1, 1), SetPadding(2, 2, 2, 2),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QS_TEXT), SetMinimalSize(256, 0), SetFill(1, 0), SetPadding(2, 2, 2, 2),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, WID_QS_WARNING), EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_DEFAULT), SetMinimalSize(87, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_DEFAULT, STR_NULL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_CANCEL), SetMinimalSize(86, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
@@ -1104,11 +1076,11 @@ static constexpr NWidgetPart _nested_query_string_widgets[] = {
EndContainer(),
};
static WindowDesc _query_string_desc(__FILE__, __LINE__,
static WindowDesc _query_string_desc(
WDP_CENTER, nullptr, 0, 0,
WC_QUERY_STRING, WC_NONE,
0,
std::begin(_nested_query_string_widgets), std::end(_nested_query_string_widgets)
_nested_query_string_widgets
);
/**
@@ -1125,7 +1097,7 @@ void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *paren
assert(parent != nullptr);
CloseWindowByClass(WC_QUERY_STRING);
new QueryStringWindow(str, caption, ((flags & QSF_LEN_IN_CHARS) ? MAX_CHAR_LENGTH : 1) * maxsize, maxsize, &_query_string_desc, parent, afilter, flags);
new QueryStringWindow(str, caption, ((flags & QSF_LEN_IN_CHARS) ? MAX_CHAR_LENGTH : 1) * maxsize, maxsize, _query_string_desc, parent, afilter, flags);
}
/**
@@ -1133,10 +1105,10 @@ void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *paren
*/
struct QueryWindow : public Window {
QueryCallbackProc *proc; ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise
std::vector<StringParameterBackup> params; ///< local copy of #_global_string_params
std::vector<StringParameterData> params; ///< local copy of #_global_string_params
StringID message; ///< message shown for query window
QueryWindow(WindowDesc *desc, StringID caption, StringID message, Window *parent, QueryCallbackProc *callback) : Window(desc)
QueryWindow(WindowDesc &desc, StringID caption, StringID message, Window *parent, QueryCallbackProc *callback) : Window(desc)
{
/* Create a backup of the variadic arguments to strings because it will be
* overridden pretty often. We will copy these back for drawing */
@@ -1174,11 +1146,11 @@ struct QueryWindow : public Window {
}
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
if (widget != WID_Q_TEXT) return;
*size = GetStringMultiLineBoundingBox(this->message, *size);
size = GetStringMultiLineBoundingBox(this->message, size);
}
void DrawWidget(const Rect &r, WidgetID widget) const override
@@ -1247,11 +1219,11 @@ static constexpr NWidgetPart _nested_query_widgets[] = {
EndContainer(),
};
static WindowDesc _query_desc(__FILE__, __LINE__,
static WindowDesc _query_desc(
WDP_CENTER, nullptr, 0, 0,
WC_CONFIRM_POPUP_QUERY, WC_NONE,
WDF_MODAL,
std::begin(_nested_query_widgets), std::end(_nested_query_widgets)
_nested_query_widgets
);
/**
@@ -1278,7 +1250,7 @@ void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallback
break;
}
QueryWindow *q = new QueryWindow(&_query_desc, caption, message, parent, callback);
QueryWindow *q = new QueryWindow(_query_desc, caption, message, parent, callback);
if (focus) SetFocusedWindow(q);
}
@@ -1287,7 +1259,7 @@ void GuiPrepareTooltipsExtra(Window *parent){
const Point p = GetTileBelowCursor();
TileIndex tile = (p.x == -1 ? INVALID_TILE : TileVirtXY(p.x, p.y));
if (_cursor.sprite_seq[0].sprite == SPR_CURSOR_QUERY) {
if (_cursor.sprites[0].image.sprite == SPR_CURSOR_QUERY) {
// Land info tool active
citymania::ShowLandInfo(tile);
return;