Skip to content

Commit c462abb

Browse files
committed
geode v5.6.0 support
1 parent c2352d3 commit c462abb

5 files changed

Lines changed: 67 additions & 40 deletions

File tree

mod.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"geode": "5.3.0",
2+
"geode": "5.6.0",
33
"gd": {
44
"win": "2.2081",
55
"android": "2.2081",
@@ -8,7 +8,7 @@
88
},
99
"id": "alphalaneous.alphas_geode_utils",
1010
"name": "Alpha's Geode Utils",
11-
"version": "v1.2.4",
11+
"version": "v1.2.5",
1212
"developer": "Alphalaneous",
1313
"description": "Miscellaneous utilities for Geode Modding",
1414
"api": {

src/AGUEngine.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "AGUEngine.hpp"
2+
#include <Geode/modify/MenuLayer.hpp>
3+
#include "ModifyHandler.hpp"
4+
5+
void AGUEngine::removeScriptObjectByCCObject(CCObject* pObj) {
6+
ObjectDestroyedEvent(pObj).send();
7+
}
8+
9+
cocos2d::ccScriptType AGUEngine::getScriptType() {
10+
// Javascript is called without needing to change m_nLuaID
11+
return cocos2d::ccScriptType::kScriptTypeJavascript;
12+
}
13+
14+
int AGUEngine::executeNodeEvent(cocos2d::CCNode* pNode, int nAction) {
15+
NodeEvent(pNode, static_cast<NodeEventType>(nAction)).send();
16+
return -1;
17+
}
18+
19+
int AGUEngine::executeMenuItemEvent(cocos2d::CCMenuItem* pMenuItem) {
20+
MenuItemActivatedEvent(pMenuItem).send(pMenuItem);
21+
return -1;
22+
}
23+
24+
$on_mod(Loaded) {
25+
CCScriptEngineManager::sharedManager()->setScriptEngine(new AGUEngine());
26+
27+
ObjectDestroyedEvent().listen([] (CCObject* object) {
28+
alpha::utils::ModifyHandler::get()->releaseObjectData(object->m_nLuaID);
29+
}).leak();
30+
}

src/AGUEngine.hpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#pragma once
2+
3+
#include <Geode/Geode.hpp>
4+
5+
using namespace geode::prelude;
6+
7+
class ObjectDestroyedEvent : public GlobalEvent<ObjectDestroyedEvent, bool(), CCObject*> {
8+
public:
9+
using GlobalEvent::GlobalEvent;
10+
};
11+
12+
class AGUEngine : public cocos2d::CCScriptEngineProtocol {
13+
14+
cocos2d::ccScriptType getScriptType();
15+
void removeScriptObjectByCCObject(cocos2d::CCObject* pObj);
16+
int executeNodeEvent(cocos2d::CCNode* pNode, int nAction);
17+
int executeMenuItemEvent(cocos2d::CCMenuItem* pMenuItem);
18+
19+
void removeScriptHandler(int nHandler) {}
20+
int reallocateScriptHandler(int nHandler) { return -1; }
21+
int executeString(const char* codes) { return -1; }
22+
int executeScriptFile(const char* filename) { return -1; }
23+
int executeGlobalFunction(const char* functionName) { return -1; }
24+
int executeNotificationEvent(cocos2d::CCNotificationCenter* pNotificationCenter, const char* pszName) { return -1; }
25+
int executeCallFuncActionEvent(cocos2d::CCCallFunc* pAction, cocos2d::CCObject* pTarget = nullptr) { return -1; }
26+
int executeSchedule(int nHandler, float dt, cocos2d::CCNode* pNode = nullptr) { return -1; }
27+
int executeLayerTouchesEvent(cocos2d::CCLayer* pLayer, int eventType, cocos2d::CCSet *pTouches) { return -1; }
28+
int executeLayerTouchEvent(cocos2d::CCLayer* pLayer, int eventType, cocos2d::CCTouch *pTouch) { return -1; }
29+
int executeLayerKeypadEvent(cocos2d::CCLayer* pLayer, int eventType) { return -1; }
30+
int executeAccelerometerEvent(cocos2d::CCLayer* pLayer, cocos2d::CCAcceleration* pAccelerationValue) { return -1; }
31+
int executeEvent(int nHandler, const char* pEventName, cocos2d::CCObject* pEventSource = nullptr, const char* pEventSourceClassName = nullptr) { return -1; }
32+
int executeEventWithArgs(int nHandler, cocos2d::CCArray* pArgs) { return -1; }
33+
bool handleAssert(const char *msg) { return false; }
34+
bool parseConfig(ConfigType type, const gd::string& str) { return false; }
35+
};

src/DummyScriptEngineProtocol.cpp

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/DummyScriptEngineProtocol.hpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)