Skip to content

Commit

Permalink
Merge remote-tracking branch 'retropie/master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
joolswills committed Apr 27, 2022
2 parents 2dd5e6b + e26fa8d commit 9663f5e
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 71 deletions.
20 changes: 1 addition & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,7 @@ The new configuration will be added to the `~/.emulationstation/es_input.cfg` fi

**If your controller stops working, you can delete the `~/.emulationstation/es_input.cfg` file to make the input configuration screen re-appear on next run.**


You can use `--help` or `-h` to view a list of command-line options. Briefly outlined here:
```
--resolution [width] [height] try and force a particular resolution
--gamelist-only skip automatic game search, only read from gamelist.xml
--ignore-gamelist ignore the gamelist (useful for troubleshooting)
--draw-framerate display the framerate
--no-exit don't show the exit option in the menu
--no-splash don't show the splash screen
--debug more logging, show console on Windows
--scrape scrape using command line interface
--windowed not fullscreen, should be used with --resolution
--vsync [1/on or 0/off] turn vsync on or off (default is on)
--max-vram [size] Max VRAM to use in Mb before swapping. 0 for unlimited
--force-kid Force the UI mode to be Kid
--force-kiosk Force the UI mode to be Kiosk
--force-disable-filters Force the UI to ignore applied filters in gamelist
--help, -h summon a sentient, angry tuba
```
You can use `--help` or `-h` to view a list of command-line options.

As long as ES hasn't frozen, you can always press F4 to close the application.

Expand Down
2 changes: 2 additions & 0 deletions es-app/src/SystemData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,8 @@ SystemData* SystemData::getRandomSystem()
if (sSystemVectorShuffled.empty())
{
std::copy_if(sSystemVector.begin(), sSystemVector.end(), std::back_inserter(sSystemVectorShuffled), [](SystemData *sd){ return sd->isGameSystem(); });
if (sSystemVectorShuffled.empty()) return NULL;

std::shuffle(sSystemVectorShuffled.begin(), sSystemVectorShuffled.end(), sURNG);
}

Expand Down
74 changes: 50 additions & 24 deletions es-app/src/components/TextListComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class TextListComponent : public IList<TextListData, T>
Alignment mAlignment;
float mHorizontalMargin;

int getFirstVisibleEntry();
std::function<void(CursorState state)> mCursorChangedCallback;

std::shared_ptr<Font> mFont;
Expand All @@ -108,7 +109,7 @@ class TextListComponent : public IList<TextListData, T>
unsigned int mColors[COLOR_ID_COUNT];
unsigned int mScreenCount;
int mStartEntry = 0;
unsigned int mCursorPrev = 1;
unsigned int mCursorPrev = -1;
bool mOneEntryUpDn = true;

ImageComponent mSelectorImage;
Expand Down Expand Up @@ -150,33 +151,12 @@ void TextListComponent<T>::render(const Transform4x4f& parentTrans)

const float entrySize = Math::max(font->getHeight(1.0), (float)font->getSize()) * mLineSpacing;


// number of entries that can fit on the screen simultaniously
mScreenCount = (int)(mSize.y() / entrySize);

if (mCursor != mCursorPrev)
if(mCursor != mCursorPrev)
{
int fromTop = mCursorPrev - mStartEntry;
bool cursorCentered = fromTop == mScreenCount/2;
mStartEntry = 0;

if(size() >= mScreenCount)
{
if (Settings::getInstance()->getBool("UseFullscreenPaging")
&& (mCursor > mScreenCount/2 || mCursor < size() - (mScreenCount - mScreenCount/2))
&& !cursorCentered && !mOneEntryUpDn)
{
mStartEntry = mCursor - fromTop;
} else {
mStartEntry = mCursor - mScreenCount/2;
}

// bounds check
if(mStartEntry < 0)
mStartEntry = 0;
else if(mStartEntry >= size() - mScreenCount)
mStartEntry = size() - mScreenCount;
}
mStartEntry = (size() > mScreenCount) ? getFirstVisibleEntry() : 0;
mCursorPrev = mCursor;
}

Expand Down Expand Up @@ -272,6 +252,52 @@ void TextListComponent<T>::render(const Transform4x4f& parentTrans)
GuiComponent::renderChildren(trans);
}


