mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-21 10:38:27 -05:00
some formatting
This commit is contained in:
parent
a776b167a9
commit
e8fcb57c9f
11 changed files with 188 additions and 143 deletions
|
@ -3,6 +3,7 @@ IndentWidth: 4
|
||||||
|
|
||||||
AlignAfterOpenBracket: BlockIndent
|
AlignAfterOpenBracket: BlockIndent
|
||||||
AlignEscapedNewlines: Left
|
AlignEscapedNewlines: Left
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
AlignOperands: DontAlign
|
AlignOperands: DontAlign
|
||||||
AlignTrailingComments: false
|
AlignTrailingComments: false
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ AlwaysBreakAfterReturnType: None
|
||||||
AlwaysBreakBeforeMultilineStrings: true
|
AlwaysBreakBeforeMultilineStrings: true
|
||||||
AlwaysBreakTemplateDeclarations: Yes
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
|
||||||
BinPackArguments: true
|
BinPackArguments: false
|
||||||
BinPackParameters: true
|
BinPackParameters: true
|
||||||
|
|
||||||
BraceWrapping:
|
BraceWrapping:
|
||||||
|
@ -49,7 +50,7 @@ BraceWrapping:
|
||||||
BreakBeforeBinaryOperators: None
|
BreakBeforeBinaryOperators: None
|
||||||
BreakBeforeBraces: Custom
|
BreakBeforeBraces: Custom
|
||||||
BreakBeforeConceptDeclarations: true
|
BreakBeforeConceptDeclarations: true
|
||||||
BreakBeforeTernaryOperators: true
|
BreakBeforeTernaryOperators: false
|
||||||
BreakConstructorInitializers: AfterColon
|
BreakConstructorInitializers: AfterColon
|
||||||
BreakInheritanceList: AfterColon
|
BreakInheritanceList: AfterColon
|
||||||
BreakStringLiterals: true
|
BreakStringLiterals: true
|
||||||
|
@ -57,7 +58,7 @@ ColumnLimit: 100
|
||||||
CompactNamespaces: false
|
CompactNamespaces: false
|
||||||
ConstructorInitializerIndentWidth: 4
|
ConstructorInitializerIndentWidth: 4
|
||||||
ContinuationIndentWidth: 4
|
ContinuationIndentWidth: 4
|
||||||
Cpp11BracedListStyle: false
|
Cpp11BracedListStyle: true
|
||||||
|
|
||||||
DeriveLineEnding: false
|
DeriveLineEnding: false
|
||||||
UseCRLF: false
|
UseCRLF: false
|
||||||
|
@ -103,7 +104,7 @@ PenaltyBreakFirstLessLess: 120
|
||||||
PenaltyBreakString: 1000
|
PenaltyBreakString: 1000
|
||||||
PenaltyBreakOpenParenthesis: 0
|
PenaltyBreakOpenParenthesis: 0
|
||||||
PenaltyBreakTemplateDeclaration: 10
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
PenaltyExcessCharacter: 1000000
|
PenaltyExcessCharacter: 10
|
||||||
PenaltyReturnTypeOnItsOwnLine: 1000000
|
PenaltyReturnTypeOnItsOwnLine: 1000000
|
||||||
PenaltyIndentedWhitespace: 0
|
PenaltyIndentedWhitespace: 0
|
||||||
|
|
||||||
|
@ -122,7 +123,7 @@ SpaceAfterTemplateKeyword: true
|
||||||
SpaceAroundPointerQualifiers: Default
|
SpaceAroundPointerQualifiers: Default
|
||||||
SpaceBeforeAssignmentOperators: true
|
SpaceBeforeAssignmentOperators: true
|
||||||
SpaceBeforeCaseColon: false
|
SpaceBeforeCaseColon: false
|
||||||
SpaceBeforeCpp11BracedList: true
|
SpaceBeforeCpp11BracedList: false
|
||||||
SpaceBeforeCtorInitializerColon: true
|
SpaceBeforeCtorInitializerColon: true
|
||||||
SpaceBeforeInheritanceColon: true
|
SpaceBeforeInheritanceColon: true
|
||||||
SpaceBeforeParens: ControlStatements
|
SpaceBeforeParens: ControlStatements
|
||||||
|
|
|
@ -75,39 +75,115 @@ namespace cocos2d::extension {}
|
||||||
} \
|
} \
|
||||||
Class_(std::monostate, void*)
|
Class_(std::monostate, void*)
|
||||||
|
|
||||||
#define GEODE_MONOSTATE_CONSTRUCTOR_BEGIN(Class_) \
|
#define GEODE_MONOSTATE_CONSTRUCTOR_BEGIN(Class_) \
|
||||||
GEODE_MACOS(GEODE_FILL_CONSTRUCTOR(Class_, 0) {}) \
|
GEODE_MACOS(GEODE_FILL_CONSTRUCTOR(Class_, 0){}) \
|
||||||
GEODE_IOS(GEODE_FILL_CONSTRUCTOR(Class_, 0) {})
|
GEODE_IOS(GEODE_FILL_CONSTRUCTOR(Class_, 0){})
|
||||||
|
|
||||||
#define GEODE_MONOSTATE_CONSTRUCTOR_COCOS(Class_, Base_) \
|
#define GEODE_MONOSTATE_CONSTRUCTOR_COCOS(Class_, Base_) \
|
||||||
GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill) {}) \
|
GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) \
|
||||||
GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill) {})
|
GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill){})
|
||||||
|
|
||||||
#define GEODE_MONOSTATE_CONSTRUCTOR_GD(Class_, Base_) \
|
#define GEODE_MONOSTATE_CONSTRUCTOR_GD(Class_, Base_) \
|
||||||
GEODE_WINDOWS(Class_(std::monostate, size_t fill) : Base_({}, fill) {}) \
|
GEODE_WINDOWS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) \
|
||||||
GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill) {}) \
|
GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) \
|
||||||
GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill) {})
|
GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill){})
|
||||||
|
|
||||||
#define GEODE_MONOSTATE_CONSTRUCTOR_CUTOFF(Class_, Base_) \
|
#define GEODE_MONOSTATE_CONSTRUCTOR_CUTOFF(Class_, Base_) \
|
||||||
GEODE_WINDOWS(GEODE_FILL_CONSTRUCTOR(Class_, sizeof(Base_)) : Base_() {}) \
|
GEODE_WINDOWS(GEODE_FILL_CONSTRUCTOR(Class_, sizeof(Base_)) : Base_(){}) \
|
||||||
GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill) {}) \
|
GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) \
|
||||||
GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill) {})
|
GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill){})
|
||||||
|
|
||||||
#define GEODE_NUMBER_OF_ARGS(...) \
|
#define GEODE_NUMBER_OF_ARGS(...) \
|
||||||
GEODE_EXPAND(GEODE_NUMBER_OF_ARGS_(__VA_ARGS__, GEODE_NUMBER_SEQUENCE(), ))
|
GEODE_EXPAND(GEODE_NUMBER_OF_ARGS_(__VA_ARGS__, GEODE_NUMBER_SEQUENCE(), ))
|
||||||
#define GEODE_NUMBER_OF_ARGS_(...) GEODE_EXPAND(GEODE_NUMBER_OF_ARGS_N(__VA_ARGS__))
|
#define GEODE_NUMBER_OF_ARGS_(...) GEODE_EXPAND(GEODE_NUMBER_OF_ARGS_N(__VA_ARGS__))
|
||||||
#define GEODE_NUMBER_OF_ARGS_N( \
|
#define GEODE_NUMBER_OF_ARGS_N( \
|
||||||
_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \
|
_1, \
|
||||||
_21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, \
|
_2, \
|
||||||
_40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, \
|
_3, \
|
||||||
_59, _60, _61, _62, _63, N, ... \
|
_4, \
|
||||||
) \
|
_5, \
|
||||||
|
_6, \
|
||||||
|
_7, \
|
||||||
|
_8, \
|
||||||
|
_9, \
|
||||||
|
_10, \
|
||||||
|
_11, \
|
||||||
|
_12, \
|
||||||
|
_13, \
|
||||||
|
_14, \
|
||||||
|
_15, \
|
||||||
|
_16, \
|
||||||
|
_17, \
|
||||||
|
_18, \
|
||||||
|
_19, \
|
||||||
|
_20, \
|
||||||
|
_21, \
|
||||||
|
_22, \
|
||||||
|
_23, \
|
||||||
|
_24, \
|
||||||
|
_25, \
|
||||||
|
_26, \
|
||||||
|
_27, \
|
||||||
|
_28, \
|
||||||
|
_29, \
|
||||||
|
_30, \
|
||||||
|
_31, \
|
||||||
|
_32, \
|
||||||
|
_33, \
|
||||||
|
_34, \
|
||||||
|
_35, \
|
||||||
|
_36, \
|
||||||
|
_37, \
|
||||||
|
_38, \
|
||||||
|
_39, \
|
||||||
|
_40, \
|
||||||
|
_41, \
|
||||||
|
_42, \
|
||||||
|
_43, \
|
||||||
|
_44, \
|
||||||
|
_45, \
|
||||||
|
_46, \
|
||||||
|
_47, \
|
||||||
|
_48, \
|
||||||
|
_49, \
|
||||||
|
_50, \
|
||||||
|
_51, \
|
||||||
|
_52, \
|
||||||
|
_53, \
|
||||||
|
_54, \
|
||||||
|
_55, \
|
||||||
|
_56, \
|
||||||
|
_57, \
|
||||||
|
_58, \
|
||||||
|
_59, \
|
||||||
|
_60, \
|
||||||
|
_61, \
|
||||||
|
_62, \
|
||||||
|
_63, \
|
||||||
|
N, \
|
||||||
|
... \
|
||||||
|
) \
|
||||||
N
|
N
|
||||||
#define GEODE_NUMBER_SEQUENCE() \
|
#define GEODE_NUMBER_SEQUENCE() \
|
||||||
63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, \
|
63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, \
|
||||||
40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, \
|
40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, \
|
||||||
18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
|
18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
|
||||||
|
|
||||||
|
#define $execute \
|
||||||
|
template <class> \
|
||||||
|
void GEODE_CONCAT(geodeExecFunction, __LINE__)(); \
|
||||||
|
namespace { \
|
||||||
|
struct GEODE_CONCAT(ExecFuncUnique, __LINE__) {}; \
|
||||||
|
} \
|
||||||
|
static inline auto GEODE_CONCAT(Exec, __LINE__) = \
|
||||||
|
(Loader::get()->scheduleOnModLoad( \
|
||||||
|
nullptr, \
|
||||||
|
&GEODE_CONCAT(geodeExecFunction, __LINE__) < GEODE_CONCAT(ExecFuncUnique, __LINE__) > \
|
||||||
|
), \
|
||||||
|
0); \
|
||||||
|
template <class> \
|
||||||
|
void GEODE_CONCAT(geodeExecFunction, __LINE__)()
|
||||||
|
|
||||||
// #define GEODE_NEST1(macro, begin) \
|
// #define GEODE_NEST1(macro, begin) \
|
||||||
// macro(GEODE_CONCAT(begin, 0)), \
|
// macro(GEODE_CONCAT(begin, 0)), \
|
||||||
// macro(GEODE_CONCAT(begin, 1)), \
|
// macro(GEODE_CONCAT(begin, 1)), \
|
||||||
|
|
|
@ -55,21 +55,3 @@
|
||||||
* Useful for callbacks
|
* Useful for callbacks
|
||||||
*/
|
*/
|
||||||
#define $cls std::remove_pointer<decltype(this)>::type
|
#define $cls std::remove_pointer<decltype(this)>::type
|
||||||
|
|
||||||
#define GEODE_ONLY_FIELD(type, field_, default_) private: field<type> field_ = default_; public:
|
|
||||||
#define GEODE_INTERNAL_FIELD(type, field, name) inline type& name() { return this->*field; }
|
|
||||||
//#define GEODE_EXTERNAL_FIELD(type, field, name) static inline type& name##From(void* self) { return reinterpret_cast<decltype(this)>(self)->*field; }
|
|
||||||
#define GEODE_FIELD(type, field, name, default_) GEODE_ONLY_FIELD(type, field, default_) GEODE_INTERNAL_FIELD(type, field, name) //GEODE_EXTERNAL_FIELD(type, field, name)
|
|
||||||
|
|
||||||
|
|
||||||
#define $execute \
|
|
||||||
template<class> \
|
|
||||||
void GEODE_CONCAT(geodeExecFunction, __LINE__)(); \
|
|
||||||
namespace { \
|
|
||||||
struct GEODE_CONCAT(ExecFuncUnique, __LINE__) {}; \
|
|
||||||
} \
|
|
||||||
static inline auto GEODE_CONCAT(Exec, __LINE__) = (Loader::get()->scheduleOnModLoad(\
|
|
||||||
nullptr, &GEODE_CONCAT(geodeExecFunction, __LINE__)<GEODE_CONCAT(ExecFuncUnique, __LINE__)> \
|
|
||||||
), 0); \
|
|
||||||
template<class> \
|
|
||||||
void GEODE_CONCAT(geodeExecFunction, __LINE__)()
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Version 1.1, February 14h, 2010
|
Version 1.1, February 14h, 2010
|
||||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
|
|
||||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
Copyright (C) 1998-2010 Gilles Vollant (minizip) (
|
||||||
|
http://www.winimage.com/zLibDll/minizip.html )
|
||||||
|
|
||||||
Modifications for Zip64 support
|
Modifications for Zip64 support
|
||||||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||||
|
@ -12,15 +13,17 @@
|
||||||
Changes
|
Changes
|
||||||
Oct-2009 - Mathias Svensson - Remove old C style function prototypes
|
Oct-2009 - Mathias Svensson - Remove old C style function prototypes
|
||||||
Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives
|
Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives
|
||||||
Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions.
|
Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of
|
||||||
Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data
|
some functions. Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field
|
||||||
It is used when recreting zip archive with RAW when deleting items from a zip.
|
data from its ZIP64 data It is used when recreting zip archive with RAW when deleting items from
|
||||||
ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed.
|
a zip. ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to
|
||||||
Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required)
|
be removed. Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib
|
||||||
Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
|
is required) Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
|
||||||
#ifndef NOCRYPT
|
#ifndef NOCRYPT
|
||||||
#define NOCRYPT
|
#define NOCRYPT
|
||||||
#endif
|
#endif
|
||||||
|
@ -1071,7 +1074,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
|
||||||
int err = ZIP_OK;
|
int err = ZIP_OK;
|
||||||
|
|
||||||
# ifdef NOCRYPT
|
# ifdef NOCRYPT
|
||||||
(crcForCrypting);
|
(void)(crcForCrypting);
|
||||||
if (password != NULL)
|
if (password != NULL)
|
||||||
return ZIP_PARAMERROR;
|
return ZIP_PARAMERROR;
|
||||||
# endif
|
# endif
|
||||||
|
@ -2006,3 +2009,5 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of namespace cocos2d
|
} // end of namespace cocos2d
|
||||||
|
|
||||||
|
// clang-format on
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#include "../core/Core.hpp"
|
#include "../core/Core.hpp"
|
||||||
|
|
||||||
|
#include <Geode/loader/IPC.hpp>
|
||||||
#include <Geode/loader/Loader.hpp>
|
#include <Geode/loader/Loader.hpp>
|
||||||
#include <Geode/loader/Log.hpp>
|
#include <Geode/loader/Log.hpp>
|
||||||
#include <Geode/loader/Mod.hpp>
|
#include <Geode/loader/Mod.hpp>
|
||||||
#include <Geode/loader/SettingEvent.hpp>
|
|
||||||
#include <Geode/loader/Setting.hpp>
|
#include <Geode/loader/Setting.hpp>
|
||||||
#include <Geode/loader/IPC.hpp>
|
#include <Geode/loader/SettingEvent.hpp>
|
||||||
#include <InternalLoader.hpp>
|
#include <InternalLoader.hpp>
|
||||||
#include <InternalMod.hpp>
|
#include <InternalMod.hpp>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
@ -100,55 +100,44 @@ BOOL WINAPI DllMain(HINSTANCE lib, DWORD reason, LPVOID) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define $_ GEODE_CONCAT(unnamedVar_, __LINE__)
|
$execute {
|
||||||
|
listenForSettingChanges<BoolSetting>("show-platform-console", [](BoolSetting* setting) {
|
||||||
static auto $_ = listenForSettingChanges<BoolSetting>(
|
|
||||||
"show-platform-console",
|
|
||||||
[](BoolSetting* setting) {
|
|
||||||
if (setting->getValue()) {
|
if (setting->getValue()) {
|
||||||
Loader::get()->openPlatformConsole();
|
Loader::get()->openPlatformConsole();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Loader::get()->closePlatfromConsole();
|
Loader::get()->closePlatfromConsole();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
listenForIPC("ipc-test", [](IPCEvent* event) -> nlohmann::json {
|
||||||
|
return "Hello from Geode!";
|
||||||
|
});
|
||||||
|
listenForIPC("loader-info", [](IPCEvent* event) -> nlohmann::json {
|
||||||
|
return Loader::get()->getInternalMod()->getModInfo();
|
||||||
|
});
|
||||||
|
|
||||||
static auto $_ = listenForIPC("ipc-test", +[](IPCEvent* event) -> nlohmann::json {
|
listenForIPC("list-mods", [](IPCEvent* event) -> nlohmann::json {
|
||||||
return "Hello from Geode!";
|
std::vector<nlohmann::json> res;
|
||||||
});
|
|
||||||
|
|
||||||
static auto $_ = listenForIPC("loader-info", +[](IPCEvent* event) -> nlohmann::json {
|
auto args = event->getMessageData();
|
||||||
return Loader::get()->getInternalMod()->getModInfo();
|
JsonChecker checker(args);
|
||||||
});
|
auto root = checker.root("").obj();
|
||||||
|
|
||||||
static auto $_ = listenForIPC("list-mods", +[](IPCEvent* event) -> nlohmann::json {
|
auto includeRunTimeInfo = root.has("include-runtime-info").template get<bool>();
|
||||||
std::vector<nlohmann::json> res;
|
auto dontIncludeLoader = root.has("dont-include-loader").template get<bool>();
|
||||||
|
|
||||||
auto args = event->getMessageData();
|
if (!dontIncludeLoader) {
|
||||||
JsonChecker checker(args);
|
auto mod = Loader::get()->getInternalMod();
|
||||||
auto root = checker.root("").obj();
|
res.push_back(includeRunTimeInfo ? mod->getRuntimeInfo() : mod->getModInfo().toJSON());
|
||||||
|
}
|
||||||
|
|
||||||
auto includeRunTimeInfo = root.has("include-runtime-info").template get<bool>();
|
for (auto& mod : Loader::get()->getAllMods()) {
|
||||||
auto dontIncludeLoader = root.has("dont-include-loader").template get<bool>();
|
res.push_back(includeRunTimeInfo ? mod->getRuntimeInfo() : mod->getModInfo().toJSON());
|
||||||
|
}
|
||||||
|
|
||||||
if (!dontIncludeLoader) {
|
return res;
|
||||||
res.push_back(includeRunTimeInfo ?
|
});
|
||||||
Loader::get()->getInternalMod()->getRuntimeInfo() :
|
}
|
||||||
Loader::get()->getInternalMod()->getModInfo().toJSON()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& mod : Loader::get()->getAllMods()) {
|
|
||||||
res.push_back(
|
|
||||||
includeRunTimeInfo ?
|
|
||||||
mod->getRuntimeInfo() :
|
|
||||||
mod->getModInfo().toJSON()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
|
|
||||||
int geodeEntry(void* platformData) {
|
int geodeEntry(void* platformData) {
|
||||||
// setup internals
|
// setup internals
|
||||||
|
|
|
@ -205,14 +205,12 @@ JsonMaybeValue<Json> JsonMaybeValue<Json>::at(size_t i) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
return JsonMaybeValue<Json>(
|
return JsonMaybeValue<Json>(
|
||||||
self().m_checker, self().m_json.at(i), self().m_hierarchy + "." + std::to_string(i),
|
self().m_checker, self().m_json.at(i), self().m_hierarchy + "." + std::to_string(i), self().m_hasValue
|
||||||
self().m_hasValue
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Json>
|
template <class Json>
|
||||||
typename JsonMaybeValue<Json>::template Iterator<JsonMaybeValue<Json>> JsonMaybeValue<
|
typename JsonMaybeValue<Json>::template Iterator<JsonMaybeValue<Json>> JsonMaybeValue<Json>::iterate() {
|
||||||
Json>::iterate() {
|
|
||||||
this->as<value_t::array>();
|
this->as<value_t::array>();
|
||||||
Iterator<JsonMaybeValue<Json>> iter;
|
Iterator<JsonMaybeValue<Json>> iter;
|
||||||
if (this->isError()) return iter;
|
if (this->isError()) return iter;
|
||||||
|
@ -226,8 +224,8 @@ typename JsonMaybeValue<Json>::template Iterator<JsonMaybeValue<Json>> JsonMaybe
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Json>
|
template <class Json>
|
||||||
typename JsonMaybeValue<Json>::template Iterator<std::pair<std::string, JsonMaybeValue<Json>>>
|
typename JsonMaybeValue<Json>::template Iterator<std::pair<std::string, JsonMaybeValue<Json>>> JsonMaybeValue<
|
||||||
JsonMaybeValue<Json>::items() {
|
Json>::items() {
|
||||||
this->as<value_t::object>();
|
this->as<value_t::object>();
|
||||||
Iterator<std::pair<std::string, JsonMaybeValue<Json>>> iter;
|
Iterator<std::pair<std::string, JsonMaybeValue<Json>>> iter;
|
||||||
if (this->isError()) return iter;
|
if (this->isError()) return iter;
|
||||||
|
@ -235,9 +233,7 @@ JsonMaybeValue<Json>::items() {
|
||||||
for (auto& [k, v] : self().m_json.items()) {
|
for (auto& [k, v] : self().m_json.items()) {
|
||||||
iter.m_values.emplace_back(
|
iter.m_values.emplace_back(
|
||||||
k,
|
k,
|
||||||
JsonMaybeValue<Json>(
|
JsonMaybeValue<Json>(self().m_checker, v, self().m_hierarchy + "." + k, self().m_hasValue)
|
||||||
self().m_checker, v, self().m_hierarchy + "." + k, self().m_hasValue
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@
|
||||||
macro(GEODE_CONCAT(begin, 7)), macro(GEODE_CONCAT(begin, 8)), \
|
macro(GEODE_CONCAT(begin, 7)), macro(GEODE_CONCAT(begin, 8)), \
|
||||||
macro(GEODE_CONCAT(begin, 9)), macro(GEODE_CONCAT(begin, a)), \
|
macro(GEODE_CONCAT(begin, 9)), macro(GEODE_CONCAT(begin, a)), \
|
||||||
macro(GEODE_CONCAT(begin, b)), macro(GEODE_CONCAT(begin, c)), \
|
macro(GEODE_CONCAT(begin, b)), macro(GEODE_CONCAT(begin, c)), \
|
||||||
macro(GEODE_CONCAT(begin, d)), macro(GEODE_CONCAT(begin, e)), \
|
macro(GEODE_CONCAT(begin, d)), macro(GEODE_CONCAT(begin, e)), macro(GEODE_CONCAT(begin, f))
|
||||||
macro(GEODE_CONCAT(begin, f))
|
|
||||||
|
|
||||||
#define GEODE_ADDRESSER_NEST2(macro, begin) \
|
#define GEODE_ADDRESSER_NEST2(macro, begin) \
|
||||||
GEODE_ADDRESSER_NEST1(macro, GEODE_CONCAT(begin, 0)), \
|
GEODE_ADDRESSER_NEST1(macro, GEODE_CONCAT(begin, 0)), \
|
||||||
|
@ -53,13 +52,13 @@ namespace {
|
||||||
using table_table_t = intptr_t[0x100];
|
using table_table_t = intptr_t[0x100];
|
||||||
|
|
||||||
struct GEODE_HIDDEN ThunkTable {
|
struct GEODE_HIDDEN ThunkTable {
|
||||||
static inline thunk0_table_t table = { GEODE_ADDRESSER_THUNK0_SET() };
|
static inline thunk0_table_t table = {GEODE_ADDRESSER_THUNK0_SET()};
|
||||||
};
|
};
|
||||||
|
|
||||||
class GEODE_HIDDEN TableTable {
|
class GEODE_HIDDEN TableTable {
|
||||||
friend class geode::addresser::Addresser;
|
friend class geode::addresser::Addresser;
|
||||||
|
|
||||||
static inline table_table_t table = { GEODE_ADDRESSER_TABLE_SET() };
|
static inline table_table_t table = {GEODE_ADDRESSER_TABLE_SET()};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
USE_GEODE_NAMESPACE();
|
USE_GEODE_NAMESPACE();
|
||||||
|
|
||||||
void cocos2d::to_json(nlohmann::json& json, ccColor3B const& color) {
|
void cocos2d::to_json(nlohmann::json& json, ccColor3B const& color) {
|
||||||
json = nlohmann::json {
|
json = nlohmann::json{
|
||||||
{ "r", color.r },
|
{"r", color.r},
|
||||||
{ "g", color.g },
|
{"g", color.g},
|
||||||
{ "b", color.b },
|
{"b", color.b},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,7 @@ void cocos2d::from_json(nlohmann::json const& json, ccColor3B& color) {
|
||||||
json.at(2).get_to(color.b);
|
json.at(2).get_to(color.b);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw nlohmann::json::type_error::create(
|
throw nlohmann::json::type_error::create(0, "Expected color array to have 3 items", json);
|
||||||
0, "Expected color array to have 3 items", json
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// object
|
// object
|
||||||
|
@ -57,11 +55,11 @@ void cocos2d::from_json(nlohmann::json const& json, ccColor3B& color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void cocos2d::to_json(nlohmann::json& json, ccColor4B const& color) {
|
void cocos2d::to_json(nlohmann::json& json, ccColor4B const& color) {
|
||||||
json = nlohmann::json {
|
json = nlohmann::json{
|
||||||
{ "r", color.r },
|
{"r", color.r},
|
||||||
{ "g", color.g },
|
{"g", color.g},
|
||||||
{ "b", color.b },
|
{"b", color.b},
|
||||||
{ "a", color.a },
|
{"a", color.a},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,9 +73,7 @@ void cocos2d::from_json(nlohmann::json const& json, ccColor4B& color) {
|
||||||
json.at(3).get_to(color.a);
|
json.at(3).get_to(color.a);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw nlohmann::json::type_error::create(
|
throw nlohmann::json::type_error::create(0, "Expected color array to have 4 items", json);
|
||||||
0, "Expected color array to have 4 items", json
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// object
|
// object
|
||||||
|
@ -245,7 +241,7 @@ CCRect geode::cocos::calculateNodeCoverage(std::vector<CCNode*> const& nodes) {
|
||||||
for (auto child : nodes) {
|
for (auto child : nodes) {
|
||||||
auto pos = child->getPosition() - child->getScaledContentSize() * child->getAnchorPoint();
|
auto pos = child->getPosition() - child->getScaledContentSize() * child->getAnchorPoint();
|
||||||
auto csize = child->getPosition() +
|
auto csize = child->getPosition() +
|
||||||
child->getScaledContentSize() * (CCPoint { 1.f, 1.f } - child->getAnchorPoint());
|
child->getScaledContentSize() * (CCPoint{1.f, 1.f} - child->getAnchorPoint());
|
||||||
if (pos.x < coverage.origin.x) {
|
if (pos.x < coverage.origin.x) {
|
||||||
coverage.origin.x = pos.x;
|
coverage.origin.x = pos.x;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +263,7 @@ CCRect geode::cocos::calculateNodeCoverage(CCArray* nodes) {
|
||||||
for (auto child : CCArrayExt<CCNode>(nodes)) {
|
for (auto child : CCArrayExt<CCNode>(nodes)) {
|
||||||
auto pos = child->getPosition() - child->getScaledContentSize() * child->getAnchorPoint();
|
auto pos = child->getPosition() - child->getScaledContentSize() * child->getAnchorPoint();
|
||||||
auto csize = child->getPosition() +
|
auto csize = child->getPosition() +
|
||||||
child->getScaledContentSize() * (CCPoint { 1.f, 1.f } - child->getAnchorPoint());
|
child->getScaledContentSize() * (CCPoint{1.f, 1.f} - child->getAnchorPoint());
|
||||||
if (pos.x < coverage.origin.x) {
|
if (pos.x < coverage.origin.x) {
|
||||||
coverage.origin.x = pos.x;
|
coverage.origin.x = pos.x;
|
||||||
}
|
}
|
||||||
|
@ -288,9 +284,7 @@ CCRect geode::cocos::calculateChildCoverage(CCNode* parent) {
|
||||||
return calculateNodeCoverage(parent->getChildren());
|
return calculateNodeCoverage(parent->getChildren());
|
||||||
}
|
}
|
||||||
|
|
||||||
void geode::cocos::limitNodeSize(
|
void geode::cocos::limitNodeSize(cocos2d::CCNode* spr, cocos2d::CCSize const& size, float def, float min) {
|
||||||
cocos2d::CCNode* spr, cocos2d::CCSize const& size, float def, float min
|
|
||||||
) {
|
|
||||||
spr->setScale(1.f);
|
spr->setScale(1.f);
|
||||||
auto [cwidth, cheight] = spr->getContentSize();
|
auto [cwidth, cheight] = spr->getContentSize();
|
||||||
|
|
||||||
|
|
|
@ -151,12 +151,14 @@ public:
|
||||||
// Read file and add to entries
|
// Read file and add to entries
|
||||||
unz_file_pos pos;
|
unz_file_pos pos;
|
||||||
if (unzGetFilePos(m_zip, &pos) == UNZ_OK) {
|
if (unzGetFilePos(m_zip, &pos) == UNZ_OK) {
|
||||||
m_entries.insert({ fileName,
|
m_entries.insert({
|
||||||
ZipEntry {
|
fileName,
|
||||||
.m_pos = pos,
|
ZipEntry {
|
||||||
.m_compressedSize = fileInfo.compressed_size,
|
.m_pos = pos,
|
||||||
.m_uncompressedSize = fileInfo.uncompressed_size,
|
.m_compressedSize = fileInfo.compressed_size,
|
||||||
} });
|
.m_uncompressedSize = fileInfo.uncompressed_size,
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Read next file, or break on error
|
// Read next file, or break on error
|
||||||
if (unzGoToNextFile64(m_zip, &fileInfo, fileName, sizeof(fileName) - 1) != UNZ_OK) {
|
if (unzGoToNextFile64(m_zip, &fileInfo, fileName, sizeof(fileName) - 1) != UNZ_OK) {
|
||||||
|
|
|
@ -91,9 +91,7 @@ std::wstring utils::string::toUpper(std::wstring const& str) {
|
||||||
return utils::string::toUpperIP(ret);
|
return utils::string::toUpperIP(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string& utils::string::replaceIP(
|
std::string& utils::string::replaceIP(std::string& str, std::string const& orig, std::string const& repl) {
|
||||||
std::string& str, std::string const& orig, std::string const& repl
|
|
||||||
) {
|
|
||||||
std::string::size_type n = 0;
|
std::string::size_type n = 0;
|
||||||
while ((n = str.find(orig, n)) != std::string::npos) {
|
while ((n = str.find(orig, n)) != std::string::npos) {
|
||||||
str.replace(n, orig.size(), repl);
|
str.replace(n, orig.size(), repl);
|
||||||
|
@ -248,7 +246,8 @@ std::wstring& utils::string::trimLeftIP(std::wstring& str) {
|
||||||
std::string& utils::string::trimRightIP(std::string& str) {
|
std::string& utils::string::trimRightIP(std::string& str) {
|
||||||
str.erase(
|
str.erase(
|
||||||
std::find_if(
|
std::find_if(
|
||||||
str.rbegin(), str.rend(),
|
str.rbegin(),
|
||||||
|
str.rend(),
|
||||||
[](auto ch) {
|
[](auto ch) {
|
||||||
return !std::isspace(ch);
|
return !std::isspace(ch);
|
||||||
}
|
}
|
||||||
|
@ -261,7 +260,8 @@ std::string& utils::string::trimRightIP(std::string& str) {
|
||||||
std::wstring& utils::string::trimRightIP(std::wstring& str) {
|
std::wstring& utils::string::trimRightIP(std::wstring& str) {
|
||||||
str.erase(
|
str.erase(
|
||||||
std::find_if(
|
std::find_if(
|
||||||
str.rbegin(), str.rend(),
|
str.rbegin(),
|
||||||
|
str.rend(),
|
||||||
[](auto ch) {
|
[](auto ch) {
|
||||||
return !std::isspace(ch);
|
return !std::isspace(ch);
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ Result<std::string> web::fetch(std::string const& url) {
|
||||||
return Err("Error getting info: " + std::string(curl_easy_strerror(res)));
|
return Err("Error getting info: " + std::string(curl_easy_strerror(res)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unordered_map<std::string, SentAsyncWebRequestHandle> RUNNING_REQUESTS {};
|
static std::unordered_map<std::string, SentAsyncWebRequestHandle> RUNNING_REQUESTS{};
|
||||||
static std::mutex RUNNING_REQUESTS_MUTEX;
|
static std::mutex RUNNING_REQUESTS_MUTEX;
|
||||||
|
|
||||||
SentAsyncWebRequest::SentAsyncWebRequest(AsyncWebRequest const& req, std::string const& id) :
|
SentAsyncWebRequest::SentAsyncWebRequest(AsyncWebRequest const& req, std::string const& id) :
|
||||||
|
@ -190,10 +190,11 @@ SentAsyncWebRequest::SentAsyncWebRequest(AsyncWebRequest const& req, std::string
|
||||||
struct ProgressData {
|
struct ProgressData {
|
||||||
SentAsyncWebRequest* self;
|
SentAsyncWebRequest* self;
|
||||||
std::ofstream* file;
|
std::ofstream* file;
|
||||||
} data { this, file.get() };
|
} data{this, file.get()};
|
||||||
|
|
||||||
curl_easy_setopt(
|
curl_easy_setopt(
|
||||||
curl, CURLOPT_PROGRESSFUNCTION,
|
curl,
|
||||||
|
CURLOPT_PROGRESSFUNCTION,
|
||||||
+[](void* ptr, double total, double now, double, double) -> int {
|
+[](void* ptr, double total, double now, double, double) -> int {
|
||||||
auto data = static_cast<ProgressData*>(ptr);
|
auto data = static_cast<ProgressData*>(ptr);
|
||||||
while (data->self->m_paused) {}
|
while (data->self->m_paused) {}
|
||||||
|
@ -350,7 +351,7 @@ SentAsyncWebRequestHandle AsyncWebRequest::send() {
|
||||||
else {
|
else {
|
||||||
auto id = m_joinID.value_or("__anon_request_" + std::to_string(COUNTER++));
|
auto id = m_joinID.value_or("__anon_request_" + std::to_string(COUNTER++));
|
||||||
ret = std::make_shared<SentAsyncWebRequest>(*this, id);
|
ret = std::make_shared<SentAsyncWebRequest>(*this, id);
|
||||||
RUNNING_REQUESTS.insert({ id, ret });
|
RUNNING_REQUESTS.insert({id, ret});
|
||||||
}
|
}
|
||||||
|
|
||||||
// resume all running requests
|
// resume all running requests
|
||||||
|
@ -367,32 +368,32 @@ AsyncWebRequest::~AsyncWebRequest() {
|
||||||
|
|
||||||
AsyncWebResult<std::monostate> AsyncWebResponse::into(std::ostream& stream) {
|
AsyncWebResult<std::monostate> AsyncWebResponse::into(std::ostream& stream) {
|
||||||
m_request.m_target = &stream;
|
m_request.m_target = &stream;
|
||||||
return this->as(+[](byte_array const&) -> Result<std::monostate> {
|
return this->as([](byte_array const&) -> Result<std::monostate> {
|
||||||
return Ok(std::monostate());
|
return Ok(std::monostate());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncWebResult<std::monostate> AsyncWebResponse::into(ghc::filesystem::path const& path) {
|
AsyncWebResult<std::monostate> AsyncWebResponse::into(ghc::filesystem::path const& path) {
|
||||||
m_request.m_target = path;
|
m_request.m_target = path;
|
||||||
return this->as(+[](byte_array const&) -> Result<std::monostate> {
|
return this->as([](byte_array const&) -> Result<std::monostate> {
|
||||||
return Ok(std::monostate());
|
return Ok(std::monostate());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncWebResult<std::string> AsyncWebResponse::text() {
|
AsyncWebResult<std::string> AsyncWebResponse::text() {
|
||||||
return this->as(+[](byte_array const& bytes) -> Result<std::string> {
|
return this->as([](byte_array const& bytes) -> Result<std::string> {
|
||||||
return Ok(std::string(bytes.begin(), bytes.end()));
|
return Ok(std::string(bytes.begin(), bytes.end()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncWebResult<byte_array> AsyncWebResponse::bytes() {
|
AsyncWebResult<byte_array> AsyncWebResponse::bytes() {
|
||||||
return this->as(+[](byte_array const& bytes) -> Result<byte_array> {
|
return this->as([](byte_array const& bytes) -> Result<byte_array> {
|
||||||
return Ok(bytes);
|
return Ok(bytes);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncWebResult<nlohmann::json> AsyncWebResponse::json() {
|
AsyncWebResult<nlohmann::json> AsyncWebResponse::json() {
|
||||||
return this->as(+[](byte_array const& bytes) -> Result<nlohmann::json> {
|
return this->as([](byte_array const& bytes) -> Result<nlohmann::json> {
|
||||||
try {
|
try {
|
||||||
return Ok(nlohmann::json::parse(bytes.begin(), bytes.end()));
|
return Ok(nlohmann::json::parse(bytes.begin(), bytes.end()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue