Skip to content

Commit

Permalink
Cleanup to release on index!
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaghettDev committed Feb 4, 2024
1 parent c0d7864 commit b176882
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 61 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ 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/).

## [1.6.0-beta.2] - 2024-02-04

### Changed

- assets/GD-Roulette.png
- Removed 1 unnecessary objectAtIndex

### Fixed

- Crash when on a fresh install of GD-Roulette

## [1.6.0-beta.1] - 2024-02-04

### Added
Expand Down
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
# GD-Roulette
A Geometry Dash Roulette.

<details>
A Geometry Dash Level Roulette.

<details open>
<summary>Image of the roulette</summary>
<br>
<img src="./assets/GD-Roulette.png" width="720"/>
</details>

## How to install
1. Download the latest release from the the [Releases tab](https://github.com/SpaghettDev/GD-Roulette/releases)
1. Copy the contents of the resources.zip from the downloaded release into the "Resources" folder of your Geometry Dash installation.
2. Then grab GD-Roulette.dll from the downloaded release and use you preferred injector to inject it into GeometryDash.exe
## How to install (from Geode)

## Errors
<details open>
<summary>Error Image</summary>
<br>
<img src="./assets/Resources-Error.png" width="480"/>
</details>
1. Get [Geode](https://geode-sdk.org)
2. Click the Geode button
3. Click the download tab, find GD-Roulette, and click Install!

You'll now find the roulette button after clicking the Create button on the main menu.

If you're getting the error above then you haven't installed the roulette correctly...
<br/>
Please follow the instructions in the [How to install](#how-to-install) part.
## How to install (from Releases)

1. Download the latest release's GD-Roulette.geode file
2. Copy it to `Geometry Dash/geode/mods`

## How to build

Run the following commands in your preferred terminal:

```sh
git clone https://github.com/SpaghettDev/GD-Roulette
cd GD-Roulette
mkdir build
cd build
cmake ..
```

Then open the generated solution in Visual Studio.

**Make sure to compile in Release Mode! Otherwise the solution will not compile.**

## Credits

- SpaghettDev ([@SpaghettDev](https://github.com/SpaghettDev)): Creator & maintainer.
- Skyue1 ([@Skyue1](https://github.com/Skyue1)): Added the featured/epic glow, and other stuff.
- qwix ([@qwix456](https://github.com/qwix456)): Added the featured/epic glow, and other stuff.
- iAndyHD3 ([@iAndyHD3](https://github.com/iAndyHD3)): Helped with issues.
- Cvolton ([@Cvolton](https://github.com/Cvolton)): Helped with issues. And the buttons (RL_blankBtn_001).
- Cvolton ([@Cvolton](https://github.com/Cvolton)): Helped with issues.
- Alphalaneous ([@Alphatism](https://github.com/Alphatism)): Helped with issues.
- mat ([@matcool](https://github.com/matcool)): Helped with Geode issues.
Binary file modified assets/GD-Roulette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/Resources-Error.png
Binary file not shown.
Binary file removed assets/resources.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"win": "2.204",
"android": "2.205"
},
"version": "v1.6.0-beta.1",
"version": "v1.6.0-beta.2",
"id": "spaghettdev.gd-roulette",
"name": "GD-Roulette",
"developer": "SpaghettDev",
Expand Down
5 changes: 2 additions & 3 deletions src/layers/CreatorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,24 @@ class $modify(RouletteButton, CreatorLayer)
{
if (!CreatorLayer::init()) return false;

auto layer = static_cast<CCMenu*>(this->getChildren()->objectAtIndex(1));
auto menu = CCMenu::create();
menu->setID("creator-layer-menu"_spr);
menu->setPosition({ .0f, .0f });
this->addChild(menu);

// Loader::get()->isModLoaded("absolllute.megahack")

// this is, well uhhh, very awful
auto rouletteButton = CCMenuItemSpriteExtra::create(
CCSprite::create("RL_blankBtn_001.png"_spr),
layer,
this,
menu_selector(RouletteButton::onRouletteButton)
);
auto rouletteSprite = CCSprite::create("RL_btn_001.png"_spr);
rouletteSprite->setScale(.725f);
rouletteSprite->setPosition({ 22.25f, 23.75f });
rouletteButton->addChild(rouletteSprite);
rouletteButton->setPosition({ 25.f, 160.f });
rouletteButton->setScale(.9f);

menu->addChild(rouletteButton);

Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "roulette/manager/RouletteManager.hpp"
#include <Geode/Geode.hpp>

using namespace geode::prelude;
Expand Down
8 changes: 4 additions & 4 deletions src/roulette/layers/RouletteInfoLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ void RouletteInfoLayer::onToggleButton(CCObject* sender)

auto button = static_cast<CCMenuItemToggler*>(sender);
auto parent = static_cast<CCMenu*>(button->getParent());
auto ind = roulette::utils::getIndexOf(g_rouletteManager.selectedListArr->as_array(), true);
auto ind = roulette::utils::getIndexOf(g_rouletteManager.getFromSaveContainer("selected-list-array").as_array(), true);

g_rouletteManager.selectedListArr->as_array().at(ind) = false;
g_rouletteManager.selectedListArr->as_array().at(button->getTag()) = true;
g_rouletteManager.getFromSaveContainer("selected-list-array").as_array().at(ind) = false;
g_rouletteManager.getFromSaveContainer("selected-list-array").as_array().at(button->getTag()) = true;

// purely visual, "toggles" the difficulty face based on the selected list (demon for demon list, insane for challenge list, and previous difficulty for normal list)
switch (button->getTag())
Expand Down Expand Up @@ -191,7 +191,7 @@ CCMenuItemToggler* RouletteInfoLayer::createToggler(int tag, const char* labelTe
// button->setSizeMult(1.2f);
button->setTag(tag);
button->setVisible(visible);
button->toggle(g_rouletteManager.selectedListArr->as_array().at(tag).as<bool>());
button->toggle(g_rouletteManager.getFromSaveContainer("selected-list-array").as_array().at(tag).as<bool>());
m_buttonMenu->addChild(button);

auto label = roulette::utils::createTextLabel(labelText, { point.x + 20, point.y }, .5f, m_buttonMenu);
Expand Down
46 changes: 23 additions & 23 deletions src/roulette/layers/RouletteLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ bool RouletteLayer::init()
plusButton->setPosition({ 135.f, -20.f });
plusButton->setSizeMult(1.2f);
plusButton->setTag(11);
plusButton->setVisible(g_rouletteManager.getArrayState(g_rouletteManager.difficultyArr, 5));
plusButton->setVisible(g_rouletteManager.getArrayState(g_rouletteManager.getFromSaveContainer("difficulty-array"), 5));
m_pMainMenu->addChild(plusButton);

auto startButtonText = CCLabelBMFont::create("Start", "bigFont.fnt");
Expand Down Expand Up @@ -347,7 +347,7 @@ bool RouletteLayer::init()
m_pErrorMenu->addChild(errorResetButton);


if (g_rouletteManager.getArrayState(g_rouletteManager.difficultyArr, 5))
if (g_rouletteManager.getArrayState(g_rouletteManager.getFromSaveContainer("difficulty-array"), 5))
{
if (RouletteLayer::m_plus_button_state)
{
Expand All @@ -356,7 +356,7 @@ bool RouletteLayer::init()
}

for (int i = 6; i < 11; i++)
if (g_rouletteManager.getArrayState(g_rouletteManager.demonDifficultyArr, i - 6))
if (g_rouletteManager.getArrayState(g_rouletteManager.getFromSaveContainer("demon-difficulty-array"), i - 6))
static_cast<CCMenuItemSpriteExtra*>(
m_pMainMenu->getChildByTag(i)
)->setColor({ 255, 255, 255 });
Expand Down Expand Up @@ -423,7 +423,7 @@ void RouletteLayer::onInfoButton(CCObject*)
void RouletteLayer::onDifficultyChosen(CCObject* sender)
{
if (
auto ind = roulette::utils::getIndexOf(g_rouletteManager.selectedListArr->as_array(), true);
auto ind = roulette::utils::getIndexOf(g_rouletteManager.getFromSaveContainer("selected-list-array").as_array(), true);
ind != 0
)
return;
Expand All @@ -434,41 +434,41 @@ void RouletteLayer::onDifficultyChosen(CCObject* sender)
// check if difficultyButton is one of the demon types and not a regular difficulty
if (tag > 5 && (tag < 10 || tag > 5))
{
int ind = roulette::utils::getIndexOf(g_rouletteManager.demonDifficultyArr->as_array(), true);
int ind = roulette::utils::getIndexOf(g_rouletteManager.getFromSaveContainer("demon-difficulty-array").as_array(), true);
static_cast<CCMenuItemSpriteExtra*>(
m_pMainMenu->getChildByTag(ind + 6)
)->setColor({ 125, 125, 125 });

g_rouletteManager.demonDifficultyArr->as_array().at(ind) = false;
g_rouletteManager.demonDifficultyArr->as_array().at(tag - 6) = true;
g_rouletteManager.getFromSaveContainer("demon-difficulty-array").as_array().at(ind) = false;
g_rouletteManager.getFromSaveContainer("demon-difficulty-array").as_array().at(tag - 6) = true;
}
else
{
if (m_plus_button_state && tag != 5)
onPlusButton(nullptr);

int ind = roulette::utils::getIndexOf(g_rouletteManager.difficultyArr->as_array(), true);
int ind = roulette::utils::getIndexOf(g_rouletteManager.getFromSaveContainer("difficulty-array").as_array(), true);
static_cast<CCMenuItemSpriteExtra*>(
m_pMainMenu->getChildByTag(ind)
)->setColor({ 125, 125, 125 });

g_rouletteManager.difficultyArr->as_array().at(ind) = false;
g_rouletteManager.difficultyArr->as_array().at(tag) = true;
g_rouletteManager.getFromSaveContainer("difficulty-array").as_array().at(ind) = false;
g_rouletteManager.getFromSaveContainer("difficulty-array").as_array().at(tag) = true;
g_rouletteManager.previousDifficulty = tag;
}

difficultyButton->setColor({ 255, 255, 255 });

// demon
m_pMainMenu->getChildByTag(11)->setVisible(g_rouletteManager.getArrayState(g_rouletteManager.difficultyArr, 5));
m_pMainMenu->getChildByTag(11)->setVisible(g_rouletteManager.getArrayState(g_rouletteManager.getFromSaveContainer("difficulty-array"), 5));
}

void RouletteLayer::onStartButton(CCObject*)
{
m_pMainMenu->setVisible(false);

int diffInd = roulette::utils::getIndexOf(g_rouletteManager.difficultyArr->as_array(), true);
int demonInd = roulette::utils::getIndexOf(g_rouletteManager.demonDifficultyArr->as_array(), true);
int diffInd = roulette::utils::getIndexOf(g_rouletteManager.getFromSaveContainer("difficulty-array").as_array(), true);
int demonInd = roulette::utils::getIndexOf(g_rouletteManager.getFromSaveContainer("demon-difficulty-array").as_array(), true);
int difficulty = diffInd == 5 ? (demonInd + 6) : (diffInd + 1);

getRandomListLevel(difficulty, m_level, m_list_fetcher_error);
Expand Down Expand Up @@ -586,8 +586,8 @@ void RouletteLayer::onNextButton(CCObject*)
m_pPlayingMenu->getChildByTag(20)
)->setString(fmt::format("{}%", g_rouletteManager.levelPercentageGoal).c_str());

int diffInd = roulette::utils::getIndexOf(g_rouletteManager.difficultyArr->as_array(), true);
int demonInd = roulette::utils::getIndexOf(g_rouletteManager.demonDifficultyArr->as_array(), true);
int diffInd = roulette::utils::getIndexOf(g_rouletteManager.getFromSaveContainer("difficulty-array").as_array(), true);
int demonInd = roulette::utils::getIndexOf(g_rouletteManager.getFromSaveContainer("demon-difficulty-array").as_array(), true);
int difficulty = diffInd == 5 ? (demonInd + 6) : (diffInd + 1);

getRandomListLevel(difficulty, m_level, m_list_fetcher_error);
Expand Down Expand Up @@ -637,7 +637,7 @@ void RouletteLayer::onResetButton(CCObject*)
m_pMainMenu->getChildByTag(12)->setVisible(true);
m_pMainMenu->getChildByTag(12)->setPositionY(-85.f);

if (g_rouletteManager.getArrayState(g_rouletteManager.difficultyArr, 5))
if (g_rouletteManager.getArrayState(g_rouletteManager.getFromSaveContainer("difficulty-array"), 5))
{
m_plus_button_state = true;
onPlusButton(nullptr);
Expand All @@ -664,8 +664,8 @@ void RouletteLayer::onSkipButton(CCObject*)

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

int diffInd = roulette::utils::getIndexOf(g_rouletteManager.difficultyArr->as_array(), true);
int demonInd = roulette::utils::getIndexOf(g_rouletteManager.demonDifficultyArr->as_array(), true);
int diffInd = roulette::utils::getIndexOf(g_rouletteManager.getFromSaveContainer("difficulty-array").as_array(), true);
int demonInd = roulette::utils::getIndexOf(g_rouletteManager.getFromSaveContainer("demon-difficulty-array").as_array(), true);
int difficulty = diffInd == 5 ? (demonInd + 6) : (diffInd + 1);

getRandomListLevel(difficulty, m_level, m_list_fetcher_error);
Expand Down Expand Up @@ -719,8 +719,8 @@ void RouletteLayer::finishLevelRoulette()
m_pPlayingMenu->getChildByTag(3)->getChildren()->objectAtIndex(0)
)->setString(("ID: " + m_level.get<std::string>("id")).c_str());

auto diffInd = roulette::utils::getIndexOf(g_rouletteManager.difficultyArr->as_array(), true);
auto demonInd = roulette::utils::getIndexOf(g_rouletteManager.demonDifficultyArr->as_array(), true);
auto diffInd = roulette::utils::getIndexOf(g_rouletteManager.getFromSaveContainer("difficulty-array").as_array(), true);
auto demonInd = roulette::utils::getIndexOf(g_rouletteManager.getFromSaveContainer("demon-difficulty-array").as_array(), true);
int difficultyTag = m_difficulty_to_tag.at(m_level.get<std::string>("difficulty"));

if (int coins = m_level.get<int>("coins"); coins > 0)
Expand Down Expand Up @@ -810,7 +810,7 @@ void RouletteLayer::onNextLevel(bool levelTextVisible, bool enableLoadingCircle,

void RouletteLayer::getRandomListLevel(int difficulty, matjson::Value& list, std::string& error)
{
int listType = roulette::utils::getIndexOf(g_rouletteManager.selectedListArr->as_array(), true);
int listType = roulette::utils::getIndexOf(g_rouletteManager.getFromSaveContainer("selected-list-array").as_array(), true);
std::thread getListThread;

switch (listType)
Expand Down Expand Up @@ -853,12 +853,12 @@ CCMenuItemSpriteExtra* RouletteLayer::createDifficultyButton(int tag, CCNode* sp
button->setTag(tag);
if (isDemon)
{
if (!g_rouletteManager.getArrayState(g_rouletteManager.difficultyArr, tag - 6))
if (!g_rouletteManager.getArrayState(g_rouletteManager.getFromSaveContainer("difficulty-array"), tag - 6))
button->setColor({ 125, 125, 125 });
}
else
{
if (!g_rouletteManager.getArrayState(g_rouletteManager.difficultyArr, tag))
if (!g_rouletteManager.getArrayState(g_rouletteManager.getFromSaveContainer("difficulty-array"), tag))
button->setColor({ 125, 125, 125 });
}
button->setVisible(visible);
Expand Down
37 changes: 24 additions & 13 deletions src/roulette/manager/RouletteManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ struct RouletteManager
inline static std::atomic_bool isPlayingRoulette = false;
inline static bool hasFinishedPreviousLevel = false;

inline static matjson::Value* difficultyArr; // 6
inline static matjson::Value* demonDifficultyArr; // 5
inline static matjson::Value* selectedListArr; // 3
// inline static matjson::Value* difficultyArr; // 6
// inline static matjson::Value* demonDifficultyArr; // 5
// inline static matjson::Value* selectedListArr; // 3

inline static int lastLevelID = 0;
inline static int lastLevelPercentage = 0;
Expand All @@ -54,29 +54,40 @@ struct RouletteManager
auto& saveContainer = Mod::get()->getSaveContainer().as_object();

if (!Mod::get()->hasSavedValue("difficulty-array"))
{
Mod::get()->setSavedValue<std::vector<bool>>("difficulty-array", { true, false, false, false, false, false });
difficultyArr = &(saveContainer["difficulty-array"]);
verifyArray(difficultyArr->as_array());
previousDifficulty = 0;
}
else
{
auto& arr = getFromSaveContainer("difficulty-array").as_array();

previousDifficulty = roulette::utils::getIndexOf(arr, true);
verifyArray(arr);
}

if (!Mod::get()->hasSavedValue("demon-difficulty-array"))
Mod::get()->setSavedValue<std::vector<bool>>("demon-difficulty-array", { true, false, false, false, false });
demonDifficultyArr = &(saveContainer["demon-difficulty-array"]);
verifyArray(demonDifficultyArr->as_array());
else
verifyArray(saveContainer["demon-difficulty-array"].as_array());

if (!Mod::get()->hasSavedValue("selected-list-array"))
Mod::get()->setSavedValue<std::vector<bool>>("selected-list-array", { true, false, false });
selectedListArr = &(saveContainer["selected-list-array"]);
verifyArray(selectedListArr->as_array());

previousDifficulty = roulette::utils::getIndexOf(difficultyArr->as_array(), true);
else
verifyArray(saveContainer["selected-list-array"].as_array());

hasInitManager = true;
}
}

bool getArrayState(matjson::Value* arr, std::size_t idx)
matjson::Value& getFromSaveContainer(std::string_view const key)
{
return Mod::get()->getSaveContainer().as_object()[key];
}

bool getArrayState(matjson::Value& arr, std::size_t idx)
{
return arr->as_array().at(idx).as<bool>();
return arr.as_array().at(idx).as<bool>();
}

void reset()
Expand Down

0 comments on commit b176882

Please sign in to comment.