diff --git a/CHANGELOG.md b/CHANGELOG.md index 955da45..913c767 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [2.0.4] - 2024-03-13 + +### Added + +- `RLLoadingCircle`, a better LoadingCircle lol + +### Changed + +- Cleaned up `#include`s in header files + +### Fixed + +- 5 Character limit in `RLIntegerInputLayer` +- `LoadingCircle` in wrong position on Android + ## [2.0.3] - 2024-03-09 ### Changed diff --git a/mod.json b/mod.json index a6a02ce..a7d9d02 100644 --- a/mod.json +++ b/mod.json @@ -1,16 +1,20 @@ { - "geode": "2.0.0-beta.21", + "geode": "2.0.0-beta.22", "gd": { "win": "2.204", "android": "2.205", "mac": "2.200" }, - "version": "v2.0.3", + "version": "v2.0.4", "id": "spaghettdev.gd-roulette", "name": "GD-Roulette", "developer": "SpaghettDev", "description": "An in-game level roulette.", "repository": "https://github.com/SpaghettDev/GD-Roulette", + "links": { + "community": "https://discord.gg/3bShQb6Jz3", + "source": "https://github.com/SpaghettDev/GD-Roulette" + }, "issues": { "info": "Report any bugs/suggestions here.", "url": "https://github.com/SpaghettDev/GD-Roulette/issues" diff --git a/src/custom_layers/RLIntegerInputLayer.cpp b/src/custom_layers/RLIntegerInputLayer.cpp index 8cd10c1..b87035e 100644 --- a/src/custom_layers/RLIntegerInputLayer.cpp +++ b/src/custom_layers/RLIntegerInputLayer.cpp @@ -70,7 +70,7 @@ bool RLIntegerInputLayer::init(const IntegerInputInfo& iili) input_node->setString(fmt::format("{}", m_iili.starting_value.value()).c_str()); input_node->setAllowedChars("0123456789"); input_node->setMaxLabelScale(.5f); - input_node->setMaxLabelLength(5); + input_node->setMaxLabelLength(m_iili.max_length); input_node->setPosition({ .0f, 5.f }); input_node->setID("input-node"); m_buttonMenu->addChild(input_node); @@ -100,7 +100,7 @@ void RLIntegerInputLayer::onClose(CCObject*) { m_integer = m_iili.starting_value.value_or(0); } - + m_iili.onFinish(this); this->setKeypadEnabled(false); diff --git a/src/custom_layers/RLIntegerInputLayer.hpp b/src/custom_layers/RLIntegerInputLayer.hpp index 21a9eec..7ca991e 100644 --- a/src/custom_layers/RLIntegerInputLayer.hpp +++ b/src/custom_layers/RLIntegerInputLayer.hpp @@ -15,6 +15,7 @@ struct IntegerInputInfo int fallback_value; int max_value; // inclusive std::optional starting_value; + int max_length; bool show_arrows; std::function onFinish; }; diff --git a/src/custom_layers/base/BaseCustomAlertLayer.hpp b/src/custom_layers/base/BaseCustomAlertLayer.hpp index edf462b..05746dd 100644 --- a/src/custom_layers/base/BaseCustomAlertLayer.hpp +++ b/src/custom_layers/base/BaseCustomAlertLayer.hpp @@ -1,7 +1,10 @@ #pragma once #include +#include -#include +#include +#include +#include using namespace geode::prelude; diff --git a/src/custom_nodes/RLDifficultyNode.hpp b/src/custom_nodes/RLDifficultyNode.hpp index 78d02cd..69a43c2 100644 --- a/src/custom_nodes/RLDifficultyNode.hpp +++ b/src/custom_nodes/RLDifficultyNode.hpp @@ -1,8 +1,7 @@ #pragma once -// #include -// #include -// #include -#include +#include +#include +#include using namespace geode::prelude; diff --git a/src/custom_nodes/RLLoadingCircle.cpp b/src/custom_nodes/RLLoadingCircle.cpp new file mode 100644 index 0000000..756b6c5 --- /dev/null +++ b/src/custom_nodes/RLLoadingCircle.cpp @@ -0,0 +1,79 @@ +// not taken from https://github.com/acaruso-xx/slope-geode/blob/main/src/plate/LoadingCircle.cpp +#include "RLLoadingCircle.hpp" + +RLLoadingCircle* RLLoadingCircle::create() +{ + auto ret = new RLLoadingCircle(); + + if (ret && ret->init()) + ret->autorelease(); + else + { + delete ret; + ret = nullptr; + } + + return ret; +} + +bool RLLoadingCircle::init() +{ + if (!this->initWithFile("loadingCircle.png")) return false; + + this->setBlendFunc({ GL_SRC_ALPHA, GL_ONE }); + this->setOpacity(0); + this->setZOrder(105); + + return true; +} + +void RLLoadingCircle::positionCenter() +{ + this->setPosition(cocos2d::CCDirector::sharedDirector()->getWinSize() / 2); +} + +void RLLoadingCircle::fadeIn() +{ + auto* fadeInAction = cocos2d::CCFadeTo::create(.4f, 200); + fadeInAction->setTag(ACTION_TAG::FADE_IN); + + this->runAction(fadeInAction); +} + +void RLLoadingCircle::fadeOut() +{ + this->stopActionByTag(ACTION_TAG::FADE_IN); + this->stopActionByTag(ACTION_TAG::ROTATE); + + auto* fadeOutAction = cocos2d::CCFadeTo::create(.4f, 0); + fadeOutAction->setTag(ACTION_TAG::FADE_OUT); + + this->runAction(fadeOutAction); +} + +void RLLoadingCircle::startRotate() +{ + auto* rotateAction = cocos2d::CCRepeatForever::create( + cocos2d::CCRotateBy::create(1.f, 360.f) + ); + rotateAction->setTag(ACTION_TAG::ROTATE); + + this->runAction(rotateAction); +} + +void RLLoadingCircle::stopRotate() +{ + this->stopActionByTag(ACTION_TAG::ROTATE); +} + +void RLLoadingCircle::show() +{ + fadeIn(); + startRotate(); +} + +void RLLoadingCircle::stopAndHide() +{ + stopRotate(); + fadeOut(); +} diff --git a/src/custom_nodes/RLLoadingCircle.hpp b/src/custom_nodes/RLLoadingCircle.hpp new file mode 100644 index 0000000..37d2f44 --- /dev/null +++ b/src/custom_nodes/RLLoadingCircle.hpp @@ -0,0 +1,29 @@ +#pragma once +#include +#include + +class RLLoadingCircle : public cocos2d::CCSprite +{ +public: + static RLLoadingCircle* create(); + + bool init() override; + + void positionCenter(); + + void fadeIn(); + void fadeOut(); + void startRotate(); + void stopRotate(); + + void show(); + void stopAndHide(); + +private: + enum ACTION_TAG : int + { + FADE_IN, + FADE_OUT, + ROTATE + }; +}; diff --git a/src/layers/CreatorLayer.cpp b/src/layers/CreatorLayer.cpp index 16ad77e..0215bab 100644 --- a/src/layers/CreatorLayer.cpp +++ b/src/layers/CreatorLayer.cpp @@ -1,7 +1,6 @@ #include "../roulette/manager/RouletteManager.hpp" #include "../roulette/layers/RLRouletteLayer.hpp" -#include #include using namespace geode::prelude; diff --git a/src/layers/LevelInfoLayer.cpp b/src/layers/LevelInfoLayer.cpp index 652e52c..652353f 100644 --- a/src/layers/LevelInfoLayer.cpp +++ b/src/layers/LevelInfoLayer.cpp @@ -3,7 +3,6 @@ #include "../roulette/manager/RouletteManager.hpp" #include "../roulette/layers/RLRouletteLayer.hpp" -#include #include using namespace geode::prelude; diff --git a/src/layers/PauseLayer.cpp b/src/layers/PauseLayer.cpp index eb7c53f..c94a945 100644 --- a/src/layers/PauseLayer.cpp +++ b/src/layers/PauseLayer.cpp @@ -1,7 +1,6 @@ #include "../roulette/manager/RouletteManager.hpp" #include "../roulette/layers/RLRouletteLayer.hpp" -#include #include using namespace geode::prelude; diff --git a/src/layers/PlayLayer.cpp b/src/layers/PlayLayer.cpp index 354b605..3a6f6fa 100644 --- a/src/layers/PlayLayer.cpp +++ b/src/layers/PlayLayer.cpp @@ -1,6 +1,5 @@ #include "../roulette/manager/RouletteManager.hpp" -#include #include #include diff --git a/src/roulette/layers/RLRouletteInfoLayer.cpp b/src/roulette/layers/RLRouletteInfoLayer.cpp index cf655fe..d309f02 100644 --- a/src/roulette/layers/RLRouletteInfoLayer.cpp +++ b/src/roulette/layers/RLRouletteInfoLayer.cpp @@ -209,7 +209,8 @@ void RLRouletteInfoLayer::onNumSkipsButton(CCObject*) { m_integer_input_layer = RLIntegerInputLayer::create({ "Number Of Skips", "Skips", 0, 3, 9999, - static_cast(Mod::get()->getSettingValue("max-skips")), true, + static_cast(Mod::get()->getSettingValue("max-skips")), + 4, true, [&](auto iil) { Mod::get()->setSettingValue("max-skips", iil->m_integer); } @@ -268,7 +269,8 @@ void RLRouletteInfoLayer::onIDButton(CCObject*) { m_integer_input_layer = RLIntegerInputLayer::create({ "List ID", "ID", 0, 0, INT_MAX, - g_rouletteManager.gdListID == 0 ? std::nullopt : std::optional(g_rouletteManager.gdListID), false, + g_rouletteManager.gdListID == 0 ? std::nullopt : std::optional(g_rouletteManager.gdListID), + 10, false, [&](auto iil) { g_rouletteManager.gdListID = iil->m_integer; Mod::get()->setSavedValue("gdListID", static_cast(iil->m_integer)); diff --git a/src/roulette/layers/RLRouletteInfoLayer.hpp b/src/roulette/layers/RLRouletteInfoLayer.hpp index 67ffd1b..f729949 100644 --- a/src/roulette/layers/RLRouletteInfoLayer.hpp +++ b/src/roulette/layers/RLRouletteInfoLayer.hpp @@ -1,7 +1,6 @@ #pragma once #include "../../custom_layers/base/BaseCustomAlertLayer.hpp" #include "../../custom_layers/RLIntegerInputLayer.hpp" -#include using namespace geode::prelude; diff --git a/src/roulette/layers/RLRouletteLayer.cpp b/src/roulette/layers/RLRouletteLayer.cpp index ae3c2b6..09e0ce0 100644 --- a/src/roulette/layers/RLRouletteLayer.cpp +++ b/src/roulette/layers/RLRouletteLayer.cpp @@ -5,8 +5,9 @@ #include "RLRouletteLayer.hpp" #include "RLRouletteInfoLayer.hpp" #include "../manager/RouletteManager.hpp" -#include "../../custom_nodes/RLDifficultyNode.hpp" #include "../../custom_layers/RLDifficultySelectLayer.hpp" +#include "../../custom_nodes/RLDifficultyNode.hpp" +#include "../../custom_nodes/RLLoadingCircle.hpp" #include "../../utils.hpp" #include @@ -144,10 +145,10 @@ bool RLRouletteLayer::init() main_menu->addChild(startButton); - m_loading_circle = LoadingCircle::create(); - m_loading_circle->setPosition({ -285.f, -170.f }); - m_loading_circle->setVisible(false); - m_buttonMenu->addChild(m_loading_circle); + m_loading_circle = RLLoadingCircle::create(); + m_loading_circle->positionCenter(); + m_loading_circle->fadeOut(); + m_mainLayer->addChild(m_loading_circle); auto levelNameButtonLabel = CCLabelBMFont::create("LevelName", "bigFont.fnt"); @@ -505,7 +506,7 @@ void RLRouletteLayer::onNextButton(CCObject*) if (g_rouletteManager.currentLevelPercentage == 100) { - onNextLevel(false, false); + onNextLevel(); static_cast(finished_menu->getChildByID("skips-label"))->setString( fmt::format("Skips Used: {}", g_rouletteManager.skipsUsed).c_str() @@ -521,7 +522,7 @@ void RLRouletteLayer::onNextButton(CCObject*) { g_rouletteManager.hasFinishedPreviousLevel = false; - onNextLevel(false, true, -125.f); + onNextLevel(false, true, 40.f); static_cast( playing_menu->getChildByID("percentage-text") @@ -561,7 +562,7 @@ void RLRouletteLayer::onResetButton(CCObject*) main_menu->getChildByID("start-button")->setVisible(true); main_menu->getChildByID("start-button")->setPositionY(-85.f); - m_loading_circle->setPositionY(-170.f); + m_loading_circle->positionCenter(); } void RLRouletteLayer::onSkipButton(CCObject*) @@ -580,7 +581,7 @@ void RLRouletteLayer::onSkipButton(CCObject*) g_rouletteManager.skipsUsed++; g_rouletteManager.hasFinishedPreviousLevel = false; - onNextLevel(false, true, -125.f); + onNextLevel(false, true, 40.f); getRandomListLevel( m_selected_difficulty == GJDifficulty::Demon ? m_selected_demon_difficulty : m_selected_difficulty, @@ -594,8 +595,7 @@ void RLRouletteLayer::onSkipButton(CCObject*) void RLRouletteLayer::finishLevelRoulette() { - m_loading_circle->stopAllActions(); - m_loading_circle->setVisible(false); + onNextLevel(false, false, 40.f); if (!m_list_fetcher_error.empty()) { @@ -607,7 +607,7 @@ void RLRouletteLayer::finishLevelRoulette() return; } - onNextLevel(true); + onNextLevel(true, false, 40.f); main_menu->setVisible(false); g_rouletteManager.currentLevelID = m_level.first.levelID; @@ -654,7 +654,7 @@ void RLRouletteLayer::finishLevelRoulette() playing_menu->setVisible(true); } -void RLRouletteLayer::onNextLevel(bool levelTextVisible, bool enableLoadingCircle, float loadingCirclePosY) +void RLRouletteLayer::onNextLevel(bool levelTextVisible, bool enableLoadingCircle, float loadingCirclePosYOffset) { // hides PlayingMenu's RLDifficultyNode, coins and level text for (int i = 1; i < 4; i++) @@ -662,12 +662,11 @@ void RLRouletteLayer::onNextLevel(bool levelTextVisible, bool enableLoadingCircl for (int i = 5; i < 9; i++) playing_menu->getChildByTag(i)->setVisible(false); - m_loading_circle->setPositionY(loadingCirclePosY); if (enableLoadingCircle) - { - m_loading_circle->setVisible(true); - m_loading_circle->runAction(CCRepeatForever::create(CCRotateBy::create(1.f, 360))); - } + m_loading_circle->show(); + else + m_loading_circle->stopAndHide(); + m_loading_circle->setPositionY(CCDirector::sharedDirector()->getWinSize().height / 2.f + loadingCirclePosYOffset); } void RLRouletteLayer::registerWithTouchDispatcher() diff --git a/src/roulette/layers/RLRouletteLayer.hpp b/src/roulette/layers/RLRouletteLayer.hpp index 387d9e9..e3b7e03 100644 --- a/src/roulette/layers/RLRouletteLayer.hpp +++ b/src/roulette/layers/RLRouletteLayer.hpp @@ -4,8 +4,7 @@ #include "../../custom_layers/base/BaseCustomAlertLayer.hpp" #include "../../custom_layers/RLConfirmationAlertLayer.hpp" #include "../../custom_layers/RLDifficultySelectLayer.hpp" - -#include +#include "../../custom_nodes/RLLoadingCircle.hpp" #include @@ -14,7 +13,7 @@ using namespace geode::prelude; class RLRouletteLayer : public BaseCustomAlertLayer { private: - LoadingCircle* m_loading_circle{}; + RLLoadingCircle* m_loading_circle{}; RLRouletteInfoLayer* m_roulette_info_layer{}; RLConfirmationAlertLayer* m_confirmation_layer{}; RLDifficultySelectLayer* m_demon_select_layer{}; @@ -49,7 +48,7 @@ class RLRouletteLayer : public BaseCustomAlertLayer void onResetButton(CCObject*); void finishLevelRoulette(); - void onNextLevel(bool = false, bool = false, float = -175.f); + void onNextLevel(bool = false, bool = false, float = .0f); void registerWithTouchDispatcher() override;