Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random level/pack selection #405

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions src/SSVOpenHexagon/Core/MenuGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ MenuGame::MenuGame(Steam::steam_manager& mSteamManager,
lvlDrawer->YScrollTo = 0;
}
}

return;
}

Expand Down Expand Up @@ -1015,6 +1014,61 @@ void MenuGame::initInput()
game.addInput( // hardcoded
{{k::F4}}, [this](ssvu::FT /*unused*/) { reloadAssets(true); },
t::Once);

//////////
// Will move to bindable keys shortly

game.addInput( // hardcoded
{{k::LControl}}, [this](ssvu::FT /*unused*/) {
int randomLevel;
int oldIndex = lvlDrawer->currentIndex;

if (lvlDrawer->levelDataIds->size() == 1) //if there is only 1 index, skip
return;

randomLevel = ssvu::getRndI(0, lvlDrawer->levelDataIds->size());

while (oldIndex == randomLevel) //prevents random from landing back on current index
randomLevel = ssvu::getRndI(0, lvlDrawer->levelDataIds->size());

setIndex(randomLevel);
playSoundOverride("beep.ogg");
},
t::Once);

auto focusRandom = [this]() { //lambda for LCtrl + L/RShift (Focus)

int randomCollection;
std::string oldIndex = currentPack->name;

if (getSelectablePackInfosSize() == 1) //if there is only 1 collection, skip
return;

randomCollection = ssvu::getRndI(0, getSelectablePackInfosSize());
changePackTo(randomCollection);

while (oldIndex == currentPack->name){ //prevents random from landing back on current collection

randomCollection = ssvu::getRndI(0, getSelectablePackInfosSize());
changePackTo(randomCollection);
}

playSoundOverride("beep.ogg");
};

game.addInput( // hardcoded
{{k::LControl, k::LShift}}, [this, focusRandom](ssvu::FT /*unused*/) {
focusRandom();
},
t::Once);

game.addInput( // hardcoded
{{k::LControl, k::RShift}}, [this, focusRandom](ssvu::FT /*unused*/) {
focusRandom();
},
t::Once);

//////////
}

void MenuGame::runLuaFile(const std::string& mFileName)
Expand Down Expand Up @@ -4994,7 +5048,8 @@ void MenuGame::drawLevelSelectionRightSide(
tempString = isFavoriteLevels() ? "PRESS F2 TO SHOW ALL LEVELS"
: "PRESS F2 TO SHOW FAVORITE LEVELS";
renderTextCentered(tempString, txtSelectionSmall.font, topLeft);
tempString = "\nHOLD FOCUS TO JUMP BETWEEN PACKS";

tempString = "\nPRESS LCONTROL TO SELECT A RANDOM LEVEL\nHOLD FOCUS TO JUMP BETWEEN PACKS";
renderTextCentered(tempString, txtSelectionSmall.font, topLeft);

//----------------------------------------
Expand Down