template <typename T>
int TextListComponent<T>::getFirstVisibleEntry()
{
if (mCursorPrev == -1)
{
// init or returned from emulator
mCursorPrev = mCursor;
int quot = div(mCursor, mScreenCount).quot;
mStartEntry = quot * mScreenCount;
}
int screenRelCursor = mCursorPrev - mStartEntry;
bool cursorCentered = screenRelCursor == mScreenCount/2;
int visibleEntryMax = size() - mScreenCount;
int firstVisibleEntry = 0;

if(Settings::getInstance()->getBool("UseFullscreenPaging") && !cursorCentered)
{
// keep visible cursor constant but move visible list (default)
firstVisibleEntry = mCursor - screenRelCursor;
if(mOneEntryUpDn)
{
int delta = mCursor - mCursorPrev;
// detect rollover (== delta is more than one item)
if(delta < -3)
firstVisibleEntry = 0;
else if(delta > 3)
firstVisibleEntry = visibleEntryMax;
else if(screenRelCursor < mScreenCount/2 && delta > 0 /*down pressed*/
|| screenRelCursor > mScreenCount/2 && delta < 0 /*up pressed*/)
// cases for list begin / list end
// move visible cursor and keep visible list section constant
firstVisibleEntry = firstVisibleEntry - delta;
}
} else {
// cursor always in middle of visible list
firstVisibleEntry = mCursor - mScreenCount/2;
}
// bounds check
if(firstVisibleEntry < 0)
firstVisibleEntry = 0;
else if(firstVisibleEntry > visibleEntryMax)
firstVisibleEntry = visibleEntryMax;
return firstVisibleEntry;
}

template <typename T>
bool TextListComponent<T>::input(InputConfig* config, Input input)
{
Expand Down
67 changes: 43 additions & 24 deletions es-app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,30 +172,52 @@ bool parseArgs(int argc, char* argv[])
std::cout <<
"EmulationStation, a graphical front-end for ROM browsing.\n"
"Written by Alec \"Aloshi\" Lofquist.\n"
"Version " << PROGRAM_VERSION_STRING << ", built " << PROGRAM_BUILT_STRING << "\n\n"
"Version " << PROGRAM_VERSION_STRING << ", built " << PROGRAM_BUILT_STRING << "\n"
"Command line arguments:\n"
"--resolution [width] [height] try and force a particular resolution\n"
"--screenrotate [n] rotate a quarter turn clockwise for each n\n"
"--screensize [width] [height] for a canvas smaller than the full resolution,\n"
"\nGeometry settings:\n"
"--resolution WIDTH HEIGHT try and force a particular resolution\n"
"--screenrotate N rotate a quarter turn clockwise for each N\n"
"--screensize WIDTH HEIGHT for a canvas smaller than the full resolution,\n"
" or if rotating into portrait mode\n"
"--screenoffset [x] [y] move the canvas by x,y pixels\n"
"--gamelist-only skip automatic game search, only read from gamelist.xml\n"
"--ignore-gamelist ignore the gamelist (useful for troubleshooting)\n"
"--draw-framerate display the framerate\n"
"--no-exit don't show the exit option in the menu\n"
"--no-confirm-quit omit confirm dialog on actions of quit menu\n"
"--no-splash don't show the splash screen\n"
"--debug more logging, show console on Windows\n"
"--scrape scrape using command line interface\n"
"--screenoffset X Y move the canvas by x,y pixels\n"
"--windowed not fullscreen, should be used with --resolution\n"
"--vsync [1/on or 0/off] turn vsync on or off (default is on)\n"
"--max-vram [size] max VRAM to use in MB before swapping. 0 for unlimited\n"
"\nGame and settings visibility in ES and behaviour of ES:\n"
"--force-disable-filters force the UI to ignore applied filters on\n"
" gamelist (p)\n"
"--force-kid force the UI mode to be Kid\n"
"--force-kiosk force the UI mode to be Kiosk\n"
"--force-disable-filters force the UI to ignore applied filters in gamelist\n"
"--home [path] directory to use as home path\n"
"--no-confirm-quit omit confirm dialog on actions of quit menu\n"
"--no-exit don't show the exit option in the menu\n"
"--no-splash don't show the splash screen\n"
"\nGamelist related:\n"
"--gamelist-only use gamelist.xml as trusted source and do not\n"
" check any path entries of gamelist.xml (p)\n"
"--ignore-gamelist do not read gamelist.xml files (useful for\n"
" troubleshooting)\n"
"\nAdvanced settings:\n"
"--debug more logging, show console on Windows. Enables\n"
" these keyboard shortcuts with left CTRL-key:\n"
" +G: Toggle Gridlayout boundary boxes\n"
" +I: Toggle image boundary box\n"
" +R: Reload all UI views (theme, gamelist, system)\n"
" +T: Toggle textcomponent boundary box\n"
"--draw-framerate display the framerate (p)\n"
"--max-vram SIZE maximum VRAM to use in MB before swapping,\n"
" use 0 for unlimited (p)\n"
"--show-hidden-files show also hidden files of filesystem, no effect\n"
" if --gamelist-only is also set (p)\n"
"--vsync 1|0 turn vsync on (1) or off (0) (default is on)\n"
"\nGeneric switches:\n"
"--help, -h summon a sentient, angry tuba\n\n"
"More information available in README.md.\n";
"--home PATH directory to use as home folder for\n"
" .emulationstation/es_settings.cfg, aso.\n"
" Subfolder .emulationstation/ will be created.\n"
"\nScrape mode:\n"
"--scrape scrape using command line interface\n\n"
"Note: Switches marked (p) will be persisted in es_settings.cfg when any\n"
"setting is changed via EmulationStation UI.\n\n"
"Please refer to the online documentation for additional information:\n"
"https://retropie.org.uk/docs/EmulationStation/\n";
return false; //exit after printing help
}
}
Expand Down Expand Up @@ -320,7 +342,6 @@ int main(int argc, char* argv[])
window.pushGui(ViewController::get());

