From c26d2211d3cab787d331f4451aa60a5099442ca5 Mon Sep 17 00:00:00 2001 From: Jouca Date: Tue, 16 Jul 2024 02:17:33 +0900 Subject: [PATCH] Added daily/weekly button notifications & removed the one for daily chests --- src/Notifications/DailyChest.cpp | 7 +++++-- src/Notifications/EventsPush.cpp | 13 +++++++++---- src/main.cpp | 19 +++++++++++-------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/Notifications/DailyChest.cpp b/src/Notifications/DailyChest.cpp index eef7a1d..2b44eed 100644 --- a/src/Notifications/DailyChest.cpp +++ b/src/Notifications/DailyChest.cpp @@ -1,6 +1,9 @@ #include "DailyChest.h" #include "EventsPush.h" +static GJRewardItem* time1 = nullptr; +static GJRewardItem* time2 = nullptr; + void DailyChest::getRewards(unsigned int type) { GameLevelManager* glm = GameLevelManager::sharedState(); glm->m_GJRewardDelegate = this; @@ -16,8 +19,8 @@ void DailyChest::rewardsStatusFinished(int p0) { // Get the rewards int time1_value = 0x1; int time2_value = 0x2; - GJRewardItem* time1 = typeinfo_cast(gsm->m_rewardItems->objectForKey(time1_value)); - GJRewardItem* time2 = typeinfo_cast(gsm->m_rewardItems->objectForKey(time2_value)); + time1 = typeinfo_cast(gsm->m_rewardItems->objectForKey(time1_value)); + time2 = typeinfo_cast(gsm->m_rewardItems->objectForKey(time2_value)); sio::message::ptr msg = sio::object_message::create(); msg->get_map()["sprite"] = sio::string_message::create("GJ_square04.png"); diff --git a/src/Notifications/EventsPush.cpp b/src/Notifications/EventsPush.cpp index 3ce2d5c..7757132 100644 --- a/src/Notifications/EventsPush.cpp +++ b/src/Notifications/EventsPush.cpp @@ -1,5 +1,6 @@ #include "EventsPush.h" #include "../Settings/CustomSettings.hpp" +#include "DailyChest.h" #include "Geode/utils/general.hpp" #include #include @@ -295,10 +296,11 @@ void EventsPush::onClickBtn(CCObject* ret) { if (layer == nullptr) return; auto events_layer = reinterpret_cast(scene->getChildByTag(1932)); if (events_layer == nullptr) return; - if (events_layer->level->m_levelID == 0) return; std::string layerName = typeid(*layer).name() + 6; if (layerName != "PlayLayer" && layerName != "PauseLayer" && layerName != "LevelEditorLayer") { // redirect to level if (eventType == EventType::Rate) { + if (events_layer->level->m_levelID == 0) return; + std::string const& url = "http://www.boomlings.com/database/getGJLevels21.php"; #ifndef GEODE_IS_MACOS int level_id = events_layer->level->m_levelID.value(); @@ -351,12 +353,15 @@ void EventsPush::onClickBtn(CCObject* ret) { ) ); } else if (eventType == EventType::Daily) { - //DailyLevelPage::create(eventType == EventType::Weekly)->show(); + DailyLevelPage::create(GJTimedLevelType::Daily)->show(); + return; + } else if (eventType == EventType::Weekly) { + DailyLevelPage::create(GJTimedLevelType::Weekly)->show(); return; - } else if (eventType == EventType::smallChest || eventType == EventType::largeChest) { + } /*else if (eventType == EventType::smallChest) { RewardsPage::create()->show(); return; - } + }*/ } else { // copy to clipboard #ifndef GEODE_IS_MACOS clipboard::write(std::to_string(events_layer->level->m_levelID)); diff --git a/src/main.cpp b/src/main.cpp index f7042c3..b5f50c5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -95,12 +95,12 @@ bool setSocket(sio::socket::ptr sock) { } // Daily chests notifications -void dailyChestThread() { +/*void dailyChestThread() { while (true) { chestQueue.push(1); - std::this_thread::sleep_for(std::chrono::minutes(20)); + std::this_thread::sleep_for(std::chrono::minutes(1)); } -} +}*/ void start_socket_func() { while (true) { @@ -112,8 +112,8 @@ void start_socket_func() { sock.set_open_listener(&ConnectionHandler::onSuccess); sock.set_close_listener(&ConnectionHandler::onClose); sock.set_fail_listener(&ConnectionHandler::onFail); - sock.connect("http://gdutils.clarifygdps.com:13573"); - //sock.connect("http://gdutilstest.clarifygdps.com:46276"); + //sock.connect("http://gdutils.clarifygdps.com:13573"); + sock.connect("http://gdutilstest.clarifygdps.com:46276"); if (!connect_finish) { cond.wait(unique_lock); } @@ -169,10 +169,10 @@ class $modify(CCScheduler) { // used to be GameManager if (currentLayer != layerName) { currentLayer = layerName; EventsPush::stopNow(scene); - processChestEvent(scene); bool everywhereElse = Mod::get()->getSettingValue("everywhereElse"); if ((layerName != "LevelEditorLayer" && layerName != "PlayLayer") && !everywhereElse) return; if ((layerName != "LevelEditorLayer" && layerName != "PlayLayer") && everywhereElse) { + processChestEvent(scene); processEvent(scene); } } @@ -406,11 +406,11 @@ class $modify(MenuLayer) { bool init() { if (!MenuLayer::init()) return false; - if (!is_dailychest_ready) { + /*if (!is_dailychest_ready) { std::thread hThread(dailyChestThread); hThread.detach(); is_dailychest_ready = true; - } + }*/ return true; } @@ -419,6 +419,9 @@ class $modify(MenuLayer) { // When the socket connection is made $on_mod(Loaded) { log::info("GDUtils Mod Loaded"); + + chestQueue.push(1); + bool startSocketServer = Mod::get()->getSettingValue("socketServer"); if (startSocketServer) { current_socket = sio::socket::ptr();