OpenTTD Source 20260531-master-g0e951f3528
livery.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef LIVERY_H
11#define LIVERY_H
12
13#include "core/enum_type.hpp"
14#include "company_type.h"
15#include "gfx_type.h"
16
17static const uint8_t LIT_NONE = 0;
18static const uint8_t LIT_COMPANY = 1;
19static const uint8_t LIT_ALL = 2;
20
60
63
64
66
79
81
82
83struct Livery {
85 enum class Flag : uint8_t {
86 Primary = 0,
87 Secondary = 1,
88 };
90
91 Flags in_use{};
94
100 inline uint8_t GetRecolourOffset(bool use_secondary = true) const
101 {
102 return use_secondary ? to_underlying(this->colour1) + to_underlying(this->colour2) * 16 : to_underlying(this->colour1);
103 }
104};
105
107
108#endif /* LIVERY_H */
Enum-as-bit-set wrapper.
Types related to companies.
Type (helpers) for enums.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
Definition enum_type.hpp:21
#define DECLARE_ENUM_AS_ADDABLE(EnumType)
Operator that allows this enumeration to be added to any other enumeration.
#define DECLARE_INCREMENT_DECREMENT_OPERATORS(enum_type)
For some enums it is useful to have pre/post increment/decrement operators.
Definition enum_type.hpp:86
Types related to the graphics and/or input devices.
Colours
One of 16 base colours used for companies and windows/widgets.
Definition gfx_type.h:283
@ Begin
Begin marker.
Definition gfx_type.h:284
static const uint8_t LIT_ALL
Show the liveries of all companies.
Definition livery.h:19
EnumBitSet< LiveryScheme, uint32_t, LiveryScheme::End > LiverySchemes
Bitset of LiveryScheme elements.
Definition livery.h:65
LiveryScheme
List of different livery schemes.
Definition livery.h:22
@ PassengerTram
Passenger trams.
Definition livery.h:55
@ Begin
Begin marker.
Definition livery.h:23
@ SmallPlane
Small aeroplanes.
Definition livery.h:51
@ PassengerWagonMaglev
Passenger wagons attached to maglev engines.
Definition livery.h:38
@ Helicopter
Helicopters.
Definition livery.h:50
@ PassengerWagonElectric
Passenger wagons attached to electric engines.
Definition livery.h:36
@ Maglev
Maglev engines.
Definition livery.h:31
@ PassengerShip
Passenger ships.
Definition livery.h:46
@ EMU
EMUs and their passenger wagons.
Definition livery.h:33
@ Bus
Buses.
Definition livery.h:42
@ Truck
Trucks.
Definition livery.h:43
@ Default
Default scheme.
Definition livery.h:24
@ PassengerWagonDiesel
Passenger wagons attached to diesel engines.
Definition livery.h:35
@ FreightShip
Freight ships.
Definition livery.h:47
@ PassengerWagonMonorail
Passenger wagons attached to monorail engines.
Definition livery.h:37
@ Monorail
Monorail engines.
Definition livery.h:30
@ FreightTram
Freight trams.
Definition livery.h:56
@ PassengerWagonSteam
Passenger wagons attached to steam engines.
Definition livery.h:34
@ LargePlane
Large aeroplanes.
Definition livery.h:52
@ FreightWagon
Freight wagons.
Definition livery.h:39
@ DMU
DMUs and their passenger wagons.
Definition livery.h:32
void ResetCompanyLivery(Company *c)
Reset the livery schemes to the company's primary colour.
static const uint8_t LIT_COMPANY
Show the liveries of your own company.
Definition livery.h:18
static const uint8_t LIT_NONE
Don't show the liveries at all.
Definition livery.h:17
LiveryClass
List of different livery classes, used only by the livery GUI.
Definition livery.h:68
@ GroupShip
Ship group.
Definition livery.h:76
@ Other
General livery schemes.
Definition livery.h:69
@ GroupRail
Rail group.
Definition livery.h:74
@ GroupAircraft
Aircraft group.
Definition livery.h:77
@ GroupRoad
Road group.
Definition livery.h:75
@ Flags
ScriptConfigFlags defining how/when to use this configuration.
@ Rail
Railway station.
@ Road
Truck or bus stop.
Aircraft, helicopters, rotors and their shadows belong to this class.
Definition aircraft.h:73
Information about a particular livery.
Definition livery.h:83
Flags in_use
Livery flags.
Definition livery.h:91
uint8_t GetRecolourOffset(bool use_secondary=true) const
Get offset for recolour palette.
Definition livery.h:100
Colours colour2
Second colour, for vehicles with 2CC support.
Definition livery.h:93
Colours colour1
First colour, for all vehicles.
Definition livery.h:92
Flag
Flags for bitmask to declare which of the colours are set.
Definition livery.h:85
All ships have this type.
Definition ship.h:32
@ End
End marker.
Definition vehicle.cpp:2829
@ Steam
Steam model.
Definition vehicle.cpp:2825
@ Electric
Electric model.
Definition vehicle.cpp:2827
@ Diesel
Diesel model.
Definition vehicle.cpp:2826