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`.

v2: Add SplashScreenProgress option enabled by default.
  • Loading branch information
lubosz committed Feb 4, 2019
1 parent a466e0d commit 87a3205
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
15 changes: 13 additions & 2 deletions es-app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ int main(int argc, char* argv[])
MameNames::init();
window.pushGui(ViewController::get());

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

if(!scrape_cmdline)
{
if(!window.init())
Expand All @@ -303,8 +306,13 @@ int main(int argc, char* argv[])
std::string glExts = (const char*)glGetString(GL_EXTENSIONS);
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();
if(splashScreen)
{
std::string progressText = "Loading...";
if (splashScreenProgress)
progressText = "Loading system config...";
window.renderLoadingScreen(progressText);
}
}

const char* errorMsg = NULL;
Expand Down Expand Up @@ -342,6 +350,9 @@ 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)
window.renderLoadingScreen("Done.");

//choose which GUI to open depending on if an input configuration already exists
if(errorMsg == NULL)
{
Expand Down
13 changes: 12 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,19 @@ 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") &&
Settings::getInstance()->getBool("SplashScreenProgress"))
{
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
2 changes: 2 additions & 0 deletions es-core/src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ std::vector<const char*> settings_dont_save {
{ "HideConsole" },
{ "ShowExit" },
{ "SplashScreen" },
{ "SplashScreenProgress" },
{ "VSync" },
{ "Windowed" },
{ "WindowWidth" },
Expand Down Expand Up @@ -60,6 +61,7 @@ void Settings::setDefaults()
mBoolMap["ShowExit"] = true;
mBoolMap["Windowed"] = false;
mBoolMap["SplashScreen"] = true;
mBoolMap["SplashScreenProgress"] = true;
mStringMap["StartupSystem"] = "";

mBoolMap["VSync"] = true;
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 87a3205

Please sign in to comment.