Fix ICU iterators on leading/trailing whitespace
[openttd/fttd.git] / src / story_base.h
blobf4e55aa76134cc4a63b6472b6352e695bc82c681
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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 <http://www.gnu.org/licenses/>.
8 */
10 /** @file story_base.h %StoryPage base class. */
12 #ifndef STORY_BASE_H
13 #define STORY_BASE_H
15 #include "company_type.h"
16 #include "story_type.h"
17 #include "date_type.h"
18 #include "core/pool_type.hpp"
20 extern uint32 _story_page_element_next_sort_value;
21 extern uint32 _story_page_next_sort_value;
24 * Each story page element is one of these types.
26 enum StoryPageElementType {
27 SPET_TEXT = 0, ///< A text element.
28 SPET_LOCATION, ///< An element that references a tile along with a one-line text.
29 SPET_GOAL, ///< An element that references a goal.
30 SPET_END,
31 INVALID_SPET = 0xFF,
34 /** Define basic enum properties */
35 template <> struct EnumPropsT<StoryPageElementType> : MakeEnumPropsT<StoryPageElementType, byte, SPET_TEXT, SPET_END, INVALID_SPET, 8> {};
36 typedef TinyEnumT<StoryPageElementType> StoryPageElementTypeByte; ///< typedefing-enumification of Direction
38 /**
39 * Struct about story page elements.
40 * Each StoryPage is composed of one or more page elements that provide
41 * page content. Each element only contain one type of content.
42 **/
43 struct StoryPageElement : PooledItem <StoryPageElement, StoryPageElementID, 64, 64000> {
44 uint32 sort_value; ///< A number that increases for every created story page element. Used for sorting. The id of a story page element is the pool index.
45 StoryPageID page; ///< Id of the page which the page element belongs to
46 StoryPageElementTypeByte type; ///< Type of page element
48 uint32 referenced_id; ///< Id of referenced object (location, goal etc.)
49 char *text; ///< Static content text of page element
51 /**
52 * We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
54 inline StoryPageElement() { }
56 /**
57 * (Empty) destructor has to be defined else operator delete might be called with NULL parameter
59 inline ~StoryPageElement() { free(this->text); }
62 #define FOR_ALL_STORY_PAGE_ELEMENTS_FROM(var, start) FOR_ALL_ITEMS_FROM(StoryPageElement, story_page_element_index, var, start)
63 #define FOR_ALL_STORY_PAGE_ELEMENTS(var) FOR_ALL_STORY_PAGE_ELEMENTS_FROM(var, 0)
65 /** Struct about stories, current and completed */
66 struct StoryPage : PooledItem <StoryPage, StoryPageID, 64, 64000> {
67 uint32 sort_value; ///< A number that increases for every created story page. Used for sorting. The id of a story page is the pool index.
68 Date date; ///< Date when the page was created.
69 CompanyByte company; ///< StoryPage is for a specific company; INVALID_COMPANY if it is global
71 char *title; ///< Title of story page
73 /**
74 * We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
76 inline StoryPage() { }
78 /**
79 * (Empty) destructor has to be defined else operator delete might be called with NULL parameter
81 inline ~StoryPage()
83 if (!this->CleaningPool()) {
84 StoryPageElement *spe;
85 FOR_ALL_STORY_PAGE_ELEMENTS(spe) {
86 if (spe->page == this->index) delete spe;
89 free(this->title);
93 #define FOR_ALL_STORY_PAGES_FROM(var, start) FOR_ALL_ITEMS_FROM(StoryPage, story_page_index, var, start)
94 #define FOR_ALL_STORY_PAGES(var) FOR_ALL_STORY_PAGES_FROM(var, 0)
96 #endif /* STORY_BASE_H */