mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-23 03:15:58 -04:00
fix the old test mod stuff
This commit is contained in:
parent
9a47d611cc
commit
f33f116ced
6 changed files with 19 additions and 61 deletions
loader
|
@ -42,7 +42,7 @@ namespace geode {
|
|||
using Ev = DispatchEvent<Args...>;
|
||||
using Callback = ListenerResult(Args...);
|
||||
|
||||
EventListenerPool* getPool() const override {
|
||||
EventListenerPool* getPool() const {
|
||||
if (pools().count(m_id) == 0) {
|
||||
pools()[m_id] = new DefaultEventListenerPool();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <Geode/Loader.hpp>
|
||||
#include <Geode/modify/MenuLayer.hpp>
|
||||
#include <Geode/loader/SettingNode.hpp>
|
||||
#include <Geode/loader/Dispatch.hpp>
|
||||
#include <Geode/loader/ModJsonTest.hpp>
|
||||
#include <Geode/binding/CCMenuItemSpriteExtra.hpp>
|
||||
#include <Geode/binding/FLAlertLayer.hpp>
|
||||
#include <Geode/Bindings.hpp>
|
||||
#include "main.hpp"
|
||||
|
||||
using namespace geode::prelude;
|
||||
|
@ -164,11 +164,12 @@ struct MyMenuLayer : Modify<MyMenuLayer, MenuLayer> {
|
|||
$on_mod(Loaded) {
|
||||
Mod::get()->addCustomSetting<MySettingValue>("overcast-skies", DEFAULT_ICON);
|
||||
|
||||
// Dispatcher::get()->addFunction<void(GJGarageLayer*)>("test-garage-open", [](GJGarageLayer*
|
||||
// gl) { auto label = CCLabelBMFont::create("Dispatcher works!", "bigFont.fnt");
|
||||
// label->setPosition(100, 80);
|
||||
// label->setScale(.4f);
|
||||
// label->setZOrder(99999);
|
||||
// gl->addChild(label);
|
||||
// });
|
||||
}
|
||||
(void)new EventListener(+[](GJGarageLayer* gl) {
|
||||
auto label = CCLabelBMFont::create("Dispatcher works!", "bigFont.fnt");
|
||||
label->setPosition(100, 80);
|
||||
label->setScale(.4f);
|
||||
label->setZOrder(99999);
|
||||
gl->addChild(label);
|
||||
return ListenerResult::Propagate;
|
||||
}, MyDispatchFilter("geode.testdep/test-garage-open"));
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <Geode/loader/Event.hpp>
|
||||
#include <Geode/loader/Dispatch.hpp>
|
||||
#include <Geode/binding/GJGarageLayer.hpp>
|
||||
|
||||
using namespace geode::prelude;
|
||||
|
||||
|
@ -31,3 +33,6 @@ public:
|
|||
TestEventFilter();
|
||||
TestEventFilter(TestEventFilter const&) = default;
|
||||
};
|
||||
|
||||
using MyDispatchEvent = geode::DispatchEvent<GJGarageLayer*>;
|
||||
using MyDispatchFilter = geode::DispatchFilter<GJGarageLayer*>;
|
|
@ -12,18 +12,9 @@ auto test = []() {
|
|||
};
|
||||
|
||||
// Exported functions
|
||||
$on_mod(Enabled) {
|
||||
log::info("Enabled");
|
||||
}
|
||||
$on_mod(Disabled) {
|
||||
log::info("Disabled");
|
||||
}
|
||||
$on_mod(Loaded) {
|
||||
log::info("Loaded");
|
||||
}
|
||||
$on_mod(Unloaded) {
|
||||
log::info("Unloaded");
|
||||
}
|
||||
|
||||
// Events
|
||||
$execute {
|
||||
|
@ -108,37 +99,8 @@ struct GJGarageLayerTest : Modify<GJGarageLayerTest, GJGarageLayer> {
|
|||
addChild(label2);
|
||||
|
||||
// Dispatch system pt. 1
|
||||
// auto fn = Dispatcher::get()->getFunction<void(GJGarageLayer*)>("test-garage-open");
|
||||
// fn(this);
|
||||
MyDispatchEvent("test-garage-open"_spr, this).post();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/*// Event system pt. 2
|
||||
int a = (0, []() {
|
||||
|
||||
Dispatcher::get()->addSelector("test-garage-open", [](GJGarageLayer* gl) {
|
||||
auto label = CCLabelBMFont::create("EventCenter works!", "bigFont.fnt");
|
||||
label->setPosition(100, 80);
|
||||
label->setScale(.4f);
|
||||
label->setZOrder(99999);
|
||||
gl->addChild(label);
|
||||
|
||||
TestDependency::depTest(gl);
|
||||
});
|
||||
|
||||
// Event system pt. 2
|
||||
// $observe("test-garage-open", GJGarageLayer*, evt) {
|
||||
// auto gl = evt.object();
|
||||
// auto label = CCLabelBMFont::create("EventCenter works!", "bigFont.fnt");
|
||||
// label->setPosition(100, 80);
|
||||
// label->setScale(.4f);
|
||||
// label->setZOrder(99999);
|
||||
// gl->addChild(label);
|
||||
|
||||
// // API pt. 2
|
||||
// TestDependency::depTest(gl);
|
||||
// }
|
||||
return 0;
|
||||
}());*/
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
{
|
||||
"id": "geode.testdep",
|
||||
"version": ">=1.0.0",
|
||||
"required": true
|
||||
"importance": "required"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
#define EXPORT_NAME TestDependency
|
||||
#include <Geode/Loader.hpp>
|
||||
|
||||
API_INIT("com.geode.testdep")
|
||||
|
||||
class TestDependency {
|
||||
public:
|
||||
static void depTest(GJGarageLayer* gl);
|
||||
// API_DECL(&TestDependency::depTest, gl);
|
||||
};
|
Loading…
Reference in a new issue