Merge remote-tracking branch 'upstream/master'

This commit is contained in:
dP
2025-06-14 17:01:17 +05:00
1132 changed files with 59429 additions and 52888 deletions
+31 -30
View File
@@ -135,14 +135,14 @@ bool SignList::match_case = false;
std::string SignList::default_name;
/** Enum referring to the Hotkeys in the sign list window */
enum SignListHotkeys {
enum SignListHotkeys : int32_t {
SLHK_FOCUS_FILTER_BOX, ///< Focus the edit box for editing the filter string
};
struct SignListWindow : Window, SignList {
QueryString filter_editbox; ///< Filter editbox;
int text_offset; ///< Offset of the sign text relative to the left edge of the WID_SIL_LIST widget.
Scrollbar *vscroll;
int text_offset = 0; ///< Offset of the sign text relative to the left edge of the WID_SIL_LIST widget.
Scrollbar *vscroll = nullptr;
SignListWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc), filter_editbox(MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS)
{
@@ -219,8 +219,7 @@ struct SignListWindow : Window, SignList {
if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, icon_left, tr.top + sprite_offset_y);
SetDParam(0, si->index);
DrawString(tr.left, tr.right, tr.top + text_offset_y, STR_SIGN_NAME, TC_YELLOW);
DrawString(tr.left, tr.right, tr.top + text_offset_y, GetString(STR_SIGN_NAME, si->index), TC_YELLOW);
tr.top += this->resize.step_height;
}
break;
@@ -228,9 +227,11 @@ struct SignListWindow : Window, SignList {
}
}
void SetStringParameters(WidgetID widget) const override
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
{
if (widget == WID_SIL_CAPTION) SetDParam(0, this->vscroll->GetCount());
if (widget == WID_SIL_CAPTION) return GetString(STR_SIGN_LIST_CAPTION, this->vscroll->GetCount());
return this->Window::GetWidgetString(widget, stringid);
}
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
@@ -271,8 +272,7 @@ struct SignListWindow : Window, SignList {
}
case WID_SIL_CAPTION:
SetDParamMaxValue(0, Sign::GetPoolSize(), 3);
size = GetStringBoundingBox(STR_SIGN_LIST_CAPTION);
size = GetStringBoundingBox(GetString(STR_SIGN_LIST_CAPTION, GetParamMaxValue(Sign::GetPoolSize(), 3)));
size.height += padding.height;
size.width += padding.width;
break;
@@ -296,7 +296,7 @@ struct SignListWindow : Window, SignList {
void OnEditboxChanged(WidgetID widget) override
{
if (widget == WID_SIL_FILTER_TEXT) this->SetFilterString(this->filter_editbox.text.buf);
if (widget == WID_SIL_FILTER_TEXT) this->SetFilterString(this->filter_editbox.text.GetText());
}
void BuildSortSignList()
@@ -354,7 +354,7 @@ struct SignListWindow : Window, SignList {
static constexpr NWidgetPart _nested_sign_list_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_SIL_CAPTION), SetDataTip(STR_SIGN_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_SIL_CAPTION),
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
@@ -366,9 +366,9 @@ static constexpr NWidgetPart _nested_sign_list_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PANEL, COLOUR_BROWN), SetFill(1, 1),
NWidget(WWT_EDITBOX, COLOUR_BROWN, WID_SIL_FILTER_TEXT), SetMinimalSize(80, 0), SetResize(1, 0), SetFill(1, 0), SetPadding(2, 2, 2, 2),
SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
SetStringTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
EndContainer(),
NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_SIL_FILTER_MATCH_CASE_BTN), SetDataTip(STR_SIGN_LIST_MATCH_CASE, STR_SIGN_LIST_MATCH_CASE_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_SIL_FILTER_MATCH_CASE_BTN), SetStringTip(STR_SIGN_LIST_MATCH_CASE, STR_SIGN_LIST_MATCH_CASE_TOOLTIP),
EndContainer(),
EndContainer(),
NWidget(NWID_VERTICAL),
@@ -381,7 +381,7 @@ static constexpr NWidgetPart _nested_sign_list_widgets[] = {
static WindowDesc _sign_list_desc(
WDP_AUTO, "list_signs", 358, 138,
WC_SIGN_LIST, WC_NONE,
0,
{},
_nested_sign_list_widgets,
&SignListWindow::hotkeys
);
@@ -411,7 +411,7 @@ static bool RenameSign(SignID index, const char *text)
struct SignWindow : Window, SignList {
QueryString name_editbox;
SignID cur_sign;
SignID cur_sign{};
SignWindow(WindowDesc &desc, const Sign *si) : Window(desc), name_editbox(MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS)
{
@@ -430,8 +430,7 @@ struct SignWindow : Window, SignList {
{
/* Display an empty string when the sign hasn't been edited yet */
if (!si->name.empty()) {
SetDParam(0, si->index);
this->name_editbox.text.Assign(STR_SIGN_NAME);
this->name_editbox.text.Assign(GetString(STR_SIGN_NAME, si->index));
} else {
this->name_editbox.text.DeleteAll();
}
@@ -469,12 +468,14 @@ struct SignWindow : Window, SignList {
return next ? this->signs.front() : this->signs.back();
}
void SetStringParameters(WidgetID widget) const override
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
{
switch (widget) {
case WID_QES_CAPTION:
SetDParam(0, this->name_editbox.caption);
break;
return GetString(this->name_editbox.caption);
default:
return this->Window::GetWidgetString(widget, stringid);
}
}
@@ -515,7 +516,7 @@ struct SignWindow : Window, SignList {
break;
case WID_QES_OK:
if (RenameSign(this->cur_sign, this->name_editbox.text.buf)) break;
if (RenameSign(this->cur_sign, this->name_editbox.text.GetText())) break;
[[fallthrough]];
case WID_QES_CANCEL:
@@ -528,26 +529,26 @@ struct SignWindow : Window, SignList {
static constexpr NWidgetPart _nested_query_sign_edit_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_QES_CAPTION), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_QES_LOCATION), SetAspect(WidgetDimensions::ASPECT_LOCATION), SetDataTip(SPR_GOTO_LOCATION, STR_EDIT_SIGN_LOCATION_TOOLTIP),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_QES_CAPTION), SetTextStyle(TC_WHITE),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_QES_LOCATION), SetAspect(WidgetDimensions::ASPECT_LOCATION), SetSpriteTip(SPR_GOTO_LOCATION, STR_EDIT_SIGN_LOCATION_TOOLTIP),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QES_TEXT), SetMinimalSize(256, 0), SetDataTip(STR_EDIT_SIGN_SIGN_OSKTITLE, STR_NULL), SetPadding(2, 2, 2, 2),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QES_TEXT), SetMinimalSize(256, 0), SetStringTip(STR_EDIT_SIGN_SIGN_OSKTITLE), SetPadding(2, 2, 2, 2),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_QES_OK), SetMinimalSize(61, 12), SetDataTip(STR_BUTTON_OK, STR_NULL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_QES_CANCEL), SetMinimalSize(60, 12), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_QES_DELETE), SetMinimalSize(60, 12), SetDataTip(STR_TOWN_VIEW_DELETE_BUTTON, STR_NULL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_QES_OK), SetMinimalSize(61, 12), SetStringTip(STR_BUTTON_OK),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_QES_CANCEL), SetMinimalSize(60, 12), SetStringTip(STR_BUTTON_CANCEL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_QES_DELETE), SetMinimalSize(60, 12), SetStringTip(STR_TOWN_VIEW_DELETE_BUTTON),
NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), EndContainer(),
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_QES_PREVIOUS), SetMinimalSize(11, 12), SetDataTip(AWV_DECREASE, STR_EDIT_SIGN_PREVIOUS_SIGN_TOOLTIP),
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_QES_NEXT), SetMinimalSize(11, 12), SetDataTip(AWV_INCREASE, STR_EDIT_SIGN_NEXT_SIGN_TOOLTIP),
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_QES_PREVIOUS), SetMinimalSize(11, 12), SetArrowWidgetTypeTip(AWV_DECREASE, STR_EDIT_SIGN_PREVIOUS_SIGN_TOOLTIP),
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_QES_NEXT), SetMinimalSize(11, 12), SetArrowWidgetTypeTip(AWV_INCREASE, STR_EDIT_SIGN_NEXT_SIGN_TOOLTIP),
EndContainer(),
};
static WindowDesc _query_sign_edit_desc(
WDP_CENTER, nullptr, 0, 0,
WC_QUERY_STRING, WC_NONE,
WDF_CONSTRUCTION,
WindowDefaultFlag::Construction,
_nested_query_sign_edit_widgets
);