bool splashScreen = Settings::getInstance()->getBool("SplashScreen");
bool splashScreenProgress = Settings::getInstance()->getBool("SplashScreenProgress");

if(!scrape_cmdline)
{
Expand All @@ -332,15 +353,13 @@ int main(int argc, char* argv[])

if (splashScreen)
{
std::string progressText = "Loading...";
if (splashScreenProgress)
progressText = "Loading system config...";
std::string progressText = "Loading system config...";
window.renderLoadingScreen(progressText);
}
}

const char* errorMsg = NULL;
if(!loadSystemConfigFile(splashScreen && splashScreenProgress ? &window : nullptr, &errorMsg))
if(!loadSystemConfigFile(splashScreen ? &window : nullptr, &errorMsg))
{
// something went terribly wrong
if(errorMsg == NULL)
Expand Down Expand Up @@ -371,7 +390,7 @@ int main(int argc, char* argv[])
// this makes for no delays when accessing content, but a longer startup time
ViewController::get()->preload();

if(splashScreen && splashScreenProgress)
if(splashScreen)
window.renderLoadingScreen("Done.");

//choose which GUI to open depending on if an input configuration already exists
Expand Down
2 changes: 1 addition & 1 deletion es-app/src/views/ViewController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ void ViewController::preload()
int i = 1;
int max = SystemData::sSystemVector.size() + 1;

bool splash = Settings::getInstance()->getBool("SplashScreen") && Settings::getInstance()->getBool("SplashScreenProgress");
bool splash = Settings::getInstance()->getBool("SplashScreen");
if (splash)
mWindow->renderLoadingScreen("Preloading UI", (float)i / (float)max);

Expand Down
4 changes: 4 additions & 0 deletions es-app/src/views/gamelist/BasicGameListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,7 @@ std::vector<HelpPrompt> BasicGameListView::getHelpPrompts()
}
return prompts;
}

void BasicGameListView::onFocusLost() {
mList.stopScrolling(true);
}
2 changes: 2 additions & 0 deletions es-app/src/views/gamelist/BasicGameListView.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class BasicGameListView : public ISimpleGameListView
virtual std::vector<HelpPrompt> getHelpPrompts() override;
virtual void launch(FileData* game) override;

void onFocusLost() override;

protected:
virtual std::string getQuickSystemSelectRightButton() override;
virtual std::string getQuickSystemSelectLeftButton() override;
Expand Down
1 change: 1 addition & 0 deletions es-app/src/views/gamelist/DetailedGameListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,5 @@ std::vector<GuiComponent*> DetailedGameListView::getMDValues()

void DetailedGameListView::onFocusLost() {
mDescContainer.reset();
mList.stopScrolling(true);
}
1 change: 1 addition & 0 deletions es-app/src/views/gamelist/VideoGameListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,5 @@ void VideoGameListView::onShow()

void VideoGameListView::onFocusLost() {
mDescContainer.reset();
mList.stopScrolling(true);
}
2 changes: 0 additions & 2 deletions es-core/src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ std::vector<const char*> settings_dont_save {
{ "ShowExit" },
{ "ConfirmQuit" },
{ "SplashScreen" },
{ "SplashScreenProgress" },
{ "VSync" },
{ "FullscreenBorderless" },
{ "Windowed" },
Expand Down Expand Up @@ -65,7 +64,6 @@ void Settings::setDefaults()
mBoolMap["FullscreenBorderless"] = false;
mBoolMap["Windowed"] = false;
mBoolMap["SplashScreen"] = true;
mBoolMap["SplashScreenProgress"] = true;
mStringMap["StartupSystem"] = "";
mBoolMap["DisableKidStartMenu"] = true;

Expand Down
8 changes: 7 additions & 1 deletion es-core/src/components/IList.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,16 @@ class IList : public GuiComponent
return mScrollVelocity;
}

void stopScrolling()
void stopScrolling(bool focusLost = false)
{
if (focusLost) {
// force remove overlay (large two letter display in center) when user scrolls
// at max speed through list and then abruptly leaves the system
mTitleOverlayOpacity = 0;
}
listInput(0);
onCursorChanged(CURSOR_STOPPED);

}

void clear()
Expand Down

0 comments on commit 9663f5e

Please sign in to comment.