Changeset - r28353:bfc4ab63f376
[Not reviewed]
master
! ! !
Peter Nelson - 11 months ago 2023-12-29 19:11:59
peter1138@openttd.org
Codechange: Replace mishmash of types for widget index with WidgetID.

Indices were stored as int, but often passed around as uint/uint8_t and casts.

Now they should all use WidgetID.
56 files changed:
0 comments (0 inline, 0 general)
src/ai/ai_gui.cpp
Show inline comments
 
@@ -112,26 +112,26 @@ struct AIConfigWindow : public Window {
 
	{
 
		CloseWindowByClass(WC_SCRIPT_LIST);
 
		CloseWindowByClass(WC_SCRIPT_SETTINGS);
 
		this->Window::Close();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_AIC_NUMBER:
 
				SetDParam(0, GetGameSettings().difficulty.max_no_competitors);
 
				break;
 

	
 
			case WID_AIC_INTERVAL:
 
				SetDParam(0, GetGameSettings().difficulty.competitors_interval);
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_AIC_DECREASE_NUMBER:
 
			case WID_AIC_INCREASE_NUMBER:
 
			case WID_AIC_DECREASE_INTERVAL:
 
			case WID_AIC_INCREASE_INTERVAL:
 
@@ -162,13 +162,13 @@ struct AIConfigWindow : public Window {
 
		for (CompanyID cid = COMPANY_FIRST; cid < (CompanyID)max_slot && cid < MAX_COMPANIES; cid++) {
 
			if (Company::IsValidHumanID(cid)) max_slot++;
 
		}
 
		return slot < max_slot;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_AIC_LIST: {
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.matrix);
 
				for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < MAX_COMPANIES; i++) {
 
					StringID text;
 
@@ -187,13 +187,13 @@ struct AIConfigWindow : public Window {
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget >= WID_AIC_TEXTFILE && widget < WID_AIC_TEXTFILE + TFT_CONTENT_END) {
 
			if (this->selected_slot == INVALID_COMPANY || AIConfig::GetConfig(this->selected_slot) == nullptr) return;
 

	
 
			ShowScriptTextfileWindow((TextfileType)(widget - WID_AIC_TEXTFILE), this->selected_slot);
 
			return;
src/airport_gui.cpp
Show inline comments
 
@@ -115,13 +115,13 @@ struct BuildAirToolbarWindow : Window {
 
			this->GetWidget<NWidgetCore>(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
 
		} else {
 
			this->GetWidget<NWidgetCore>(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_AT_AIRPORT:
 
				if (HandlePlacePushButton(this, WID_AT_AIRPORT, SPR_CURSOR_AIRPORT, HT_RECT)) {
 
					ShowBuildAirportPicker(this);
 
					this->last_user_action = widget;
 
@@ -288,13 +288,13 @@ public:
 
	void Close([[maybe_unused]] int data = 0) override
 
	{
 
		CloseWindowById(WC_SELECT_STATION, 0);
 
		this->PickerWindowBase::Close();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_AP_CLASS_DROPDOWN:
 
				SetDParam(0, AirportClass::Get(_selected_airport_class)->name);
 
				break;
 

	
 
@@ -313,13 +313,13 @@ public:
 
				break;
 

	
 
			default: break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_AP_CLASS_DROPDOWN: {
 
				Dimension d = {0, 0};
 
				for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
 
					d = maxdim(d, GetStringBoundingBox(AirportClass::Get((AirportClassID)i)->name));
 
@@ -374,13 +374,13 @@ public:
 
				break;
 

	
 
			default: break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_AP_AIRPORT_LIST: {
 
				Rect row = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.bevel);
 
				Rect text = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.matrix);
 
				AirportClass *apclass = AirportClass::Get(_selected_airport_class);
 
@@ -484,13 +484,13 @@ public:
 

	
 
			int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
 
			if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_AP_CLASS_DROPDOWN:
 
				ShowDropDownList(this, BuildAirportClassDropDown(), _selected_airport_class, WID_AP_CLASS_DROPDOWN);
 
				break;
 

	
 
@@ -559,13 +559,13 @@ public:
 
			}
 
		}
 
		/* If all airports are unavailable, select nothing. */
 
		this->SelectOtherAirport(-1);
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		if (widget == WID_AP_CLASS_DROPDOWN) {
 
			_selected_airport_class = (AirportClassID)index;
 
			this->vscroll->SetCount(AirportClass::Get(_selected_airport_class)->GetSpecCount());
 
			this->SelectFirstAvailableAirport(false);
 
		}
src/autoreplace_gui.cpp
Show inline comments
 
@@ -312,13 +312,13 @@ public:
 
		this->sort_criteria = _engine_sort_last_criteria[vehicletype];
 
		this->descending_sort_order = _engine_sort_last_order[vehicletype];
 
		this->owner = _local_company;
 
		this->sel_group = id_g;
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_RV_SORT_ASCENDING_DESCENDING: {
 
				Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
 
				d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
 
				d.height += padding.height;
 
@@ -399,13 +399,13 @@ public:
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_RV_CAPTION:
 
				SetDParam(0, STR_REPLACE_VEHICLE_TRAIN + this->window_number);
 
				switch (this->sel_group) {
 
					case ALL_GROUP:
 
@@ -454,13 +454,13 @@ public:
 
			case WID_RV_ROAD_TYPE_DROPDOWN:
 
				SetDParam(0, this->sel_roadtype == INVALID_ROADTYPE ? STR_REPLACE_ALL_ROADTYPE : GetRoadTypeInfo(this->sel_roadtype)->strings.replace_text);
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_RV_SORT_ASCENDING_DESCENDING:
 
				this->DrawSortButtonState(WID_RV_SORT_ASCENDING_DESCENDING, this->descending_sort_order ? SBS_DOWN : SBS_UP);
 
				break;
 

	
 
@@ -538,13 +538,13 @@ public:
 
				this->ReInit();
 
				return;
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_RV_SORT_ASCENDING_DESCENDING:
 
				this->descending_sort_order ^= true;
 
				_engine_sort_last_order[this->window_number] = this->descending_sort_order;
 
				this->engines[1].ForceRebuild();
 
@@ -652,13 +652,13 @@ public:
 
				this->SetDirty();
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_RV_SORT_DROPDOWN:
 
				if (this->sort_criteria != index) {
 
					this->sort_criteria = index;
 
					_engine_sort_last_criteria[this->window_number] = this->sort_criteria;
 
@@ -694,13 +694,13 @@ public:
 
			case WID_RV_START_REPLACE:
 
				this->ReplaceClick_StartReplace(index != 0);
 
				break;
 
		}
 
	}
 

	
 
	bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override
 
	bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override
 
	{
 
		if (widget != WID_RV_TRAIN_WAGONREMOVE_TOGGLE) return false;
 

	
 
		if (Group::IsValidID(this->sel_group)) {
 
			SetDParam(0, STR_REPLACE_REMOVE_WAGON_HELP);
 
			GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_GROUP_HELP, close_cond, 1);
src/bootstrap_gui.cpp
Show inline comments
 
@@ -54,13 +54,13 @@ public:
 
	{
 
		this->InitNested(0);
 
		CLRBITS(this->flags, WF_WHITE_BORDER);
 
		ResizeWindow(this, _screen.width, _screen.height);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int) const override
 
	void DrawWidget(const Rect &r, WidgetID) const override
 
	{
 
		GfxFillRect(r.left, r.top, r.right, r.bottom, 4, FILLRECT_OPAQUE);
 
		GfxFillRect(r.left, r.top, r.right, r.bottom, 0, FILLRECT_CHECKER);
 
	}
 
};
 

	
 
@@ -94,29 +94,29 @@ public:
 
	void Close([[maybe_unused]] int data = 0) override
 
	{
 
		_exit_game = true;
 
		this->Window::Close();
 
	}
 

	
 
	void UpdateWidgetSize(int 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_BEM_MESSAGE) {
 
			*size = GetStringBoundingBox(STR_MISSING_GRAPHICS_ERROR);
 
			size->width += WidgetDimensions::scaled.frametext.Horizontal();
 
			size->height += WidgetDimensions::scaled.frametext.Vertical();
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget == WID_BEM_MESSAGE) {
 
			DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.frametext), STR_MISSING_GRAPHICS_ERROR, TC_FROMSTRING, SA_CENTER);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget == WID_BEM_QUIT) {
 
			_exit_game = true;
 
		}
 
	}
 
};
 
@@ -208,13 +208,13 @@ public:
 
	void Close([[maybe_unused]] int data = 0) override
 
	{
 
		_network_content_client.RemoveCallback(this);
 
		this->Window::Close();
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		/* We cache the button size. This is safe as no reinit can happen here. */
 
		if (this->button_size.width == 0) {
 
			this->button_size = maxdim(GetStringBoundingBox(STR_MISSING_GRAPHICS_YES_DOWNLOAD), GetStringBoundingBox(STR_MISSING_GRAPHICS_NO_QUIT));
 
			this->button_size.width += WidgetDimensions::scaled.frametext.Horizontal();
 
			this->button_size.height += WidgetDimensions::scaled.frametext.Vertical();
 
@@ -231,20 +231,20 @@ public:
 
			case WID_BAFD_NO:
 
				*size = this->button_size;
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_BAFD_QUESTION) return;
 

	
 
		DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.frametext), STR_MISSING_GRAPHICS_SET_MESSAGE, TC_FROMSTRING, SA_CENTER);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_BAFD_YES:
 
				/* We got permission to connect! Yay! */
 
				_network_content_client.Connect();
 
				break;
src/bridge_gui.cpp
Show inline comments
 
@@ -171,13 +171,13 @@ public:
 

	
 
	~BuildBridgeWindow()
 
	{
 
		this->last_sorting = this->bridges.GetListing();
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_BBS_DROPDOWN_ORDER: {
 
				Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
 
				d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
 
				d.height += padding.height;
 
@@ -218,13 +218,13 @@ public:
 
		Point corner; // point of the top left corner of the window.
 
		corner.y = Clamp(_cursor.pos.y - list->pos_y - 5, GetMainViewTop(), GetMainViewBottom() - sm_height);
 
		corner.x = Clamp(_cursor.pos.x - list->pos_x - 5, 0, _screen.width - sm_width);
 
		return corner;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_BBS_DROPDOWN_ORDER:
 
				this->DrawSortButtonState(widget, this->bridges.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
 
				break;
 

	
 
@@ -252,13 +252,13 @@ public:
 
			this->Close();
 
			return ES_HANDLED;
 
		}
 
		return ES_NOT_HANDLED;
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			default: break;
 
			case WID_BBS_BRIDGE_LIST: {
 
				auto it = this->vscroll->GetScrolledItemFromWidget(this->bridges, pt.y, this, WID_BBS_BRIDGE_LIST);
 
				if (it != this->bridges.end()) {
 
@@ -276,13 +276,13 @@ public:
 
			case WID_BBS_DROPDOWN_CRITERIA:
 
				ShowDropDownMenu(this, this->sorter_names, this->bridges.SortType(), WID_BBS_DROPDOWN_CRITERIA, 0, 0);
 
				break;
 
		}
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		if (widget == WID_BBS_DROPDOWN_CRITERIA && this->bridges.SortType() != index) {
 
			this->bridges.SetSortType(index);
 

	
 
			this->SortBridgeList();
 
		}
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1583,13 +1583,13 @@ struct BuildVehicleWindow : Window {
 
			list.push_back(std::make_unique<DropDownListIconItem>(d, cs->GetCargoIcon(), PAL_NONE, cs->name, cs->Index(), false));
 
		}
 

	
 
		return list;
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_BV_SORT_ASCENDING_DESCENDING:
 
				this->descending_sort_order ^= true;
 
				_engine_sort_last_order[this->vehicle_type] = this->descending_sort_order;
 
				this->eng_list.ForceRebuild();
 
@@ -1704,13 +1704,13 @@ struct BuildVehicleWindow : Window {
 
			this->sort_criteria = 0;
 
			_engine_sort_last_criteria[VEH_ROAD] = 0;
 
		}
 
		this->eng_list.ForceRebuild();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_BV_CAPTION:
 
				if (this->vehicle_type == VEH_TRAIN && !this->listview_mode) {
 
					const RailTypeInfo *rti = GetRailTypeInfo(this->filter.railtype);
 
					SetDParam(0, rti->strings.build_caption);
 
@@ -1739,13 +1739,13 @@ struct BuildVehicleWindow : Window {
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_BV_LIST:
 
				resize->height = GetEngineListHeight(this->vehicle_type);
 
				size->height = 3 * resize->height;
 
				size->width = std::max(size->width, GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_left + GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_right + 165) + padding.width;
 
@@ -1780,13 +1780,13 @@ struct BuildVehicleWindow : Window {
 
				size->width += padding.width;
 
				size->height += padding.height;
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_BV_LIST:
 
				DrawEngineList(
 
					this->vehicle_type,
 
					r,
 
@@ -1838,13 +1838,13 @@ struct BuildVehicleWindow : Window {
 
	{
 
		if (str == nullptr) return;
 

	
 
		Command<CMD_RENAME_ENGINE>::Post(STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type, this->rename_engine, str);
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_BV_SORT_DROPDOWN:
 
				if (this->sort_criteria != index) {
 
					this->sort_criteria = index;
 
					_engine_sort_last_criteria[this->vehicle_type] = this->sort_criteria;
 
@@ -1868,13 +1868,13 @@ struct BuildVehicleWindow : Window {
 

	
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_BV_LIST);
 
	}
 

	
 
	void OnEditboxChanged(int wid) override
 
	void OnEditboxChanged(WidgetID wid) override
 
	{
 
		if (wid == WID_BV_FILTER) {
 
			this->string_filter.SetFilterTerm(this->vehicle_editbox.text.buf);
 
			this->InvalidateData();
 
		}
 
	}
src/cheat_gui.cpp
Show inline comments
 
@@ -233,13 +233,13 @@ struct CheatWindow : Window {
 
	void OnInit() override
 
	{
 
		this->box = maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED));
 
		this->icon = GetSpriteSize(SPR_COMPANY_ICON);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_C_PANEL) return;
 

	
 
		const Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 
		int y = ir.top;
 

	
 
@@ -295,13 +295,13 @@ struct CheatWindow : Window {
 
			DrawString(text_left, text_right, y + text_y_offset, ce->str);
 

	
 
			y += this->line_height;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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_C_PANEL) return;
 

	
 
		uint width = 0;
 
		for (int i = 0; i != lengthof(_cheats_ui); i++) {
 
			const CheatEntry *ce = &_cheats_ui[i];
 
@@ -341,13 +341,13 @@ struct CheatWindow : Window {
 
		this->line_height = std::max<uint>(this->line_height, GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.framerect.Vertical();
 

	
 
		size->width = width + WidgetDimensions::scaled.hsep_wide * 4 + this->box.width + SETTING_BUTTON_WIDTH /* stuff on the left */ + WidgetDimensions::scaled.hsep_wide * 2 /* extra spacing on right */;
 
		size->height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lengthof(_cheats_ui);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget != WID_C_PANEL) return;
 

	
 
		Rect r = this->GetWidget<NWidgetBase>(WID_C_PANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
 
		uint btn = (pt.y - r.top) / this->line_height;
 
		uint x = pt.x - r.left;
src/company_gui.cpp
Show inline comments
 
@@ -339,13 +339,13 @@ struct CompanyFinancesWindow : Window {
 
		this->SetupWidgets();
 
		this->FinishInitNested(company);
 

	
 
		this->owner = (Owner)this->window_number;
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_CF_CAPTION:
 
				SetDParam(0, (CompanyID)this->window_number);
 
				SetDParam(1, (CompanyID)this->window_number);
 
				break;
 
@@ -380,13 +380,13 @@ struct CompanyFinancesWindow : Window {
 
			case WID_CF_REPAY_LOAN:
 
				SetDParam(0, LOAN_INTERVAL);
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_CF_EXPS_CATEGORY:
 
				size->width  = GetMaxCategoriesWidth();
 
				size->height = GetTotalCategoriesHeight();
 
				break;
 
@@ -407,13 +407,13 @@ struct CompanyFinancesWindow : Window {
 
			case WID_CF_INTEREST_RATE:
 
				size->height = GetCharacterHeight(FS_NORMAL);
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_CF_EXPS_CATEGORY:
 
				DrawCategories(r);
 
				break;
 

	
 
@@ -476,13 +476,13 @@ struct CompanyFinancesWindow : Window {
 
			this->SetWidgetDisabledState(WID_CF_REPAY_LOAN, company != _local_company || c->current_loan == 0); // Repay button only shows when there is any more money to repay.
 
		}
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_CF_TOGGLE_SIZE: // toggle size
 
				this->small = !this->small;
 
				this->SetupWidgets();
 
				if (this->IsShaded()) {
 
@@ -769,13 +769,13 @@ public:
 
				this->vscroll->SetPosition(i - this->vscroll->GetCapacity() / 2);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_SCL_SPACER_DROPDOWN: {
 
				/* The matrix widget below needs enough room to print all the schemes. */
 
				Dimension d = {0, 0};
 
				for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
 
@@ -835,13 +835,13 @@ public:
 

	
 
		this->BuildGroupList((CompanyID)this->window_number);
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SCL_CAPTION:
 
				SetDParam(0, (CompanyID)this->window_number);
 
				break;
 

	
 
@@ -875,13 +875,13 @@ public:
 
				SetDParam(0, colour);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_SCL_MATRIX) return;
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 

	
 
		/* Coordinates of scheme name column. */
 
@@ -947,13 +947,13 @@ public:
 
				VehicleType vtype = (VehicleType)(this->livery_class - LC_GROUP_RAIL);
 
				DrawString(ir.left, ir.right, y + text_offs, empty_labels[vtype], TC_BLACK);
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			/* Livery Class buttons */
 
			case WID_SCL_CLASS_GENERAL:
 
			case WID_SCL_CLASS_RAIL:
 
			case WID_SCL_CLASS_ROAD:
 
@@ -1026,13 +1026,13 @@ public:
 

	
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_SCL_MATRIX);
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		bool local = (CompanyID)this->window_number == _local_company;
 
		if (!local) return;
 

	
 
		if (index >= COLOUR_END) index = INVALID_COLOUR;
 

	
 
@@ -1365,13 +1365,13 @@ class SelectCompanyManagerFaceWindow : p
 
	 * Set parameters for value of face control buttons.
 
	 *
 
	 * @param widget_index   index of this widget in the window
 
	 * @param val            the value which will be displayed
 
	 * @param is_bool_widget is it a bool button
 
	 */
 
	void SetFaceStringParameters(byte widget_index, uint8_t val, bool is_bool_widget) const
 
	void SetFaceStringParameters(WidgetID widget_index, uint8_t val, bool is_bool_widget) const
 
	{
 
		const NWidgetCore *nwi_widget = this->GetWidget<NWidgetCore>(widget_index);
 
		if (nwi_widget->IsDisabled()) {
 
			SetDParam(0, STR_EMPTY);
 
		} else {
 
			if (is_bool_widget) {
 
@@ -1449,13 +1449,13 @@ public:
 
		number_dim.width = yesno_dim.width - arrows_width;
 

	
 
		this->yesno_dim = yesno_dim;
 
		this->number_dim = number_dim;
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT:
 
				*size = maxdim(*size, GetStringBoundingBox(STR_FACE_EARRING));
 
				*size = maxdim(*size, GetStringBoundingBox(STR_FACE_MOUSTACHE));
 
				break;
 
@@ -1552,13 +1552,13 @@ public:
 
		this->SetWidgetsDisabledState(_cmf_info[CMFV_GLASSES].valid_values[this->ge] < 2 || GetCompanyManagerFaceBits(this->face, CMFV_HAS_GLASSES, this->ge) == 0,
 
				WID_SCMF_GLASSES, WID_SCMF_GLASSES_L, WID_SCMF_GLASSES_R);
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SCMF_HAS_MOUSTACHE_EARRING:
 
				if (this->is_female) { // Only for female faces
 
					this->SetFaceStringParameters(WID_SCMF_HAS_MOUSTACHE_EARRING, GetCompanyManagerFaceBits(this->face, CMFV_HAS_TIE_EARRING, this->ge), true);
 
				} else { // Only for male faces
 
@@ -1613,22 +1613,22 @@ public:
 
			case WID_SCMF_COLLAR:
 
				this->SetFaceStringParameters(WID_SCMF_COLLAR,      GetCompanyManagerFaceBits(this->face, CMFV_COLLAR,      this->ge), false);
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SCMF_FACE:
 
				DrawCompanyManagerFace(this->face, Company::Get((CompanyID)this->window_number)->colour, r);
 
				break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			/* Toggle size, advanced/simple face selection */
 
			case WID_SCMF_TOGGLE_LARGE_SMALL:
 
			case WID_SCMF_TOGGLE_LARGE_SMALL_BUTTON:
 
				this->advanced = !this->advanced;
 
@@ -1875,22 +1875,22 @@ struct CompanyInfrastructureWindow : Win
 
		total += StationMaintenanceCost(c->infrastructure.station);
 
		total += AirportMaintenanceCost(c->index);
 

	
 
		return total;
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_CI_CAPTION:
 
				SetDParam(0, (CompanyID)this->window_number);
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		const Company *c = Company::Get((CompanyID)this->window_number);
 

	
 
		switch (widget) {
 
			case WID_CI_RAIL_DESC: {
 
				uint lines = 1; // Starts at 1 because a line is also required for the section title
 
@@ -2009,13 +2009,13 @@ struct CompanyInfrastructureWindow : Win
 
			SetDParam(0, monthly_cost * 12); // Convert to per year
 
			Rect tr = r.WithWidth(this->total_width, _current_text_dir == TD_RTL);
 
			DrawString(tr.left, tr.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL, TC_FROMSTRING, SA_RIGHT);
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		const Company *c = Company::Get((CompanyID)this->window_number);
 

	
 
		int y = r.top;
 

	
 
		Rect ir = r.Indent(WidgetDimensions::scaled.hsep_indent, _current_text_dir == TD_RTL);
 
@@ -2288,13 +2288,13 @@ struct CompanyWindow : Window
 
			}
 
		}
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_C_FACE:
 
				*size = maxdim(*size, GetScaledSpriteSize(SPR_GRADIENT));
 
				break;
 

	
 
@@ -2416,13 +2416,13 @@ struct CompanyWindow : Window
 
		if (y == r.top) {
 
			/* No String was emited before, so there must be no infrastructure at all. */
 
			DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_NONE);
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		const Company *c = Company::Get((CompanyID)this->window_number);
 
		switch (widget) {
 
			case WID_C_FACE:
 
				DrawCompanyManagerFace(c->face, c->colour, r);
 
				break;
 
@@ -2453,13 +2453,13 @@ struct CompanyWindow : Window
 
					DrawSprite(SPR_LOCK, PAL_NONE, r.left, r.top);
 
				}
 
				break;
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_C_CAPTION:
 
				SetDParam(0, (CompanyID)this->window_number);
 
				SetDParam(1, (CompanyID)this->window_number);
 
				break;
 
@@ -2471,13 +2471,13 @@ struct CompanyWindow : Window
 
			case WID_C_DESC_COMPANY_VALUE:
 
				SetDParam(0, CalculateCompanyValue(Company::Get((CompanyID)this->window_number)));
 
				break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_C_NEW_FACE: DoSelectCompanyManagerFace(this); break;
 

	
 
			case WID_C_COLOUR_SCHEME:
 
				ShowCompanyLiveryWindow((CompanyID)this->window_number, INVALID_GROUP);
 
@@ -2645,13 +2645,13 @@ struct BuyCompanyWindow : Window {
 
		this->InitNested(window_number);
 

	
 
		const Company *c = Company::Get((CompanyID)this->window_number);
 
		this->company_value = hostile_takeover ? CalculateHostileTakeoverValue(c) : c->bankrupt_value;
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_BC_FACE:
 
				*size = GetScaledSpriteSize(SPR_GRADIENT);
 
				break;
 

	
 
@@ -2661,23 +2661,23 @@ struct BuyCompanyWindow : Window {
 
				SetDParam(1, this->company_value);
 
				size->height = GetStringHeight(this->hostile_takeover ? STR_BUY_COMPANY_HOSTILE_TAKEOVER : STR_BUY_COMPANY_MESSAGE, size->width);
 
				break;
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_BC_CAPTION:
 
				SetDParam(0, STR_COMPANY_NAME);
 
				SetDParam(1, Company::Get((CompanyID)this->window_number)->index);
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_BC_FACE: {
 
				const Company *c = Company::Get((CompanyID)this->window_number);
 
				DrawCompanyManagerFace(c->face, c->colour, r);
 
				break;
 
@@ -2690,13 +2690,13 @@ struct BuyCompanyWindow : Window {
 
				DrawStringMultiLine(r.left, r.right, r.top, r.bottom, this->hostile_takeover ? STR_BUY_COMPANY_HOSTILE_TAKEOVER : STR_BUY_COMPANY_MESSAGE, TC_FROMSTRING, SA_CENTER);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_BC_NO:
 
				this->Close();
 
				break;
 

	
src/console_gui.cpp
Show inline comments
 
@@ -268,13 +268,13 @@ struct IConsoleWindow : Window
 
				}
 
				break;
 
		}
 
		return ES_HANDLED;
 
	}
 

	
 
	void InsertTextString(int, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) override
 
	void InsertTextString(WidgetID, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) override
 
	{
 
		if (_iconsole_cmdline.InsertString(str, marked, caret, insert_location, replacement_end)) {
 
			IConsoleWindow::scroll = 0;
 
			IConsoleResetHistoryPos();
 
			this->SetDirty();
 
		}
src/date_gui.cpp
Show inline comments
 
@@ -62,13 +62,13 @@ struct SetDateWindow : Window {
 
	}
 

	
 
	/**
 
	 * Helper function to construct the dropdown.
 
	 * @param widget the dropdown widget to create the dropdown for
 
	 */
 
	void ShowDateDropDown(int widget)
 
	void ShowDateDropDown(WidgetID widget)
 
	{
 
		int selected;
 
		DropDownList list;
 

	
 
		switch (widget) {
 
			default: NOT_REACHED();
 
@@ -96,13 +96,13 @@ struct SetDateWindow : Window {
 
				break;
 
		}
 

	
 
		ShowDropDownList(this, std::move(list), selected, widget);
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		Dimension d = {0, 0};
 
		switch (widget) {
 
			default: return;
 

	
 
			case WID_SD_DAY:
 
@@ -125,22 +125,22 @@ struct SetDateWindow : Window {
 

	
 
		d.width += padding.width;
 
		d.height += padding.height;
 
		*size = d;
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SD_DAY:   SetDParam(0, this->date.day - 1 + STR_DAY_NUMBER_1ST); break;
 
			case WID_SD_MONTH: SetDParam(0, this->date.month + STR_MONTH_JAN); break;
 
			case WID_SD_YEAR:  SetDParam(0, this->date.year); break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_SD_DAY:
 
			case WID_SD_MONTH:
 
			case WID_SD_YEAR:
 
				ShowDateDropDown(widget);
 
@@ -150,13 +150,13 @@ struct SetDateWindow : Window {
 
				if (this->callback != nullptr) this->callback(this, TimerGameCalendar::ConvertYMDToDate(this->date.year, this->date.month, this->date.day), this->callback_data);
 
				this->Close();
 
				break;
 
		}
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_SD_DAY:
 
				this->date.day = index;
 
				break;
 

	
src/depot_gui.cpp
Show inline comments
 
@@ -255,13 +255,13 @@ const Sprite *GetAircraftSprite(EngineID
 

	
 
struct DepotWindow : Window {
 
	VehicleID sel;
 
	VehicleID vehicle_over; ///< Rail vehicle over which another one is dragged, \c INVALID_VEHICLE if none.
 
	VehicleType type;
 
	bool generate_list;
 
	int hovered_widget; ///< Index of the widget being hovered during drag/drop. -1 if no drag is in progress.
 
	WidgetID hovered_widget; ///< Index of the widget being hovered during drag/drop. -1 if no drag is in progress.
 
	VehicleList vehicle_list;
 
	VehicleList wagon_list;
 
	uint unitnumber_digits;
 
	uint num_columns;       ///< Number of columns.
 
	Scrollbar *hscroll;     ///< Only for trains.
 
	Scrollbar *vscroll;
 
@@ -360,13 +360,13 @@ struct DepotWindow : Window {
 

	
 
			SetDParam(0, v->unitnumber);
 
			DrawString(text, STR_JUST_COMMA, (v->max_age - CalendarTime::DAYS_IN_LEAP_YEAR) >= v->age ? TC_BLACK : TC_RED);
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_D_MATRIX) return;
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 

	
 
		/* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */
 
@@ -418,13 +418,13 @@ struct DepotWindow : Window {
 
		for (; num < maxval; num++, ir = ir.Translate(0, this->resize.step_height)) {
 
			const Vehicle *v = this->wagon_list[num - this->vehicle_list.size()];
 
			this->DrawVehicleInDepot(v, ir);
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget != WID_D_CAPTION) return;
 

	
 
		SetDParam(0, this->type);
 
		SetDParam(1, this->GetDepotIndex());
 
	}
 
@@ -650,13 +650,13 @@ struct DepotWindow : Window {
 
	void OnInit() override
 
	{
 
		this->cell_size = GetVehicleImageCellSize(this->type, EIT_IN_DEPOT);
 
		this->flag_size = maxdim(GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED), GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING));
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_D_MATRIX: {
 
				uint min_height = 0;
 

	
 
				if (this->type == VEH_TRAIN) {
 
@@ -754,13 +754,13 @@ struct DepotWindow : Window {
 
			WID_D_RENAME,
 
			WID_D_AUTOREPLACE);
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_D_MATRIX: // List
 
				this->DepotClick(pt.x, pt.y);
 
				break;
 

	
 
@@ -836,13 +836,13 @@ struct DepotWindow : Window {
 
		if (str == nullptr) return;
 

	
 
		/* Do depot renaming */
 
		Command<CMD_RENAME_DEPOT>::Post(STR_ERROR_CAN_T_RENAME_DEPOT, this->GetDepotIndex(), str);
 
	}
 

	
 
	bool OnRightClick([[maybe_unused]] Point pt, int widget) override
 
	bool OnRightClick([[maybe_unused]] Point pt, WidgetID widget) override
 
	{
 
		if (widget != WID_D_MATRIX) return false;
 

	
 
		GetDepotVehiclePtData gdvp = { nullptr, nullptr };
 
		const Vehicle *v = nullptr;
 
		DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp);
 
@@ -971,13 +971,13 @@ struct DepotWindow : Window {
 
			this->SetWidgetLoweredState(this->hovered_widget, false);
 
			this->SetWidgetDirty(this->hovered_widget);
 
			this->hovered_widget = -1;
 
		}
 
	}
 

	
 
	void OnMouseDrag(Point pt, int widget) override
 
	void OnMouseDrag(Point pt, WidgetID widget) override
 
	{
 
		if (this->sel == INVALID_VEHICLE) return;
 
		if (widget != this->hovered_widget) {
 
			if (this->hovered_widget == WID_D_SELL || this->hovered_widget == WID_D_SELL_CHAIN) {
 
				this->SetWidgetLoweredState(this->hovered_widget, false);
 
				this->SetWidgetDirty(this->hovered_widget);
 
@@ -1022,13 +1022,13 @@ struct DepotWindow : Window {
 
		if (this->vehicle_over == new_vehicle_over) return;
 

	
 
		this->vehicle_over = new_vehicle_over;
 
		this->SetWidgetDirty(widget);
 
	}
 

	
 
	void OnDragDrop(Point pt, int widget) override
 
	void OnDragDrop(Point pt, WidgetID widget) override
 
	{
 
		switch (widget) {
 
			case WID_D_MATRIX: {
 
				const Vehicle *v = nullptr;
 
				VehicleID sel = this->sel;
 

	
src/dock_gui.cpp
Show inline comments
 
@@ -145,13 +145,13 @@ struct BuildDocksToolbarWindow : Window 
 
				this->GetWidget<NWidgetCore>(WID_DT_STATION)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP);
 
				this->GetWidget<NWidgetCore>(WID_DT_BUOY)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP);
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_DT_CANAL: // Build canal button
 
				HandlePlacePushButton(this, WID_DT_CANAL, SPR_CURSOR_CANAL, HT_RECT);
 
				break;
 

	
 
@@ -450,13 +450,13 @@ public:
 
		 * (This is the case, if making the window bigger moves the mouse into the window.) */
 
		if (top > r.bottom) {
 
			ResizeWindow(this, 0, top - r.bottom, false);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case BDSW_LT_OFF:
 
			case BDSW_LT_ON:
 
				this->RaiseWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
 
				_settings_client.gui.station_show_coverage = (widget != BDSW_LT_OFF);
 
@@ -526,24 +526,24 @@ public:
 
	{
 
		this->InitNested(TRANSPORT_WATER);
 
		this->LowerWidget(_ship_depot_direction + WID_BDD_X);
 
		UpdateDocksDirection();
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_BDD_X:
 
			case WID_BDD_Y:
 
				size->width  = ScaleGUITrad(96) + WidgetDimensions::scaled.fullbevel.Horizontal();
 
				size->height = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Vertical();
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		DrawPixelInfo tmp_dpi;
 

	
 
		switch (widget) {
 
			case WID_BDD_X:
 
			case WID_BDD_Y: {
 
@@ -561,13 +561,13 @@ public:
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_BDD_X:
 
			case WID_BDD_Y:
 
				this->RaiseWidget(_ship_depot_direction + WID_BDD_X);
 
				_ship_depot_direction = (widget == WID_BDD_X ? AXIS_X : AXIS_Y);
src/engine_gui.cpp
Show inline comments
 
@@ -75,13 +75,13 @@ struct EnginePreviewWindow : Window {
 
		this->InitNested(window_number);
 

	
 
		/* There is no way to recover the window; so disallow closure via DEL; unless SHIFT+DEL */
 
		this->flags |= WF_STICKY;
 
	}
 

	
 
	void UpdateWidgetSize(int 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_EP_QUESTION) return;
 

	
 
		/* Get size of engine sprite, on loan from depot_gui.cpp */
 
		EngineID engine = this->window_number;
 
		EngineImageType image_type = EIT_PURCHASE;
 
@@ -102,13 +102,13 @@ struct EnginePreviewWindow : Window {
 
		SetDParam(0, GetEngineCategoryName(engine));
 
		size->height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size->width) + WidgetDimensions::scaled.vsep_wide + GetCharacterHeight(FS_NORMAL) + this->vehicle_space;
 
		SetDParam(0, engine);
 
		size->height += GetStringHeight(GetEngineInfoString(engine), size->width);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_EP_QUESTION) return;
 

	
 
		EngineID engine = this->window_number;
 
		SetDParam(0, GetEngineCategoryName(engine));
 
		int y = DrawStringMultiLine(r, STR_ENGINE_PREVIEW_MESSAGE, TC_FROMSTRING, SA_HOR_CENTER | SA_TOP) + WidgetDimensions::scaled.vsep_wide;
 
@@ -120,13 +120,13 @@ struct EnginePreviewWindow : Window {
 
		DrawVehicleEngine(r.left, r.right, this->width >> 1, y + this->vehicle_space / 2, engine, GetEnginePalette(engine, _local_company), EIT_PREVIEW);
 

	
 
		y += this->vehicle_space;
 
		DrawStringMultiLine(r.left, r.right, y, r.bottom, GetEngineInfoString(engine), TC_FROMSTRING, SA_CENTER);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_EP_YES:
 
				Command<CMD_WANT_ENGINE_PREVIEW>::Post(this->window_number);
 
				FALLTHROUGH;
 
			case WID_EP_NO:
src/error_gui.cpp
Show inline comments
 
@@ -186,13 +186,13 @@ public:
 
		/* Only start the timeout if the message is not critical. */
 
		if (!this->is_critical) {
 
			this->display_timeout.Reset();
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_EM_MESSAGE: {
 
				CopyInDParam(this->params);
 
				if (this->textref_stack_size > 0) StartTextRefStackUsage(this->textref_stack_grffile, this->textref_stack_size, this->textref_stack);
 

	
 
@@ -254,18 +254,18 @@ public:
 
	void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
 
	{
 
		/* If company gets shut down, while displaying an error about it, remove the error message. */
 
		if (this->face != INVALID_COMPANY && !Company::IsValidID(this->face)) this->Close();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_EM_CAPTION) CopyInDParam(this->params);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_EM_FACE: {
 
				const Company *c = Company::Get(this->face);
 
				DrawCompanyManagerFace(c->face, c->colour, r);
 
				break;
src/fios_gui.cpp
Show inline comments
 
@@ -405,13 +405,13 @@ public:
 
		if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
 
			Command<CMD_PAUSE>::Post(PM_PAUSED_SAVELOAD, false);
 
		}
 
		this->Window::Close();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SL_SORT_BYNAME:
 
			case WID_SL_SORT_BYDATE:
 
				if (((_savegame_sort_order & SORT_BY_NAME) != 0) == (widget == WID_SL_SORT_BYNAME)) {
 
					this->DrawSortButtonState(widget, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP);
 
@@ -558,13 +558,13 @@ public:
 
					if (tr.top > tr.bottom) break;
 
				}
 
			}
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_SL_BACKGROUND:
 
				size->height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height;
 
				break;
 

	
 
@@ -591,13 +591,13 @@ public:
 
			this->OnInvalidateData(SLIWD_FILTER_CHANGES);
 
		}
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_SL_SORT_BYNAME: // Sort save names by name
 
				_savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ?
 
					SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME;
 
				_savegame_sort_dirty = true;
 
@@ -713,13 +713,13 @@ public:
 
				/* Note, this is also called via the OSK; and we need to lower the button. */
 
				this->HandleButtonClick(WID_SL_SAVE_GAME);
 
				break;
 
		}
 
	}
 

	
 
	void OnMouseOver([[maybe_unused]] Point pt, int widget) override
 
	void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override
 
	{
 
		if (widget == WID_SL_DRIVES_DIRECTORIES_LIST) {
 
			auto it = this->vscroll->GetScrolledItemFromWidget(this->display_list, pt.y, this, WID_SL_DRIVES_DIRECTORIES_LIST, WidgetDimensions::scaled.inset.top);
 
			if (it == this->display_list.end()) return;
 

	
 
			/* Get the corresponding non-filtered out item from the list */
 
@@ -870,13 +870,13 @@ public:
 
			case SLIWD_FILTER_CHANGES:
 
				this->BuildDisplayList();
 
				break;
 
		}
 
	}
 

	
 
	void OnEditboxChanged(int wid) override
 
	void OnEditboxChanged(WidgetID wid) override
 
	{
 
		if (wid == WID_SL_FILTER) {
 
			this->string_filter.SetFilterTerm(this->filter_editbox.text.buf);
 
			this->InvalidateData(SLIWD_FILTER_CHANGES);
 
		}
 
	}
src/framerate_gui.cpp
Show inline comments
 
@@ -509,13 +509,13 @@ struct FramerateWindow : Window {
 
			sb->SetCount(this->num_active);
 
			sb->SetCapacity(std::min(this->num_displayed, this->num_active));
 
			this->ReInit();
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_FRW_CAPTION:
 
				/* When the window is shaded, the caption shows game loop rate and speed factor */
 
				if (!this->small) break;
 
				SetDParam(0, this->rate_gameloop.strid);
 
@@ -537,13 +537,13 @@ struct FramerateWindow : Window {
 
			case WID_FRW_INFO_DATA_POINTS:
 
				SetDParam(0, NUM_FRAMERATE_POINTS);
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_FRW_RATE_GAMELOOP:
 
				SetDParam(0, STR_FRAMERATE_FPS_GOOD);
 
				SetDParam(1, 999999);
 
				SetDParam(2, 2);
 
@@ -648,13 +648,13 @@ struct FramerateWindow : Window {
 
				drawable--;
 
				if (drawable == 0) break;
 
			}
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_FRW_TIMES_NAMES: {
 
				/* Render a column of titles for performance element names */
 
				const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
 
				uint16_t skip = sb->GetPosition();
 
@@ -690,13 +690,13 @@ struct FramerateWindow : Window {
 
			case WID_FRW_ALLOCSIZE:
 
				DrawElementAllocationsColumn(r);
 
				break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_FRW_TIMES_NAMES:
 
			case WID_FRW_TIMES_CURRENT:
 
			case WID_FRW_TIMES_AVERAGE: {
 
				/* Open time graph windows when clicking detail measurement lines */
 
@@ -762,13 +762,13 @@ struct FrametimeGraphWindow : Window {
 
		this->vertical_scale = TIMESTAMP_PRECISION / 10;
 

	
 
		this->InitNested(number);
 
		this->UpdateScale();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_FGW_CAPTION:
 
				if (this->element < PFE_AI0) {
 
					SetDParam(0, STR_FRAMETIME_CAPTION_GAMELOOP + this->element);
 
				} else {
 
@@ -777,13 +777,13 @@ struct FrametimeGraphWindow : Window {
 
					SetDParamStr(2, GetAIName(this->element - PFE_AI0));
 
				}
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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_FGW_GRAPH) {
 
			SetDParam(0, 100);
 
			Dimension size_ms_label = GetStringBoundingBox(STR_FRAMERATE_GRAPH_MILLISECONDS);
 
			SetDParam(0, 100);
 
			Dimension size_s_label = GetStringBoundingBox(STR_FRAMERATE_GRAPH_SECONDS);
 
@@ -894,13 +894,13 @@ struct FrametimeGraphWindow : Window {
 
	{
 
		T dst_diff = dst_max - dst_min;
 
		T src_diff = src_max - src_min;
 
		return (value - src_min) * dst_diff / src_diff + dst_min;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget == WID_FGW_GRAPH) {
 
			const TimingMeasurement *durations  = _pf_data[this->element].durations;
 
			const TimingMeasurement *timestamps = _pf_data[this->element].timestamps;
 
			int point = _pf_data[this->element].prev_index;
 

	
src/game/game_gui.cpp
Show inline comments
 
@@ -132,13 +132,13 @@ struct GSConfigWindow : public Window {
 
			}
 
		}
 

	
 
		this->vscroll->SetCount(this->visible_settings.size());
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_GSC_SETTINGS:
 
				this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height;
 
				resize->width = 1;
 
				resize->height = this->line_height;
 
@@ -158,13 +158,13 @@ struct GSConfigWindow : public Window {
 
	 */
 
	static bool IsEditable()
 
	{
 
		return _game_mode != GM_NORMAL || Game::GetInstance() != nullptr;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_GSC_GSLIST: {
 
				StringID text = STR_AI_CONFIG_NONE;
 

	
 
				if (GameConfig::GetConfig()->GetInfo() != nullptr) {
 
@@ -240,13 +240,13 @@ struct GSConfigWindow : public Window {
 
			this->closing_dropdown = false;
 
			this->clicked_dropdown = false;
 
		}
 
		this->DrawWidgets();
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget >= WID_GSC_TEXTFILE && widget < WID_GSC_TEXTFILE + TFT_CONTENT_END) {
 
			if (GameConfig::GetConfig() == nullptr) return;
 

	
 
			ShowScriptTextfileWindow((TextfileType)(widget - WID_GSC_TEXTFILE), (CompanyID)OWNER_DEITY);
 
			return;
 
@@ -370,20 +370,20 @@ struct GSConfigWindow : public Window {
 
	{
 
		if (StrEmpty(str)) return;
 
		int32_t value = atoi(str);
 
		SetValue(value);
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		if (widget != WID_GSC_SETTING_DROPDOWN) return;
 
		assert(this->clicked_dropdown);
 
		SetValue(index);
 
	}
 

	
 
	void OnDropdownClose(Point, int widget, int, bool) override
 
	void OnDropdownClose(Point, WidgetID widget, int, bool) override
 
	{
 
		if (widget != WID_GSC_SETTING_DROPDOWN) return;
 
		/* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
 
		 * the same dropdown button was clicked again, and then not open the dropdown again.
 
		 * So, we only remember that it was closed, and process it on the next OnPaint, which is
 
		 * after OnClick. */
src/genworld_gui.cpp
Show inline comments
 
@@ -381,13 +381,13 @@ static const StringID _num_towns[]   = {
 
static const StringID _num_inds[]    = {STR_FUNDING_ONLY, STR_MINIMAL, STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM, INVALID_STRING_ID};
 
static const StringID _variety[]     = {STR_VARIETY_NONE, STR_VARIETY_VERY_LOW, STR_VARIETY_LOW, STR_VARIETY_MEDIUM, STR_VARIETY_HIGH, STR_VARIETY_VERY_HIGH, INVALID_STRING_ID};
 

	
 
static_assert(lengthof(_num_inds) == ID_END + 1);
 

	
 
struct GenerateLandscapeWindow : public Window {
 
	uint widget_id;
 
	WidgetID widget_id;
 
	uint x;
 
	uint y;
 
	std::string name;
 
	GenerateLandscapeWindowMode mode;
 

	
 
	GenerateLandscapeWindow(WindowDesc *desc, WindowNumber number = 0) : Window(desc)
 
@@ -412,13 +412,13 @@ struct GenerateLandscapeWindow : public 
 
		}
 

	
 
		this->OnInvalidateData();
 
	}
 

	
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_GL_START_DATE_TEXT:      SetDParam(0, TimerGameCalendar::ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); break;
 
			case WID_GL_MAPSIZE_X_PULLDOWN:   SetDParam(0, 1LL << _settings_newgame.game_creation.map_x); break;
 
			case WID_GL_MAPSIZE_Y_PULLDOWN:   SetDParam(0, 1LL << _settings_newgame.game_creation.map_y); break;
 
			case WID_GL_HEIGHTMAP_HEIGHT_TEXT: SetDParam(0, _settings_newgame.game_creation.heightmap_height); break;
 
@@ -567,13 +567,13 @@ struct GenerateLandscapeWindow : public 
 
				_settings_newgame.difficulty.terrain_type = 1;
 
			}
 
		}
 

	
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		Dimension d{0, (uint)GetCharacterHeight(FS_NORMAL)};
 
		const StringID *strs = nullptr;
 
		switch (widget) {
 
			case WID_GL_TEMPERATE: case WID_GL_ARCTIC:
 
			case WID_GL_TROPICAL: case WID_GL_TOYLAND:
 
@@ -666,13 +666,13 @@ struct GenerateLandscapeWindow : public 
 
		}
 
		d.width += padding.width;
 
		d.height += padding.height;
 
		*size = maxdim(*size, d);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_GL_TEMPERATE:
 
			case WID_GL_ARCTIC:
 
			case WID_GL_TROPICAL:
 
			case WID_GL_TOYLAND:
 
@@ -876,13 +876,13 @@ struct GenerateLandscapeWindow : public 
 
			this->RaiseWidgetsWhenLowered(WID_GL_HEIGHTMAP_HEIGHT_DOWN, WID_GL_HEIGHTMAP_HEIGHT_UP, WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_SNOW_COVERAGE_UP, WID_GL_SNOW_COVERAGE_DOWN, WID_GL_DESERT_COVERAGE_UP, WID_GL_DESERT_COVERAGE_DOWN);
 
		} else {
 
			this->RaiseWidgetsWhenLowered(WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_SNOW_COVERAGE_UP, WID_GL_SNOW_COVERAGE_DOWN, WID_GL_DESERT_COVERAGE_UP, WID_GL_DESERT_COVERAGE_DOWN);
 
		}
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_GL_MAPSIZE_X_PULLDOWN:     _settings_newgame.game_creation.map_x = index; break;
 
			case WID_GL_MAPSIZE_Y_PULLDOWN:     _settings_newgame.game_creation.map_y = index; break;
 
			case WID_GL_RIVER_PULLDOWN:         _settings_newgame.game_creation.amount_of_rivers = index; break;
 
			case WID_GL_SMOOTHNESS_PULLDOWN:    _settings_newgame.game_creation.tgen_smoothness = index;  break;
 
@@ -1073,21 +1073,21 @@ void StartNewGameWithoutGUI(uint32_t see
 

	
 
	StartGeneratingLandscape(GLWM_GENERATE);
 
}
 

	
 
struct CreateScenarioWindow : public Window
 
{
 
	uint widget_id;
 
	WidgetID widget_id;
 

	
 
	CreateScenarioWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
 
	{
 
		this->InitNested(window_number);
 
		this->LowerWidget(_settings_newgame.game_creation.landscape + WID_CS_TEMPERATE);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_CS_START_DATE_TEXT:
 
				SetDParam(0, TimerGameCalendar::ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
 
				break;
 

	
 
@@ -1117,13 +1117,13 @@ struct CreateScenarioWindow : public Win
 
		this->SetWidgetLoweredState(WID_CS_TROPICAL,  _settings_newgame.game_creation.landscape == LT_TROPIC);
 
		this->SetWidgetLoweredState(WID_CS_TOYLAND,   _settings_newgame.game_creation.landscape == LT_TOYLAND);
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		StringID str = STR_JUST_INT;
 
		switch (widget) {
 
			case WID_CS_TEMPERATE: case WID_CS_ARCTIC:
 
			case WID_CS_TROPICAL: case WID_CS_TOYLAND:
 
				size->width += WidgetDimensions::scaled.fullbevel.Horizontal();
 
@@ -1150,13 +1150,13 @@ struct CreateScenarioWindow : public Win
 
		Dimension d = GetStringBoundingBox(str);
 
		d.width += padding.width;
 
		d.height += padding.height;
 
		*size = maxdim(*size, d);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_CS_TEMPERATE:
 
			case WID_CS_ARCTIC:
 
			case WID_CS_TROPICAL:
 
			case WID_CS_TOYLAND:
 
@@ -1220,13 +1220,13 @@ struct CreateScenarioWindow : public Win
 

	
 
	void OnTimeout() override
 
	{
 
		this->RaiseWidgetsWhenLowered(WID_CS_START_DATE_DOWN, WID_CS_START_DATE_UP, WID_CS_FLAT_LAND_HEIGHT_DOWN, WID_CS_FLAT_LAND_HEIGHT_UP);
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_CS_MAPSIZE_X_PULLDOWN: _settings_newgame.game_creation.map_x = index; break;
 
			case WID_CS_MAPSIZE_Y_PULLDOWN: _settings_newgame.game_creation.map_y = index; break;
 
		}
 
		this->SetDirty();
 
@@ -1386,13 +1386,13 @@ struct GenerateProgressWindow : public W
 

	
 
	GenerateProgressWindow() : Window(&_generate_progress_desc)
 
	{
 
		this->InitNested();
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_GP_ABORT:
 
				SetMouseCursorBusy(false);
 
				ShowQuery(
 
					STR_GENERATION_ABORT_CAPTION,
 
@@ -1401,13 +1401,13 @@ struct GenerateProgressWindow : public W
 
					AbortGeneratingWorldCallback
 
				);
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_GP_PROGRESS_BAR: {
 
				SetDParamMaxValue(0, 100);
 
				*size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
 
				/* We need some spacing for the 'border' */
 
@@ -1422,13 +1422,13 @@ struct GenerateProgressWindow : public W
 
				}
 
				size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_GP_PROGRESS_BAR: {
 
				/* Draw the % complete with a bar and a text */
 
				DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED);
 
				Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
src/goal_gui.cpp
Show inline comments
 
@@ -48,25 +48,25 @@ struct GoalListWindow : public Window {
 
		this->owner = (Owner)this->window_number;
 
		NWidgetStacked *wi = this->GetWidget<NWidgetStacked>(WID_GOAL_SELECT_BUTTONS);
 
		wi->SetDisplayedPlane(window_number == INVALID_COMPANY ? 1 : 0);
 
		this->OnInvalidateData(0);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget != WID_GOAL_CAPTION) return;
 

	
 
		if (this->window_number == INVALID_COMPANY) {
 
			SetDParam(0, STR_GOALS_SPECTATOR_CAPTION);
 
		} else {
 
			SetDParam(0, STR_GOALS_CAPTION);
 
			SetDParam(1, this->window_number);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_GOAL_GLOBAL_BUTTON:
 
				ShowGoalsList(INVALID_COMPANY);
 
				break;
 

	
 
@@ -165,13 +165,13 @@ struct GoalListWindow : public Window {
 
		/* Count the 'none' lines. */
 
		if (num == 0) num = 1;
 

	
 
		return num;
 
	}
 

	
 
	void UpdateWidgetSize(int 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_GOAL_LIST) return;
 
		Dimension d = GetStringBoundingBox(STR_GOALS_NONE);
 

	
 
		resize->width = 1;
 
		resize->height = d.height;
 
@@ -348,13 +348,13 @@ struct GoalQuestionWindow : public Windo
 
			this->GetWidget<NWidgetStacked>(WID_GQ_BUTTONS)->SetDisplayedPlane(this->buttons - 1);
 
		}
 
		this->FinishInitNested(window_number);
 
	}
 

	
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_GQ_BUTTON_1:
 
				SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[0]);
 
				break;
 

	
 
@@ -365,13 +365,13 @@ struct GoalQuestionWindow : public Windo
 
			case WID_GQ_BUTTON_3:
 
				SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[2]);
 
				break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_GQ_BUTTON_1:
 
				Command<CMD_GOAL_QUESTION_ANSWER>::Post(this->window_number, this->button[0]);
 
				this->Close();
 
				break;
 
@@ -385,21 +385,21 @@ struct GoalQuestionWindow : public Windo
 
				Command<CMD_GOAL_QUESTION_ANSWER>::Post(this->window_number, this->button[2]);
 
				this->Close();
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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_GQ_QUESTION) return;
 

	
 
		SetDParamStr(0, this->question);
 
		size->height = GetStringHeight(STR_JUST_RAW_STRING, size->width);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_GQ_QUESTION) return;
 

	
 
		SetDParamStr(0, this->question);
 
		DrawStringMultiLine(r, STR_JUST_RAW_STRING, this->colour, SA_TOP | SA_HOR_CENTER);
 
	}
src/graph_gui.cpp
Show inline comments
 
@@ -53,13 +53,13 @@ struct GraphLegendWindow : Window {
 
			if (!HasBit(_legend_excluded_companies, c)) this->LowerWidget(c + WID_GL_FIRST_COMPANY);
 

	
 
			this->OnInvalidateData(c);
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, MAX_COMPANIES + WID_GL_FIRST_COMPANY)) return;
 

	
 
		CompanyID cid = (CompanyID)(widget - WID_GL_FIRST_COMPANY);
 

	
 
		if (!Company::IsValidID(cid)) return;
 
@@ -73,13 +73,13 @@ struct GraphLegendWindow : Window {
 
		const Rect tr = ir.Indent(d.width + WidgetDimensions::scaled.hsep_normal, rtl);
 
		SetDParam(0, cid);
 
		SetDParam(1, cid);
 
		DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, GetCharacterHeight(FS_NORMAL)), STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, MAX_COMPANIES + WID_GL_FIRST_COMPANY)) return;
 

	
 
		ToggleBit(_legend_excluded_companies, widget - WID_GL_FIRST_COMPANY);
 
		this->ToggleWidgetLoweredState(widget);
 
		this->SetDirty();
 
@@ -112,13 +112,13 @@ struct GraphLegendWindow : Window {
 
static NWidgetBase *MakeNWidgetCompanyLines()
 
{
 
	NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE);
 
	vert->SetPadding(2, 2, 2, 2);
 
	uint sprite_height = GetSpriteSize(SPR_COMPANY_ICON, nullptr, ZOOM_LVL_OUT_4X).height;
 

	
 
	for (int widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) {
 
	for (WidgetID widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) {
 
		NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum);
 
		panel->SetMinimalSize(246, sprite_height + WidgetDimensions::unscaled.framerect.Vertical());
 
		panel->SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical(), FS_NORMAL);
 
		panel->SetFill(1, 1);
 
		panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP);
 
		vert->Add(panel);
 
@@ -188,13 +188,13 @@ protected:
 

	
 
	/* These values are used if the graph is being plotted against values
 
	 * rather than the dates specified by month and year. */
 
	uint16_t x_values_start;
 
	uint16_t x_values_increment;
 

	
 
	int graph_widget;
 
	WidgetID graph_widget;
 
	StringID format_str_y_axis;
 
	byte colours[GRAPH_MAX_DATASETS];
 
	OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][GRAPH_NUM_MONTHS]; ///< Stored costs for the last #GRAPH_NUM_MONTHS months
 

	
 
	/**
 
	 * Get the interval that contains the graph's data. Excluded data is ignored to show smaller values in
 
@@ -468,13 +468,13 @@ protected:
 
				}
 
			}
 
		}
 
	}
 

	
 

	
 
	BaseGraphWindow(WindowDesc *desc, int widget, StringID format_str_y_axis) :
 
	BaseGraphWindow(WindowDesc *desc, WidgetID widget, StringID format_str_y_axis) :
 
			Window(desc),
 
			format_str_y_axis(format_str_y_axis)
 
	{
 
		SetWindowDirty(WC_GRAPH_LEGEND, 0);
 
		this->num_vert_lines = 24;
 
		this->graph_widget = widget;
 
@@ -486,13 +486,13 @@ protected:
 
		this->UpdateStatistics(true);
 

	
 
		this->InitNested(number);
 
	}
 

	
 
public:
 
	void UpdateWidgetSize(int 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 != this->graph_widget) return;
 

	
 
		uint x_label_width = 0;
 

	
 
		/* Draw x-axis labels and markings for graphs based on financial quarters and years.  */
 
@@ -522,25 +522,25 @@ public:
 

	
 
		size->width  = std::max<uint>(size->width,  ScaleGUITrad(5) + y_label_width + this->num_on_x_axis * (x_label_width + ScaleGUITrad(5)) + ScaleGUITrad(9));
 
		size->height = std::max<uint>(size->height, ScaleGUITrad(5) + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->draw_dates ? 3 : 1)) * GetCharacterHeight(FS_SMALL) + ScaleGUITrad(4));
 
		size->height = std::max<uint>(size->height, size->width / 3);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != this->graph_widget) return;
 

	
 
		DrawGraph(r);
 
	}
 

	
 
	virtual OverflowSafeInt64 GetGraphData(const Company *, int)
 
	{
 
		return INVALID_DATAPOINT;
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		/* Clicked on legend? */
 
		if (widget == WID_CV_KEY_BUTTON) ShowGraphLegend();
 
	}
 

	
 
	void OnGameTick() override
 
@@ -775,13 +775,13 @@ struct PerformanceHistoryGraphWindow : B
 

	
 
	OverflowSafeInt64 GetGraphData(const Company *c, int j) override
 
	{
 
		return c->old_economy[j].performance_history;
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget == WID_PHG_DETAILED_PERFORMANCE) ShowPerformanceRatingDetail();
 
		this->BaseGraphWindow::OnClick(pt, widget, click_count);
 
	}
 
};
 

	
 
@@ -909,13 +909,13 @@ struct PaymentRatesGraphWindow : BaseGra
 
		for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
 
			if (HasBit(_legend_excluded_cargo, cs->Index())) SetBit(this->excluded_data, i);
 
			i++;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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_CPR_MATRIX) {
 
			BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize);
 
			return;
 
		}
 

	
 
@@ -933,13 +933,13 @@ struct PaymentRatesGraphWindow : BaseGra
 
		this->line_height = size->height;
 
		size->height = this->line_height * 11; /* Default number of cargo types in most climates. */
 
		resize->width = 0;
 
		resize->height = this->line_height;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_CPR_MATRIX) {
 
			BaseGraphWindow::DrawWidget(r, widget);
 
			return;
 
		}
 

	
 
@@ -970,13 +970,13 @@ struct PaymentRatesGraphWindow : BaseGra
 
			DrawString(text.Indent(this->legend_width + WidgetDimensions::scaled.hsep_normal, rtl), STR_GRAPH_CARGO_PAYMENT_CARGO);
 

	
 
			line = line.Translate(0, this->line_height);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_CPR_ENABLE_CARGOES:
 
				/* Remove all cargoes from the excluded lists. */
 
				_legend_excluded_cargo = 0;
 
				this->excluded_data = 0;
 
@@ -1137,13 +1137,13 @@ struct PerformanceRatingDetailWindow : W
 
	uint bar_right;
 
	uint bar_width;
 
	uint bar_height;
 
	uint score_detail_left;
 
	uint score_detail_right;
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_PRD_SCORE_FIRST:
 
				this->bar_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.fullbevel.Vertical();
 
				size->height = this->bar_height + WidgetDimensions::scaled.matrix.Vertical();
 

	
 
@@ -1195,13 +1195,13 @@ struct PerformanceRatingDetailWindow : W
 
				this->bar_left  = left + (rtl ? score_detail_width : score_info_width) + WidgetDimensions::scaled.hsep_wide;
 
				this->bar_right = this->bar_left + this->bar_width - 1;
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		/* No need to draw when there's nothing to draw */
 
		if (this->company == INVALID_COMPANY) return;
 

	
 
		if (IsInsideMM(widget, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST + 1)) {
 
			if (this->IsWidgetDisabled(widget)) return;
 
@@ -1273,13 +1273,13 @@ struct PerformanceRatingDetailWindow : W
 
				break;
 
			default:
 
				DrawString(this->score_detail_left, this->score_detail_right, text_top, STR_PERFORMANCE_DETAIL_AMOUNT_INT);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		/* Check which button is clicked */
 
		if (IsInsideMM(widget, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST + 1)) {
 
			/* Is it no on disable? */
 
			if (!this->IsWidgetDisabled(widget)) {
 
				this->RaiseWidget(this->company + WID_PRD_COMPANY_FIRST);
 
@@ -1352,13 +1352,13 @@ static NWidgetBase *MakePerformanceDetai
 
		STR_PERFORMANCE_DETAIL_TOTAL_TOOLTIP,
 
	};
 

	
 
	static_assert(lengthof(performance_tips) == SCORE_END - SCORE_BEGIN);
 

	
 
	NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE);
 
	for (int widnum = WID_PRD_SCORE_FIRST; widnum <= WID_PRD_SCORE_LAST; widnum++) {
 
	for (WidgetID widnum = WID_PRD_SCORE_FIRST; widnum <= WID_PRD_SCORE_LAST; widnum++) {
 
		NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum);
 
		panel->SetFill(1, 1);
 
		panel->SetDataTip(0x0, performance_tips[widnum - WID_PRD_SCORE_FIRST]);
 
		vert->Add(panel);
 
	}
 
	return vert;
src/group_gui.cpp
Show inline comments
 
@@ -381,13 +381,13 @@ public:
 

	
 
	~VehicleGroupWindow()
 
	{
 
		*this->sorting = this->vehgroups.GetListing();
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_GL_LIST_GROUP:
 
				size->width = this->ComputeGroupInfoSize();
 
				resize->height = this->tiny_step_height;
 
				fill->height = this->tiny_step_height;
 
@@ -463,13 +463,13 @@ public:
 
			this->vli.index = ALL_GROUP;
 
			this->CloseChildWindows(WC_DROPDOWN_MENU);
 
		}
 
		this->SetDirty();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_GL_FILTER_BY_CARGO:
 
				SetDParam(0, this->GetCargoFilterLabel(this->cargo_filter_criteria));
 
				break;
 

	
 
@@ -549,13 +549,13 @@ public:
 
		/* Set text of "sort by" dropdown widget. */
 
		this->GetWidget<NWidgetCore>(WID_GL_SORT_BY_DROPDOWN)->widget_data = this->GetVehicleSorterNames()[this->vehgroups.SortType()];
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_GL_ALL_VEHICLES:
 
				DrawGroupInfo(r.top, r.left, r.right, ALL_GROUP);
 
				break;
 

	
 
@@ -645,13 +645,13 @@ public:
 
			VehicleGroupWindow *w = (VehicleGroupWindow*)win;
 
			w->vli.index = ALL_GROUP;
 
			Command<CMD_DELETE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_DELETE, w->group_confirm);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_GL_SORT_BY_ORDER: // Flip sorting method ascending/descending
 
				this->vehgroups.ToggleSortOrder();
 
				this->SetDirty();
 
				break;
 
@@ -820,13 +820,13 @@ public:
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnDragDrop_Group(Point pt, int widget)
 
	void OnDragDrop_Group(Point pt, WidgetID widget)
 
	{
 
		const Group *g = Group::Get(this->group_sel);
 

	
 
		switch (widget) {
 
			case WID_GL_ALL_VEHICLES: // All vehicles
 
			case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles
 
@@ -852,13 +852,13 @@ public:
 
				this->SetDirty();
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnDragDrop_Vehicle(Point pt, int widget)
 
	void OnDragDrop_Vehicle(Point pt, WidgetID widget)
 
	{
 
		switch (widget) {
 
			case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles
 
				Command<CMD_ADD_VEHICLE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, DEFAULT_GROUP, this->vehicle_sel, _ctrl_pressed || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{});
 

	
 
				this->vehicle_sel = INVALID_VEHICLE;
 
@@ -918,13 +918,13 @@ public:
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnDragDrop(Point pt, int widget) override
 
	void OnDragDrop(Point pt, WidgetID widget) override
 
	{
 
		if (this->vehicle_sel != INVALID_VEHICLE) OnDragDrop_Vehicle(pt, widget);
 
		if (this->group_sel != INVALID_GROUP) OnDragDrop_Group(pt, widget);
 

	
 
		_cursor.vehchain = false;
 
	}
 
@@ -938,13 +938,13 @@ public:
 
	void OnResize() override
 
	{
 
		this->group_sb->SetCapacityFromWidget(this, WID_GL_LIST_GROUP);
 
		this->vscroll->SetCapacityFromWidget(this, WID_GL_LIST_VEHICLE);
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_GL_GROUP_BY_DROPDOWN:
 
				this->UpdateVehicleGroupBy(static_cast<GroupBy>(index));
 
				break;
 

	
 
@@ -1007,13 +1007,13 @@ public:
 
		this->DirtyHighlightedGroupWidget();
 
		this->group_sel = INVALID_GROUP;
 
		this->group_over = INVALID_GROUP;
 
		this->SetWidgetDirty(WID_GL_LIST_VEHICLE);
 
	}
 

	
 
	void OnMouseDrag(Point pt, int widget) override
 
	void OnMouseDrag(Point pt, WidgetID widget) override
 
	{
 
		if (this->vehicle_sel == INVALID_VEHICLE && this->group_sel == INVALID_GROUP) return;
 

	
 
		/* A vehicle is dragged over... */
 
		GroupID new_group_over = INVALID_GROUP;
 
		switch (widget) {
src/help_gui.cpp
Show inline comments
 
@@ -70,13 +70,13 @@ struct GameManualTextfileWindow : public
 

	
 
		this->filepath = filepath.value();
 
		this->LoadTextfile(this->filepath, NO_DIRECTORY);
 
		this->OnClick({ 0, 0 }, WID_TF_WRAPTEXT, 1);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_TF_CAPTION) {
 
			SetDParamStr(0, this->filename);
 
		}
 
	}
 

	
 
@@ -126,13 +126,13 @@ struct HelpWindow : public Window {
 
		this->EnableTextfileButton(README_FILENAME, WID_HW_README);
 
		this->EnableTextfileButton(CHANGELOG_FILENAME, WID_HW_CHANGELOG);
 
		this->EnableTextfileButton(KNOWN_BUGS_FILENAME, WID_HW_KNOWN_BUGS);
 
		this->EnableTextfileButton(LICENSE_FILENAME, WID_HW_LICENSE);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_HW_README:
 
				new GameManualTextfileWindow(README_FILENAME);
 
				break;
 
			case WID_HW_CHANGELOG:
src/highscore_gui.cpp
Show inline comments
 
@@ -62,13 +62,13 @@ struct EndGameHighScoreBaseWindow : Wind
 
	Point GetTopLeft(int x, int y)
 
	{
 
		Point pt = {std::max(0, (_screen.width / 2) - (x / 2)), std::max(0, (_screen.height / 2) - (y / 2))};
 
		return pt;
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		this->Close();
 
	}
 

	
 
	EventState OnKeyPress([[maybe_unused]] char32_t key, uint16_t keycode) override
 
	{
src/industry_gui.cpp
Show inline comments
 
@@ -419,13 +419,13 @@ public:
 
		this->legend.height = GetCharacterHeight(FS_SMALL);
 
		this->legend.width = this->legend.height * 9 / 6;
 

	
 
		this->SetupArrays();
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_DPI_MATRIX_WIDGET: {
 
				Dimension d = GetStringBoundingBox(STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES);
 
				for (const auto &indtype : this->list) {
 
					d = maxdim(d, GetStringBoundingBox(GetIndustrySpec(indtype)->name));
 
@@ -491,13 +491,13 @@ public:
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_DPI_FUND_WIDGET:
 
				/* Raw industries might be prospected. Show this fact by changing the string
 
				 * In Editor, you just build, while ingame, or you fund or you prospect */
 
				if (_game_mode == GM_EDITOR) {
 
@@ -512,13 +512,13 @@ public:
 
					}
 
				}
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_DPI_MATRIX_WIDGET: {
 
				bool rtl = _current_text_dir == TD_RTL;
 
				Rect text = r.WithHeight(this->resize.step_height).Shrink(WidgetDimensions::scaled.matrix);
 
				Rect icon = text.WithWidth(this->legend.width, rtl);
 
@@ -623,13 +623,13 @@ public:
 
			}
 
		}
 

	
 
		MarkWholeScreenDirty();
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_DPI_CREATE_RANDOM_INDUSTRIES_WIDGET: {
 
				assert(_game_mode == GM_EDITOR);
 
				this->HandleButtonClick(WID_DPI_CREATE_RANDOM_INDUSTRIES_WIDGET);
 
				ShowQuery(STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES_CAPTION, STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES_QUERY, nullptr, AskManyRandomIndustriesCallback);
 
@@ -978,23 +978,23 @@ public:
 
		}
 

	
 
		/* Return required bottom position, the last pixel row plus some padding. */
 
		return ir.top - 1 + WidgetDimensions::scaled.framerect.bottom;
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_IV_CAPTION) SetDParam(0, this->window_number);
 
	}
 

	
 
	void UpdateWidgetSize(int 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_IV_INFO) size->height = this->info_height;
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_IV_INFO: {
 
				Industry *i = Industry::Get(this->window_number);
 
				InfoLine line = IL_NONE;
 

	
 
@@ -1643,13 +1643,13 @@ public:
 

	
 
	void OnInit() override
 
	{
 
		this->SetCargoFilterArray();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_ID_DROPDOWN_CRITERIA:
 
				SetDParam(0, IndustryDirectoryWindow::sorter_names[this->industries.SortType()]);
 
				break;
 

	
 
@@ -1660,13 +1660,13 @@ public:
 
			case WID_ID_FILTER_BY_PROD_CARGO:
 
				SetDParam(0, this->GetCargoFilterLabel(this->produced_cargo_filter_criteria));
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_ID_DROPDOWN_ORDER:
 
				this->DrawSortButtonState(widget, this->industries.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
 
				break;
 

	
 
@@ -1706,13 +1706,13 @@ public:
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_ID_DROPDOWN_ORDER: {
 
				Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
 
				d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
 
				d.height += padding.height;
 
@@ -1758,13 +1758,13 @@ public:
 
			list.push_back(std::make_unique<DropDownListIconItem>(d, cs->GetCargoIcon(), PAL_NONE, cs->name, cs->Index(), false));
 
		}
 

	
 
		return list;
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_ID_DROPDOWN_ORDER:
 
				this->industries.ToggleSortOrder();
 
				this->SetDirty();
 
				break;
 
@@ -1792,13 +1792,13 @@ public:
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_ID_DROPDOWN_CRITERIA: {
 
				if (this->industries.SortType() != index) {
 
					this->industries.SetSortType(index);
 
					this->BuildSortIndustriesList();
 
@@ -1823,13 +1823,13 @@ public:
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_ID_INDUSTRY_LIST);
 
		this->hscroll->SetCapacityFromWidget(this, WID_ID_INDUSTRY_LIST);
 
	}
 

	
 
	void OnEditboxChanged(int wid) override
 
	void OnEditboxChanged(WidgetID wid) override
 
	{
 
		if (wid == WID_ID_FILTER) {
 
			this->string_filter.SetFilterTerm(this->industry_editbox.text.buf);
 
			this->InvalidateData(IDIWD_FORCE_REBUILD);
 
		}
 
	}
 
@@ -2623,13 +2623,13 @@ struct IndustryCargoesWindow : public Wi
 
		CargoesField::normal_height = d.height + CargoesField::vert_inter_industry_space;
 

	
 
		/* Width of a #CFT_CARGO field. */
 
		CargoesField::cargo_field_width = CargoesField::cargo_border.width * 2 + CargoesField::cargo_line.width * CargoesField::max_cargoes + CargoesField::cargo_space.width * (CargoesField::max_cargoes - 1);
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_IC_PANEL:
 
				resize->height = CargoesField::normal_height;
 
				size->width = CargoesField::industry_width * 3 + CargoesField::cargo_field_width * 2 + WidgetDimensions::scaled.frametext.Horizontal();
 
				size->height = CargoesField::small_height + 2 * resize->height + WidgetDimensions::scaled.frametext.Vertical();
 
@@ -2644,13 +2644,13 @@ struct IndustryCargoesWindow : public Wi
 
				break;
 
		}
 
	}
 

	
 

	
 
	CargoesFieldType type; ///< Type of field.
 
	void SetStringParameters  (int widget) const override
 
	void SetStringParameters  (WidgetID widget) const override
 
	{
 
		if (widget != WID_IC_CAPTION) return;
 

	
 
		if (this->ind_cargo < NUM_INDUSTRYTYPES) {
 
			const IndustrySpec *indsp = GetIndustrySpec(this->ind_cargo);
 
			SetDParam(0, indsp->name);
 
@@ -2973,13 +2973,13 @@ struct IndustryCargoesWindow : public Wi
 
		}
 

	
 
		assert(data >= 0 && data < NUM_INDUSTRYTYPES);
 
		this->ComputeIndustryDisplay(data);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_IC_PANEL) return;
 

	
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
		DrawPixelInfo tmp_dpi;
 
		if (!FillDrawPixelInfo(&tmp_dpi, ir)) return;
 
@@ -3058,13 +3058,13 @@ struct IndustryCargoesWindow : public Wi
 
			fieldxy->x = column;
 
			xy->x = xpos;
 
		}
 
		return true;
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_IC_PANEL: {
 
				Point fieldxy, xy;
 
				if (!CalculatePositionInWidget(pt, &fieldxy, &xy)) return;
 

	
 
@@ -3131,13 +3131,13 @@ struct IndustryCargoesWindow : public Wi
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		if (index < 0) return;
 

	
 
		switch (widget) {
 
			case WID_IC_CARGO_DROPDOWN:
 
				this->ComputeCargoDisplay(index);
 
@@ -3146,13 +3146,13 @@ struct IndustryCargoesWindow : public Wi
 
			case WID_IC_IND_DROPDOWN:
 
				this->ComputeIndustryDisplay(index);
 
				break;
 
		}
 
	}
 

	
 
	bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override
 
	bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override
 
	{
 
		if (widget != WID_IC_PANEL) return false;
 

	
 
		Point fieldxy, xy;
 
		if (!CalculatePositionInWidget(pt, &fieldxy, &xy)) return false;
 

	
src/intro_gui.cpp
Show inline comments
 
@@ -279,13 +279,13 @@ struct SelectGameWindow : public Window 
 
		this->GetWidget<NWidgetStacked>(WID_SGI_BASESET_SELECTION)->SetDisplayedPlane(missing_sprites ? 0 : SZSP_NONE);
 

	
 
		bool missing_lang = _current_language->missing >= _settings_client.gui.missing_strings_threshold && !IsReleasedVersion();
 
		this->GetWidget<NWidgetStacked>(WID_SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing_lang ? 0 : SZSP_NONE);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SGI_BASESET:
 
				SetDParam(0, _missing_extra_graphics);
 
				DrawStringMultiLine(r.left, r.right, r.top,  r.bottom, STR_INTRO_BASESET, TC_FROMSTRING, SA_CENTER);
 
				break;
 
@@ -294,13 +294,13 @@ struct SelectGameWindow : public Window 
 
				SetDParam(0, _current_language->missing);
 
				DrawStringMultiLine(r.left, r.right, r.top,  r.bottom, STR_INTRO_TRANSLATION, TC_FROMSTRING, SA_CENTER);
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_SGI_TEMPERATE_LANDSCAPE: case WID_SGI_ARCTIC_LANDSCAPE:
 
			case WID_SGI_TROPIC_LANDSCAPE: case WID_SGI_TOYLAND_LANDSCAPE:
 
				size->width += WidgetDimensions::scaled.fullbevel.Horizontal();
 
				size->height += WidgetDimensions::scaled.fullbevel.Vertical();
 
@@ -322,13 +322,13 @@ struct SelectGameWindow : public Window 
 
			changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_TRANSLATION), 3);
 
		}
 

	
 
		if (changed) this->ReInit(0, 0, this->flags & WF_CENTERED);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		/* Do not create a network server when you (just) have closed one of the game
 
		 * creation/load windows for the network server. */
 
		if (IsInsideMM(widget, WID_SGI_GENERATE_GAME, WID_SGI_EDIT_SCENARIO + 1)) _is_network_server = false;
 

	
 
		switch (widget) {
src/league_gui.cpp
Show inline comments
 
@@ -97,13 +97,13 @@ public:
 
		this->BuildCompanyList();
 
		this->companies.Sort(&PerformanceSorter);
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_PLT_BACKGROUND) return;
 

	
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
 
		int icon_y_offset = (this->line_height - this->icon.height) / 2;
 
		int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2;
 
@@ -124,13 +124,13 @@ public:
 
			SetDParam(2, GetPerformanceTitleFromValue(c->old_economy[0].performance_history));
 
			DrawString(text.left, text.right, ir.top + text_y_offset, STR_COMPANY_LEAGUE_COMPANY_NAME);
 
			ir.top += this->line_height;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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_PLT_BACKGROUND) return;
 

	
 
		this->ordinal_width = 0;
 
		for (uint i = 0; i < MAX_COMPANIES; i++) {
 
			this->ordinal_width = std::max(this->ordinal_width, GetStringBoundingBox(STR_ORDINAL_NUMBER_1ST + i).width);
 
@@ -299,24 +299,24 @@ public:
 
	{
 
		this->table = table;
 
		this->BuildTable();
 
		this->InitNested(table);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget != WID_SLT_CAPTION) return;
 
		SetDParamStr(0, this->title);
 
	}
 

	
 
	void OnPaint() override
 
	{
 
		this->DrawWidgets();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_SLT_BACKGROUND) return;
 

	
 
		auto lt = LeagueTable::GetIfValid(this->table);
 
		if (lt == nullptr) return;
 

	
 
@@ -352,13 +352,13 @@ public:
 
			ir.top += WidgetDimensions::scaled.vsep_wide;
 
			SetDParamStr(0, lt->footer);
 
			ir.top = DrawStringMultiLine(ir.left, ir.right, ir.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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_SLT_BACKGROUND) return;
 

	
 
		auto lt = LeagueTable::GetIfValid(this->table);
 
		if (lt == nullptr) return;
 

	
 
@@ -392,13 +392,13 @@ public:
 
		if (!lt->footer.empty()) {
 
			SetDParamStr(0, lt->footer);
 
			size->height += GetStringHeight(STR_JUST_RAW_STRING, size->width - WidgetDimensions::scaled.framerect.Horizontal()) + WidgetDimensions::scaled.vsep_wide;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget != WID_SLT_BACKGROUND) return;
 

	
 
		auto *wid = this->GetWidget<NWidgetResizeBase>(WID_SLT_BACKGROUND);
 
		int index = (pt.y - WidgetDimensions::scaled.framerect.top - wid->pos_y - this->header_height) / this->line_height;
 
		if (index >= 0 && (uint)index < this->rows.size()) {
src/linkgraph/linkgraph_gui.cpp
Show inline comments
 
@@ -579,13 +579,13 @@ void LinkGraphLegendWindow::SetOverlay(s
 
	CargoTypes cargoes = this->overlay->GetCargoMask();
 
	for (uint c = 0; c < this->num_cargo; c++) {
 
		this->SetWidgetLoweredState(WID_LGL_CARGO_FIRST + c, HasBit(cargoes, _sorted_cargo_specs[c]->Index()));
 
	}
 
}
 

	
 
void LinkGraphLegendWindow::UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize)
 
void LinkGraphLegendWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize)
 
{
 
	if (IsInsideMM(widget, WID_LGL_SATURATION_FIRST, WID_LGL_SATURATION_LAST + 1)) {
 
		StringID str = STR_NULL;
 
		if (widget == WID_LGL_SATURATION_FIRST) {
 
			str = STR_LINKGRAPH_LEGEND_UNUSED;
 
		} else if (widget == WID_LGL_SATURATION_LAST) {
 
@@ -606,13 +606,13 @@ void LinkGraphLegendWindow::UpdateWidget
 
		dim.width += padding.width;
 
		dim.height += padding.height;
 
		*size = maxdim(*size, dim);
 
	}
 
}
 

	
 
void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const
 
void LinkGraphLegendWindow::DrawWidget(const Rect &r, WidgetID widget) const
 
{
 
	Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
 
	if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) {
 
		if (this->IsWidgetDisabled(widget)) return;
 
		CompanyID cid = (CompanyID)(widget - WID_LGL_COMPANY_FIRST);
 
		Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON);
 
@@ -637,13 +637,13 @@ void LinkGraphLegendWindow::DrawWidget(c
 
		const CargoSpec *cargo = _sorted_cargo_specs[widget - WID_LGL_CARGO_FIRST];
 
		GfxFillRect(br, cargo->legend_colour);
 
		DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_SMALL)), cargo->abbrev, GetContrastColour(cargo->legend_colour, 73), SA_HOR_CENTER, false, FS_SMALL);
 
	}
 
}
 

	
 
bool LinkGraphLegendWindow::OnTooltip([[maybe_unused]] Point, int widget, TooltipCloseCondition close_cond)
 
bool LinkGraphLegendWindow::OnTooltip([[maybe_unused]] Point, WidgetID widget, TooltipCloseCondition close_cond)
 
{
 
	if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) {
 
		if (this->IsWidgetDisabled(widget)) {
 
			GuiShowTooltips(this, STR_LINKGRAPH_LEGEND_SELECT_COMPANIES, close_cond);
 
		} else {
 
			SetDParam(0, STR_LINKGRAPH_LEGEND_SELECT_COMPANIES);
 
@@ -684,13 +684,13 @@ void LinkGraphLegendWindow::UpdateOverla
 
		if (!this->IsWidgetLowered(c + WID_LGL_CARGO_FIRST)) continue;
 
		SetBit(mask, _sorted_cargo_specs[c]->Index());
 
	}
 
	this->overlay->SetCargoMask(mask);
 
}
 

	
 
void LinkGraphLegendWindow::OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count)
 
void LinkGraphLegendWindow::OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count)
 
{
 
	/* Check which button is clicked */
 
	if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) {
 
		if (!this->IsWidgetDisabled(widget)) {
 
			this->ToggleWidgetLoweredState(widget);
 
			this->UpdateOverlayCompanies();
src/linkgraph/linkgraph_gui.h
Show inline comments
 
@@ -51,13 +51,13 @@ public:
 
	 * @param w Window to be drawn into.
 
	 * @param wid ID of the widget to draw into.
 
	 * @param cargo_mask Bitmask of cargoes to be shown.
 
	 * @param company_mask Bitmask of companies to be shown.
 
	 * @param scale Desired thickness of lines and size of station dots.
 
	 */
 
	LinkGraphOverlay(Window *w, uint wid, CargoTypes cargo_mask, CompanyMask company_mask, uint scale) :
 
	LinkGraphOverlay(Window *w, WidgetID wid, CargoTypes cargo_mask, CompanyMask company_mask, uint scale) :
 
			window(w), widget_id(wid), cargo_mask(cargo_mask), company_mask(company_mask), scale(scale)
 
	{}
 

	
 
	void Draw(const DrawPixelInfo *dpi);
 
	void SetCargoMask(CargoTypes cargo_mask);
 
	void SetCompanyMask(CompanyMask company_mask);
 
@@ -72,13 +72,13 @@ public:
 

	
 
	/** Get a bitmask of the currently shown companies. */
 
	CompanyMask GetCompanyMask() { return this->company_mask; }
 

	
 
protected:
 
	Window *window;                    ///< Window to be drawn into.
 
	const uint widget_id;              ///< ID of Widget in Window to be drawn to.
 
	const WidgetID widget_id;          ///< ID of Widget in Window to be drawn to.
 
	CargoTypes cargo_mask;             ///< Bitmask of cargos to be displayed.
 
	CompanyMask company_mask;          ///< Bitmask of companies to be displayed.
 
	LinkMap cached_links;              ///< Cache for links to reduce recalculation.
 
	StationSupplyList cached_stations; ///< Cache for stations to be drawn.
 
	uint scale;                        ///< Width of link lines.
 
	bool dirty;                        ///< Set if overlay should be rebuilt.
 
@@ -105,16 +105,16 @@ void ShowLinkGraphLegend();
 
 */
 
struct LinkGraphLegendWindow : Window {
 
public:
 
	LinkGraphLegendWindow(WindowDesc *desc, int window_number);
 
	void SetOverlay(std::shared_ptr<LinkGraphOverlay> overlay);
 

	
 
	void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override;
 
	void DrawWidget(const Rect &r, int widget) const override;
 
	bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override;
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override;
 
	void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override;
 
	void DrawWidget(const Rect &r, WidgetID widget) const override;
 
	bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override;
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override;
 
	void OnInvalidateData(int data = 0, bool gui_scope = true) override;
 

	
 
private:
 
	std::shared_ptr<LinkGraphOverlay> overlay;
 
	size_t num_cargo;
 

	
src/main_gui.cpp
Show inline comments
 
@@ -57,13 +57,13 @@
 
 * @param w Window which called the function
 
 * @param widget ID of the widget (=button) that called this function
 
 * @param cursor How should the cursor image change? E.g. cursor with depot image in it
 
 * @param mode Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground
 
 * @return true if the button is clicked, false if it's unclicked
 
 */
 
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
 
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
 
{
 
	if (w->IsWidgetDisabled(widget)) return false;
 

	
 
	if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
 
	w->SetDirty();
 

	
 
@@ -445,13 +445,13 @@ struct MainWindow : Window
 
			NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_M_VIEWPORT);
 
			nvp->UpdateViewportCoordinates(this);
 
			this->refresh_timeout.Reset();
 
		}
 
	}
 

	
 
	bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override
 
	bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override
 
	{
 
		if (widget != WID_M_VIEWPORT) return false;
 
		return this->viewport->overlay->ShowTooltip(pt, close_cond);
 
	}
 

	
 
	/**
src/misc_gui.cpp
Show inline comments
 
@@ -69,13 +69,13 @@ class LandInfoWindow : public Window {
 
	StringList  landinfo_data;    ///< Info lines to show.
 
	std::string cargo_acceptance; ///< Centered multi-line string for cargo acceptance.
 

	
 
public:
 
	TileIndex tile;
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_LI_BACKGROUND) return;
 

	
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.frametext);
 
		for (size_t i = 0; i < this->landinfo_data.size(); i++) {
 
			DrawString(ir, this->landinfo_data[i], i == 0 ? TC_LIGHT_BLUE : TC_FROMSTRING, SA_HOR_CENTER);
 
@@ -85,13 +85,13 @@ public:
 
		if (!this->cargo_acceptance.empty()) {
 
			SetDParamStr(0, this->cargo_acceptance);
 
			DrawStringMultiLine(ir, STR_JUST_RAW_STRING, TC_FROMSTRING, SA_CENTER);
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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();
 
		for (size_t i = 0; i < this->landinfo_data.size(); i++) {
 
			uint width = GetStringBoundingBox(this->landinfo_data[i]).width + WidgetDimensions::scaled.frametext.Horizontal();
 
@@ -337,13 +337,13 @@ public:
 

	
 
	void ShowNewGRFInspectWindow() const override
 
	{
 
		::ShowNewGRFInspectWindow(GetGrfSpecFeature(this->tile), this->tile.base());
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_LI_LOCATION:
 
				if (_ctrl_pressed) {
 
					ShowExtraViewportWindow(this->tile);
 
				} else {
 
@@ -475,19 +475,19 @@ struct AboutWindow : public Window {
 
	{
 
		this->InitNested(WN_GAME_OPTIONS_ABOUT);
 

	
 
		this->text_position = this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->pos_y + this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->current_y;
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_A_WEBSITE) SetDParamStr(0, "Website: https://www.openttd.org");
 
		if (widget == WID_A_COPYRIGHT) SetDParamStr(0, _openttd_revision_year);
 
	}
 

	
 
	void UpdateWidgetSize(int 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;
 

	
 
		this->line_height = GetCharacterHeight(FS_NORMAL);
 

	
 
		Dimension d;
 
@@ -497,13 +497,13 @@ struct AboutWindow : public Window {
 
		for (uint i = 0; i < lengthof(_credits); i++) {
 
			d.width = std::max(d.width, GetStringBoundingBox(_credits[i]).width);
 
		}
 
		*size = maxdim(*size, d);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_A_SCROLLING_TEXT) return;
 

	
 
		int y = this->text_position;
 

	
 
		/* Show all scrolling _credits */
 
@@ -694,26 +694,26 @@ struct TooltipsWindow : public Window
 
		if (pt.y + sm_height > scr_bot) pt.y = std::min(_cursor.pos.y + _cursor.total_offs.y - 5, scr_bot) - sm_height;
 
		pt.x = sm_width >= _screen.width ? 0 : SoftClamp(_cursor.pos.x - (sm_width >> 1), 0, _screen.width - sm_width);
 

	
 
		return pt;
 
	}
 

	
 
	void UpdateWidgetSize(int 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);
 

	
 
		/* 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();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_TT_BACKGROUND) return;
 
		GfxFillRect(r, PC_BLACK);
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_LIGHT_YELLOW);
 

	
 
		CopyInDParam(this->params);
 
@@ -757,13 +757,13 @@ void GuiShowTooltips(Window *parent, Str
 

	
 
	if (str == STR_NULL || !_cursor.in_window) return;
 

	
 
	new TooltipsWindow(parent, str, paramcount, close_tooltip);
 
}
 

	
 
void QueryString::HandleEditBox(Window *w, int wid)
 
void QueryString::HandleEditBox(Window *w, WidgetID wid)
 
{
 
	if (w->IsWidgetGloballyFocused(wid) && this->text.HandleCaret()) {
 
		w->SetWidgetDirty(wid);
 

	
 
		/* For the OSK also invalidate the parent window */
 
		if (w->window_class == WC_OSK) w->InvalidateData();
 
@@ -772,13 +772,13 @@ void QueryString::HandleEditBox(Window *
 

	
 
static int GetCaretWidth()
 
{
 
	return GetCharacterWidth(FS_NORMAL, '_');
 
}
 

	
 
void QueryString::DrawEditBox(const Window *w, int wid) const
 
void QueryString::DrawEditBox(const Window *w, WidgetID wid) const
 
{
 
	const NWidgetLeaf *wi = w->GetWidget<NWidgetLeaf>(wid);
 

	
 
	assert((wi->type & WWT_MASK) == WWT_EDITBOX);
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
@@ -824,13 +824,13 @@ void QueryString::DrawEditBox(const Wind
 
/**
 
 * Get the current caret position.
 
 * @param w Window the edit box is in.
 
 * @param wid Widget index.
 
 * @return Top-left location of the caret, relative to the window.
 
 */
 
Point QueryString::GetCaretPosition(const Window *w, int wid) const
 
Point QueryString::GetCaretPosition(const Window *w, WidgetID wid) const
 
{
 
	const NWidgetLeaf *wi = w->GetWidget<NWidgetLeaf>(wid);
 

	
 
	assert((wi->type & WWT_MASK) == WWT_EDITBOX);
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
@@ -853,13 +853,13 @@ Point QueryString::GetCaretPosition(cons
 
 * @param w Window the edit box is in.
 
 * @param wid Widget index.
 
 * @param from Start of the string range.
 
 * @param to End of the string range.
 
 * @return Rectangle encompassing the string range, relative to the window.
 
 */
 
Rect QueryString::GetBoundingRect(const Window *w, int wid, const char *from, const char *to) const
 
Rect QueryString::GetBoundingRect(const Window *w, WidgetID wid, const char *from, const char *to) const
 
{
 
	const NWidgetLeaf *wi = w->GetWidget<NWidgetLeaf>(wid);
 

	
 
	assert((wi->type & WWT_MASK) == WWT_EDITBOX);
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
@@ -884,13 +884,13 @@ Rect QueryString::GetBoundingRect(const 
 
 * Get the character that is rendered at a position.
 
 * @param w Window the edit box is in.
 
 * @param wid Widget index.
 
 * @param pt Position to test.
 
 * @return Index of the character position or -1 if no character is at the position.
 
 */
 
ptrdiff_t QueryString::GetCharAtPosition(const Window *w, int wid, const Point &pt) const
 
ptrdiff_t QueryString::GetCharAtPosition(const Window *w, WidgetID wid, const Point &pt) const
 
{
 
	const NWidgetLeaf *wi = w->GetWidget<NWidgetLeaf>(wid);
 

	
 
	assert((wi->type & WWT_MASK) == WWT_EDITBOX);
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
@@ -906,13 +906,13 @@ ptrdiff_t QueryString::GetCharAtPosition
 
	int delta = std::min(0, r.Width() - tb->pixels - GetCaretWidth());
 
	if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs;
 

	
 
	return ::GetCharAtPosition(tb->buf, pt.x - delta - r.left);
 
}
 

	
 
void QueryString::ClickEditBox(Window *w, Point pt, int wid, int click_count, bool focus_changed)
 
void QueryString::ClickEditBox(Window *w, Point pt, WidgetID wid, int click_count, bool focus_changed)
 
{
 
	const NWidgetLeaf *wi = w->GetWidget<NWidgetLeaf>(wid);
 

	
 
	assert((wi->type & WWT_MASK) == WWT_EDITBOX);
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
@@ -978,13 +978,13 @@ struct QueryStringWindow : public Window
 
			this->warning_size = Dimension{ 0, 0 };
 
		}
 

	
 
		this->ReInit();
 
	}
 

	
 
	void UpdateWidgetSize(int 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;
 
@@ -992,23 +992,23 @@ struct QueryStringWindow : public Window
 

	
 
		if (widget == WID_QS_WARNING) {
 
			*size = this->warning_size;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	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);
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_QS_CAPTION) SetDParam(0, this->editbox.caption);
 
	}
 

	
 
	void OnOk()
 
	{
 
@@ -1017,13 +1017,13 @@ struct QueryStringWindow : public Window
 

	
 
			this->parent->OnQueryTextFinished(this->editbox.text.buf);
 
			this->editbox.handled = true;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_QS_DEFAULT:
 
				this->editbox.text.DeleteAll();
 
				FALLTHROUGH;
 

	
 
@@ -1121,41 +1121,41 @@ struct QueryWindow : public Window {
 
		/* Position query window over the calling window, ensuring it's within screen bounds. */
 
		this->left = SoftClamp(parent->left + (parent->width / 2) - (this->width / 2), 0, _screen.width - this->width);
 
		this->top = SoftClamp(parent->top + (parent->height / 2) - (this->height / 2), 0, _screen.height - this->height);
 
		this->SetDirty();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_Q_CAPTION:
 
			case WID_Q_TEXT:
 
				CopyInDParam(this->params);
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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;
 

	
 
		Dimension d = GetStringMultiLineBoundingBox(this->message, *size);
 
		d.width += WidgetDimensions::scaled.frametext.Horizontal();
 
		d.height += WidgetDimensions::scaled.framerect.Vertical();
 
		*size = d;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_Q_TEXT) return;
 

	
 
		DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect),
 
				this->message, TC_FROMSTRING, SA_CENTER);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_Q_YES: {
 
				/* in the Generate New World window, clicking 'Yes' causes
 
				 * CloseNonVitalWindows() to be called - we shouldn't be in a window then */
 
				QueryCallbackProc *proc = this->proc;
src/music_gui.cpp
Show inline comments
 
@@ -483,13 +483,13 @@ struct MusicTrackSelectionWindow : publi
 
		this->LowerWidget(WID_MTS_LIST_LEFT);
 
		this->LowerWidget(WID_MTS_LIST_RIGHT);
 
		this->SetWidgetDisabledState(WID_MTS_CLEAR, _settings_client.music.playlist <= 3);
 
		this->LowerWidget(WID_MTS_ALL + _settings_client.music.playlist);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_MTS_PLAYLIST:
 
				SetDParam(0, STR_MUSIC_PLAYLIST_ALL + _settings_client.music.playlist);
 
				break;
 
			case WID_MTS_CAPTION:
 
@@ -515,13 +515,13 @@ struct MusicTrackSelectionWindow : publi
 
			this->ReInit();
 
		} else {
 
			this->SetDirty();
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_MTS_PLAYLIST: {
 
				Dimension d = {0, 0};
 

	
 
				for (int i = 0; i < 6; i++) {
 
@@ -550,13 +550,13 @@ struct MusicTrackSelectionWindow : publi
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_MTS_LIST_LEFT: {
 
				GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK);
 

	
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
 
@@ -583,13 +583,13 @@ struct MusicTrackSelectionWindow : publi
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_MTS_LIST_LEFT: { // add to playlist
 
				int y = this->GetRowFromWidget(pt.y, widget, 0, GetCharacterHeight(FS_SMALL));
 
				_music.PlaylistAdd(y);
 
				break;
 
@@ -615,13 +615,13 @@ struct MusicTrackSelectionWindow : publi
 
			case WID_MTS_EZY: case WID_MTS_CUSTOM1: case WID_MTS_CUSTOM2: // set playlist
 
				_music.ChangePlaylist((MusicSystem::PlaylistChoices)(widget - WID_MTS_ALL));
 
				break;
 
		}
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_MTS_MUSICSET:
 
				ChangeMusicSet(index);
 
				break;
 
			default:
 
@@ -697,13 +697,13 @@ struct MusicWindow : public Window {
 
			BaseMusic::GetUsedSet()->num_available == 0,
 
			WID_M_PREV, WID_M_NEXT, WID_M_STOP, WID_M_PLAY, WID_M_SHUFFLE,
 
			WID_M_ALL, WID_M_OLD, WID_M_NEW, WID_M_EZY, WID_M_CUSTOM1, WID_M_CUSTOM2
 
			);
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			/* Make sure that WID_M_SHUFFLE and WID_M_PROGRAMME have the same size.
 
			 * This can't be done by using NC_EQUALSIZE as the WID_M_INFO is
 
			 * between those widgets and of different size. */
 
			case WID_M_SHUFFLE: case WID_M_PROGRAMME: {
 
@@ -739,13 +739,13 @@ struct MusicWindow : public Window {
 
			case WID_M_PREV: this->GetWidget<NWidgetCore>(WID_M_PREV)->widget_data = _current_text_dir == TD_RTL ? SPR_IMG_SKIP_TO_NEXT : SPR_IMG_SKIP_TO_PREV; break;
 
			case WID_M_NEXT: this->GetWidget<NWidgetCore>(WID_M_NEXT)->widget_data = _current_text_dir == TD_RTL ? SPR_IMG_SKIP_TO_PREV : SPR_IMG_SKIP_TO_NEXT; break;
 
			case WID_M_PLAY: this->GetWidget<NWidgetCore>(WID_M_PLAY)->widget_data = _current_text_dir == TD_RTL ? SPR_IMG_PLAY_MUSIC_RTL : SPR_IMG_PLAY_MUSIC; break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_M_TRACK_NR: {
 
				GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel.left, WidgetDimensions::scaled.bevel.top, 0, WidgetDimensions::scaled.bevel.bottom), PC_BLACK);
 
				if (BaseMusic::GetUsedSet()->num_available == 0) {
 
					break;
 
@@ -802,13 +802,13 @@ struct MusicWindow : public Window {
 
			this->ReInit();
 
		} else {
 
			this->SetDirty();
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_M_PREV: // skip to prev
 
				_music.Prev();
 
				break;
 

	
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -437,22 +437,22 @@ struct NetworkChatWindow : public Window
 
	Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override
 
	{
 
		Point pt = { 0, _screen.height - sm_height - FindWindowById(WC_STATUS_BAR, 0)->height };
 
		return pt;
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget != WID_NC_DESTINATION) return;
 

	
 
		if (this->dtype == DESTTYPE_CLIENT) {
 
			SetDParamStr(0, NetworkClientInfo::GetByClientID((ClientID)this->dest)->client_name);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_NC_SENDBUTTON: /* Send */
 
				SendChat(this->message_editbox.text.buf, this->dtype, this->dest);
 
				FALLTHROUGH;
 

	
 
@@ -469,13 +469,13 @@ struct NetworkChatWindow : public Window
 
			ChatTabCompletion();
 
			state = ES_HANDLED;
 
		}
 
		return state;
 
	}
 

	
 
	void OnEditboxChanged(int widget) override
 
	void OnEditboxChanged(WidgetID widget) override
 
	{
 
		if (widget == WID_NC_TEXTBOX) {
 
			_chat_tab_completion_active = false;
 
		}
 
	}
 

	
src/network/network_content_gui.cpp
Show inline comments
 
@@ -61,13 +61,13 @@ struct ContentTextfileWindow : public Te
 
			case CONTENT_TYPE_SCENARIO:      return STR_CONTENT_TYPE_SCENARIO;
 
			case CONTENT_TYPE_HEIGHTMAP:     return STR_CONTENT_TYPE_HEIGHTMAP;
 
			default: NOT_REACHED();
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_TF_CAPTION) {
 
			SetDParam(0, this->GetTypeString());
 
			SetDParamStr(1, this->ci->name);
 
		}
 
	}
 
@@ -111,13 +111,13 @@ BaseNetworkContentDownloadStatusWindow::
 
void BaseNetworkContentDownloadStatusWindow::Close([[maybe_unused]] int data)
 
{
 
	_network_content_client.RemoveCallback(this);
 
	this->Window::Close();
 
}
 

	
 
void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize)
 
void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize)
 
{
 
	switch (widget) {
 
		case WID_NCDS_PROGRESS_BAR:
 
			SetDParamMaxDigits(0, 8);
 
			SetDParamMaxDigits(1, 8);
 
			SetDParamMaxDigits(2, 8);
 
@@ -130,13 +130,13 @@ void BaseNetworkContentDownloadStatusWin
 
		case WID_NCDS_PROGRESS_TEXT:
 
			size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
 
			break;
 
	}
 
}
 

	
 
void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widget) const
 
void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, WidgetID widget) const
 
{
 
	switch (widget) {
 
		case WID_NCDS_PROGRESS_BAR: {
 
			/* Draw the % complete with a bar and a text */
 
			DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED);
 
			Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
@@ -282,13 +282,13 @@ public:
 
		/* Always invalidate the download window; tell it we are going to be gone */
 
		InvalidateWindowData(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST, 2);
 

	
 
		this->BaseNetworkContentDownloadStatusWindow::Close();
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget == WID_NCDS_CANCELOK) {
 
			if (this->downloaded_bytes != this->total_bytes) {
 
				_network_content_client.CloseConnection();
 
				this->Close();
 
			} else {
 
@@ -578,13 +578,13 @@ public:
 

	
 
	void OnInit() override
 
	{
 
		this->checkbox_size = maxdim(maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED)), GetSpriteSize(SPR_BLOT));
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_NCL_CHECKBOX:
 
				size->width = this->checkbox_size.width + padding.width;
 
				break;
 

	
 
@@ -602,13 +602,13 @@ public:
 
				size->height = 10 * resize->height;
 
				break;
 
		}
 
	}
 

	
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_NCL_DETAILS:
 
				this->DrawDetails(r);
 
				break;
 

	
 
@@ -785,13 +785,13 @@ public:
 
				SetDParamStr(0, buf);
 
				tr.top = DrawStringMultiLine(tr, STR_CONTENT_DETAIL_SELECTED_BECAUSE_OF);
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget >= WID_NCL_TEXTFILE && widget < WID_NCL_TEXTFILE + TFT_CONTENT_END) {
 
			if (this->selected == nullptr || this->selected->state != ContentInfo::ALREADY_HERE) return;
 

	
 
			ShowContentTextfileWindow((TextfileType)(widget - WID_NCL_TEXTFILE), this->selected);
 
			return;
 
@@ -918,13 +918,13 @@ public:
 

	
 
		/* redraw window */
 
		this->InvalidateData();
 
		return ES_HANDLED;
 
	}
 

	
 
	void OnEditboxChanged(int wid) override
 
	void OnEditboxChanged(WidgetID wid) override
 
	{
 
		if (wid == WID_NCL_FILTER) {
 
			this->filter_data.string_filter.SetFilterTerm(this->filter_editbox.text.buf);
 
			this->UpdateFilterState();
 
			this->content.ForceRebuild();
 
			this->InvalidateData();
src/network/network_content_gui.h
Show inline comments
 
@@ -30,14 +30,14 @@ public:
 
	 * Create the window with the given description.
 
	 * @param desc  The description of the window.
 
	 */
 
	BaseNetworkContentDownloadStatusWindow(WindowDesc *desc);
 

	
 
	void Close([[maybe_unused]] int data = 0) override;
 
	void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override;
 
	void DrawWidget(const Rect &r, int widget) const override;
 
	void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override;
 
	void DrawWidget(const Rect &r, WidgetID widget) const override;
 
	void OnDownloadProgress(const ContentInfo *ci, int bytes) override;
 
};
 

	
 
void BuildContentTypeStringList();
 

	
 
#endif /* NETWORK_CONTENT_GUI_H */
src/network/network_gui.cpp
Show inline comments
 
@@ -459,13 +459,13 @@ public:
 
	{
 
		this->lock_offset = ScaleGUITrad(5);
 
		this->blot_offset = this->lock_offset + ScaleGUITrad(3) + GetSpriteSize(SPR_LOCK).width;
 
		this->flag_offset = this->blot_offset + ScaleGUITrad(2) + GetSpriteSize(SPR_BLOT).width;
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_NG_MATRIX:
 
				resize->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
 
				fill->height = resize->height;
 
				size->height = 12 * resize->height;
 
@@ -505,13 +505,13 @@ public:
 
				SetDParamMaxValue(0, 5);
 
				*size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_NG_MATRIX: {
 
				uint16_t y = r.top;
 

	
 
				const int max = std::min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.size());
 
@@ -663,13 +663,13 @@ public:
 
			} else if (sel->info.use_password) {
 
				DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_PASSWORD, TC_FROMSTRING, SA_HOR_CENTER); // password warning
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_NG_CANCEL: // Cancel button
 
				CloseWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
 
				break;
 

	
 
@@ -797,13 +797,13 @@ public:
 
			}
 
		}
 

	
 
		return state;
 
	}
 

	
 
	void OnEditboxChanged(int wid) override
 
	void OnEditboxChanged(WidgetID wid) override
 
	{
 
		switch (wid) {
 
			case WID_NG_FILTER: {
 
				this->servers.ForceRebuild();
 
				this->BuildGUINetworkGameList();
 
				this->ScrollToSelectedServer();
 
@@ -960,26 +960,26 @@ void ShowNetworkGameWindow()
 
	}
 

	
 
	new NetworkGameWindow(&_network_game_window_desc);
 
}
 

	
 
struct NetworkStartServerWindow : public Window {
 
	byte widget_id;              ///< The widget that has the pop-up input menu
 
	WidgetID widget_id;          ///< The widget that has the pop-up input menu
 
	QueryString name_editbox;    ///< Server name editbox.
 

	
 
	NetworkStartServerWindow(WindowDesc *desc) : Window(desc), name_editbox(NETWORK_NAME_LENGTH)
 
	{
 
		this->InitNested(WN_NETWORK_WINDOW_START);
 

	
 
		this->querystrings[WID_NSS_GAMENAME] = &this->name_editbox;
 
		this->name_editbox.text.Assign(_settings_client.network.server_name);
 

	
 
		this->SetFocusedWidget(WID_NSS_GAMENAME);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_NSS_CONNTYPE_BTN:
 
				SetDParam(0, STR_NETWORK_SERVER_VISIBILITY_LOCAL + _settings_client.network.server_game_type);
 
				break;
 

	
 
@@ -990,33 +990,33 @@ struct NetworkStartServerWindow : public
 
			case WID_NSS_COMPANIES_TXT:
 
				SetDParam(0, _settings_client.network.max_companies);
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_NSS_CONNTYPE_BTN:
 
				*size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY));
 
				size->width += padding.width;
 
				size->height += padding.height;
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_NSS_SETPWD:
 
				/* If password is set, draw red '*' next to 'Set password' button. */
 
				if (!_settings_client.network.server_password.empty()) DrawString(r.right + WidgetDimensions::scaled.framerect.left, this->width - WidgetDimensions::scaled.framerect.right, r.top, "*", TC_RED);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_NSS_CANCEL: // Cancel button
 
				ShowNetworkGameWindow();
 
				break;
 

	
 
@@ -1088,13 +1088,13 @@ struct NetworkStartServerWindow : public
 
				_is_network_server = true;
 
				ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_LOAD);
 
				break;
 
		}
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_NSS_CONNTYPE_BTN:
 
				_settings_client.network.server_game_type = (ServerGameType)index;
 
				break;
 
			default:
 
@@ -1653,13 +1653,13 @@ public:
 

	
 
		/* Currently server information is not sync'd to clients, so we cannot show it on clients. */
 
		this->GetWidget<NWidgetStacked>(WID_CL_SERVER_SELECTOR)->SetDisplayedPlane(_network_server ? 0 : SZSP_HORIZONTAL);
 
		this->SetWidgetDisabledState(WID_CL_SERVER_NAME_EDIT, !_network_server);
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_CL_SERVER_VISIBILITY:
 
				*size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY));
 
				size->width += padding.width;
 
				size->height += padding.height;
 
@@ -1681,13 +1681,13 @@ public:
 

	
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_CL_MATRIX);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_CL_SERVER_NAME:
 
				SetDParamStr(0, _network_server ? _settings_client.network.server_name : _network_server_name);
 
				break;
 

	
 
@@ -1716,13 +1716,13 @@ public:
 
				SetDParam(1, Company::GetNumItems());
 
				SetDParam(2, NetworkMaxCompaniesAllowed());
 
				break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_CL_SERVER_NAME_EDIT:
 
				if (!_network_server) break;
 

	
 
				this->query_widget = WID_CL_SERVER_NAME_EDIT;
 
@@ -1750,13 +1750,13 @@ public:
 
				button->OnClick(this, pt);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override
 
	bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override
 
	{
 
		switch (widget) {
 
			case WID_CL_MATRIX: {
 
				int index = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_CL_MATRIX);
 

	
 
				bool rtl = _current_text_dir == TD_RTL;
 
@@ -1789,21 +1789,21 @@ public:
 
			};
 
		}
 

	
 
		return false;
 
	}
 

	
 
	void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
 
	void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close) override
 
	{
 
		/* If you close the dropdown outside the list, don't take any action. */
 
		if (widget == WID_CL_MATRIX) return;
 

	
 
		Window::OnDropdownClose(pt, widget, index, instant_close);
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_CL_SERVER_VISIBILITY:
 
				if (!_network_server) break;
 

	
 
				_settings_client.network.server_game_type = (ServerGameType)index;
 
@@ -2007,13 +2007,13 @@ public:
 

	
 
			y += this->line_height;
 
			line++;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_CL_MATRIX: {
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.framerect, RectPadding::zero);
 
				uint line = 0;
 

	
 
@@ -2043,13 +2043,13 @@ public:
 

	
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnMouseOver([[maybe_unused]] Point pt, int widget) override
 
	void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override
 
	{
 
		if (widget != WID_CL_MATRIX) {
 
			if (this->hover_index != -1) {
 
				this->hover_index = -1;
 
				this->SetWidgetDirty(WID_CL_MATRIX);
 
			}
 
@@ -2079,13 +2079,13 @@ struct NetworkJoinStatusWindow : Window 
 
	NetworkJoinStatusWindow(WindowDesc *desc) : Window(desc)
 
	{
 
		this->parent = FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
 
		this->InitNested(WN_NETWORK_STATUS_WINDOW_JOIN);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_NJS_PROGRESS_BAR: {
 
				/* Draw the % complete with a bar and a text */
 
				DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED);
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
@@ -2130,13 +2130,13 @@ struct NetworkJoinStatusWindow : Window 
 
						break;
 
				}
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_NJS_PROGRESS_BAR:
 
				/* Account for the statuses */
 
				for (uint i = 0; i < NETWORK_JOIN_STATUS_END; i++) {
 
					*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_CONNECTING_1 + i));
 
@@ -2156,13 +2156,13 @@ struct NetworkJoinStatusWindow : Window 
 
				*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1));
 
				*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1));
 
				break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget == WID_NJS_CANCELOK) { // Disconnect button
 
			NetworkDisconnect();
 
			SwitchToMode(SM_MENU);
 
			ShowNetworkGameWindow();
 
		}
 
@@ -2245,20 +2245,20 @@ struct NetworkCompanyPasswordWindow : pu
 
		this->warning_size.height = GetStringHeight(STR_WARNING_PASSWORD_SECURITY, this->warning_size.width);
 
		this->warning_size.height += (WidgetDimensions::scaled.framerect.Vertical()) * 2;
 

	
 
		this->ReInit();
 
	}
 

	
 
	void UpdateWidgetSize(int 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_NCP_WARNING) {
 
			*size = this->warning_size;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_NCP_WARNING) return;
 

	
 
		DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.framerect),
 
			STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
 
	}
 
@@ -2269,13 +2269,13 @@ struct NetworkCompanyPasswordWindow : pu
 
			_settings_client.network.default_company_pass = this->password_editbox.text.buf;
 
		}
 

	
 
		NetworkChangeCompanyPassword(_local_company, this->password_editbox.text.buf);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_NCP_OK:
 
				this->OnOk();
 
				FALLTHROUGH;
 

	
 
@@ -2351,20 +2351,20 @@ struct NetworkAskRelayWindow : public Wi
 
	void Close(int data = 0) override
 
	{
 
		if (data == NRWCD_UNHANDLED) _network_coordinator_client.ConnectFailure(this->token, 0);
 
		this->Window::Close();
 
	}
 

	
 
	void UpdateWidgetSize(int 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_NAR_TEXT) {
 
			*size = GetStringBoundingBox(STR_NETWORK_ASK_RELAY_TEXT);
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget == WID_NAR_TEXT) {
 
			DrawStringMultiLine(r, STR_NETWORK_ASK_RELAY_TEXT, TC_FROMSTRING, SA_CENTER);
 
		}
 
	}
 

	
 
@@ -2373,23 +2373,23 @@ struct NetworkAskRelayWindow : public Wi
 
		/* Position query window over the calling window, ensuring it's within screen bounds. */
 
		this->left = Clamp(parent->left + (parent->width / 2) - (this->width / 2), 0, _screen.width - this->width);
 
		this->top = Clamp(parent->top + (parent->height / 2) - (this->height / 2), 0, _screen.height - this->height);
 
		this->SetDirty();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_NAR_TEXT:
 
				SetDParamStr(0, this->server_connection_string);
 
				SetDParamStr(1, this->relay_connection_string);
 
				break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_NAR_NO:
 
				_network_coordinator_client.ConnectFailure(this->token, 0);
 
				this->Close(NRWCD_HANDLED);
 
				break;
 
@@ -2454,20 +2454,20 @@ struct NetworkAskSurveyWindow : public W
 
		Window(desc)
 
	{
 
		this->parent = parent;
 
		this->InitNested(0);
 
	}
 

	
 
	void UpdateWidgetSize(int 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_NAS_TEXT) {
 
			*size = GetStringBoundingBox(STR_NETWORK_ASK_SURVEY_TEXT);
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget == WID_NAS_TEXT) {
 
			DrawStringMultiLine(r, STR_NETWORK_ASK_SURVEY_TEXT, TC_BLACK, SA_CENTER);
 
		}
 
	}
 

	
 
@@ -2476,13 +2476,13 @@ struct NetworkAskSurveyWindow : public W
 
		/* Position query window over the calling window, ensuring it's within screen bounds. */
 
		this->left = Clamp(parent->left + (parent->width / 2) - (this->width / 2), 0, _screen.width - this->width);
 
		this->top = Clamp(parent->top + (parent->height / 2) - (this->height / 2), 0, _screen.height - this->height);
 
		this->SetDirty();
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_NAS_PREVIEW:
 
				ShowSurveyResultTextfileWindow();
 
				break;
 

	
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -356,20 +356,20 @@ struct NewGRFInspectWindow : Window {
 
		this->vscroll->SetCount(0);
 
		this->SetWidgetDisabledState(WID_NGRFI_PARENT, GetFeatureHelper(this->window_number)->GetParent(this->GetFeatureIndex()) == UINT32_MAX);
 

	
 
		this->OnInvalidateData(0, true);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget != WID_NGRFI_CAPTION) return;
 

	
 
		GetFeatureHelper(this->window_number)->SetStringParameters(this->GetFeatureIndex());
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_NGRFI_VEH_CHAIN: {
 
				assert(this->HasChainIndex());
 
				GrfSpecFeature f = GetFeatureNum(this->window_number);
 
				size->height = std::max(size->height, GetVehicleImageCellSize((VehicleType)(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height + 2 + WidgetDimensions::scaled.bevel.Vertical());
 
@@ -539,26 +539,26 @@ struct NewGRFInspectWindow : Window {
 
		/* Not nice and certainly a hack, but it beats duplicating
 
		 * this whole function just to count the actual number of
 
		 * elements. Especially because they need to be redrawn. */
 
		const_cast<NewGRFInspectWindow*>(this)->vscroll->SetCount(i);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_NGRFI_VEH_CHAIN:
 
				this->DrawVehicleChainWidget(r);
 
				break;
 

	
 
			case WID_NGRFI_MAINPANEL:
 
				this->DrawMainPanelWidget(r);
 
				break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_NGRFI_PARENT: {
 
				const NIHelper *nih   = GetFeatureHelper(this->window_number);
 
				uint index = nih->GetParent(this->GetFeatureIndex());
 
				::ShowNewGRFInspectWindow(GetFeatureNum(index), ::GetFeatureIndex(index), nih->GetGRFID(this->GetFeatureIndex()));
 
@@ -840,13 +840,13 @@ struct SpriteAlignerWindow : Window {
 
		/* Oh yes, we assume there is at least one normal sprite! */
 
		while (GetSpriteType(this->current_sprite) != SpriteType::Normal) this->current_sprite++;
 

	
 
		this->InvalidateData(0, true);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		const Sprite *spr = GetSprite(this->current_sprite, SpriteType::Normal);
 
		switch (widget) {
 
			case WID_SA_CAPTION:
 
				SetDParam(0, this->current_sprite);
 
				SetDParamStr(1, GetOriginFile(this->current_sprite)->GetSimplifiedFilename());
 
@@ -874,13 +874,13 @@ struct SpriteAlignerWindow : Window {
 

	
 
			default:
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_SA_SPRITE:
 
				size->height = ScaleGUITrad(200);
 
				break;
 
			case WID_SA_LIST:
 
@@ -892,13 +892,13 @@ struct SpriteAlignerWindow : Window {
 
				break;
 
			default:
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SA_SPRITE: {
 
				/* Center the sprite ourselves */
 
				const Sprite *spr = GetSprite(this->current_sprite, SpriteType::Normal);
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
@@ -944,13 +944,13 @@ struct SpriteAlignerWindow : Window {
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_SA_PREVIOUS:
 
				do {
 
					this->current_sprite = (this->current_sprite == 0 ? GetMaxSpriteID() :  this->current_sprite) - 1;
 
				} while (GetSpriteType(this->current_sprite) != SpriteType::Normal);
src/newgrf_gui.cpp
Show inline comments
 
@@ -207,13 +207,13 @@ struct NewGRFParametersWindow : public W
 
	 */
 
	GRFParameterInfo &GetParameterInfo(uint nr) const
 
	{
 
		return this->HasParameterInfo(nr) ? this->grf_config->param_info[nr].value() : GetDummyParameterInfo(nr);
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_NP_NUMPAR_DEC:
 
			case WID_NP_NUMPAR_INC: {
 
				size->width  = std::max(SETTING_BUTTON_WIDTH / 2, GetCharacterHeight(FS_NORMAL));
 
				size->height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL));
 
@@ -250,22 +250,22 @@ struct NewGRFParametersWindow : public W
 
				}
 
				size->height = suggestion.height;
 
				break;
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_NP_NUMPAR:
 
				SetDParam(0, this->vscroll->GetCount());
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget == WID_NP_DESCRIPTION) {
 
			if (!this->HasParameterInfo(this->clicked_row)) return;
 
			const GRFParameterInfo &par_info = this->GetParameterInfo(this->clicked_row);
 
			const char *desc = GetGRFStringFromGRFText(par_info.desc);
 
			if (desc == nullptr) return;
 
@@ -328,13 +328,13 @@ struct NewGRFParametersWindow : public W
 
			this->closing_dropdown = false;
 
			this->clicked_dropdown = false;
 
		}
 
		this->DrawWidgets();
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_NP_NUMPAR_DEC:
 
				if (this->editable && !this->action14present && this->grf_config->num_params > 0) {
 
					this->grf_config->num_params--;
 
					this->InvalidateData();
 
@@ -450,22 +450,22 @@ struct NewGRFParametersWindow : public W
 
		GRFParameterInfo &par_info = this->GetParameterInfo(this->clicked_row);
 
		uint32_t val = Clamp<uint32_t>(value, par_info.min_value, par_info.max_value);
 
		par_info.SetValue(this->grf_config, val);
 
		this->SetDirty();
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		if (widget != WID_NP_SETTING_DROPDOWN) return;
 
		assert(this->clicked_dropdown);
 
		GRFParameterInfo &par_info = this->GetParameterInfo(this->clicked_row);
 
		par_info.SetValue(this->grf_config, index);
 
		this->SetDirty();
 
	}
 

	
 
	void OnDropdownClose(Point, int widget, int, bool) override
 
	void OnDropdownClose(Point, WidgetID widget, int, bool) override
 
	{
 
		if (widget != WID_NP_SETTING_DROPDOWN) return;
 
		/* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
 
		 * the same dropdown button was clicked again, and then not open the dropdown again.
 
		 * So, we only remember that it was closed, and process it on the next OnPaint, which is
 
		 * after OnClick. */
 
@@ -561,13 +561,13 @@ struct NewGRFTextfileWindow : public Tex
 
	NewGRFTextfileWindow(TextfileType file_type, const GRFConfig *c) : TextfileWindow(file_type), grf_config(c)
 
	{
 
		auto textfile = this->grf_config->GetTextfile(file_type);
 
		this->LoadTextfile(textfile.value(), NEWGRF_DIR);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_TF_CAPTION) {
 
			SetDParam(0, STR_CONTENT_TYPE_NEWGRF);
 
			SetDParamStr(1, this->grf_config->GetName());
 
		}
 
	}
 
@@ -738,13 +738,13 @@ struct NewGRFWindow : public Window, New
 
			delete *c;
 
			*c = d;
 
			iter->second = d;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_NS_FILE_LIST:
 
			{
 
				Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN));
 
				resize->height = std::max<uint>(d.height + 2U, GetCharacterHeight(FS_NORMAL));
 
@@ -796,13 +796,13 @@ struct NewGRFWindow : public Window, New
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_NS_FILE_LIST);
 
		this->vscroll2->SetCapacityFromWidget(this, WID_NS_AVAIL_LIST);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_NS_PRESET_LIST:
 
				if (this->preset == -1) {
 
					SetDParam(0, STR_NUM_CUSTOM);
 
				} else {
 
@@ -845,13 +845,13 @@ struct NewGRFWindow : public Window, New
 
			}
 
		}
 

	
 
		return pal;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_NS_FILE_LIST: {
 
				const Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
 
				GfxFillRect(br, PC_BLACK);
 

	
 
@@ -937,13 +937,13 @@ struct NewGRFWindow : public Window, New
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget >= WID_NS_NEWGRF_TEXTFILE && widget < WID_NS_NEWGRF_TEXTFILE + TFT_CONTENT_END) {
 
			if (this->active_sel == nullptr && this->avail_sel == nullptr) return;
 

	
 
			ShowNewGRFTextfileWindow((TextfileType)(widget - WID_NS_NEWGRF_TEXTFILE), this->active_sel != nullptr ? this->active_sel : this->avail_sel);
 
			return;
 
@@ -1172,13 +1172,13 @@ struct NewGRFWindow : public Window, New
 
		this->avail_sel = nullptr;
 
		this->avail_pos = -1;
 
		this->avails.ForceRebuild();
 
		this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		if (widget != WID_NS_PRESET_LIST) return;
 
		if (!this->editable) return;
 

	
 
		ClearGRFConfigList(&this->actives);
 
		this->preset = index;
 
@@ -1358,25 +1358,25 @@ struct NewGRFWindow : public Window, New
 
			this->InvalidateData(0);
 
		}
 

	
 
		return ES_HANDLED;
 
	}
 

	
 
	void OnEditboxChanged(int widget) override
 
	void OnEditboxChanged(WidgetID widget) override
 
	{
 
		if (!this->editable) return;
 

	
 
		if (widget == WID_NS_FILTER) {
 
			string_filter.SetFilterTerm(this->filter_editbox.text.buf);
 
			this->avails.SetFilterState(!string_filter.IsEmpty());
 
			this->avails.ForceRebuild();
 
			this->InvalidateData(0);
 
		}
 
	}
 

	
 
	void OnDragDrop(Point pt, int widget) override
 
	void OnDragDrop(Point pt, WidgetID widget) override
 
	{
 
		if (!this->editable) return;
 

	
 
		if (widget == WID_NS_FILE_LIST) {
 
			if (this->active_sel != nullptr) {
 
				/* Get pointer to the selected file in the active list. */
 
@@ -1418,13 +1418,13 @@ struct NewGRFWindow : public Window, New
 
			/* End of drag-and-drop, hide dragged destination highlight. */
 
			this->SetWidgetDirty(this->active_over == -2 ? WID_NS_AVAIL_LIST : WID_NS_FILE_LIST);
 
			this->active_over = -1;
 
		}
 
	}
 

	
 
	void OnMouseDrag(Point pt, int widget) override
 
	void OnMouseDrag(Point pt, WidgetID widget) override
 
	{
 
		if (!this->editable) return;
 

	
 
		if (widget == WID_NS_FILE_LIST && (this->active_sel != nullptr || this->avail_sel != nullptr)) {
 
			/* An NewGRF file is dragged over the active list. */
 
			int to_pos = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NS_FILE_LIST);
 
@@ -2093,13 +2093,13 @@ struct SavePresetWindow : public Window 
 
	}
 

	
 
	~SavePresetWindow()
 
	{
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_SVP_PRESET_LIST: {
 
				resize->height = GetCharacterHeight(FS_NORMAL);
 
				size->height = 0;
 
				for (uint i = 0; i < this->presets.size(); i++) {
 
@@ -2110,13 +2110,13 @@ struct SavePresetWindow : public Window 
 
				size->height = ClampU((uint)this->presets.size(), 5, 20) * resize->height + padding.height;
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SVP_PRESET_LIST: {
 
				const Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
 
				GfxFillRect(br, PC_BLACK);
 

	
 
@@ -2134,13 +2134,13 @@ struct SavePresetWindow : public Window 
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_SVP_PRESET_LIST: {
 
				auto it = this->vscroll->GetScrolledItemFromWidget(this->presets, pt.y, this, WID_SVP_PRESET_LIST);
 
				if (it != this->presets.end()) {
 
					this->selected = it - this->presets.begin();
 
@@ -2208,13 +2208,13 @@ struct ScanProgressWindow : public Windo
 
	/** Create the window. */
 
	ScanProgressWindow() : Window(&_scan_progress_desc), scanned(0)
 
	{
 
		this->InitNested(1);
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_SP_PROGRESS_BAR: {
 
				SetDParamMaxValue(0, 100);
 
				*size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
 
				/* We need some spacing for the 'border' */
 
@@ -2231,13 +2231,13 @@ struct ScanProgressWindow : public Windo
 
				size->width = std::max<uint>(size->width, GetStringBoundingBox(STR_NEWGRF_SCAN_STATUS).width + padding.width);
 
				size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SP_PROGRESS_BAR: {
 
				/* Draw the % complete with a bar and a text */
 
				DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED);
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
src/news_gui.cpp
Show inline comments
 
@@ -339,13 +339,13 @@ struct NewsWindow : Window {
 
	Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override
 
	{
 
		Point pt = { 0, _screen.height };
 
		return pt;
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		StringID str = STR_NULL;
 
		switch (widget) {
 
			case WID_N_CAPTION: {
 
				/* Caption is not a real caption (so that the window cannot be moved)
 
				 * thus it doesn't get the default sizing of a caption. */
 
@@ -413,18 +413,18 @@ struct NewsWindow : Window {
 
		d = GetStringMultiLineBoundingBox(str, d);
 
		d.width += padding.width;
 
		d.height += padding.height;
 
		*size = maxdim(*size, d);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_N_DATE) SetDParam(0, this->ni->date);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_N_CAPTION:
 
				DrawCaption(r, COLOUR_LIGHT_BLUE, this->owner, TC_FROMSTRING, STR_NEWS_MESSAGE_CAPTION, SA_CENTER, FS_NORMAL);
 
				break;
 

	
 
@@ -475,13 +475,13 @@ struct NewsWindow : Window {
 
				DrawStringMultiLine(r.left, r.right, r.top, r.bottom, GetEngineInfoString(engine), TC_FROMSTRING, SA_CENTER);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_N_CLOSEBOX:
 
				NewsWindow::duration = 0;
 
				this->Close();
 
				_forced_news = nullptr;
 
@@ -587,13 +587,13 @@ private:
 
	{
 
		/* Company news with a face have a separate headline, so the normal message is shifted by two params */
 
		CopyInDParam(span(this->ni->params.data() + 2, this->ni->params.size() - 2));
 
		return this->ni->params[1].data;
 
	}
 

	
 
	StringID GetNewVehicleMessageString(int widget) const
 
	StringID GetNewVehicleMessageString(WidgetID widget) const
 
	{
 
		assert(this->ni->reftype1 == NR_ENGINE);
 
		EngineID engine = this->ni->ref1;
 

	
 
		switch (widget) {
 
			case WID_N_VEH_TITLE:
 
@@ -1124,13 +1124,13 @@ struct MessageHistoryWindow : Window {
 
		this->CreateNestedTree();
 
		this->vscroll = this->GetScrollbar(WID_MH_SCROLLBAR);
 
		this->FinishInitNested(); // Initializes 'this->line_height' and 'this->date_width'.
 
		this->OnInvalidateData(0);
 
	}
 

	
 
	void UpdateWidgetSize(int 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_MH_BACKGROUND) {
 
			this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
 
			resize->height = this->line_height;
 

	
 
			/* Months are off-by-one, so it's actually 8. Not using
 
@@ -1146,13 +1146,13 @@ struct MessageHistoryWindow : Window {
 
	void OnPaint() override
 
	{
 
		this->OnInvalidateData(0);
 
		this->DrawWidgets();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_MH_BACKGROUND || _total_news == 0) return;
 

	
 
		/* Find the first news item to display. */
 
		NewsItem *ni = _latest_news;
 
		for (int n = this->vscroll->GetPosition(); n > 0; n--) {
 
@@ -1185,13 +1185,13 @@ struct MessageHistoryWindow : Window {
 
	void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
 
	{
 
		if (!gui_scope) return;
 
		this->vscroll->SetCount(_total_news);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget == WID_MH_BACKGROUND) {
 
			NewsItem *ni = _latest_news;
 
			if (ni == nullptr) return;
 

	
 
			for (int n = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_MH_BACKGROUND, WidgetDimensions::scaled.framerect.top); n > 0; n--) {
src/object_gui.cpp
Show inline comments
 
@@ -181,13 +181,13 @@ public:
 
		} else {
 
			this->SelectFirstAvailableObject(true);
 
		}
 
		assert(ObjectClass::Get(_selected_object_class)->GetUISpecCount() > 0); // object GUI should be disabled elsewise
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_BO_OBJECT_NAME: {
 
				ObjectClass *objclass = ObjectClass::Get(_selected_object_class);
 
				const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
 
				SetDParam(0, spec != nullptr ? spec->name : STR_EMPTY);
 
@@ -209,13 +209,13 @@ public:
 

	
 
	void OnInit() override
 
	{
 
		this->object_margin = ScaleGUITrad(4);
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_BO_CLASS_LIST: {
 
				for (auto object_class_id : this->object_classes) {
 
					ObjectClass *objclass = ObjectClass::Get(object_class_id);
 
					if (objclass->GetUISpecCount() == 0) continue;
 
@@ -301,13 +301,13 @@ public:
 
				break;
 

	
 
			default: break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (GB(widget, 0, 16)) {
 
			case WID_BO_CLASS_LIST: {
 
				Rect mr = r.Shrink(WidgetDimensions::scaled.matrix);
 
				uint pos = 0;
 
				for (auto object_class_id : this->object_classes) {
 
@@ -491,13 +491,13 @@ public:
 

	
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_BO_CLASS_LIST);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (GB(widget, 0, 16)) {
 
			case WID_BO_CLASS_LIST: {
 
				auto it = this->vscroll->GetScrolledItemFromWidget(this->object_classes, pt.y, this, widget);
 
				if (it == this->object_classes.end()) break;
 

	
 
@@ -572,13 +572,13 @@ public:
 
				return ES_NOT_HANDLED;
 
		}
 

	
 
		return ES_HANDLED;
 
	}
 

	
 
	void OnEditboxChanged(int widget) override
 
	void OnEditboxChanged(WidgetID widget) override
 
	{
 
		if (widget == WID_BO_FILTER) {
 
			string_filter.SetFilterTerm(this->filter_editbox.text.buf);
 
			this->object_classes.SetFilterState(!string_filter.IsEmpty());
 
			this->object_classes.ForceRebuild();
 
			this->InvalidateData();
src/order_gui.cpp
Show inline comments
 
@@ -798,13 +798,13 @@ public:
 

	
 
			if (station_orders < 2) this->OrderClick_Goto(OPOS_GOTO);
 
		}
 
		this->OnInvalidateData(VIWD_MODIFY_ORDERS);
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_O_ORDER_LIST:
 
				resize->height = GetCharacterHeight(FS_NORMAL);
 
				size->height = 6 * resize->height + padding.height;
 
				break;
 
@@ -1078,13 +1078,13 @@ public:
 
		} else {
 
			this->SetWidgetLoweredState(WID_O_GOTO, this->goto_type != OPOS_NONE);
 
		}
 
		this->DrawWidgets();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_O_ORDER_LIST) return;
 

	
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
 
		bool rtl = _current_text_dir == TD_RTL;
 
		SetDParamMaxValue(0, this->vehicle->GetNumOrders(), 2);
 
@@ -1137,13 +1137,13 @@ public:
 
		if (this->vscroll->IsVisible(i)) {
 
			StringID str = this->vehicle->IsOrderListShared() ? STR_ORDERS_END_OF_SHARED_ORDERS : STR_ORDERS_END_OF_ORDERS;
 
			DrawString(rtl ? ir.left : middle, rtl ? middle : ir.right, y, str, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_O_COND_VALUE: {
 
				VehicleOrderID sel = this->OrderGetSel();
 
				const Order *order = this->vehicle->GetOrder(sel);
 

	
 
@@ -1158,13 +1158,13 @@ public:
 
			case WID_O_CAPTION:
 
				SetDParam(0, this->vehicle->index);
 
				break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_O_ORDER_LIST: {
 
				if (this->goto_type == OPOS_CONDITIONAL) {
 
					VehicleOrderID order_id = this->GetOrderFromPt(_cursor.pos.y - this->top);
 
					if (order_id != INVALID_VEH_ORDER_ID) {
 
@@ -1348,13 +1348,13 @@ public:
 
					break;
 
			}
 
			Command<CMD_MODIFY_ORDER>::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel, MOF_COND_VALUE, Clamp(value, 0, 2047));
 
		}
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_O_NON_STOP:
 
				this->OrderClick_Nonstop(index);
 
				break;
 

	
 
@@ -1391,13 +1391,13 @@ public:
 
			case WID_O_COND_COMPARATOR:
 
				Command<CMD_MODIFY_ORDER>::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), MOF_COND_COMPARATOR, index);
 
				break;
 
		}
 
	}
 

	
 
	void OnDragDrop(Point pt, int widget) override
 
	void OnDragDrop(Point pt, WidgetID widget) override
 
	{
 
		switch (widget) {
 
			case WID_O_ORDER_LIST: {
 
				VehicleOrderID from_order = this->OrderGetSel();
 
				VehicleOrderID to_order = this->GetOrderFromPt(pt.y);
 

	
 
@@ -1522,13 +1522,13 @@ public:
 
		if (this->order_over != INVALID_VEH_ORDER_ID) {
 
			this->order_over = INVALID_VEH_ORDER_ID;
 
			this->SetWidgetDirty(WID_O_ORDER_LIST);
 
		}
 
	}
 

	
 
	void OnMouseDrag(Point pt, int widget) override
 
	void OnMouseDrag(Point pt, WidgetID widget) override
 
	{
 
		if (this->selected_order != -1 && widget == WID_O_ORDER_LIST) {
 
			/* An order is dragged.. */
 
			VehicleOrderID from_order = this->OrderGetSel();
 
			VehicleOrderID to_order = this->GetOrderFromPt(pt.y);
 
			uint num_orders = this->vehicle->GetNumOrders();
src/osk_gui.cpp
Show inline comments
 
@@ -34,13 +34,13 @@ enum KeyStateBits {
 
};
 
static byte _keystate = KEYS_NONE;
 

	
 
struct OskWindow : public Window {
 
	StringID caption;      ///< the caption for this window.
 
	QueryString *qs;       ///< text-input
 
	int text_btn;          ///< widget number of parent's text field
 
	WidgetID text_btn;     ///< widget number of parent's text field
 
	Textbuf *text;         ///< pointer to parent's textbuffer (to update caret position)
 
	std::string orig_str;  ///< Original string.
 
	bool shift;            ///< Is the shift effectively pressed?
 

	
 
	OskWindow(WindowDesc *desc, Window *parent, int button) : Window(desc)
 
	{
 
@@ -85,26 +85,26 @@ struct OskWindow : public Window {
 
		this->SetWidgetDisabledState(WID_OSK_SPACE, !IsValidChar(' ', this->qs->text.afilter));
 

	
 
		this->SetWidgetLoweredState(WID_OSK_SHIFT, HasBit(_keystate, KEYS_SHIFT));
 
		this->SetWidgetLoweredState(WID_OSK_CAPS, HasBit(_keystate, KEYS_CAPS));
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_OSK_CAPTION) SetDParam(0, this->caption);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget < WID_OSK_LETTERS) return;
 

	
 
		widget -= WID_OSK_LETTERS;
 
		DrawCharCentered(_keyboard[this->shift][widget], r, TC_BLACK);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		/* clicked a letter */
 
		if (widget >= WID_OSK_LETTERS) {
 
			char32_t c = _keyboard[this->shift][widget - WID_OSK_LETTERS];
 

	
 
			if (!IsValidChar(c, this->qs->text.afilter)) return;
 
@@ -180,13 +180,13 @@ struct OskWindow : public Window {
 
					this->Close();
 
				}
 
				break;
 
		}
 
	}
 

	
 
	void OnEditboxChanged(int widget) override
 
	void OnEditboxChanged(WidgetID widget) override
 
	{
 
		if (widget == WID_OSK_TEXT) {
 
			this->SetWidgetDirty(WID_OSK_TEXT);
 
			this->parent->OnEditboxChanged(this->text_btn);
 
			this->parent->SetWidgetDirty(this->text_btn);
 
		}
 
@@ -219,13 +219,13 @@ static const int KEY_PADDING = 6;     //
 
 * @param num_half Number of 1/2 key widths that this key has.
 
 * @param widtype Widget type of the key. Must be either \c NWID_SPACER for an invisible key, or a \c WWT_* widget.
 
 * @param widnum  Widget number of the key.
 
 * @param widdata Data value of the key widget.
 
 * @note Key width is measured in 1/2 keys to allow for 1/2 key shifting between rows.
 
 */
 
static void AddKey(NWidgetHorizontal *hor, int pad_y, int num_half, WidgetType widtype, int widnum, uint16_t widdata)
 
static void AddKey(NWidgetHorizontal *hor, int pad_y, int num_half, WidgetType widtype, WidgetID widnum, uint16_t widdata)
 
{
 
	int key_width = HALF_KEY_WIDTH + (INTER_KEY_SPACE + HALF_KEY_WIDTH) * (num_half - 1);
 

	
 
	if (widtype == NWID_SPACER) {
 
		if (!hor->IsEmpty()) key_width += INTER_KEY_SPACE;
 
		NWidgetSpacer *spc = new NWidgetSpacer(key_width, 0);
 
@@ -257,50 +257,50 @@ static NWidgetBase *MakeTopKeys()
 

	
 
/** Construct the row containing the digit keys. */
 
static NWidgetBase *MakeNumberKeys()
 
{
 
	NWidgetHorizontal *hor = new NWidgetHorizontalLTR();
 

	
 
	for (int widnum = WID_OSK_NUMBERS_FIRST; widnum <= WID_OSK_NUMBERS_LAST; widnum++) {
 
	for (WidgetID widnum = WID_OSK_NUMBERS_FIRST; widnum <= WID_OSK_NUMBERS_LAST; widnum++) {
 
		AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0);
 
	}
 
	return hor;
 
}
 

	
 
/** Construct the qwerty row keys. */
 
static NWidgetBase *MakeQwertyKeys()
 
{
 
	NWidgetHorizontal *hor = new NWidgetHorizontalLTR();
 

	
 
	AddKey(hor, KEY_PADDING, 3, WWT_PUSHIMGBTN, WID_OSK_SPECIAL, SPR_OSK_SPECIAL);
 
	for (int widnum = WID_OSK_QWERTY_FIRST; widnum <= WID_OSK_QWERTY_LAST; widnum++) {
 
	for (WidgetID widnum = WID_OSK_QWERTY_FIRST; widnum <= WID_OSK_QWERTY_LAST; widnum++) {
 
		AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0);
 
	}
 
	AddKey(hor, KEY_PADDING, 1, NWID_SPACER, 0, 0);
 
	return hor;
 
}
 

	
 
/** Construct the asdfg row keys. */
 
static NWidgetBase *MakeAsdfgKeys()
 
{
 
	NWidgetHorizontal *hor = new NWidgetHorizontalLTR();
 

	
 
	AddKey(hor, KEY_PADDING, 4, WWT_IMGBTN, WID_OSK_CAPS, SPR_OSK_CAPS);
 
	for (int widnum = WID_OSK_ASDFG_FIRST; widnum <= WID_OSK_ASDFG_LAST; widnum++) {
 
	for (WidgetID widnum = WID_OSK_ASDFG_FIRST; widnum <= WID_OSK_ASDFG_LAST; widnum++) {
 
		AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0);
 
	}
 
	return hor;
 
}
 

	
 
/** Construct the zxcvb row keys. */
 
static NWidgetBase *MakeZxcvbKeys()
 
{
 
	NWidgetHorizontal *hor = new NWidgetHorizontalLTR();
 

	
 
	AddKey(hor, KEY_PADDING, 3, WWT_IMGBTN, WID_OSK_SHIFT, SPR_OSK_SHIFT);
 
	for (int widnum = WID_OSK_ZXCVB_FIRST; widnum <= WID_OSK_ZXCVB_LAST; widnum++) {
 
	for (WidgetID widnum = WID_OSK_ZXCVB_FIRST; widnum <= WID_OSK_ZXCVB_LAST; widnum++) {
 
		AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0);
 
	}
 
	AddKey(hor, KEY_PADDING, 1, NWID_SPACER, 0, 0);
 
	return hor;
 
}
 

	
 
@@ -387,13 +387,13 @@ void GetKeyboardLayout()
 

	
 
/**
 
 * Show the on-screen keyboard (osk) associated with a given textbox
 
 * @param parent pointer to the Window where this keyboard originated from
 
 * @param button widget number of parent's textbox
 
 */
 
void ShowOnScreenKeyboard(Window *parent, int button)
 
void ShowOnScreenKeyboard(Window *parent, WidgetID button)
 
{
 
	CloseWindowById(WC_OSK, 0);
 

	
 
	GetKeyboardLayout();
 
	new OskWindow(&_osk_desc, parent, button);
 
}
 
@@ -402,13 +402,13 @@ void ShowOnScreenKeyboard(Window *parent
 
 * Updates the original text of the OSK so when the 'parent' changes the
 
 * original and you press on cancel you won't get the 'old' original text
 
 * but the updated one.
 
 * @param parent window that just updated its original text
 
 * @param button widget number of parent's textbox to update
 
 */
 
void UpdateOSKOriginalText(const Window *parent, int button)
 
void UpdateOSKOriginalText(const Window *parent, WidgetID button)
 
{
 
	OskWindow *osk = dynamic_cast<OskWindow *>(FindWindowById(WC_OSK, 0));
 
	if (osk == nullptr || osk->parent != parent || osk->text_btn != button) return;
 

	
 
	osk->orig_str = osk->qs->text.buf;
 

	
 
@@ -418,11 +418,11 @@ void UpdateOSKOriginalText(const Window 
 
/**
 
 * Check whether the OSK is opened for a specific editbox.
 
 * @param w Window to check for
 
 * @param button Editbox of \a w to check for
 
 * @return true if the OSK is opened for \a button.
 
 */
 
bool IsOSKOpenedFor(const Window *w, int button)
 
bool IsOSKOpenedFor(const Window *w, WidgetID button)
 
{
 
	OskWindow *osk = dynamic_cast<OskWindow *>(FindWindowById(WC_OSK, 0));
 
	return osk != nullptr && osk->parent == w && osk->text_btn == button;
 
}
src/querystring_gui.h
Show inline comments
 
@@ -37,20 +37,20 @@ struct QueryString {
 
	 */
 
	QueryString(uint16_t size, uint16_t chars = UINT16_MAX) : ok_button(ACTION_NOTHING), cancel_button(ACTION_DESELECT), text(size, chars)
 
	{
 
	}
 

	
 
public:
 
	void DrawEditBox(const Window *w, int wid) const;
 
	void ClickEditBox(Window *w, Point pt, int wid, int click_count, bool focus_changed);
 
	void HandleEditBox(Window *w, int wid);
 
	void DrawEditBox(const Window *w, WidgetID wid) const;
 
	void ClickEditBox(Window *w, Point pt, WidgetID wid, int click_count, bool focus_changed);
 
	void HandleEditBox(Window *w, WidgetID wid);
 

	
 
	Point GetCaretPosition(const Window *w, int wid) const;
 
	Rect GetBoundingRect(const Window *w, int wid, const char *from, const char *to) const;
 
	ptrdiff_t GetCharAtPosition(const Window *w, int wid, const Point &pt) const;
 
	Point GetCaretPosition(const Window *w, WidgetID wid) const;
 
	Rect GetBoundingRect(const Window *w, WidgetID wid, const char *from, const char *to) const;
 
	ptrdiff_t GetCharAtPosition(const Window *w, WidgetID wid, const Point &pt) const;
 
};
 

	
 
void ShowOnScreenKeyboard(Window *parent, int button);
 
void UpdateOSKOriginalText(const Window *parent, int button);
 
bool IsOSKOpenedFor(const Window *w, int button);
 
void ShowOnScreenKeyboard(Window *parent, WidgetID button);
 
void UpdateOSKOriginalText(const Window *parent, WidgetID button);
 
bool IsOSKOpenedFor(const Window *w, WidgetID button);
 

	
 
#endif /* QUERYSTRING_GUI_H */
src/rail_gui.cpp
Show inline comments
 
@@ -303,13 +303,13 @@ static void ToggleRailButton_Remove(Wind
 
 */
 
static bool RailToolbar_CtrlChanged(Window *w)
 
{
 
	if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return false;
 

	
 
	/* allow ctrl to switch remove mode only for these widgets */
 
	for (uint i = WID_RAT_BUILD_NS; i <= WID_RAT_BUILD_STATION; i++) {
 
	for (WidgetID i = WID_RAT_BUILD_NS; i <= WID_RAT_BUILD_STATION; i++) {
 
		if ((i <= WID_RAT_AUTORAIL || i >= WID_RAT_BUILD_WAYPOINT) && w->IsWidgetLowered(i)) {
 
			ToggleRailButton_Remove(w);
 
			return true;
 
		}
 
	}
 

	
 
@@ -455,13 +455,13 @@ struct BuildRailToolbarWindow : Window {
 
	void ModifyRailType(RailType railtype)
 
	{
 
		this->SetupRailToolbar(railtype);
 
		this->ReInit();
 
	}
 

	
 
	void UpdateRemoveWidgetStatus(int clicked_widget)
 
	void UpdateRemoveWidgetStatus(WidgetID clicked_widget)
 
	{
 
		switch (clicked_widget) {
 
			case WID_RAT_REMOVE:
 
				/* If it is the removal button that has been clicked, do nothing,
 
				 * as it is up to the other buttons to drive removal status */
 
				return;
 
@@ -485,13 +485,13 @@ struct BuildRailToolbarWindow : Window {
 
				this->DisableWidget(WID_RAT_REMOVE);
 
				this->RaiseWidget(WID_RAT_REMOVE);
 
				break;
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_RAT_CAPTION) {
 
			const RailTypeInfo *rti = GetRailTypeInfo(this->railtype);
 
			if (rti->max_speed > 0) {
 
				SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
 
				SetDParam(1, rti->strings.toolbar_caption);
 
@@ -499,13 +499,13 @@ struct BuildRailToolbarWindow : Window {
 
			} else {
 
				SetDParam(0, rti->strings.toolbar_caption);
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget < WID_RAT_BUILD_NS) return;
 

	
 
		_remove_button_clicked = false;
 
		switch (widget) {
 
			case WID_RAT_BUILD_NS:
 
@@ -1120,13 +1120,13 @@ public:
 
				return ES_NOT_HANDLED;
 
		}
 

	
 
		return ES_HANDLED;
 
	}
 

	
 
	void OnEditboxChanged(int widget) override
 
	void OnEditboxChanged(WidgetID widget) override
 
	{
 
		if (widget == WID_BRAS_FILTER_EDITBOX) {
 
			string_filter.SetFilterTerm(this->filter_editbox.text.buf);
 
			this->station_classes.SetFilterState(!string_filter.IsEmpty());
 
			this->station_classes.ForceRebuild();
 
			this->InvalidateData();
 
@@ -1178,13 +1178,13 @@ public:
 
		if (top > r.bottom) {
 
			this->coverage_height += top - r.bottom;
 
			this->ReInit();
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_BRAS_NEWST_LIST: {
 
				Dimension d = {0, 0};
 
				for (auto station_class : this->station_classes) {
 
					d = maxdim(d, GetStringBoundingBox(StationClass::Get(station_class)->name));
 
@@ -1233,13 +1233,13 @@ public:
 
				fill->height = 1;
 
				resize->height = 1;
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		DrawPixelInfo tmp_dpi;
 

	
 
		switch (GB(widget, 0, 16)) {
 
			case WID_BRAS_PLATFORM_DIR_X: {
 
				/* Set up a clipping area for the '/' station preview */
 
@@ -1312,21 +1312,21 @@ public:
 
	{
 
		if (this->vscroll != nullptr) { // New stations available.
 
			this->vscroll->SetCapacityFromWidget(this, WID_BRAS_NEWST_LIST);
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_BRAS_SHOW_NEWST_TYPE) {
 
			const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type);
 
			SetDParam(0, (statspec != nullptr && statspec->name != 0) ? statspec->name : STR_STATION_CLASS_DFLT_STATION);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (GB(widget, 0, 16)) {
 
			case WID_BRAS_PLATFORM_DIR_X:
 
			case WID_BRAS_PLATFORM_DIR_Y:
 
				this->RaiseWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
 
				_railstation.orientation = (Axis)(widget - WID_BRAS_PLATFORM_DIR_X);
 
@@ -1641,13 +1641,13 @@ private:
 
	 * Draw dynamic a signal-sprite in a button in the signal GUI
 
	 * Draw the sprite +1px to the right and down if the button is lowered
 
	 *
 
	 * @param widget_index index of this widget in the window
 
	 * @param image        the sprite to draw
 
	 */
 
	void DrawSignalSprite(const Rect &r, int widget_index, SpriteID image) const
 
	void DrawSignalSprite(const Rect &r, WidgetID widget_index, SpriteID image) const
 
	{
 
		Point offset;
 
		Dimension sprite_size = GetSpriteSize(image, &offset);
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.imgbtn);
 
		int x = CenterBounds(ir.left, ir.right, sprite_size.width - offset.x) - offset.x; // centered
 
		int y = ir.top - sig_sprite_bottom_offset +
 
@@ -1705,47 +1705,47 @@ public:
 
					this->sig_sprite_size.height = std::max<int>(this->sig_sprite_size.height, sprite_size.height - offset.y);
 
				}
 
			}
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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_BS_DRAG_SIGNALS_DENSITY_LABEL) {
 
			/* Two digits for signals density. */
 
			size->width = std::max(size->width, 2 * GetDigitWidth() + padding.width + WidgetDimensions::scaled.framerect.Horizontal());
 
		} else if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) {
 
			size->width = std::max(size->width, this->sig_sprite_size.width + padding.width);
 
			size->height = std::max(size->height, this->sig_sprite_size.height + padding.height);
 
		} else if (widget == WID_BS_CAPTION) {
 
			size->width += WidgetDimensions::scaled.frametext.Horizontal();
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_BS_DRAG_SIGNALS_DENSITY_LABEL:
 
				SetDParam(0, _settings_client.gui.drag_signals_density);
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) {
 
			/* Extract signal from widget number. */
 
			int type = (widget - WID_BS_SEMAPHORE_NORM) % SIGTYPE_END;
 
			int var = SIG_SEMAPHORE - (widget - WID_BS_SEMAPHORE_NORM) / SIGTYPE_END; // SignalVariant order is reversed compared to the widgets.
 
			SpriteID sprite = GetRailTypeInfo(_cur_railtype)->gui_sprites.signals[type][var][this->IsWidgetLowered(widget)];
 

	
 
			this->DrawSignalSprite(r, widget, sprite);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_BS_SEMAPHORE_NORM:
 
			case WID_BS_SEMAPHORE_ENTRY:
 
			case WID_BS_SEMAPHORE_EXIT:
 
			case WID_BS_SEMAPHORE_COMBO:
 
@@ -1894,21 +1894,21 @@ struct BuildRailDepotWindow : public Pic
 
	BuildRailDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
 
	{
 
		this->InitNested(TRANSPORT_RAIL);
 
		this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE);
 
	}
 

	
 
	void UpdateWidgetSize(int 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 (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
 

	
 
		size->width  = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
 
		size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
 

	
 
		DrawPixelInfo tmp_dpi;
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
		if (FillDrawPixelInfo(&tmp_dpi, ir)) {
 
@@ -1916,13 +1916,13 @@ struct BuildRailDepotWindow : public Pic
 
			int x = (ir.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
			int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
 
			DrawTrainDepotSprite(x, y, widget - WID_BRAD_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_BRAD_DEPOT_NE:
 
			case WID_BRAD_DEPOT_SE:
 
			case WID_BRAD_DEPOT_SW:
 
			case WID_BRAD_DEPOT_NW:
 
@@ -2049,13 +2049,13 @@ struct BuildRailWaypointWindow : PickerW
 
		} else {
 
			_cur_waypoint_type = this->list.front();
 
			return 0;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_BRW_WAYPOINT_MATRIX:
 
				/* Two blobs high and three wide. */
 
				size->width  += resize->width  * 2;
 
				size->height += resize->height * 1;
 
@@ -2068,13 +2068,13 @@ struct BuildRailWaypointWindow : PickerW
 
				size->width  = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
 
				size->height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical();
 
				break;
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_BRW_NAME) {
 
			if (!this->list.empty() && IsInsideBS(_cur_waypoint_type, 0, this->waypoints->GetSpecCount())) {
 
				const StationSpec *statspec = this->waypoints->GetSpec(_cur_waypoint_type);
 
				if (statspec == nullptr) {
 
					SetDParam(0, STR_STATION_CLASS_WAYP_WAYPOINT);
 
@@ -2090,13 +2090,13 @@ struct BuildRailWaypointWindow : PickerW
 
	void OnPaint() override
 
	{
 
		this->BuildPickerList();
 
		this->DrawWidgets();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (GB(widget, 0, 16)) {
 
			case WID_BRW_WAYPOINT: {
 
				uint16_t type = this->list.at(GB(widget, 16, 16));
 
				const StationSpec *statspec = this->waypoints->GetSpec(type);
 

	
 
@@ -2113,13 +2113,13 @@ struct BuildRailWaypointWindow : PickerW
 
					GfxFillRect(ir, PC_BLACK, FILLRECT_CHECKER);
 
				}
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (GB(widget, 0, 16)) {
 
			case WID_BRW_WAYPOINT: {
 
				uint16_t sel = GB(widget, 16, 16);
 
				assert(sel < this->list.size());
 
				uint16_t type = this->list.at(sel);
 
@@ -2140,13 +2140,13 @@ struct BuildRailWaypointWindow : PickerW
 
	void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
 
	{
 
		if (!gui_scope) return;
 
		this->list.ForceRebuild();
 
	}
 

	
 
	void OnEditboxChanged(int wid) override
 
	void OnEditboxChanged(WidgetID wid) override
 
	{
 
		if (wid == WID_BRW_FILTER) {
 
			this->string_filter.SetFilterTerm(this->editbox.text.buf);
 
			this->InvalidateData();
 
		}
 
	}
src/road_gui.cpp
Show inline comments
 
@@ -291,13 +291,13 @@ static void ToggleRoadButton_Remove(Wind
 
 */
 
static bool RoadToolbar_CtrlChanged(Window *w)
 
{
 
	if (w->IsWidgetDisabled(WID_ROT_REMOVE)) return false;
 

	
 
	/* allow ctrl to switch remove mode only for these widgets */
 
	for (uint i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) {
 
	for (WidgetID i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) {
 
		if (w->IsWidgetLowered(i)) {
 
			ToggleRoadButton_Remove(w);
 
			return true;
 
		}
 
	}
 

	
 
@@ -400,13 +400,13 @@ struct BuildRoadToolbarWindow : Window {
 
	{
 
		this->Initialize(roadtype);
 
		this->SetupRoadToolbar();
 
		this->ReInit();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_ROT_CAPTION) {
 
			if (this->rti->max_speed > 0) {
 
				SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
 
				SetDParam(1, this->rti->strings.toolbar_caption);
 
				SetDParam(2, PackVelocity(this->rti->max_speed / 2, VEH_ROAD));
 
@@ -467,13 +467,13 @@ struct BuildRoadToolbarWindow : Window {
 
				}
 

	
 
				break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		_remove_button_clicked = false;
 
		_one_way_button_clicked = false;
 
		switch (widget) {
 
			case WID_ROT_ROAD_X:
 
				HandlePlacePushButton(this, WID_ROT_ROAD_X, this->rti->cursor.road_nwse, HT_RECT);
 
@@ -1007,27 +1007,29 @@ struct BuildRoadDepotWindow : public Pic
 
	{
 
		this->CreateNestedTree();
 

	
 
		this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
 
		if (RoadTypeIsTram(_cur_roadtype)) {
 
			this->GetWidget<NWidgetCore>(WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION;
 
			for (int i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
 
			for (WidgetID i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) {
 
				this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
 
			}
 
		}
 

	
 
		this->FinishInitNested(TRANSPORT_ROAD);
 
	}
 

	
 
	void UpdateWidgetSize(int 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 (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
 

	
 
		size->width  = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
 
		size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
 

	
 
		DrawPixelInfo tmp_dpi;
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
		if (FillDrawPixelInfo(&tmp_dpi, ir)) {
 
@@ -1035,13 +1037,13 @@ struct BuildRoadDepotWindow : public Pic
 
			int x = (ir.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
			int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
 
			DrawRoadDepotSprite(x, y, (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_BROD_DEPOT_NW:
 
			case WID_BROD_DEPOT_NE:
 
			case WID_BROD_DEPOT_SW:
 
			case WID_BROD_DEPOT_SE:
 
@@ -1175,13 +1177,13 @@ public:
 
		if (RoadTypeIsTram(_cur_roadtype) && _roadstop_gui_settings.orientation < DIAGDIR_END) {
 
			_roadstop_gui_settings.orientation = DIAGDIR_END;
 
		}
 
		const RoadTypeInfo *rti = GetRoadTypeInfo(_cur_roadtype);
 
		this->GetWidget<NWidgetCore>(WID_BROS_CAPTION)->widget_data = rti->strings.picker_title[rs];
 

	
 
		for (uint i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) {
 
		for (WidgetID i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) {
 
			this->GetWidget<NWidgetCore>(i)->tool_tip = rti->strings.picker_tooltip[rs];
 
		}
 

	
 
		this->LowerWidget(_roadstop_gui_settings.orientation + WID_BROS_STATION_NE);
 
		this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
 

	
 
@@ -1300,13 +1302,13 @@ public:
 
			return ES_HANDLED;
 
		}
 

	
 
		return ES_NOT_HANDLED;
 
	}
 

	
 
	void OnEditboxChanged(int widget) override
 
	void OnEditboxChanged(WidgetID widget) override
 
	{
 
		if (widget == WID_BROS_FILTER_EDITBOX) {
 
			string_filter.SetFilterTerm(this->filter_editbox.text.buf);
 
			this->roadstop_classes.SetFilterState(!string_filter.IsEmpty());
 
			this->roadstop_classes.ForceRebuild();
 
			this->InvalidateData();
 
@@ -1338,13 +1340,13 @@ public:
 
		if (top > r.bottom) {
 
			this->coverage_height += top - r.bottom;
 
			this->ReInit();
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_BROS_NEWST_LIST: {
 
				Dimension d = { 0, 0 };
 
				for (auto rs_class : this->roadstop_classes) {
 
					d = maxdim(d, GetStringBoundingBox(RoadStopClass::Get(rs_class)->name));
 
@@ -1402,13 +1404,13 @@ public:
 
			case WC_BUS_STATION:          return STATION_BUS;
 
			case WC_TRUCK_STATION:        return STATION_TRUCK;
 
			default: NOT_REACHED();
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (GB(widget, 0, 16)) {
 
			case WID_BROS_STATION_NE:
 
			case WID_BROS_STATION_SE:
 
			case WID_BROS_STATION_SW:
 
			case WID_BROS_STATION_NW:
 
@@ -1482,21 +1484,21 @@ public:
 
	{
 
		if (this->vscrollList != nullptr) {
 
			this->vscrollList->SetCapacityFromWidget(this, WID_BROS_NEWST_LIST);
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_BROS_SHOW_NEWST_TYPE) {
 
			const RoadStopSpec *roadstopspec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
 
			SetDParam(0, (roadstopspec != nullptr && roadstopspec->name != 0) ? roadstopspec->name : STR_STATION_CLASS_DFLT_ROADSTOP);
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (GB(widget, 0, 16)) {
 
			case WID_BROS_STATION_NE:
 
			case WID_BROS_STATION_SE:
 
			case WID_BROS_STATION_SW:
 
			case WID_BROS_STATION_NW:
src/screenshot_gui.cpp
Show inline comments
 
@@ -24,13 +24,13 @@ struct ScreenshotWindow : Window {
 

	
 
	void OnPaint() override
 
	{
 
		this->DrawWidgets();
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		ScreenshotType st;
 
		switch (widget) {
 
			default: return;
 
			case WID_SC_TAKE:             st = SC_VIEWPORT;    break;
 
			case WID_SC_TAKE_ZOOMIN:      st = SC_ZOOMEDIN;    break;
src/script/api/script_event_types.hpp
Show inline comments
 
@@ -921,13 +921,13 @@ public:
 
#ifndef DOXYGEN_API
 
	/**
 
	 * @param window The windowclass that was clicked.
 
	 * @param number The windownumber that was clicked.
 
	 * @param widget The widget in the window that was clicked.
 
	 */
 
	ScriptEventWindowWidgetClick(ScriptWindow::WindowClass window, uint32_t number, uint8_t widget) :
 
	ScriptEventWindowWidgetClick(ScriptWindow::WindowClass window, uint32_t number, WidgetID widget) :
 
		ScriptEvent(ET_WINDOW_WIDGET_CLICK),
 
		window(window),
 
		number(number),
 
		widget(widget)
 
	{}
 
#endif /* DOXYGEN_API */
 
@@ -952,18 +952,18 @@ public:
 
	uint32_t GetWindowNumber() { return this->number; }
 

	
 
	/**
 
	 * Get the number of the widget that was clicked.
 
	 * @return The number of the clicked widget.
 
	 */
 
	uint8_t GetWidgetNumber() { return this->widget; }
 
	int GetWidgetNumber() { return this->widget; }
 

	
 
private:
 
	ScriptWindow::WindowClass window; ///< Window of the click.
 
	uint32_t number;                    ///< Number of the click.
 
	uint8_t widget;                     ///< Widget of the click.
 
	uint32_t number;                  ///< Number of the click.
 
	WidgetID widget;                       ///< Widget of the click.
 
};
 

	
 
/**
 
 * Event Goal Question Answer, where you receive the answer given to your questions.
 
 * @note It is possible that you get more than 1 answer from the same company
 
 *  (due to lag). Please keep this in mind while handling this event.
src/script/script_gui.cpp
Show inline comments
 
@@ -92,31 +92,31 @@ struct ScriptListWindow : public Window 
 

	
 
				i++;
 
			}
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget != WID_SCRL_CAPTION) return;
 

	
 
		SetDParam(0, (this->slot == OWNER_DEITY) ? STR_AI_LIST_CAPTION_GAMESCRIPT : STR_AI_LIST_CAPTION_AI);
 
	}
 

	
 
	void UpdateWidgetSize(int 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_SCRL_LIST) return;
 

	
 
		this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
 

	
 
		resize->width = 1;
 
		resize->height = this->line_height;
 
		size->height = 5 * this->line_height;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SCRL_LIST: {
 
				/* Draw a list of all available Scripts. */
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.matrix);
 
				/* First AI in the list is hardcoded to random */
 
@@ -181,13 +181,13 @@ struct ScriptListWindow : public Window 
 
		InvalidateWindowData(WC_GAME_OPTIONS, slot == OWNER_DEITY ? WN_GAME_OPTIONS_GS : WN_GAME_OPTIONS_AI);
 
		InvalidateWindowClassesData(WC_SCRIPT_SETTINGS);
 
		CloseWindowByClass(WC_QUERY_STRING);
 
		InvalidateWindowClassesData(WC_TEXTFILE);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_SCRL_LIST: { // Select one of the Scripts
 
				int sel = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SCRL_LIST) - 1;
 
				if (sel < (int)this->info_list->size()) {
 
					this->selected = sel;
 
@@ -332,31 +332,31 @@ struct ScriptSettingsWindow : public Win
 
			}
 
		}
 

	
 
		this->vscroll->SetCount(this->visible_settings.size());
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget != WID_SCRS_CAPTION) return;
 

	
 
		SetDParam(0, (this->slot == OWNER_DEITY) ? STR_AI_SETTINGS_CAPTION_GAMESCRIPT : STR_AI_SETTINGS_CAPTION_AI);
 
	}
 

	
 
	void UpdateWidgetSize(int 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_SCRS_BACKGROUND) return;
 

	
 
		this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height;
 

	
 
		resize->width = 1;
 
		resize->height = this->line_height;
 
		size->height = 5 * this->line_height;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_SCRS_BACKGROUND) return;
 

	
 
		ScriptConfig *config = this->script_config;
 
		VisibleSettingsList::const_iterator it = this->visible_settings.begin();
 
		int i = 0;
 
@@ -418,13 +418,13 @@ struct ScriptSettingsWindow : public Win
 
			this->closing_dropdown = false;
 
			this->clicked_dropdown = false;
 
		}
 
		this->DrawWidgets();
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_SCRS_BACKGROUND: {
 
				auto it = this->vscroll->GetScrolledItemFromWidget(this->visible_settings, pt.y, this, widget);
 
				if (it == this->visible_settings.end()) break;
 

	
 
@@ -521,20 +521,20 @@ struct ScriptSettingsWindow : public Win
 
		if (StrEmpty(str)) return;
 
		int32_t value = atoi(str);
 

	
 
		SetValue(value);
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		if (widget != WID_SCRS_SETTING_DROPDOWN) return;
 
		assert(this->clicked_dropdown);
 
		SetValue(index);
 
	}
 

	
 
	void OnDropdownClose(Point, int widget, int, bool) override
 
	void OnDropdownClose(Point, WidgetID widget, int, bool) override
 
	{
 
		if (widget != WID_SCRS_SETTING_DROPDOWN) return;
 
		/* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
 
		 * the same dropdown button was clicked again, and then not open the dropdown again.
 
		 * So, we only remember that it was closed, and process it on the next OnPaint, which is
 
		 * after OnClick. */
 
@@ -631,13 +631,13 @@ struct ScriptTextfileWindow : public Tex
 

	
 
	ScriptTextfileWindow(TextfileType file_type, CompanyID slot) : TextfileWindow(file_type), slot(slot)
 
	{
 
		this->OnInvalidateData();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_TF_CAPTION) {
 
			SetDParam(0, (slot == OWNER_DEITY) ? STR_CONTENT_TYPE_GAME_SCRIPT : STR_CONTENT_TYPE_AI);
 
			SetDParamStr(1, GetConfig(slot)->GetInfo()->GetName());
 
		}
 
	}
 
@@ -818,13 +818,13 @@ struct ScriptDebugWindow : public Window
 

	
 
	~ScriptDebugWindow()
 
	{
 
		ScriptDebugWindow::initial_state = this->filter;
 
	}
 

	
 
	void UpdateWidgetSize(int 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_SCRD_LOG_PANEL) {
 
			resize->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
 
			size->height = 14 * resize->height + WidgetDimensions::scaled.framerect.Vertical();
 
		}
 
	}
 
@@ -835,13 +835,13 @@ struct ScriptDebugWindow : public Window
 
		this->UpdateLogScroll();
 

	
 
		/* Draw standard stuff */
 
		this->DrawWidgets();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget != WID_SCRD_NAME_TEXT) return;
 

	
 
		if (this->filter.script_debug_company == OWNER_DEITY) {
 
			const GameInfo *info = Game::GetInfo();
 
			assert(info != nullptr);
 
@@ -856,13 +856,13 @@ struct ScriptDebugWindow : public Window
 
			SetDParam(0, STR_AI_DEBUG_NAME_AND_VERSION);
 
			SetDParamStr(1, info->GetName());
 
			SetDParam(2, info->GetVersion());
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SCRD_LOG_PANEL:
 
				this->DrawWidgetLog(r);
 
				break;
 

	
 
@@ -877,13 +877,13 @@ struct ScriptDebugWindow : public Window
 
	/**
 
	 * Draw a company button icon.
 
	 * @param r Rect area to draw within.
 
	 * @param widget Widget index to start.
 
	 * @param start Widget index of first company button.
 
	 */
 
	void DrawWidgetCompanyButton(const Rect &r, int widget, int start) const
 
	void DrawWidgetCompanyButton(const Rect &r, WidgetID widget, int start) const
 
	{
 
		if (this->IsWidgetDisabled(widget)) return;
 
		CompanyID cid = (CompanyID)(widget - start);
 
		Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON);
 
		DrawCompanyIcon(cid, CenterBounds(r.left, r.right, sprite_size.width), CenterBounds(r.top, r.bottom, sprite_size.height));
 
	}
 
@@ -1031,13 +1031,13 @@ struct ScriptDebugWindow : public Window
 
		this->InvalidateData(-1);
 

	
 
		this->autoscroll = true;
 
		this->last_vscroll_pos = this->vscroll->GetPosition();
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		/* Also called for hotkeys, so check for disabledness */
 
		if (this->IsWidgetDisabled(widget)) return;
 

	
 
		/* Check which button is clicked */
 
		if (IsInsideMM(widget, WID_SCRD_COMPANY_BUTTON_START, WID_SCRD_COMPANY_BUTTON_END + 1)) {
 
@@ -1100,13 +1100,13 @@ struct ScriptDebugWindow : public Window
 
				this->highlight_row = -1;
 
				this->InvalidateData(-1);
 
				break;
 
		}
 
	}
 

	
 
	void OnEditboxChanged(int wid) override
 
	void OnEditboxChanged(WidgetID wid) override
 
	{
 
		if (wid != WID_SCRD_BREAK_STR_EDIT_BOX) return;
 

	
 
		/* Save the current string to static member so it can be restored next time the window is opened. */
 
		this->filter.break_string = this->break_editbox.text.buf;
 
		this->break_string_filter.SetFilterTerm(this->filter.break_string);
src/settings_gui.cpp
Show inline comments
 
@@ -93,13 +93,13 @@ struct BaseSetTextfileWindow : public Te
 
	BaseSetTextfileWindow(TextfileType file_type, const TBaseSet* baseset, StringID content_type) : TextfileWindow(file_type), baseset(baseset), content_type(content_type)
 
	{
 
		auto textfile = this->baseset->GetTextfile(file_type);
 
		this->LoadTextfile(textfile.value(), BASESET_DIR);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_TF_CAPTION) {
 
			SetDParam(0, content_type);
 
			SetDParamStr(1, this->baseset->name);
 
		}
 
	}
 
@@ -167,13 +167,13 @@ static const std::map<int, StringID> _vo
 
};
 

	
 
struct GameOptionsWindow : Window {
 
	GameSettings *opt;
 
	bool reload;
 
	int gui_scale;
 
	static inline int active_tab = WID_GO_TAB_GENERAL;
 
	static inline WidgetID active_tab = WID_GO_TAB_GENERAL;
 

	
 
	GameOptionsWindow(WindowDesc *desc) : Window(desc)
 
	{
 
		this->opt = &GetGameSettings();
 
		this->reload = false;
 
		this->gui_scale = _gui_scale;
 
@@ -199,13 +199,13 @@ struct GameOptionsWindow : Window {
 
	/**
 
	 * Build the dropdown list for a specific widget.
 
	 * @param widget         Widget to build list for
 
	 * @param selected_index Currently selected item
 
	 * @return the built dropdown list, or nullptr if the widget has no dropdown menu.
 
	 */
 
	DropDownList BuildDropDownList(int widget, int *selected_index) const
 
	DropDownList BuildDropDownList(WidgetID widget, int *selected_index) const
 
	{
 
		DropDownList list;
 
		switch (widget) {
 
			case WID_GO_CURRENCY_DROPDOWN: { // Setup currencies dropdown
 
				*selected_index = this->opt->locale.currency;
 
				uint64_t disabled = _game_mode == GM_MENU ? 0LL : ~GetMaskOfAllowedCurrencies();
 
@@ -301,13 +301,13 @@ struct GameOptionsWindow : Window {
 
				break;
 
		}
 

	
 
		return list;
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_GO_CURRENCY_DROPDOWN: {
 
				const CurrencySpec &currency = _currency_specs[this->opt->locale.currency];
 
				if (currency.code.empty()) {
 
					SetDParam(0, currency.name);
 
@@ -344,13 +344,13 @@ struct GameOptionsWindow : Window {
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_GO_BASE_GRF_DESCRIPTION:
 
				SetDParamStr(0, BaseGraphics::GetUsedSet()->GetDescription(GetCurrentLanguageIsoCode()));
 
				DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
 
				break;
 
@@ -381,13 +381,13 @@ struct GameOptionsWindow : Window {
 
			case WID_GO_BASE_MUSIC_VOLUME:
 
				DrawSliderWidget(r, 0, INT8_MAX, _settings_client.music.music_vol, _volume_labels);
 
				break;
 
		}
 
	}
 

	
 
	void SetTab(int widget)
 
	void SetTab(WidgetID widget)
 
	{
 
		this->SetWidgetsLoweredState(false, WID_GO_TAB_GENERAL, WID_GO_TAB_GRAPHICS, WID_GO_TAB_SOUND);
 
		this->LowerWidget(widget);
 
		GameOptionsWindow::active_tab = widget;
 

	
 
		int pane = 0;
 
@@ -430,13 +430,13 @@ struct GameOptionsWindow : Window {
 
		y = GetStringHeight(STR_GAME_OPTIONS_VIDEO_DRIVER_INFO, wid->current_x);
 
		changed |= wid->UpdateVerticalSize(y);
 

	
 
		if (changed) this->ReInit(0, 0, this->flags & WF_CENTERED);
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_GO_TEXT_SFX_VOLUME:
 
			case WID_GO_TEXT_MUSIC_VOLUME: {
 
				Dimension d = maxdim(GetStringBoundingBox(STR_GAME_OPTIONS_SFX_VOLUME), GetStringBoundingBox(STR_GAME_OPTIONS_MUSIC_VOLUME));
 
				d.width += padding.width;
 
@@ -450,13 +450,13 @@ struct GameOptionsWindow : Window {
 
				size->width = std::max(size->width, GetDropDownListDimension(this->BuildDropDownList(widget, &selected)).width + padding.width);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget >= WID_GO_BASE_GRF_TEXTFILE && widget < WID_GO_BASE_GRF_TEXTFILE + TFT_CONTENT_END) {
 
			if (BaseGraphics::GetUsedSet() == nullptr) return;
 

	
 
			ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_GRF_TEXTFILE), BaseGraphics::GetUsedSet(), STR_CONTENT_TYPE_BASE_GRAPHICS);
 
			return;
 
@@ -641,13 +641,13 @@ struct GameOptionsWindow : Window {
 
			ReInitAllWindows(true);
 
			this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, false);
 
			this->SetDirty();
 
		}
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_GO_CURRENCY_DROPDOWN: // Currency
 
				if (index == CURRENCY_CUSTOM) ShowCustCurrency();
 
				this->opt->locale.currency = index;
 
				ReInitAllWindows(false);
 
@@ -2107,13 +2107,13 @@ struct GameSettingsWindow : Window {
 

	
 
	void OnInit() override
 
	{
 
		_circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED));
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_GS_OPTIONSPANEL:
 
				resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)}) + WidgetDimensions::scaled.vsep_normal;
 
				resize->width = 1;
 

	
 
@@ -2175,13 +2175,13 @@ struct GameSettingsWindow : Window {
 
		if (this->warn_missing != WHR_NONE) {
 
			SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]);
 
			DrawStringMultiLine(panel.WithHeight(this->warn_lines * GetCharacterHeight(FS_NORMAL)), warn_str, TC_FROMSTRING, SA_CENTER);
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_GS_RESTRICT_DROPDOWN:
 
				SetDParam(0, _game_settings_restrict_dropdown[this->filter.mode]);
 
				break;
 

	
 
@@ -2193,13 +2193,13 @@ struct GameSettingsWindow : Window {
 
					default:         SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL); break;
 
				}
 
				break;
 
		}
 
	}
 

	
 
	DropDownList BuildDropDownList(int widget) const
 
	DropDownList BuildDropDownList(WidgetID widget) const
 
	{
 
		DropDownList list;
 
		switch (widget) {
 
			case WID_GS_RESTRICT_DROPDOWN:
 
				for (int mode = 0; mode != RM_END; mode++) {
 
					/* If we are in adv. settings screen for the new game's settings,
 
@@ -2217,13 +2217,13 @@ struct GameSettingsWindow : Window {
 
				list.push_back(std::make_unique<DropDownListStringItem>(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false));
 
				break;
 
		}
 
		return list;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_GS_OPTIONSPANEL: {
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
 
				tr.top += this->warn_lines * SETTING_HEIGHT;
 
				uint last_row = this->vscroll->GetPosition() + this->vscroll->GetCapacity() - this->warn_lines;
 
@@ -2267,13 +2267,13 @@ struct GameSettingsWindow : Window {
 
	void SetDisplayedHelpText(SettingEntry *pe)
 
	{
 
		if (this->last_clicked != pe) this->SetDirty();
 
		this->last_clicked = pe;
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_GS_EXPAND_ALL:
 
				this->manually_changed_folding = true;
 
				GetSettingsTree().UnFoldAll();
 
				this->InvalidateData();
 
@@ -2485,13 +2485,13 @@ struct GameSettingsWindow : Window {
 
		}
 

	
 
		SetSettingValue(this->valuewindow_entry->setting, value);
 
		this->SetDirty();
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_GS_RESTRICT_DROPDOWN:
 
				this->filter.mode = (RestrictionMode)index;
 
				if (this->filter.mode == RM_CHANGED_AGAINST_DEFAULT ||
 
						this->filter.mode == RM_CHANGED_AGAINST_NEW) {
 
@@ -2522,13 +2522,13 @@ struct GameSettingsWindow : Window {
 
				SetSettingValue(sd, index);
 
				this->SetDirty();
 
				break;
 
		}
 
	}
 

	
 
	void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
 
	void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close) override
 
	{
 
		if (widget != WID_GS_SETTING_DROPDOWN) {
 
			/* Normally the default implementation of OnDropdownClose() takes care of
 
			 * a few things. We want that behaviour here too, but only for
 
			 * "normal" dropdown boxes. The special dropdown boxes added for every
 
			 * setting that needs one can't have this call. */
 
@@ -2571,13 +2571,13 @@ struct GameSettingsWindow : Window {
 
		bool all_unfolded = true;
 
		GetSettingsTree().GetFoldingState(all_folded, all_unfolded);
 
		this->SetWidgetDisabledState(WID_GS_EXPAND_ALL, all_unfolded);
 
		this->SetWidgetDisabledState(WID_GS_COLLAPSE_ALL, all_folded);
 
	}
 

	
 
	void OnEditboxChanged(int wid) override
 
	void OnEditboxChanged(WidgetID wid) override
 
	{
 
		if (wid == WID_GS_FILTER) {
 
			this->filter.string.SetFilterTerm(this->filter_editbox.text.buf);
 
			if (!this->filter.string.IsEmpty() && !this->manually_changed_folding) {
 
				/* User never expanded/collapsed single pages and entered a filter term.
 
				 * Expand everything, to save weird expand clicks, */
 
@@ -2734,13 +2734,13 @@ struct CustomCurrencyWindow : Window {
 
		this->SetWidgetDisabledState(WID_CC_RATE_DOWN, _custom_currency.rate == 1);
 
		this->SetWidgetDisabledState(WID_CC_RATE_UP, _custom_currency.rate == UINT16_MAX);
 
		this->SetWidgetDisabledState(WID_CC_YEAR_DOWN, _custom_currency.to_euro == CF_NOEURO);
 
		this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == CalendarTime::MAX_YEAR);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_CC_RATE:      SetDParam(0, 1); SetDParam(1, 1);            break;
 
			case WID_CC_SEPARATOR: SetDParamStr(0, _custom_currency.separator); break;
 
			case WID_CC_PREFIX:    SetDParamStr(0, _custom_currency.prefix);    break;
 
			case WID_CC_SUFFIX:    SetDParamStr(0, _custom_currency.suffix);    break;
 
@@ -2752,13 +2752,13 @@ struct CustomCurrencyWindow : Window {
 
			case WID_CC_PREVIEW:
 
				SetDParam(0, 10000);
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			/* Set the appropriate width for the up/down buttons. */
 
			case WID_CC_RATE_DOWN:
 
			case WID_CC_RATE_UP:
 
			case WID_CC_YEAR_DOWN:
 
@@ -2779,13 +2779,13 @@ struct CustomCurrencyWindow : Window {
 
				SetDParam(1, INT32_MAX);
 
				*size = GetStringBoundingBox(STR_CURRENCY_EXCHANGE_RATE);
 
				break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		int line = 0;
 
		int len = 0;
 
		StringID str = 0;
 
		CharSetFilter afilter = CS_ALPHANUMERAL;
 

	
src/signs_gui.cpp
Show inline comments
 
@@ -189,13 +189,13 @@ struct SignListWindow : Window, SignList
 
	void OnPaint() override
 
	{
 
		if (!this->IsShaded() && this->signs.NeedRebuild()) this->BuildSortSignList();
 
		this->DrawWidgets();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SIL_LIST: {
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
 
				uint text_offset_y = (this->resize.step_height - GetCharacterHeight(FS_NORMAL) + 1) / 2;
 
				/* No signs? */
 
@@ -223,18 +223,18 @@ struct SignListWindow : Window, SignList
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_SIL_CAPTION) SetDParam(0, this->vscroll->GetCount());
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_SIL_LIST: {
 
				auto it = this->vscroll->GetScrolledItemFromWidget(this->signs, pt.y, this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.top);
 
				if (it == this->signs.end()) return;
 

	
 
@@ -260,13 +260,13 @@ struct SignListWindow : Window, SignList
 

	
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.Vertical());
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_SIL_LIST: {
 
				Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
 
				this->text_offset = WidgetDimensions::scaled.frametext.left + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
 
				resize->height = std::max<uint>(GetCharacterHeight(FS_NORMAL), spr_dim.height + 2);
 
@@ -296,13 +296,13 @@ struct SignListWindow : Window, SignList
 
				return ES_NOT_HANDLED;
 
		}
 

	
 
		return ES_HANDLED;
 
	}
 

	
 
	void OnEditboxChanged(int widget) override
 
	void OnEditboxChanged(WidgetID widget) override
 
	{
 
		if (widget == WID_SIL_FILTER_TEXT) this->SetFilterString(this->filter_editbox.text.buf);
 
	}
 

	
 
	void BuildSortSignList()
 
	{
 
@@ -471,22 +471,22 @@ struct SignWindow : Window, SignList {
 
			}
 
		}
 
		/* If we haven't found the current sign by now, return the last/first sign */
 
		return next ? this->signs.front() : this->signs.back();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_QES_CAPTION:
 
				SetDParam(0, this->name_editbox.caption);
 
				break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_QES_LOCATION: {
 
				const Sign *si = Sign::Get(this->cur_sign);
 
				TileIndex tile = TileVirtXY(si->x, si->y);
 
				if (_ctrl_pressed) {
src/smallmap_gui.cpp
Show inline comments
 
@@ -1456,13 +1456,13 @@ public:
 
	void Close([[maybe_unused]] int data) override
 
	{
 
		this->BreakIndustryChainLink();
 
		this->Window::Close();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SM_CAPTION:
 
				SetDParam(0, STR_SMALLMAP_TYPE_CONTOURS + this->map_type);
 
				break;
 
		}
 
@@ -1534,13 +1534,13 @@ public:
 
			}
 
		}
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SM_MAP: {
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
				DrawPixelInfo new_dpi;
 
				if (!FillDrawPixelInfo(&new_dpi, ir)) return;
 
@@ -1631,13 +1631,13 @@ public:
 
					icon = icon.Translate(0, row_height);
 
				}
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_SM_MAP: { // Map window
 
				if (click_count > 0) this->mouse_capture_widget = widget;
 

	
 
				const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP);
 
@@ -1776,13 +1776,13 @@ public:
 

	
 
			default: NOT_REACHED();
 
		}
 
		this->SetDirty();
 
	}
 

	
 
	bool OnRightClick(Point, int widget) override
 
	bool OnRightClick(Point, WidgetID widget) override
 
	{
 
		if (widget != WID_SM_MAP || _scrolling_viewport) return false;
 

	
 
		_scrolling_viewport = true;
 
		return true;
 
	}
 
@@ -1809,13 +1809,13 @@ public:
 
		Point pt = this->PixelToTile(delta.x, delta.y, &sub);
 
		this->SetNewScroll(this->scroll_x + pt.x * TILE_SIZE, this->scroll_y + pt.y * TILE_SIZE, sub);
 

	
 
		this->SetDirty();
 
	}
 

	
 
	void OnMouseOver([[maybe_unused]] Point pt, int widget) override
 
	void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override
 
	{
 
		IndustryType new_highlight = INVALID_INDUSTRYTYPE;
 
		if (widget == WID_SM_LEGEND && this->map_type == SMT_INDUSTRY) {
 
			int industry_pos = GetPositionOnLegend(pt);
 
			if (industry_pos >= 0 && industry_pos < _smallmap_industry_count) {
 
				new_highlight = _legend_from_industries[industry_pos].type;
src/station_gui.cpp
Show inline comments
 
@@ -396,13 +396,13 @@ public:
 
	{
 
		/* Save filter state. */
 
		this->filter.last_sorting = this->stations.GetListing();
 
		CompanyStationsWindow::initial_state = this->filter;
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_STL_SORTBY: {
 
				Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
 
				d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
 
				d.height += padding.height;
 
@@ -450,13 +450,13 @@ public:
 
		this->BuildStationsList((Owner)this->window_number);
 
		this->SortStationsList();
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_STL_SORTBY:
 
				/* draw arrow pointing up/down for ascending/descending sorting */
 
				this->DrawSortButtonState(WID_STL_SORTBY, this->stations.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
 
				break;
 
@@ -522,21 +522,21 @@ public:
 
					DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_SMALL)), cs->abbrev, tc, SA_HOR_CENTER, false, FS_SMALL);
 
				}
 
				break;
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_STL_CAPTION) {
 
			SetDParam(0, this->window_number);
 
			SetDParam(1, this->vscroll->GetCount());
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_STL_LIST: {
 
				auto it = this->vscroll->GetScrolledItemFromWidget(this->stations, pt.y, this, WID_STL_LIST);
 
				if (it == this->stations.end()) return; // click out of list bound
 

	
 
@@ -569,13 +569,13 @@ public:
 
				}
 
				this->stations.ForceRebuild();
 
				this->SetDirty();
 
				break;
 

	
 
			case WID_STL_FACILALL:
 
				for (uint i = WID_STL_TRAIN; i <= WID_STL_SHIP; i++) {
 
				for (WidgetID i = WID_STL_TRAIN; i <= WID_STL_SHIP; i++) {
 
					this->LowerWidget(i);
 
				}
 

	
 
				this->filter.facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
 
				this->stations.ForceRebuild();
 
				this->SetDirty();
 
@@ -645,13 +645,13 @@ public:
 
					this->SetDirty();
 
				}
 
				break;
 
		}
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		if (widget == WID_STL_SORTDROPBTN) {
 
			if (this->stations.SortType() != index) {
 
				this->stations.SetSortType(index);
 

	
 
				/* Display the current sort variant */
 
@@ -1383,13 +1383,13 @@ struct StationViewWindow : public Window
 
					break;
 
			}
 
		}
 
		data->Update(count);
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		switch (widget) {
 
			case WID_SV_WAITING:
 
				resize->height = GetCharacterHeight(FS_NORMAL);
 
				size->height = 4 * resize->height + padding.height;
 
				this->expand_shrink_width = std::max(GetStringBoundingBox("-").width, GetStringBoundingBox("+").width);
 
@@ -1467,13 +1467,13 @@ struct StationViewWindow : public Window
 
			Rect waiting_rect = nwi->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
 
			this->DrawEntries(&cargo, waiting_rect, pos, maxrows, 0);
 
			scroll_to_row = INT_MAX;
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		if (widget == WID_SV_CAPTION) {
 
			const Station *st = Station::Get(this->window_number);
 
			SetDParam(0, st->index);
 
			SetDParam(1, st->facilities);
 
		}
 
@@ -1911,13 +1911,13 @@ struct StationViewWindow : public Window
 
				this->HandleCargoWaitingClick<StationID>(display.filter, display.next_station);
 
			}
 
		}
 
		this->SetWidgetDirty(WID_SV_WAITING);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_SV_WAITING:
 
				this->HandleCargoWaitingClick(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SV_WAITING, WidgetDimensions::scaled.framerect.top) - this->vscroll->GetPosition());
 
				break;
 

	
 
@@ -2076,13 +2076,13 @@ struct StationViewWindow : public Window
 
				this->groupings[3] = GR_SOURCE;
 
				break;
 
		}
 
		this->SetDirty();
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		if (widget == WID_SV_SORT_BY) {
 
			this->SelectSortBy(index);
 
		} else {
 
			this->SelectGroupBy(index);
 
		}
 
@@ -2296,13 +2296,13 @@ struct SelectStationWindow : Window {
 
		SetViewportCatchmentSpecializedStation<T>(nullptr, true);
 

	
 
		_thd.freeze = false;
 
		this->Window::Close();
 
	}
 

	
 
	void UpdateWidgetSize(int 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_JS_PANEL) return;
 

	
 
		/* Determine the widest string */
 
		Dimension d = GetStringBoundingBox(T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
 
		for (const auto &station : _stations_nearby_list) {
 
@@ -2317,13 +2317,13 @@ struct SelectStationWindow : Window {
 
		d.height *= 5;
 
		d.width += padding.width;
 
		d.height += padding.height;
 
		*size = d;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_JS_PANEL) return;
 

	
 
		Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
 
		for (uint i = this->vscroll->GetPosition(); i < _stations_nearby_list.size(); ++i, tr.top += this->resize.step_height) {
 
			if (_stations_nearby_list[i] == NEW_STATION) {
 
@@ -2335,13 +2335,13 @@ struct SelectStationWindow : Window {
 
				DrawString(tr, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION);
 
			}
 
		}
 

	
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget != WID_JS_PANEL) return;
 

	
 
		auto it = this->vscroll->GetScrolledItemFromWidget(_stations_nearby_list, pt.y, this, WID_JS_PANEL, WidgetDimensions::scaled.framerect.top);
 
		if (it == _stations_nearby_list.end()) return;
 

	
 
@@ -2375,13 +2375,13 @@ struct SelectStationWindow : Window {
 
		if (!gui_scope) return;
 
		FindStationsNearby<T>(this->area, true);
 
		this->vscroll->SetCount(_stations_nearby_list.size());
 
		this->SetDirty();
 
	}
 

	
 
	void OnMouseOver([[maybe_unused]] Point pt, int widget) override
 
	void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override
 
	{
 
		if (widget != WID_JS_PANEL) {
 
			SetViewportCatchmentSpecializedStation<T>(nullptr, true);
 
			return;
 
		}
 

	
src/statusbar_gui.cpp
Show inline comments
 
@@ -80,13 +80,13 @@ struct StatusBarWindow : Window {
 

	
 
	void FindWindowPlacementAndResize([[maybe_unused]] int def_width, [[maybe_unused]] int def_height) override
 
	{
 
		Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
 
	}
 

	
 
	void UpdateWidgetSize(int 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
 
	{
 
		Dimension d;
 
		switch (widget) {
 
			case WID_S_LEFT:
 
				SetDParamMaxValue(0, TimerGameCalendar::DateAtStartOfYear(CalendarTime::MAX_YEAR));
 
				d = GetStringBoundingBox(STR_JUST_DATE_LONG);
 
@@ -106,13 +106,13 @@ struct StatusBarWindow : Window {
 

	
 
		d.width += padding.width;
 
		d.height += padding.height;
 
		*size = maxdim(d, *size);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		Rect tr = r.Shrink(WidgetDimensions::scaled.framerect, RectPadding::zero);
 
		tr.top = CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL));
 
		switch (widget) {
 
			case WID_S_LEFT:
 
				/* Draw the date */
 
@@ -187,13 +187,13 @@ struct StatusBarWindow : Window {
 
				this->ticker_scroll    =   TICKER_STOP; // reset ticker ...
 
				this->reminder_timeout.Abort(); // ... and reminder
 
				break;
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_S_MIDDLE: ShowLastNewsMessage(); break;
 
			case WID_S_RIGHT:  if (_local_company != COMPANY_SPECTATOR) ShowCompanyFinances(_local_company); break;
 
			default: ResetObjectToPlace();
 
		}
src/story_gui.cpp
Show inline comments
 
@@ -640,13 +640,13 @@ public:
 
			this->selected_page_id = page_index;
 
			this->RefreshSelectedPage();
 
			this->UpdatePrevNextDisabledState();
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_SB_SEL_PAGE: {
 
				StoryPage *page = this->GetSelPage();
 
				SetDParamStr(0, page != nullptr && !page->title.empty() ? page->title : this->selected_generic_title);
 
				break;
 
@@ -674,13 +674,13 @@ public:
 
			this->SetWidgetDirty(WID_SB_PAGE_PANEL);
 
		}
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_SB_PAGE_PANEL) return;
 

	
 
		StoryPage *page = this->GetSelPage();
 
		if (page == nullptr) return;
 

	
 
@@ -748,13 +748,13 @@ public:
 

	
 
				default: NOT_REACHED();
 
			}
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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_SB_SEL_PAGE && widget != WID_SB_PAGE_PANEL) return;
 

	
 
		Dimension d;
 
		d.height = GetCharacterHeight(FS_NORMAL);
 
		d.width = 0;
 
@@ -798,13 +798,13 @@ public:
 
	{
 
		this->InvalidateStoryPageElementLayout();
 
		this->vscroll->SetCapacityFromWidget(this, WID_SB_PAGE_PANEL, WidgetDimensions::scaled.frametext.Vertical());
 
		this->vscroll->SetCount(this->GetContentHeight());
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_SB_SEL_PAGE: {
 
				DropDownList list = this->BuildDropDownList();
 
				if (!list.empty()) {
 
					/* Get the index of selected page. */
 
@@ -839,13 +839,13 @@ public:
 
					}
 
				}
 
			}
 
		}
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	void OnDropdownSelect(WidgetID widget, int index) override
 
	{
 
		if (widget != WID_SB_SEL_PAGE) return;
 

	
 
		/* index (which is set in BuildDropDownList) is the page id. */
 
		this->SetSelectedPage(index);
 
	}
src/subsidy_gui.cpp
Show inline comments
 
@@ -33,13 +33,13 @@ struct SubsidyListWindow : Window {
 
		this->CreateNestedTree();
 
		this->vscroll = this->GetScrollbar(WID_SUL_SCROLLBAR);
 
		this->FinishInitNested(window_number);
 
		this->OnInvalidateData(0);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget != WID_SUL_PANEL) return;
 

	
 
		int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SUL_PANEL, WidgetDimensions::scaled.framerect.top);
 
		int num = 0;
 
		for (const Subsidy *s : Subsidy::Iterate()) {
 
@@ -122,26 +122,26 @@ struct SubsidyListWindow : Window {
 
		if (num_not_awarded == 0) num_not_awarded = 1;
 

	
 
		/* Offered, accepted and an empty line before the accepted ones. */
 
		return 3 + num_awarded + num_not_awarded;
 
	}
 

	
 
	void UpdateWidgetSize(int 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_SUL_PANEL) return;
 
		Dimension d = maxdim(GetStringBoundingBox(STR_SUBSIDIES_OFFERED_TITLE), GetStringBoundingBox(STR_SUBSIDIES_SUBSIDISED_TITLE));
 

	
 
		resize->height = GetCharacterHeight(FS_NORMAL);
 

	
 
		d.height *= 5;
 
		d.width += WidgetDimensions::scaled.framerect.Horizontal();
 
		d.height += WidgetDimensions::scaled.framerect.Vertical();
 
		*size = maxdim(*size, d);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_SUL_PANEL) return;
 

	
 
		TimerGameCalendar::YearMonthDay ymd = TimerGameCalendar::ConvertDateToYMD(TimerGameCalendar::date);
 

	
 
		Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
src/terraform_gui.cpp
Show inline comments
 
@@ -172,13 +172,13 @@ struct TerraformToolbarWindow : Window {
 
	{
 
		/* Don't show the place object button when there are no objects to place. */
 
		NWidgetStacked *show_object = this->GetWidget<NWidgetStacked>(WID_TT_SHOW_PLACE_OBJECT);
 
		show_object->SetDisplayedPlane(ObjectClass::GetUIClassCount() != 0 ? 0 : SZSP_NONE);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget < WID_TT_BUTTONS_START) return;
 

	
 
		switch (widget) {
 
			case WID_TT_LOWER_LAND: // Lower land button
 
				HandlePlacePushButton(this, WID_TT_LOWER_LAND, ANIMCURSOR_LOWERLAND, HT_POINT | HT_DIAGONAL);
 
@@ -550,21 +550,21 @@ struct ScenarioEditorLandscapeGeneration
 

	
 
		if (this->IsWidgetLowered(WID_ETT_LOWER_LAND) || this->IsWidgetLowered(WID_ETT_RAISE_LAND)) { // change area-size if raise/lower corner is selected
 
			SetTileSelectSize(_terraform_size, _terraform_size);
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int 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_ETT_DOTS) return;
 

	
 
		size->width  = std::max<uint>(size->width,  ScaleGUITrad(59));
 
		size->height = std::max<uint>(size->height, ScaleGUITrad(31));
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	void DrawWidget(const Rect &r, WidgetID widget) const override
 
	{
 
		if (widget != WID_ETT_DOTS) return;
 

	
 
		int center_x = RoundDivSU(r.left + r.right, 2);
 
		int center_y = RoundDivSU(r.top + r.bottom, 2);
 

	
 
@@ -575,13 +575,13 @@ struct ScenarioEditorLandscapeGeneration
 
		do {
 
			DrawSprite(SPR_WHITE_POINT, PAL_NONE, center_x + ScaleGUITrad(coords[0]), center_y + ScaleGUITrad(coords[1]));
 
			coords += 2;
 
		} while (--n);
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (widget < WID_ETT_BUTTONS_START) return;
 

	
 
		switch (widget) {
 
			case WID_ETT_DEMOLISH: // Demolish aka dynamite button
 
				HandlePlacePushButton(this, WID_ETT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
src/textfile_gui.cpp
Show inline comments
 
@@ -123,13 +123,13 @@ uint TextfileWindow::ReflowContent()
 
uint TextfileWindow::GetContentHeight()
 
{
 
	if (this->lines.empty()) return 0;
 
	return this->lines.back().bottom;
 
}
 

	
 
/* virtual */ void TextfileWindow::UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize)
 
/* virtual */ void TextfileWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize)
 
{
 
	switch (widget) {
 
		case WID_TF_BACKGROUND:
 
			resize->height = GetCharacterHeight(FS_MONO);
 

	
 
			size->height = 4 * resize->height + WidgetDimensions::scaled.frametext.Vertical(); // At least 4 lines are visible.
 
@@ -513,13 +513,13 @@ void TextfileWindow::AfterLoadMarkdown()
 
			this->lines[line_index].colour = TC_GOLD;
 
			this->link_anchors.emplace_back(Hyperlink{ line_index, 0, 0, MakeAnchorSlug(line.text) });
 
		}
 
	}
 
}
 

	
 
/* virtual */ void TextfileWindow::OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count)
 
/* virtual */ void TextfileWindow::OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count)
 
{
 
	switch (widget) {
 
		case WID_TF_WRAPTEXT:
 
			this->ToggleWidgetLoweredState(WID_TF_WRAPTEXT);
 
			this->InvalidateData();
 
			break;
 
@@ -545,13 +545,13 @@ void TextfileWindow::AfterLoadMarkdown()
 
		case WID_TF_BACKGROUND:
 
			this->CheckHyperlinkClick(pt);
 
			break;
 
	}
 
}
 

	
 
/* virtual */ void TextfileWindow::DrawWidget(const Rect &r, int widget) const
 
/* virtual */ void TextfileWindow::DrawWidget(const Rect &r, WidgetID widget) const
 
{
 
	if (widget != WID_TF_BACKGROUND) return;
 

	
 
	Rect fr = r.Shrink(WidgetDimensions::scaled.frametext);
 

	
 
	DrawPixelInfo new_dpi;
 
@@ -589,13 +589,13 @@ void TextfileWindow::AfterLoadMarkdown()
 
{
 
	if (!gui_scope) return;
 

	
 
	this->SetupScrollbars(true);
 
}
 

	
 
void TextfileWindow::OnDropdownSelect(int widget, int index)
 
void TextfileWindow::OnDropdownSelect(WidgetID widget, int index)
 
{
 
	if (widget != WID_TF_JUMPLIST) return;
 

	
 
	this->ScrollToLine(index);
 
}
 

	

Changeset was too big and was cut off... Show full diff anyway

0 comments (0 inline, 0 general)