Changeset - r28488:814e7fc9b052
[Not reviewed]
master
0 21 0
Rubidium - 11 months ago 2024-01-16 21:01:28
rubidium@openttd.org
Codechange: allow certain enumeration to be added

Otherwise C++20 doesn't like it.
21 files changed with 83 insertions and 63 deletions:
0 comments (0 inline, 0 general)
src/company_gui.cpp
Show inline comments
 
@@ -744,23 +744,23 @@ public:
 
		this->owner = company;
 
		this->InvalidateData(1);
 
	}
 

	
 
	void SetSelectedGroup(CompanyID company, GroupID group)
 
	{
 
		this->RaiseWidget(this->livery_class + WID_SCL_CLASS_GENERAL);
 
		this->RaiseWidget(WID_SCL_CLASS_GENERAL + this->livery_class);
 
		const Group *g = Group::Get(group);
 
		switch (g->vehicle_type) {
 
			case VEH_TRAIN: this->livery_class = LC_GROUP_RAIL; break;
 
			case VEH_ROAD: this->livery_class = LC_GROUP_ROAD; break;
 
			case VEH_SHIP: this->livery_class = LC_GROUP_SHIP; break;
 
			case VEH_AIRCRAFT: this->livery_class = LC_GROUP_AIRCRAFT; break;
 
			default: NOT_REACHED();
 
		}
 
		this->sel = group;
 
		this->LowerWidget(this->livery_class + WID_SCL_CLASS_GENERAL);
 
		this->LowerWidget(WID_SCL_CLASS_GENERAL + this->livery_class);
 

	
 
		this->groups.ForceRebuild();
 
		this->BuildGroupList(company);
 
		this->SetRows();
 

	
 
		/* Position scrollbar to selected group */
 
@@ -960,15 +960,15 @@ public:
 
			case WID_SCL_CLASS_SHIP:
 
			case WID_SCL_CLASS_AIRCRAFT:
 
			case WID_SCL_GROUPS_RAIL:
 
			case WID_SCL_GROUPS_ROAD:
 
			case WID_SCL_GROUPS_SHIP:
 
			case WID_SCL_GROUPS_AIRCRAFT:
 
				this->RaiseWidget(this->livery_class + WID_SCL_CLASS_GENERAL);
 
				this->RaiseWidget(WID_SCL_CLASS_GENERAL + this->livery_class);
 
				this->livery_class = (LiveryClass)(widget - WID_SCL_CLASS_GENERAL);
 
				this->LowerWidget(this->livery_class + WID_SCL_CLASS_GENERAL);
 
				this->LowerWidget(WID_SCL_CLASS_GENERAL + this->livery_class);
 

	
 
				/* Select the first item in the list */
 
				if (this->livery_class < LC_GROUP_RAIL) {
 
					this->sel = 0;
 
					for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
 
						if (_livery_class[scheme] == this->livery_class && HasBit(_loaded_newgrf_features.used_liveries, scheme)) {
src/company_type.h
Show inline comments
 
@@ -32,12 +32,13 @@ enum Owner : byte {
 
	/* 'Fake' companies used for networks */
 
	COMPANY_INACTIVE_CLIENT = 253, ///< The client is joining
 
	COMPANY_NEW_COMPANY     = 254, ///< The client wants a new company
 
	COMPANY_SPECTATOR       = 255, ///< The client is spectating
 
};
 
DECLARE_POSTFIX_INCREMENT(Owner)
 
DECLARE_ENUM_AS_ADDABLE(Owner)
 

	
 
static const uint MAX_LENGTH_PRESIDENT_NAME_CHARS = 32; ///< The maximum length of a president name in characters including '\0'
 
static const uint MAX_LENGTH_COMPANY_NAME_CHARS   = 32; ///< The maximum length of a company name in characters including '\0'
 

	
 
static const uint MAX_HISTORY_QUARTERS            = 24; ///< The maximum number of quarters kept as performance's history
 

	
src/core/enum_type.hpp
Show inline comments
 
@@ -34,8 +34,14 @@
 
	inline constexpr enum_type operator ^ (enum_type m1, enum_type m2) {return (enum_type)((std::underlying_type<enum_type>::type)m1 ^ (std::underlying_type<enum_type>::type)m2);} \
 
	inline constexpr enum_type& operator |= (enum_type& m1, enum_type m2) {m1 = m1 | m2; return m1;} \
 
	inline constexpr enum_type& operator &= (enum_type& m1, enum_type m2) {m1 = m1 & m2; return m1;} \
 
	inline constexpr enum_type& operator ^= (enum_type& m1, enum_type m2) {m1 = m1 ^ m2; return m1;} \
 
	inline constexpr enum_type operator ~(enum_type m) {return (enum_type)(~(std::underlying_type<enum_type>::type)m);}
 

	
 
/** Operator that allows this enumeration to be added to any other enumeration. */
 
#define DECLARE_ENUM_AS_ADDABLE(EnumType) \
 
	template <typename OtherEnumType, typename = typename std::enable_if<std::is_enum_v<OtherEnumType>, OtherEnumType>::type> \
 
	constexpr OtherEnumType operator + (OtherEnumType m1, EnumType m2) { \
 
		return static_cast<OtherEnumType>(static_cast<typename std::underlying_type<OtherEnumType>::type>(m1) + static_cast<typename std::underlying_type<EnumType>::type>(m2)); \
 
	}
 

	
 
#endif /* ENUM_TYPE_HPP */
src/direction_type.h
Show inline comments
 
@@ -76,15 +76,14 @@ enum DiagDirection : byte {
 
	DIAGDIR_SE  = 1,        ///< Southeast
 
	DIAGDIR_SW  = 2,        ///< Southwest
 
	DIAGDIR_NW  = 3,        ///< Northwest
 
	DIAGDIR_END,            ///< Used for iterations
 
	INVALID_DIAGDIR = 0xFF, ///< Flag for an invalid DiagDirection
 
};
 

	
 
/** Allow incrementing of DiagDirection variables */
 
DECLARE_POSTFIX_INCREMENT(DiagDirection)
 
DECLARE_ENUM_AS_ADDABLE(DiagDirection)
 

	
 
/**
 
 * Enumeration for the difference between to DiagDirection.
 
 *
 
 * As the DiagDirection only contains 4 possible directions the
 
 * difference between two of these directions can only be in 4 ways.
 
@@ -117,8 +116,9 @@ DECLARE_POSTFIX_INCREMENT(DiagDirDiff)
 
enum Axis : byte {
 
	AXIS_X = 0,          ///< The X axis
 
	AXIS_Y = 1,          ///< The y axis
 
	AXIS_END,            ///< Used for iterations
 
	INVALID_AXIS = 0xFF, ///< Flag for an invalid Axis
 
};
 
DECLARE_ENUM_AS_ADDABLE(Axis)
 

	
 
#endif /* DIRECTION_TYPE_H */
src/dock_gui.cpp
Show inline comments
 
@@ -522,13 +522,13 @@ private:
 
	}
 

	
 
public:
 
	BuildDocksDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
 
	{
 
		this->InitNested(TRANSPORT_WATER);
 
		this->LowerWidget(_ship_depot_direction + WID_BDD_X);
 
		this->LowerWidget(WID_BDD_X + _ship_depot_direction);
 
		UpdateDocksDirection();
 
	}
 

	
 
	void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
 
	{
 
		switch (widget) {
 
@@ -566,15 +566,15 @@ public:
 

	
 
	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);
 
				this->RaiseWidget(WID_BDD_X + _ship_depot_direction);
 
				_ship_depot_direction = (widget == WID_BDD_X ? AXIS_X : AXIS_Y);
 
				this->LowerWidget(_ship_depot_direction + WID_BDD_X);
 
				this->LowerWidget(WID_BDD_X + _ship_depot_direction);
 
				if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
 
				UpdateDocksDirection();
 
				this->SetDirty();
 
				break;
 
		}
 
	}
src/gfx_type.h
Show inline comments
 
@@ -244,12 +244,13 @@ enum Colours : byte {
 
	COLOUR_BROWN,
 
	COLOUR_GREY,
 
	COLOUR_WHITE,
 
	COLOUR_END,
 
	INVALID_COLOUR = 0xFF,
 
};
 
DECLARE_ENUM_AS_ADDABLE(Colours)
 

	
 
/** Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palette.png */
 
enum TextColour {
 
	TC_BEGIN       = 0x00,
 
	TC_FROMSTRING  = 0x00,
 
	TC_BLUE        = 0x00,
src/graph_gui.cpp
Show inline comments
 
@@ -47,21 +47,21 @@ static const uint INVALID_DATAPOINT_POS 
 
struct GraphLegendWindow : Window {
 
	GraphLegendWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
 
	{
 
		this->InitNested(window_number);
 

	
 
		for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
 
			if (!HasBit(_legend_excluded_companies, c)) this->LowerWidget(c + WID_GL_FIRST_COMPANY);
 
			if (!HasBit(_legend_excluded_companies, c)) this->LowerWidget(WID_GL_FIRST_COMPANY + c);
 

	
 
			this->OnInvalidateData(c);
 
		}
 
	}
 

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

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

	
 
		if (!Company::IsValidID(cid)) return;
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 
@@ -75,13 +75,13 @@ struct GraphLegendWindow : Window {
 
		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, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, MAX_COMPANIES + WID_GL_FIRST_COMPANY)) return;
 
		if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, WID_GL_FIRST_COMPANY + MAX_COMPANIES)) return;
 

	
 
		ToggleBit(_legend_excluded_companies, widget - WID_GL_FIRST_COMPANY);
 
		this->ToggleWidgetLoweredState(widget);
 
		this->SetDirty();
 
		InvalidateWindowData(WC_INCOME_GRAPH, 0);
 
		InvalidateWindowData(WC_OPERATING_PROFIT, 0);
 
