Codechange: allow certain enumeration to be added

Otherwise C++20 doesn't like it.
This commit is contained in:
Rubidium 2024-01-16 22:01:28 +01:00 committed by rubidium42
parent 7737aa6640
commit aa5ba5bd7f
21 changed files with 83 additions and 63 deletions

View File

@ -747,7 +747,7 @@ public:
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;
@ -757,7 +757,7 @@ public:
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);
@ -963,9 +963,9 @@ public:
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) {

View File

@ -35,6 +35,7 @@ enum Owner : byte {
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'

View File

@ -37,5 +37,11 @@
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 */

View File

@ -79,9 +79,8 @@ enum DiagDirection : byte {
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.
@ -120,5 +119,6 @@ enum Axis : byte {
AXIS_END, ///< Used for iterations
INVALID_AXIS = 0xFF, ///< Flag for an invalid Axis
};
DECLARE_ENUM_AS_ADDABLE(Axis)
#endif /* DIRECTION_TYPE_H */

View File

@ -525,7 +525,7 @@ 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();
}
@ -569,9 +569,9 @@ public:
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();

View File

@ -247,6 +247,7 @@ enum Colours : byte {
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 {

View File

@ -50,7 +50,7 @@ struct GraphLegendWindow : Window {
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);
}
@ -58,7 +58,7 @@ struct GraphLegendWindow : Window {
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);
@ -78,7 +78,7 @@ struct GraphLegendWindow : Window {
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);
@ -1282,9 +1282,9 @@ struct PerformanceRatingDetailWindow : Window {
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();
}
}
@ -1309,13 +1309,13 @@ struct PerformanceRatingDetailWindow : Window {
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;
}
@ -1327,7 +1327,7 @@ struct PerformanceRatingDetailWindow : Window {
}
/* Make sure the widget is lowered */
this->LowerWidget(this->company + WID_PRD_COMPANY_FIRST);
this->LowerWidget(WID_PRD_COMPANY_FIRST + this->company);
}
};

View File

@ -666,9 +666,9 @@ bool LinkGraphLegendWindow::OnTooltip([[maybe_unused]] Point, WidgetID widget, T
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);
@ -680,8 +680,8 @@ void LinkGraphLegendWindow::UpdateOverlayCompanies()
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);
@ -696,8 +696,8 @@ void LinkGraphLegendWindow::OnClick([[maybe_unused]] Point pt, WidgetID 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();
@ -728,6 +728,6 @@ void LinkGraphLegendWindow::OnInvalidateData([[maybe_unused]] int data, [[maybe_
/* 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));
}
}

View File

@ -59,7 +59,7 @@ enum LiveryScheme : byte {
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,
@ -71,6 +71,7 @@ enum LiveryClass {
LC_GROUP_AIRCRAFT,
LC_END
};
DECLARE_ENUM_AS_ADDABLE(LiveryClass)
/** Information about a particular livery. */
struct Livery {

View File

@ -10,6 +10,8 @@
#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;
@ -86,11 +88,12 @@ 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.

View File

@ -998,12 +998,12 @@ public:
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);
@ -1328,9 +1328,9 @@ public:
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);
@ -1343,7 +1343,7 @@ public:
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;
@ -1894,7 +1894,7 @@ 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
@ -1926,9 +1926,9 @@ struct BuildRailDepotWindow : public PickerWindowBase {
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;

View File

@ -1007,7 +1007,7 @@ struct BuildRoadDepotWindow : public PickerWindowBase {
{
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++) {
@ -1047,9 +1047,9 @@ struct BuildRoadDepotWindow : public PickerWindowBase {
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;
@ -1132,9 +1132,9 @@ private:
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);
}
@ -1184,8 +1184,8 @@ public:
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);
@ -1508,9 +1508,9 @@ public:
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);

View File

@ -983,7 +983,7 @@ struct ScriptDebugWindow : public Window {
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);

View File

@ -32,6 +32,7 @@ enum SignalType : byte {
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

View File

@ -611,20 +611,21 @@ 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.
@ -820,9 +821,9 @@ protected:
*/
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();
@ -1404,7 +1405,7 @@ public:
_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();
@ -1830,7 +1831,7 @@ public:
};
SmallMapWindow::SmallMapType SmallMapWindow::map_type = SMT_CONTOUR;
SmallMapType SmallMapWindow::map_type = SMT_CONTOUR;
bool SmallMapWindow::show_towns = true;
int SmallMapWindow::map_height_limit = -1;

View File

@ -26,5 +26,6 @@ enum TextfileType {
TFT_END,
};
DECLARE_POSTFIX_INCREMENT(TextfileType)
DECLARE_ENUM_AS_ADDABLE(TextfileType)
#endif /* TEXTFILE_TYPE_H */

View File

@ -24,6 +24,7 @@ enum TownSize : byte {
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
@ -87,6 +88,7 @@ enum TownLayout : byte {
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 {

View File

@ -2587,7 +2587,7 @@ struct VehicleDetailsWindow : Window {
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));
}

View File

@ -22,12 +22,13 @@
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 {

View File

@ -35,6 +35,7 @@ enum VehicleType : byte {
VEH_INVALID = 0xFF, ///< Non-existing type of vehicle.
};
DECLARE_POSTFIX_INCREMENT(VehicleType)
DECLARE_ENUM_AS_ADDABLE(VehicleType)
struct Vehicle;
struct Train;

View File

@ -45,6 +45,7 @@ enum ZoomLevel : byte {
};
DECLARE_POSTFIX_INCREMENT(ZoomLevel)
DECLARE_ENUM_AS_ADDABLE(ZoomLevel)
extern int _gui_scale;
extern int _gui_scale_cfg;