mirror of https://github.com/OpenTTD/OpenTTD
Codechange: strongly type StoryPageID and StoryPageElementID
parent
5ca5790ac8
commit
3aa60fd479
|
@ -56,7 +56,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
|
|||
c, title != nullptr ? title->GetEncodedText() : std::string{})) return STORY_PAGE_INVALID;
|
||||
|
||||
/* In case of test-mode, we return StoryPageID 0 */
|
||||
return static_cast<StoryPageID>(0);
|
||||
return StoryPageID::Begin();
|
||||
}
|
||||
|
||||
/* static */ StoryPageElementID ScriptStoryPage::NewElement(StoryPageID story_page_id, StoryPageElementType type, SQInteger reference, Text *text)
|
||||
|
@ -103,7 +103,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
|
|||
encoded_text)) return STORY_PAGE_ELEMENT_INVALID;
|
||||
|
||||
/* In case of test-mode, we return StoryPageElementID 0 */
|
||||
return static_cast<StoryPageElementID>(0);
|
||||
return StoryPageElementID::Begin();
|
||||
}
|
||||
|
||||
/* static */ bool ScriptStoryPage::UpdateElement(StoryPageElementID story_page_element_id, SQInteger reference, Text *text)
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
#include "vehicle_type.h"
|
||||
#include "core/pool_type.hpp"
|
||||
|
||||
typedef Pool<StoryPageElement, StoryPageElementID, 64, 64000> StoryPageElementPool;
|
||||
typedef Pool<StoryPage, StoryPageID, 64, 64000> StoryPagePool;
|
||||
using StoryPageElementPool = Pool<StoryPageElement, StoryPageElementID, 64, StoryPageElementID::End().base()>;
|
||||
using StoryPagePool = Pool<StoryPage, StoryPageID, 64, StoryPageID::End().base()>;
|
||||
extern StoryPageElementPool _story_page_element_pool;
|
||||
extern StoryPagePool _story_page_pool;
|
||||
extern uint32_t _story_page_element_next_sort_value;
|
||||
|
|
|
@ -251,11 +251,11 @@ protected:
|
|||
for (const StoryPage *p : this->story_pages) {
|
||||
bool current_page = p->index == this->selected_page_id;
|
||||
if (!p->title.empty()) {
|
||||
list.push_back(MakeDropDownListStringItem(p->title, p->index, current_page));
|
||||
list.push_back(MakeDropDownListStringItem(p->title, p->index.base(), current_page));
|
||||
} else {
|
||||
/* No custom title => use a generic page title with page number. */
|
||||
SetDParam(0, page_num);
|
||||
list.push_back(MakeDropDownListStringItem(STR_STORY_BOOK_GENERIC_PAGE_ITEM, p->index, current_page));
|
||||
list.push_back(MakeDropDownListStringItem(STR_STORY_BOOK_GENERIC_PAGE_ITEM, p->index.base(), current_page));
|
||||
}
|
||||
page_num++;
|
||||
}
|
||||
|
@ -633,7 +633,7 @@ public:
|
|||
void SetSelectedPage(StoryPageID page_index)
|
||||
{
|
||||
if (this->selected_page_id != page_index) {
|
||||
if (this->active_button_id) ResetObjectToPlace();
|
||||
if (this->active_button_id != 0) ResetObjectToPlace();
|
||||
this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
|
||||
this->selected_page_id = page_index;
|
||||
this->RefreshSelectedPage();
|
||||
|
|
|
@ -11,15 +11,16 @@
|
|||
#define STORY_TYPE_H
|
||||
|
||||
#include "core/enum_type.hpp"
|
||||
#include "core/pool_type.hpp"
|
||||
|
||||
typedef uint16_t StoryPageElementID; ///< ID of a story page element
|
||||
typedef uint16_t StoryPageID; ///< ID of a story page
|
||||
using StoryPageElementID = PoolID<uint16_t, struct StoryPageElementIDTag, 64000, 0xFFFF>; ///< ID of a story page element
|
||||
using StoryPageID = PoolID<uint16_t, struct StoryPageIDTag, 64000, 0xFFFF>; ///< ID of a story page
|
||||
struct StoryPageElement;
|
||||
struct StoryPage;
|
||||
enum StoryPageElementType : uint8_t;
|
||||
|
||||
static const StoryPageElementID INVALID_STORY_PAGE_ELEMENT = 0xFFFF; ///< Constant representing a non-existing story page element.
|
||||
static const StoryPageID INVALID_STORY_PAGE = 0xFFFF; ///< Constant representing a non-existing story page.
|
||||
static constexpr StoryPageElementID INVALID_STORY_PAGE_ELEMENT = StoryPageElementID::Invalid(); ///< Constant representing a non-existing story page element.
|
||||
static constexpr StoryPageID INVALID_STORY_PAGE = StoryPageID::Invalid(); ///< Constant representing a non-existing story page.
|
||||
|
||||
#endif /* STORY_TYPE_H */
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ void InputLoop();
|
|||
|
||||
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data = 0, bool gui_scope = false);
|
||||
void InvalidateWindowClassesData(WindowClass cls, int data = 0, bool gui_scope = false);
|
||||
void InvalidateWindowClassesData(WindowClass cls, ConvertibleThroughBase auto data, bool gui_scope = false) { InvalidateWindowClassesData(cls, data.base(), gui_scope); }
|
||||
|
||||
void CloseNonVitalWindows();
|
||||
void CloseAllNonVitalWindows();
|
||||
|
|
Loading…
Reference in New Issue