mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-03-06 14:27:43 +00:00
Removed some old effects code from Window.
Added a simple "LOADING" screen when ES starts up. ViewController now preloads GameListViews so there's no lag when browsing to a system for the first time.
This commit is contained in:
parent
3fb06d1833
commit
ccea2a7e04
|
@ -9,16 +9,17 @@
|
||||||
#include "views/ViewController.h"
|
#include "views/ViewController.h"
|
||||||
|
|
||||||
Window::Window() : mNormalizeNextUpdate(false), mFrameTimeElapsed(0), mFrameCountElapsed(0), mAverageDeltaTime(10),
|
Window::Window() : mNormalizeNextUpdate(false), mFrameTimeElapsed(0), mFrameCountElapsed(0), mAverageDeltaTime(10),
|
||||||
mZoomFactor(1.0f), mCenterPoint(0, 0), mMatrix(Eigen::Affine3f::Identity()), mFadePercent(0.0f), mAllowSleep(true)
|
mAllowSleep(true)
|
||||||
{
|
{
|
||||||
mInputManager = new InputManager(this);
|
mInputManager = new InputManager(this);
|
||||||
mViewController = new ViewController(this);
|
mViewController = new ViewController(this);
|
||||||
pushGui(mViewController);
|
pushGui(mViewController);
|
||||||
setCenterPoint(Eigen::Vector2f(Renderer::getScreenWidth() / 2, Renderer::getScreenHeight() / 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::~Window()
|
Window::~Window()
|
||||||
{
|
{
|
||||||
|
delete mViewController; // this would get deleted down below, but just to be safe, delete it here
|
||||||
|
|
||||||
//delete all our GUIs
|
//delete all our GUIs
|
||||||
while(peekGui())
|
while(peekGui())
|
||||||
delete peekGui();
|
delete peekGui();
|
||||||
|
@ -131,13 +132,12 @@ void Window::update(int deltaTime)
|
||||||
|
|
||||||
void Window::render()
|
void Window::render()
|
||||||
{
|
{
|
||||||
|
Eigen::Affine3f transform = Eigen::Affine3f::Identity();
|
||||||
for(unsigned int i = 0; i < mGuiStack.size(); i++)
|
for(unsigned int i = 0; i < mGuiStack.size(); i++)
|
||||||
{
|
{
|
||||||
mGuiStack.at(i)->render(mMatrix);
|
mGuiStack.at(i)->render(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
postProcess();
|
|
||||||
|
|
||||||
if(Settings::getInstance()->getBool("DRAWFRAMERATE"))
|
if(Settings::getInstance()->getBool("DRAWFRAMERATE"))
|
||||||
{
|
{
|
||||||
Renderer::setMatrix(Eigen::Affine3f::Identity());
|
Renderer::setMatrix(Eigen::Affine3f::Identity());
|
||||||
|
@ -150,42 +150,6 @@ void Window::normalizeNextUpdate()
|
||||||
mNormalizeNextUpdate = true;
|
mNormalizeNextUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::setZoomFactor(const float& zoom)
|
|
||||||
{
|
|
||||||
mZoomFactor = zoom;
|
|
||||||
updateMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::setCenterPoint(const Eigen::Vector2f& point)
|
|
||||||
{
|
|
||||||
mCenterPoint = point;
|
|
||||||
updateMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::updateMatrix()
|
|
||||||
{
|
|
||||||
const float sw = Renderer::getScreenWidth() / mZoomFactor;
|
|
||||||
const float sh = Renderer::getScreenHeight() / mZoomFactor;
|
|
||||||
|
|
||||||
mMatrix = Eigen::Affine3f::Identity();
|
|
||||||
mMatrix = mMatrix.scale(Eigen::Vector3f(mZoomFactor, mZoomFactor, 1));
|
|
||||||
mMatrix = mMatrix.translate(Eigen::Vector3f(sw / 2 - mCenterPoint.x(), sh / 2 - mCenterPoint.y(), 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::setFadePercent(const float& perc)
|
|
||||||
{
|
|
||||||
mFadePercent = perc;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::postProcess()
|
|
||||||
{
|
|
||||||
if(mFadePercent > 0.0f)
|
|
||||||
{
|
|
||||||
Renderer::setMatrix(Eigen::Affine3f::Identity());
|
|
||||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x00000000 | ((unsigned char)(mFadePercent * 255)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Window::getAllowSleep()
|
bool Window::getAllowSleep()
|
||||||
{
|
{
|
||||||
return mAllowSleep;
|
return mAllowSleep;
|
||||||
|
@ -195,3 +159,11 @@ void Window::setAllowSleep(bool sleep)
|
||||||
{
|
{
|
||||||
mAllowSleep = sleep;
|
mAllowSleep = sleep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::renderLoadingScreen()
|
||||||
|
{
|
||||||
|
Renderer::setMatrix(Eigen::Affine3f::Identity());
|
||||||
|
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF);
|
||||||
|
mDefaultFonts.at(2)->drawCenteredText("LOADING", 0, (Renderer::getScreenHeight() - mDefaultFonts.at(2)->getHeight()) / 2.0f , 0xFFFFFFFF);
|
||||||
|
Renderer::swapBuffers();
|
||||||
|
}
|
||||||
|
|
16
src/Window.h
16
src/Window.h
|
@ -30,14 +30,11 @@ public:
|
||||||
|
|
||||||
void normalizeNextUpdate();
|
void normalizeNextUpdate();
|
||||||
|
|
||||||
void setZoomFactor(const float& zoom);
|
|
||||||
void setCenterPoint(const Eigen::Vector2f& point);
|
|
||||||
|
|
||||||
void setFadePercent(const float& perc);
|
|
||||||
|
|
||||||
bool getAllowSleep();
|
bool getAllowSleep();
|
||||||
void setAllowSleep(bool sleep);
|
void setAllowSleep(bool sleep);
|
||||||
|
|
||||||
|
void renderLoadingScreen();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InputManager* mInputManager;
|
InputManager* mInputManager;
|
||||||
ViewController* mViewController;
|
ViewController* mViewController;
|
||||||
|
@ -52,15 +49,6 @@ private:
|
||||||
|
|
||||||
bool mNormalizeNextUpdate;
|
bool mNormalizeNextUpdate;
|
||||||
|
|
||||||
float mZoomFactor;
|
|
||||||
Eigen::Vector2f mCenterPoint;
|
|
||||||
|
|
||||||
void updateMatrix();
|
|
||||||
Eigen::Affine3f mMatrix;
|
|
||||||
|
|
||||||
void postProcess();
|
|
||||||
float mFadePercent;
|
|
||||||
|
|
||||||
bool mAllowSleep;
|
bool mAllowSleep;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
15
src/main.cpp
15
src/main.cpp
|
@ -131,10 +131,15 @@ int main(int argc, char* argv[])
|
||||||
atexit(&onExit);
|
atexit(&onExit);
|
||||||
|
|
||||||
Window window;
|
Window window;
|
||||||
if(!scrape_cmdline && !window.init(width, height))
|
if(!scrape_cmdline)
|
||||||
{
|
{
|
||||||
LOG(LogError) << "Window failed to initialize!";
|
if(!window.init(width, height))
|
||||||
return 1;
|
{
|
||||||
|
LOG(LogError) << "Window failed to initialize!";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.renderLoadingScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
//try loading the system config file
|
//try loading the system config file
|
||||||
|
@ -160,6 +165,10 @@ int main(int argc, char* argv[])
|
||||||
//dont generate joystick events while we're loading (hopefully fixes "automatically started emulator" bug)
|
//dont generate joystick events while we're loading (hopefully fixes "automatically started emulator" bug)
|
||||||
SDL_JoystickEventState(SDL_DISABLE);
|
SDL_JoystickEventState(SDL_DISABLE);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
window.getViewController()->preload();
|
||||||
|
|
||||||
//choose which GUI to open depending on if an input configuration already exists
|
//choose which GUI to open depending on if an input configuration already exists
|
||||||
if(fs::exists(InputManager::getConfigPath()))
|
if(fs::exists(InputManager::getConfigPath()))
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,6 @@ void ViewController::goToSystemSelect()
|
||||||
mState.viewing = SYSTEM_SELECT;
|
mState.viewing = SYSTEM_SELECT;
|
||||||
mCurrentView = getSystemListView();
|
mCurrentView = getSystemListView();
|
||||||
playViewTransition();
|
playViewTransition();
|
||||||
LOG(LogInfo) << "going to system select";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemData* getSystemCyclic(SystemData* from, bool reverse)
|
SystemData* getSystemCyclic(SystemData* from, bool reverse)
|
||||||
|
@ -46,7 +45,7 @@ SystemData* getSystemCyclic(SystemData* from, bool reverse)
|
||||||
|
|
||||||
void ViewController::goToNextGameList()
|
void ViewController::goToNextGameList()
|
||||||
{
|
{
|
||||||
assert(mState.viewing == SYSTEM);
|
assert(mState.viewing == GAME_LIST);
|
||||||
|
|
||||||
SystemData* system = mState.data.system;
|
SystemData* system = mState.data.system;
|
||||||
if(system == NULL)
|
if(system == NULL)
|
||||||
|
@ -57,7 +56,7 @@ void ViewController::goToNextGameList()
|
||||||
|
|
||||||
void ViewController::goToPrevGameList()
|
void ViewController::goToPrevGameList()
|
||||||
{
|
{
|
||||||
assert(mState.viewing == SYSTEM);
|
assert(mState.viewing == GAME_LIST);
|
||||||
|
|
||||||
SystemData* system = mState.data.system;
|
SystemData* system = mState.data.system;
|
||||||
if(system == NULL)
|
if(system == NULL)
|
||||||
|
@ -213,3 +212,11 @@ void ViewController::render(const Eigen::Affine3f& parentTrans)
|
||||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x00000000 | (unsigned char)(mFadeOpacity * 255));
|
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x00000000 | (unsigned char)(mFadeOpacity * 255));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewController::preload()
|
||||||
|
{
|
||||||
|
for(auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
|
||||||
|
{
|
||||||
|
getGameListView(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,10 @@ class ViewController : public GuiComponent
|
||||||
public:
|
public:
|
||||||
ViewController(Window* window);
|
ViewController(Window* window);
|
||||||
|
|
||||||
|
// Try to completely populate the GameListView map.
|
||||||
|
// Caches things so there's no pauses during transitions.
|
||||||
|
void preload();
|
||||||
|
|
||||||
// Navigation.
|
// Navigation.
|
||||||
void goToNextGameList();
|
void goToNextGameList();
|
||||||
void goToPrevGameList();
|
void goToPrevGameList();
|
||||||
|
|
Loading…
Reference in a new issue