2014-06-25 16:29:58 +00:00
|
|
|
#include "views/ViewController.h"
|
|
|
|
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "animations/Animation.h"
|
|
|
|
#include "animations/LambdaAnimation.h"
|
2014-06-25 16:29:58 +00:00
|
|
|
#include "animations/LaunchAnimation.h"
|
|
|
|
#include "animations/MoveCameraAnimation.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "guis/GuiMenu.h"
|
|
|
|
#include "views/gamelist/DetailedGameListView.h"
|
|
|
|
#include "views/gamelist/IGameListView.h"
|
|
|
|
#include "views/gamelist/VideoGameListView.h"
|
|
|
|
#include "views/SystemView.h"
|
2017-09-08 13:20:07 +00:00
|
|
|
#include "FileFilterIndex.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "Log.h"
|
|
|
|
#include "Settings.h"
|
|
|
|
#include "SystemData.h"
|
|
|
|
#include "Window.h"
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
ViewController* ViewController::sInstance = NULL;
|
|
|
|
|
|
|
|
ViewController* ViewController::get()
|
|
|
|
{
|
|
|
|
assert(sInstance);
|
|
|
|
return sInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewController::init(Window* window)
|
|
|
|
{
|
|
|
|
assert(!sInstance);
|
|
|
|
sInstance = new ViewController(window);
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewController::ViewController(Window* window)
|
2017-10-28 20:24:35 +00:00
|
|
|
: GuiComponent(window), mCurrentView(nullptr), mCamera(Transform4x4f::Identity()), mFadeOpacity(0), mLockInput(false)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
|
|
|
mState.viewing = NOTHING;
|
2017-09-08 14:49:47 +00:00
|
|
|
mCurUIMode = Settings::getInstance()->getString("UIMode");
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ViewController::~ViewController()
|
|
|
|
{
|
|
|
|
assert(sInstance == this);
|
|
|
|
sInstance = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewController::goToStart()
|
|
|
|
{
|
2017-10-24 15:38:25 +00:00
|
|
|
// If specific system is requested, go directly to the game list
|
|
|
|
auto requestedSystem = Settings::getInstance()->getString("StartupSystem");
|
|
|
|
if("" != requestedSystem && "retropie" != requestedSystem)
|
|
|
|
{
|
2017-11-11 14:56:22 +00:00
|
|
|
for(auto it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); it++){
|
2017-10-24 15:38:25 +00:00
|
|
|
if ((*it)->getName() == requestedSystem)
|
|
|
|
{
|
|
|
|
goToGameList(*it);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
goToSystemView(SystemData::sSystemVector.at(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
int ViewController::getSystemId(SystemData* system)
|
|
|
|
{
|
|
|
|
std::vector<SystemData*>& sysVec = SystemData::sSystemVector;
|
2017-11-17 14:58:52 +00:00
|
|
|
return (int)(std::find(sysVec.cbegin(), sysVec.cend(), system) - sysVec.cbegin());
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ViewController::goToSystemView(SystemData* system)
|
|
|
|
{
|
2016-12-04 23:47:34 +00:00
|
|
|
// Tell any current view it's about to be hidden
|
|
|
|
if (mCurrentView)
|
|
|
|
{
|
|
|
|
mCurrentView->onHide();
|
|
|
|
}
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
mState.viewing = SYSTEM_SELECT;
|
|
|
|
mState.system = system;
|
|
|
|
|
|
|
|
auto systemList = getSystemListView();
|
|
|
|
systemList->setPosition(getSystemId(system) * (float)Renderer::getScreenWidth(), systemList->getPosition().y());
|
|
|
|
|
|
|
|
systemList->goToSystem(system, false);
|
|
|
|
mCurrentView = systemList;
|
2017-08-15 02:34:34 +00:00
|
|
|
mCurrentView->onShow();
|
2017-07-20 07:07:02 +00:00
|
|
|
PowerSaver::setState(true);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
playViewTransition();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewController::goToNextGameList()
|
|
|
|
{
|
|
|
|
assert(mState.viewing == GAME_LIST);
|
|
|
|
SystemData* system = getState().getSystem();
|
|
|
|
assert(system);
|
2016-03-29 04:03:39 +00:00
|
|
|
goToGameList(system->getNext());
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ViewController::goToPrevGameList()
|
|
|
|
{
|
|
|
|
assert(mState.viewing == GAME_LIST);
|
|
|
|
SystemData* system = getState().getSystem();
|
|
|
|
assert(system);
|
2016-03-29 04:03:39 +00:00
|
|
|
goToGameList(system->getPrev());
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ViewController::goToGameList(SystemData* system)
|
|
|
|
{
|
|
|
|
if(mState.viewing == SYSTEM_SELECT)
|
|
|
|
{
|
|
|
|
// move system list
|
|
|
|
auto sysList = getSystemListView();
|
|
|
|
float offX = sysList->getPosition().x();
|
|
|
|
int sysId = getSystemId(system);
|
|
|
|
sysList->setPosition(sysId * (float)Renderer::getScreenWidth(), sysList->getPosition().y());
|
|
|
|
offX = sysList->getPosition().x() - offX;
|
|
|
|
mCamera.translation().x() -= offX;
|
|
|
|
}
|
|
|
|
|
|
|
|
mState.viewing = GAME_LIST;
|
|
|
|
mState.system = system;
|
|
|
|
|
2016-12-04 23:47:34 +00:00
|
|
|
if (mCurrentView)
|
|
|
|
{
|
|
|
|
mCurrentView->onHide();
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
mCurrentView = getGameListView(system);
|
2016-12-04 23:47:34 +00:00
|
|
|
if (mCurrentView)
|
|
|
|
{
|
|
|
|
mCurrentView->onShow();
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
playViewTransition();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewController::playViewTransition()
|
|
|
|
{
|
2017-10-28 20:24:35 +00:00
|
|
|
Vector3f target(Vector3f::Zero());
|
2017-05-18 10:16:57 +00:00
|
|
|
if(mCurrentView)
|
2014-06-25 16:29:58 +00:00
|
|
|
target = mCurrentView->getPosition();
|
|
|
|
|
|
|
|
// no need to animate, we're not going anywhere (probably goToNextGamelist() or goToPrevGamelist() when there's only 1 system)
|
|
|
|
if(target == -mCamera.translation() && !isAnimationPlaying(0))
|
|
|
|
return;
|
|
|
|
|
2017-05-26 00:52:49 +00:00
|
|
|
std::string transition_style = Settings::getInstance()->getString("TransitionStyle");
|
|
|
|
if(transition_style == "fade")
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
|
|
|
// fade
|
|
|
|
// stop whatever's currently playing, leaving mFadeOpacity wherever it is
|
|
|
|
cancelAnimation(0);
|
|
|
|
|
|
|
|
auto fadeFunc = [this](float t) {
|
2017-11-13 22:16:38 +00:00
|
|
|
mFadeOpacity = Math::lerp(0, 1, t);
|
2014-06-25 16:29:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const static int FADE_DURATION = 240; // fade in/out time
|
|
|
|
const static int FADE_WAIT = 320; // time to wait between in/out
|
|
|
|
setAnimation(new LambdaAnimation(fadeFunc, FADE_DURATION), 0, [this, fadeFunc, target] {
|
|
|
|
this->mCamera.translation() = -target;
|
|
|
|
updateHelpPrompts();
|
|
|
|
setAnimation(new LambdaAnimation(fadeFunc, FADE_DURATION), FADE_WAIT, nullptr, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
// fast-forward animation if we're partway faded
|
|
|
|
if(target == -mCamera.translation())
|
|
|
|
{
|
|
|
|
// not changing screens, so cancel the first half entirely
|
|
|
|
advanceAnimation(0, FADE_DURATION);
|
|
|
|
advanceAnimation(0, FADE_WAIT);
|
|
|
|
advanceAnimation(0, FADE_DURATION - (int)(mFadeOpacity * FADE_DURATION));
|
|
|
|
}else{
|
|
|
|
advanceAnimation(0, (int)(mFadeOpacity * FADE_DURATION));
|
|
|
|
}
|
2017-06-28 16:50:37 +00:00
|
|
|
} else if (transition_style == "slide"){
|
2017-05-31 16:54:11 +00:00
|
|
|
// slide or simple slide
|
2014-06-25 16:29:58 +00:00
|
|
|
setAnimation(new MoveCameraAnimation(mCamera, target));
|
|
|
|
updateHelpPrompts(); // update help prompts immediately
|
2017-05-24 00:41:14 +00:00
|
|
|
} else {
|
2017-05-31 16:54:11 +00:00
|
|
|
// instant
|
2017-05-24 00:41:14 +00:00
|
|
|
setAnimation(new LambdaAnimation(
|
2017-11-17 14:58:52 +00:00
|
|
|
[this, target](float /*t*/)
|
2017-05-24 00:41:14 +00:00
|
|
|
{
|
|
|
|
this->mCamera.translation() = -target;
|
|
|
|
}, 1));
|
|
|
|
updateHelpPrompts();
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewController::onFileChanged(FileData* file, FileChangeType change)
|
|
|
|
{
|
|
|
|
auto it = mGameListViews.find(file->getSystem());
|
2017-11-11 14:56:22 +00:00
|
|
|
if(it != mGameListViews.cend())
|
2014-06-25 16:29:58 +00:00
|
|
|
it->second->onFileChanged(file, change);
|
|
|
|
}
|
|
|
|
|
2017-10-28 20:24:35 +00:00
|
|
|
void ViewController::launch(FileData* game, Vector3f center)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
|
|
|
if(game->getType() != GAME)
|
|
|
|
{
|
|
|
|
LOG(LogError) << "tried to launch something that isn't a game";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-12-04 23:47:34 +00:00
|
|
|
// Hide the current view
|
|
|
|
if (mCurrentView)
|
|
|
|
mCurrentView->onHide();
|
|
|
|
|
2017-10-28 20:24:35 +00:00
|
|
|
Transform4x4f origCamera = mCamera;
|
2014-06-25 16:29:58 +00:00
|
|
|
origCamera.translation() = -mCurrentView->getPosition();
|
|
|
|
|
|
|
|
center += mCurrentView->getPosition();
|
|
|
|
stopAnimation(1); // make sure the fade in isn't still playing
|
2017-06-12 16:38:59 +00:00
|
|
|
mWindow->stopInfoPopup(); // make sure we disable any existing info popup
|
2014-06-25 16:29:58 +00:00
|
|
|
mLockInput = true;
|
|
|
|
|
2017-05-26 00:52:49 +00:00
|
|
|
std::string transition_style = Settings::getInstance()->getString("TransitionStyle");
|
|
|
|
if(transition_style == "fade")
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
|
|
|
// fade out, launch game, fade back in
|
|
|
|
auto fadeFunc = [this](float t) {
|
2017-11-13 22:16:38 +00:00
|
|
|
mFadeOpacity = Math::lerp(0.0f, 1.0f, t);
|
2014-06-25 16:29:58 +00:00
|
|
|
};
|
|
|
|
setAnimation(new LambdaAnimation(fadeFunc, 800), 0, [this, game, fadeFunc]
|
|
|
|
{
|
2017-06-12 16:38:59 +00:00
|
|
|
game->launchGame(mWindow);
|
2017-08-22 21:33:26 +00:00
|
|
|
setAnimation(new LambdaAnimation(fadeFunc, 800), 0, [this] { mLockInput = false; }, true);
|
2014-06-25 16:29:58 +00:00
|
|
|
this->onFileChanged(game, FILE_METADATA_CHANGED);
|
|
|
|
});
|
2017-06-28 16:50:37 +00:00
|
|
|
} else if (transition_style == "slide"){
|
2014-06-25 16:29:58 +00:00
|
|
|
// move camera to zoom in on center + fade out, launch game, come back in
|
2017-05-18 10:16:57 +00:00
|
|
|
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 1500), 0, [this, origCamera, center, game]
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2017-06-12 16:38:59 +00:00
|
|
|
game->launchGame(mWindow);
|
2014-06-25 16:29:58 +00:00
|
|
|
mCamera = origCamera;
|
2017-08-22 21:33:26 +00:00
|
|
|
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 600), 0, [this] { mLockInput = false; }, true);
|
2014-06-25 16:29:58 +00:00
|
|
|
this->onFileChanged(game, FILE_METADATA_CHANGED);
|
|
|
|
});
|
2017-08-22 21:33:26 +00:00
|
|
|
} else { // instant
|
2017-05-24 00:41:14 +00:00
|
|
|
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 10), 0, [this, origCamera, center, game]
|
|
|
|
{
|
2017-06-12 16:38:59 +00:00
|
|
|
game->launchGame(mWindow);
|
2017-05-24 00:41:14 +00:00
|
|
|
mCamera = origCamera;
|
2017-08-22 21:33:26 +00:00
|
|
|
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 10), 0, [this] { mLockInput = false; }, true);
|
2017-05-24 00:41:14 +00:00
|
|
|
this->onFileChanged(game, FILE_METADATA_CHANGED);
|
|
|
|
});
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-18 09:45:50 +00:00
|
|
|
void ViewController::removeGameListView(SystemData* system)
|
|
|
|
{
|
|
|
|
//if we already made one, return that one
|
|
|
|
auto exists = mGameListViews.find(system);
|
2017-11-11 14:56:22 +00:00
|
|
|
if(exists != mGameListViews.cend())
|
2017-07-18 09:45:50 +00:00
|
|
|
{
|
|
|
|
exists->second.reset();
|
|
|
|
mGameListViews.erase(system);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
std::shared_ptr<IGameListView> ViewController::getGameListView(SystemData* system)
|
|
|
|
{
|
|
|
|
//if we already made one, return that one
|
|
|
|
auto exists = mGameListViews.find(system);
|
2017-11-11 14:56:22 +00:00
|
|
|
if(exists != mGameListViews.cend())
|
2014-06-25 16:29:58 +00:00
|
|
|
return exists->second;
|
|
|
|
|
|
|
|
//if we didn't, make it, remember it, and return it
|
|
|
|
std::shared_ptr<IGameListView> view;
|
|
|
|
|
2017-02-25 04:19:29 +00:00
|
|
|
bool themeHasVideoView = system->getTheme()->hasView("video");
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
//decide type
|
2017-03-24 19:30:20 +00:00
|
|
|
GameListViewType selectedViewType = AUTOMATIC;
|
|
|
|
|
|
|
|
std::string viewPreference = Settings::getInstance()->getString("GamelistViewStyle");
|
|
|
|
if (viewPreference.compare("basic") == 0)
|
|
|
|
selectedViewType = BASIC;
|
|
|
|
if (viewPreference.compare("detailed") == 0)
|
|
|
|
selectedViewType = DETAILED;
|
|
|
|
if (viewPreference.compare("video") == 0)
|
|
|
|
selectedViewType = VIDEO;
|
|
|
|
|
|
|
|
if (selectedViewType == AUTOMATIC)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2017-03-24 19:30:20 +00:00
|
|
|
std::vector<FileData*> files = system->getRootFolder()->getFilesRecursive(GAME | FOLDER);
|
2017-11-11 14:56:22 +00:00
|
|
|
for (auto it = files.cbegin(); it != files.cend(); it++)
|
2016-12-04 23:47:34 +00:00
|
|
|
{
|
2017-03-24 19:30:20 +00:00
|
|
|
if (themeHasVideoView && !(*it)->getVideoPath().empty())
|
|
|
|
{
|
|
|
|
selectedViewType = VIDEO;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!(*it)->getThumbnailPath().empty())
|
|
|
|
{
|
|
|
|
selectedViewType = DETAILED;
|
|
|
|
// Don't break out in case any subsequent files have video
|
|
|
|
}
|
2016-12-04 23:47:34 +00:00
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
2017-03-24 19:30:20 +00:00
|
|
|
|
|
|
|
// Create the view
|
|
|
|
switch (selectedViewType)
|
|
|
|
{
|
|
|
|
case VIDEO:
|
|
|
|
view = std::shared_ptr<IGameListView>(new VideoGameListView(mWindow, system->getRootFolder()));
|
|
|
|
break;
|
|
|
|
case DETAILED:
|
|
|
|
view = std::shared_ptr<IGameListView>(new DetailedGameListView(mWindow, system->getRootFolder()));
|
|
|
|
break;
|
|
|
|
// case GRID placeholder for future implementation.
|
|
|
|
// view = std::shared_ptr<IGameListView>(new GridGameListView(mWindow, system->getRootFolder()));
|
|
|
|
// break;
|
|
|
|
case BASIC:
|
|
|
|
default:
|
|
|
|
view = std::shared_ptr<IGameListView>(new BasicGameListView(mWindow, system->getRootFolder()));
|
|
|
|
break;
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
view->setTheme(system->getTheme());
|
|
|
|
|
|
|
|
std::vector<SystemData*>& sysVec = SystemData::sSystemVector;
|
2017-11-17 14:58:52 +00:00
|
|
|
int id = (int)(std::find(sysVec.cbegin(), sysVec.cend(), system) - sysVec.cbegin());
|
2014-06-25 16:29:58 +00:00
|
|
|
view->setPosition(id * (float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight() * 2);
|
|
|
|
|
|
|
|
addChild(view.get());
|
|
|
|
|
|
|
|
mGameListViews[system] = view;
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<SystemView> ViewController::getSystemListView()
|
|
|
|
{
|
|
|
|
//if we already made one, return that one
|
|
|
|
if(mSystemListView)
|
|
|
|
return mSystemListView;
|
|
|
|
|
|
|
|
mSystemListView = std::shared_ptr<SystemView>(new SystemView(mWindow));
|
|
|
|
addChild(mSystemListView.get());
|
|
|
|
mSystemListView->setPosition(0, (float)Renderer::getScreenHeight());
|
|
|
|
return mSystemListView;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ViewController::input(InputConfig* config, Input input)
|
|
|
|
{
|
|
|
|
if(mLockInput)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// open menu
|
|
|
|
if(config->isMappedTo("start", input) && input.value != 0)
|
|
|
|
{
|
|
|
|
// open menu
|
|
|
|
mWindow->pushGui(new GuiMenu(mWindow));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mCurrentView)
|
|
|
|
return mCurrentView->input(config, input);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewController::update(int deltaTime)
|
|
|
|
{
|
|
|
|
if(mCurrentView)
|
|
|
|
{
|
|
|
|
mCurrentView->update(deltaTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
updateSelf(deltaTime);
|
|
|
|
}
|
|
|
|
|
2017-10-28 20:24:35 +00:00
|
|
|
void ViewController::render(const Transform4x4f& parentTrans)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2017-10-28 20:24:35 +00:00
|
|
|
Transform4x4f trans = mCamera * parentTrans;
|
2017-10-30 19:43:58 +00:00
|
|
|
Transform4x4f transInverse;
|
|
|
|
transInverse.invert(trans);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
// camera position, position + size
|
2017-10-28 20:24:35 +00:00
|
|
|
Vector3f viewStart = transInverse.translation();
|
|
|
|
Vector3f viewEnd = transInverse * Vector3f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight(), 0);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2017-09-08 14:49:47 +00:00
|
|
|
// Keep track of UI mode changes.
|
|
|
|
monitorUIMode();
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
// draw systemview
|
|
|
|
getSystemListView()->render(trans);
|
2017-05-18 10:16:57 +00:00
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
// draw gamelists
|
2017-11-11 14:56:22 +00:00
|
|
|
for(auto it = mGameListViews.cbegin(); it != mGameListViews.cend(); it++)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
|
|
|
// clipping
|
2017-10-28 20:24:35 +00:00
|
|
|
Vector3f guiStart = it->second->getPosition();
|
|
|
|
Vector3f guiEnd = it->second->getPosition() + Vector3f(it->second->getSize().x(), it->second->getSize().y(), 0);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
if(guiEnd.x() >= viewStart.x() && guiEnd.y() >= viewStart.y() &&
|
|
|
|
guiStart.x() <= viewEnd.x() && guiStart.y() <= viewEnd.y())
|
2017-09-08 13:20:07 +00:00
|
|
|
it->second->render(trans);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(mWindow->peekGui() == this)
|
|
|
|
mWindow->renderHelpPromptsEarly();
|
|
|
|
|
|
|
|
// fade out
|
|
|
|
if(mFadeOpacity)
|
|
|
|
{
|
|
|
|
Renderer::setMatrix(parentTrans);
|
|
|
|
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x00000000 | (unsigned char)(mFadeOpacity * 255));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewController::preload()
|
|
|
|
{
|
2017-11-11 14:56:22 +00:00
|
|
|
for(auto it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); it++)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2017-09-08 13:20:07 +00:00
|
|
|
(*it)->getIndex()->resetFilters();
|
2014-06-25 16:29:58 +00:00
|
|
|
getGameListView(*it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme)
|
|
|
|
{
|
2017-11-11 14:56:22 +00:00
|
|
|
for(auto it = mGameListViews.cbegin(); it != mGameListViews.cend(); it++)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
|
|
|
if(it->second.get() == view)
|
|
|
|
{
|
|
|
|
bool isCurrent = (mCurrentView == it->second);
|
|
|
|
SystemData* system = it->first;
|
|
|
|
FileData* cursor = view->getCursor();
|
|
|
|
mGameListViews.erase(it);
|
|
|
|
|
|
|
|
if(reloadTheme)
|
|
|
|
system->loadTheme();
|
|
|
|
std::shared_ptr<IGameListView> newView = getGameListView(system);
|
2017-03-18 17:54:39 +00:00
|
|
|
|
|
|
|
// to counter having come from a placeholder
|
|
|
|
if (!cursor->isPlaceHolder()) {
|
|
|
|
newView->setCursor(cursor);
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
if(isCurrent)
|
|
|
|
mCurrentView = newView;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-12-04 23:47:34 +00:00
|
|
|
// Redisplay the current view
|
|
|
|
if (mCurrentView)
|
|
|
|
mCurrentView->onShow();
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ViewController::reloadAll()
|
|
|
|
{
|
2017-09-08 13:20:07 +00:00
|
|
|
// clear all gamelistviews
|
2014-06-25 16:29:58 +00:00
|
|
|
std::map<SystemData*, FileData*> cursorMap;
|
2017-11-11 14:56:22 +00:00
|
|
|
for(auto it = mGameListViews.cbegin(); it != mGameListViews.cend(); it++)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
|
|
|
cursorMap[it->first] = it->second->getCursor();
|
|
|
|
}
|
|
|
|
mGameListViews.clear();
|
|
|
|
|
2017-09-08 13:20:07 +00:00
|
|
|
|
|
|
|
// load themes, create gamelistviews and reset filters
|
2017-11-11 14:56:22 +00:00
|
|
|
for(auto it = cursorMap.cbegin(); it != cursorMap.cend(); it++)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
|
|
|
it->first->loadTheme();
|
2017-09-08 13:20:07 +00:00
|
|
|
it->first->getIndex()->resetFilters();
|
2014-06-25 16:29:58 +00:00
|
|
|
getGameListView(it->first)->setCursor(it->second);
|
|
|
|
}
|
|
|
|
|
2017-09-08 13:20:07 +00:00
|
|
|
// Rebuild SystemListView
|
2014-06-25 16:29:58 +00:00
|
|
|
mSystemListView.reset();
|
|
|
|
getSystemListView();
|
|
|
|
|
|
|
|
// update mCurrentView since the pointers changed
|
|
|
|
if(mState.viewing == GAME_LIST)
|
|
|
|
{
|
|
|
|
mCurrentView = getGameListView(mState.getSystem());
|
|
|
|
}else if(mState.viewing == SYSTEM_SELECT)
|
|
|
|
{
|
2017-01-22 23:28:06 +00:00
|
|
|
SystemData* system = mState.getSystem();
|
|
|
|
goToSystemView(SystemData::sSystemVector.front());
|
|
|
|
mSystemListView->goToSystem(system, false);
|
2014-06-25 16:29:58 +00:00
|
|
|
mCurrentView = mSystemListView;
|
|
|
|
}else{
|
|
|
|
goToSystemView(SystemData::sSystemVector.front());
|
|
|
|
}
|
|
|
|
|
|
|
|
updateHelpPrompts();
|
|
|
|
}
|
|
|
|
|
2017-09-08 14:49:47 +00:00
|
|
|
void ViewController::monitorUIMode()
|
|
|
|
{
|
|
|
|
std::string uimode = Settings::getInstance()->getString("UIMode");
|
|
|
|
if (uimode != mCurUIMode) // UIMODE HAS CHANGED
|
2017-10-24 15:38:25 +00:00
|
|
|
{
|
2017-09-08 13:20:07 +00:00
|
|
|
mWindow->renderLoadingScreen();
|
2017-09-08 14:49:47 +00:00
|
|
|
mCurUIMode = uimode;
|
|
|
|
reloadAll();
|
|
|
|
goToStart();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ViewController::isUIModeFull()
|
|
|
|
{
|
|
|
|
return ((mCurUIMode == "Full") && ! Settings::getInstance()->getBool("ForceKiosk"));
|
|
|
|
}
|
|
|
|
|
2017-09-08 13:20:07 +00:00
|
|
|
bool ViewController::isUIModeKid()
|
|
|
|
{
|
|
|
|
return (Settings::getInstance()->getBool("ForceKid") ||
|
|
|
|
((mCurUIMode == "Kid") && !Settings::getInstance()->getBool("ForceKiosk")));
|
|
|
|
}
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
std::vector<HelpPrompt> ViewController::getHelpPrompts()
|
|
|
|
{
|
|
|
|
std::vector<HelpPrompt> prompts;
|
|
|
|
if(!mCurrentView)
|
|
|
|
return prompts;
|
2017-05-18 10:16:57 +00:00
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
prompts = mCurrentView->getHelpPrompts();
|
|
|
|
prompts.push_back(HelpPrompt("start", "menu"));
|
|
|
|
|
|
|
|
return prompts;
|
|
|
|
}
|
|
|
|
|
|
|
|
HelpStyle ViewController::getHelpStyle()
|
|
|
|
{
|
|
|
|
if(!mCurrentView)
|
|
|
|
return GuiComponent::getHelpStyle();
|
|
|
|
|
|
|
|
return mCurrentView->getHelpStyle();
|
|
|
|
}
|