2020-09-15 20:57:54 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-06 14:48:05 +00:00
|
|
|
//
|
2020-09-15 20:57:54 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-21 12:25:28 +00:00
|
|
|
// SystemView.cpp
|
2020-06-06 14:48:05 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// Main system view.
|
2020-06-06 14:48:05 +00:00
|
|
|
//
|
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
#include "views/SystemView.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
|
|
|
|
|
#include "Log.h"
|
2014-06-25 16:29:58 +00:00
|
|
|
#include "Settings.h"
|
2020-06-17 20:13:07 +00:00
|
|
|
#include "Sound.h"
|
2022-01-17 20:53:23 +00:00
|
|
|
#include "UIModeController.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "Window.h"
|
2021-07-07 18:03:42 +00:00
|
|
|
#include "animations/LambdaAnimation.h"
|
|
|
|
|
#include "guis/GuiMsgBox.h"
|
|
|
|
|
#include "views/ViewController.h"
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-08-23 19:27:01 +00:00
|
|
|
#if defined(_WIN64)
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-01-19 17:01:54 +00:00
|
|
|
SystemView::SystemView()
|
2022-03-14 18:51:48 +00:00
|
|
|
: mRenderer {Renderer::getInstance()}
|
2022-03-24 22:05:23 +00:00
|
|
|
, mPrimary {nullptr}
|
|
|
|
|
, mPrimaryType {PrimaryType::CAROUSEL}
|
2022-09-20 19:16:39 +00:00
|
|
|
, mLastCursor {-1}
|
2022-03-14 18:51:48 +00:00
|
|
|
, mCamOffset {0.0f}
|
2022-02-06 13:01:40 +00:00
|
|
|
, mFadeOpacity {0.0f}
|
2022-02-08 23:05:06 +00:00
|
|
|
, mPreviousScrollVelocity {0}
|
2022-01-16 17:18:28 +00:00
|
|
|
, mUpdatedGameCount {false}
|
|
|
|
|
, mViewNeedsReload {true}
|
2022-01-30 20:16:03 +00:00
|
|
|
, mLegacyMode {false}
|
2022-02-19 20:22:46 +00:00
|
|
|
, mNavigated {false}
|
2022-03-11 22:20:27 +00:00
|
|
|
, mMaxFade {false}
|
|
|
|
|
, mFadeTransitions {false}
|
2022-09-23 20:47:49 +00:00
|
|
|
, mTransitionAnim {false}
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2022-02-11 22:38:23 +00:00
|
|
|
setSize(Renderer::getScreenWidth(), Renderer::getScreenHeight());
|
2022-02-06 19:13:53 +00:00
|
|
|
populate();
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-15 07:28:47 +00:00
|
|
|
SystemView::~SystemView()
|
|
|
|
|
{
|
2022-02-06 13:01:40 +00:00
|
|
|
if (mLegacyMode) {
|
|
|
|
|
// Delete any existing extras.
|
2022-02-06 19:13:53 +00:00
|
|
|
for (auto& entry : mSystemElements) {
|
2022-02-06 13:01:40 +00:00
|
|
|
for (auto extra : entry.legacyExtras)
|
|
|
|
|
delete extra;
|
|
|
|
|
entry.legacyExtras.clear();
|
|
|
|
|
}
|
2020-08-15 07:28:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-23 15:19:24 +00:00
|
|
|
void SystemView::onShow()
|
|
|
|
|
{
|
2022-09-24 14:50:14 +00:00
|
|
|
finishAnimation(0);
|
|
|
|
|
mFadeOpacity = 0.0f;
|
|
|
|
|
mTransitionAnim = false;
|
2022-09-23 15:19:24 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-19 21:46:52 +00:00
|
|
|
void SystemView::onTransition()
|
|
|
|
|
{
|
2022-03-24 22:05:23 +00:00
|
|
|
for (auto& anim : mSystemElements[mPrimary->getCursor()].lottieAnimComponents)
|
2022-02-19 21:46:52 +00:00
|
|
|
anim->setPauseAnimation(true);
|
2022-03-05 20:10:40 +00:00
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
for (auto& anim : mSystemElements[mPrimary->getCursor()].GIFAnimComponents)
|
2022-03-05 20:10:40 +00:00
|
|
|
anim->setPauseAnimation(true);
|
2022-09-23 20:47:49 +00:00
|
|
|
|
|
|
|
|
if (mFadeTransitions)
|
|
|
|
|
mTransitionAnim = true;
|
2022-02-19 21:46:52 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
void SystemView::goToSystem(SystemData* system, bool animate)
|
|
|
|
|
{
|
2022-03-24 22:05:23 +00:00
|
|
|
mPrimary->setCursor(system);
|
2022-02-14 18:32:07 +00:00
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
for (auto& selector : mSystemElements[mPrimary->getCursor()].gameSelectors) {
|
2022-02-14 18:32:07 +00:00
|
|
|
if (selector->getGameSelection() == GameSelectorComponent::GameSelection::RANDOM)
|
|
|
|
|
selector->setNeedsRefresh();
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
for (auto& video : mSystemElements[mPrimary->getCursor()].videoComponents)
|
2022-02-19 20:22:46 +00:00
|
|
|
video->setStaticVideo();
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
for (auto& anim : mSystemElements[mPrimary->getCursor()].lottieAnimComponents)
|
2022-02-19 21:46:52 +00:00
|
|
|
anim->resetFileAnimation();
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
for (auto& anim : mSystemElements[mPrimary->getCursor()].GIFAnimComponents)
|
2022-03-05 20:10:40 +00:00
|
|
|
anim->resetFileAnimation();
|
|
|
|
|
|
2022-02-14 18:32:07 +00:00
|
|
|
updateGameSelectors();
|
2020-11-15 19:06:33 +00:00
|
|
|
updateGameCount();
|
2022-02-19 20:22:46 +00:00
|
|
|
startViewVideos();
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (!animate)
|
2022-02-06 13:01:40 +00:00
|
|
|
finishSystemAnimation(0);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SystemView::input(InputConfig* config, Input input)
|
|
|
|
|
{
|
2022-02-19 20:22:46 +00:00
|
|
|
mNavigated = false;
|
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (input.value != 0) {
|
|
|
|
|
if (config->getDeviceId() == DEVICE_KEYBOARD && input.value && input.id == SDLK_r &&
|
2021-07-07 18:03:42 +00:00
|
|
|
SDL_GetModState() & KMOD_LCTRL && Settings::getInstance()->getBool("Debug")) {
|
2021-03-21 10:26:28 +00:00
|
|
|
LOG(LogDebug) << "SystemView::input(): Reloading all";
|
2022-08-14 19:31:59 +00:00
|
|
|
TextureResource::manualUnloadAll();
|
2022-01-04 20:49:22 +00:00
|
|
|
ViewController::getInstance()->reloadAll();
|
2020-06-21 12:25:28 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config->isMappedTo("a", input)) {
|
2022-03-24 22:05:23 +00:00
|
|
|
mPrimary->stopScrolling();
|
2022-02-19 20:22:46 +00:00
|
|
|
pauseViewVideos();
|
2022-03-24 22:05:23 +00:00
|
|
|
ViewController::getInstance()->goToGamelist(mPrimary->getSelected());
|
2021-11-15 21:43:06 +00:00
|
|
|
NavigationSounds::getInstance().playThemeNavigationSound(SELECTSOUND);
|
2020-06-21 12:25:28 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2021-05-16 12:03:13 +00:00
|
|
|
if (Settings::getInstance()->getBool("RandomAddButton") &&
|
2021-07-07 18:03:42 +00:00
|
|
|
(config->isMappedTo("leftthumbstickclick", input) ||
|
|
|
|
|
config->isMappedTo("rightthumbstickclick", input))) {
|
2021-05-16 12:03:13 +00:00
|
|
|
// Get a random system and jump to it.
|
2021-11-15 21:43:06 +00:00
|
|
|
NavigationSounds::getInstance().playThemeNavigationSound(SYSTEMBROWSESOUND);
|
2022-09-23 15:19:24 +00:00
|
|
|
mPrimary->stopScrolling();
|
2022-03-24 22:05:23 +00:00
|
|
|
mPrimary->setCursor(SystemData::getRandomSystem(mPrimary->getSelected()));
|
2020-06-21 12:25:28 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2020-09-18 16:40:22 +00:00
|
|
|
|
2022-05-16 17:55:08 +00:00
|
|
|
if (config->isMappedTo("back", input) &&
|
2021-07-07 18:03:42 +00:00
|
|
|
Settings::getInstance()->getBool("ScreensaverControls")) {
|
2020-11-10 21:18:20 +00:00
|
|
|
if (!mWindow->isScreensaverActive()) {
|
2022-01-04 20:49:22 +00:00
|
|
|
ViewController::getInstance()->stopScrolling();
|
|
|
|
|
ViewController::getInstance()->cancelViewTransitions();
|
2022-05-18 21:56:51 +00:00
|
|
|
mWindow->startScreensaver(false);
|
2020-11-10 21:18:20 +00:00
|
|
|
mWindow->renderScreensaver();
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
return mPrimary->input(config, input);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SystemView::update(int deltaTime)
|
|
|
|
|
{
|
2022-03-24 22:05:23 +00:00
|
|
|
if (!mPrimary->isAnimationPlaying(0))
|
2022-03-11 22:20:27 +00:00
|
|
|
mMaxFade = false;
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
mPrimary->update(deltaTime);
|
2022-02-19 20:22:46 +00:00
|
|
|
|
2022-09-20 19:16:39 +00:00
|
|
|
for (auto& video : mSystemElements[mPrimary->getCursor()].videoComponents) {
|
|
|
|
|
if (!isScrolling())
|
|
|
|
|
video->update(deltaTime);
|
|
|
|
|
}
|
2022-02-19 20:22:46 +00:00
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
for (auto& anim : mSystemElements[mPrimary->getCursor()].lottieAnimComponents)
|
2022-02-19 21:46:52 +00:00
|
|
|
anim->update(deltaTime);
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
for (auto& anim : mSystemElements[mPrimary->getCursor()].GIFAnimComponents)
|
2022-03-05 20:10:40 +00:00
|
|
|
anim->update(deltaTime);
|
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
GuiComponent::update(deltaTime);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-06 13:55:48 +00:00
|
|
|
void SystemView::render(const glm::mat4& parentTrans)
|
|
|
|
|
{
|
2022-03-28 15:47:34 +00:00
|
|
|
if (mPrimary == nullptr)
|
2022-02-06 13:55:48 +00:00
|
|
|
return; // Nothing to render.
|
|
|
|
|
|
2022-09-26 18:02:31 +00:00
|
|
|
bool transitionFade {false};
|
2022-02-19 20:22:46 +00:00
|
|
|
|
2022-03-11 22:20:27 +00:00
|
|
|
if (mNavigated && mMaxFade)
|
2022-09-26 18:02:31 +00:00
|
|
|
transitionFade = true;
|
2022-02-19 20:22:46 +00:00
|
|
|
|
2022-09-26 18:02:31 +00:00
|
|
|
if (!transitionFade)
|
2022-02-19 20:22:46 +00:00
|
|
|
renderElements(parentTrans, false);
|
2022-02-06 13:55:48 +00:00
|
|
|
glm::mat4 trans {getTransform() * parentTrans};
|
|
|
|
|
|
2022-09-25 20:57:43 +00:00
|
|
|
// Make sure that the primary component doesn't render outside our designated area.
|
2022-09-12 17:06:09 +00:00
|
|
|
mRenderer->pushClipRect(
|
|
|
|
|
glm::ivec2 {static_cast<int>(std::round(trans[3].x)),
|
|
|
|
|
static_cast<int>(std::round(trans[3].y))},
|
|
|
|
|
glm::ivec2 {static_cast<int>(std::round(mSize.x)), static_cast<int>(std::round(mSize.y))});
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
mPrimary->render(trans);
|
2022-09-25 18:55:26 +00:00
|
|
|
mRenderer->popClipRect();
|
2022-02-06 13:55:48 +00:00
|
|
|
|
2022-09-26 18:02:31 +00:00
|
|
|
if (!mPrimary->getFadeAbovePrimary() || !transitionFade)
|
2022-02-09 17:22:06 +00:00
|
|
|
renderElements(parentTrans, true);
|
2022-02-06 13:55:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SystemView::onThemeChanged(const std::shared_ptr<ThemeData>& /*theme*/)
|
|
|
|
|
{
|
|
|
|
|
LOG(LogDebug) << "SystemView::onThemeChanged()";
|
|
|
|
|
mViewNeedsReload = true;
|
|
|
|
|
populate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<HelpPrompt> SystemView::getHelpPrompts()
|
|
|
|
|
{
|
|
|
|
|
std::vector<HelpPrompt> prompts;
|
2022-03-24 22:05:23 +00:00
|
|
|
if (mCarousel != nullptr) {
|
|
|
|
|
if (mCarousel->getType() == CarouselComponent<SystemData*>::CarouselType::VERTICAL ||
|
|
|
|
|
mCarousel->getType() == CarouselComponent<SystemData*>::CarouselType::VERTICAL_WHEEL)
|
|
|
|
|
prompts.push_back(HelpPrompt("up/down", "choose"));
|
|
|
|
|
else
|
|
|
|
|
prompts.push_back(HelpPrompt("left/right", "choose"));
|
|
|
|
|
}
|
|
|
|
|
else if (mTextList != nullptr) {
|
2022-02-06 13:55:48 +00:00
|
|
|
prompts.push_back(HelpPrompt("up/down", "choose"));
|
2022-03-24 22:05:23 +00:00
|
|
|
}
|
2022-02-06 13:55:48 +00:00
|
|
|
|
|
|
|
|
prompts.push_back(HelpPrompt("a", "select"));
|
|
|
|
|
|
|
|
|
|
if (Settings::getInstance()->getBool("RandomAddButton"))
|
|
|
|
|
prompts.push_back(HelpPrompt("thumbstickclick", "random"));
|
|
|
|
|
|
2022-05-16 17:55:08 +00:00
|
|
|
if (Settings::getInstance()->getBool("ScreensaverControls"))
|
2022-02-06 13:55:48 +00:00
|
|
|
prompts.push_back(HelpPrompt("back", "screensaver"));
|
|
|
|
|
|
|
|
|
|
return prompts;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
void SystemView::onCursorChanged(const CursorState& state)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2022-03-24 22:05:23 +00:00
|
|
|
int cursor {mPrimary->getCursor()};
|
2022-02-14 18:32:07 +00:00
|
|
|
|
2022-09-20 19:16:39 +00:00
|
|
|
// Avoid double updates.
|
2022-09-23 15:19:24 +00:00
|
|
|
if (cursor != mLastCursor) {
|
|
|
|
|
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
|
|
|
|
if (selector->getGameSelection() == GameSelectorComponent::GameSelection::RANDOM)
|
|
|
|
|
selector->setNeedsRefresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-20 19:16:39 +00:00
|
|
|
|
|
|
|
|
mLastCursor = cursor;
|
|
|
|
|
|
2022-02-19 20:22:46 +00:00
|
|
|
for (auto& video : mSystemElements[cursor].videoComponents)
|
|
|
|
|
video->setStaticVideo();
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
for (auto& anim : mSystemElements[mPrimary->getCursor()].lottieAnimComponents)
|
2022-02-19 21:46:52 +00:00
|
|
|
anim->resetFileAnimation();
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
for (auto& anim : mSystemElements[mPrimary->getCursor()].GIFAnimComponents)
|
2022-03-05 20:10:40 +00:00
|
|
|
anim->resetFileAnimation();
|
|
|
|
|
|
2022-02-14 18:32:07 +00:00
|
|
|
updateGameSelectors();
|
2022-02-19 20:22:46 +00:00
|
|
|
startViewVideos();
|
2020-06-21 12:25:28 +00:00
|
|
|
updateHelpPrompts();
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
int scrollVelocity {mPrimary->getScrollingVelocity()};
|
2022-02-06 13:01:40 +00:00
|
|
|
float startPos {mCamOffset};
|
2022-03-24 22:05:23 +00:00
|
|
|
float posMax {static_cast<float>(mPrimary->getNumEntries())};
|
2022-02-14 18:32:07 +00:00
|
|
|
float target {static_cast<float>(cursor)};
|
2022-03-24 22:05:23 +00:00
|
|
|
float endPos {target};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
if (mPreviousScrollVelocity > 0 && scrollVelocity == 0 && mCamOffset > posMax - 1.0f)
|
|
|
|
|
startPos = 0.0f;
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
if (mPrimaryType == PrimaryType::CAROUSEL) {
|
|
|
|
|
// Find the shortest path to the target.
|
2022-05-15 16:58:39 +00:00
|
|
|
float dist {fabsf(endPos - startPos)};
|
2022-03-24 22:05:23 +00:00
|
|
|
|
|
|
|
|
if (fabs(target + posMax - startPos - scrollVelocity) < dist)
|
|
|
|
|
endPos = target + posMax; // Loop around the end (0 -> max).
|
|
|
|
|
if (fabs(target - posMax - startPos - scrollVelocity) < dist)
|
|
|
|
|
endPos = target - posMax; // Loop around the start (max - 1 -> -1).
|
|
|
|
|
}
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2022-02-08 23:05:06 +00:00
|
|
|
// Make sure transitions do not animate in reverse.
|
|
|
|
|
bool changedDirection {false};
|
2022-03-24 22:05:23 +00:00
|
|
|
if (mPreviousScrollVelocity != 0 && mPreviousScrollVelocity != scrollVelocity) {
|
|
|
|
|
if (scrollVelocity > 0 && startPos + scrollVelocity < posMax)
|
|
|
|
|
changedDirection = true;
|
|
|
|
|
}
|
2022-02-08 23:05:06 +00:00
|
|
|
|
|
|
|
|
if (!changedDirection && scrollVelocity > 0 && endPos < startPos)
|
|
|
|
|
endPos = endPos + posMax;
|
|
|
|
|
|
|
|
|
|
if (!changedDirection && scrollVelocity < 0 && endPos > startPos)
|
|
|
|
|
endPos = endPos - posMax;
|
|
|
|
|
|
|
|
|
|
if (scrollVelocity != 0)
|
|
|
|
|
mPreviousScrollVelocity = scrollVelocity;
|
|
|
|
|
|
2022-03-11 22:20:27 +00:00
|
|
|
std::string transitionStyle {Settings::getInstance()->getString("TransitionStyle")};
|
|
|
|
|
mFadeTransitions = transitionStyle == "fade";
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
|
Animation* anim;
|
2020-11-15 19:06:33 +00:00
|
|
|
|
2022-03-11 22:20:27 +00:00
|
|
|
if (transitionStyle == "fade") {
|
2022-02-06 13:01:40 +00:00
|
|
|
float startFade {mFadeOpacity};
|
2020-06-21 12:25:28 +00:00
|
|
|
anim = new LambdaAnimation(
|
2022-02-06 13:01:40 +00:00
|
|
|
[this, startFade, startPos, endPos, posMax](float t) {
|
2021-07-07 18:03:42 +00:00
|
|
|
t -= 1;
|
2022-02-09 17:22:06 +00:00
|
|
|
float f {glm::mix(startPos, endPos, t * t * t + 1.0f)};
|
|
|
|
|
if (f < 0.0f)
|
2021-07-07 18:03:42 +00:00
|
|
|
f += posMax;
|
|
|
|
|
if (f >= posMax)
|
|
|
|
|
f -= posMax;
|
|
|
|
|
|
|
|
|
|
t += 1;
|
2022-02-09 17:22:06 +00:00
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
if (t < 0.3f)
|
2022-02-09 17:22:06 +00:00
|
|
|
mFadeOpacity =
|
2022-02-06 13:01:40 +00:00
|
|
|
glm::mix(0.0f, 1.0f, glm::clamp(t / 0.2f + startFade, 0.0f, 1.0f));
|
2021-07-07 18:03:42 +00:00
|
|
|
else if (t < 0.7f)
|
2022-02-09 17:22:06 +00:00
|
|
|
mFadeOpacity = 1.0f;
|
2021-07-07 18:03:42 +00:00
|
|
|
else
|
2022-02-09 17:22:06 +00:00
|
|
|
mFadeOpacity = glm::mix(1.0f, 0.0f, glm::clamp((t - 0.6f) / 0.3f, 0.0f, 1.0f));
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
if (t > 0.5f)
|
2022-02-09 17:22:06 +00:00
|
|
|
mCamOffset = endPos;
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2022-03-11 22:20:27 +00:00
|
|
|
if (t >= 0.7f && t != 1.0f)
|
|
|
|
|
mMaxFade = true;
|
|
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
// Update the game count when the entire animation has been completed.
|
2022-03-11 22:20:27 +00:00
|
|
|
if (mFadeOpacity == 1.0f) {
|
|
|
|
|
mMaxFade = false;
|
2021-07-07 18:03:42 +00:00
|
|
|
updateGameCount();
|
2022-03-11 22:20:27 +00:00
|
|
|
}
|
2021-07-07 18:03:42 +00:00
|
|
|
},
|
|
|
|
|
500);
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2022-03-11 22:20:27 +00:00
|
|
|
else if (transitionStyle == "slide") {
|
2020-11-15 19:06:33 +00:00
|
|
|
mUpdatedGameCount = false;
|
2020-06-21 12:25:28 +00:00
|
|
|
anim = new LambdaAnimation(
|
2021-07-07 18:03:42 +00:00
|
|
|
[this, startPos, endPos, posMax](float t) {
|
|
|
|
|
t -= 1;
|
2022-02-09 17:22:06 +00:00
|
|
|
float f {glm::mix(startPos, endPos, t * t * t + 1.0f)};
|
|
|
|
|
if (f < 0.0f)
|
2021-07-07 18:03:42 +00:00
|
|
|
f += posMax;
|
|
|
|
|
if (f >= posMax)
|
|
|
|
|
f -= posMax;
|
|
|
|
|
|
2022-02-09 17:22:06 +00:00
|
|
|
mCamOffset = f;
|
2021-07-07 18:03:42 +00:00
|
|
|
|
|
|
|
|
// Hack to make the game count being updated in the middle of the animation.
|
2022-02-06 13:01:40 +00:00
|
|
|
bool update {false};
|
2021-07-07 18:03:42 +00:00
|
|
|
if (endPos == -1.0f && fabs(fabs(posMax) - fabs(mCamOffset)) > 0.5f &&
|
|
|
|
|
!mUpdatedGameCount) {
|
|
|
|
|
update = true;
|
|
|
|
|
}
|
|
|
|
|
else if (endPos > posMax && fabs(endPos - posMax - fabs(mCamOffset)) < 0.5f &&
|
|
|
|
|
!mUpdatedGameCount) {
|
|
|
|
|
update = true;
|
|
|
|
|
}
|
|
|
|
|
else if (fabs(fabs(endPos) - fabs(mCamOffset)) < 0.5f && !mUpdatedGameCount) {
|
|
|
|
|
update = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (update) {
|
|
|
|
|
mUpdatedGameCount = true;
|
|
|
|
|
updateGameCount();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
500);
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// Instant.
|
2020-11-15 19:06:33 +00:00
|
|
|
updateGameCount();
|
2020-06-21 12:25:28 +00:00
|
|
|
anim = new LambdaAnimation(
|
2021-07-07 18:03:42 +00:00
|
|
|
[this, startPos, endPos, posMax](float t) {
|
|
|
|
|
t -= 1;
|
2022-02-09 17:22:06 +00:00
|
|
|
float f {glm::mix(startPos, endPos, t * t * t + 1.0f)};
|
|
|
|
|
if (f < 0.0f)
|
2021-07-07 18:03:42 +00:00
|
|
|
f += posMax;
|
|
|
|
|
if (f >= posMax)
|
|
|
|
|
f -= posMax;
|
|
|
|
|
|
2022-02-09 17:22:06 +00:00
|
|
|
mCamOffset = endPos;
|
2021-07-07 18:03:42 +00:00
|
|
|
},
|
|
|
|
|
500);
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setAnimation(anim, 0, nullptr, false, 0);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-06 13:55:48 +00:00
|
|
|
void SystemView::populate()
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2022-03-28 15:47:34 +00:00
|
|
|
if (SystemData::sSystemVector.size() == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-02-09 17:22:06 +00:00
|
|
|
LOG(LogDebug) << "SystemView::populate(): Populating carousel";
|
|
|
|
|
|
2022-02-06 13:55:48 +00:00
|
|
|
auto themeSets = ThemeData::getThemeSets();
|
2022-04-09 13:57:37 +00:00
|
|
|
std::map<std::string, ThemeData::ThemeSet, ThemeData::StringComparator>::const_iterator
|
|
|
|
|
selectedSet {themeSets.find(Settings::getInstance()->getString("ThemeSet"))};
|
2017-05-27 07:40:18 +00:00
|
|
|
|
2022-02-06 13:55:48 +00:00
|
|
|
assert(selectedSet != themeSets.cend());
|
|
|
|
|
mLegacyMode = selectedSet->second.capabilities.legacyTheme;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2022-02-06 19:13:53 +00:00
|
|
|
if (mLegacyMode) {
|
|
|
|
|
mLegacySystemInfo = std::make_unique<TextComponent>(
|
|
|
|
|
"SYSTEM INFO", Font::get(FONT_SIZE_SMALL), 0x33333300, ALIGN_CENTER);
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-06 13:55:48 +00:00
|
|
|
for (auto it : SystemData::sSystemVector) {
|
|
|
|
|
const std::shared_ptr<ThemeData>& theme {it->getTheme()};
|
2022-04-17 08:40:18 +00:00
|
|
|
std::string itemPath;
|
|
|
|
|
std::string defaultItemPath;
|
2021-10-23 15:34:20 +00:00
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
if (mLegacyMode && mViewNeedsReload) {
|
|
|
|
|
if (mCarousel == nullptr) {
|
|
|
|
|
mCarousel = std::make_unique<CarouselComponent<SystemData*>>();
|
|
|
|
|
mPrimary = mCarousel.get();
|
2022-09-23 15:19:24 +00:00
|
|
|
// For legacy themes the carousel has a zIndex value of 40 instead of 50.
|
|
|
|
|
mPrimary->setDefaultZIndex(40.0f);
|
2022-03-24 22:05:23 +00:00
|
|
|
mPrimary->setCursorChangedCallback(
|
|
|
|
|
[&](const CursorState& state) { onCursorChanged(state); });
|
|
|
|
|
mPrimary->setCancelTransitionsCallback([&] {
|
|
|
|
|
ViewController::getInstance()->cancelViewTransitions();
|
|
|
|
|
mNavigated = true;
|
|
|
|
|
if (mSystemElements.size() > 1) {
|
|
|
|
|
for (auto& anim :
|
|
|
|
|
mSystemElements[mPrimary->getCursor()].lottieAnimComponents)
|
|
|
|
|
anim->setPauseAnimation(true);
|
|
|
|
|
for (auto& anim : mSystemElements[mPrimary->getCursor()].GIFAnimComponents)
|
|
|
|
|
anim->setPauseAnimation(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-02-09 17:22:06 +00:00
|
|
|
legacyApplyTheme(theme);
|
2022-03-24 22:05:23 +00:00
|
|
|
}
|
2021-10-23 15:34:20 +00:00
|
|
|
|
2022-02-06 13:55:48 +00:00
|
|
|
if (mLegacyMode) {
|
|
|
|
|
SystemViewElements elements;
|
|
|
|
|
elements.name = it->getName();
|
|
|
|
|
elements.legacyExtras = ThemeData::makeExtras(theme, "system");
|
2022-02-06 13:01:40 +00:00
|
|
|
|
2022-02-06 13:55:48 +00:00
|
|
|
// Sort the extras by z-index.
|
|
|
|
|
std::stable_sort(
|
|
|
|
|
elements.legacyExtras.begin(), elements.legacyExtras.end(),
|
|
|
|
|
[](GuiComponent* a, GuiComponent* b) { return b->getZIndex() > a->getZIndex(); });
|
2017-04-22 14:15:16 +00:00
|
|
|
|
2022-02-06 19:13:53 +00:00
|
|
|
mSystemElements.emplace_back(std::move(elements));
|
2022-03-18 19:14:51 +00:00
|
|
|
mSystemElements.back().helpStyle.applyTheme(theme, "system");
|
2022-02-06 13:55:48 +00:00
|
|
|
}
|
2022-02-06 13:01:40 +00:00
|
|
|
|
2022-02-06 13:55:48 +00:00
|
|
|
if (!mLegacyMode) {
|
|
|
|
|
SystemViewElements elements;
|
|
|
|
|
if (theme->hasView("system")) {
|
|
|
|
|
elements.name = it->getName();
|
2022-02-06 19:13:53 +00:00
|
|
|
elements.fullName = it->getFullName();
|
2022-02-06 13:55:48 +00:00
|
|
|
for (auto& element : theme->getViewElements("system").elements) {
|
2022-02-13 21:30:03 +00:00
|
|
|
if (element.second.type == "gameselector") {
|
2022-02-14 18:32:07 +00:00
|
|
|
elements.gameSelectors.emplace_back(
|
|
|
|
|
std::make_unique<GameSelectorComponent>(it));
|
|
|
|
|
elements.gameSelectors.back()->applyTheme(theme, "system", element.first,
|
|
|
|
|
ThemeFlags::ALL);
|
|
|
|
|
elements.gameSelectors.back()->setNeedsRefresh();
|
2022-02-13 21:30:03 +00:00
|
|
|
}
|
2022-03-24 22:05:23 +00:00
|
|
|
if (element.second.type == "textlist" || element.second.type == "carousel") {
|
|
|
|
|
if (element.second.type == "carousel" && mTextList != nullptr) {
|
|
|
|
|
LOG(LogWarning)
|
|
|
|
|
<< "SystemView::populate(): Multiple primary components "
|
|
|
|
|
<< "defined, skipping <carousel> configuration entry";
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (element.second.type == "textlist" && mCarousel != nullptr) {
|
|
|
|
|
LOG(LogWarning)
|
|
|
|
|
<< "SystemView::populate(): Multiple primary components "
|
|
|
|
|
<< "defined, skipping <textlist> configuration entry";
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (element.second.type == "carousel" && mCarousel == nullptr) {
|
|
|
|
|
mCarousel = std::make_unique<CarouselComponent<SystemData*>>();
|
|
|
|
|
mPrimary = mCarousel.get();
|
|
|
|
|
mPrimaryType = PrimaryType::CAROUSEL;
|
|
|
|
|
}
|
|
|
|
|
else if (element.second.type == "textlist" && mTextList == nullptr) {
|
|
|
|
|
mTextList = std::make_unique<TextListComponent<SystemData*>>();
|
|
|
|
|
mPrimary = mTextList.get();
|
|
|
|
|
mPrimaryType = PrimaryType::TEXTLIST;
|
|
|
|
|
}
|
|
|
|
|
mPrimary->setDefaultZIndex(50.0f);
|
|
|
|
|
mPrimary->applyTheme(theme, "system", element.first, ThemeFlags::ALL);
|
|
|
|
|
mPrimary->setCursorChangedCallback(
|
|
|
|
|
[&](const CursorState& state) { onCursorChanged(state); });
|
|
|
|
|
mPrimary->setCancelTransitionsCallback([&] {
|
|
|
|
|
ViewController::getInstance()->cancelViewTransitions();
|
|
|
|
|
mNavigated = true;
|
|
|
|
|
if (mSystemElements.size() > 1) {
|
|
|
|
|
for (auto& anim :
|
|
|
|
|
mSystemElements[mPrimary->getCursor()].lottieAnimComponents)
|
|
|
|
|
anim->setPauseAnimation(true);
|
|
|
|
|
for (auto& anim :
|
|
|
|
|
mSystemElements[mPrimary->getCursor()].GIFAnimComponents)
|
|
|
|
|
anim->setPauseAnimation(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (mCarousel != nullptr) {
|
2022-04-16 19:54:58 +00:00
|
|
|
if (element.second.has("staticItem"))
|
2022-04-17 08:40:18 +00:00
|
|
|
itemPath = element.second.get<std::string>("staticItem");
|
2022-04-16 19:54:58 +00:00
|
|
|
if (element.second.has("defaultItem"))
|
2022-04-17 08:40:18 +00:00
|
|
|
defaultItemPath = element.second.get<std::string>("defaultItem");
|
2022-03-24 22:05:23 +00:00
|
|
|
}
|
2022-02-06 19:36:06 +00:00
|
|
|
}
|
|
|
|
|
else if (element.second.type == "image") {
|
2022-09-10 14:07:43 +00:00
|
|
|
// If this is the first system, then forceload the images to avoid texture
|
|
|
|
|
// pop-in.
|
|
|
|
|
if (it == SystemData::sSystemVector.front())
|
|
|
|
|
elements.imageComponents.emplace_back(
|
|
|
|
|
std::make_unique<ImageComponent>(true));
|
|
|
|
|
else
|
|
|
|
|
elements.imageComponents.emplace_back(
|
|
|
|
|
std::make_unique<ImageComponent>());
|
|
|
|
|
|
2022-02-06 13:55:48 +00:00
|
|
|
elements.imageComponents.back()->setDefaultZIndex(30.0f);
|
|
|
|
|
elements.imageComponents.back()->applyTheme(theme, "system", element.first,
|
|
|
|
|
ThemeFlags::ALL);
|
|
|
|
|
elements.children.emplace_back(elements.imageComponents.back().get());
|
2022-02-06 13:01:40 +00:00
|
|
|
}
|
2022-02-19 20:22:46 +00:00
|
|
|
else if (element.second.type == "video") {
|
|
|
|
|
elements.videoComponents.emplace_back(
|
|
|
|
|
std::make_unique<VideoFFmpegComponent>());
|
|
|
|
|
elements.videoComponents.back()->setDefaultZIndex(30.0f);
|
|
|
|
|
elements.videoComponents.back()->setStaticVideo();
|
|
|
|
|
elements.videoComponents.back()->applyTheme(theme, "system", element.first,
|
|
|
|
|
ThemeFlags::ALL);
|
|
|
|
|
elements.children.emplace_back(elements.videoComponents.back().get());
|
|
|
|
|
}
|
2022-03-11 22:20:27 +00:00
|
|
|
else if (element.second.type == "animation" && element.second.has("path")) {
|
2022-03-05 20:10:40 +00:00
|
|
|
const std::string extension {Utils::FileSystem::getExtension(
|
|
|
|
|
element.second.get<std::string>("path"))};
|
|
|
|
|
if (extension == ".json") {
|
|
|
|
|
elements.lottieAnimComponents.emplace_back(
|
|
|
|
|
std::make_unique<LottieAnimComponent>());
|
|
|
|
|
elements.lottieAnimComponents.back()->setDefaultZIndex(35.0f);
|
|
|
|
|
elements.lottieAnimComponents.back()->applyTheme(
|
|
|
|
|
theme, "system", element.first, ThemeFlags::ALL);
|
|
|
|
|
elements.children.emplace_back(
|
|
|
|
|
elements.lottieAnimComponents.back().get());
|
|
|
|
|
}
|
|
|
|
|
else if (extension == ".gif") {
|
|
|
|
|
elements.GIFAnimComponents.emplace_back(
|
|
|
|
|
std::make_unique<GIFAnimComponent>());
|
|
|
|
|
elements.GIFAnimComponents.back()->setDefaultZIndex(35.0f);
|
|
|
|
|
elements.GIFAnimComponents.back()->applyTheme(
|
|
|
|
|
theme, "system", element.first, ThemeFlags::ALL);
|
|
|
|
|
elements.children.emplace_back(elements.GIFAnimComponents.back().get());
|
|
|
|
|
}
|
|
|
|
|
else if (extension == ".") {
|
|
|
|
|
LOG(LogWarning)
|
|
|
|
|
<< "SystemView::populate(): Invalid theme configuration, "
|
|
|
|
|
"animation file extension is missing";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
LOG(LogWarning)
|
|
|
|
|
<< "SystemView::populate(): Invalid theme configuration, "
|
|
|
|
|
"animation file extension defined as \""
|
|
|
|
|
<< extension << "\"";
|
|
|
|
|
}
|
2022-02-19 21:46:52 +00:00
|
|
|
}
|
2022-02-06 13:55:48 +00:00
|
|
|
else if (element.second.type == "text") {
|
2022-02-13 10:45:06 +00:00
|
|
|
if (element.second.has("systemdata") &&
|
|
|
|
|
element.second.get<std::string>("systemdata").substr(0, 9) ==
|
|
|
|
|
"gamecount") {
|
|
|
|
|
if (element.second.has("systemdata")) {
|
2022-02-06 19:13:53 +00:00
|
|
|
elements.gameCountComponents.emplace_back(
|
|
|
|
|
std::make_unique<TextComponent>());
|
|
|
|
|
elements.gameCountComponents.back()->setDefaultZIndex(40.0f);
|
|
|
|
|
elements.gameCountComponents.back()->applyTheme(
|
|
|
|
|
theme, "system", element.first, ThemeFlags::ALL);
|
|
|
|
|
elements.children.emplace_back(
|
|
|
|
|
elements.gameCountComponents.back().get());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
elements.textComponents.emplace_back(std::make_unique<TextComponent>());
|
|
|
|
|
elements.textComponents.back()->setDefaultZIndex(40.0f);
|
|
|
|
|
elements.textComponents.back()->applyTheme(
|
|
|
|
|
theme, "system", element.first, ThemeFlags::ALL);
|
|
|
|
|
elements.children.emplace_back(elements.textComponents.back().get());
|
|
|
|
|
}
|
2022-02-06 13:01:40 +00:00
|
|
|
}
|
2022-02-20 14:49:32 +00:00
|
|
|
else if (element.second.type == "datetime") {
|
|
|
|
|
elements.dateTimeComponents.emplace_back(
|
|
|
|
|
std::make_unique<DateTimeComponent>());
|
|
|
|
|
elements.dateTimeComponents.back()->setDefaultZIndex(40.0f);
|
|
|
|
|
elements.dateTimeComponents.back()->applyTheme(
|
|
|
|
|
theme, "system", element.first, ThemeFlags::ALL);
|
2022-03-18 21:16:53 +00:00
|
|
|
elements.dateTimeComponents.back()->setVisible(false);
|
2022-02-20 14:49:32 +00:00
|
|
|
elements.children.emplace_back(elements.dateTimeComponents.back().get());
|
|
|
|
|
}
|
2022-03-18 21:16:53 +00:00
|
|
|
else if (element.second.type == "rating") {
|
|
|
|
|
elements.ratingComponents.emplace_back(std::make_unique<RatingComponent>());
|
|
|
|
|
elements.ratingComponents.back()->setDefaultZIndex(45.0f);
|
|
|
|
|
elements.ratingComponents.back()->applyTheme(theme, "system", element.first,
|
|
|
|
|
ThemeFlags::ALL);
|
|
|
|
|
elements.ratingComponents.back()->setVisible(false);
|
2022-08-17 15:07:52 +00:00
|
|
|
elements.ratingComponents.back()->setOpacity(
|
|
|
|
|
elements.ratingComponents.back()->getOpacity());
|
2022-03-18 21:16:53 +00:00
|
|
|
elements.children.emplace_back(elements.ratingComponents.back().get());
|
|
|
|
|
}
|
2022-02-06 13:01:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
2021-10-15 20:54:04 +00:00
|
|
|
|
2022-02-06 13:55:48 +00:00
|
|
|
std::stable_sort(
|
|
|
|
|
elements.children.begin(), elements.children.end(),
|
|
|
|
|
[](GuiComponent* a, GuiComponent* b) { return b->getZIndex() > a->getZIndex(); });
|
|
|
|
|
|
|
|
|
|
std::stable_sort(elements.imageComponents.begin(), elements.imageComponents.end(),
|
|
|
|
|
[](const std::unique_ptr<ImageComponent>& a,
|
|
|
|
|
const std::unique_ptr<ImageComponent>& b) {
|
|
|
|
|
return b->getZIndex() > a->getZIndex();
|
|
|
|
|
});
|
|
|
|
|
std::stable_sort(elements.textComponents.begin(), elements.textComponents.end(),
|
|
|
|
|
[](const std::unique_ptr<TextComponent>& a,
|
|
|
|
|
const std::unique_ptr<TextComponent>& b) {
|
|
|
|
|
return b->getZIndex() > a->getZIndex();
|
|
|
|
|
});
|
2022-02-06 19:13:53 +00:00
|
|
|
mSystemElements.emplace_back(std::move(elements));
|
2022-03-18 19:14:51 +00:00
|
|
|
mSystemElements.back().helpStyle.applyTheme(theme, "system");
|
2022-02-06 13:01:40 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
if (mPrimary == nullptr) {
|
|
|
|
|
mCarousel = std::make_unique<CarouselComponent<SystemData*>>();
|
|
|
|
|
mPrimary = mCarousel.get();
|
|
|
|
|
mPrimaryType = PrimaryType::CAROUSEL;
|
|
|
|
|
mPrimary->setDefaultZIndex(50.0f);
|
|
|
|
|
mPrimary->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
|
|
|
|
mPrimary->setCursorChangedCallback(
|
|
|
|
|
[&](const CursorState& state) { onCursorChanged(state); });
|
|
|
|
|
mPrimary->setCancelTransitionsCallback([&] {
|
|
|
|
|
ViewController::getInstance()->cancelViewTransitions();
|
|
|
|
|
mNavigated = true;
|
|
|
|
|
if (mSystemElements.size() > 1) {
|
|
|
|
|
for (auto& anim : mSystemElements[mPrimary->getCursor()].lottieAnimComponents)
|
|
|
|
|
anim->setPauseAnimation(true);
|
|
|
|
|
for (auto& anim : mSystemElements[mPrimary->getCursor()].GIFAnimComponents)
|
|
|
|
|
anim->setPauseAnimation(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-02-06 13:55:48 +00:00
|
|
|
|
2022-11-03 11:31:42 +00:00
|
|
|
auto letterCaseFunc = [&it, this](std::string& name) {
|
|
|
|
|
LetterCase letterCase {LetterCase::NONE};
|
|
|
|
|
if (it->isCollection()) {
|
|
|
|
|
letterCase = mPrimary->getLetterCaseCollections();
|
|
|
|
|
if (letterCase == LetterCase::NONE)
|
|
|
|
|
letterCase = mPrimary->getLetterCase();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
letterCase = mPrimary->getLetterCase();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (letterCase == LetterCase::UPPERCASE)
|
|
|
|
|
name = Utils::String::toUpper(name);
|
|
|
|
|
else if (letterCase == LetterCase::LOWERCASE)
|
|
|
|
|
name = Utils::String::toLower(name);
|
|
|
|
|
else if (letterCase == LetterCase::CAPITALIZED)
|
|
|
|
|
name = Utils::String::toCapitalized(name);
|
|
|
|
|
};
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
if (mCarousel != nullptr) {
|
|
|
|
|
CarouselComponent<SystemData*>::Entry entry;
|
2022-11-03 11:31:42 +00:00
|
|
|
// Keep showing only the short name for legacy themes to maintain maximum
|
|
|
|
|
// backward compatibility. This also applies to unreadable theme sets.
|
|
|
|
|
if (mLegacyMode)
|
|
|
|
|
entry.name = it->getName();
|
|
|
|
|
else
|
|
|
|
|
entry.name = it->getFullName();
|
|
|
|
|
letterCaseFunc(entry.name);
|
2022-03-24 22:05:23 +00:00
|
|
|
entry.object = it;
|
2022-04-17 08:40:18 +00:00
|
|
|
entry.data.itemPath = itemPath;
|
|
|
|
|
entry.data.defaultItemPath = defaultItemPath;
|
2022-03-24 22:05:23 +00:00
|
|
|
mCarousel->addEntry(entry, theme);
|
|
|
|
|
}
|
2022-11-03 11:31:42 +00:00
|
|
|
else if (mTextList != nullptr) {
|
2022-03-24 22:05:23 +00:00
|
|
|
TextListComponent<SystemData*>::Entry entry;
|
|
|
|
|
entry.name = it->getFullName();
|
2022-11-03 11:31:42 +00:00
|
|
|
letterCaseFunc(entry.name);
|
2022-03-24 22:05:23 +00:00
|
|
|
entry.object = it;
|
|
|
|
|
entry.data.colorId = 0;
|
|
|
|
|
mTextList->addEntry(entry);
|
|
|
|
|
}
|
2021-10-23 15:34:20 +00:00
|
|
|
}
|
2022-02-06 13:01:40 +00:00
|
|
|
|
2022-02-06 19:13:53 +00:00
|
|
|
for (auto& elements : mSystemElements) {
|
|
|
|
|
for (auto& text : elements.textComponents) {
|
2022-02-13 10:45:06 +00:00
|
|
|
if (text->getThemeSystemdata() != "") {
|
|
|
|
|
if (text->getThemeSystemdata() == "name")
|
2022-02-06 19:13:53 +00:00
|
|
|
text->setValue(elements.name);
|
2022-02-13 10:45:06 +00:00
|
|
|
else if (text->getThemeSystemdata() == "fullname")
|
2022-02-06 19:13:53 +00:00
|
|
|
text->setValue(elements.fullName);
|
|
|
|
|
else
|
2022-02-13 10:45:06 +00:00
|
|
|
text->setValue(text->getThemeSystemdata());
|
2022-02-06 19:13:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
if (mPrimary->getNumEntries() == 0) {
|
2022-02-06 13:55:48 +00:00
|
|
|
// Something is wrong, there is not a single system to show, check if UI mode is not full.
|
|
|
|
|
if (!UIModeController::getInstance()->isUIModeFull()) {
|
|
|
|
|
Settings::getInstance()->setString("UIMode", "full");
|
|
|
|
|
mWindow->pushGui(new GuiMsgBox(
|
|
|
|
|
getHelpStyle(),
|
|
|
|
|
"The selected UI mode has nothing to show,\n returning to UI mode \"Full\"", "OK",
|
|
|
|
|
nullptr));
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-11 22:20:27 +00:00
|
|
|
|
|
|
|
|
mFadeTransitions = Settings::getInstance()->getString("TransitionStyle") == "fade";
|
2017-03-13 21:11:07 +00:00
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2022-02-06 13:55:48 +00:00
|
|
|
void SystemView::updateGameCount()
|
2017-03-13 21:11:07 +00:00
|
|
|
{
|
2022-02-06 13:55:48 +00:00
|
|
|
std::pair<unsigned int, unsigned int> gameCount =
|
2022-03-24 22:05:23 +00:00
|
|
|
mPrimary->getSelected()->getDisplayedGameCount();
|
2022-02-06 13:55:48 +00:00
|
|
|
std::stringstream ss;
|
2022-02-06 19:13:53 +00:00
|
|
|
std::stringstream ssGames;
|
|
|
|
|
std::stringstream ssFavorites;
|
|
|
|
|
bool games {false};
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
if (!mPrimary->getSelected()->isGameSystem()) {
|
2022-02-06 19:13:53 +00:00
|
|
|
ss << "Configuration";
|
|
|
|
|
}
|
2022-03-24 22:05:23 +00:00
|
|
|
else if (mPrimary->getSelected()->isCollection() &&
|
|
|
|
|
(mPrimary->getSelected()->getName() == "favorites")) {
|
2022-02-06 19:13:53 +00:00
|
|
|
ss << gameCount.first << " Game" << (gameCount.first == 1 ? " " : "s");
|
|
|
|
|
}
|
2022-03-24 22:05:23 +00:00
|
|
|
else if (mPrimary->getSelected()->isCollection() &&
|
|
|
|
|
(mPrimary->getSelected()->getName() == "recent")) {
|
2022-02-06 19:13:53 +00:00
|
|
|
// The "recent" gamelist has probably been trimmed after sorting, so we'll cap it at
|
|
|
|
|
// its maximum limit of 50 games.
|
|
|
|
|
ss << (gameCount.first > 50 ? 50 : gameCount.first) << " Game"
|
|
|
|
|
<< (gameCount.first == 1 ? " " : "s");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ss << gameCount.first << " Game" << (gameCount.first == 1 ? " " : "s ") << "("
|
|
|
|
|
<< gameCount.second << " Favorite" << (gameCount.second == 1 ? ")" : "s)");
|
|
|
|
|
ssGames << gameCount.first << " Game" << (gameCount.first == 1 ? " " : "s ");
|
|
|
|
|
ssFavorites << gameCount.second << " Favorite" << (gameCount.second == 1 ? "" : "s");
|
|
|
|
|
games = true;
|
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2022-02-06 19:13:53 +00:00
|
|
|
if (mLegacyMode) {
|
|
|
|
|
mLegacySystemInfo->setText(ss.str());
|
|
|
|
|
}
|
|
|
|
|
else {
|
2022-03-24 22:05:23 +00:00
|
|
|
for (auto& gameCount : mSystemElements[mPrimary->getCursor()].gameCountComponents) {
|
2022-02-13 10:45:06 +00:00
|
|
|
if (gameCount->getThemeSystemdata() == "gamecount") {
|
2022-02-06 19:13:53 +00:00
|
|
|
gameCount->setValue(ss.str());
|
|
|
|
|
}
|
2022-02-13 10:45:06 +00:00
|
|
|
else if (gameCount->getThemeSystemdata() == "gamecount_games") {
|
2022-02-06 19:13:53 +00:00
|
|
|
if (games)
|
|
|
|
|
gameCount->setValue(ssGames.str());
|
|
|
|
|
else
|
|
|
|
|
gameCount->setValue(ss.str());
|
|
|
|
|
}
|
2022-02-13 10:45:06 +00:00
|
|
|
else if (gameCount->getThemeSystemdata() == "gamecount_favorites") {
|
2022-02-06 19:13:53 +00:00
|
|
|
gameCount->setValue(ssFavorites.str());
|
|
|
|
|
}
|
|
|
|
|
else {
|
2022-02-13 10:45:06 +00:00
|
|
|
gameCount->setValue(gameCount->getThemeSystemdata());
|
2022-02-06 19:13:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-13 21:11:07 +00:00
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2022-02-14 18:32:07 +00:00
|
|
|
void SystemView::updateGameSelectors()
|
2022-02-13 21:30:03 +00:00
|
|
|
{
|
2022-02-14 18:32:07 +00:00
|
|
|
if (mLegacyMode)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
int cursor {mPrimary->getCursor()};
|
2022-02-13 21:30:03 +00:00
|
|
|
|
2022-02-14 18:32:07 +00:00
|
|
|
if (mSystemElements[cursor].gameSelectors.size() == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool multipleSelectors {mSystemElements[cursor].gameSelectors.size() > 1};
|
|
|
|
|
|
|
|
|
|
for (auto& image : mSystemElements[cursor].imageComponents) {
|
|
|
|
|
if (image->getThemeImageTypes().size() == 0)
|
|
|
|
|
continue;
|
|
|
|
|
GameSelectorComponent* gameSelector {nullptr};
|
|
|
|
|
if (multipleSelectors) {
|
|
|
|
|
const std::string& imageSelector {image->getThemeGameSelector()};
|
|
|
|
|
if (imageSelector == "") {
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
LOG(LogWarning) << "SystemView::updateGameSelectors(): Multiple gameselector "
|
|
|
|
|
"elements defined but image element does not state which one to "
|
2022-02-19 20:22:46 +00:00
|
|
|
"use, selecting first entry";
|
2022-02-14 18:32:07 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
2022-03-18 21:16:53 +00:00
|
|
|
if (selector->getSelectorName() == imageSelector) {
|
2022-02-14 18:32:07 +00:00
|
|
|
gameSelector = selector.get();
|
2022-03-18 21:16:53 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2022-02-14 18:32:07 +00:00
|
|
|
}
|
2022-02-19 20:22:46 +00:00
|
|
|
if (gameSelector == nullptr) {
|
|
|
|
|
LOG(LogWarning)
|
|
|
|
|
<< "SystemView::updateGameSelectors(): Invalid gameselector \""
|
|
|
|
|
<< imageSelector << "\" defined for image element, selecting first entry";
|
2022-02-14 18:32:07 +00:00
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
2022-02-19 20:22:46 +00:00
|
|
|
}
|
2022-02-14 18:32:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
}
|
|
|
|
|
gameSelector->refreshGames();
|
|
|
|
|
std::vector<FileData*> games {gameSelector->getGames()};
|
2022-02-13 21:30:03 +00:00
|
|
|
if (!games.empty()) {
|
2022-02-14 18:32:07 +00:00
|
|
|
std::string path;
|
|
|
|
|
for (auto& imageType : image->getThemeImageTypes()) {
|
|
|
|
|
if (imageType == "image") {
|
|
|
|
|
path = games.front()->getImagePath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
image->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "miximage") {
|
|
|
|
|
path = games.front()->getMiximagePath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
image->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "marquee") {
|
|
|
|
|
path = games.front()->getMarqueePath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
image->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "screenshot") {
|
|
|
|
|
path = games.front()->getScreenshotPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
image->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "titlescreen") {
|
|
|
|
|
path = games.front()->getTitleScreenPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
image->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-02-13 21:30:03 +00:00
|
|
|
}
|
2022-02-14 18:32:07 +00:00
|
|
|
else if (imageType == "cover") {
|
|
|
|
|
path = games.front()->getCoverPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
image->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "backcover") {
|
|
|
|
|
path = games.front()->getBackCoverPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
image->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "3dbox") {
|
|
|
|
|
path = games.front()->get3DBoxPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
image->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-07 15:32:42 +00:00
|
|
|
else if (imageType == "physicalmedia") {
|
|
|
|
|
path = games.front()->getPhysicalMediaPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
image->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-14 18:32:07 +00:00
|
|
|
else if (imageType == "fanart") {
|
|
|
|
|
path = games.front()->getFanArtPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
image->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// This is needed so the default image is set if no game media was found.
|
|
|
|
|
if (path == "" && image->getThemeImageTypes().size() > 0)
|
|
|
|
|
image->setImage("");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
image->setImage("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-19 20:22:46 +00:00
|
|
|
for (auto& video : mSystemElements[cursor].videoComponents) {
|
|
|
|
|
// If a static video has been set, then don't attempt to find a gameselector entry.
|
|
|
|
|
if (video->hasStaticVideo())
|
|
|
|
|
continue;
|
|
|
|
|
GameSelectorComponent* gameSelector {nullptr};
|
|
|
|
|
if (multipleSelectors) {
|
|
|
|
|
const std::string& videoSelector {video->getThemeGameSelector()};
|
|
|
|
|
if (videoSelector == "") {
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
LOG(LogWarning) << "SystemView::updateGameSelectors(): Multiple gameselector "
|
|
|
|
|
"elements defined but video element does not state which one to "
|
|
|
|
|
"use, selecting first entry";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
2022-03-18 21:16:53 +00:00
|
|
|
if (selector->getSelectorName() == videoSelector) {
|
2022-02-19 20:22:46 +00:00
|
|
|
gameSelector = selector.get();
|
2022-03-18 21:16:53 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2022-02-19 20:22:46 +00:00
|
|
|
}
|
|
|
|
|
if (gameSelector == nullptr) {
|
|
|
|
|
LOG(LogWarning)
|
|
|
|
|
<< "SystemView::updateGameSelectors(): Invalid gameselector \""
|
|
|
|
|
<< videoSelector << "\" defined for video element, selecting first entry";
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
}
|
|
|
|
|
gameSelector->refreshGames();
|
|
|
|
|
std::vector<FileData*> games {gameSelector->getGames()};
|
|
|
|
|
if (!games.empty()) {
|
|
|
|
|
if (!video->setVideo(games.front()->getVideoPath()))
|
|
|
|
|
video->setDefaultVideo();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto& video : mSystemElements[cursor].videoComponents) {
|
2022-09-15 15:27:16 +00:00
|
|
|
if (video->hasStaticVideo() || video->getThemeImageTypes().size() == 0)
|
2022-02-19 20:22:46 +00:00
|
|
|
continue;
|
|
|
|
|
GameSelectorComponent* gameSelector {nullptr};
|
|
|
|
|
if (multipleSelectors) {
|
|
|
|
|
const std::string& imageSelector {video->getThemeGameSelector()};
|
|
|
|
|
if (imageSelector == "") {
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
LOG(LogWarning) << "SystemView::updateGameSelectors(): Multiple gameselector "
|
|
|
|
|
"elements defined but video element does not state which one to "
|
|
|
|
|
"use, selecting first entry";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
2022-03-18 21:16:53 +00:00
|
|
|
if (selector->getSelectorName() == imageSelector) {
|
2022-02-19 20:22:46 +00:00
|
|
|
gameSelector = selector.get();
|
2022-03-18 21:16:53 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2022-02-19 20:22:46 +00:00
|
|
|
}
|
|
|
|
|
if (gameSelector == nullptr) {
|
|
|
|
|
LOG(LogWarning)
|
|
|
|
|
<< "SystemView::updateGameSelectors(): Invalid gameselector \""
|
|
|
|
|
<< imageSelector << "\" defined for video element, selecting first entry";
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
}
|
|
|
|
|
gameSelector->refreshGames();
|
|
|
|
|
std::vector<FileData*> games {gameSelector->getGames()};
|
|
|
|
|
if (!games.empty()) {
|
|
|
|
|
std::string path;
|
|
|
|
|
for (auto& imageType : video->getThemeImageTypes()) {
|
|
|
|
|
if (imageType == "image") {
|
|
|
|
|
path = games.front()->getImagePath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
video->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "miximage") {
|
|
|
|
|
path = games.front()->getMiximagePath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
video->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "marquee") {
|
|
|
|
|
path = games.front()->getMarqueePath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
video->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "screenshot") {
|
|
|
|
|
path = games.front()->getScreenshotPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
video->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "titlescreen") {
|
|
|
|
|
path = games.front()->getTitleScreenPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
video->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "cover") {
|
|
|
|
|
path = games.front()->getCoverPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
video->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "backcover") {
|
|
|
|
|
path = games.front()->getBackCoverPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
video->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "3dbox") {
|
|
|
|
|
path = games.front()->get3DBoxPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
video->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-07 15:32:42 +00:00
|
|
|
else if (imageType == "physicalmedia") {
|
|
|
|
|
path = games.front()->getPhysicalMediaPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
video->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-19 20:22:46 +00:00
|
|
|
else if (imageType == "fanart") {
|
|
|
|
|
path = games.front()->getFanArtPath();
|
|
|
|
|
if (path != "") {
|
|
|
|
|
video->setImage(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// This is needed so the default image is set if no game media was found.
|
|
|
|
|
if (path == "" && video->getThemeImageTypes().size() > 0)
|
|
|
|
|
video->setImage("");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
video->setImage("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-14 18:32:07 +00:00
|
|
|
for (auto& text : mSystemElements[cursor].textComponents) {
|
|
|
|
|
if (text->getThemeMetadata() == "")
|
|
|
|
|
continue;
|
|
|
|
|
GameSelectorComponent* gameSelector {nullptr};
|
|
|
|
|
if (multipleSelectors) {
|
|
|
|
|
const std::string& textSelector {text->getThemeGameSelector()};
|
|
|
|
|
if (textSelector == "") {
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
LOG(LogWarning) << "SystemView::updateGameSelectors(): Multiple gameselector "
|
|
|
|
|
"elements defined but text element does not state which one to "
|
2022-02-20 14:49:32 +00:00
|
|
|
"use, selecting first entry";
|
2022-02-13 21:30:03 +00:00
|
|
|
}
|
2022-02-14 18:32:07 +00:00
|
|
|
else {
|
|
|
|
|
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
2022-03-18 21:16:53 +00:00
|
|
|
if (selector->getSelectorName() == textSelector) {
|
2022-02-14 18:32:07 +00:00
|
|
|
gameSelector = selector.get();
|
2022-03-18 21:16:53 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2022-02-14 18:32:07 +00:00
|
|
|
}
|
2022-02-20 14:49:32 +00:00
|
|
|
if (gameSelector == nullptr) {
|
|
|
|
|
LOG(LogWarning)
|
|
|
|
|
<< "SystemView::updateGameSelectors(): Invalid gameselector \""
|
|
|
|
|
<< textSelector << "\" defined for text element, selecting first entry";
|
2022-02-14 18:32:07 +00:00
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
2022-02-20 14:49:32 +00:00
|
|
|
}
|
2022-02-14 18:32:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
}
|
|
|
|
|
gameSelector->refreshGames();
|
|
|
|
|
std::vector<FileData*> games {gameSelector->getGames()};
|
|
|
|
|
if (!games.empty()) {
|
|
|
|
|
const std::string metadata {text->getThemeMetadata()};
|
|
|
|
|
if (metadata == "name")
|
|
|
|
|
text->setValue(games.front()->metadata.get("name"));
|
|
|
|
|
if (metadata == "description")
|
|
|
|
|
text->setValue(games.front()->metadata.get("desc"));
|
2022-06-06 20:44:48 +00:00
|
|
|
if (metadata == "rating")
|
|
|
|
|
text->setValue(
|
|
|
|
|
RatingComponent::getRatingValue(games.front()->metadata.get("rating")));
|
2022-02-14 18:32:07 +00:00
|
|
|
if (metadata == "developer")
|
|
|
|
|
text->setValue(games.front()->metadata.get("developer"));
|
|
|
|
|
if (metadata == "publisher")
|
|
|
|
|
text->setValue(games.front()->metadata.get("publisher"));
|
|
|
|
|
if (metadata == "genre")
|
|
|
|
|
text->setValue(games.front()->metadata.get("genre"));
|
|
|
|
|
if (metadata == "players")
|
|
|
|
|
text->setValue(games.front()->metadata.get("players"));
|
|
|
|
|
if (metadata == "favorite")
|
|
|
|
|
text->setValue(games.front()->metadata.get("favorite") == "true" ? "yes" : "no");
|
|
|
|
|
if (metadata == "completed")
|
|
|
|
|
text->setValue(games.front()->metadata.get("completed") == "true" ? "yes" : "no");
|
|
|
|
|
if (metadata == "kidgame")
|
|
|
|
|
text->setValue(games.front()->metadata.get("kidgame") == "true" ? "yes" : "no");
|
|
|
|
|
if (metadata == "broken")
|
|
|
|
|
text->setValue(games.front()->metadata.get("broken") == "true" ? "yes" : "no");
|
|
|
|
|
if (metadata == "playcount")
|
|
|
|
|
text->setValue(games.front()->metadata.get("playcount"));
|
|
|
|
|
if (metadata == "altemulator")
|
|
|
|
|
text->setValue(games.front()->metadata.get("altemulator"));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
text->setValue("");
|
2022-02-13 21:30:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-02-20 14:49:32 +00:00
|
|
|
|
|
|
|
|
for (auto& dateTime : mSystemElements[cursor].dateTimeComponents) {
|
|
|
|
|
if (dateTime->getThemeMetadata() == "")
|
|
|
|
|
continue;
|
|
|
|
|
GameSelectorComponent* gameSelector {nullptr};
|
|
|
|
|
if (multipleSelectors) {
|
|
|
|
|
const std::string& dateTimeSelector {dateTime->getThemeGameSelector()};
|
|
|
|
|
if (dateTimeSelector == "") {
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
LOG(LogWarning) << "SystemView::updateGameSelectors(): Multiple gameselector "
|
|
|
|
|
"elements defined but datetime element does not state which one "
|
|
|
|
|
"to use, selecting first entry";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
2022-03-18 21:16:53 +00:00
|
|
|
if (selector->getSelectorName() == dateTimeSelector) {
|
2022-02-20 14:49:32 +00:00
|
|
|
gameSelector = selector.get();
|
2022-03-18 21:16:53 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2022-02-20 14:49:32 +00:00
|
|
|
}
|
|
|
|
|
if (gameSelector == nullptr) {
|
|
|
|
|
LOG(LogWarning) << "SystemView::updateGameSelectors(): Invalid gameselector \""
|
|
|
|
|
<< dateTimeSelector
|
|
|
|
|
<< "\" defined for datetime element, selecting first entry";
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
}
|
|
|
|
|
gameSelector->refreshGames();
|
|
|
|
|
std::vector<FileData*> games {gameSelector->getGames()};
|
|
|
|
|
if (!games.empty()) {
|
2022-03-18 21:16:53 +00:00
|
|
|
dateTime->setVisible(true);
|
2022-02-20 14:49:32 +00:00
|
|
|
const std::string metadata {dateTime->getThemeMetadata()};
|
|
|
|
|
if (metadata == "releasedate")
|
|
|
|
|
dateTime->setValue(games.front()->metadata.get("releasedate"));
|
|
|
|
|
if (metadata == "lastplayed")
|
|
|
|
|
dateTime->setValue(games.front()->metadata.get("lastplayed"));
|
|
|
|
|
}
|
|
|
|
|
else {
|
2022-03-18 21:16:53 +00:00
|
|
|
dateTime->setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto& rating : mSystemElements[cursor].ratingComponents) {
|
|
|
|
|
GameSelectorComponent* gameSelector {nullptr};
|
|
|
|
|
if (multipleSelectors) {
|
|
|
|
|
const std::string& ratingSelector {rating->getThemeGameSelector()};
|
|
|
|
|
if (ratingSelector == "") {
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
LOG(LogWarning)
|
|
|
|
|
<< "SystemView::updateGameSelectors(): Multiple gameselector "
|
|
|
|
|
"elements defined but rating element does not state which one to "
|
|
|
|
|
"use, selecting first entry";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
|
|
|
|
if (selector->getSelectorName() == ratingSelector) {
|
|
|
|
|
gameSelector = selector.get();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (gameSelector == nullptr) {
|
|
|
|
|
LOG(LogWarning)
|
|
|
|
|
<< "SystemView::updateGameSelectors(): Invalid gameselector \""
|
|
|
|
|
<< ratingSelector << "\" defined for rating element, selecting first entry";
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
|
|
|
|
}
|
|
|
|
|
gameSelector->refreshGames();
|
|
|
|
|
std::vector<FileData*> games {gameSelector->getGames()};
|
|
|
|
|
if (!games.empty()) {
|
|
|
|
|
rating->setVisible(true);
|
|
|
|
|
rating->setValue(games.front()->metadata.get("rating"));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
rating->setVisible(false);
|
2022-02-20 14:49:32 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-02-13 21:30:03 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-09 17:22:06 +00:00
|
|
|
void SystemView::legacyApplyTheme(const std::shared_ptr<ThemeData>& theme)
|
2017-03-13 21:11:07 +00:00
|
|
|
{
|
2022-02-06 13:01:40 +00:00
|
|
|
if (theme->hasView("system"))
|
|
|
|
|
mViewNeedsReload = false;
|
|
|
|
|
else
|
|
|
|
|
mViewNeedsReload = true;
|
2021-07-07 18:03:42 +00:00
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
if (mCarousel != nullptr)
|
|
|
|
|
mPrimary->applyTheme(theme, "system", "carousel_systemcarousel", ThemeFlags::ALL);
|
|
|
|
|
else if (mTextList != nullptr)
|
|
|
|
|
mPrimary->applyTheme(theme, "system", "textlist_gamelist", ThemeFlags::ALL);
|
2022-02-09 17:22:06 +00:00
|
|
|
|
|
|
|
|
mLegacySystemInfo->setSize(mSize.x, mLegacySystemInfo->getFont()->getLetterHeight() * 2.2f);
|
2022-10-24 22:43:27 +00:00
|
|
|
mLegacySystemInfo->setPosition(0.0f,
|
|
|
|
|
std::floor(mPrimary->getPosition().y) + mPrimary->getSize().y);
|
2022-02-09 17:22:06 +00:00
|
|
|
mLegacySystemInfo->setBackgroundColor(0xDDDDDDD8);
|
|
|
|
|
mLegacySystemInfo->setRenderBackground(true);
|
2022-10-24 23:20:31 +00:00
|
|
|
mLegacySystemInfo->setFont(Font::get(0.035f * mSize.y, Font::getDefaultPath()));
|
2022-02-09 17:22:06 +00:00
|
|
|
mLegacySystemInfo->setColor(0x000000FF);
|
|
|
|
|
mLegacySystemInfo->setUppercase(true);
|
2022-09-23 15:19:24 +00:00
|
|
|
mLegacySystemInfo->setZIndex(50.0f);
|
|
|
|
|
mLegacySystemInfo->setDefaultZIndex(50.0f);
|
2022-02-09 17:22:06 +00:00
|
|
|
|
|
|
|
|
const ThemeData::ThemeElement* sysInfoElem {
|
|
|
|
|
theme->getElement("system", "text_systemInfo", "text")};
|
|
|
|
|
|
|
|
|
|
if (sysInfoElem)
|
|
|
|
|
mLegacySystemInfo->applyTheme(theme, "system", "text_systemInfo", ThemeFlags::ALL);
|
2017-04-22 14:15:16 +00:00
|
|
|
}
|
2017-03-13 21:11:07 +00:00
|
|
|
|
2022-02-09 17:22:06 +00:00
|
|
|
void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary)
|
2017-04-22 14:15:16 +00:00
|
|
|
{
|
2022-02-09 17:22:06 +00:00
|
|
|
glm::mat4 trans {getTransform() * parentTrans};
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
const float primaryZIndex {mPrimary->getZIndex()};
|
2022-02-09 17:22:06 +00:00
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
int renderBefore {static_cast<int>(mCamOffset)};
|
|
|
|
|
int renderAfter {static_cast<int>(mCamOffset)};
|
2022-03-05 20:10:40 +00:00
|
|
|
|
|
|
|
|
// If we're transitioning then also render the previous and next systems.
|
2022-03-24 22:05:23 +00:00
|
|
|
if (mPrimary->isAnimationPlaying(0)) {
|
|
|
|
|
renderBefore -= 1;
|
|
|
|
|
renderAfter += 1;
|
2022-03-05 20:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
for (int i = renderBefore; i <= renderAfter; ++i) {
|
2022-02-09 17:22:06 +00:00
|
|
|
int index {i};
|
|
|
|
|
while (index < 0)
|
2022-03-24 22:05:23 +00:00
|
|
|
index += static_cast<int>(mPrimary->getNumEntries());
|
|
|
|
|
while (index >= static_cast<int>(mPrimary->getNumEntries()))
|
|
|
|
|
index -= static_cast<int>(mPrimary->getNumEntries());
|
2022-02-09 17:22:06 +00:00
|
|
|
|
2022-03-24 22:05:23 +00:00
|
|
|
if (mPrimary->isAnimationPlaying(0) || index == mPrimary->getCursor()) {
|
2022-02-09 17:22:06 +00:00
|
|
|
glm::mat4 elementTrans {trans};
|
2022-03-24 22:05:23 +00:00
|
|
|
if (mCarousel != nullptr) {
|
|
|
|
|
if (mCarousel->getType() ==
|
|
|
|
|
CarouselComponent<SystemData*>::CarouselType::HORIZONTAL ||
|
|
|
|
|
mCarousel->getType() ==
|
|
|
|
|
CarouselComponent<SystemData*>::CarouselType::HORIZONTAL_WHEEL)
|
|
|
|
|
elementTrans = glm::translate(
|
2022-09-05 18:13:47 +00:00
|
|
|
elementTrans,
|
|
|
|
|
glm::round(glm::vec3 {(i - mCamOffset) * mSize.x, 0.0f, 0.0f}));
|
2022-03-24 22:05:23 +00:00
|
|
|
else
|
|
|
|
|
elementTrans = glm::translate(
|
2022-09-05 18:13:47 +00:00
|
|
|
elementTrans,
|
|
|
|
|
glm::round(glm::vec3 {0.0f, (i - mCamOffset) * mSize.y, 0.0f}));
|
2022-03-24 22:05:23 +00:00
|
|
|
}
|
|
|
|
|
else if (mTextList != nullptr) {
|
2022-09-05 18:13:47 +00:00
|
|
|
elementTrans = glm::translate(
|
|
|
|
|
elementTrans, glm::round(glm::vec3 {0.0f, (i - mCamOffset) * mSize.y, 0.0f}));
|
2022-03-24 22:05:23 +00:00
|
|
|
}
|
2022-02-09 17:22:06 +00:00
|
|
|
|
2022-03-14 18:51:48 +00:00
|
|
|
mRenderer->pushClipRect(
|
2022-02-09 17:22:06 +00:00
|
|
|
glm::ivec2 {static_cast<int>(glm::round(elementTrans[3].x)),
|
|
|
|
|
static_cast<int>(glm::round(elementTrans[3].y))},
|
|
|
|
|
glm::ivec2 {static_cast<int>(mSize.x), static_cast<int>(mSize.y)});
|
|
|
|
|
|
|
|
|
|
if (mLegacyMode && mSystemElements.size() > static_cast<size_t>(index)) {
|
2022-03-11 22:20:27 +00:00
|
|
|
for (auto element : mSystemElements[index].legacyExtras) {
|
2022-06-03 17:34:39 +00:00
|
|
|
if (abovePrimary && element->getZIndex() < primaryZIndex)
|
|
|
|
|
continue;
|
|
|
|
|
if ((mFadeTransitions || element->getDimming() != 1.0f) &&
|
|
|
|
|
element->getZIndex() < primaryZIndex)
|
2022-03-11 22:51:41 +00:00
|
|
|
element->setDimming(1.0f - mFadeOpacity);
|
2022-09-26 18:02:31 +00:00
|
|
|
if (mFadeTransitions && mPrimary->getFadeAbovePrimary()) {
|
|
|
|
|
if (mFadeTransitions && isAnimationPlaying(0))
|
|
|
|
|
element->setOpacity(1.0f - mFadeOpacity);
|
|
|
|
|
else
|
|
|
|
|
element->setOpacity(1.0f);
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-09 17:22:06 +00:00
|
|
|
element->render(elementTrans);
|
2022-03-11 22:20:27 +00:00
|
|
|
}
|
2022-02-09 17:22:06 +00:00
|
|
|
}
|
|
|
|
|
else if (!mLegacyMode && mSystemElements.size() > static_cast<size_t>(index)) {
|
|
|
|
|
for (auto child : mSystemElements[index].children) {
|
2022-09-26 18:02:31 +00:00
|
|
|
if (abovePrimary && (child->getZIndex() > primaryZIndex)) {
|
|
|
|
|
if (mFadeTransitions && mPrimary->getFadeAbovePrimary()) {
|
|
|
|
|
if (mFadeTransitions || child->getOpacity() != 1.0f)
|
|
|
|
|
child->setOpacity(1.0f - mFadeOpacity);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
child->setOpacity(1.0f);
|
|
|
|
|
}
|
2022-02-09 17:22:06 +00:00
|
|
|
child->render(elementTrans);
|
2022-03-11 22:20:27 +00:00
|
|
|
}
|
2022-09-26 18:02:31 +00:00
|
|
|
|
2022-03-11 22:20:27 +00:00
|
|
|
else if (!abovePrimary && child->getZIndex() <= primaryZIndex) {
|
2022-03-11 22:51:41 +00:00
|
|
|
if (mFadeTransitions || child->getDimming() != 1.0f)
|
|
|
|
|
child->setDimming(1.0f - mFadeOpacity);
|
2022-02-09 17:22:06 +00:00
|
|
|
child->render(elementTrans);
|
2022-03-11 22:20:27 +00:00
|
|
|
}
|
2022-02-09 17:22:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-23 15:19:24 +00:00
|
|
|
if (mLegacyMode) {
|
|
|
|
|
if (mFadeTransitions && !abovePrimary) {
|
|
|
|
|
if (mFadeTransitions && isAnimationPlaying(0))
|
2022-09-23 20:47:49 +00:00
|
|
|
mLegacySystemInfo->setOpacity(1.0f - mFadeOpacity);
|
2022-09-23 15:19:24 +00:00
|
|
|
else
|
|
|
|
|
mLegacySystemInfo->setOpacity(1.0f);
|
|
|
|
|
}
|
|
|
|
|
if ((abovePrimary && mLegacySystemInfo->getZIndex() > 40.0f) ||
|
|
|
|
|
(!abovePrimary && mLegacySystemInfo->getZIndex() <= 40.0f))
|
|
|
|
|
mLegacySystemInfo->render(elementTrans);
|
2022-03-11 22:20:27 +00:00
|
|
|
}
|
2022-02-09 17:22:06 +00:00
|
|
|
|
2022-03-14 18:51:48 +00:00
|
|
|
mRenderer->popClipRect();
|
2022-02-09 17:22:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|