2022-10-13 06:07:37 -04:00
|
|
|
#include <Geode/Loader.hpp>
|
2023-01-21 09:00:14 -05:00
|
|
|
#include <Geode/loader/ModEvent.hpp>
|
2023-04-07 13:07:16 -04:00
|
|
|
#include <Geode/utils/cocos.hpp>
|
2023-04-03 03:04:56 -04:00
|
|
|
#include "../dependency/main.hpp"
|
2022-07-30 12:24:03 -04:00
|
|
|
|
2023-03-10 14:33:24 -05:00
|
|
|
using namespace geode::prelude;
|
2022-07-30 12:24:03 -04:00
|
|
|
|
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(Loaded) {
|
2022-11-09 13:03:53 -05:00
|
|
|
log::info("Loaded");
|
2022-07-30 12:24:03 -04:00
|
|
|
}
|
|
|
|
|
2024-02-25 02:38:46 -05:00
|
|
|
static std::string s_recievedEvent;
|
|
|
|
|
2023-04-03 03:04:56 -04:00
|
|
|
// Events
|
|
|
|
$execute {
|
|
|
|
new EventListener<TestEventFilter>(+[](TestEvent* event) {
|
|
|
|
log::info("Received event: {}", event->getData());
|
2024-02-25 02:38:46 -05:00
|
|
|
s_recievedEvent = event->getData();
|
2023-04-03 03:04:56 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-07 13:07:16 -04:00
|
|
|
#include <Geode/modify/MenuLayer.hpp>
|
|
|
|
struct $modify(MenuLayer) {
|
|
|
|
bool init() {
|
|
|
|
if (!MenuLayer::init())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto node = CCNode::create();
|
|
|
|
auto ref = WeakRef(node);
|
|
|
|
log::info("ref: {}", ref.lock().data());
|
|
|
|
node->release();
|
|
|
|
log::info("ref: {}", ref.lock().data());
|
|
|
|
|
2024-01-24 14:04:00 -05:00
|
|
|
// Launch arguments
|
|
|
|
log::info("Testing launch args...");
|
2024-11-16 05:01:22 -05:00
|
|
|
log::NestScope nest;
|
2024-01-24 14:04:00 -05:00
|
|
|
log::info("For global context:");
|
2024-11-16 05:01:22 -05:00
|
|
|
{
|
|
|
|
log::NestScope nest;
|
|
|
|
for (const auto& arg : Loader::get()->getLaunchArgumentNames()) {
|
|
|
|
log::info("{}", arg);
|
|
|
|
}
|
2024-01-24 14:04:00 -05:00
|
|
|
}
|
|
|
|
log::info("For this mod:");
|
2024-11-16 05:01:22 -05:00
|
|
|
{
|
|
|
|
log::NestScope nest;
|
|
|
|
for (const auto& arg : Mod::get()->getLaunchArgumentNames()) {
|
|
|
|
log::info("{}", arg);
|
|
|
|
}
|
2024-01-24 14:04:00 -05:00
|
|
|
}
|
2024-01-28 11:00:39 -05:00
|
|
|
log::info("Mod has launch arg 'mod-arg': {}", Mod::get()->hasLaunchArgument("mod-arg"));
|
|
|
|
log::info("Loader flag 'bool-arg': {}", Loader::get()->getLaunchFlag("bool-arg"));
|
2024-11-09 01:05:16 -05:00
|
|
|
log::info("Loader int 'int-arg': {}", Loader::get()->parseLaunchArgument<int>("int-arg").unwrapOr(0));
|
2024-01-24 14:04:00 -05:00
|
|
|
|
2024-11-16 06:53:21 -05:00
|
|
|
log::debug("should run second!");
|
|
|
|
|
2023-04-07 13:07:16 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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> {
|
2024-06-03 16:04:22 -04:00
|
|
|
struct Fields {
|
|
|
|
int myValue = 1907;
|
|
|
|
std::string myString = "yeah have fun finding a better thing for this";
|
|
|
|
};
|
2022-11-09 13:03:53 -05:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2022-11-28 13:17:58 -05:00
|
|
|
// Saved Values
|
|
|
|
auto timesOpened = Mod::get()->getSavedValue<int64_t>("times-opened", 0);
|
|
|
|
Mod::get()->setSavedValue("times-opened", timesOpened + 1);
|
|
|
|
|
|
|
|
auto label2 = CCLabelBMFont::create(
|
|
|
|
fmt::format("Times opened: {}", timesOpened).c_str(),
|
|
|
|
"bigFont.fnt"
|
|
|
|
);
|
2022-11-09 13:03:53 -05:00
|
|
|
label2->setPosition(100, 90);
|
|
|
|
label2->setScale(.4f);
|
|
|
|
label2->setZOrder(99999);
|
|
|
|
addChild(label2);
|
|
|
|
|
|
|
|
// Dispatch system pt. 1
|
2024-02-25 02:38:46 -05:00
|
|
|
MyDispatchEvent("geode.test/test-garage-open", this).post();
|
|
|
|
|
|
|
|
if (s_recievedEvent.size() > 0) {
|
|
|
|
auto label = CCLabelBMFont::create("Event works!", "bigFont.fnt");
|
|
|
|
label->setPosition(100, 70);
|
|
|
|
label->setScale(.4f);
|
|
|
|
label->setZOrder(99999);
|
|
|
|
addChild(label);
|
|
|
|
}
|
2022-11-09 13:03:53 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2022-07-30 12:24:03 -04:00
|
|
|
};
|
2024-04-21 17:09:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
#include <Geode/modify/GJGarageLayer.hpp>
|
|
|
|
|
|
|
|
struct GJGarageLayerTest2 : Modify<GJGarageLayerTest2, GJGarageLayer> {
|
|
|
|
struct Fields {
|
|
|
|
int myOtherValue = 80085;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool init() {
|
|
|
|
if (!GJGarageLayer::init()) return false;
|
|
|
|
|
|
|
|
if (m_fields->myOtherValue == 80085) {
|
|
|
|
auto label = CCLabelBMFont::create("Alternate Fields works!", "bigFont.fnt");
|
|
|
|
label->setPosition(100, 60);
|
|
|
|
label->setScale(.4f);
|
|
|
|
label->setZOrder(99999);
|
|
|
|
this->addChild(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|