Skip to content

Commit e7f8238

Browse files
committed
Merge branch 'main' of https://github.com/geode-sdk/geode into main
2 parents 6b3e682 + 355df5a commit e7f8238

File tree

15 files changed

+283
-280
lines changed

15 files changed

+283
-280
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
os: windows-2019
1818
prefixes: ''
1919
extra_flags: '-G "Visual Studio 16 2019" -T host=x86 -A win32'
20-
out_paths: './bin/nightly/geode.dll ./bin/nightly/geode.lib ./bin/nightly/XInput9_1_0.dll'
20+
out_paths: './bin/nightly/geode.dll ./bin/nightly/GeodeBootstrapper.dll ./bin/nightly/geode.lib ./bin/nightly/XInput9_1_0.dll'
2121
- name: "macOS"
2222
os: macos-latest
2323
prefixes: 'PATH="/usr/local/opt/ccache/libexec:$PATH"'
2424
extra_flags: "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON"
25-
out_paths: './bin/nightly/Geode.dylib'
25+
out_paths: './bin/nightly/Geode.dylib ./bin/nightly/GeodeBootstrapper.dylib'
2626
name: ${{ matrix.config.name }}
2727
runs-on: ${{ matrix.config.os }}
2828

bindings/GeometryDash.bro

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ class CCTextInputNode : cocos2d::CCLayer, cocos2d::CCIMEDelegate, cocos2d::CCTex
573573
bool init(float width, float height, const char* caption, const char* thonburi, int maxCharCount, const char* font) = mac 0x5d180, win 0x20e50, ios 0xe261c;
574574

575575
void refreshLabel() = mac 0x5d730, win 0x21330, ios 0xe2af4;
576-
void updateLabel(gd::string) = mac 0x5d4a0, win 0x0, ios 0x0;
576+
void updateLabel(gd::string) = mac 0x5d4a0, win 0x21190, ios 0x0;
577577
void updateBlinkLabel() = mac 0x5d920;
578578
virtual void registerWithTouchDispatcher() = mac 0x5eec0, win 0x220e0, ios 0x0;
579579
virtual void visit() = mac 0x5d380, win 0x21000, ios 0x0;
@@ -691,7 +691,7 @@ class ColorSelectDelegate {
691691
}
692692

