2022-10-13 06:07:37 -04:00
|
|
|
#include <Geode/Loader.hpp>
|
2022-07-30 12:24:03 -04:00
|
|
|
|
|
|
|
USE_GEODE_NAMESPACE();
|
|
|
|
|
2022-11-09 13:03:53 -05:00
|
|
|
auto test = []() {
|
2022-10-08 09:53:09 -04:00
|
|
|
log::info("Static logged");
|
|
|
|
return 0;
|
|
|
|
};
|
|
|
|
|
2022-07-30 12:24:03 -04:00
|
|
|
// Exported functions
|
2022-11-12 07:55:25 -05:00
|
|
|
$on_mod(Enabled) {
|
2022-11-09 13:03:53 -05:00
|
|
|
log::info("Enabled");
|
2022-07-30 12:24:03 -04:00
|
|
|
}
|
2022-11-12 07:55:25 -05:00
|
|
|
$on_mod(Disabled) {
|
2022-11-09 13:03:53 -05:00
|
|
|
log::info("Disabled");
|
2022-07-30 12:24:03 -04:00
|
|
|
}
|
2022-11-12 07:55:25 -05:00
|
|
|
$on_mod(Loaded) {
|
2022-11-09 13:03:53 -05:00
|
|
|
log::info("Loaded");
|
2022-07-30 12:24:03 -04:00
|
|
|
}
|
2022-11-12 07:55:25 -05:00
|
|
|
$on_mod(Unloaded) {
|
2022-11-09 13:03:53 -05:00
|
|
|
log::info("Unloaded");
|
2022-07-30 12:24:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Modify
|
2022-10-13 07:00:41 -04:00
|
|
|
#include <Geode/modify/GJGarageLayer.hpp>
|
2022-11-09 13:03:53 -05:00
|
|
|
|
|
|
|
struct GJGarageLayerTest : Modify<GJGarageLayerTest, GJGarageLayer> {
|
|
|
|
GJGarageLayerTest() : myValue(1907) {}
|
|
|
|
|
|
|
|
int myValue;
|
|
|
|
std::string myString = "yeah have fun finding a better thing for this";
|
|
|
|
|
|
|
|
bool init() {
|
|
|
|
if (!GJGarageLayer::init()) return false;
|
|
|
|
|
|
|
|
auto label = CCLabelBMFont::create("Modify works!", "bigFont.fnt");
|
|
|
|
label->setPosition(100, 110);
|
|
|
|
label->setScale(.4f);
|
|
|
|
label->setZOrder(99999);
|
|
|
|
addChild(label);
|
|
|
|
|
|
|
|
if (m_fields->myValue == 1907 && m_fields->myString != "") {
|
|
|
|
auto label = CCLabelBMFont::create("Field default works!", "bigFont.fnt");
|
|
|
|
label->setPosition(100, 100);
|
|
|
|
label->setScale(.4f);
|
|
|
|
label->setZOrder(99999);
|
|
|
|
addChild(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Data Store
|
|
|
|
auto ds = Mod::get()->getDataStore();
|
|
|
|
int out = ds["times-opened"];
|
|
|
|
ds["times-opened"] = out + 1;
|
|
|
|
|
|
|
|
std::string text = std::string("Times opened: ") + std::to_string(out);
|
|
|
|
|
|
|
|
auto label2 = CCLabelBMFont::create(text.c_str(), "bigFont.fnt");
|
|
|
|
label2->setPosition(100, 90);
|
|
|
|
label2->setScale(.4f);
|
|
|
|
label2->setZOrder(99999);
|
|
|
|
addChild(label2);
|
|
|
|
|
|
|
|
// Dispatch system pt. 1
|
|
|
|
// auto fn = Dispatcher::get()->getFunction<void(GJGarageLayer*)>("test-garage-open");
|
|
|
|
// fn(this);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2022-07-30 12:24:03 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*// Event system pt. 2
|
|
|
|
int a = (0, []() {
|
|
|
|
|
2022-11-09 13:03:53 -05:00
|
|
|
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);
|
2022-07-30 12:24:03 -04:00
|
|
|
|
2022-11-09 13:03:53 -05:00
|
|
|
TestDependency::depTest(gl);
|
|
|
|
});
|
2022-07-30 12:24:03 -04:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
// }
|
2022-11-09 13:03:53 -05:00
|
|
|
return 0;
|
2022-07-30 12:24:03 -04:00
|
|
|
}());*/
|