OpenTTD Source 20260606-master-ga894ddf665
story_base.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 STORY_BASE_H
11#define STORY_BASE_H
12
13#include "company_type.h"
14#include "story_type.h"
15#include "strings_type.h"
17#include "gfx_type.h"
18#include "vehicle_type.h"
19#include "core/pool_type.hpp"
20
21using StoryPageElementPool = Pool<StoryPageElement, StoryPageElementID, 64>;
22using StoryPagePool = Pool<StoryPage, StoryPageID, 64>;
23extern StoryPageElementPool _story_page_element_pool;
24extern StoryPagePool _story_page_pool;
25extern uint32_t _story_page_element_next_sort_value;
26extern uint32_t _story_page_next_sort_value;
27
38
40enum class StoryPageButtonFlag : uint8_t {
43};
44
47
108
116{
117 return cursor < StoryPageButtonCursor::End;
118}
119
122 uint32_t referenced_id = 0;
123
124 void SetColour(Colours button_colour);
125 void SetFlags(StoryPageButtonFlags flags);
126 void SetCursor(StoryPageButtonCursor cursor);
127 void SetVehicleType(VehicleType vehtype);
128 Colours GetColour() const;
132 bool ValidateColour() const;
133 bool ValidateFlags() const;
134 bool ValidateCursor() const;
135 bool ValidateVehicleType() const;
136};
137
143struct StoryPageElement : StoryPageElementPool::PoolItem<&_story_page_element_pool> {
144 uint32_t sort_value = 0;
147
148 uint32_t referenced_id = 0;
150
151 StoryPageElement(StoryPageElementID index) : StoryPageElementPool::PoolItem<&_story_page_element_pool>(index) {}
153 StoryPageElementPool::PoolItem<&_story_page_element_pool>(index), sort_value(sort_value), page(page), type(type) {}
154
159};
160
162struct StoryPage : StoryPagePool::PoolItem<&_story_page_pool> {
163 uint32_t sort_value = 0;
165 CompanyID company = CompanyID::Invalid();
166
168
169 StoryPage(StoryPageID index) : StoryPagePool::PoolItem<&_story_page_pool>(index) {}
171 StoryPagePool::PoolItem<&_story_page_pool>(index), sort_value(sort_value), date(date), company(company), title(title) {}
172
173 ~StoryPage();
174};
175
176#endif /* STORY_BASE_H */
177
Container for an encoded string, created by GetEncodedString.
Enum-as-bit-set wrapper.
StrongType::Typedef< int32_t, DateTag< struct Calendar >, StrongType::Compare, StrongType::Integer > Date
Types related to companies.
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
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
@ Dock
Ship dock.
StoryPageElementType
Each story page element is one of these types.
Definition story_base.h:29
@ ButtonTile
A button that allows the player to select a tile, and triggers an event with the tile.
Definition story_base.h:34
@ Invalid
Invalid story page element type.
Definition story_base.h:36
@ ButtonVehicle
A button that allows the player to select a vehicle, and triggers an event with the vehicle.
Definition story_base.h:35
@ ButtonPush
A push button that triggers an immediate event.
Definition story_base.h:33
@ Text
A text element.
Definition story_base.h:30
@ Location
An element that references a tile along with a one-line text.
Definition story_base.h:31
StoryPageButtonCursor
Mouse cursors usable by story page buttons.
Definition story_base.h:49
@ Desert
Use the Desert cursor.
Definition story_base.h:63
@ BuyLand
Use the Buy Land cursor.
Definition story_base.h:58
@ River
Use the River cursor.
Definition story_base.h:69
@ AutoRail
Use the Auto Rail cursor.
Definition story_base.h:77
@ LowerLand
Use the Lower Land cursor.
Definition story_base.h:101
@ TruckStation
Use the Truck Station cursor.
Definition story_base.h:94
@ ConvertMono
Use the Convert Mono cursor.
Definition story_base.h:88
@ PickStation
Use the Pick Station cursor.
Definition story_base.h:103
@ MonoDepot
Use the Mono Depot cursor.
Definition story_base.h:84
@ Transmitter
Use the Transmitter cursor.
Definition story_base.h:64
@ Tree
Use the Tree cursor.
Definition story_base.h:57
@ Demolish
Use the Demolish cursor.
Definition story_base.h:100
@ AutoMono
Use the Auto Mono cursor.
Definition story_base.h:79
@ BuildSignals
Use the Build Signals cursor.
Definition story_base.h:104
@ ConvertRail
Use the Convert Rail cursor.
Definition story_base.h:86
@ RockyArea
Use the RockyArea cursor.
Definition story_base.h:62
@ AutoTram
Use the Auto Tram cursor.
Definition story_base.h:91
@ RailDepot
Use the Rail Depot cursor.
Definition story_base.h:82
@ Query
Use the Query cursor.
Definition story_base.h:53
@ RailStation
Use the Rail Station cursor.
Definition story_base.h:72
@ RoadDepot
Use the Road Depot cursor.
Definition story_base.h:92
@ TunnelElrail
Use the Tunnel Elrail cursor.
Definition story_base.h:74
@ MaglevDepot
Use the Maglev Depot cursor.
Definition story_base.h:85
@ CloneAirplane
Use the Clone Airplane cursor.
Definition story_base.h:99
@ CloneRoadVeh
Use the Clone Road Veh cursor.
Definition story_base.h:97
@ RaiseLand
Use the Raise Land cursor.
Definition story_base.h:102
@ ConvertMaglev
Use the Convert Maglev cursor.
Definition story_base.h:89
@ CloneShip
Use the Clone Ship cursor.
Definition story_base.h:98
@ RoadTunnel
Use the Road Tunnel cursor.
Definition story_base.h:95
@ HQ
Use the HQ cursor.
Definition story_base.h:54
@ ShipDepot
Use the Ship Depot cursor.
Definition story_base.h:55
@ TunnelRail
Use the Tunnel Rail cursor.
Definition story_base.h:73
@ Canal
Use the Canal cursor.
Definition story_base.h:67
@ CloneTrain
Use the Clone Train cursor.
Definition story_base.h:96
@ TunnelMaglev
Use the Tunnel Maglev cursor.
Definition story_base.h:76
@ Buoy
Use the Buoy cursor.
Definition story_base.h:52
@ AutoRoad
Use the Auto Road cursor.
Definition story_base.h:90
@ Lock
Use the Lock cursor.
Definition story_base.h:68
@ BusStation
Use the Bus Station cursor.
Definition story_base.h:93
@ Aqueduct
Use the Aqueduct cursor.
Definition story_base.h:70
@ TunnelMono
Use the Tunnel Mono cursor.
Definition story_base.h:75
@ Zzz
Use the Zzz cursor.
Definition story_base.h:51
@ ConvertElrail
Use the Convert Elrail cursor.
Definition story_base.h:87
@ AutoElrail
Use the Auto Elrail cursor.
Definition story_base.h:78
@ LevelLand
Use the Level Land cursor.
Definition story_base.h:59
@ Bridge
Use the Bridge cursor.
Definition story_base.h:71
@ ElrailDepot
Use the Elrail Depot cursor.
Definition story_base.h:83
@ Mouse
Use the Mouse cursor.
Definition story_base.h:50
@ AutoMaglev
Use the Auto Maglev cursor.
Definition story_base.h:80
StoryPageButtonFlag
Flags available for buttons.
Definition story_base.h:40
@ FloatLeft
Button will float on the left.
Definition story_base.h:41
@ FloatRight
Button will float on the right.
Definition story_base.h:42
EnumBitSet< StoryPageButtonFlag, uint8_t > StoryPageButtonFlags
Bitset of StoryPageButtonFlag elements.
Definition story_base.h:46
bool IsValidStoryPageButtonCursor(StoryPageButtonCursor cursor)
Checks if a StoryPageButtonCursor value is valid.
Definition story_base.h:115
Basic types related to story pages.
PoolID< uint16_t, struct StoryPageIDTag, 64000, 0xFFFF > StoryPageID
ID of a story page.
Definition story_type.h:16
PoolID< uint16_t, struct StoryPageElementIDTag, 64000, 0xFFFF > StoryPageElementID
ID of a story page element.
Definition story_type.h:15
Types related to strings.
All airport-related information.
Struct about goals, current and completed.
Definition goal_base.h:22
Defines the internal data of a functional industry.
Definition industry.h:62
Base class for all pools.
Helper to construct packed "id" values for button-type StoryPageElement.
Definition story_base.h:121
Colours GetColour() const
Get the button background colour.
Definition story.cpp:173
VehicleType GetVehicleType() const
Get the type of vehicles that are accepted by the button.
Definition story.cpp:204
void SetColour(Colours button_colour)
Set the button background colour.
Definition story.cpp:134
bool ValidateVehicleType() const
Verity that the data stored a valid VehicleType value.
Definition story.cpp:246
StoryPageButtonFlags GetFlags() const
Get the button flags.
Definition story.cpp:184
bool ValidateFlags() const
Verify that valid flags were set.
Definition story.cpp:223
bool ValidateColour() const
Verify that the data stored a valid Colour value.
Definition story.cpp:213
void SetVehicleType(VehicleType vehtype)
Set the type of vehicles that are accepted by the button.
Definition story.cpp:163
StoryPageButtonCursor GetCursor() const
Get the mouse cursor used while waiting for input for the button.
Definition story.cpp:193
bool ValidateCursor() const
Verify that the data stores a valid StoryPageButtonCursor value.
Definition story.cpp:237
void SetCursor(StoryPageButtonCursor cursor)
Set the mouse cursor used while waiting for input for the button.
Definition story.cpp:153
void SetFlags(StoryPageButtonFlags flags)
Set the button flags.
Definition story.cpp:144
Struct about story page elements.
Definition story_base.h:143
uint32_t referenced_id
Id of referenced object (location, goal etc.).
Definition story_base.h:148
EncodedString text
Static content text of page element.
Definition story_base.h:149
uint32_t sort_value
A number that increases for every created story page element. Used for sorting. The id of a story pag...
Definition story_base.h:144
StoryPageElementType type
Type of page element.
Definition story_base.h:146
~StoryPageElement()
(Empty) destructor has to be defined else operator delete might be called with nullptr parameter
Definition story_base.h:158
StoryPageID page
Id of the page which the page element belongs to.
Definition story_base.h:145
Struct about stories, current and completed.
Definition story_base.h:162
EncodedString title
Title of story page.
Definition story_base.h:167
uint32_t sort_value
A number that increases for every created story page. Used for sorting. The id of a story page is the...
Definition story_base.h:163
CompanyID company
StoryPage is for a specific company; CompanyID::Invalid() if it is global.
Definition story_base.h:165
~StoryPage()
Delete all of our StoryPageElements.
Definition story.cpp:41
TimerGameCalendar::Date date
Date when the page was created.
Definition story_base.h:164
Town data structure.
Definition town.h:63
Representation of a waypoint.
Definition of the game-calendar-timer.
@ End
End marker.
Definition vehicle.cpp:2829
Types related to vehicles.
VehicleType
Available vehicle types.