Skip to content

Commit

Permalink
feat(roulette): Allow refreshing of roulette if error occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaghettDev committed Dec 7, 2024
1 parent e63f955 commit 20fcc34
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/roulette/layers/RLRouletteLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,15 @@ bool RLRouletteLayer::init()
errorReasonText->setID("reason-label");
error_menu->addChild(errorReasonText);

auto refreshButton = CCMenuItemSpriteExtra::create(
ButtonSprite::create("Refresh", 50, true, "bigFont.fnt", "GJ_button_01.png", .0f, .9f),
this,
menu_selector(RLRouletteLayer::onRefreshButton)
);
refreshButton->setPosition({ 50.f, -70.f });
refreshButton->setID("refresh-button");
error_menu->addChild(refreshButton);

auto errorResetButton = CCMenuItemSpriteExtra::create(
ButtonSprite::create("Reset", 50, true, "bigFont.fnt", "GJ_button_06.png", .0f, .8f),
this,
Expand Down Expand Up @@ -557,6 +566,13 @@ void RLRouletteLayer::onNextButton(CCObject*)
rl::utils::createNotificationToast(this, fmt::format("You need to get at least {}%!", g_rouletteManager.currentPercentageGoal), .5f, 85.f);
}

void RLRouletteLayer::onRefreshButton(CCObject*)
{
g_rouletteManager.gameState.hasReachedGoal = true;
error_menu->setVisible(false);
onNextButton(nullptr);
}

void RLRouletteLayer::onResetButton(CCObject*)
{
if (m_list_fetcher.is_fetching)
Expand Down Expand Up @@ -589,9 +605,12 @@ void RLRouletteLayer::onSkipButton(CCObject*)
if (m_list_fetcher.is_fetching)
return;

if (g_rouletteManager.gameState.levelPercentage == 100)
if (g_rouletteManager.gameState.levelPercentage == 100 || g_rouletteManager.gameState.hasReachedGoal)
{
rl::utils::createNotificationToast(this, "Skip not used, you have already reached the goal!", .5f, 85.f);

onNextButton(nullptr);

return;
}

Expand Down Expand Up @@ -623,7 +642,6 @@ void RLRouletteLayer::finishLevelRoulette()

playing_menu->setVisible(false);
error_menu->setVisible(true);
g_rouletteManager.reset();

return;
}
Expand Down
1 change: 1 addition & 0 deletions src/roulette/layers/RLRouletteLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class RLRouletteLayer : public BaseCustomAlertLayer
void onPlayButton(CCObject*);
void onSkipButton(CCObject*);
void onNextButton(CCObject*);
void onRefreshButton(CCObject*);
void onResetButton(CCObject*);

void finishLevelRoulette();
Expand Down

0 comments on commit 20fcc34

Please sign in to comment.