1+ #include < Geode/utils/ObjectDestroyedEvent.hpp>
2+ #include < Geode/ui/NodeEvent.hpp>
3+
4+ using namespace geode ::prelude;
5+
6+ namespace geode {
7+ class ScriptEngine : public CCScriptEngineProtocol {
8+
9+ ccScriptType getScriptType () {
10+ // Javascript engine is called without needing to change m_nLuaID
11+ return cocos2d::ccScriptType::kScriptTypeJavascript ;
12+ }
13+
14+ void removeScriptObjectByCCObject (CCObject* object) {
15+ ObjectDestroyedEvent (object).send ();
16+ }
17+
18+ int executeNodeEvent (CCNode* node, int action) {
19+ NodeEvent (node, static_cast <NodeEventType>(action)).send ();
20+ return -1 ;
21+ }
22+
23+ int executeMenuItemEvent (CCMenuItem* menuItem) {
24+ MenuItemEvent (menuItem).send ();
25+ return -1 ;
26+ }
27+
28+ void removeScriptHandler (int handler) {}
29+ int reallocateScriptHandler (int handler) { return -1 ; }
30+ int executeString (const char * codes) { return -1 ; }
31+ int executeScriptFile (const char * filename) { return -1 ; }
32+ int executeGlobalFunction (const char * functionName) { return -1 ; }
33+ int executeNotificationEvent (CCNotificationCenter* notificationCenter, const char * name) { return -1 ; }
34+ int executeCallFuncActionEvent (CCCallFunc* action, CCObject* target) { return -1 ; }
35+ int executeSchedule (int handler, float dt, CCNode* node) { return -1 ; }
36+ int executeLayerTouchesEvent (CCLayer* layer, int eventType, CCSet* touches) { return -1 ; }
37+ int executeLayerTouchEvent (CCLayer* layer, int eventType, CCTouch* touch) { return -1 ; }
38+ int executeLayerKeypadEvent (CCLayer* layer, int eventType) { return -1 ; }
39+ int executeAccelerometerEvent (CCLayer* layer, CCAcceleration* accelerationValue) { return -1 ; }
40+ int executeEvent (int handler, const char * eventName, CCObject* eventSource, const char * eventSourceClassName) { return -1 ; }
41+ int executeEventWithArgs (int handler, CCArray* args) { return -1 ; }
42+ bool handleAssert (const char * msg) { return false ; }
43+ bool parseConfig (ConfigType type, const gd::string& str) { return false ; }
44+ };
45+ }
46+
47+ $execute {
48+ CCScriptEngineManager::sharedManager ()->setScriptEngine (new geode::ScriptEngine ());
49+ }
0 commit comments