-
Notifications
You must be signed in to change notification settings - Fork 448
NodeEvent, MenuItemActivatedEvent #1964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7d78998
implement all the node events
Alphalaneous bbf2b1c
Rename MenuItemEvent
Alphalaneous a1754a5
Add some helper methods
Alphalaneous 8db05cf
Fix MenuItemActivatedEvent
Alphalaneous 3ae3a0c
Update ScriptEngine.cpp
Alphalaneous 78bdb83
Remove ObjectDestroyedEvent
Alphalaneous 51b1d8c
Forgot about that
Alphalaneous 80a043a
Update ScriptEngine.cpp
altalk23 b3f8855
Merge branch 'geode-sdk:main' into node-events
Alphalaneous File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #pragma once | ||
|
|
||
| #include "../loader/Event.hpp" | ||
|
|
||
| namespace geode { | ||
|
|
||
| enum class NodeEventType { | ||
| /// Fired when a CCNode is added to the scene tree. | ||
| OnEnter, | ||
|
|
||
| /// Fired when a CCNode is removed from the scene tree. | ||
| OnExit, | ||
|
|
||
| /// Fired when a CCNode is already added to the scene tree but after a scene transition. | ||
| OnEnterTransitionDidFinish, | ||
|
|
||
| /// Fired when a CCNode is about to be removed from the scene tree before a scene transition. | ||
| OnExitTransitionDidStart, | ||
|
|
||
| /// Fired when a CCNode is cleaned up (Schedules removed and Actions stopped). | ||
| OnCleanup, | ||
| }; | ||
|
|
||
| /// Fired when a CCNode has a specific Event in NodeEventType. | ||
| class NodeEvent : public GlobalEvent<NodeEvent, bool(), cocos2d::CCNode*, NodeEventType> { | ||
| public: | ||
| using GlobalEvent::GlobalEvent; | ||
| }; | ||
|
|
||
| /// Fired when a CCMenuItem is Activated (after the callback). | ||
| class MenuItemActivatedEvent : public Event<MenuItemActivatedEvent, bool(cocos2d::CCMenuItem*), cocos2d::CCMenuItem*> { | ||
| public: | ||
| using Event::Event; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #include <Geode/ui/NodeEvent.hpp> | ||
|
|
||
| using namespace geode::prelude; | ||
|
|
||
| namespace geode { | ||
| class ScriptEngine : public CCScriptEngineProtocol { | ||
|
|
||
| ccScriptType getScriptType() { | ||
| // Javascript engine is called without needing to change m_nLuaID | ||
| return cocos2d::ccScriptType::kScriptTypeJavascript; | ||
| } | ||
|
|
||
| int executeNodeEvent(CCNode* node, int action) { | ||
| NodeEvent(node, static_cast<NodeEventType>(action)).send(); | ||
| return -1; | ||
| } | ||
|
|
||
| int executeMenuItemEvent(CCMenuItem* menuItem) { | ||
| MenuItemActivatedEvent(menuItem).send(menuItem); | ||
| return -1; | ||
| } | ||
|
|
||
| void removeScriptObjectByCCObject(CCObject* object) {} | ||
| void removeScriptHandler(int handler) {} | ||
| int reallocateScriptHandler(int handler) { return -1; } | ||
| int executeString(const char* codes) { return -1; } | ||
| int executeScriptFile(const char* filename) { return -1; } | ||
| int executeGlobalFunction(const char* functionName) { return -1; } | ||
| int executeNotificationEvent(CCNotificationCenter* notificationCenter, const char* name) { return -1; } | ||
| int executeCallFuncActionEvent(CCCallFunc* action, CCObject* target) { return -1; } | ||
| int executeSchedule(int handler, float dt, CCNode* node) { return -1; } | ||
| int executeLayerTouchesEvent(CCLayer* layer, int eventType, CCSet* touches) { return -1; } | ||
| int executeLayerTouchEvent(CCLayer* layer, int eventType, CCTouch* touch) { return -1; } | ||
| int executeLayerKeypadEvent(CCLayer* layer, int eventType) { return -1; } | ||
| int executeAccelerometerEvent(CCLayer* layer, CCAcceleration* accelerationValue) { return -1; } | ||
| int executeEvent(int handler, const char* eventName, CCObject* eventSource, const char* eventSourceClassName) { return -1; } | ||
| int executeEventWithArgs(int handler, CCArray* args) { return -1; } | ||
| bool handleAssert(const char* msg) { return false; } | ||
| bool parseConfig(ConfigType type, const gd::string& str) { return false; } | ||
| }; | ||
| } | ||
|
|
||
| $on_mod(Loaded) { | ||
| CCScriptEngineManager::sharedManager()->setScriptEngine(new geode::ScriptEngine()); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.