@@ -1279,15 +1279,15 @@ struct PerformanceRatingDetailWindow : W
 
	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);
 
				this->RaiseWidget(WID_PRD_COMPANY_FIRST + this->company);
 
				this->company = (CompanyID)(widget - WID_PRD_COMPANY_FIRST);
 
				this->LowerWidget(this->company + WID_PRD_COMPANY_FIRST);
 
				this->LowerWidget(WID_PRD_COMPANY_FIRST + this->company);
 
				this->SetDirty();
 
			}
 
		}
 
	}
 

	
 
	void OnGameTick() override
 
@@ -1306,31 +1306,31 @@ struct PerformanceRatingDetailWindow : W
 
	 */
 
	void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
 
	{
 
		if (!gui_scope) return;
 
		/* Disable the companies who are not active */
 
		for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
 
			this->SetWidgetDisabledState(i + WID_PRD_COMPANY_FIRST, !Company::IsValidID(i));
 
			this->SetWidgetDisabledState(WID_PRD_COMPANY_FIRST + i, !Company::IsValidID(i));
 
		}
 

	
 
		/* Check if the currently selected company is still active. */
 
		if (this->company != INVALID_COMPANY && !Company::IsValidID(this->company)) {
 
			/* Raise the widget for the previous selection. */
 
			this->RaiseWidget(this->company + WID_PRD_COMPANY_FIRST);
 
			this->RaiseWidget(WID_PRD_COMPANY_FIRST + this->company);
 
			this->company = INVALID_COMPANY;
 
		}
 

	
 
		if (this->company == INVALID_COMPANY) {
 
			for (const Company *c : Company::Iterate()) {
 
				this->company = c->index;
 
				break;
 
			}
 
		}
 

	
 
		/* Make sure the widget is lowered */
 
		this->LowerWidget(this->company + WID_PRD_COMPANY_FIRST);
 
		this->LowerWidget(WID_PRD_COMPANY_FIRST + this->company);
 
	}
 
};
 

	
 
CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY;
 

	
 
/**
src/linkgraph/linkgraph_gui.cpp
Show inline comments
 
@@ -663,28 +663,28 @@ bool LinkGraphLegendWindow::OnTooltip([[
 
/**
 
 * Update the overlay with the new company selection.
 
 */
 
void LinkGraphLegendWindow::UpdateOverlayCompanies()
 
{
 
	uint32_t mask = 0;
 
	for (uint c = 0; c < MAX_COMPANIES; c++) {
 
		if (this->IsWidgetDisabled(c + WID_LGL_COMPANY_FIRST)) continue;
 
		if (!this->IsWidgetLowered(c + WID_LGL_COMPANY_FIRST)) continue;
 
	for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
 
		if (this->IsWidgetDisabled(WID_LGL_COMPANY_FIRST + c)) continue;
 
		if (!this->IsWidgetLowered(WID_LGL_COMPANY_FIRST + c)) continue;
 
		SetBit(mask, c);
 
	}
 
	this->overlay->SetCompanyMask(mask);
 
}
 

	
 
/**
 
 * Update the overlay with the new cargo selection.
 
 */
 
void LinkGraphLegendWindow::UpdateOverlayCargoes()
 
{
 
	CargoTypes mask = 0;
 
	for (uint c = 0; c < num_cargo; c++) {
 
		if (!this->IsWidgetLowered(c + WID_LGL_CARGO_FIRST)) continue;
 
	for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
 
		if (!this->IsWidgetLowered(WID_LGL_CARGO_FIRST + c)) continue;
 
		SetBit(mask, _sorted_cargo_specs[c]->Index());
 
	}
 
	this->overlay->SetCargoMask(mask);
 
}
 

	
 
void LinkGraphLegendWindow::OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count)
 
