Skip to content

Commit

Permalink
Android bugfixes and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaghettDev committed Mar 13, 2024
1 parent 85b7bee commit 4cffd1f
Show file tree
Hide file tree
Showing 16 changed files with 163 additions and 38 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/custom_layers/RLIntegerInputLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -100,7 +100,7 @@ void RLIntegerInputLayer::onClose(CCObject*)
{
m_integer = m_iili.starting_value.value_or(0);
}

m_iili.onFinish(this);

this->setKeypadEnabled(false);
Expand Down
1 change: 1 addition & 0 deletions src/custom_layers/RLIntegerInputLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct IntegerInputInfo
int fallback_value;
int max_value; // inclusive
std::optional<int> starting_value;
int max_length;
bool show_arrows;
std::function<void(RLIntegerInputLayer*)> onFinish;
};
Expand Down
5 changes: 4 additions & 1 deletion src/custom_layers/base/BaseCustomAlertLayer.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#pragma once
#include <limits>
#include <string>

#include <Geode/Bindings.hpp>
#include <Geode/cocos/include/ccTypes.h>
#include <Geode/cocos/cocoa/CCObject.h>
#include <Geode/binding/CCMenuItemSpriteExtra.hpp>

using namespace geode::prelude;

Expand Down
7 changes: 3 additions & 4 deletions src/custom_nodes/RLDifficultyNode.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#pragma once
// #include <Geode/cocos/base_nodes/CCNode.h>
// #include <Geode/cocos/sprite_nodes/CCSprite.h>
// #include <Geode/cocos/include/ccTypes.h>
#include <Geode/Geode.hpp>
#include <Geode/cocos/base_nodes/CCNode.h>
#include <Geode/cocos/sprite_nodes/CCSprite.h>
#include <Geode/cocos/include/ccTypes.h>

using namespace geode::prelude;

Expand Down
79 changes: 79 additions & 0 deletions src/custom_nodes/RLLoadingCircle.cpp
Original file line number Diff line number Diff line change
@@ -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();
}
29 changes: 29 additions & 0 deletions src/custom_nodes/RLLoadingCircle.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once
#include <Geode/cocos/sprite_nodes/CCSprite.h>
#include <Geode/cocos/actions/CCActionInterval.h>

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
};
};
1 change: 0 additions & 1 deletion src/layers/CreatorLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "../roulette/manager/RouletteManager.hpp"
#include "../roulette/layers/RLRouletteLayer.hpp"

#include <Geode/Geode.hpp>
#include <Geode/modify/CreatorLayer.hpp>

using namespace geode::prelude;
Expand Down
1 change: 0 additions & 1 deletion src/layers/LevelInfoLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "../roulette/manager/RouletteManager.hpp"
#include "../roulette/layers/RLRouletteLayer.hpp"

#include <Geode/Geode.hpp>
#include <Geode/modify/LevelInfoLayer.hpp>

using namespace geode::prelude;
Expand Down
1 change: 0 additions & 1 deletion src/layers/PauseLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "../roulette/manager/RouletteManager.hpp"
#include "../roulette/layers/RLRouletteLayer.hpp"

#include <Geode/Geode.hpp>
#include <Geode/modify/PauseLayer.hpp>

using namespace geode::prelude;
Expand Down
1 change: 0 additions & 1 deletion src/layers/PlayLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "../roulette/manager/RouletteManager.hpp"

#include <Geode/Geode.hpp>
#include <Geode/modify/PlayLayer.hpp>
#include <Geode/modify/GJBaseGameLayer.hpp>

Expand Down
6 changes: 4 additions & 2 deletions src/roulette/layers/RLRouletteInfoLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ void RLRouletteInfoLayer::onNumSkipsButton(CCObject*)
{
m_integer_input_layer = RLIntegerInputLayer::create({
"Number Of Skips", "Skips", 0, 3, 9999,
static_cast<int>(Mod::get()->getSettingValue<int64_t>("max-skips")), true,
static_cast<int>(Mod::get()->getSettingValue<int64_t>("max-skips")),
4, true,
[&](auto iil) {
Mod::get()->setSettingValue<int64_t>("max-skips", iil->m_integer);
}
Expand Down Expand Up @@ -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<int>(g_rouletteManager.gdListID), false,
g_rouletteManager.gdListID == 0 ? std::nullopt : std::optional<int>(g_rouletteManager.gdListID),
10, false,
[&](auto iil) {
g_rouletteManager.gdListID = iil->m_integer;
Mod::get()->setSavedValue<uint64_t>("gdListID", static_cast<uint64_t>(iil->m_integer));
Expand Down
1 change: 0 additions & 1 deletion src/roulette/layers/RLRouletteInfoLayer.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once
#include "../../custom_layers/base/BaseCustomAlertLayer.hpp"
#include "../../custom_layers/RLIntegerInputLayer.hpp"
#include <Geode/Bindings.hpp>

using namespace geode::prelude;

Expand Down
35 changes: 17 additions & 18 deletions src/roulette/layers/RLRouletteLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Geode/Geode.hpp>
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -505,7 +506,7 @@ void RLRouletteLayer::onNextButton(CCObject*)

if (g_rouletteManager.currentLevelPercentage == 100)
{
onNextLevel(false, false);
onNextLevel();

static_cast<CCLabelBMFont*>(finished_menu->getChildByID("skips-label"))->setString(
fmt::format("Skips Used: {}", g_rouletteManager.skipsUsed).c_str()
Expand All @@ -521,7 +522,7 @@ void RLRouletteLayer::onNextButton(CCObject*)
{
g_rouletteManager.hasFinishedPreviousLevel = false;

onNextLevel(false, true, -125.f);
onNextLevel(false, true, 40.f);

static_cast<CCLabelBMFont*>(
playing_menu->getChildByID("percentage-text")
Expand Down Expand Up @@ -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*)
Expand All @@ -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,
Expand All @@ -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())
{
Expand All @@ -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;
Expand Down Expand Up @@ -654,20 +654,19 @@ 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++)
playing_menu->getChildByTag(i)->setVisible(levelTextVisible);
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()
Expand Down
7 changes: 3 additions & 4 deletions src/roulette/layers/RLRouletteLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
#include "../../custom_layers/base/BaseCustomAlertLayer.hpp"
#include "../../custom_layers/RLConfirmationAlertLayer.hpp"
#include "../../custom_layers/RLDifficultySelectLayer.hpp"

#include <Geode/Bindings.hpp>
#include "../../custom_nodes/RLLoadingCircle.hpp"

#include <rtrp/objects/LevelObject.hpp>

Expand All @@ -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{};
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 4cffd1f

Please sign in to comment.