Skip to content

Commit

Permalink
Loading screen: Be more verbose about what is happening.
Browse files Browse the repository at this point in the history
Starting up emulationstation takes me about 1 minute over the network
with a large collection of 27 systems with images.

This patch uses the loading screen to tell the user about the status
of the startup, with information how many systems are left for view
initialization.

The most beefy part of the startup process is initializing the views,
and preloading images.

This patch extends the `renderLoadingScreen` function to take a string
and uses it in `ViewController::preload`.
  • Loading branch information
lubosz committed Jan 31, 2019
1 parent a466e0d commit cc5ea80
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
8 changes: 7 additions & 1 deletion es-app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ int main(int argc, char* argv[])
LOG(LogInfo) << "Checking available OpenGL extensions...";
LOG(LogInfo) << " ARB_texture_non_power_of_two: " << (glExts.find("ARB_texture_non_power_of_two") != std::string::npos ? "ok" : "MISSING");
if(Settings::getInstance()->getBool("SplashScreen"))
window.renderLoadingScreen();
window.renderLoadingScreen("Loading system config...");
}

const char* errorMsg = NULL;
Expand Down Expand Up @@ -338,10 +338,16 @@ int main(int argc, char* argv[])
//dont generate joystick events while we're loading (hopefully fixes "automatically started emulator" bug)
SDL_JoystickEventState(SDL_DISABLE);

if(Settings::getInstance()->getBool("SplashScreen"))
window.renderLoadingScreen("Preloading views...");

// preload what we can right away instead of waiting for the user to select it
// this makes for no delays when accessing content, but a longer startup time
ViewController::get()->preload();

if(Settings::getInstance()->getBool("SplashScreen"))
window.renderLoadingScreen("Done.");

//choose which GUI to open depending on if an input configuration already exists
if(errorMsg == NULL)
{
Expand Down
12 changes: 11 additions & 1 deletion es-app/src/views/ViewController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void ViewController::goToStart()

void ViewController::ReloadAndGoToStart()
{
mWindow->renderLoadingScreen();
mWindow->renderLoadingScreen("Loading...");
ViewController::get()->reloadAll();
ViewController::get()->goToStart();
}
Expand Down Expand Up @@ -429,8 +429,18 @@ void ViewController::render(const Transform4x4f& parentTrans)

void ViewController::preload()
{
uint32_t i = 0;
for(auto it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); it++)
{
if(Settings::getInstance()->getBool("SplashScreen"))
{
i++;
char buffer[100];
sprintf (buffer, "Loading '%s' (%d/%d)",
(*it)->getFullName().c_str(), i, SystemData::sSystemVector.size());
mWindow->renderLoadingScreen(std::string(buffer));
}

(*it)->getIndex()->resetFilters();
getGameListView(*it);
}
Expand Down
10 changes: 6 additions & 4 deletions es-core/src/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void Window::setAllowSleep(bool sleep)
mAllowSleep = sleep;
}

void Window::renderLoadingScreen()
void Window::renderLoadingScreen(std::string text)
{
Transform4x4f trans = Transform4x4f::Identity();
Renderer::setMatrix(trans);
Expand All @@ -311,9 +311,11 @@ void Window::renderLoadingScreen()
splash.render(trans);

auto& font = mDefaultFonts.at(1);
TextCache* cache = font->buildTextCache("LOADING...", 0, 0, 0x656565FF);
trans = trans.translate(Vector3f(Math::round((Renderer::getScreenWidth() - cache->metrics.size.x()) / 2.0f),
Math::round(Renderer::getScreenHeight() * 0.835f), 0.0f));
TextCache* cache = font->buildTextCache(text, 0, 0, 0x656565FF);

float x = Math::round((Renderer::getScreenWidth() - cache->metrics.size.x()) / 2.0f);
float y = Math::round(Renderer::getScreenHeight() * 0.835f);
trans = trans.translate(Vector3f(x, y, 0.0f));
Renderer::setMatrix(trans);
font->renderTextCache(cache);
delete cache;
Expand Down
2 changes: 1 addition & 1 deletion es-core/src/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Window
bool getAllowSleep();
void setAllowSleep(bool sleep);

void renderLoadingScreen();
void renderLoadingScreen(std::string text);

void renderHelpPromptsEarly(); // used to render HelpPrompts before a fade
void setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpStyle& style);
Expand Down

0 comments on commit cc5ea80

Please sign in to comment.