mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 07:05:39 +00:00
Fixing random game selection, and aligning menus
- Fixing off-by-one error - Update menu alignment
This commit is contained in:
parent
2decb2b6a4
commit
a035433d1d
|
@ -383,13 +383,12 @@ SystemData* SystemData::getRandomSystem()
|
||||||
}
|
}
|
||||||
|
|
||||||
// get random number in range
|
// 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++)
|
for (auto it = sSystemVector.begin(); it != sSystemVector.end(); it++)
|
||||||
{
|
{
|
||||||
if ((*it)->isGameSystem())
|
if ((*it)->isGameSystem())
|
||||||
{
|
{
|
||||||
if (target >= 0)
|
if (target > 0)
|
||||||
{
|
{
|
||||||
target--;
|
target--;
|
||||||
}
|
}
|
||||||
|
@ -406,7 +405,7 @@ FileData* SystemData::getRandomGame()
|
||||||
std::vector<FileData*> list = mRootFolder->getFilesRecursive(GAME, true);
|
std::vector<FileData*> list = mRootFolder->getFilesRecursive(GAME, true);
|
||||||
unsigned int total = list.size();
|
unsigned int total = list.size();
|
||||||
// get random number in range
|
// 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);
|
return list.at(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,19 +69,6 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui
|
||||||
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openGamelistFilter, this));
|
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openGamelistFilter, this));
|
||||||
mMenu.addRow(row);
|
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
|
// center the menu
|
||||||
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
||||||
mMenu.setPosition((mSize.x() - mMenu.getSize().x()) / 2, (mSize.y() - mMenu.getSize().y()) / 2);
|
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(&mMenu);
|
||||||
addChild(&mVersion);
|
addChild(&mVersion);
|
||||||
|
|
||||||
/*int menuWidth = Renderer::getScreenWidth() * 0.4f;
|
|
||||||
int menuHeight = Renderer::getScreenHeight() * 0.74f;
|
|
||||||
mMenu.setSize(menuWidth, menuHeight);*/
|
|
||||||
|
|
||||||
setSize(mMenu.getSize());
|
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() {
|
void GuiMenu::openScreensaverOptions() {
|
||||||
|
|
Loading…
Reference in a new issue