From cce4daf5010d3083fefd363ab5bef2631dc427ae Mon Sep 17 00:00:00 2001 From: altalk23 Date: Thu, 13 Oct 2022 12:56:23 +0300 Subject: [PATCH] more compile time optimizations --- README.md | 3 +- bindings/GeometryDash.bro | 4 +- codegen/src/BindingGen.cpp | 4 +- entry.cpp | 2 +- loader/CMakeLists.txt | 4 +- loader/include/Geode/Bindings.hpp | 332 +----------------- loader/include/Geode/DefaultInclude.hpp | 146 ++++---- loader/include/Geode/Enums.hpp | 324 +++++++++++++++++ loader/include/Geode/loader/Dispatch.hpp | 2 +- loader/include/Geode/loader/Hook.hpp | 2 +- loader/include/Geode/loader/Loader.hpp | 3 +- loader/include/Geode/loader/Mod.hpp | 7 +- loader/include/Geode/loader/Setting.hpp | 12 +- loader/include/Geode/loader/SettingNode.hpp | 2 +- loader/include/Geode/modify/Field.hpp | 5 +- loader/include/Geode/ui/BasedButton.hpp | 1 + loader/include/Geode/ui/BasedButtonSprite.hpp | 2 +- loader/include/Geode/ui/ColorPickPopup.hpp | 2 + loader/include/Geode/ui/IconButtonSprite.hpp | 6 +- loader/include/Geode/ui/InputNode.hpp | 2 +- loader/include/Geode/ui/ListView.hpp | 3 +- loader/include/Geode/ui/MDTextArea.hpp | 3 +- loader/include/Geode/ui/Notification.hpp | 2 +- loader/include/Geode/ui/Popup.hpp | 3 +- loader/include/Geode/ui/SceneManager.hpp | 5 +- loader/include/Geode/ui/ScrollLayer.hpp | 3 +- loader/include/Geode/ui/Scrollbar.hpp | 2 +- loader/include/Geode/ui/SelectList.hpp | 2 +- loader/include/Geode/ui/TextRenderer.hpp | 2 +- loader/include/Geode/utils/cocos.hpp | 8 +- loader/include/Geode/utils/operators.hpp | 2 +- loader/src/hooks/GeodeNodeMetadata.cpp | 8 +- loader/src/hooks/MenuLayer.cpp | 2 +- loader/src/hooks/dictionary_fixes.cpp | 1 - loader/src/index/Index.cpp | 3 + loader/src/index/Index.hpp | 1 - loader/src/index/InstallTicket.cpp | 2 + loader/src/internal/InternalLoader.cpp | 1 - loader/src/internal/windows/crashlog.cpp | 2 - loader/src/load/Loader.cpp | 1 - loader/src/load/Log.cpp | 1 - loader/src/load/ios/Mod.mm | 2 +- loader/src/load/windows/Mod.cpp | 2 +- loader/src/ui/internal/list/ModListView.cpp | 2 +- .../ui/internal/settings/GeodeSettingNode.cpp | 4 + .../ui/internal/settings/GeodeSettingNode.hpp | 103 +++--- .../ui/internal/settings/ModSettingsPopup.cpp | 1 + loader/src/ui/nodes/ColorPickPopup.cpp | 4 + loader/src/ui/nodes/IconButtonSprite.cpp | 2 +- loader/src/ui/nodes/InputNode.cpp | 1 + loader/src/ui/nodes/ListView.cpp | 5 +- loader/src/ui/nodes/MDPopup.cpp | 1 + loader/src/ui/nodes/MDTextArea.cpp | 9 +- loader/src/ui/nodes/Notification.cpp | 7 +- loader/src/ui/nodes/SceneManager.cpp | 4 +- loader/src/ui/nodes/ScrollLayer.cpp | 4 +- loader/src/ui/nodes/Scrollbar.cpp | 3 +- loader/src/ui/nodes/TextRenderer.cpp | 8 +- loader/src/utils/cocos.cpp | 2 +- loader/src/utils/file.cpp | 1 - 60 files changed, 563 insertions(+), 524 deletions(-) create mode 100644 loader/include/Geode/Enums.hpp diff --git a/README.md b/README.md index ee068499..9b62d04c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ There's nothing worse than having to read thousands of words just to see what some library's code actually looks like, so instead, here's a **Hello World** in Geode right off the bat: ```cpp -#include +#include +#include USE_GEODE_NAMESPACE(); diff --git a/bindings/GeometryDash.bro b/bindings/GeometryDash.bro index ea6724fe..67225804 100644 --- a/bindings/GeometryDash.bro +++ b/bindings/GeometryDash.bro @@ -92,8 +92,8 @@ class AudioEffectsLayer { } class BoomListView : cocos2d::CCLayer, TableViewDelegate, TableViewDataSource { - inline BoomListView() {} - inline ~BoomListView() { + BoomListView() {} + ~BoomListView() { CC_SAFE_RELEASE(m_entries); } diff --git a/codegen/src/BindingGen.cpp b/codegen/src/BindingGen.cpp index 025ab3a3..9faf9a1c 100644 --- a/codegen/src/BindingGen.cpp +++ b/codegen/src/BindingGen.cpp @@ -10,7 +10,9 @@ namespace { namespace format_strings { char const* class_includes = R"GEN(#pragma once #include #include +#include #include +#include )GEN"; @@ -75,7 +77,7 @@ std::string generateBindingHeader(Root& root, ghc::filesystem::path const& singl std::string single_output; single_output += format_strings::class_includes; - for (auto dep : cls.superclasses) { + for (auto dep : cls.depends) { if (can_find(dep, "cocos2d::")) continue; std::string depfilename = (codegen::getUnqualifiedClassName(dep) + ".hpp"); diff --git a/entry.cpp b/entry.cpp index 6babddc3..0be8b4f4 100644 --- a/entry.cpp +++ b/entry.cpp @@ -1,6 +1,6 @@ // included by default in every geode project -#include +#include GEODE_API bool GEODE_CALL geode_implicit_load(geode::Mod* m) { geode::Mod::setSharedMod(m); diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 013cecfc..f7e65a02 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -117,10 +117,10 @@ target_link_libraries(${PROJECT_NAME} z lilac_hook geode-sdk) set_source_files_properties(${OBJC_SOURCES} PROPERTIES SKIP_PRECOMPILE_HEADERS ON) target_precompile_headers(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/DefaultInclude.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Utils.hpp" + # "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Utils.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Loader.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/UI.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Bindings.hpp" + # "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Bindings.hpp" # "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Modify.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/cocos/cocos2dx/include/cocos2d.h" ) diff --git a/loader/include/Geode/Bindings.hpp b/loader/include/Geode/Bindings.hpp index 5cd00a05..2fa5a2c6 100644 --- a/loader/include/Geode/Bindings.hpp +++ b/loader/include/Geode/Bindings.hpp @@ -15,340 +15,10 @@ #include #include #include +#include "Enums.hpp" namespace geode::core::meta {} -template -struct address_of_t { - static inline auto value = geode::base::get(); -}; - -template -inline auto address_of = address_of_t::value; - -//thanks pie -enum class SearchType { - Search = 0, - Downloaded = 1, - MostLiked = 2, - Trending = 3, - Recent = 4, - UsersLevels = 5, - Featured = 6, - Magic = 7, - Sends = 8, - MapPack = 9, - MapPackOnClick = 10, - Awarded = 11, - Followed = 12, - Friends = 13, - Users = 14, - LikedGDW = 15, - HallOfFame = 16, - FeaturedGDW = 17, - Similar = 18, - MyLevels = 98, - SavedLevels = 99, - FavouriteLevels = 100 -}; - -// jesus fucking christ (painfully written by @hjfod) -enum class GameObjectType { - Solid = 0, - Hazard = 2, - InverseGravityPortal = 3, - NormalGravityPortal = 4, - ShipPortal = 5, - CubePortal = 6, - Decoration = 7, - YellowJumpPad = 8, - PinkJumpPad = 9, - GravityPad = 10, - YellowJumpRing = 11, - PinkJumpRing = 12, - GravityRing = 13, - InverseMirrorPortal = 14, - NormalMirrorPortal = 15, - BallPortal = 16, - RegularSizePortal = 17, - MiniSizePortal = 18, - UfoPortal = 19, - Modifier = 20, - SecretCoin = 22, - DualPortal = 23, - SoloPortal = 24, - Slope = 25, - WavePortal = 26, - RobotPortal = 27, - TeleportPortal = 28, - GreenRing = 29, - Collectible = 30, - UserCoin = 31, - DropRing = 32, - SpiderPortal = 33, - RedJumpPad = 34, - RedJumpRing = 35, - CustomRing = 36, - DashRing = 37, - GravityDashRing = 38, - CollisionObject = 39, - Special = 40, -}; - -enum class PulseEffectType {}; -enum class TouchTriggerType {}; -enum class PlayerButton {}; -enum class GhostType {}; -enum class TableViewCellEditingStyle {}; -enum class UserListType {}; -enum class GJErrorCode {}; -enum class AccountError {}; -enum class GJSongError {}; -enum class LikeItemType { - Unknown = 0, - Level = 1, - Comment = 2, - AccountComment = 3 -}; - -enum class GJStoreItem {}; -enum class CommentError {}; -enum class BackupAccountError {}; - -enum class BoomListType { - Default = 0x0, - User = 0x2, - Stats = 0x3, - Achievement = 0x4, - Level = 0x5, - Level2 = 0x6, - Comment = 0x7, - Comment2 = 0x8, - Song = 0xb, - Score = 0xc, - MapPack = 0xd, - CustomSong = 0xe, - Comment3 = 0xf, - User2 = 0x10, - Request = 0x11, - Message = 0x12, - LevelScore = 0x13, - Artist = 0x14, -}; - -enum class MenuAnimationType { - Scale = 0, - Move = 1, -}; - -enum class ShopType { - Normal, - Secret, - Community -}; - -// Geode Addition -enum class ZLayer { - B4 = -3, - B3 = -1, - B2 = 1, - B1 = 3, - Default = 0, - T1 = 5, - T2 = 7, - T3 = 9, -}; - -enum class UpdateResponse { - Unknown, - UpToDate, - GameVerOutOfDate, - UpdateSuccess, -}; - -enum class UnlockType { - Cube = 0x1, - Col1 = 0x2, - Col2 = 0x3, - Ship = 0x4, - Ball = 0x5, - Bird = 0x6, - Dart = 0x7, - Robot = 0x8, - Spider = 0x9, - Streak = 0xA, - Death = 0xB, - GJItem = 0xC, -}; - -enum class SpecialRewardItem { - FireShard = 0x1, - IceShard = 0x2, - PoisonShard = 0x3, - ShadowShard = 0x4, - LavaShard = 0x5, - BonusKey = 0x6, - Orbs = 0x7, - Diamonds = 0x8, - CustomItem = 0x9, -}; - -enum class EditCommand { - SmallLeft = 1, - SmallRight = 2, - SmallUp = 3, - SmallDown = 4, - - Left = 5, - Right = 6, - Up = 7, - Down = 8, - - BigLeft = 9, - BigRight = 10, - BigUp = 11, - BigDown = 12, - - TinyLeft = 13, - TinyRight = 14, - TinyUp = 15, - TinyDown = 16, - - FlipX = 17, - FlipY = 18, - RotateCW = 19, - RotateCCW = 20, - RotateCW45 = 21, - RotateCCW45 = 22, - RotateFree = 23, - RotateSnap = 24, - - Scale = 25, -}; - -// Geode Addition -enum class PlaybackMode { - Not = 0, - Playing = 1, - Paused = 2, -}; - -enum class SelectArtType { - Background = 0, - Ground = 1, -}; - -enum class UndoCommand { - Delete = 1, - New = 2, - Paste = 3, - DeleteMulti = 4, - Transform = 5, - Select = 6, -}; - -enum class EasingType { - None = 0, - EaseInOut = 1, - EaseIn = 2, - EaseOut = 3, - ElasticInOut = 4, - ElasticIn = 5, - ElasticOut = 6, - BounceInOut = 7, - BounceIn = 8, - BounceOut = 9, - ExponentialInOut = 10, - ExponentialIn = 11, - ExponentialOut = 12, - SineInOut = 13, - SineIn = 14, - SineOut = 15, - BackInOut = 16, - BackIn = 17, - BackOut = 18, -}; - -enum class GJDifficulty { - Auto = 0, - Easy = 1, - Normal = 2, - Hard = 3, - Harder = 4, - Insane = 5, - Demon = 6, - DemonEasy = 7, - DemonMedium = 8, - DemonInsane = 9, - DemonExtreme = 10 -}; - -enum class GJLevelType { - Local = 1, - Editor = 2, - Saved = 3 -}; - -enum class IconType { - Cube = 0, - Ship = 1, - Ball = 2, - Ufo = 3, - Wave = 4, - Robot = 5, - Spider = 6, - DeathEffect = 98, - Special = 99, -}; - -enum class GJChallengeType { - Unknown = 0, - Orbs = 1, - UserCoins = 2, - Stars = 3 -}; - -enum class GJScoreType { - Unknown = 0, - Creator = 1 -}; - -enum class LevelLeaderboardType { - Friends = 0, - Global = 1, - Weekly = 2 -}; - -// Geode Addition -enum class ComparisonType { - Equals = 0, - Larger = 1, - Smaller = 2, -}; - -// Geode Addition -enum class MoveTargetType { - Both = 0, - XOnly = 1, - YOnly = 2, -}; - -// Geode Addition -enum class TouchToggleMode { - Normal = 0, - ToggleOn = 1, - ToggleOff = 2, -}; - -// Geode Addition -enum class LeaderboardState { - Default = 0, - Top100 = 1, - Global = 2, - Creator = 3, - Friends = 4, -}; - #define CLASSPARAM(...) #define STRUCTPARAM(...) diff --git a/loader/include/Geode/DefaultInclude.hpp b/loader/include/Geode/DefaultInclude.hpp index af94ce66..1246b2f6 100644 --- a/loader/include/Geode/DefaultInclude.hpp +++ b/loader/include/Geode/DefaultInclude.hpp @@ -103,82 +103,82 @@ _61,_62,_63,N,...) N 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 -#define GEODE_NEST1(macro, begin) \ -macro(GEODE_CONCAT(begin, 0)), \ -macro(GEODE_CONCAT(begin, 1)), \ -macro(GEODE_CONCAT(begin, 2)), \ -macro(GEODE_CONCAT(begin, 3)), \ -macro(GEODE_CONCAT(begin, 4)), \ -macro(GEODE_CONCAT(begin, 5)), \ -macro(GEODE_CONCAT(begin, 6)), \ -macro(GEODE_CONCAT(begin, 7)), \ -macro(GEODE_CONCAT(begin, 8)), \ -macro(GEODE_CONCAT(begin, 9)), \ -macro(GEODE_CONCAT(begin, a)), \ -macro(GEODE_CONCAT(begin, b)), \ -macro(GEODE_CONCAT(begin, c)), \ -macro(GEODE_CONCAT(begin, d)), \ -macro(GEODE_CONCAT(begin, e)), \ -macro(GEODE_CONCAT(begin, f)) +// #define GEODE_NEST1(macro, begin) \ +// macro(GEODE_CONCAT(begin, 0)), \ +// macro(GEODE_CONCAT(begin, 1)), \ +// macro(GEODE_CONCAT(begin, 2)), \ +// macro(GEODE_CONCAT(begin, 3)), \ +// macro(GEODE_CONCAT(begin, 4)), \ +// macro(GEODE_CONCAT(begin, 5)), \ +// macro(GEODE_CONCAT(begin, 6)), \ +// macro(GEODE_CONCAT(begin, 7)), \ +// macro(GEODE_CONCAT(begin, 8)), \ +// macro(GEODE_CONCAT(begin, 9)), \ +// macro(GEODE_CONCAT(begin, a)), \ +// macro(GEODE_CONCAT(begin, b)), \ +// macro(GEODE_CONCAT(begin, c)), \ +// macro(GEODE_CONCAT(begin, d)), \ +// macro(GEODE_CONCAT(begin, e)), \ +// macro(GEODE_CONCAT(begin, f)) -#define GEODE_NEST2(macro, begin) \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, 0)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, 1)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, 2)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, 3)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, 4)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, 5)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, 6)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, 7)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, 8)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, 9)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, a)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, b)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, c)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, d)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, e)), \ -GEODE_NEST1(macro, GEODE_CONCAT(begin, f)) +// #define GEODE_NEST2(macro, begin) \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, 0)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, 1)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, 2)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, 3)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, 4)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, 5)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, 6)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, 7)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, 8)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, 9)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, a)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, b)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, c)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, d)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, e)), \ +// GEODE_NEST1(macro, GEODE_CONCAT(begin, f)) -#define GEODE_NEST3(macro, begin) \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, 0)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, 1)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, 2)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, 3)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, 4)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, 5)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, 6)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, 7)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, 8)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, 9)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, a)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, b)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, c)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, d)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, e)), \ -GEODE_NEST2(macro, GEODE_CONCAT(begin, f)) +// #define GEODE_NEST3(macro, begin) \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, 0)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, 1)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, 2)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, 3)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, 4)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, 5)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, 6)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, 7)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, 8)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, 9)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, a)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, b)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, c)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, d)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, e)), \ +// GEODE_NEST2(macro, GEODE_CONCAT(begin, f)) -#define GEODE_NEST4(macro, begin) \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, 0)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, 1)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, 2)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, 3)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, 4)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, 5)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, 6)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, 7)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, 8)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, 9)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, a)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, b)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, c)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, d)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, e)), \ -GEODE_NEST3(macro, GEODE_CONCAT(begin, f)) +// #define GEODE_NEST4(macro, begin) \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, 0)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, 1)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, 2)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, 3)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, 4)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, 5)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, 6)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, 7)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, 8)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, 9)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, a)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, b)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, c)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, d)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, e)), \ +// GEODE_NEST3(macro, GEODE_CONCAT(begin, f)) -#define GEODE_ENUM_OFFSETS_DEFINE(hex) GEODE_CONCAT($, hex) -#define GEODE_ENUM_OFFSETS_SET() GEODE_NEST4(GEODE_ENUM_OFFSETS_DEFINE, 0x) +// #define GEODE_ENUM_OFFSETS_DEFINE(hex) GEODE_CONCAT($, hex) +// #define GEODE_ENUM_OFFSETS_SET() GEODE_NEST4(GEODE_ENUM_OFFSETS_DEFINE, 0x) -enum class PrinterOffsets { - GEODE_ENUM_OFFSETS_SET() -}; +// enum class PrinterOffsets { +// GEODE_ENUM_OFFSETS_SET() +// }; diff --git a/loader/include/Geode/Enums.hpp b/loader/include/Geode/Enums.hpp new file mode 100644 index 00000000..0c95030b --- /dev/null +++ b/loader/include/Geode/Enums.hpp @@ -0,0 +1,324 @@ +#pragma once + +//thanks pie +enum class SearchType { + Search = 0, + Downloaded = 1, + MostLiked = 2, + Trending = 3, + Recent = 4, + UsersLevels = 5, + Featured = 6, + Magic = 7, + Sends = 8, + MapPack = 9, + MapPackOnClick = 10, + Awarded = 11, + Followed = 12, + Friends = 13, + Users = 14, + LikedGDW = 15, + HallOfFame = 16, + FeaturedGDW = 17, + Similar = 18, + MyLevels = 98, + SavedLevels = 99, + FavouriteLevels = 100 +}; + +// jesus fucking christ (painfully written by @hjfod) +enum class GameObjectType { + Solid = 0, + Hazard = 2, + InverseGravityPortal = 3, + NormalGravityPortal = 4, + ShipPortal = 5, + CubePortal = 6, + Decoration = 7, + YellowJumpPad = 8, + PinkJumpPad = 9, + GravityPad = 10, + YellowJumpRing = 11, + PinkJumpRing = 12, + GravityRing = 13, + InverseMirrorPortal = 14, + NormalMirrorPortal = 15, + BallPortal = 16, + RegularSizePortal = 17, + MiniSizePortal = 18, + UfoPortal = 19, + Modifier = 20, + SecretCoin = 22, + DualPortal = 23, + SoloPortal = 24, + Slope = 25, + WavePortal = 26, + RobotPortal = 27, + TeleportPortal = 28, + GreenRing = 29, + Collectible = 30, + UserCoin = 31, + DropRing = 32, + SpiderPortal = 33, + RedJumpPad = 34, + RedJumpRing = 35, + CustomRing = 36, + DashRing = 37, + GravityDashRing = 38, + CollisionObject = 39, + Special = 40, +}; + +enum class PulseEffectType {}; +enum class TouchTriggerType {}; +enum class PlayerButton {}; +enum class GhostType {}; +enum class TableViewCellEditingStyle {}; +enum class UserListType {}; +enum class GJErrorCode {}; +enum class AccountError {}; +enum class GJSongError {}; +enum class LikeItemType { + Unknown = 0, + Level = 1, + Comment = 2, + AccountComment = 3 +}; + +enum class GJStoreItem {}; +enum class CommentError {}; +enum class BackupAccountError {}; + +enum class BoomListType { + Default = 0x0, + User = 0x2, + Stats = 0x3, + Achievement = 0x4, + Level = 0x5, + Level2 = 0x6, + Comment = 0x7, + Comment2 = 0x8, + Song = 0xb, + Score = 0xc, + MapPack = 0xd, + CustomSong = 0xe, + Comment3 = 0xf, + User2 = 0x10, + Request = 0x11, + Message = 0x12, + LevelScore = 0x13, + Artist = 0x14, +}; + +enum class MenuAnimationType { + Scale = 0, + Move = 1, +}; + +enum class ShopType { + Normal, + Secret, + Community +}; + +// Geode Addition +enum class ZLayer { + B4 = -3, + B3 = -1, + B2 = 1, + B1 = 3, + Default = 0, + T1 = 5, + T2 = 7, + T3 = 9, +}; + +enum class UpdateResponse { + Unknown, + UpToDate, + GameVerOutOfDate, + UpdateSuccess, +}; + +enum class UnlockType { + Cube = 0x1, + Col1 = 0x2, + Col2 = 0x3, + Ship = 0x4, + Ball = 0x5, + Bird = 0x6, + Dart = 0x7, + Robot = 0x8, + Spider = 0x9, + Streak = 0xA, + Death = 0xB, + GJItem = 0xC, +}; + +enum class SpecialRewardItem { + FireShard = 0x1, + IceShard = 0x2, + PoisonShard = 0x3, + ShadowShard = 0x4, + LavaShard = 0x5, + BonusKey = 0x6, + Orbs = 0x7, + Diamonds = 0x8, + CustomItem = 0x9, +}; + +enum class EditCommand { + SmallLeft = 1, + SmallRight = 2, + SmallUp = 3, + SmallDown = 4, + + Left = 5, + Right = 6, + Up = 7, + Down = 8, + + BigLeft = 9, + BigRight = 10, + BigUp = 11, + BigDown = 12, + + TinyLeft = 13, + TinyRight = 14, + TinyUp = 15, + TinyDown = 16, + + FlipX = 17, + FlipY = 18, + RotateCW = 19, + RotateCCW = 20, + RotateCW45 = 21, + RotateCCW45 = 22, + RotateFree = 23, + RotateSnap = 24, + + Scale = 25, +}; + +// Geode Addition +enum class PlaybackMode { + Not = 0, + Playing = 1, + Paused = 2, +}; + +enum class SelectArtType { + Background = 0, + Ground = 1, +}; + +enum class UndoCommand { + Delete = 1, + New = 2, + Paste = 3, + DeleteMulti = 4, + Transform = 5, + Select = 6, +}; + +enum class EasingType { + None = 0, + EaseInOut = 1, + EaseIn = 2, + EaseOut = 3, + ElasticInOut = 4, + ElasticIn = 5, + ElasticOut = 6, + BounceInOut = 7, + BounceIn = 8, + BounceOut = 9, + ExponentialInOut = 10, + ExponentialIn = 11, + ExponentialOut = 12, + SineInOut = 13, + SineIn = 14, + SineOut = 15, + BackInOut = 16, + BackIn = 17, + BackOut = 18, +}; + +enum class GJDifficulty { + Auto = 0, + Easy = 1, + Normal = 2, + Hard = 3, + Harder = 4, + Insane = 5, + Demon = 6, + DemonEasy = 7, + DemonMedium = 8, + DemonInsane = 9, + DemonExtreme = 10 +}; + +enum class GJLevelType { + Local = 1, + Editor = 2, + Saved = 3 +}; + +enum class IconType { + Cube = 0, + Ship = 1, + Ball = 2, + Ufo = 3, + Wave = 4, + Robot = 5, + Spider = 6, + DeathEffect = 98, + Special = 99, +}; + +enum class GJChallengeType { + Unknown = 0, + Orbs = 1, + UserCoins = 2, + Stars = 3 +}; + +enum class GJScoreType { + Unknown = 0, + Creator = 1 +}; + +enum class LevelLeaderboardType { + Friends = 0, + Global = 1, + Weekly = 2 +}; + +// Geode Addition +enum class ComparisonType { + Equals = 0, + Larger = 1, + Smaller = 2, +}; + +// Geode Addition +enum class MoveTargetType { + Both = 0, + XOnly = 1, + YOnly = 2, +}; + +// Geode Addition +enum class TouchToggleMode { + Normal = 0, + ToggleOn = 1, + ToggleOff = 2, +}; + +// Geode Addition +enum class LeaderboardState { + Default = 0, + Top100 = 1, + Global = 2, + Creator = 3, + Friends = 4, +}; \ No newline at end of file diff --git a/loader/include/Geode/loader/Dispatch.hpp b/loader/include/Geode/loader/Dispatch.hpp index 4ecaf7af..4ee51ceb 100644 --- a/loader/include/Geode/loader/Dispatch.hpp +++ b/loader/include/Geode/loader/Dispatch.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include "Event.hpp" #include #include #include diff --git a/loader/include/Geode/loader/Hook.hpp b/loader/include/Geode/loader/Hook.hpp index 5bd057b8..acc28922 100644 --- a/loader/include/Geode/loader/Hook.hpp +++ b/loader/include/Geode/loader/Hook.hpp @@ -5,7 +5,7 @@ #include #include -#include "../hook-core/Hook.hpp" +#include namespace geode { class Mod; diff --git a/loader/include/Geode/loader/Loader.hpp b/loader/include/Geode/loader/Loader.hpp index 375cbb75..c82e3e1a 100644 --- a/loader/include/Geode/loader/Loader.hpp +++ b/loader/include/Geode/loader/Loader.hpp @@ -10,9 +10,7 @@ #include #include #include -#include #include "Log.hpp" -#include namespace geode { #pragma warning(disable: 4251) @@ -27,6 +25,7 @@ namespace geode { class Mod; class Hook; struct ModInfo; + class VersionInfo; namespace modifier { template diff --git a/loader/include/Geode/loader/Mod.hpp b/loader/include/Geode/loader/Mod.hpp index 13934913..36e7a4df 100644 --- a/loader/include/Geode/loader/Mod.hpp +++ b/loader/include/Geode/loader/Mod.hpp @@ -3,15 +3,14 @@ #include #include "Types.hpp" #include "Hook.hpp" -#include "../utils/types.hpp" -#include "../utils/Result.hpp" -#include "../utils/VersionInfo.hpp" +#include +#include +#include #include #include #include #include #include -#include #include "Setting.hpp" #include diff --git a/loader/include/Geode/loader/Setting.hpp b/loader/include/Geode/loader/Setting.hpp index 895c2a36..0d203e03 100644 --- a/loader/include/Geode/loader/Setting.hpp +++ b/loader/include/Geode/loader/Setting.hpp @@ -3,12 +3,12 @@ #include #include #include -#include "../utils/container.hpp" -#include "../utils/json.hpp" -#include "../utils/Result.hpp" -#include "../utils/JsonValidation.hpp" -#include "../utils/convert.hpp" -#include "../utils/platform.hpp" +#include +#include +#include +#include +#include +#include #include #pragma warning(push) diff --git a/loader/include/Geode/loader/SettingNode.hpp b/loader/include/Geode/loader/SettingNode.hpp index 52c460bf..e1c46a93 100644 --- a/loader/include/Geode/loader/SettingNode.hpp +++ b/loader/include/Geode/loader/SettingNode.hpp @@ -1,7 +1,7 @@ #pragma once #include "Setting.hpp" -#include +#include namespace geode { class SettingNode; diff --git a/loader/include/Geode/modify/Field.hpp b/loader/include/Geode/modify/Field.hpp index 55af599f..b8e29edd 100644 --- a/loader/include/Geode/modify/Field.hpp +++ b/loader/include/Geode/modify/Field.hpp @@ -1,10 +1,13 @@ #pragma once -#include #include "Traits.hpp" #include #include +namespace cocos2d { + class CCNode; +} + namespace geode::modifier { class FieldContainer { private: diff --git a/loader/include/Geode/ui/BasedButton.hpp b/loader/include/Geode/ui/BasedButton.hpp index 45554312..9d5bc0c5 100644 --- a/loader/include/Geode/ui/BasedButton.hpp +++ b/loader/include/Geode/ui/BasedButton.hpp @@ -1,6 +1,7 @@ #pragma once #include "BasedButtonSprite.hpp" +#include #pragma warning(disable : 4275) diff --git a/loader/include/Geode/ui/BasedButtonSprite.hpp b/loader/include/Geode/ui/BasedButtonSprite.hpp index 86323248..6b2f0b3b 100644 --- a/loader/include/Geode/ui/BasedButtonSprite.hpp +++ b/loader/include/Geode/ui/BasedButtonSprite.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace geode { enum class CircleBaseSize { diff --git a/loader/include/Geode/ui/ColorPickPopup.hpp b/loader/include/Geode/ui/ColorPickPopup.hpp index 49d3f17d..d0f46938 100644 --- a/loader/include/Geode/ui/ColorPickPopup.hpp +++ b/loader/include/Geode/ui/ColorPickPopup.hpp @@ -1,6 +1,8 @@ #include "Popup.hpp" #include "InputNode.hpp" +#include + namespace geode { class ColorPickPopupDelegate { public: diff --git a/loader/include/Geode/ui/IconButtonSprite.hpp b/loader/include/Geode/ui/IconButtonSprite.hpp index acf7e749..859baaee 100644 --- a/loader/include/Geode/ui/IconButtonSprite.hpp +++ b/loader/include/Geode/ui/IconButtonSprite.hpp @@ -1,6 +1,10 @@ #pragma once -#include +#include + +namespace cocos2d::extension { + class CCScale9Sprite; +} namespace geode { class GEODE_DLL IconButtonSprite : diff --git a/loader/include/Geode/ui/InputNode.hpp b/loader/include/Geode/ui/InputNode.hpp index 57898607..ebf81827 100644 --- a/loader/include/Geode/ui/InputNode.hpp +++ b/loader/include/Geode/ui/InputNode.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace geode { class GEODE_DLL InputNode : public cocos2d::CCMenuItem { diff --git a/loader/include/Geode/ui/ListView.hpp b/loader/include/Geode/ui/ListView.hpp index 6af51d0b..ca561ff6 100644 --- a/loader/include/Geode/ui/ListView.hpp +++ b/loader/include/Geode/ui/ListView.hpp @@ -1,6 +1,7 @@ #pragma once -#include +#include +#include namespace geode { class GEODE_DLL GenericListCell : public TableViewCell { diff --git a/loader/include/Geode/ui/MDTextArea.hpp b/loader/include/Geode/ui/MDTextArea.hpp index 1b7b466e..3c781ed6 100644 --- a/loader/include/Geode/ui/MDTextArea.hpp +++ b/loader/include/Geode/ui/MDTextArea.hpp @@ -1,10 +1,11 @@ #pragma once -#include +#include #include "TextRenderer.hpp" #include "ScrollLayer.hpp" struct MDParser; +class CCScrollLayerExt; namespace geode { /** diff --git a/loader/include/Geode/ui/Notification.hpp b/loader/include/Geode/ui/Notification.hpp index ee50a235..0c9baf08 100644 --- a/loader/include/Geode/ui/Notification.hpp +++ b/loader/include/Geode/ui/Notification.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include "SceneManager.hpp" #include #include "../utils/Ref.hpp" diff --git a/loader/include/Geode/ui/Popup.hpp b/loader/include/Geode/ui/Popup.hpp index ba3f7216..7f93271c 100644 --- a/loader/include/Geode/ui/Popup.hpp +++ b/loader/include/Geode/ui/Popup.hpp @@ -1,6 +1,7 @@ #pragma once -#include +#include +#include namespace geode { template diff --git a/loader/include/Geode/ui/SceneManager.hpp b/loader/include/Geode/ui/SceneManager.hpp index f13c0c65..899562f4 100644 --- a/loader/include/Geode/ui/SceneManager.hpp +++ b/loader/include/Geode/ui/SceneManager.hpp @@ -1,6 +1,9 @@ #pragma once -#include +namespace cocos2d { + class CCArray; + class CCNode; +} namespace geode { class GEODE_DLL SceneManager { diff --git a/loader/include/Geode/ui/ScrollLayer.hpp b/loader/include/Geode/ui/ScrollLayer.hpp index 7562be00..29d73495 100644 --- a/loader/include/Geode/ui/ScrollLayer.hpp +++ b/loader/include/Geode/ui/ScrollLayer.hpp @@ -1,6 +1,7 @@ #pragma once -#include +#include +#include namespace geode { /** diff --git a/loader/include/Geode/ui/Scrollbar.hpp b/loader/include/Geode/ui/Scrollbar.hpp index 3eefc0a5..d4f23a4b 100644 --- a/loader/include/Geode/ui/Scrollbar.hpp +++ b/loader/include/Geode/ui/Scrollbar.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace geode { class GEODE_DLL Scrollbar : public cocos2d::CCLayer { diff --git a/loader/include/Geode/ui/SelectList.hpp b/loader/include/Geode/ui/SelectList.hpp index 99ff389a..0cdd0865 100644 --- a/loader/include/Geode/ui/SelectList.hpp +++ b/loader/include/Geode/ui/SelectList.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace geode { diff --git a/loader/include/Geode/ui/TextRenderer.hpp b/loader/include/Geode/ui/TextRenderer.hpp index ab153a26..1d9133db 100644 --- a/loader/include/Geode/ui/TextRenderer.hpp +++ b/loader/include/Geode/ui/TextRenderer.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace geode { enum class TextAlignment { diff --git a/loader/include/Geode/utils/cocos.hpp b/loader/include/Geode/utils/cocos.hpp index ed36a5d8..ea6bb60f 100644 --- a/loader/include/Geode/utils/cocos.hpp +++ b/loader/include/Geode/utils/cocos.hpp @@ -247,14 +247,20 @@ namespace geode::cocos { } }; +} + +namespace std { template - struct std::iterator_traits> { + struct iterator_traits> { using difference_type = ptrdiff_t; using value_type = T; using pointer = T*; using reference = T&; using iterator_category = std::random_access_iterator_tag; // its random access but im too lazy to implement it }; +} + +namespace geode::cocos { struct GEODE_DLL CCArrayInserter { public: diff --git a/loader/include/Geode/utils/operators.hpp b/loader/include/Geode/utils/operators.hpp index c22341fc..63492330 100644 --- a/loader/include/Geode/utils/operators.hpp +++ b/loader/include/Geode/utils/operators.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace geode { static cocos2d::CCPoint& operator*=(cocos2d::CCPoint & pos, float mul) { diff --git a/loader/src/hooks/GeodeNodeMetadata.cpp b/loader/src/hooks/GeodeNodeMetadata.cpp index c7e44039..e756bc74 100644 --- a/loader/src/hooks/GeodeNodeMetadata.cpp +++ b/loader/src/hooks/GeodeNodeMetadata.cpp @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include USE_GEODE_NAMESPACE(); @@ -83,7 +83,7 @@ void CCNode::setID(std::string const& id) { } CCNode* CCNode::getChildByID(std::string const& id) { - CCARRAY_FOREACH_B_TYPE(m_pChildren, child, CCNode) { + for (auto child : CCArrayExt(m_pChildren)) { if (child->getID() == id) { return child; } @@ -95,7 +95,7 @@ CCNode* CCNode::getChildByIDRecursive(std::string const& id) { if (auto child = this->getChildByID(id)) { return child; } - CCARRAY_FOREACH_B_TYPE(m_pChildren, child, CCNode) { + for (auto child : CCArrayExt(m_pChildren)) { if ((child = child->getChildByIDRecursive(id))) { return child; } diff --git a/loader/src/hooks/MenuLayer.cpp b/loader/src/hooks/MenuLayer.cpp index 0d4e462f..6e00ee34 100644 --- a/loader/src/hooks/MenuLayer.cpp +++ b/loader/src/hooks/MenuLayer.cpp @@ -228,7 +228,7 @@ class $modify(CustomMenuLayer, MenuLayer) { bottomMenu->alignItemsHorizontallyWithPadding(3.f); - CCARRAY_FOREACH_B_TYPE(bottomMenu->getChildren(), node, CCNode) { + for (auto node : CCArrayExt(bottomMenu->getChildren())) { node->setPositionY(y); } if (chest) { diff --git a/loader/src/hooks/dictionary_fixes.cpp b/loader/src/hooks/dictionary_fixes.cpp index 9cb07694..519256db 100644 --- a/loader/src/hooks/dictionary_fixes.cpp +++ b/loader/src/hooks/dictionary_fixes.cpp @@ -1,4 +1,3 @@ -// #include // // this is the fix for the dynamic_cast problems // USE_GEODE_NAMESPACE(); diff --git a/loader/src/index/Index.cpp b/loader/src/index/Index.cpp index 58c8e520..79665c47 100644 --- a/loader/src/index/Index.cpp +++ b/loader/src/index/Index.cpp @@ -3,6 +3,9 @@ #include #include #include +#include +#include +#include #define GITHUB_DONT_RATE_LIMIT_ME_PLS 0 diff --git a/loader/src/index/Index.hpp b/loader/src/index/Index.hpp index e15755d5..d05bee7d 100644 --- a/loader/src/index/Index.hpp +++ b/loader/src/index/Index.hpp @@ -1,6 +1,5 @@ #pragma once -#include #include #include diff --git a/loader/src/index/InstallTicket.cpp b/loader/src/index/InstallTicket.cpp index 4a0cb98a..3ea0f15a 100644 --- a/loader/src/index/InstallTicket.cpp +++ b/loader/src/index/InstallTicket.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include void InstallTicket::postProgress( UpdateStatus status, diff --git a/loader/src/internal/InternalLoader.cpp b/loader/src/internal/InternalLoader.cpp index f8b6518a..f3094428 100644 --- a/loader/src/internal/InternalLoader.cpp +++ b/loader/src/internal/InternalLoader.cpp @@ -6,7 +6,6 @@ #include "InternalMod.hpp" #include #include -#include #include #include diff --git a/loader/src/internal/windows/crashlog.cpp b/loader/src/internal/windows/crashlog.cpp index 6a3c1a65..db128c99 100644 --- a/loader/src/internal/windows/crashlog.cpp +++ b/loader/src/internal/windows/crashlog.cpp @@ -4,8 +4,6 @@ #ifdef GEODE_IS_WINDOWS -#include - #include "../crashlog.hpp" #include #include diff --git a/loader/src/load/Loader.cpp b/loader/src/load/Loader.cpp index 683f7182..50169587 100644 --- a/loader/src/load/Loader.cpp +++ b/loader/src/load/Loader.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include diff --git a/loader/src/load/Log.cpp b/loader/src/load/Log.cpp index f917b6bb..81e81af8 100644 --- a/loader/src/load/Log.cpp +++ b/loader/src/load/Log.cpp @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/loader/src/load/ios/Mod.mm b/loader/src/load/ios/Mod.mm index 70e8b19e..6f6d25e6 100644 --- a/loader/src/load/ios/Mod.mm +++ b/loader/src/load/ios/Mod.mm @@ -2,7 +2,7 @@ #ifdef GEODE_IS_IOS -#include +#include #include USE_GEODE_NAMESPACE(); diff --git a/loader/src/load/windows/Mod.cpp b/loader/src/load/windows/Mod.cpp index 9fea54d6..3f8c1cd1 100644 --- a/loader/src/load/windows/Mod.cpp +++ b/loader/src/load/windows/Mod.cpp @@ -2,7 +2,7 @@ #ifdef GEODE_IS_WINDOWS -#include +#include USE_GEODE_NAMESPACE(); template diff --git a/loader/src/ui/internal/list/ModListView.cpp b/loader/src/ui/internal/list/ModListView.cpp index 72400e74..42b57d72 100644 --- a/loader/src/ui/internal/list/ModListView.cpp +++ b/loader/src/ui/internal/list/ModListView.cpp @@ -384,7 +384,7 @@ ModCell* ModCell::create(ModListView* list, bool expanded, const char* key, CCSi void ModListView::updateAllStates(ModCell* toggled) { - CCARRAY_FOREACH_B_TYPE(m_tableView->m_cellArray, cell, ModCell) { + for (auto cell : CCArrayExt(m_tableView->m_cellArray)) { cell->updateState(toggled == cell); } } diff --git a/loader/src/ui/internal/settings/GeodeSettingNode.cpp b/loader/src/ui/internal/settings/GeodeSettingNode.cpp index aa1cef87..e321c730 100644 --- a/loader/src/ui/internal/settings/GeodeSettingNode.cpp +++ b/loader/src/ui/internal/settings/GeodeSettingNode.cpp @@ -1,5 +1,9 @@ #include "GeodeSettingNode.hpp" #include +#include +#include +#include +#include // BoolSettingNode diff --git a/loader/src/ui/internal/settings/GeodeSettingNode.hpp b/loader/src/ui/internal/settings/GeodeSettingNode.hpp index 19cd2ae2..48da2f75 100644 --- a/loader/src/ui/internal/settings/GeodeSettingNode.hpp +++ b/loader/src/ui/internal/settings/GeodeSettingNode.hpp @@ -2,7 +2,10 @@ #include #include -#include +#include +#include +#include +#include #include #include #include @@ -297,7 +300,7 @@ namespace { decArrowSpr->setScale(.3f); m_decArrow = CCMenuItemSpriteExtra::create( - decArrowSpr, self(), menu_selector(ImplArrows::onDecrement) + decArrowSpr, self(), menu_selector(ImplArrows::Callbacks::onDecrement) ); m_decArrow->setPosition(-width / 2 + 80.f, yPos); self()->m_menu->addChild(m_decArrow); @@ -306,7 +309,7 @@ namespace { incArrowSpr->setScale(.3f); m_incArrow = CCMenuItemSpriteExtra::create( - incArrowSpr, self(), menu_selector(ImplArrows::onIncrement) + incArrowSpr, self(), menu_selector(ImplArrows::Callbacks::onIncrement) ); m_incArrow->setPosition(-10.f, yPos); self()->m_menu->addChild(m_incArrow); @@ -318,7 +321,7 @@ namespace { decArrowSpr->setScale(.3f); m_bigDecArrow = CCMenuItemSpriteExtra::create( - decArrowSpr, self(), menu_selector(ImplArrows::onBigDecrement) + decArrowSpr, self(), menu_selector(ImplArrows::Callbacks::onBigDecrement) ); m_bigDecArrow->setPosition(-width / 2 + 65.f, yPos); self()->m_menu->addChild(m_bigDecArrow); @@ -327,50 +330,46 @@ namespace { incArrowSpr->setScale(.3f); m_bigIncArrow = CCMenuItemSpriteExtra::create( - incArrowSpr, self(), menu_selector(ImplArrows::onBigIncrement) + incArrowSpr, self(), menu_selector(ImplArrows::Callbacks::onBigIncrement) ); m_bigIncArrow->setPosition(5.f, yPos); self()->m_menu->addChild(m_bigIncArrow); } } - void onIncrement(CCObject*) { - // intentionally refcast to prevent warnings on clang and - // not to offset this as it has already been offset to the - // correct vtable when it's passed to CCMenuItemSpriteExtra - auto self = reference_cast(this); - self->m_uncommittedValue += std::static_pointer_cast( - self->m_setting - )->getArrowStepSize(); - self->valueChanged(true); - } + // intentionally a subclass to make it relatively safe to + // use as callbacks for the child class, since we give the + // child class as the target to CCMenuItemSpriteExtra + struct Callbacks : public C { + void onIncrement(CCObject*) { + this->m_uncommittedValue += std::static_pointer_cast( + this->m_setting + )->getArrowStepSize(); + this->valueChanged(true); + } - void onDecrement(CCObject*) { - // intentional, see ImplArrows::onIncrement - auto self = reference_cast(this); - self->m_uncommittedValue -= std::static_pointer_cast( - self->m_setting - )->getArrowStepSize(); - self->valueChanged(true); - } + void onDecrement(CCObject*) { + this->m_uncommittedValue -= std::static_pointer_cast( + this->m_setting + )->getArrowStepSize(); + this->valueChanged(true); + } - void onBigIncrement(CCObject*) { - // intentional, see ImplArrows::onIncrement - auto self = reference_cast(this); - self->m_uncommittedValue += std::static_pointer_cast( - self->m_setting - )->getBigArrowStepSize(); - self->valueChanged(true); - } + void onBigIncrement(CCObject*) { + this->m_uncommittedValue += std::static_pointer_cast( + this->m_setting + )->getBigArrowStepSize(); + this->valueChanged(true); + } + + void onBigDecrement(CCObject*) { + this->m_uncommittedValue -= std::static_pointer_cast( + this->m_setting + )->getBigArrowStepSize(); + this->valueChanged(true); + } + }; - void onBigDecrement(CCObject*) { - // intentional, see ImplArrows::onIncrement - auto self = reference_cast(this); - self->m_uncommittedValue -= std::static_pointer_cast( - self->m_setting - )->getBigArrowStepSize(); - self->valueChanged(true); - } }; template @@ -413,7 +412,7 @@ namespace { void setupSlider(std::shared_ptr setting, float width) { if (setting->hasSlider()) { m_slider = Slider::create( - self(), menu_selector(ImplSlider::onSlider), .5f + self(), menu_selector(ImplSlider::Callbacks::onSlider), .5f ); m_slider->setPosition(-50.f, -15.f); self()->m_menu->addChild(m_slider); @@ -432,17 +431,21 @@ namespace { } } - void onSlider(CCObject* slider) { - // intentional, see ImplArrows::onIncrement - auto self = reference_cast(this); - auto setting = std::static_pointer_cast(self->m_setting); + // intentionally a subclass to make it relatively safe to + // use as callbacks for the child class, since we give the + // child class as the target to CCMenuItemSpriteExtra + struct Callbacks : public C { + void onSlider(CCObject* slider) { + auto setting = std::static_pointer_cast(this->m_setting); - self->m_uncommittedValue = valueFromSlider( - setting, - static_cast(slider)->getValue() - ); - self->valueChanged(true); - } + this->m_uncommittedValue = valueFromSlider( + setting, + static_cast(slider)->getValue() + ); + this->valueChanged(true); + + } + }; }; } diff --git a/loader/src/ui/internal/settings/ModSettingsPopup.cpp b/loader/src/ui/internal/settings/ModSettingsPopup.cpp index f5d3f7c7..221ca0b3 100644 --- a/loader/src/ui/internal/settings/ModSettingsPopup.cpp +++ b/loader/src/ui/internal/settings/ModSettingsPopup.cpp @@ -3,6 +3,7 @@ #include #include #include +#include bool ModSettingsPopup::setup(Mod* mod) { m_noElasticity = true; diff --git a/loader/src/ui/nodes/ColorPickPopup.cpp b/loader/src/ui/nodes/ColorPickPopup.cpp index 7dda2d48..5e53ed1d 100644 --- a/loader/src/ui/nodes/ColorPickPopup.cpp +++ b/loader/src/ui/nodes/ColorPickPopup.cpp @@ -1,5 +1,9 @@ #include #include +#include +#include +#include +#include USE_GEODE_NAMESPACE(); diff --git a/loader/src/ui/nodes/IconButtonSprite.cpp b/loader/src/ui/nodes/IconButtonSprite.cpp index 5ab69616..a8cb2909 100644 --- a/loader/src/ui/nodes/IconButtonSprite.cpp +++ b/loader/src/ui/nodes/IconButtonSprite.cpp @@ -1,5 +1,5 @@ #include -#include +#include USE_GEODE_NAMESPACE(); diff --git a/loader/src/ui/nodes/InputNode.cpp b/loader/src/ui/nodes/InputNode.cpp index 3ca25134..20f741e5 100644 --- a/loader/src/ui/nodes/InputNode.cpp +++ b/loader/src/ui/nodes/InputNode.cpp @@ -1,4 +1,5 @@ #include +#include USE_GEODE_NAMESPACE(); diff --git a/loader/src/ui/nodes/ListView.cpp b/loader/src/ui/nodes/ListView.cpp index 1438e9ed..67b50b9d 100644 --- a/loader/src/ui/nodes/ListView.cpp +++ b/loader/src/ui/nodes/ListView.cpp @@ -1,5 +1,8 @@ #include -#include +#include +#include +#include +#include USE_GEODE_NAMESPACE(); diff --git a/loader/src/ui/nodes/MDPopup.cpp b/loader/src/ui/nodes/MDPopup.cpp index f905b8d9..fb6f9954 100644 --- a/loader/src/ui/nodes/MDPopup.cpp +++ b/loader/src/ui/nodes/MDPopup.cpp @@ -1,5 +1,6 @@ #include #include +#include USE_GEODE_NAMESPACE(); diff --git a/loader/src/ui/nodes/MDTextArea.cpp b/loader/src/ui/nodes/MDTextArea.cpp index 46731d9d..552389f5 100644 --- a/loader/src/ui/nodes/MDTextArea.cpp +++ b/loader/src/ui/nodes/MDTextArea.cpp @@ -1,7 +1,10 @@ #include -#include #include -#include +#include +#include +#include +#include +#include USE_GEODE_NAMESPACE(); @@ -53,7 +56,7 @@ public: // so that's why based MDContentLayer expects itself // to have a CCMenu :-) if (m_content) { - CCARRAY_FOREACH_B_TYPE(m_content->getChildren(), child, CCNode) { + for (auto child : CCArrayExt(m_content->getChildren())) { auto y = this->getPositionY() + child->getPositionY(); child->setVisible(!( (m_content->getContentSize().height < y) || diff --git a/loader/src/ui/nodes/Notification.cpp b/loader/src/ui/nodes/Notification.cpp index 313bc11c..44622ea4 100644 --- a/loader/src/ui/nodes/Notification.cpp +++ b/loader/src/ui/nodes/Notification.cpp @@ -1,7 +1,8 @@ #include #include -#include -#include +#include +#include +#include USE_GEODE_NAMESPACE(); @@ -220,7 +221,7 @@ bool Notification::init( m_obContentSize.width += iconSpace; m_icon->setPositionX(m_icon->getPositionX() - iconSpace / 2); m_title->setPositionX(m_title->getPositionX() - iconSpace / 2); - CCARRAY_FOREACH_B_TYPE(m_labels, label, CCNode) { + for (auto label : CCArrayExt(m_labels)) { label->setPosition( label->getPositionX() + iconSpace - m_obContentSize.width / 2, label->getPositionY() - m_obContentSize.height / 2 + 2.f diff --git a/loader/src/ui/nodes/SceneManager.cpp b/loader/src/ui/nodes/SceneManager.cpp index 91b746e0..4f7311b4 100644 --- a/loader/src/ui/nodes/SceneManager.cpp +++ b/loader/src/ui/nodes/SceneManager.cpp @@ -1,5 +1,5 @@ #include -#include +#include USE_GEODE_NAMESPACE(); @@ -31,7 +31,7 @@ void SceneManager::forget(CCNode* node) { } void SceneManager::willSwitchToScene(CCScene* scene) { - CCARRAY_FOREACH_B_TYPE(m_persistedNodes, node, CCNode) { + for (auto node : CCArrayExt(m_persistedNodes)) { // no cleanup in order to keep actions running node->removeFromParentAndCleanup(false); scene->addChild(node); diff --git a/loader/src/ui/nodes/ScrollLayer.cpp b/loader/src/ui/nodes/ScrollLayer.cpp index 0cd1c6ac..0a782c74 100644 --- a/loader/src/ui/nodes/ScrollLayer.cpp +++ b/loader/src/ui/nodes/ScrollLayer.cpp @@ -1,5 +1,5 @@ #include -#include +#include USE_GEODE_NAMESPACE(); @@ -18,7 +18,7 @@ void GenericContentLayer::setPosition(CCPoint const& pos) { // all be TableViewCells CCLayerColor::setPosition(pos); - CCARRAY_FOREACH_B_TYPE(m_pChildren, child, CCNode) { + for (auto child : CCArrayExt(m_pChildren)) { auto y = this->getPositionY() + child->getPositionY(); child->setVisible(!( (m_obContentSize.height < y) || diff --git a/loader/src/ui/nodes/Scrollbar.cpp b/loader/src/ui/nodes/Scrollbar.cpp index 16b55f28..75927f9c 100644 --- a/loader/src/ui/nodes/Scrollbar.cpp +++ b/loader/src/ui/nodes/Scrollbar.cpp @@ -1,5 +1,6 @@ #include -#include +#include +#include // TODO: die #undef min diff --git a/loader/src/ui/nodes/TextRenderer.cpp b/loader/src/ui/nodes/TextRenderer.cpp index cc0b439e..aa984c28 100644 --- a/loader/src/ui/nodes/TextRenderer.cpp +++ b/loader/src/ui/nodes/TextRenderer.cpp @@ -1,6 +1,8 @@ #include -#include -#include +#include +#include +#include +#include #undef max #undef min @@ -279,7 +281,7 @@ CCNode* TextRenderer::end( padY = std::max(m_size.height - renderedHeight, 0.f); break; } // adjust child positions - CCARRAY_FOREACH_B_TYPE(m_target->getChildren(), child, CCNode) { + for (auto child : CCArrayExt(m_target->getChildren())) { child->setPosition( child->getPositionX() + padX, child->getPositionY() + diff --git a/loader/src/utils/cocos.cpp b/loader/src/utils/cocos.cpp index 37caad3d..2751a052 100644 --- a/loader/src/utils/cocos.cpp +++ b/loader/src/utils/cocos.cpp @@ -27,7 +27,7 @@ CCRect geode::cocos::calculateNodeCoverage(std::vector const& nodes) { CCRect geode::cocos::calculateNodeCoverage(CCArray* nodes) { CCRect coverage; - CCARRAY_FOREACH_B_TYPE(nodes, child, CCNode) { + for (auto child : CCArrayExt(nodes)) { auto pos = child->getPosition() - child->getScaledContentSize() * child->getAnchorPoint(); auto csize = child->getPosition() + child->getScaledContentSize() * (CCPoint { 1.f, 1.f } - child->getAnchorPoint()); if (pos.x < coverage.origin.x) { diff --git a/loader/src/utils/file.cpp b/loader/src/utils/file.cpp index 986a42b2..91226100 100644 --- a/loader/src/utils/file.cpp +++ b/loader/src/utils/file.cpp @@ -1,7 +1,6 @@ #include #include #include -#include USE_GEODE_NAMESPACE();