@@ -693,14 +693,14 @@ void LinkGraphLegendWindow::OnClick([[ma
 
	if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) {
 
		if (!this->IsWidgetDisabled(widget)) {
 
			this->ToggleWidgetLoweredState(widget);
 
			this->UpdateOverlayCompanies();
 
		}
 
	} else if (widget == WID_LGL_COMPANIES_ALL || widget == WID_LGL_COMPANIES_NONE) {
 
		for (uint c = 0; c < MAX_COMPANIES; c++) {
 
			if (this->IsWidgetDisabled(c + WID_LGL_COMPANY_FIRST)) continue;
 
		for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
 
			if (this->IsWidgetDisabled(WID_LGL_COMPANY_FIRST + c)) continue;
 
			this->SetWidgetLoweredState(WID_LGL_COMPANY_FIRST + c, widget == WID_LGL_COMPANIES_ALL);
 
		}
 
		this->UpdateOverlayCompanies();
 
		this->SetDirty();
 
	} else if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) {
 
		this->ToggleWidgetLoweredState(widget);
 
@@ -725,9 +725,9 @@ void LinkGraphLegendWindow::OnInvalidate
 
		this->Close();
 
		return;
 
	}
 

	
 
	/* Disable the companies who are not active */
 
	for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
 
		this->SetWidgetDisabledState(i + WID_LGL_COMPANY_FIRST, !Company::IsValidID(i));
 
		this->SetWidgetDisabledState(WID_LGL_COMPANY_FIRST + i, !Company::IsValidID(i));
 
	}
 
}
src/livery.h
Show inline comments
 
@@ -56,24 +56,25 @@ enum LiveryScheme : byte {
 
	LS_END
 
};
 

	
 
DECLARE_POSTFIX_INCREMENT(LiveryScheme)
 

	
 
/** List of different livery classes, used only by the livery GUI. */
 
enum LiveryClass {
 
enum LiveryClass : byte {
 
	LC_OTHER,
 
	LC_RAIL,
 
	LC_ROAD,
 
	LC_SHIP,
 
	LC_AIRCRAFT,
 
	LC_GROUP_RAIL,
 
	LC_GROUP_ROAD,
 
	LC_GROUP_SHIP,
 
	LC_GROUP_AIRCRAFT,
 
	LC_END
 
};
 
DECLARE_ENUM_AS_ADDABLE(LiveryClass)
 

	
 
/** Information about a particular livery. */
 
struct Livery {
 
	byte in_use;  ///< Bit 0 set if this livery should override the default livery first colour, Bit 1 for the second colour.
 
	byte colour1; ///< First colour, for all vehicles.
 
	byte colour2; ///< Second colour, for vehicles with 2CC support.
src/network/network_type.h
Show inline comments
 
@@ -7,12 +7,14 @@
 

	
 
/** @file network_type.h Types used for networking. */
 

	
 
#ifndef NETWORK_TYPE_H
 
#define NETWORK_TYPE_H
 

	
 
#include "../core/enum_type.hpp"
 

	
 
/** How many clients can we have */
 
static const uint MAX_CLIENTS = 255;
 

	
 
/**
 
 * The number of slots; must be at least 1 more than MAX_CLIENTS. It must
 
 * furthermore be less than or equal to 256 as client indices (sent over
 
@@ -83,17 +85,18 @@ enum NetworkPasswordType {
 
};
 

	
 
/**
 
 * Destination of our chat messages.
 
 * @warning The values of the enum items are part of the admin network API. Only append at the end.
 
 */
 
enum DestType {
 
enum DestType : byte {
 
	DESTTYPE_BROADCAST, ///< Send message/notice to all clients (All)
 
	DESTTYPE_TEAM,      ///< Send message/notice to everyone playing the same company (Team)
 
	DESTTYPE_CLIENT,    ///< Send message/notice to only a certain client (Private)
 
};
 
DECLARE_ENUM_AS_ADDABLE(DestType)
 

	
 
/**
 
 * Actions that can be used for NetworkTextMessage.
 
 * @warning The values of the enum items are part of the admin network API. Only append at the end.
 
 */
 
enum NetworkAction {
src/rail_gui.cpp
Show inline comments
 
@@ -995,18 +995,18 @@ public:
 

	
 
		BuildStationClassesAvailable();
 
		SelectClassAndStation();
 

	
 
		this->FinishInitNested(TRANSPORT_RAIL);
 

	
 
		this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
 
		this->LowerWidget(WID_BRAS_PLATFORM_DIR_X + _railstation.orientation);
 
