From 9dfd4f3b1935852650d6b2d9f3d3c09394975d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 4 Dec 2024 20:43:55 +0200 Subject: [PATCH] Rename the callback types --- src/openrct2-ui/WindowManager.cpp | 8 ++++---- src/openrct2-ui/windows/MapGen.cpp | 2 +- src/openrct2-ui/windows/NetworkStatus.cpp | 6 +++--- src/openrct2-ui/windows/ProgressWindow.cpp | 6 +++--- src/openrct2-ui/windows/Ride.cpp | 2 +- src/openrct2-ui/windows/SavePrompt.cpp | 2 +- src/openrct2-ui/windows/ScenarioSelect.cpp | 2 +- src/openrct2-ui/windows/ServerStart.cpp | 2 +- src/openrct2-ui/windows/Window.h | 10 +++++----- src/openrct2/Editor.cpp | 2 +- src/openrct2/Game.cpp | 4 ++-- src/openrct2/interface/Window.h | 2 +- src/openrct2/windows/Intent.cpp | 6 +++--- src/openrct2/windows/Intent.h | 6 +++--- 14 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 4c9fc87aa3..dfdf3684dd 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -246,7 +246,7 @@ public: { uint32_t type = intent->GetUIntExtra(INTENT_EXTRA_LOADSAVE_TYPE); std::string defaultName = intent->GetStringExtra(INTENT_EXTRA_PATH); - loadsave_callback callback = reinterpret_cast( + LoadSaveCallback callback = reinterpret_cast( intent->GetCloseCallbackExtra(INTENT_EXTRA_CALLBACK)); TrackDesign* trackDesign = static_cast(intent->GetPointerExtra(INTENT_EXTRA_TRACK_DESIGN)); auto* w = LoadsaveOpen( @@ -265,7 +265,7 @@ public: case WindowClass::NetworkStatus: { std::string message = intent->GetStringExtra(INTENT_EXTRA_MESSAGE); - close_callback callback = intent->GetCloseCallbackExtra(INTENT_EXTRA_CALLBACK); + CloseCallback callback = intent->GetCloseCallbackExtra(INTENT_EXTRA_CALLBACK); return NetworkStatusOpen(message, callback); } case WindowClass::ObjectLoadError: @@ -294,7 +294,7 @@ public: } case WindowClass::ScenarioSelect: return ScenarioselectOpen( - reinterpret_cast(intent->GetCloseCallbackExtra(INTENT_EXTRA_CALLBACK))); + reinterpret_cast(intent->GetCloseCallbackExtra(INTENT_EXTRA_CALLBACK))); case WindowClass::Null: // Intent does not hold a window class @@ -335,7 +335,7 @@ public: case INTENT_ACTION_PROGRESS_OPEN: { std::string message = intent->GetStringExtra(INTENT_EXTRA_MESSAGE); - close_callback callback = intent->GetCloseCallbackExtra(INTENT_EXTRA_CALLBACK); + CloseCallback callback = intent->GetCloseCallbackExtra(INTENT_EXTRA_CALLBACK); return ProgressWindowOpen(message, callback); } diff --git a/src/openrct2-ui/windows/MapGen.cpp b/src/openrct2-ui/windows/MapGen.cpp index 7efcea20e2..5f9160fe1d 100644 --- a/src/openrct2-ui/windows/MapGen.cpp +++ b/src/openrct2-ui/windows/MapGen.cpp @@ -942,7 +942,7 @@ namespace OpenRCT2::Ui::Windows { auto intent = Intent(WindowClass::Loadsave); intent.PutExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_LOAD | LOADSAVETYPE_HEIGHTMAP); - intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(HeightmapLoadsaveCallback)); + intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(HeightmapLoadsaveCallback)); ContextOpenIntent(&intent); return; } diff --git a/src/openrct2-ui/windows/NetworkStatus.cpp b/src/openrct2-ui/windows/NetworkStatus.cpp index a42c262512..50255cd6b5 100644 --- a/src/openrct2-ui/windows/NetworkStatus.cpp +++ b/src/openrct2-ui/windows/NetworkStatus.cpp @@ -110,7 +110,7 @@ namespace OpenRCT2::Ui::Windows DrawText(dpi, screenCoords, { COLOUR_BLACK }, _buffer.c_str()); } - void SetCloseCallBack(close_callback onClose) + void SetCloseCallBack(CloseCallback onClose) { _onClose = onClose; } @@ -127,12 +127,12 @@ namespace OpenRCT2::Ui::Windows } private: - close_callback _onClose = nullptr; + CloseCallback _onClose = nullptr; std::string _windowNetworkStatusText; std::string _password; }; - WindowBase* NetworkStatusOpen(const std::string& text, close_callback onClose) + WindowBase* NetworkStatusOpen(const std::string& text, CloseCallback onClose) { ContextForceCloseWindowByClass(WindowClass::ProgressWindow); diff --git a/src/openrct2-ui/windows/ProgressWindow.cpp b/src/openrct2-ui/windows/ProgressWindow.cpp index 0ca872e532..2866eddc16 100644 --- a/src/openrct2-ui/windows/ProgressWindow.cpp +++ b/src/openrct2-ui/windows/ProgressWindow.cpp @@ -70,7 +70,7 @@ namespace OpenRCT2::Ui::Windows class ProgressWindow final : public Window { private: - close_callback _onClose = nullptr; + CloseCallback _onClose = nullptr; StringId _progressFormat; std::string _progressTitle; @@ -213,7 +213,7 @@ namespace OpenRCT2::Ui::Windows Invalidate(); } - void SetCloseCallback(close_callback onClose) + void SetCloseCallback(CloseCallback onClose) { _onClose = onClose; } @@ -231,7 +231,7 @@ namespace OpenRCT2::Ui::Windows } }; - WindowBase* ProgressWindowOpen(const std::string& text, close_callback onClose) + WindowBase* ProgressWindowOpen(const std::string& text, CloseCallback onClose) { ContextForceCloseWindowByClass(WindowClass::NetworkStatus); diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index e364906851..4e89347cd3 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -5456,7 +5456,7 @@ namespace OpenRCT2::Ui::Windows intent.PutExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_SAVE | LOADSAVETYPE_TRACK); intent.PutExtra(INTENT_EXTRA_TRACK_DESIGN, _trackDesign.get()); intent.PutExtra(INTENT_EXTRA_PATH, trackName); - intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(&TrackDesignCallback)); + intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(&TrackDesignCallback)); ContextOpenIntent(&intent); } diff --git a/src/openrct2-ui/windows/SavePrompt.cpp b/src/openrct2-ui/windows/SavePrompt.cpp index b286a59adf..c268854c97 100644 --- a/src/openrct2-ui/windows/SavePrompt.cpp +++ b/src/openrct2-ui/windows/SavePrompt.cpp @@ -173,7 +173,7 @@ namespace OpenRCT2::Ui::Windows intent = CreateSaveGameAsIntent(); } Close(); - intent->PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(WindowSavePromptCallback)); + intent->PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(WindowSavePromptCallback)); ContextOpenIntent(intent.get()); break; } diff --git a/src/openrct2-ui/windows/ScenarioSelect.cpp b/src/openrct2-ui/windows/ScenarioSelect.cpp index 8c4ab4d378..1b7aa88986 100644 --- a/src/openrct2-ui/windows/ScenarioSelect.cpp +++ b/src/openrct2-ui/windows/ScenarioSelect.cpp @@ -761,7 +761,7 @@ namespace OpenRCT2::Ui::Windows } }; - WindowBase* ScenarioselectOpen(scenarioselect_callback callback) + WindowBase* ScenarioselectOpen(ScenarioSelectCallback callback) { return ScenarioselectOpen([callback](std::string_view scenario) { callback(std::string(scenario).c_str()); }); } diff --git a/src/openrct2-ui/windows/ServerStart.cpp b/src/openrct2-ui/windows/ServerStart.cpp index d38a4cfd6a..dc851cb5ea 100644 --- a/src/openrct2-ui/windows/ServerStart.cpp +++ b/src/openrct2-ui/windows/ServerStart.cpp @@ -139,7 +139,7 @@ namespace OpenRCT2::Ui::Windows NetworkSetPassword(_password); auto intent = Intent(WindowClass::Loadsave); intent.PutExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME); - intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(LoadSaveCallback)); + intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(LoadSaveCallback)); ContextOpenIntent(&intent); break; } diff --git a/src/openrct2-ui/windows/Window.h b/src/openrct2-ui/windows/Window.h index aaf44d7a81..75b39767ca 100644 --- a/src/openrct2-ui/windows/Window.h +++ b/src/openrct2-ui/windows/Window.h @@ -24,8 +24,8 @@ struct Vehicle; enum class GuestListFilterType : int32_t; enum class ScatterToolDensity : uint8_t; -using loadsave_callback = void (*)(int32_t result, const utf8* path); -using scenarioselect_callback = void (*)(const utf8* path); +using LoadSaveCallback = void (*)(int32_t result, const utf8* path); +using ScenarioSelectCallback = void (*)(const utf8* path); namespace OpenRCT2::Ui::Windows { @@ -118,7 +118,7 @@ namespace OpenRCT2::Ui::Windows WindowBase* GuestListOpen(); WindowBase* GuestListOpenWithFilter(GuestListFilterType type, int32_t index); WindowBase* StaffFirePromptOpen(Peep* peep); - WindowBase* ScenarioselectOpen(scenarioselect_callback callback); + WindowBase* ScenarioselectOpen(ScenarioSelectCallback callback); WindowBase* ScenarioselectOpen(std::function callback); WindowBase* ErrorOpen(StringId title, StringId message, const class Formatter& formatter, bool autoClose = false); @@ -174,11 +174,11 @@ namespace OpenRCT2::Ui::Windows WindowBase* MazeConstructionOpen(); void WindowMazeConstructionUpdatePressedWidgets(); - WindowBase* NetworkStatusOpen(const std::string& text, close_callback onClose); + WindowBase* NetworkStatusOpen(const std::string& text, CloseCallback onClose); WindowBase* NetworkStatusOpenPassword(); void WindowNetworkStatusClose(); - WindowBase* ProgressWindowOpen(const std::string& text, close_callback onClose = nullptr); + WindowBase* ProgressWindowOpen(const std::string& text, CloseCallback onClose = nullptr); void ProgressWindowSet(uint32_t currentProgress, uint32_t totalCount, StringId format = STR_NONE); void ProgressWindowClose(); diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index 8e05fd3d61..80560a2a2d 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -128,7 +128,7 @@ namespace OpenRCT2::Editor ToolCancel(); auto intent = Intent(WindowClass::Loadsave); intent.PutExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME); - intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(ConvertSaveToScenarioCallback)); + intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(ConvertSaveToScenarioCallback)); ContextOpenIntent(&intent); } diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index f77124cc5c..444b9b3890 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -654,7 +654,7 @@ void GameLoadOrQuitNoSavePrompt() { auto intent = Intent(WindowClass::Loadsave); intent.PutExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME); - intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(GameLoadOrQuitNoSavePromptCallback)); + intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(GameLoadOrQuitNoSavePromptCallback)); ContextOpenIntent(&intent); } break; @@ -683,7 +683,7 @@ void GameLoadOrQuitNoSavePrompt() GameActions::Execute(&loadOrQuitAction); ToolCancel(); auto intent = Intent(WindowClass::ScenarioSelect); - intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(NewGameWindowCallback)); + intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(NewGameWindowCallback)); ContextOpenIntent(&intent); break; } diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index 7595214fe3..e01bb155e3 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -445,7 +445,7 @@ extern Tool gCurrentToolId; extern WidgetRef gCurrentToolWidget; using modal_callback = void (*)(int32_t result); -using close_callback = void (*)(); +using CloseCallback = void (*)(); constexpr int8_t kWindowLimitMin = 4; constexpr int8_t kWindowLimitMax = 64; diff --git a/src/openrct2/windows/Intent.cpp b/src/openrct2/windows/Intent.cpp index 2dd7e6aa3e..81c70ce823 100644 --- a/src/openrct2/windows/Intent.cpp +++ b/src/openrct2/windows/Intent.cpp @@ -82,7 +82,7 @@ Intent* Intent::PutExtra(uint32_t key, std::string value) return this; } -Intent* Intent::PutExtra(uint32_t key, close_callback value) +Intent* Intent::PutExtra(uint32_t key, CloseCallback value) { putExtraImpl(_Data, key, value); return this; @@ -123,7 +123,7 @@ std::string Intent::GetStringExtra(uint32_t key) const return getExtraImpl(_Data, key); } -close_callback Intent::GetCloseCallbackExtra(uint32_t key) const +CloseCallback Intent::GetCloseCallbackExtra(uint32_t key) const { - return getExtraImpl(_Data, key); + return getExtraImpl(_Data, key); } diff --git a/src/openrct2/windows/Intent.h b/src/openrct2/windows/Intent.h index 6983010a97..bafa710594 100644 --- a/src/openrct2/windows/Intent.h +++ b/src/openrct2/windows/Intent.h @@ -62,7 +62,7 @@ enum IntentAction // The maximum amount of data the Intent can hold, 8 should be sufficient, raise this if needed. static constexpr size_t kIntentMaxDataSlots = 8; -using IntentData = std::variant; +using IntentData = std::variant; using IntentDataEntry = std::pair; using IntentDataStorage = sfl::static_vector; @@ -86,13 +86,13 @@ public: std::string GetStringExtra(uint32_t key) const; uint32_t GetUIntExtra(uint32_t key) const; int32_t GetSIntExtra(uint32_t key) const; - close_callback GetCloseCallbackExtra(uint32_t key) const; + CloseCallback GetCloseCallbackExtra(uint32_t key) const; Intent* PutExtra(uint32_t key, uint32_t value); Intent* PutExtra(uint32_t key, void* value); Intent* PutExtra(uint32_t key, int32_t value); Intent* PutExtra(uint32_t key, std::string value); - Intent* PutExtra(uint32_t key, close_callback value); + Intent* PutExtra(uint32_t key, CloseCallback value); template Intent* PutExtra(uint32_t key, const TIdentifier& value)