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
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
// Buffer values for scrolling velocity (left, stopped, right).
|
|
|
|
|
const int logoBuffersLeft[] = {-5, -2, -1};
|
|
|
|
|
const int logoBuffersRight[] = {1, 2, 5};
|
|
|
|
|
|
|
|
|
|
} // namespace
|
2017-05-17 12:01:15 +00:00
|
|
|
|
2022-01-19 17:01:54 +00:00
|
|
|
SystemView::SystemView()
|
2022-02-06 13:01:40 +00:00
|
|
|
: mCamOffset {0.0f}
|
|
|
|
|
, mFadeOpacity {0.0f}
|
2022-01-16 17:18:28 +00:00
|
|
|
, mUpdatedGameCount {false}
|
|
|
|
|
, mViewNeedsReload {true}
|
2022-01-30 20:16:03 +00:00
|
|
|
, mLegacyMode {false}
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2022-02-06 13:01:40 +00:00
|
|
|
mCarousel = std::make_unique<CarouselComponent>();
|
|
|
|
|
mSystemInfo = std::make_unique<TextComponent>("SYSTEM INFO", Font::get(FONT_SIZE_SMALL),
|
|
|
|
|
0x33333300, ALIGN_CENTER);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-09-18 16:40:22 +00:00
|
|
|
setSize(static_cast<float>(Renderer::getScreenWidth()),
|
|
|
|
|
static_cast<float>(Renderer::getScreenHeight()));
|
2022-02-06 13:01:40 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
populate();
|
2022-02-06 13:01:40 +00:00
|
|
|
|
|
|
|
|
mCarousel->setCursorChangedCallback([&](const CursorState& state) { onCursorChanged(state); });
|
|
|
|
|
mCarousel->setCancelTransitionsCallback(
|
|
|
|
|
[&] { ViewController::getInstance()->cancelViewTransitions(); });
|
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.
|
|
|
|
|
for (auto& entry : mElements) {
|
|
|
|
|
for (auto extra : entry.legacyExtras)
|
|
|
|
|
delete extra;
|
|
|
|
|
entry.legacyExtras.clear();
|
|
|
|
|
}
|
2020-08-15 07:28:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
void SystemView::populate()
|
|
|
|
|
{
|
2022-02-06 13:01:40 +00:00
|
|
|
auto themeSets = ThemeData::getThemeSets();
|
|
|
|
|
std::map<std::string, ThemeData::ThemeSet>::const_iterator selectedSet =
|
|
|
|
|
themeSets.find(Settings::getInstance()->getString("ThemeSet"));
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
assert(selectedSet != themeSets.cend());
|
|
|
|
|
mLegacyMode = selectedSet->second.capabilities.legacyTheme;
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
for (auto it : SystemData::sSystemVector) {
|
|
|
|
|
const std::shared_ptr<ThemeData>& theme {it->getTheme()};
|
2022-01-30 20:16:03 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (mViewNeedsReload)
|
|
|
|
|
getViewElements(theme);
|
|
|
|
|
|
2022-01-30 20:16:03 +00:00
|
|
|
if (mLegacyMode) {
|
2022-02-06 13:01:40 +00:00
|
|
|
SystemViewElements elements;
|
|
|
|
|
elements.name = it->getName();
|
|
|
|
|
elements.legacyExtras = ThemeData::makeExtras(theme, "system");
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
|
// Sort the extras by z-index.
|
2021-07-07 18:03:42 +00:00
|
|
|
std::stable_sort(
|
2022-02-06 13:01:40 +00:00
|
|
|
elements.legacyExtras.begin(), elements.legacyExtras.end(),
|
2021-07-07 18:03:42 +00:00
|
|
|
[](GuiComponent* a, GuiComponent* b) { return b->getZIndex() > a->getZIndex(); });
|
2022-02-06 13:01:40 +00:00
|
|
|
|
|
|
|
|
mElements.emplace_back(std::move(elements));
|
2022-01-30 20:16:03 +00:00
|
|
|
}
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
if (!mLegacyMode) {
|
|
|
|
|
SystemViewElements elements;
|
2022-01-30 20:16:03 +00:00
|
|
|
if (theme->hasView("system")) {
|
2022-02-06 13:01:40 +00:00
|
|
|
elements.name = it->getName();
|
2022-01-30 20:16:03 +00:00
|
|
|
for (auto& element : theme->getViewElements("system").elements) {
|
|
|
|
|
if (element.second.type == "image") {
|
2022-02-06 13:01:40 +00:00
|
|
|
elements.imageComponents.emplace_back(std::make_unique<ImageComponent>());
|
|
|
|
|
elements.imageComponents.back()->setDefaultZIndex(30.0f);
|
|
|
|
|
elements.imageComponents.back()->applyTheme(theme, "system", element.first,
|
|
|
|
|
ThemeFlags::ALL);
|
|
|
|
|
if (elements.imageComponents.back()->getMetadataField() != "")
|
|
|
|
|
elements.imageComponents.back()->setScrollHide(true);
|
|
|
|
|
elements.children.emplace_back(elements.imageComponents.back().get());
|
2022-01-30 20:16:03 +00:00
|
|
|
}
|
|
|
|
|
else if (element.second.type == "text") {
|
2022-02-06 13:01:40 +00:00
|
|
|
elements.textComponents.push_back(std::make_unique<TextComponent>());
|
|
|
|
|
elements.textComponents.back()->setDefaultZIndex(40.0f);
|
|
|
|
|
elements.textComponents.back()->applyTheme(theme, "system", element.first,
|
|
|
|
|
ThemeFlags::ALL);
|
|
|
|
|
if (elements.textComponents.back()->getMetadataField() != "")
|
|
|
|
|
elements.textComponents.back()->setScrollHide(true);
|
|
|
|
|
elements.children.emplace_back(elements.textComponents.back().get());
|
2022-01-30 20:16:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-06 13:01:40 +00:00
|
|
|
|
|
|
|
|
elements.children.emplace_back(mCarousel.get());
|
|
|
|
|
elements.children.emplace_back(mSystemInfo.get());
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
});
|
|
|
|
|
mElements.emplace_back(std::move(elements));
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2022-01-30 20:16:03 +00:00
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
CarouselComponent::Entry entry;
|
|
|
|
|
entry.name = it->getName();
|
|
|
|
|
entry.object = it;
|
|
|
|
|
|
|
|
|
|
mCarousel->addEntry(theme, entry);
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2022-02-06 13:01:40 +00:00
|
|
|
|
|
|
|
|
if (mCarousel->getNumEntries() == 0) {
|
2020-06-21 12:25:28 +00:00
|
|
|
// Something is wrong, there is not a single system to show, check if UI mode is not full.
|
|
|
|
|
if (!UIModeController::getInstance()->isUIModeFull()) {
|
2020-07-27 10:11:30 +00:00
|
|
|
Settings::getInstance()->setString("UIMode", "full");
|
2021-07-07 18:03:42 +00:00
|
|
|
mWindow->pushGui(new GuiMsgBox(
|
2022-01-19 17:01:54 +00:00
|
|
|
getHelpStyle(),
|
2021-07-07 18:03:42 +00:00
|
|
|
"The selected UI mode has nothing to show,\n returning to UI mode \"Full\"", "OK",
|
|
|
|
|
nullptr));
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
2020-11-15 19:06:33 +00:00
|
|
|
void SystemView::updateGameCount()
|
|
|
|
|
{
|
2022-02-06 13:01:40 +00:00
|
|
|
std::pair<unsigned int, unsigned int> gameCount =
|
|
|
|
|
mCarousel->getSelected()->getDisplayedGameCount();
|
2020-11-15 19:06:33 +00:00
|
|
|
std::stringstream ss;
|
|
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
if (!mCarousel->getSelected()->isGameSystem())
|
2020-11-15 19:06:33 +00:00
|
|
|
ss << "CONFIGURATION";
|
2022-02-06 13:01:40 +00:00
|
|
|
else if (mCarousel->getSelected()->isCollection() &&
|
|
|
|
|
(mCarousel->getSelected()->getName() == "favorites"))
|
2020-11-15 19:06:33 +00:00
|
|
|
ss << gameCount.first << " GAME" << (gameCount.first == 1 ? " " : "S");
|
2021-07-07 18:03:42 +00:00
|
|
|
// The "recent" gamelist has probably been trimmed after sorting, so we'll cap it at
|
2020-11-15 19:06:33 +00:00
|
|
|
// its maximum limit of 50 games.
|
2022-02-06 13:01:40 +00:00
|
|
|
else if (mCarousel->getSelected()->isCollection() &&
|
|
|
|
|
(mCarousel->getSelected()->getName() == "recent"))
|
2021-07-07 18:03:42 +00:00
|
|
|
ss << (gameCount.first > 50 ? 50 : gameCount.first) << " GAME"
|
|
|
|
|
<< (gameCount.first == 1 ? " " : "S");
|
2020-11-15 19:06:33 +00:00
|
|
|
else
|
2021-07-07 18:03:42 +00:00
|
|
|
ss << gameCount.first << " GAME" << (gameCount.first == 1 ? " " : "S ") << "("
|
|
|
|
|
<< gameCount.second << " FAVORITE" << (gameCount.second == 1 ? ")" : "S)");
|
2020-11-15 19:06:33 +00:00
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
mSystemInfo->setText(ss.str());
|
2020-11-15 19:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
void SystemView::goToSystem(SystemData* system, bool animate)
|
|
|
|
|
{
|
2022-02-06 13:01:40 +00:00
|
|
|
mCarousel->setCursor(system);
|
2020-11-15 19:06:33 +00:00
|
|
|
updateGameCount();
|
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)
|
|
|
|
|
{
|
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-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-02-06 13:01:40 +00:00
|
|
|
mCarousel->stopScrolling();
|
|
|
|
|
ViewController::getInstance()->goToGamelist(mCarousel->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-02-06 13:01:40 +00:00
|
|
|
mCarousel->setCursor(SystemData::getRandomSystem(mCarousel->getSelected()));
|
2020-06-21 12:25:28 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2020-09-18 16:40:22 +00:00
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
if (!UIModeController::getInstance()->isUIModeKid() && config->isMappedTo("back", input) &&
|
|
|
|
|
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();
|
2020-11-10 21:18:20 +00:00
|
|
|
mWindow->startScreensaver();
|
|
|
|
|
mWindow->renderScreensaver();
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
return mCarousel->input(config, input);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SystemView::update(int deltaTime)
|
|
|
|
|
{
|
2022-02-06 13:01:40 +00:00
|
|
|
mCarousel->update(deltaTime);
|
2020-06-21 12:25:28 +00:00
|
|
|
GuiComponent::update(deltaTime);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
2017-11-17 14:58:52 +00:00
|
|
|
void SystemView::onCursorChanged(const CursorState& /*state*/)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
// Update help style.
|
|
|
|
|
updateHelpPrompts();
|
|
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
int scrollVelocity {mCarousel->getScrollingVelocity()};
|
|
|
|
|
|
|
|
|
|
float startPos {mCamOffset};
|
|
|
|
|
float posMax {static_cast<float>(mCarousel->getNumEntries())};
|
|
|
|
|
float target {static_cast<float>(mCarousel->getCursor())};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2020-11-15 10:30:43 +00:00
|
|
|
// Find the shortest path to the target.
|
2022-02-06 13:01:40 +00:00
|
|
|
float endPos {target}; // Directly.
|
|
|
|
|
float dist {fabs(endPos - startPos)};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
if (fabs(target + posMax - startPos - scrollVelocity) < dist)
|
2020-06-21 12:25:28 +00:00
|
|
|
endPos = target + posMax; // Loop around the end (0 -> max).
|
2022-02-06 13:01:40 +00:00
|
|
|
if (fabs(target - posMax - startPos - scrollVelocity) < dist)
|
2020-06-21 12:25:28 +00:00
|
|
|
endPos = target - posMax; // Loop around the start (max - 1 -> -1).
|
|
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
std::string transition_style {Settings::getInstance()->getString("TransitionStyle")};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
|
Animation* anim;
|
2020-11-15 19:06:33 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (transition_style == "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;
|
2021-08-17 18:55:29 +00:00
|
|
|
float f = glm::mix(startPos, endPos, t * t * t + 1);
|
2021-07-07 18:03:42 +00:00
|
|
|
if (f < 0)
|
|
|
|
|
f += posMax;
|
|
|
|
|
if (f >= posMax)
|
|
|
|
|
f -= posMax;
|
|
|
|
|
|
|
|
|
|
t += 1;
|
|
|
|
|
if (t < 0.3f)
|
2022-02-06 13:01:40 +00:00
|
|
|
this->mFadeOpacity =
|
|
|
|
|
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-06 13:01:40 +00:00
|
|
|
this->mFadeOpacity = 1.0f;
|
2021-07-07 18:03:42 +00:00
|
|
|
else
|
2022-02-06 13:01:40 +00:00
|
|
|
this->mFadeOpacity =
|
2021-08-17 18:55:29 +00:00
|
|
|
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-06 13:01:40 +00:00
|
|
|
this->mCamOffset = endPos;
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
// Update the game count when the entire animation has been completed.
|
2022-02-06 13:01:40 +00:00
|
|
|
if (mFadeOpacity == 1.0f)
|
2021-07-07 18:03:42 +00:00
|
|
|
updateGameCount();
|
|
|
|
|
},
|
|
|
|
|
500);
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
|
else if (transition_style == "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;
|
2021-08-17 18:55:29 +00:00
|
|
|
float f = glm::mix(startPos, endPos, t * t * t + 1);
|
2021-07-07 18:03:42 +00:00
|
|
|
if (f < 0)
|
|
|
|
|
f += posMax;
|
|
|
|
|
if (f >= posMax)
|
|
|
|
|
f -= posMax;
|
|
|
|
|
|
|
|
|
|
this->mCamOffset = f;
|
|
|
|
|
|
|
|
|
|
// 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;
|
2021-08-17 18:55:29 +00:00
|
|
|
float f = glm::mix(startPos, endPos, t * t * t + 1);
|
2021-07-07 18:03:42 +00:00
|
|
|
if (f < 0)
|
|
|
|
|
f += posMax;
|
|
|
|
|
if (f >= posMax)
|
|
|
|
|
f -= posMax;
|
|
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
this->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
|
|
|
}
|
|
|
|
|
|
2021-08-15 17:30:31 +00:00
|
|
|
void SystemView::render(const glm::mat4& parentTrans)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2022-02-06 13:01:40 +00:00
|
|
|
if (mCarousel->getNumEntries() == 0)
|
2021-07-07 18:03:42 +00:00
|
|
|
return; // Nothing to render.
|
2017-05-27 07:40:18 +00:00
|
|
|
|
2022-01-16 11:09:55 +00:00
|
|
|
glm::mat4 trans {getTransform() * parentTrans};
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
// Adding texture loading buffers depending on scrolling speed and status.
|
|
|
|
|
int bufferIndex {mCarousel->getScrollingVelocity() + 1};
|
2021-10-23 15:34:20 +00:00
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
Renderer::pushClipRect(glm::ivec2 {},
|
|
|
|
|
glm::ivec2 {static_cast<int>(mSize.x), static_cast<int>(mSize.y)});
|
2021-10-23 15:34:20 +00:00
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
for (int i = static_cast<int>(mCamOffset) + logoBuffersLeft[bufferIndex];
|
|
|
|
|
i <= static_cast<int>(mCamOffset) + logoBuffersRight[bufferIndex]; ++i) {
|
|
|
|
|
int index {i};
|
|
|
|
|
while (index < 0)
|
|
|
|
|
index += static_cast<int>(mCarousel->getNumEntries());
|
|
|
|
|
while (index >= static_cast<int>(mCarousel->getNumEntries()))
|
|
|
|
|
index -= static_cast<int>(mCarousel->getNumEntries());
|
|
|
|
|
|
|
|
|
|
if (mCarousel->isAnimationPlaying(0) || index == mCarousel->getCursor()) {
|
|
|
|
|
glm::mat4 elementTrans {trans};
|
|
|
|
|
if (mCarousel->getType() == CarouselComponent::HORIZONTAL ||
|
|
|
|
|
mCarousel->getType() == CarouselComponent::HORIZONTAL_WHEEL)
|
|
|
|
|
elementTrans = glm::translate(elementTrans,
|
|
|
|
|
glm::vec3 {(i - mCamOffset) * mSize.x, 0.0f, 0.0f});
|
|
|
|
|
else
|
|
|
|
|
elementTrans = glm::translate(elementTrans,
|
|
|
|
|
glm::vec3 {0.0f, (i - mCamOffset) * mSize.y, 0.0f});
|
2017-04-22 14:15:16 +00:00
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
Renderer::pushClipRect(
|
|
|
|
|
glm::ivec2 {static_cast<int>(elementTrans[3].x),
|
|
|
|
|
static_cast<int>(elementTrans[3].y)},
|
|
|
|
|
glm::ivec2 {static_cast<int>(mSize.x), static_cast<int>(mSize.y)});
|
|
|
|
|
|
|
|
|
|
if (mLegacyMode && mElements.size() > static_cast<size_t>(index)) {
|
|
|
|
|
for (auto element : mElements[index].legacyExtras)
|
|
|
|
|
element->render(elementTrans);
|
|
|
|
|
}
|
|
|
|
|
else if (mElements.size() > static_cast<size_t>(index)) {
|
|
|
|
|
for (auto child : mElements[index].children) {
|
|
|
|
|
if (child == mCarousel.get()) {
|
|
|
|
|
// Render black above anything lower than the zIndex of the carousel
|
|
|
|
|
// if fade transitions are in use and we're transitioning.
|
|
|
|
|
if (mFadeOpacity)
|
|
|
|
|
renderFade(trans);
|
|
|
|
|
child->render(trans);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
child->render(elementTrans);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-22 14:15:16 +00:00
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
if (mLegacyMode)
|
|
|
|
|
mSystemInfo->render(elementTrans);
|
2021-10-15 20:54:04 +00:00
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
Renderer::popClipRect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mLegacyMode) {
|
|
|
|
|
if (mFadeOpacity)
|
|
|
|
|
renderFade(trans);
|
|
|
|
|
mCarousel->render(trans);
|
2021-10-23 15:34:20 +00:00
|
|
|
}
|
2022-02-06 13:01:40 +00:00
|
|
|
|
|
|
|
|
Renderer::popClipRect();
|
2017-03-13 21:11:07 +00:00
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2017-03-13 21:11:07 +00:00
|
|
|
std::vector<HelpPrompt> SystemView::getHelpPrompts()
|
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
std::vector<HelpPrompt> prompts;
|
2022-02-06 13:01:40 +00:00
|
|
|
if (mCarousel->getType() == CarouselComponent::VERTICAL ||
|
|
|
|
|
mCarousel->getType() == CarouselComponent::VERTICAL_WHEEL)
|
2020-06-21 12:25:28 +00:00
|
|
|
prompts.push_back(HelpPrompt("up/down", "choose"));
|
|
|
|
|
else
|
|
|
|
|
prompts.push_back(HelpPrompt("left/right", "choose"));
|
2021-05-16 12:03:13 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
prompts.push_back(HelpPrompt("a", "select"));
|
2021-05-16 12:03:13 +00:00
|
|
|
|
|
|
|
|
if (Settings::getInstance()->getBool("RandomAddButton"))
|
|
|
|
|
prompts.push_back(HelpPrompt("thumbstickclick", "random"));
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
|
if (!UIModeController::getInstance()->isUIModeKid() &&
|
2021-07-07 18:03:42 +00:00
|
|
|
Settings::getInstance()->getBool("ScreensaverControls"))
|
2021-08-19 17:45:54 +00:00
|
|
|
prompts.push_back(HelpPrompt("back", "screensaver"));
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
|
return prompts;
|
2017-03-13 21:11:07 +00:00
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2017-03-13 21:11:07 +00:00
|
|
|
HelpStyle SystemView::getHelpStyle()
|
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
HelpStyle style;
|
2022-02-06 13:01:40 +00:00
|
|
|
style.applyTheme(mCarousel->getEntry(mCarousel->getCursor()).object->getTheme(), "system");
|
2020-06-21 12:25:28 +00:00
|
|
|
return style;
|
2017-03-13 21:11:07 +00:00
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
void SystemView::onThemeChanged(const std::shared_ptr<ThemeData>& /*theme*/)
|
2017-03-13 21:11:07 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
LOG(LogDebug) << "SystemView::onThemeChanged()";
|
|
|
|
|
mViewNeedsReload = true;
|
|
|
|
|
populate();
|
2017-03-13 21:11:07 +00:00
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
void SystemView::getViewElements(const std::shared_ptr<ThemeData>& theme)
|
2017-03-13 21:11:07 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
LOG(LogDebug) << "SystemView::getViewElements()";
|
2014-06-25 16:29:58 +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-02-06 13:01:40 +00:00
|
|
|
mCarousel->applyTheme(theme, "system", "carousel_systemcarousel", ThemeFlags::ALL);
|
2017-03-13 21:11:07 +00:00
|
|
|
|
2022-02-06 13:01:40 +00:00
|
|
|
// System info bar.
|
|
|
|
|
mSystemInfo->setSize(mSize.x, mSystemInfo->getFont()->getLetterHeight() * 2.2f);
|
|
|
|
|
mSystemInfo->setPosition(0.0f, mCarousel->getPosition().y + mCarousel->getSize().y);
|
|
|
|
|
mSystemInfo->setBackgroundColor(0xDDDDDDD8);
|
|
|
|
|
mSystemInfo->setRenderBackground(true);
|
|
|
|
|
mSystemInfo->setFont(Font::get(static_cast<int>(0.035f * mSize.y), Font::getDefaultPath()));
|
|
|
|
|
mSystemInfo->setColor(0x000000FF);
|
|
|
|
|
mSystemInfo->setZIndex(49.0f);
|
|
|
|
|
mSystemInfo->setDefaultZIndex(49.0f);
|
|
|
|
|
|
|
|
|
|
const ThemeData::ThemeElement* sysInfoElem {
|
|
|
|
|
theme->getElement("system", "text_systemInfo", "text")};
|
2021-07-07 18:03:42 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (sysInfoElem)
|
2022-02-06 13:01:40 +00:00
|
|
|
mSystemInfo->applyTheme(theme, "system", "text_systemInfo", ThemeFlags::ALL);
|
2017-04-22 14:15:16 +00:00
|
|
|
}
|
2017-03-13 21:11:07 +00:00
|
|
|
|
2021-08-15 17:30:31 +00:00
|
|
|
void SystemView::renderFade(const glm::mat4& trans)
|
2017-04-22 14:15:16 +00:00
|
|
|
{
|
2022-02-06 13:01:40 +00:00
|
|
|
unsigned int fadeColor {0x00000000 | static_cast<unsigned int>(mFadeOpacity * 255.0f)};
|
2020-11-15 19:06:33 +00:00
|
|
|
Renderer::setMatrix(trans);
|
2021-08-16 16:25:01 +00:00
|
|
|
Renderer::drawRect(0.0f, 0.0f, mSize.x, mSize.y, fadeColor, fadeColor);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|