		if (_settings_client.gui.station_dragdrop) {
 
			this->LowerWidget(WID_BRAS_PLATFORM_DRAG_N_DROP);
 
		} else {
 
			this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
 
			this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
 
			this->LowerWidget(WID_BRAS_PLATFORM_NUM_BEGIN + _settings_client.gui.station_numtracks);
 
			this->LowerWidget(WID_BRAS_PLATFORM_LEN_BEGIN + _settings_client.gui.station_platlength);
 
		}
 
		this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage);
 
		this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage);
 

	
 
		if (!newstation) {
 
			_railstation.station_class = StationClassID::STAT_CLASS_DFLT;
 
@@ -1325,28 +1325,28 @@ public:
 

	
 
	void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_BRAS_PLATFORM_DIR_X:
 
			case WID_BRAS_PLATFORM_DIR_Y:
 
				this->RaiseWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
 
				this->RaiseWidget(WID_BRAS_PLATFORM_DIR_X + _railstation.orientation);
 
				_railstation.orientation = (Axis)(widget - WID_BRAS_PLATFORM_DIR_X);
 
				this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
 
				this->LowerWidget(WID_BRAS_PLATFORM_DIR_X + _railstation.orientation);
 
				if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
 
				this->SetDirty();
 
				CloseWindowById(WC_SELECT_STATION, 0);
 
				break;
 

	
 
			case WID_BRAS_PLATFORM_NUM_1:
 
			case WID_BRAS_PLATFORM_NUM_2:
 
			case WID_BRAS_PLATFORM_NUM_3:
 
			case WID_BRAS_PLATFORM_NUM_4:
 
			case WID_BRAS_PLATFORM_NUM_5:
 
			case WID_BRAS_PLATFORM_NUM_6:
 
			case WID_BRAS_PLATFORM_NUM_7: {
 
				this->RaiseWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
 
				this->RaiseWidget(WID_BRAS_PLATFORM_NUM_BEGIN + _settings_client.gui.station_numtracks);
 
				this->RaiseWidget(WID_BRAS_PLATFORM_DRAG_N_DROP);
 

	
 
				_settings_client.gui.station_numtracks = widget - WID_BRAS_PLATFORM_NUM_BEGIN;
 
				_settings_client.gui.station_dragdrop = false;
 

	
 
				const StationSpec *statspec = _railstation.newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : nullptr;
 
@@ -1891,13 +1891,13 @@ static void ShowSignalBuilder(Window *pa
 
}
 

	
 
struct BuildRailDepotWindow : public PickerWindowBase {
 
	BuildRailDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
 
	{
 
		this->InitNested(TRANSPORT_RAIL);
 
		this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE);
 
		this->LowerWidget(WID_BRAD_DEPOT_NE + _build_depot_direction);
 
	}
 

	
 
	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;
 

	
 
@@ -1923,15 +1923,15 @@ struct BuildRailDepotWindow : public Pic
 
	{
 
		switch (widget) {
 
			case WID_BRAD_DEPOT_NE:
 
			case WID_BRAD_DEPOT_SE:
 
			case WID_BRAD_DEPOT_SW:
 
			case WID_BRAD_DEPOT_NW:
 
				this->RaiseWidget(_build_depot_direction + WID_BRAD_DEPOT_NE);
 
				this->RaiseWidget(WID_BRAD_DEPOT_NE + _build_depot_direction);
 
				_build_depot_direction = (DiagDirection)(widget - WID_BRAD_DEPOT_NE);
 
				this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE);
 
				this->LowerWidget(WID_BRAD_DEPOT_NE + _build_depot_direction);
 
				if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
 
				this->SetDirty();
 
				break;
 
		}
 
	}
 
};
src/road_gui.cpp
Show inline comments
 
@@ -1004,13 +1004,13 @@ Window *ShowBuildRoadScenToolbar(RoadTyp
 

	
 
struct BuildRoadDepotWindow : public PickerWindowBase {
 
	BuildRoadDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
 
	{
 
		this->CreateNestedTree();
 

	
 
		this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
 
		this->LowerWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
 
		if (RoadTypeIsTram(_cur_roadtype)) {
 
			this->GetWidget<NWidgetCore>(WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION;
 
			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;
 
			}
 
		}
 
@@ -1044,15 +1044,15 @@ struct BuildRoadDepotWindow : public Pic
 
	{
 
		switch (widget) {
 
			case WID_BROD_DEPOT_NW:
 
			case WID_BROD_DEPOT_NE:
 
			case WID_BROD_DEPOT_SW:
 
			case WID_BROD_DEPOT_SE:
 
				this->RaiseWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
 
				this->RaiseWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
 
				_road_depot_orientation = (DiagDirection)(widget - WID_BROD_DEPOT_NE);
 
				this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
 
				this->LowerWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
 
				if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
 
				this->SetDirty();
 
				break;
 

	
 
			default:
 
				break;
 
@@ -1129,15 +1129,15 @@ private:
 

	
 
	void CheckOrientationValid()
 
	{
 
		if (_roadstop_gui_settings.orientation >= DIAGDIR_END) return;
 
		const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
 
		if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) {
 
			this->RaiseWidget(_roadstop_gui_settings.orientation + WID_BROS_STATION_NE);
 
			this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
 
			_roadstop_gui_settings.orientation = DIAGDIR_END;
 
			this->LowerWidget(_roadstop_gui_settings.orientation + WID_BROS_STATION_NE);
 
			this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
 
			this->SetDirty();
 
			CloseWindowById(WC_SELECT_STATION, 0);
 
		}
 
	}
 

	
 
public:
 
@@ -1181,14 +1181,14 @@ public:
 
		this->GetWidget<NWidgetCore>(WID_BROS_CAPTION)->widget_data = rti->strings.picker_title[rs];
 

	
 
		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);
 
		this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
 
		this->LowerWidget(WID_BROS_LT_OFF + _settings_client.gui.station_show_coverage);
 

	
 
		this->FinishInitNested(TRANSPORT_ROAD);
 

	
 
		this->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
 
		if (!newstops || _roadstop_gui_settings.roadstop_class >= (int)RoadStopClass::GetClassCount()) {
 
			/* There's no new stops available or the list has reduced in size.
 
@@ -1505,15 +1505,15 @@ public:
 
			case WID_BROS_STATION_X:
 
			case WID_BROS_STATION_Y:
 
				if (widget < WID_BROS_STATION_X) {
 
					const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
 
					if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) return;
 
				}
 
				this->RaiseWidget(_roadstop_gui_settings.orientation + WID_BROS_STATION_NE);
 
				this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
 
				_roadstop_gui_settings.orientation = (DiagDirection)(widget - WID_BROS_STATION_NE);
 
				this->LowerWidget(_roadstop_gui_settings.orientation + WID_BROS_STATION_NE);
 
				this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
 
				if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
 
				this->SetDirty();
 
				CloseWindowById(WC_SELECT_STATION, 0);
 
				break;
 

	
 
			case WID_BROS_LT_OFF:
src/script/script_gui.cpp
Show inline comments
 
@@ -980,13 +980,13 @@ struct ScriptDebugWindow : public Window
 
		for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
 
			/* Mark dead/paused AIs by setting the background colour. */
 
			bool valid = Company::IsValidAiID(i);
 
			bool dead = valid && Company::Get(i)->ai_instance->IsDead();
 
			bool paused = valid && Company::Get(i)->ai_instance->IsPaused();
 

	
 
			NWidgetCore *button = this->GetWidget<NWidgetCore>(i + WID_SCRD_COMPANY_BUTTON_START);
 
			NWidgetCore *button = this->GetWidget<NWidgetCore>(WID_SCRD_COMPANY_BUTTON_START + i);
 
			button->SetDisabled(!valid);
 
			button->SetLowered(this->filter.script_debug_company == i);
 
			SetScriptButtonColour(*button, dead, paused);
 
		}
 
	}
 

	
src/signal_type.h
Show inline comments
 
@@ -29,12 +29,13 @@ enum SignalType : byte {
 
	SIGTYPE_PBS_ONEWAY = 5, ///< no-entry signal
 

	
 
	SIGTYPE_END,
 
	SIGTYPE_LAST       = SIGTYPE_PBS_ONEWAY,
 
	SIGTYPE_LAST_NOPBS = SIGTYPE_COMBO,
 
};
 
DECLARE_ENUM_AS_ADDABLE(SignalType)
 

	
 
/**
 
 * These are states in which a signal can be. Currently these are only two, so
 
 * simple boolean logic will do. But do try to compare to this enum instead of
 
 * normal boolean evaluation, since that will make future additions easier.
 
 */
src/smallmap_gui.cpp
Show inline comments
 
@@ -608,26 +608,27 @@ uint32_t GetSmallMapOwnerPixels(TileInde
 

	
 
/** Vehicle colours in #SMT_VEHICLES mode. Indexed by #VehicleType. */
 
static const byte _vehicle_type_colours[6] = {
 
	PC_RED, PC_YELLOW, PC_LIGHT_BLUE, PC_WHITE, PC_BLACK, PC_RED
 
};
 

	
 
/** Types of legends in the #WID_SM_LEGEND widget. */
 
enum SmallMapType : byte {
 
	SMT_CONTOUR,
 
	SMT_VEHICLES,
 
	SMT_INDUSTRY,
 
	SMT_LINKSTATS,
 
	SMT_ROUTES,
 
	SMT_VEGETATION,
 
	SMT_OWNER,
 
};
 
DECLARE_ENUM_AS_ADDABLE(SmallMapType)
 

	
 
/** Class managing the smallmap window. */
 
class SmallMapWindow : public Window {
 
protected:
 
	/** Types of legends in the #WID_SM_LEGEND widget. */
 
	enum SmallMapType {
 
		SMT_CONTOUR,
 
		SMT_VEHICLES,
 
		SMT_INDUSTRY,
 
		SMT_LINKSTATS,
 
		SMT_ROUTES,
 
		SMT_VEGETATION,
 
		SMT_OWNER,
 
	};
 

	
 
	/** Available kinds of zoomlevel changes. */
 
	enum ZoomLevelChange {
 
		ZLC_INITIALIZE, ///< Initialize zoom level.
 
		ZLC_ZOOM_OUT,   ///< Zoom out.
 
		ZLC_ZOOM_IN,    ///< Zoom in.
 
	};
 
@@ -817,15 +818,15 @@ protected:
 
	/**
 
	 * Select a new map type.
 
	 * @param map_type New map type.
 
	 */
 
	void SwitchMapType(SmallMapType map_type)
 
	{
 
		this->RaiseWidget(this->map_type + WID_SM_CONTOUR);
 
		this->RaiseWidget(WID_SM_CONTOUR + this->map_type);
 
		this->map_type = map_type;
 
		this->LowerWidget(this->map_type + WID_SM_CONTOUR);
 
		this->LowerWidget(WID_SM_CONTOUR + this->map_type);
 

	
 
		this->SetupWidgetData();
 

	
 
		if (map_type == SMT_LINKSTATS) this->overlay->SetDirty();
 
		if (map_type != SMT_INDUSTRY) this->BreakIndustryChainLink();
 
		this->SetDirty();
 
@@ -1401,13 +1402,13 @@ public:
 

	
 
	SmallMapWindow(WindowDesc *desc, int window_number) : Window(desc)
 
	{
 
		_smallmap_industry_highlight = INVALID_INDUSTRYTYPE;
 
		this->overlay = std::make_unique<LinkGraphOverlay>(this, WID_SM_MAP, 0, this->GetOverlayCompanyMask(), 1);
 
		this->InitNested(window_number);
 
		this->LowerWidget(this->map_type + WID_SM_CONTOUR);
 
		this->LowerWidget(WID_SM_CONTOUR + this->map_type);
 

	
 
		this->RebuildColourIndexIfNecessary();
 

	
 
		this->SetWidgetLoweredState(WID_SM_SHOW_HEIGHT, _smallmap_show_heightmap);
 

	
 
		this->SetWidgetLoweredState(WID_SM_TOGGLETOWNNAME, this->show_towns);
 
@@ -1827,13 +1828,13 @@ public:
 
			this->SetDirty();
 
		}
 
	}
 

	
 
};
 

	
 
SmallMapWindow::SmallMapType SmallMapWindow::map_type = SMT_CONTOUR;
 
SmallMapType SmallMapWindow::map_type = SMT_CONTOUR;
 
bool SmallMapWindow::show_towns = true;
 
int SmallMapWindow::map_height_limit = -1;
 

	
 
/**
 
 * Custom container class for displaying smallmap with a vertically resizing legend panel.
 
 * The legend panel has a smallest height that depends on its width. Standard containers cannot handle this case.
src/textfile_type.h
Show inline comments
 
@@ -23,8 +23,9 @@ enum TextfileType {
 
	TFT_SURVEY_RESULT = TFT_CONTENT_END, ///< Survey result (preview)
 
	TFT_GAME_MANUAL,                ///< Game manual/documentation file
 

	
 
	TFT_END,
 
};
 
DECLARE_POSTFIX_INCREMENT(TextfileType)
 
DECLARE_ENUM_AS_ADDABLE(TextfileType)
 

	
 
#endif /* TEXTFILE_TYPE_H */
src/town_type.h
Show inline comments
 
@@ -21,12 +21,13 @@ enum TownSize : byte {
 
	TSZ_MEDIUM, ///< Medium town.
 
	TSZ_LARGE,  ///< Large town.
 
	TSZ_RANDOM, ///< Random size, bigger than small, smaller than large.
 

	
 
	TSZ_END,    ///< Number of available town sizes.
 
};
 
DECLARE_ENUM_AS_ADDABLE(TownSize)
 

	
 
enum Ratings {
 
	/* These refer to the maximums, so Appalling is -1000 to -400
 
	 * MAXIMUM RATINGS BOUNDARIES */
 
	RATING_MINIMUM     = -1000,
 
	RATING_APPALLING   =  -400,
 
@@ -84,12 +85,13 @@ enum TownLayout : byte {
 
	TL_3X3_GRID,         ///< Geometric 3x3 grid algorithm
 

	
 
	TL_RANDOM,           ///< Random town layout
 

	
 
	NUM_TLS,             ///< Number of town layouts
 
};
 
DECLARE_ENUM_AS_ADDABLE(TownLayout)
 

	
 
/** Town founding setting values. It needs to be 8bits, because we save and load it as such */
 
enum TownFounding : byte {
 
	TF_BEGIN = 0,     ///< Used for iterations and limit testing
 
	TF_FORBIDDEN = 0, ///< Forbidden
 
	TF_ALLOWED,       ///< Allowed
src/vehicle_gui.cpp
Show inline comments
 
@@ -2584,13 +2584,13 @@ struct VehicleDetailsWindow : Window {
 
	/** Repaint vehicle details window. */
 
	void OnPaint() override
 
	{
 
		const Vehicle *v = Vehicle::Get(this->window_number);
 

	
 
		if (v->type == VEH_TRAIN) {
 
			this->LowerWidget(this->tab + WID_VD_DETAILS_CARGO_CARRIED);
 
			this->LowerWidget(WID_VD_DETAILS_CARGO_CARRIED + this->tab);
 
			this->vscroll->SetCount(GetTrainDetailsWndVScroll(v->index, this->tab));
 
		}
 

	
 
		/* Disable service-scroller when interval is set to disabled */
 
		this->SetWidgetsDisabledState(!IsVehicleServiceIntervalEnabled(v->type, v->owner),
 
			WID_VD_INCREASE_SERVICING_INTERVAL,
src/vehicle_gui.h
Show inline comments
 
@@ -19,18 +19,19 @@
 
#include "engine_type.h"
 
#include "company_type.h"
 

	
 
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit = false);
 

	
 
/** The tabs in the train details window */
 
enum TrainDetailsWindowTabs {
 
enum TrainDetailsWindowTabs : byte {
 
	TDW_TAB_CARGO = 0, ///< Tab with cargo carried by the vehicles
 
	TDW_TAB_INFO,      ///< Tab with name and value of the vehicles
 
	TDW_TAB_CAPACITY,  ///< Tab with cargo capacity of the vehicles
 
	TDW_TAB_TOTALS,    ///< Tab with sum of total cargo transported
 
};
 
DECLARE_ENUM_AS_ADDABLE(TrainDetailsWindowTabs)
 

	
 
/** Special values for vehicle-related windows for the data parameter of #InvalidateWindowData. */
 
enum VehicleInvalidateWindowData {
 
	VIWD_REMOVE_ALL_ORDERS = -1, ///< Removed / replaced all orders (after deleting / sharing).
 
	VIWD_MODIFY_ORDERS     = -2, ///< Other order modifications.
 
	VIWD_CONSIST_CHANGED   = -3, ///< Vehicle composition was changed.
src/vehicle_type.h
Show inline comments
 
@@ -32,12 +32,13 @@ enum VehicleType : byte {
 
	VEH_DISASTER,                 ///< Disaster vehicle type.
 

	
 
	VEH_END,
 
	VEH_INVALID = 0xFF,           ///< Non-existing type of vehicle.
 
};
 
DECLARE_POSTFIX_INCREMENT(VehicleType)
 
DECLARE_ENUM_AS_ADDABLE(VehicleType)
 

	
 
struct Vehicle;
 
struct Train;
 
struct RoadVehicle;
 
struct Ship;
 
struct Aircraft;
src/zoom_type.h
Show inline comments
 
@@ -42,12 +42,13 @@ enum ZoomLevel : byte {
 

	
 
	ZOOM_LVL_MIN      = ZOOM_LVL_NORMAL, ///< Minimum zoom level.
 
	ZOOM_LVL_MAX      = ZOOM_LVL_OUT_32X, ///< Maximum zoom level.
 

	
 
};
 
DECLARE_POSTFIX_INCREMENT(ZoomLevel)
 
DECLARE_ENUM_AS_ADDABLE(ZoomLevel)
 

	
 
extern int _gui_scale;
 
extern int _gui_scale_cfg;
 

	
 
extern ZoomLevel _gui_zoom;
 
extern ZoomLevel _font_zoom;
0 comments (0 inline, 0 general)