693693
class ColorSelectLiveOverlay : FLAlertLayer {
694-
bool init(ColorAction*, ColorAction*, EffectGameObject*) = mac 0x2e2790;
694+
bool init(ColorAction*, ColorAction*, EffectGameObject*) = mac 0x2e2790, win 0x41db0;
695695
void sliderChanged(cocos2d::CCObject*) = mac 0x2e3830;
696696
EffectGameObject* m_effectGameObject;
697697
cocos2d::CCArray* m_barSprites;
@@ -707,7 +707,7 @@ class ColorSelectPopup : FLAlertLayer, cocos2d::extension::ColorPickerDelegate,
707707
bool init(EffectGameObject* triggerObj, cocos2d::CCArray* triggerObjs, ColorAction* colorAction) = mac 0x41ee70, win 0x43ae0, ios 0x0;
708708
void updateColorValue() = mac 0x0, win 0x46f30, ios 0x0;
709709
void updateCopyColorTextInputLabel() = mac 0x0, win 0x479c0, ios 0x0;
710-
void closeColorSelect(cocos2d::CCObject* sender) = mac 0x421af0;
710+
void closeColorSelect(cocos2d::CCObject* sender) = mac 0x421af0, win 0x46d80;
711711

712712
cocos2d::extension::CCControlColourPicker* m_colorPicker;
713713
cocos2d::CCLabelBMFont* m_unk1DC;
@@ -2766,10 +2766,10 @@ class GameManager : GManager {
27662766
bool getGameVariable(const char*) = mac 0x1cccd0, win 0xc9d30, ios 0x0;
27672767
int getIntGameVariable(const char*) = mac 0x1cd1d0, win 0xca330, ios 0x0;
27682768
bool getUGV(const char*) = mac 0x1ccfa0, win 0xca0d0, ios 0x0;
2769-
void loadBackground(int) = mac 0x1cc820;
2769+
void loadBackground(int) = mac 0x1cc820, win 0xc9990;
27702770
void loadDeathEffect(int) = mac 0x1cc690, win 0x0, ios 0x0;
2771-
void loadFont(int) = mac 0x1cc550, win 0x0, ios 0x0;
2772-
void loadGround(int) = mac 0x1cc8e0;
2771+
void loadFont(int) = mac 0x1cc550, win 0xc9770, ios 0x0;
2772+
void loadGround(int) = mac 0x1cc8e0, win 0xc9a50;
27732773
void reloadAll(bool, bool, bool) = mac 0x1d08a0, win 0xce950, ios 0x0;
27742774
void reloadAllStep2() = mac 0x1d0940, win 0xce9e0, ios 0x23b1f4;
27752775
void reloadAllStep5() = mac 0x1d0b00, win 0x0, ios 0x0;
@@ -3799,8 +3799,8 @@ class LevelSettingsObject : cocos2d::CCNode {
37993799
virtual ~LevelSettingsObject() = mac 0xa5650, win 0x16e800, ios 0x0;
38003800
virtual bool init() = mac 0xa5690, win 0x16e940, ios 0x0;
38013801
static LevelSettingsObject* create() = mac 0x92760, win 0x16e8a0, ios 0x0;
3802-
static LevelSettingsObject* objectFromDict(cocos2d::CCDictionary*) = mac 0xa5810, win 0x0, ios 0x0;
3803-
static LevelSettingsObject* objectFromString(gd::string) = mac 0x945a0, win 0x0, ios 0x0;
3802+
static LevelSettingsObject* objectFromDict(cocos2d::CCDictionary*) = mac 0xa5810, win 0x16f4d0, ios 0x0;
3803+
static LevelSettingsObject* objectFromString(gd::string) = mac 0x945a0, win 0x16f440, ios 0x0;
38043804
void setupColorsFromLegacyMode(cocos2d::CCDictionary*) = mac 0xa6a30, win 0x170050, ios 0x0;
38053805

38063806
gd::string getSaveString() = mac 0x979c0, win 0x16ebf0;

cmake/GeodeFile.cmake

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,29 @@ function(create_geode_file proname)
4141
return()
4242
endif()
4343

44-
message(STATUS "Creating geode file for ${proname}")
45-
44+
# what is this for
4645
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mod.json ${CMAKE_CURRENT_BINARY_DIR}/what.txt)
4746
set_target_properties(${proname} PROPERTIES CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/mod.json)
4847

48+
if(GEODE_CLI STREQUAL "GEODE_CLI-NOTFOUND")
49+
message(WARNING "create_geode_file called, but Geode CLI was not found - You will need to manually package the .geode files")
50+
return()
51+
endif()
52+
53+
message(STATUS "Creating geode file for ${proname}")
54+
4955
execute_process(
5056
COMMAND ${GEODE_CLI} package get-id ${CMAKE_CURRENT_SOURCE_DIR} --raw
5157
OUTPUT_VARIABLE MOD_ID
5258
)
5359

5460
set_target_properties(${proname} PROPERTIES PREFIX "")
5561
set_target_properties(${proname} PROPERTIES OUTPUT_NAME ${MOD_ID})
56-
57-
if(GEODE_CLI STREQUAL "GEODE_CLI-NOTFOUND")
58-
message(WARNING "create_geode_file called, but Geode CLI was not found - You will need to manually package the .geode files")
59-
else()
60-
add_custom_target(${proname}_PACKAGE ALL
61-
DEPENDS ${proname} ${CMAKE_CURRENT_SOURCE_DIR}/mod.json
62-
COMMAND ${GEODE_CLI} package new ${CMAKE_CURRENT_SOURCE_DIR} --binary $<TARGET_FILE:${proname}> --output $<TARGET_FILE_DIR:${proname}>/${proname}.geode --install
63-
VERBATIM USES_TERMINAL
64-
)
65-
endif()
62+
add_custom_target(${proname}_PACKAGE ALL
63+
DEPENDS ${proname} ${CMAKE_CURRENT_SOURCE_DIR}/mod.json
64+
COMMAND ${GEODE_CLI} package new ${CMAKE_CURRENT_SOURCE_DIR} --binary $<TARGET_FILE:${proname}> --output $<TARGET_FILE_DIR:${proname}>/${proname}.geode --install
65+
VERBATIM USES_TERMINAL
66+
)
6667
endfunction()
6768

6869
function(package_geode_resources proname src dest)

loader/include/Geode/loader/Setting.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ namespace geode {
155155
return m_name;
156156
}
157157

158+
std::string getDisplayName() const {
159+
return m_name.value_or(m_key);
160+
}
161+
158162
std::optional<std::string> getDescription() const {
159163
return m_description;
160164
}

loader/include/Geode/utils/cocos.hpp

Lines changed: 34 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ namespace geode::cocos {
171171
GEODE_DLL bool fileExistsInSearchPaths(const char* filename);
172172

173173

174-
template <class T>
175-
struct GEODE_DLL CCArrayIterator {
174+
template <typename T>
175+
struct CCArrayIterator {
176176
public:
177177
CCArrayIterator(T* p) : m_ptr(p) {}
178178
T* m_ptr;
@@ -416,69 +416,6 @@ namespace geode::cocos {
416416
return m_dict->allKeys(key)->count();
417417
}
418418
};
419-
420-
template <typename R, typename ...Args>
421-
class SelectorWrapperImpl : public cocos2d::CCObject {
422-
protected:
423-
std::function<R(Args...)> m_inner;
424-
public:
425-
static SelectorWrapperImpl<R, Args...>* create(std::function<R(Args...)> fn) {
426-
auto ret = new SelectorWrapperImpl<R, Args...>();
427-
ret->m_inner = fn;
428-
ret->autorelease();
429-
return ret;
430-
}
431-
432-
R invoke(Args... args) {
433-
return m_inner(args...);
434-
}
435-
};
436-
437-
template <typename R, typename ...Args>
438-
class SelectorWrapper {
439-
protected:
440-
using Target = SelectorWrapperImpl<R, Args...>;
441-
bool m_tied;
442-
Target* m_impl;
443-
public:
444-
SelectorWrapper(std::function<R(Args...)> fn) {
445-
m_impl = Target::create(fn);
446-
m_impl->retain();
447-
}
448-
449-
~SelectorWrapper() {
450-
if (!m_tied)
451-
m_impl->release();
452-
}
453-
454-
Target* target() {
455-
return m_impl;
456-
}
457-
458-
auto selector() {
459-
return reinterpret_cast<R(cocos2d::CCObject::*)(Args...)>(&Target::invoke);
460-
}
461-
462-
SelectorWrapper<R, Args...>& leak() {
463-
m_impl->retain();
464-
return *this;
465-
}
466-
467-
SelectorWrapper<R, Args...> tieToNode(cocos2d::CCNode* node) {
468-
if (!m_tied) {
469-
node->addChild(m_impl);
470-
m_impl->release();
471-
m_tied = true;
472-
}
473-
474-
return *this;
475-
}
476-
};
477-
478-
template <typename F>
479-
auto selectorFromFn(std::function<F> fn) {
480-
return SelectorWrapper(fn);
481-
}
482419

483420
// namespace for storing implementation stuff for
484421
// inline member functions
@@ -499,6 +436,9 @@ namespace geode::cocos {
499436
m_lambda.~F();
500437
}
501438
}
439+
LambdaHolder(F&& func) {
440+
this->assign(std::forward<F>(func));
441+
}
502442
Ret operator()(Args... args) {
503443
if (m_assigned) {
504444
return m_lambda(std::forward<Args>(args)...);
@@ -531,13 +471,18 @@ namespace geode::cocos {
531471

532472
template<class Base, class Func, class... Args>
533473
struct InlineMemberFunction<Base, Func, std::tuple<Args...>> : public Base {
534-
// this class isn't instantiated anywhere, and is
535-
// just used as a proxy to redirect the member function
536-
// to the lambda
537-
static inline LambdaHolder<Func, typename ExtractLambda<Func>::Ret, Args...> s_selector {};
538-
typename ExtractLambda<Func>::Ret onSelector(Args... args) {
474+
using Ret = typename ExtractLambda<Func>::Ret;
475+
using Selector = Ret(Base::*)(Args...);
476+
using Holder = LambdaHolder<Func, Ret, Args...>;
477+
478+
static inline Holder s_selector {};
479+
Ret selector(Args... args) {
539480
return s_selector(std::forward<Args>(args)...);
540481
}
482+
static Selector get(Func&& function) {
483+
s_selector.assign(std::move(function));
484+
return static_cast<Selector>(&InlineMemberFunction::selector);
485+
}
541486
};
542487
}
543488

@@ -554,9 +499,14 @@ namespace geode::cocos {
554499
* same captured values.
555500
*/
556501
template<class Base, class Func>
502+
[[deprecated(
503+
"Due to too many implementation problems, "
504+
"makeMemberFunction will be removed in the future."
505+
)]]
557506
static auto makeMemberFunction(Func&& function) {
558-
InlineMemberFunction<Base, Func, typename ExtractLambda<Func>::Params>::s_selector.assign(std::move(function));
559-
return &InlineMemberFunction<Base, Func, typename ExtractLambda<Func>::Params>::onSelector;
507+
return InlineMemberFunction<
508+
Base, Func, typename ExtractLambda<Func>::Params
509+
>::get(std::move(function));
560510
}
561511

562512
/**
@@ -566,16 +516,22 @@ namespace geode::cocos {
566516
* for even more concise code.
567517
*
568518
* Do note that due to implementation problems, captures may have
569-
* unexpected side-effects. In practice, lambda member functions with
570-
* captures do not work properly in loops. If you assign the same
571-
* member lambda to multiple different targets, they will share the
572-
* same captured values.
519+
* unexpected side-effects. In practice, **you should not expect to be able
520+
* to pass any more information than you can pass to a normal menu selector
521+
* through captures**. If you assign the same member lambda to multiple
522+
* different targets, they will share the same captured values.
573523
*/
574524
template<class Func>
525+
[[deprecated(
526+
"Due to too many implementation problems, "
527+
"makeMenuSelector will be removed in the future."
528+
)]]
575529
static cocos2d::SEL_MenuHandler makeMenuSelector(Func&& selector) {
576-
return (cocos2d::SEL_MenuHandler)(makeMemberFunction<cocos2d::CCObject, Func>(std::move(selector)));
530+
return reinterpret_cast<cocos2d::SEL_MenuHandler>(
531+
makeMemberFunction<cocos2d::CCObject, Func>(std::move(selector))
532+
);
577533
}
578534

579535
#define GEODE_MENU_SELECTOR(senderArg, ...) \
580-
makeMenuSelector([=](senderArg) { __VA_ARGS__; })
536+
makeMenuSelector([this](senderArg) { __VA_ARGS__; })
581537
}

0 commit comments

Comments
 (0)