diff --git a/changelog.md b/changelog.md index b9d76b8..9006aa8 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,5 @@ # v1.3.0 - Port to Geometry Dash 2.206 - - Increased leaderboards top to INFINITE - Daily chest notifications - Epic Gauntlets redesign diff --git a/src/Notifications/DailyChest.cpp b/src/Notifications/DailyChest.cpp index e4f75c2..eef7a1d 100644 --- a/src/Notifications/DailyChest.cpp +++ b/src/Notifications/DailyChest.cpp @@ -1,10 +1,5 @@ -#include "../includes.h" #include "DailyChest.h" #include "EventsPush.h" -#include - - -bool is_dailychest_ready = false; void DailyChest::getRewards(unsigned int type) { GameLevelManager* glm = GameLevelManager::sharedState(); @@ -56,26 +51,3 @@ void DailyChest::rewardsStatusFinished(int p0) { void DailyChest::rewardsStatusFailed() { log::error("Failed to get rewards"); }; - -// Daily chests notifications -void dailyChestThread() { - while (true) { - auto dailyChest = new DailyChest(); - dailyChest->getRewards(0); - - std::this_thread::sleep_for(std::chrono::minutes(20)); - } -} -class $modify(MenuLayer) { - bool init() { - if (!MenuLayer::init()) return false; - - if (!is_dailychest_ready) { - std::thread hThread(dailyChestThread); - hThread.detach(); - is_dailychest_ready = true; - } - - return true; - } -}; diff --git a/src/Notifications/DailyChest.h b/src/Notifications/DailyChest.h index 750233e..964b9c7 100644 --- a/src/Notifications/DailyChest.h +++ b/src/Notifications/DailyChest.h @@ -1,6 +1,7 @@ #pragma once #include +using namespace geode::prelude; class DailyChest : public CCNode, public GJRewardDelegate { public: diff --git a/src/Settings/CustomSettings.cpp b/src/Settings/CustomSettings.cpp index 521b40c..f76d80e 100644 --- a/src/Settings/CustomSettings.cpp +++ b/src/Settings/CustomSettings.cpp @@ -1,6 +1,8 @@ #include "CustomSettings.hpp" #include #include +#include "../Notifications/EventsPush.h" +#include "../includes.h" int cycleTypes = -1; SettingNode* SettingSectionValue::createNode(float width) { diff --git a/src/Settings/CustomSettings.hpp b/src/Settings/CustomSettings.hpp index c49c0a6..dec5a6f 100644 --- a/src/Settings/CustomSettings.hpp +++ b/src/Settings/CustomSettings.hpp @@ -2,8 +2,7 @@ #include #include "CreditsBetaMenu.h" #include "CreditsMenu.h" -#include "../Notifications/EventsPush.h" -#include "../includes.h" +#include using namespace geode::prelude; /* @@ -518,7 +517,7 @@ class SettingAppNode : public SettingNode { )->show(); } public: - InputNode* defaultApp_input = InputNode::create(180.0F, "Application", "bigFont.fnt", "", 1); + TextInput* defaultApp_input = TextInput::create(180.0F, "Application", "bigFont.fnt"); void commit() override { static_cast(m_value)->setApp(m_currentApp); this->dispatchCommitted(); diff --git a/src/main.cpp b/src/main.cpp index 943fcf5..5f81ed1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include "includes.h" @@ -18,9 +19,9 @@ #include #include #include -#include #include #include +#include "Notifications/DailyChest.h" #include static std::unordered_map RUNNING_REQUESTS {}; @@ -36,6 +37,7 @@ bool event_fired = false; std::queue dataQueue; +std::queue chestQueue; sio::message::ptr event_data = nullptr; std::mutex lock; @@ -78,7 +80,7 @@ namespace ConnectionHandler { bool setSocket(sio::socket::ptr sock) { current_socket = sock; log::info("listening for events"); - current_socket->emit("geode-" + Mod::get()->getVersion().toString()); + current_socket->emit(fmt::format("geode-{}", Mod::get()->getVersion())); current_socket->on("rate", sio::socket::event_listener_aux([&](std::string const& user, sio::message::ptr const& data, bool isAck, sio::message::list &ack_resp) { log::info("call rate event"); event_fired = true; @@ -91,6 +93,14 @@ bool setSocket(sio::socket::ptr sock) { return true; } +// Daily chests notifications +void dailyChestThread() { + while (true) { + chestQueue.push(1); + std::this_thread::sleep_for(std::chrono::minutes(20)); + } +} + void start_socket_func() { while (true) { log::info("Starting socket..."); @@ -130,6 +140,15 @@ void processEvent(CCScene* self) { } } +void processChestEvent(CCScene* self) { + if (!chestQueue.empty()) { + auto data = chestQueue.front(); + chestQueue.pop(); + auto dailyChest = new DailyChest(); + dailyChest->getRewards(0); + } +} + class $modify(CCScheduler) { // used to be GameManager void update(float dt) { CCScheduler::update(dt); @@ -148,6 +167,7 @@ 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) { @@ -377,6 +397,22 @@ class $modify(CCScale9Sprite) { } }; +bool is_dailychest_ready = false; + +class $modify(MenuLayer) { + bool init() { + if (!MenuLayer::init()) return false; + + if (!is_dailychest_ready) { + std::thread hThread(dailyChestThread); + hThread.detach(); + is_dailychest_ready = true; + } + + return true; + } +}; + // When the socket connection is made $on_mod(Loaded) { log::info("GDUtils Mod Loaded");