diff --git a/src/script/api/script_story_page.cpp b/src/script/api/script_story_page.cpp index 6232187983..cba2360222 100644 --- a/src/script/api/script_story_page.cpp +++ b/src/script/api/script_story_page.cpp @@ -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(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(0); + return StoryPageElementID::Begin(); } /* static */ bool ScriptStoryPage::UpdateElement(StoryPageElementID story_page_element_id, SQInteger reference, Text *text) diff --git a/src/story_base.h b/src/story_base.h index 6978ad3a42..dd6ede0859 100644 --- a/src/story_base.h +++ b/src/story_base.h @@ -17,8 +17,8 @@ #include "vehicle_type.h" #include "core/pool_type.hpp" -typedef Pool StoryPageElementPool; -typedef Pool StoryPagePool; +using StoryPageElementPool = Pool; +using StoryPagePool = Pool; extern StoryPageElementPool _story_page_element_pool; extern StoryPagePool _story_page_pool; extern uint32_t _story_page_element_next_sort_value; diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 18a832c40e..6592e5e830 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -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(); diff --git a/src/story_type.h b/src/story_type.h index 773c1a4404..3eddaf3460 100644 --- a/src/story_type.h +++ b/src/story_type.h @@ -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; ///< ID of a story page element +using StoryPageID = PoolID; ///< 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 */ diff --git a/src/window_func.h b/src/window_func.h index 530bad4ca1..2d51cc04c4 100644 --- a/src/window_func.h +++ b/src/window_func.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();