mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Merge pull request #180 from pjft/Random-Selection
Fixing random game selection, and aligning menus
This commit is contained in:
commit
227d5b89a9
|
@ -383,13 +383,12 @@ SystemData* SystemData::getRandomSystem()
|
|||
}
|
||||
|
||||
// get random number in range
|
||||
int target = std::round(((double)std::rand() / (double)RAND_MAX) * total);
|
||||
|
||||
int target = std::round(((double)std::rand() / (double)RAND_MAX) * (total - 1));
|
||||
for (auto it = sSystemVector.begin(); it != sSystemVector.end(); it++)
|
||||
{
|
||||
if ((*it)->isGameSystem())
|
||||
{
|
||||
if (target >= 0)
|
||||
if (target > 0)
|
||||
{
|
||||
target--;
|
||||
}
|
||||
|
@ -406,7 +405,7 @@ FileData* SystemData::getRandomGame()
|
|||
std::vector<FileData*> list = mRootFolder->getFilesRecursive(GAME, true);
|
||||
unsigned int total = list.size();
|
||||
// get random number in range
|
||||
int target = std::round(((double)std::rand() / (double)RAND_MAX) * total);
|
||||
int target = std::round(((double)std::rand() / (double)RAND_MAX) * (total - 1));
|
||||
return list.at(target);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,19 +69,6 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui
|
|||
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openGamelistFilter, this));
|
||||
mMenu.addRow(row);
|
||||
|
||||
row.elements.clear();
|
||||
row.addElement(std::make_shared<TextComponent>(mWindow, "SURPRISE ME!", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
||||
row.input_handler = [&](InputConfig* config, Input input) {
|
||||
if (config->isMappedTo("a", input) && input.value)
|
||||
{
|
||||
ViewController::get()->goToRandomGame();
|
||||
delete this;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
mMenu.addRow(row);
|
||||
|
||||
// center the menu
|
||||
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
||||
mMenu.setPosition((mSize.x() - mMenu.getSize().x()) / 2, (mSize.y() - mMenu.getSize().y()) / 2);
|
||||
|
|
|
@ -373,12 +373,8 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
|
|||
addChild(&mMenu);
|
||||
addChild(&mVersion);
|
||||
|
||||
/*int menuWidth = Renderer::getScreenWidth() * 0.4f;
|
||||
int menuHeight = Renderer::getScreenHeight() * 0.74f;
|
||||
mMenu.setSize(menuWidth, menuHeight);*/
|
||||
|
||||
setSize(mMenu.getSize());
|
||||
setPosition((Renderer::getScreenWidth() - mSize.x()) / 2, Renderer::getScreenHeight() * 0.13f);
|
||||
setPosition((Renderer::getScreenWidth() - mSize.x()) / 2, Renderer::getScreenHeight() * 0.15f);
|
||||
}
|
||||
|
||||
void GuiMenu::openScreensaverOptions() {
|
||||
|
|
Loading…
Reference in a new issue