Removed a huge amount of unnecessary Window* function arguments.

This commit is contained in:
Leon Styhre 2022-01-19 18:01:54 +01:00
parent 21b167ed9b
commit a443f86235
119 changed files with 903 additions and 1077 deletions

View file

@ -774,8 +774,10 @@ const FileData::SortType& FileData::getSortTypeFromString(const std::string& des
return FileSorts::SortTypes.at(0); return FileSorts::SortTypes.at(0);
} }
void FileData::launchGame(Window* window) void FileData::launchGame()
{ {
Window* window {Window::getInstance()};
LOG(LogInfo) << "Launching game \"" << this->metadata.get("name") << "\"..."; LOG(LogInfo) << "Launching game \"" << this->metadata.get("name") << "\"...";
SystemData* gameSystem = nullptr; SystemData* gameSystem = nullptr;

View file

@ -106,7 +106,7 @@ public:
// As above, but also remove parenthesis. // As above, but also remove parenthesis.
std::string getCleanName() const; std::string getCleanName() const;
void launchGame(Window* window); void launchGame();
const std::string findEmulatorPath(std::string& command); const std::string findEmulatorPath(std::string& command);
using ComparisonFunction = bool(const FileData* a, const FileData* b); using ComparisonFunction = bool(const FileData* a, const FileData* b);

View file

@ -13,11 +13,10 @@
#include "views/ViewController.h" #include "views/ViewController.h"
MediaViewer::MediaViewer() MediaViewer::MediaViewer()
: mWindow {Window::getInstance()} : mVideo {nullptr}
, mVideo {nullptr}
, mImage {nullptr} , mImage {nullptr}
{ {
mWindow->setMediaViewer(this); Window::getInstance()->setMediaViewer(this);
} }
MediaViewer::~MediaViewer() MediaViewer::~MediaViewer()
@ -260,7 +259,7 @@ void MediaViewer::playVideo()
mDisplayingImage = false; mDisplayingImage = false;
ViewController::getInstance()->onStopVideo(); ViewController::getInstance()->onStopVideo();
mVideo = new VideoFFmpegComponent(mWindow); mVideo = new VideoFFmpegComponent;
mVideo->topWindow(true); mVideo->topWindow(true);
mVideo->setOrigin(0.5f, 0.5f); mVideo->setOrigin(0.5f, 0.5f);
mVideo->setPosition(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f); mVideo->setPosition(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f);
@ -285,7 +284,7 @@ void MediaViewer::showImage(int index)
mDisplayingImage = true; mDisplayingImage = true;
if (!mImageFiles.empty() && static_cast<int>(mImageFiles.size()) >= index) { if (!mImageFiles.empty() && static_cast<int>(mImageFiles.size()) >= index) {
mImage = new ImageComponent(mWindow, false, false); mImage = new ImageComponent(false, false);
mImage->setImage(mImageFiles[index]); mImage->setImage(mImageFiles[index]);
mImage->setOrigin(0.5f, 0.5f); mImage->setOrigin(0.5f, 0.5f);
mImage->setPosition(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f); mImage->setPosition(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f);

View file

@ -36,7 +36,6 @@ private:
void showNext() override; void showNext() override;
void showPrevious() override; void showPrevious() override;
Window* mWindow;
FileData* mGame; FileData* mGame;
bool mHasVideo; bool mHasVideo;

View file

@ -116,7 +116,7 @@ void Screensaver::startScreensaver(bool generateMediaList)
generateOverlayInfo(); generateOverlayInfo();
if (!mImageScreensaver) if (!mImageScreensaver)
mImageScreensaver = new ImageComponent(mWindow, false, false); mImageScreensaver = new ImageComponent(false, false);
mTimer = 0; mTimer = 0;
@ -156,7 +156,7 @@ void Screensaver::startScreensaver(bool generateMediaList)
if (Settings::getInstance()->getBool("ScreensaverVideoGameInfo")) if (Settings::getInstance()->getBool("ScreensaverVideoGameInfo"))
generateOverlayInfo(); generateOverlayInfo();
mVideoScreensaver = new VideoFFmpegComponent(mWindow); mVideoScreensaver = new VideoFFmpegComponent;
mVideoScreensaver->topWindow(true); mVideoScreensaver->topWindow(true);
mVideoScreensaver->setOrigin(0.5f, 0.5f); mVideoScreensaver->setOrigin(0.5f, 0.5f);
mVideoScreensaver->setPosition(Renderer::getScreenWidth() / 2.0f, mVideoScreensaver->setPosition(Renderer::getScreenWidth() / 2.0f,

View file

@ -13,9 +13,8 @@
#include "SystemData.h" #include "SystemData.h"
#include "views/ViewController.h" #include "views/ViewController.h"
GuiAlternativeEmulators::GuiAlternativeEmulators(Window* window) GuiAlternativeEmulators::GuiAlternativeEmulators()
: GuiComponent {window} : mMenu {"ALTERNATIVE EMULATORS"}
, mMenu {window, "ALTERNATIVE EMULATORS"}
, mHasSystems {false} , mHasSystems {false}
{ {
addChild(&mMenu); addChild(&mMenu);
@ -36,8 +35,8 @@ GuiAlternativeEmulators::GuiAlternativeEmulators(Window* window)
ComponentListRow row; ComponentListRow row;
std::string name {(*it)->getName()}; std::string name {(*it)->getName()};
std::shared_ptr<TextComponent> systemText {std::make_shared<TextComponent>( std::shared_ptr<TextComponent> systemText {
mWindow, name, Font::get(FONT_SIZE_MEDIUM), 0x777777FF)}; std::make_shared<TextComponent>(name, Font::get(FONT_SIZE_MEDIUM), 0x777777FF)};
systemText->setSize(systemSizeX, systemText->getSize().y); systemText->setSize(systemSizeX, systemText->getSize().y);
row.addElement(systemText, false); row.addElement(systemText, false);
@ -68,13 +67,12 @@ GuiAlternativeEmulators::GuiAlternativeEmulators(Window* window)
if (label == (*it)->getSystemEnvData()->mLaunchCommands.front().second) { if (label == (*it)->getSystemEnvData()->mLaunchCommands.front().second) {
labelText = std::make_shared<TextComponent>( labelText = std::make_shared<TextComponent>(
mWindow, label, Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT), 0x777777FF, label, Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT);
ALIGN_RIGHT);
} }
else { else {
// Mark any non-default value with bold and add a gear symbol as well. // Mark any non-default value with bold and add a gear symbol as well.
labelText = std::make_shared<TextComponent>( labelText = std::make_shared<TextComponent>(
mWindow, label + (!invalidEntry ? " " + ViewController::GEAR_CHAR : ""), label + (!invalidEntry ? " " + ViewController::GEAR_CHAR : ""),
Font::get(FONT_SIZE_MEDIUM, FONT_PATH_BOLD), 0x777777FF, ALIGN_RIGHT); Font::get(FONT_SIZE_MEDIUM, FONT_PATH_BOLD), 0x777777FF, ALIGN_RIGHT);
} }
@ -103,7 +101,7 @@ GuiAlternativeEmulators::GuiAlternativeEmulators(Window* window)
if (!mHasSystems) { if (!mHasSystems) {
ComponentListRow row; ComponentListRow row;
std::shared_ptr<TextComponent> systemText = std::make_shared<TextComponent>( std::shared_ptr<TextComponent> systemText = std::make_shared<TextComponent>(
mWindow, ViewController::EXCLAMATION_CHAR + " NO ALTERNATIVE EMULATORS DEFINED", ViewController::EXCLAMATION_CHAR + " NO ALTERNATIVE EMULATORS DEFINED",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER);
row.addElement(systemText, true); row.addElement(systemText, true);
mMenu.addRow(row); mMenu.addRow(row);
@ -133,7 +131,7 @@ void GuiAlternativeEmulators::updateMenu(const std::string& systemName,
void GuiAlternativeEmulators::selectorWindow(SystemData* system) void GuiAlternativeEmulators::selectorWindow(SystemData* system)
{ {
auto s = new GuiSettings(mWindow, system->getFullName()); auto s = new GuiSettings(system->getFullName());
std::string selectedLabel = system->getAlternativeEmulator(); std::string selectedLabel = system->getAlternativeEmulator();
std::string label; std::string label;
@ -147,7 +145,7 @@ void GuiAlternativeEmulators::selectorWindow(SystemData* system)
label = entry.second; label = entry.second;
std::shared_ptr<TextComponent> labelText = std::make_shared<TextComponent>( std::shared_ptr<TextComponent> labelText = std::make_shared<TextComponent>(
mWindow, label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_LEFT); label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_LEFT);
labelText->setSelectable(true); labelText->setSelectable(true);
if (system->getSystemEnvData()->mLaunchCommands.front().second == label) if (system->getSystemEnvData()->mLaunchCommands.front().second == label)

View file

@ -18,7 +18,7 @@ template <typename T> class OptionListComponent;
class GuiAlternativeEmulators : public GuiComponent class GuiAlternativeEmulators : public GuiComponent
{ {
public: public:
GuiAlternativeEmulators(Window* window); GuiAlternativeEmulators();
private: private:
void updateMenu(const std::string& systemName, const std::string& label, bool defaultEmulator); void updateMenu(const std::string& systemName, const std::string& label, bool defaultEmulator);

View file

@ -19,8 +19,8 @@
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include "views/ViewController.h" #include "views/ViewController.h"
GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::string title) GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(std::string title)
: GuiSettings {window, title} : GuiSettings {title}
, mAddedCustomCollection {false} , mAddedCustomCollection {false}
, mDeletedCustomCollection {false} , mDeletedCustomCollection {false}
{ {
@ -29,7 +29,6 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
ComponentListRow row; ComponentListRow row;
row.addElement( row.addElement(
std::make_shared<TextComponent>( std::make_shared<TextComponent>(
mWindow,
"FINISH EDITING '" + "FINISH EDITING '" +
Utils::String::toUpper( Utils::String::toUpper(
CollectionSystemsManager::getInstance()->getEditingCollection()) + CollectionSystemsManager::getInstance()->getEditingCollection()) +
@ -46,7 +45,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
// Automatic collections. // Automatic collections.
collection_systems_auto = std::make_shared<OptionListComponent<std::string>>( collection_systems_auto = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "SELECT COLLECTIONS", true); getHelpStyle(), "SELECT COLLECTIONS", true);
std::map<std::string, CollectionSystemData, stringComparator> autoSystems = std::map<std::string, CollectionSystemData, stringComparator> autoSystems =
CollectionSystemsManager::getInstance()->getAutoCollectionSystems(); CollectionSystemsManager::getInstance()->getAutoCollectionSystems();
// Add automatic systems. // Add automatic systems.
@ -95,7 +94,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
// Custom collections. // Custom collections.
collection_systems_custom = std::make_shared<OptionListComponent<std::string>>( collection_systems_custom = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "SELECT COLLECTIONS", true); getHelpStyle(), "SELECT COLLECTIONS", true);
std::map<std::string, CollectionSystemData, stringComparator> customSystems = std::map<std::string, CollectionSystemData, stringComparator> customSystems =
CollectionSystemsManager::getInstance()->getCustomCollectionSystems(); CollectionSystemsManager::getInstance()->getCustomCollectionSystems();
// Add custom systems. // Add custom systems.
@ -163,20 +162,19 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
CollectionSystemsManager::getInstance()->getUnusedSystemsFromTheme(); CollectionSystemsManager::getInstance()->getUnusedSystemsFromTheme();
if (unusedFolders.size() > 0) { if (unusedFolders.size() > 0) {
ComponentListRow row; ComponentListRow row;
auto themeCollection = auto themeCollection = std::make_shared<TextComponent>(
std::make_shared<TextComponent>(mWindow, "CREATE NEW CUSTOM COLLECTION FROM THEME", "CREATE NEW CUSTOM COLLECTION FROM THEME", Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
Font::get(FONT_SIZE_MEDIUM), 0x777777FF); auto bracketThemeCollection = std::make_shared<ImageComponent>();
auto bracketThemeCollection = std::make_shared<ImageComponent>(mWindow);
bracketThemeCollection->setImage(":/graphics/arrow.svg"); bracketThemeCollection->setImage(":/graphics/arrow.svg");
bracketThemeCollection->setResize( bracketThemeCollection->setResize(
glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
row.addElement(themeCollection, true); row.addElement(themeCollection, true);
row.addElement(bracketThemeCollection, false); row.addElement(bracketThemeCollection, false);
row.makeAcceptInputHandler([this, unusedFolders] { row.makeAcceptInputHandler([this, unusedFolders] {
auto ss = new GuiSettings(mWindow, "SELECT THEME FOLDER"); auto ss = new GuiSettings("SELECT THEME FOLDER");
std::shared_ptr<OptionListComponent<std::string>> folderThemes = std::shared_ptr<OptionListComponent<std::string>> folderThemes {
std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(), std::make_shared<OptionListComponent<std::string>>(getHelpStyle(),
"SELECT THEME FOLDER", true); "SELECT THEME FOLDER", true)};
// Add custom systems. // Add custom systems.
for (auto it = unusedFolders.cbegin(); it != unusedFolders.cend(); ++it) { for (auto it = unusedFolders.cbegin(); it != unusedFolders.cend(); ++it) {
ComponentListRow row; ComponentListRow row;
@ -186,7 +184,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
}; };
row.makeAcceptInputHandler(createCollectionCall); row.makeAcceptInputHandler(createCollectionCall);
auto themeFolder = std::make_shared<TextComponent>( auto themeFolder = std::make_shared<TextComponent>(
mWindow, Utils::String::toUpper(name), Font::get(FONT_SIZE_SMALL), 0x777777FF); Utils::String::toUpper(name), Font::get(FONT_SIZE_SMALL), 0x777777FF);
themeFolder->setSelectable(true); themeFolder->setSelectable(true);
row.addElement(themeFolder, true); row.addElement(themeFolder, true);
ss->addRow(row); ss->addRow(row);
@ -198,35 +196,35 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
// Create new custom collection. // Create new custom collection.
ComponentListRow row; ComponentListRow row;
auto newCollection = std::make_shared<TextComponent>(mWindow, "CREATE NEW CUSTOM COLLECTION", auto newCollection = std::make_shared<TextComponent>("CREATE NEW CUSTOM COLLECTION",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF); Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
auto bracketNewCollection = std::make_shared<ImageComponent>(mWindow); auto bracketNewCollection = std::make_shared<ImageComponent>();
bracketNewCollection->setImage(":/graphics/arrow.svg"); bracketNewCollection->setImage(":/graphics/arrow.svg");
bracketNewCollection->setResize( bracketNewCollection->setResize(
glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
row.addElement(newCollection, true); row.addElement(newCollection, true);
row.addElement(bracketNewCollection, false); row.addElement(bracketNewCollection, false);
auto createCollectionCall = [this](const std::string& newVal) { auto createCollectionCall = [this](const std::string& newVal) {
std::string name = newVal; std::string name {newVal};
// We need to store the first GUI and remove it, as it'll be deleted // We need to store the first GUI and remove it, as it'll be deleted
// by the actual GUI. // by the actual GUI.
Window* window = mWindow; Window* window {mWindow};
GuiComponent* topGui = window->peekGui(); GuiComponent* topGui {window->peekGui()};
window->removeGui(topGui); window->removeGui(topGui);
createCustomCollection(name); createCustomCollection(name);
}; };
if (Settings::getInstance()->getBool("VirtualKeyboard")) { if (Settings::getInstance()->getBool("VirtualKeyboard")) {
row.makeAcceptInputHandler([this, createCollectionCall] { row.makeAcceptInputHandler([this, createCollectionCall] {
mWindow->pushGui(new GuiTextEditKeyboardPopup( mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), "New Collection Name", "",
mWindow, getHelpStyle(), "New Collection Name", "", createCollectionCall, false, createCollectionCall, false, "CREATE",
"CREATE", "CREATE COLLECTION?")); "CREATE COLLECTION?"));
}); });
} }
else { else {
row.makeAcceptInputHandler([this, createCollectionCall] { row.makeAcceptInputHandler([this, createCollectionCall] {
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), "New Collection Name", mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), "New Collection Name", "",
"", createCollectionCall, false, "CREATE", createCollectionCall, false, "CREATE",
"CREATE COLLECTION?")); "CREATE COLLECTION?"));
}); });
} }
@ -235,17 +233,17 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
// Delete custom collection. // Delete custom collection.
row.elements.clear(); row.elements.clear();
auto deleteCollection = std::make_shared<TextComponent>( auto deleteCollection = std::make_shared<TextComponent>(
mWindow, "DELETE CUSTOM COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); "DELETE CUSTOM COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
auto bracketDeleteCollection = std::make_shared<ImageComponent>(mWindow); auto bracketDeleteCollection = std::make_shared<ImageComponent>();
bracketDeleteCollection->setImage(":/graphics/arrow.svg"); bracketDeleteCollection->setImage(":/graphics/arrow.svg");
bracketDeleteCollection->setResize( bracketDeleteCollection->setResize(
glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
row.addElement(deleteCollection, true); row.addElement(deleteCollection, true);
row.addElement(bracketDeleteCollection, false); row.addElement(bracketDeleteCollection, false);
row.makeAcceptInputHandler([this, customSystems] { row.makeAcceptInputHandler([this, customSystems] {
auto ss = new GuiSettings(mWindow, "SELECT COLLECTION TO DELETE"); auto ss = new GuiSettings("SELECT COLLECTION TO DELETE");
std::shared_ptr<OptionListComponent<std::string>> customCollections = std::shared_ptr<OptionListComponent<std::string>> customCollections {
std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(), "", true); std::make_shared<OptionListComponent<std::string>>(getHelpStyle(), "", true)};
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator it = for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator it =
customSystems.cbegin(); customSystems.cbegin();
it != customSystems.cend(); ++it) { it != customSystems.cend(); ++it) {
@ -253,7 +251,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
std::string name = (*it).first; std::string name = (*it).first;
std::function<void()> deleteCollectionCall = [this, name] { std::function<void()> deleteCollectionCall = [this, name] {
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
mWindow, getHelpStyle(), getHelpStyle(),
"THIS WILL PERMANENTLY\nDELETE THE COLLECTION\n'" + "THIS WILL PERMANENTLY\nDELETE THE COLLECTION\n'" +
Utils::String::toUpper(name) + Utils::String::toUpper(name) +
"'\n" "'\n"
@ -297,7 +295,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
}; };
row.makeAcceptInputHandler(deleteCollectionCall); row.makeAcceptInputHandler(deleteCollectionCall);
auto customCollection = std::make_shared<TextComponent>( auto customCollection = std::make_shared<TextComponent>(
mWindow, Utils::String::toUpper(name), Font::get(FONT_SIZE_MEDIUM), 0x777777FF); Utils::String::toUpper(name), Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
customCollection->setSelectable(true); customCollection->setSelectable(true);
row.addElement(customCollection, true); row.addElement(customCollection, true);
ss->addRow(row); ss->addRow(row);
@ -313,7 +311,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
addRow(row); addRow(row);
// Sort favorites on top for custom collections. // Sort favorites on top for custom collections.
auto fav_first_custom = std::make_shared<SwitchComponent>(mWindow); auto fav_first_custom = std::make_shared<SwitchComponent>();
fav_first_custom->setState(Settings::getInstance()->getBool("FavFirstCustom")); fav_first_custom->setState(Settings::getInstance()->getBool("FavFirstCustom"));
addWithLabel("SORT FAVORITES ON TOP FOR CUSTOM COLLECTIONS", fav_first_custom); addWithLabel("SORT FAVORITES ON TOP FOR CUSTOM COLLECTIONS", fav_first_custom);
addSaveFunc([this, fav_first_custom] { addSaveFunc([this, fav_first_custom] {
@ -328,7 +326,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
}); });
// Display star markings for custom collections. // Display star markings for custom collections.
auto fav_star_custom = std::make_shared<SwitchComponent>(mWindow); auto fav_star_custom = std::make_shared<SwitchComponent>();
fav_star_custom->setState(Settings::getInstance()->getBool("FavStarCustom")); fav_star_custom->setState(Settings::getInstance()->getBool("FavStarCustom"));
addWithLabel("DISPLAY STAR MARKINGS FOR CUSTOM COLLECTIONS", fav_star_custom); addWithLabel("DISPLAY STAR MARKINGS FOR CUSTOM COLLECTIONS", fav_star_custom);
addSaveFunc([this, fav_star_custom] { addSaveFunc([this, fav_star_custom] {
@ -341,7 +339,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
}); });
// Group unthemed custom collections. // Group unthemed custom collections.
auto use_custom_collections_system = std::make_shared<SwitchComponent>(mWindow); auto use_custom_collections_system = std::make_shared<SwitchComponent>();
use_custom_collections_system->setState( use_custom_collections_system->setState(
Settings::getInstance()->getBool("UseCustomCollectionsSystem")); Settings::getInstance()->getBool("UseCustomCollectionsSystem"));
addWithLabel("GROUP UNTHEMED CUSTOM COLLECTIONS", use_custom_collections_system); addWithLabel("GROUP UNTHEMED CUSTOM COLLECTIONS", use_custom_collections_system);
@ -363,7 +361,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
}); });
// Show system names in collections. // Show system names in collections.
auto collection_show_system_info = std::make_shared<SwitchComponent>(mWindow); auto collection_show_system_info = std::make_shared<SwitchComponent>();
collection_show_system_info->setState( collection_show_system_info->setState(
Settings::getInstance()->getBool("CollectionShowSystemInfo")); Settings::getInstance()->getBool("CollectionShowSystemInfo"));
addWithLabel("SHOW SYSTEM NAMES IN COLLECTIONS", collection_show_system_info); addWithLabel("SHOW SYSTEM NAMES IN COLLECTIONS", collection_show_system_info);
@ -384,10 +382,10 @@ void GuiCollectionSystemsOptions::createCustomCollection(std::string inName)
if (CollectionSystemsManager::getInstance()->isEditing()) if (CollectionSystemsManager::getInstance()->isEditing())
CollectionSystemsManager::getInstance()->exitEditMode(); CollectionSystemsManager::getInstance()->exitEditMode();
std::string collectionName = std::string collectionName {
CollectionSystemsManager::getInstance()->getValidNewCollectionName(inName); CollectionSystemsManager::getInstance()->getValidNewCollectionName(inName)};
SystemData* newCollection = SystemData* newCollection {
CollectionSystemsManager::getInstance()->addNewCustomCollection(collectionName); CollectionSystemsManager::getInstance()->addNewCustomCollection(collectionName)};
CollectionSystemsManager::getInstance()->saveCustomCollection(newCollection); CollectionSystemsManager::getInstance()->saveCustomCollection(newCollection);
collection_systems_custom->add(collectionName, collectionName, true); collection_systems_custom->add(collectionName, collectionName, true);
@ -400,7 +398,7 @@ void GuiCollectionSystemsOptions::createCustomCollection(std::string inName)
else else
setNeedsGoToSystem(newCollection); setNeedsGoToSystem(newCollection);
Window* window = mWindow; Window* window {mWindow};
while (window->peekGui() && window->peekGui() != ViewController::getInstance()) while (window->peekGui() && window->peekGui() != ViewController::getInstance())
delete window->peekGui(); delete window->peekGui();
CollectionSystemsManager::getInstance()->setEditMode(collectionName); CollectionSystemsManager::getInstance()->setEditMode(collectionName);

View file

@ -17,7 +17,7 @@ template <typename T> class OptionListComponent;
class GuiCollectionSystemsOptions : public GuiSettings class GuiCollectionSystemsOptions : public GuiSettings
{ {
public: public:
GuiCollectionSystemsOptions(Window* window, std::string title); GuiCollectionSystemsOptions(std::string title);
private: private:
void createCustomCollection(std::string inName); void createCustomCollection(std::string inName);

View file

@ -19,11 +19,9 @@
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include "views/ViewController.h" #include "views/ViewController.h"
GuiGamelistFilter::GuiGamelistFilter(Window* window, GuiGamelistFilter::GuiGamelistFilter(SystemData* system,
SystemData* system,
std::function<void(bool)> filterChangedCallback) std::function<void(bool)> filterChangedCallback)
: GuiComponent {window} : mMenu {"FILTER GAMELIST"}
, mMenu {window, "FILTER GAMELIST"}
, mSystem {system} , mSystem {system}
, mFiltersChangedCallback {filterChangedCallback} , mFiltersChangedCallback {filterChangedCallback}
, mFiltersChanged {false} , mFiltersChanged {false}
@ -51,8 +49,8 @@ void GuiGamelistFilter::initializeMenu()
// Show filtered menu. // Show filtered menu.
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, "RESET ALL FILTERS", row.addElement(std::make_shared<TextComponent>("RESET ALL FILTERS", Font::get(FONT_SIZE_MEDIUM),
Font::get(FONT_SIZE_MEDIUM), 0x777777FF), 0x777777FF),
true); true);
row.makeAcceptInputHandler(std::bind(&GuiGamelistFilter::resetAllFilters, this)); row.makeAcceptInputHandler(std::bind(&GuiGamelistFilter::resetAllFilters, this));
mMenu.addRow(row); mMenu.addRow(row);
@ -99,22 +97,22 @@ void GuiGamelistFilter::addFiltersToMenu()
ComponentListRow row; ComponentListRow row;
auto lbl = std::make_shared<TextComponent>( auto lbl = std::make_shared<TextComponent>(
mWindow, Utils::String::toUpper(ViewController::KEYBOARD_CHAR + " GAME NAME"), Utils::String::toUpper(ViewController::KEYBOARD_CHAR + " GAME NAME"),
Font::get(FONT_SIZE_MEDIUM), 0x777777FF); Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
mTextFilterField = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_MEDIUM), mTextFilterField =
0x777777FF, ALIGN_RIGHT); std::make_shared<TextComponent>("", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_RIGHT);
// Don't show the free text filter entry unless there are any games in the system. // Don't show the free text filter entry unless there are any games in the system.
if (mSystem->getRootFolder()->getChildren().size() > 0) { if (mSystem->getRootFolder()->getChildren().size() > 0) {
row.addElement(lbl, true); row.addElement(lbl, true);
row.addElement(mTextFilterField, true); row.addElement(mTextFilterField, true);
auto spacer = std::make_shared<GuiComponent>(mWindow); auto spacer = std::make_shared<GuiComponent>();
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f); spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f);
row.addElement(spacer, false); row.addElement(spacer, false);
auto bracket = std::make_shared<ImageComponent>(mWindow); auto bracket = std::make_shared<ImageComponent>();
bracket->setImage(":/graphics/arrow.svg"); bracket->setImage(":/graphics/arrow.svg");
bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()});
row.addElement(bracket, false); row.addElement(bracket, false);
@ -130,14 +128,14 @@ void GuiGamelistFilter::addFiltersToMenu()
if (Settings::getInstance()->getBool("VirtualKeyboard")) { if (Settings::getInstance()->getBool("VirtualKeyboard")) {
row.makeAcceptInputHandler([this, updateVal] { row.makeAcceptInputHandler([this, updateVal] {
mWindow->pushGui(new GuiTextEditKeyboardPopup(mWindow, getHelpStyle(), "GAME NAME", mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), "GAME NAME",
mTextFilterField->getValue(), updateVal, mTextFilterField->getValue(), updateVal,
false, "OK", "APPLY CHANGES?")); false, "OK", "APPLY CHANGES?"));
}); });
} }
else { else {
row.makeAcceptInputHandler([this, updateVal] { row.makeAcceptInputHandler([this, updateVal] {
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), "GAME NAME", mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), "GAME NAME",
mTextFilterField->getValue(), updateVal, false, mTextFilterField->getValue(), updateVal, false,
"OK", "APPLY CHANGES?")); "OK", "APPLY CHANGES?"));
}); });
@ -178,10 +176,10 @@ void GuiGamelistFilter::addFiltersToMenu()
// For bool values, make the selection exclusive so that both True and False can't be // For bool values, make the selection exclusive so that both True and False can't be
// selected at the same time. This should be changed to a SwitchComponent at some point. // selected at the same time. This should be changed to a SwitchComponent at some point.
if (exclusiveSelect) if (exclusiveSelect)
optionList = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(), optionList = std::make_shared<OptionListComponent<std::string>>(getHelpStyle(),
menuLabel, true, true); menuLabel, true, true);
else else
optionList = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(), optionList = std::make_shared<OptionListComponent<std::string>>(getHelpStyle(),
menuLabel, true, false); menuLabel, true, false);
// Still display fields that can't be filtered in the menu, but notify the user and set // Still display fields that can't be filtered in the menu, but notify the user and set

View file

@ -21,10 +21,7 @@ class SystemData;
class GuiGamelistFilter : public GuiComponent class GuiGamelistFilter : public GuiComponent
{ {
public: public:
GuiGamelistFilter(Window* window, GuiGamelistFilter(SystemData* system, std::function<void(bool)> filtersChangedCallback);
SystemData* system,
std::function<void(bool)> filtersChangedCallback);
~GuiGamelistFilter() { mFilterOptions.clear(); } ~GuiGamelistFilter() { mFilterOptions.clear(); }
bool input(InputConfig* config, Input input) override; bool input(InputConfig* config, Input input) override;

View file

@ -24,9 +24,8 @@
#include "scrapers/Scraper.h" #include "scrapers/Scraper.h"
#include "views/ViewController.h" #include "views/ViewController.h"
GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) GuiGamelistOptions::GuiGamelistOptions(SystemData* system)
: GuiComponent {window} : mMenu {"OPTIONS"}
, mMenu {window, "OPTIONS"}
, mSystem {system} , mSystem {system}
, mFiltersChanged {false} , mFiltersChanged {false}
, mCancelled {false} , mCancelled {false}
@ -95,8 +94,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
mCurrentFirstCharacter = Utils::String::getFirstCharacter(file->getSortName()); mCurrentFirstCharacter = Utils::String::getFirstCharacter(file->getSortName());
} }
mJumpToLetterList = mJumpToLetterList = std::make_shared<LetterList>(getHelpStyle(), "JUMP TO...", false);
std::make_shared<LetterList>(mWindow, getHelpStyle(), "JUMP TO...", false);
// Enable key repeat so that the left or right button can be held to cycle through // Enable key repeat so that the left or right button can be held to cycle through
// the letters. // the letters.
@ -115,7 +113,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
// Add the sorting entry, unless this is the grouped custom collections list. // Add the sorting entry, unless this is the grouped custom collections list.
if (!mIsCustomCollectionGroup) { if (!mIsCustomCollectionGroup) {
// Sort list by selected sort type (persistent throughout the program session). // Sort list by selected sort type (persistent throughout the program session).
mListSort = std::make_shared<SortList>(mWindow, getHelpStyle(), "SORT GAMES BY", false); mListSort = std::make_shared<SortList>(getHelpStyle(), "SORT GAMES BY", false);
FileData* root; FileData* root;
if (mIsCustomCollection) if (mIsCustomCollection)
root = getGamelist()->getCursor()->getSystem()->getRootFolder(); root = getGamelist()->getCursor()->getSystem()->getRootFolder();
@ -151,10 +149,10 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
if (!mIsCustomCollectionGroup && system->getRootFolder()->getChildren().size() > 0) { if (!mIsCustomCollectionGroup && system->getRootFolder()->getChildren().size() > 0) {
if (system->getName() != "recent" && Settings::getInstance()->getBool("GamelistFilters")) { if (system->getName() != "recent" && Settings::getInstance()->getBool("GamelistFilters")) {
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, "FILTER GAMELIST", row.addElement(std::make_shared<TextComponent>("FILTER GAMELIST",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF), Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
true); true);
row.addElement(makeArrow(mWindow), false); row.addElement(makeArrow(), false);
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openGamelistFilter, this)); row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openGamelistFilter, this));
mMenu.addRow(row); mMenu.addRow(row);
} }
@ -164,7 +162,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
mSystem->getRootFolder()->getChildren().size() == 0 && !mIsCustomCollectionGroup && mSystem->getRootFolder()->getChildren().size() == 0 && !mIsCustomCollectionGroup &&
!mIsCustomCollection) { !mIsCustomCollection) {
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, "THIS SYSTEM HAS NO GAMES", row.addElement(std::make_shared<TextComponent>("THIS SYSTEM HAS NO GAMES",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF), Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
true); true);
mMenu.addRow(row); mMenu.addRow(row);
@ -180,8 +178,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
(mIsCustomCollection || mIsCustomCollectionGroup)) { (mIsCustomCollection || mIsCustomCollectionGroup)) {
if (CollectionSystemsManager::getInstance()->getEditingCollection() != customSystem) { if (CollectionSystemsManager::getInstance()->getEditingCollection() != customSystem) {
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, row.addElement(std::make_shared<TextComponent>("ADD/REMOVE GAMES TO THIS COLLECTION",
"ADD/REMOVE GAMES TO THIS COLLECTION",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF), Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
true); true);
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::startEditMode, this)); row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::startEditMode, this));
@ -194,7 +191,6 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
row.elements.clear(); row.elements.clear();
row.addElement( row.addElement(
std::make_shared<TextComponent>( std::make_shared<TextComponent>(
mWindow,
"FINISH EDITING '" + "FINISH EDITING '" +
Utils::String::toUpper( Utils::String::toUpper(
CollectionSystemsManager::getInstance()->getEditingCollection()) + CollectionSystemsManager::getInstance()->getEditingCollection()) +
@ -209,10 +205,10 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
if (UIModeController::getInstance()->isUIModeFull() && !mFromPlaceholder && if (UIModeController::getInstance()->isUIModeFull() && !mFromPlaceholder &&
!(mSystem->isCollection() && file->getType() == FOLDER)) { !(mSystem->isCollection() && file->getType() == FOLDER)) {
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, "EDIT THIS FOLDER'S METADATA", row.addElement(std::make_shared<TextComponent>("EDIT THIS FOLDER'S METADATA",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF), Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
true); true);
row.addElement(makeArrow(mWindow), false); row.addElement(makeArrow(), false);
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openMetaDataEd, this)); row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openMetaDataEd, this));
mMenu.addRow(row); mMenu.addRow(row);
} }
@ -221,10 +217,10 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
if (UIModeController::getInstance()->isUIModeFull() && !mFromPlaceholder && if (UIModeController::getInstance()->isUIModeFull() && !mFromPlaceholder &&
!(mSystem->isCollection() && file->getType() == FOLDER)) { !(mSystem->isCollection() && file->getType() == FOLDER)) {
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, "EDIT THIS GAME'S METADATA", row.addElement(std::make_shared<TextComponent>("EDIT THIS GAME'S METADATA",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF), Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
true); true);
row.addElement(makeArrow(mWindow), false); row.addElement(makeArrow(), false);
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openMetaDataEd, this)); row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openMetaDataEd, this));
mMenu.addRow(row); mMenu.addRow(row);
} }
@ -323,10 +319,9 @@ void GuiGamelistOptions::openGamelistFilter()
}; };
if (mIsCustomCollection) if (mIsCustomCollection)
ggf = new GuiGamelistFilter(mWindow, getGamelist()->getCursor()->getSystem(), ggf = new GuiGamelistFilter(getGamelist()->getCursor()->getSystem(), filtersChangedFunc);
filtersChangedFunc);
else else
ggf = new GuiGamelistFilter(mWindow, mSystem, filtersChangedFunc); ggf = new GuiGamelistFilter(mSystem, filtersChangedFunc);
mWindow->pushGui(ggf); mWindow->pushGui(ggf);
} }
@ -452,7 +447,7 @@ void GuiGamelistOptions::openMetaDataEd()
if (file->getType() == FOLDER) { if (file->getType() == FOLDER) {
mWindow->pushGui(new GuiMetaDataEd( mWindow->pushGui(new GuiMetaDataEd(
mWindow, &file->metadata, file->metadata.getMDD(FOLDER_METADATA), p, &file->metadata, file->metadata.getMDD(FOLDER_METADATA), p,
std::bind(&GamelistView::onFileChanged, std::bind(&GamelistView::onFileChanged,
ViewController::getInstance()->getGamelistView(file->getSystem()).get(), file, ViewController::getInstance()->getGamelistView(file->getSystem()).get(), file,
true), true),
@ -460,7 +455,7 @@ void GuiGamelistOptions::openMetaDataEd()
} }
else { else {
mWindow->pushGui(new GuiMetaDataEd( mWindow->pushGui(new GuiMetaDataEd(
mWindow, &file->metadata, file->metadata.getMDD(GAME_METADATA), p, &file->metadata, file->metadata.getMDD(GAME_METADATA), p,
std::bind(&GamelistView::onFileChanged, std::bind(&GamelistView::onFileChanged,
ViewController::getInstance()->getGamelistView(file->getSystem()).get(), file, ViewController::getInstance()->getGamelistView(file->getSystem()).get(), file,
true), true),
@ -470,7 +465,7 @@ void GuiGamelistOptions::openMetaDataEd()
void GuiGamelistOptions::jumpToLetter() void GuiGamelistOptions::jumpToLetter()
{ {
char letter = mJumpToLetterList->getSelected().front(); char letter {mJumpToLetterList->getSelected().front()};
// Get the gamelist. // Get the gamelist.
const std::vector<FileData*>& files = const std::vector<FileData*>& files =

View file

@ -25,7 +25,7 @@ class SystemData;
class GuiGamelistOptions : public GuiComponent class GuiGamelistOptions : public GuiComponent
{ {
public: public:
GuiGamelistOptions(Window* window, SystemData* system); GuiGamelistOptions(SystemData* system);
virtual ~GuiGamelistOptions(); virtual ~GuiGamelistOptions();
bool input(InputConfig* config, Input input) override; bool input(InputConfig* config, Input input) override;

View file

@ -15,9 +15,7 @@
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
GuiLaunchScreen::GuiLaunchScreen() GuiLaunchScreen::GuiLaunchScreen()
: GuiComponent {Window::getInstance()} : mBackground {":/graphics/frame.svg"}
, mWindow {Window::getInstance()}
, mBackground {mWindow, ":/graphics/frame.svg"}
, mGrid {nullptr} , mGrid {nullptr}
, mMarquee {nullptr} , mMarquee {nullptr}
{ {
@ -33,7 +31,7 @@ GuiLaunchScreen::~GuiLaunchScreen()
void GuiLaunchScreen::displayLaunchScreen(FileData* game) void GuiLaunchScreen::displayLaunchScreen(FileData* game)
{ {
mGrid = new ComponentGrid(mWindow, glm::ivec2 {3, 8}); mGrid = new ComponentGrid(glm::ivec2 {3, 8});
addChild(mGrid); addChild(mGrid);
mImagePath = game->getMarqueePath(); mImagePath = game->getMarqueePath();
@ -42,7 +40,7 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
// which would lead to the wrong size when using the image here. // which would lead to the wrong size when using the image here.
if (mImagePath != "") { if (mImagePath != "") {
TextureResource::manualUnload(mImagePath, false); TextureResource::manualUnload(mImagePath, false);
mMarquee = new ImageComponent(mWindow); mMarquee = new ImageComponent;
} }
mScaleUp = 0.5f; mScaleUp = 0.5f;
@ -50,52 +48,52 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
const float gameNameFontSize = 0.073f; const float gameNameFontSize = 0.073f;
// Spacer row. // Spacer row.
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 0}, false, false, mGrid->setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {1, 0}, false, false,
glm::ivec2 {1, 1}); glm::ivec2 {1, 1});
// Title. // Title.
mTitle = std::make_shared<TextComponent>( mTitle = std::make_shared<TextComponent>(
mWindow, "LAUNCHING GAME", "LAUNCHING GAME",
Font::get(static_cast<int>( Font::get(static_cast<int>(
titleFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))), titleFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))),
0x666666FF, ALIGN_CENTER); 0x666666FF, ALIGN_CENTER);
mGrid->setEntry(mTitle, glm::ivec2 {1, 1}, false, true, glm::ivec2 {1, 1}); mGrid->setEntry(mTitle, glm::ivec2 {1, 1}, false, true, glm::ivec2 {1, 1});
// Spacer row. // Spacer row.
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 2}, false, false, mGrid->setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {1, 2}, false, false,
glm::ivec2 {1, 1}); glm::ivec2 {1, 1});
// Row for the marquee. // Row for the marquee.
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 3}, false, false, mGrid->setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {1, 3}, false, false,
glm::ivec2 {1, 1}); glm::ivec2 {1, 1});
// Spacer row. // Spacer row.
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 4}, false, false, mGrid->setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {1, 4}, false, false,
glm::ivec2 {1, 1}); glm::ivec2 {1, 1});
// Game name. // Game name.
mGameName = std::make_shared<TextComponent>( mGameName = std::make_shared<TextComponent>(
mWindow, "GAME NAME", "GAME NAME",
Font::get(static_cast<int>( Font::get(static_cast<int>(
gameNameFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))), gameNameFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))),
0x444444FF, ALIGN_CENTER); 0x444444FF, ALIGN_CENTER);
mGrid->setEntry(mGameName, glm::ivec2 {1, 5}, false, true, glm::ivec2 {1, 1}); mGrid->setEntry(mGameName, glm::ivec2 {1, 5}, false, true, glm::ivec2 {1, 1});
// System name. // System name.
mSystemName = std::make_shared<TextComponent>( mSystemName = std::make_shared<TextComponent>("SYSTEM NAME", Font::get(FONT_SIZE_MEDIUM),
mWindow, "SYSTEM NAME", Font::get(FONT_SIZE_MEDIUM), 0x666666FF, ALIGN_CENTER); 0x666666FF, ALIGN_CENTER);
mGrid->setEntry(mSystemName, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1}); mGrid->setEntry(mSystemName, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1});
// Spacer row. // Spacer row.
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 7}, false, false, mGrid->setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {1, 7}, false, false,
glm::ivec2 {1, 1}); glm::ivec2 {1, 1});
// Left spacer. // Left spacer.
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {0, 0}, false, false, mGrid->setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {0, 0}, false, false,
glm::ivec2 {1, 8}); glm::ivec2 {1, 8});
// Right spacer. // Right spacer.
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {2, 0}, false, false, mGrid->setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {2, 0}, false, false,
glm::ivec2 {1, 8}); glm::ivec2 {1, 8});
// Adjust the width depending on the aspect ratio of the screen, to make the screen look // Adjust the width depending on the aspect ratio of the screen, to make the screen look

View file

@ -33,7 +33,6 @@ public:
void render(const glm::mat4& parentTrans) override; void render(const glm::mat4& parentTrans) override;
private: private:
Window* mWindow;
NinePatchComponent mBackground; NinePatchComponent mBackground;
ComponentGrid* mGrid; ComponentGrid* mGrid;

View file

@ -12,11 +12,11 @@
#include "Settings.h" #include "Settings.h"
#include "components/SwitchComponent.h" #include "components/SwitchComponent.h"
GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string& title) GuiMediaViewerOptions::GuiMediaViewerOptions(const std::string& title)
: GuiSettings {window, title} : GuiSettings {title}
{ {
// Keep videos running when viewing images. // Keep videos running when viewing images.
auto keep_video_running = std::make_shared<SwitchComponent>(mWindow); auto keep_video_running = std::make_shared<SwitchComponent>();
keep_video_running->setState(Settings::getInstance()->getBool("MediaViewerKeepVideoRunning")); keep_video_running->setState(Settings::getInstance()->getBool("MediaViewerKeepVideoRunning"));
addWithLabel("KEEP VIDEOS RUNNING WHEN VIEWING IMAGES", keep_video_running); addWithLabel("KEEP VIDEOS RUNNING WHEN VIEWING IMAGES", keep_video_running);
addSaveFunc([keep_video_running, this] { addSaveFunc([keep_video_running, this] {
@ -29,7 +29,7 @@ GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string&
}); });
// Stretch videos to screen resolution. // Stretch videos to screen resolution.
auto stretch_videos = std::make_shared<SwitchComponent>(mWindow); auto stretch_videos = std::make_shared<SwitchComponent>();
stretch_videos->setState(Settings::getInstance()->getBool("MediaViewerStretchVideos")); stretch_videos->setState(Settings::getInstance()->getBool("MediaViewerStretchVideos"));
addWithLabel("STRETCH VIDEOS TO SCREEN RESOLUTION", stretch_videos); addWithLabel("STRETCH VIDEOS TO SCREEN RESOLUTION", stretch_videos);
addSaveFunc([stretch_videos, this] { addSaveFunc([stretch_videos, this] {
@ -43,7 +43,7 @@ GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string&
#if defined(USE_OPENGL_21) #if defined(USE_OPENGL_21)
// Render scanlines for videos using a shader. // Render scanlines for videos using a shader.
auto video_scanlines = std::make_shared<SwitchComponent>(mWindow); auto video_scanlines = std::make_shared<SwitchComponent>();
video_scanlines->setState(Settings::getInstance()->getBool("MediaViewerVideoScanlines")); video_scanlines->setState(Settings::getInstance()->getBool("MediaViewerVideoScanlines"));
addWithLabel("RENDER SCANLINES FOR VIDEOS", video_scanlines); addWithLabel("RENDER SCANLINES FOR VIDEOS", video_scanlines);
addSaveFunc([video_scanlines, this] { addSaveFunc([video_scanlines, this] {
@ -56,7 +56,7 @@ GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string&
}); });
// Render blur for videos using a shader. // Render blur for videos using a shader.
auto video_blur = std::make_shared<SwitchComponent>(mWindow); auto video_blur = std::make_shared<SwitchComponent>();
video_blur->setState(Settings::getInstance()->getBool("MediaViewerVideoBlur")); video_blur->setState(Settings::getInstance()->getBool("MediaViewerVideoBlur"));
addWithLabel("RENDER BLUR FOR VIDEOS", video_blur); addWithLabel("RENDER BLUR FOR VIDEOS", video_blur);
addSaveFunc([video_blur, this] { addSaveFunc([video_blur, this] {
@ -67,7 +67,7 @@ GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string&
}); });
// Render scanlines for screenshots and title screens using a shader. // Render scanlines for screenshots and title screens using a shader.
auto screenshot_scanlines = std::make_shared<SwitchComponent>(mWindow); auto screenshot_scanlines = std::make_shared<SwitchComponent>();
screenshot_scanlines->setState( screenshot_scanlines->setState(
Settings::getInstance()->getBool("MediaViewerScreenshotScanlines")); Settings::getInstance()->getBool("MediaViewerScreenshotScanlines"));
addWithLabel("RENDER SCANLINES FOR SCREENSHOTS AND TITLES", screenshot_scanlines); addWithLabel("RENDER SCANLINES FOR SCREENSHOTS AND TITLES", screenshot_scanlines);

View file

@ -15,7 +15,7 @@
class GuiMediaViewerOptions : public GuiSettings class GuiMediaViewerOptions : public GuiSettings
{ {
public: public:
GuiMediaViewerOptions(Window* window, const std::string& title); GuiMediaViewerOptions(const std::string& title);
}; };
#endif // ES_APP_GUIS_GUI_MEDIA_VIEWER_OPTIONS_H #endif // ES_APP_GUIS_GUI_MEDIA_VIEWER_OPTIONS_H

View file

@ -39,10 +39,8 @@
#include <SDL2/SDL_events.h> #include <SDL2/SDL_events.h>
#include <algorithm> #include <algorithm>
GuiMenu::GuiMenu(Window* window) GuiMenu::GuiMenu()
: GuiComponent {window} : mMenu {"MAIN MENU"}
, mMenu {window, "MAIN MENU"}
, mVersion {window}
{ {
bool isFullUI = UIModeController::getInstance()->isUIModeFull(); bool isFullUI = UIModeController::getInstance()->isUIModeFull();
@ -94,16 +92,16 @@ GuiMenu::~GuiMenu()
void GuiMenu::openScraperOptions() void GuiMenu::openScraperOptions()
{ {
// Open the scraper menu. // Open the scraper menu.
mWindow->pushGui(new GuiScraperMenu(mWindow, "SCRAPER")); mWindow->pushGui(new GuiScraperMenu("SCRAPER"));
} }
void GuiMenu::openUIOptions() void GuiMenu::openUIOptions()
{ {
auto s = new GuiSettings(mWindow, "UI SETTINGS"); auto s = new GuiSettings("UI SETTINGS");
// Optionally start in selected system/gamelist. // Optionally start in selected system/gamelist.
auto startupSystem = std::make_shared<OptionListComponent<std::string>>( auto startupSystem = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "GAMELIST ON STARTUP", false); getHelpStyle(), "GAMELIST ON STARTUP", false);
startupSystem->add("NONE", "", Settings::getInstance()->getString("StartupSystem") == ""); startupSystem->add("NONE", "", Settings::getInstance()->getString("StartupSystem") == "");
for (auto it = SystemData::sSystemVector.cbegin(); // Line break. for (auto it = SystemData::sSystemVector.cbegin(); // Line break.
it != SystemData::sSystemVector.cend(); ++it) { it != SystemData::sSystemVector.cend(); ++it) {
@ -130,7 +128,7 @@ void GuiMenu::openUIOptions()
// Gamelist view style. // Gamelist view style.
auto gamelist_view_style = std::make_shared<OptionListComponent<std::string>>( auto gamelist_view_style = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "GAMELIST VIEW STYLE", false); getHelpStyle(), "GAMELIST VIEW STYLE", false);
std::string selectedViewStyle = Settings::getInstance()->getString("GamelistViewStyle"); std::string selectedViewStyle = Settings::getInstance()->getString("GamelistViewStyle");
gamelist_view_style->add("automatic", "automatic", selectedViewStyle == "automatic"); gamelist_view_style->add("automatic", "automatic", selectedViewStyle == "automatic");
gamelist_view_style->add("basic", "basic", selectedViewStyle == "basic"); gamelist_view_style->add("basic", "basic", selectedViewStyle == "basic");
@ -154,7 +152,7 @@ void GuiMenu::openUIOptions()
// Transition style. // Transition style.
auto transition_style = std::make_shared<OptionListComponent<std::string>>( auto transition_style = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "TRANSITION STYLE", false); getHelpStyle(), "TRANSITION STYLE", false);
std::vector<std::string> transitions; std::vector<std::string> transitions;
transitions.push_back("slide"); transitions.push_back("slide");
transitions.push_back("fade"); transitions.push_back("fade");
@ -178,8 +176,8 @@ void GuiMenu::openUIOptions()
themeSets.find(Settings::getInstance()->getString("ThemeSet")); themeSets.find(Settings::getInstance()->getString("ThemeSet"));
if (selectedSet == themeSets.cend()) if (selectedSet == themeSets.cend())
selectedSet = themeSets.cbegin(); selectedSet = themeSets.cbegin();
auto theme_set = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(), auto theme_set =
"THEME SET", false); std::make_shared<OptionListComponent<std::string>>(getHelpStyle(), "THEME SET", false);
for (auto it = themeSets.cbegin(); it != themeSets.cend(); ++it) { for (auto it = themeSets.cbegin(); it != themeSets.cend(); ++it) {
// If required, abbreviate the theme set name so it doesn't overlap the setting name. // If required, abbreviate the theme set name so it doesn't overlap the setting name.
float maxNameLength = mSize.x * 0.62f; float maxNameLength = mSize.x * 0.62f;
@ -208,8 +206,8 @@ void GuiMenu::openUIOptions()
} }
// UI mode. // UI mode.
auto ui_mode = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(), auto ui_mode =
"UI MODE", false); std::make_shared<OptionListComponent<std::string>>(getHelpStyle(), "UI MODE", false);
std::vector<std::string> uiModes; std::vector<std::string> uiModes;
uiModes.push_back("full"); uiModes.push_back("full");
uiModes.push_back("kiosk"); uiModes.push_back("kiosk");
@ -248,7 +246,7 @@ void GuiMenu::openUIOptions()
msg += UIModeController::getInstance()->getFormattedPassKeyStr() + "\n\n"; msg += UIModeController::getInstance()->getFormattedPassKeyStr() + "\n\n";
msg += "DO YOU WANT TO PROCEED?"; msg += "DO YOU WANT TO PROCEED?";
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
mWindow, this->getHelpStyle(), msg, "YES", this->getHelpStyle(), msg, "YES",
[this, selectedMode] { [this, selectedMode] {
LOG(LogDebug) << "GuiMenu::openUISettings(): Setting UI mode to '" LOG(LogDebug) << "GuiMenu::openUISettings(): Setting UI mode to '"
<< selectedMode << "'."; << selectedMode << "'.";
@ -296,7 +294,7 @@ void GuiMenu::openUIOptions()
// Default gamelist sort order. // Default gamelist sort order.
std::string sortOrder; std::string sortOrder;
auto default_sort_order = std::make_shared<OptionListComponent<const FileData::SortType*>>( auto default_sort_order = std::make_shared<OptionListComponent<const FileData::SortType*>>(
mWindow, getHelpStyle(), "DEFAULT SORT ORDER", false); getHelpStyle(), "DEFAULT SORT ORDER", false);
// Exclude the System sort options. // Exclude the System sort options.
unsigned int numSortTypes = static_cast<unsigned int>(FileSorts::SortTypes.size() - 2); unsigned int numSortTypes = static_cast<unsigned int>(FileSorts::SortTypes.size() - 2);
for (unsigned int i = 0; i < numSortTypes; ++i) { for (unsigned int i = 0; i < numSortTypes; ++i) {
@ -331,7 +329,7 @@ void GuiMenu::openUIOptions()
// Open menu effect. // Open menu effect.
auto menu_opening_effect = std::make_shared<OptionListComponent<std::string>>( auto menu_opening_effect = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "MENU OPENING EFFECT", false); getHelpStyle(), "MENU OPENING EFFECT", false);
std::string selectedMenuEffect = Settings::getInstance()->getString("MenuOpeningEffect"); std::string selectedMenuEffect = Settings::getInstance()->getString("MenuOpeningEffect");
menu_opening_effect->add("SCALE-UP", "scale-up", selectedMenuEffect == "scale-up"); menu_opening_effect->add("SCALE-UP", "scale-up", selectedMenuEffect == "scale-up");
menu_opening_effect->add("NONE", "none", selectedMenuEffect == "none"); menu_opening_effect->add("NONE", "none", selectedMenuEffect == "none");
@ -351,7 +349,7 @@ void GuiMenu::openUIOptions()
// Launch screen duration. // Launch screen duration.
auto launch_screen_duration = std::make_shared<OptionListComponent<std::string>>( auto launch_screen_duration = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "LAUNCH SCREEN DURATION", false); getHelpStyle(), "LAUNCH SCREEN DURATION", false);
std::string selectedDuration = Settings::getInstance()->getString("LaunchScreenDuration"); std::string selectedDuration = Settings::getInstance()->getString("LaunchScreenDuration");
launch_screen_duration->add("NORMAL", "normal", selectedDuration == "normal"); launch_screen_duration->add("NORMAL", "normal", selectedDuration == "normal");
launch_screen_duration->add("BRIEF", "brief", selectedDuration == "brief"); launch_screen_duration->add("BRIEF", "brief", selectedDuration == "brief");
@ -374,28 +372,27 @@ void GuiMenu::openUIOptions()
// Media viewer. // Media viewer.
ComponentListRow media_viewer_row; ComponentListRow media_viewer_row;
media_viewer_row.elements.clear(); media_viewer_row.elements.clear();
media_viewer_row.addElement(std::make_shared<TextComponent>(mWindow, "MEDIA VIEWER SETTINGS", media_viewer_row.addElement(std::make_shared<TextComponent>("MEDIA VIEWER SETTINGS",
Font::get(FONT_SIZE_MEDIUM), Font::get(FONT_SIZE_MEDIUM),
0x777777FF), 0x777777FF),
true); true);
media_viewer_row.addElement(makeArrow(mWindow), false); media_viewer_row.addElement(makeArrow(), false);
media_viewer_row.makeAcceptInputHandler(std::bind(&GuiMenu::openMediaViewerOptions, this)); media_viewer_row.makeAcceptInputHandler(std::bind(&GuiMenu::openMediaViewerOptions, this));
s->addRow(media_viewer_row); s->addRow(media_viewer_row);
// Screensaver. // Screensaver.
ComponentListRow screensaver_row; ComponentListRow screensaver_row;
screensaver_row.elements.clear(); screensaver_row.elements.clear();
screensaver_row.addElement(std::make_shared<TextComponent>(mWindow, "SCREENSAVER SETTINGS", screensaver_row.addElement(std::make_shared<TextComponent>(
Font::get(FONT_SIZE_MEDIUM), "SCREENSAVER SETTINGS", Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
0x777777FF),
true); true);
screensaver_row.addElement(makeArrow(mWindow), false); screensaver_row.addElement(makeArrow(), false);
screensaver_row.makeAcceptInputHandler(std::bind(&GuiMenu::openScreensaverOptions, this)); screensaver_row.makeAcceptInputHandler(std::bind(&GuiMenu::openScreensaverOptions, this));
s->addRow(screensaver_row); s->addRow(screensaver_row);
#if defined(USE_OPENGL_21) #if defined(USE_OPENGL_21)
// Blur background when the menu is open. // Blur background when the menu is open.
auto menu_blur_background = std::make_shared<SwitchComponent>(mWindow); auto menu_blur_background = std::make_shared<SwitchComponent>();
menu_blur_background->setState(Settings::getInstance()->getBool("MenuBlurBackground")); menu_blur_background->setState(Settings::getInstance()->getBool("MenuBlurBackground"));
s->addWithLabel("BLUR BACKGROUND WHEN MENU IS OPEN", menu_blur_background); s->addWithLabel("BLUR BACKGROUND WHEN MENU IS OPEN", menu_blur_background);
s->addSaveFunc([menu_blur_background, s] { s->addSaveFunc([menu_blur_background, s] {
@ -410,7 +407,7 @@ void GuiMenu::openUIOptions()
#endif #endif
// Display pillarboxes (and letterboxes) for videos in the gamelists. // Display pillarboxes (and letterboxes) for videos in the gamelists.
auto gamelist_video_pillarbox = std::make_shared<SwitchComponent>(mWindow); auto gamelist_video_pillarbox = std::make_shared<SwitchComponent>();
gamelist_video_pillarbox->setState(Settings::getInstance()->getBool("GamelistVideoPillarbox")); gamelist_video_pillarbox->setState(Settings::getInstance()->getBool("GamelistVideoPillarbox"));
s->addWithLabel("DISPLAY PILLARBOXES FOR GAMELIST VIDEOS", gamelist_video_pillarbox); s->addWithLabel("DISPLAY PILLARBOXES FOR GAMELIST VIDEOS", gamelist_video_pillarbox);
s->addSaveFunc([gamelist_video_pillarbox, s] { s->addSaveFunc([gamelist_video_pillarbox, s] {
@ -424,7 +421,7 @@ void GuiMenu::openUIOptions()
#if defined(USE_OPENGL_21) #if defined(USE_OPENGL_21)
// Render scanlines for videos in the gamelists. // Render scanlines for videos in the gamelists.
auto gamelist_video_scanlines = std::make_shared<SwitchComponent>(mWindow); auto gamelist_video_scanlines = std::make_shared<SwitchComponent>();
gamelist_video_scanlines->setState(Settings::getInstance()->getBool("GamelistVideoScanlines")); gamelist_video_scanlines->setState(Settings::getInstance()->getBool("GamelistVideoScanlines"));
s->addWithLabel("RENDER SCANLINES FOR GAMELIST VIDEOS", gamelist_video_scanlines); s->addWithLabel("RENDER SCANLINES FOR GAMELIST VIDEOS", gamelist_video_scanlines);
s->addSaveFunc([gamelist_video_scanlines, s] { s->addSaveFunc([gamelist_video_scanlines, s] {
@ -438,7 +435,7 @@ void GuiMenu::openUIOptions()
#endif #endif
// Sort folders on top of the gamelists. // Sort folders on top of the gamelists.
auto folders_on_top = std::make_shared<SwitchComponent>(mWindow); auto folders_on_top = std::make_shared<SwitchComponent>();
folders_on_top->setState(Settings::getInstance()->getBool("FoldersOnTop")); folders_on_top->setState(Settings::getInstance()->getBool("FoldersOnTop"));
s->addWithLabel("SORT FOLDERS ON TOP OF GAMELISTS", folders_on_top); s->addWithLabel("SORT FOLDERS ON TOP OF GAMELISTS", folders_on_top);
s->addSaveFunc([folders_on_top, s] { s->addSaveFunc([folders_on_top, s] {
@ -451,7 +448,7 @@ void GuiMenu::openUIOptions()
}); });
// Sort favorites on top of non-favorites in the gamelists. // Sort favorites on top of non-favorites in the gamelists.
auto favorites_first = std::make_shared<SwitchComponent>(mWindow); auto favorites_first = std::make_shared<SwitchComponent>();
favorites_first->setState(Settings::getInstance()->getBool("FavoritesFirst")); favorites_first->setState(Settings::getInstance()->getBool("FavoritesFirst"));
s->addWithLabel("SORT FAVORITE GAMES ABOVE NON-FAVORITES", favorites_first); s->addWithLabel("SORT FAVORITE GAMES ABOVE NON-FAVORITES", favorites_first);
s->addSaveFunc([favorites_first, s] { s->addSaveFunc([favorites_first, s] {
@ -465,7 +462,7 @@ void GuiMenu::openUIOptions()
}); });
// Enable gamelist star markings for favorite games. // Enable gamelist star markings for favorite games.
auto favorites_star = std::make_shared<SwitchComponent>(mWindow); auto favorites_star = std::make_shared<SwitchComponent>();
favorites_star->setState(Settings::getInstance()->getBool("FavoritesStar")); favorites_star->setState(Settings::getInstance()->getBool("FavoritesStar"));
s->addWithLabel("ADD STAR MARKINGS TO FAVORITE GAMES", favorites_star); s->addWithLabel("ADD STAR MARKINGS TO FAVORITE GAMES", favorites_star);
s->addSaveFunc([favorites_star, s] { s->addSaveFunc([favorites_star, s] {
@ -478,7 +475,7 @@ void GuiMenu::openUIOptions()
}); });
// Use ASCII for special characters in the gamelist view instead of the Font Awesome symbols. // Use ASCII for special characters in the gamelist view instead of the Font Awesome symbols.
auto special_chars_ascii = std::make_shared<SwitchComponent>(mWindow); auto special_chars_ascii = std::make_shared<SwitchComponent>();
special_chars_ascii->setState(Settings::getInstance()->getBool("SpecialCharsASCII")); special_chars_ascii->setState(Settings::getInstance()->getBool("SpecialCharsASCII"));
s->addWithLabel("USE PLAIN ASCII FOR SPECIAL GAMELIST CHARACTERS", special_chars_ascii); s->addWithLabel("USE PLAIN ASCII FOR SPECIAL GAMELIST CHARACTERS", special_chars_ascii);
s->addSaveFunc([special_chars_ascii, s] { s->addSaveFunc([special_chars_ascii, s] {
@ -492,7 +489,7 @@ void GuiMenu::openUIOptions()
}); });
// Enable quick list scrolling overlay. // Enable quick list scrolling overlay.
auto list_scroll_overlay = std::make_shared<SwitchComponent>(mWindow); auto list_scroll_overlay = std::make_shared<SwitchComponent>();
list_scroll_overlay->setState(Settings::getInstance()->getBool("ListScrollOverlay")); list_scroll_overlay->setState(Settings::getInstance()->getBool("ListScrollOverlay"));
s->addWithLabel("ENABLE QUICK LIST SCROLLING OVERLAY", list_scroll_overlay); s->addWithLabel("ENABLE QUICK LIST SCROLLING OVERLAY", list_scroll_overlay);
s->addSaveFunc([list_scroll_overlay, s] { s->addSaveFunc([list_scroll_overlay, s] {
@ -504,7 +501,7 @@ void GuiMenu::openUIOptions()
}); });
// Enable virtual (on-screen) keyboard. // Enable virtual (on-screen) keyboard.
auto virtual_keyboard = std::make_shared<SwitchComponent>(mWindow); auto virtual_keyboard = std::make_shared<SwitchComponent>();
virtual_keyboard->setState(Settings::getInstance()->getBool("VirtualKeyboard")); virtual_keyboard->setState(Settings::getInstance()->getBool("VirtualKeyboard"));
s->addWithLabel("ENABLE VIRTUAL KEYBOARD", virtual_keyboard); s->addWithLabel("ENABLE VIRTUAL KEYBOARD", virtual_keyboard);
s->addSaveFunc([virtual_keyboard, s] { s->addSaveFunc([virtual_keyboard, s] {
@ -516,7 +513,7 @@ void GuiMenu::openUIOptions()
}); });
// Enable menu scroll indicators. // Enable menu scroll indicators.
auto scroll_indicators = std::make_shared<SwitchComponent>(mWindow); auto scroll_indicators = std::make_shared<SwitchComponent>();
scroll_indicators->setState(Settings::getInstance()->getBool("ScrollIndicators")); scroll_indicators->setState(Settings::getInstance()->getBool("ScrollIndicators"));
s->addWithLabel("ENABLE MENU SCROLL INDICATORS", scroll_indicators); s->addWithLabel("ENABLE MENU SCROLL INDICATORS", scroll_indicators);
s->addSaveFunc([scroll_indicators, s] { s->addSaveFunc([scroll_indicators, s] {
@ -528,7 +525,7 @@ void GuiMenu::openUIOptions()
}); });
// Enable the 'Y' button for tagging games as favorites. // Enable the 'Y' button for tagging games as favorites.
auto favorites_add_button = std::make_shared<SwitchComponent>(mWindow); auto favorites_add_button = std::make_shared<SwitchComponent>();
favorites_add_button->setState(Settings::getInstance()->getBool("FavoritesAddButton")); favorites_add_button->setState(Settings::getInstance()->getBool("FavoritesAddButton"));
s->addWithLabel("ENABLE TOGGLE FAVORITES BUTTON", favorites_add_button); s->addWithLabel("ENABLE TOGGLE FAVORITES BUTTON", favorites_add_button);
s->addSaveFunc([favorites_add_button, s] { s->addSaveFunc([favorites_add_button, s] {
@ -541,7 +538,7 @@ void GuiMenu::openUIOptions()
}); });
// Enable the thumbstick click buttons for jumping to a random system or game. // Enable the thumbstick click buttons for jumping to a random system or game.
auto random_add_button = std::make_shared<SwitchComponent>(mWindow); auto random_add_button = std::make_shared<SwitchComponent>();
random_add_button->setState(Settings::getInstance()->getBool("RandomAddButton")); random_add_button->setState(Settings::getInstance()->getBool("RandomAddButton"));
s->addWithLabel("ENABLE RANDOM SYSTEM OR GAME BUTTON", random_add_button); s->addWithLabel("ENABLE RANDOM SYSTEM OR GAME BUTTON", random_add_button);
s->addSaveFunc([random_add_button, s] { s->addSaveFunc([random_add_button, s] {
@ -552,7 +549,7 @@ void GuiMenu::openUIOptions()
}); });
// Gamelist filters. // Gamelist filters.
auto gamelist_filters = std::make_shared<SwitchComponent>(mWindow); auto gamelist_filters = std::make_shared<SwitchComponent>();
gamelist_filters->setState(Settings::getInstance()->getBool("GamelistFilters")); gamelist_filters->setState(Settings::getInstance()->getBool("GamelistFilters"));
s->addWithLabel("ENABLE GAMELIST FILTERS", gamelist_filters); s->addWithLabel("ENABLE GAMELIST FILTERS", gamelist_filters);
s->addSaveFunc([gamelist_filters, s] { s->addSaveFunc([gamelist_filters, s] {
@ -564,7 +561,7 @@ void GuiMenu::openUIOptions()
}); });
// Quick system select (navigate left/right in gamelist view). // Quick system select (navigate left/right in gamelist view).
auto quick_system_select = std::make_shared<SwitchComponent>(mWindow); auto quick_system_select = std::make_shared<SwitchComponent>();
quick_system_select->setState(Settings::getInstance()->getBool("QuickSystemSelect")); quick_system_select->setState(Settings::getInstance()->getBool("QuickSystemSelect"));
s->addWithLabel("ENABLE QUICK SYSTEM SELECT", quick_system_select); s->addWithLabel("ENABLE QUICK SYSTEM SELECT", quick_system_select);
s->addSaveFunc([quick_system_select, s] { s->addSaveFunc([quick_system_select, s] {
@ -576,7 +573,7 @@ void GuiMenu::openUIOptions()
}); });
// On-screen help prompts. // On-screen help prompts.
auto show_help_prompts = std::make_shared<SwitchComponent>(mWindow); auto show_help_prompts = std::make_shared<SwitchComponent>();
show_help_prompts->setState(Settings::getInstance()->getBool("ShowHelpPrompts")); show_help_prompts->setState(Settings::getInstance()->getBool("ShowHelpPrompts"));
s->addWithLabel("DISPLAY ON-SCREEN HELP", show_help_prompts); s->addWithLabel("DISPLAY ON-SCREEN HELP", show_help_prompts);
s->addSaveFunc([show_help_prompts, s] { s->addSaveFunc([show_help_prompts, s] {
@ -587,7 +584,7 @@ void GuiMenu::openUIOptions()
}); });
// Play videos immediately (overrides theme setting). // Play videos immediately (overrides theme setting).
auto play_videos_immediately = std::make_shared<SwitchComponent>(mWindow); auto play_videos_immediately = std::make_shared<SwitchComponent>();
play_videos_immediately->setState(Settings::getInstance()->getBool("PlayVideosImmediately")); play_videos_immediately->setState(Settings::getInstance()->getBool("PlayVideosImmediately"));
s->addWithLabel("PLAY VIDEOS IMMEDIATELY (OVERRIDE THEME)", play_videos_immediately); s->addWithLabel("PLAY VIDEOS IMMEDIATELY (OVERRIDE THEME)", play_videos_immediately);
s->addSaveFunc([play_videos_immediately, s] { s->addSaveFunc([play_videos_immediately, s] {
@ -605,7 +602,7 @@ void GuiMenu::openUIOptions()
void GuiMenu::openSoundOptions() void GuiMenu::openSoundOptions()
{ {
auto s = new GuiSettings(mWindow, "SOUND SETTINGS"); auto s = new GuiSettings("SOUND SETTINGS");
// TODO: Hide the volume slider on macOS and BSD Unix until the volume control logic has been // TODO: Hide the volume slider on macOS and BSD Unix until the volume control logic has been
// implemented for these operating systems. // implemented for these operating systems.
@ -618,7 +615,7 @@ void GuiMenu::openSoundOptions()
VolumeControl volumeControl; VolumeControl volumeControl;
int currentVolume = volumeControl.getVolume(); int currentVolume = volumeControl.getVolume();
auto systemVolume = std::make_shared<SliderComponent>(mWindow, 0.f, 100.f, 1.f, "%"); auto systemVolume = std::make_shared<SliderComponent>(0.f, 100.f, 1.f, "%");
systemVolume->setValue(static_cast<float>(currentVolume)); systemVolume->setValue(static_cast<float>(currentVolume));
s->addWithLabel("SYSTEM VOLUME", systemVolume); s->addWithLabel("SYSTEM VOLUME", systemVolume);
s->addSaveFunc([systemVolume, currentVolume] { s->addSaveFunc([systemVolume, currentVolume] {
@ -631,7 +628,7 @@ void GuiMenu::openSoundOptions()
#endif #endif
// Volume for navigation sounds. // Volume for navigation sounds.
auto sound_volume_navigation = std::make_shared<SliderComponent>(mWindow, 0.f, 100.f, 1.f, "%"); auto sound_volume_navigation = std::make_shared<SliderComponent>(0.f, 100.f, 1.f, "%");
sound_volume_navigation->setValue( sound_volume_navigation->setValue(
static_cast<float>(Settings::getInstance()->getInt("SoundVolumeNavigation"))); static_cast<float>(Settings::getInstance()->getInt("SoundVolumeNavigation")));
s->addWithLabel("NAVIGATION SOUNDS VOLUME", sound_volume_navigation); s->addWithLabel("NAVIGATION SOUNDS VOLUME", sound_volume_navigation);
@ -645,7 +642,7 @@ void GuiMenu::openSoundOptions()
}); });
// Volume for videos. // Volume for videos.
auto sound_volume_videos = std::make_shared<SliderComponent>(mWindow, 0.f, 100.f, 1.f, "%"); auto sound_volume_videos = std::make_shared<SliderComponent>(0.f, 100.f, 1.f, "%");
sound_volume_videos->setValue( sound_volume_videos->setValue(
static_cast<float>(Settings::getInstance()->getInt("SoundVolumeVideos"))); static_cast<float>(Settings::getInstance()->getInt("SoundVolumeVideos")));
s->addWithLabel("VIDEO PLAYER VOLUME", sound_volume_videos); s->addWithLabel("VIDEO PLAYER VOLUME", sound_volume_videos);
@ -660,7 +657,7 @@ void GuiMenu::openSoundOptions()
if (UIModeController::getInstance()->isUIModeFull()) { if (UIModeController::getInstance()->isUIModeFull()) {
// Play audio for gamelist videos. // Play audio for gamelist videos.
auto gamelist_video_audio = std::make_shared<SwitchComponent>(mWindow); auto gamelist_video_audio = std::make_shared<SwitchComponent>();
gamelist_video_audio->setState(Settings::getInstance()->getBool("GamelistVideoAudio")); gamelist_video_audio->setState(Settings::getInstance()->getBool("GamelistVideoAudio"));
s->addWithLabel("PLAY AUDIO FOR VIDEOS IN THE GAMELIST VIEW", gamelist_video_audio); s->addWithLabel("PLAY AUDIO FOR VIDEOS IN THE GAMELIST VIEW", gamelist_video_audio);
s->addSaveFunc([gamelist_video_audio, s] { s->addSaveFunc([gamelist_video_audio, s] {
@ -673,7 +670,7 @@ void GuiMenu::openSoundOptions()
}); });
// Play audio for media viewer videos. // Play audio for media viewer videos.
auto media_viewer_video_audio = std::make_shared<SwitchComponent>(mWindow); auto media_viewer_video_audio = std::make_shared<SwitchComponent>();
media_viewer_video_audio->setState( media_viewer_video_audio->setState(
Settings::getInstance()->getBool("MediaViewerVideoAudio")); Settings::getInstance()->getBool("MediaViewerVideoAudio"));
s->addWithLabel("PLAY AUDIO FOR MEDIA VIEWER VIDEOS", media_viewer_video_audio); s->addWithLabel("PLAY AUDIO FOR MEDIA VIEWER VIDEOS", media_viewer_video_audio);
@ -687,7 +684,7 @@ void GuiMenu::openSoundOptions()
}); });
// Play audio for screensaver videos. // Play audio for screensaver videos.
auto screensaver_video_audio = std::make_shared<SwitchComponent>(mWindow); auto screensaver_video_audio = std::make_shared<SwitchComponent>();
screensaver_video_audio->setState( screensaver_video_audio->setState(
Settings::getInstance()->getBool("ScreensaverVideoAudio")); Settings::getInstance()->getBool("ScreensaverVideoAudio"));
s->addWithLabel("PLAY AUDIO FOR SCREENSAVER VIDEOS", screensaver_video_audio); s->addWithLabel("PLAY AUDIO FOR SCREENSAVER VIDEOS", screensaver_video_audio);
@ -701,7 +698,7 @@ void GuiMenu::openSoundOptions()
}); });
// Navigation sounds. // Navigation sounds.
auto navigation_sounds = std::make_shared<SwitchComponent>(mWindow); auto navigation_sounds = std::make_shared<SwitchComponent>();
navigation_sounds->setState(Settings::getInstance()->getBool("NavigationSounds")); navigation_sounds->setState(Settings::getInstance()->getBool("NavigationSounds"));
s->addWithLabel("ENABLE NAVIGATION SOUNDS", navigation_sounds); s->addWithLabel("ENABLE NAVIGATION SOUNDS", navigation_sounds);
s->addSaveFunc([navigation_sounds, s] { s->addSaveFunc([navigation_sounds, s] {
@ -719,11 +716,11 @@ void GuiMenu::openSoundOptions()
void GuiMenu::openInputDeviceOptions() void GuiMenu::openInputDeviceOptions()
{ {
auto s = new GuiSettings(mWindow, "INPUT DEVICE SETTINGS"); auto s = new GuiSettings("INPUT DEVICE SETTINGS");
// Controller type. // Controller type.
auto input_controller_type = std::make_shared<OptionListComponent<std::string>>( auto input_controller_type = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "CONTROLLER TYPE", false); getHelpStyle(), "CONTROLLER TYPE", false);
std::string selectedPlayer = Settings::getInstance()->getString("InputControllerType"); std::string selectedPlayer = Settings::getInstance()->getString("InputControllerType");
input_controller_type->add("XBOX", "xbox", selectedPlayer == "xbox"); input_controller_type->add("XBOX", "xbox", selectedPlayer == "xbox");
input_controller_type->add("XBOX 360", "xbox360", selectedPlayer == "xbox360"); input_controller_type->add("XBOX 360", "xbox360", selectedPlayer == "xbox360");
@ -746,7 +743,7 @@ void GuiMenu::openInputDeviceOptions()
}); });
// Whether to only accept input from the first controller. // Whether to only accept input from the first controller.
auto input_only_first_controller = std::make_shared<SwitchComponent>(mWindow); auto input_only_first_controller = std::make_shared<SwitchComponent>();
input_only_first_controller->setState( input_only_first_controller->setState(
Settings::getInstance()->getBool("InputOnlyFirstController")); Settings::getInstance()->getBool("InputOnlyFirstController"));
s->addWithLabel("ONLY ACCEPT INPUT FROM FIRST CONTROLLER", input_only_first_controller); s->addWithLabel("ONLY ACCEPT INPUT FROM FIRST CONTROLLER", input_only_first_controller);
@ -763,10 +760,10 @@ void GuiMenu::openInputDeviceOptions()
ComponentListRow configure_input_row; ComponentListRow configure_input_row;
configure_input_row.elements.clear(); configure_input_row.elements.clear();
configure_input_row.addElement( configure_input_row.addElement(
std::make_shared<TextComponent>(mWindow, "CONFIGURE KEYBOARD AND CONTROLLERS", std::make_shared<TextComponent>("CONFIGURE KEYBOARD AND CONTROLLERS",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF), Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
true); true);
configure_input_row.addElement(makeArrow(mWindow), false); configure_input_row.addElement(makeArrow(), false);
configure_input_row.makeAcceptInputHandler(std::bind(&GuiMenu::openConfigInput, this, s)); configure_input_row.makeAcceptInputHandler(std::bind(&GuiMenu::openConfigInput, this, s));
s->addRow(configure_input_row); s->addRow(configure_input_row);
@ -789,34 +786,33 @@ void GuiMenu::openConfigInput(GuiSettings* settings)
"(THIS WILL NOT AFFECT THE HELP PROMPTS)\n" "(THIS WILL NOT AFFECT THE HELP PROMPTS)\n"
"CONTINUE?"; "CONTINUE?";
Window* window = mWindow; Window* window {mWindow};
window->pushGui(new GuiMsgBox( window->pushGui(new GuiMsgBox(
window, getHelpStyle(), message, "YES", getHelpStyle(), message, "YES",
[window] { window->pushGui(new GuiDetectDevice(window, false, false, nullptr)); }, "NO", [window] { window->pushGui(new GuiDetectDevice(false, false, nullptr)); }, "NO", nullptr));
nullptr));
} }
void GuiMenu::openOtherOptions() void GuiMenu::openOtherOptions()
{ {
auto s = new GuiSettings(mWindow, "OTHER SETTINGS"); auto s = new GuiSettings("OTHER SETTINGS");
// Alternative emulators GUI. // Alternative emulators GUI.
ComponentListRow alternativeEmulatorsRow; ComponentListRow alternativeEmulatorsRow;
alternativeEmulatorsRow.elements.clear(); alternativeEmulatorsRow.elements.clear();
alternativeEmulatorsRow.addElement( alternativeEmulatorsRow.addElement(std::make_shared<TextComponent>("ALTERNATIVE EMULATORS",
std::make_shared<TextComponent>(mWindow, "ALTERNATIVE EMULATORS", Font::get(FONT_SIZE_MEDIUM),
Font::get(FONT_SIZE_MEDIUM), 0x777777FF), 0x777777FF),
true); true);
alternativeEmulatorsRow.addElement(makeArrow(mWindow), false); alternativeEmulatorsRow.addElement(makeArrow(), false);
alternativeEmulatorsRow.makeAcceptInputHandler( alternativeEmulatorsRow.makeAcceptInputHandler(
std::bind([this] { mWindow->pushGui(new GuiAlternativeEmulators(mWindow)); })); std::bind([this] { mWindow->pushGui(new GuiAlternativeEmulators); }));
s->addRow(alternativeEmulatorsRow); s->addRow(alternativeEmulatorsRow);
// Game media directory. // Game media directory.
ComponentListRow rowMediaDir; ComponentListRow rowMediaDir;
auto media_directory = std::make_shared<TextComponent>(mWindow, "GAME MEDIA DIRECTORY", auto media_directory = std::make_shared<TextComponent>("GAME MEDIA DIRECTORY",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF); Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
auto bracketMediaDirectory = std::make_shared<ImageComponent>(mWindow); auto bracketMediaDirectory = std::make_shared<ImageComponent>();
bracketMediaDirectory->setImage(":/graphics/arrow.svg"); bracketMediaDirectory->setImage(":/graphics/arrow.svg");
bracketMediaDirectory->setResize( bracketMediaDirectory->setResize(
glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
@ -838,23 +834,21 @@ void GuiMenu::openOtherOptions()
multiLineMediaDir] { multiLineMediaDir] {
if (Settings::getInstance()->getBool("VirtualKeyboard")) { if (Settings::getInstance()->getBool("VirtualKeyboard")) {
mWindow->pushGui(new GuiTextEditKeyboardPopup( mWindow->pushGui(new GuiTextEditKeyboardPopup(
mWindow, getHelpStyle(), titleMediaDir, getHelpStyle(), titleMediaDir, Settings::getInstance()->getString("MediaDirectory"),
Settings::getInstance()->getString("MediaDirectory"), updateValMediaDir, updateValMediaDir, multiLineMediaDir, "SAVE", "SAVE CHANGES?",
multiLineMediaDir, "SAVE", "SAVE CHANGES?", mediaDirectoryStaticText, mediaDirectoryStaticText, defaultDirectoryText, "load default directory"));
defaultDirectoryText, "load default directory"));
} }
else { else {
mWindow->pushGui(new GuiTextEditPopup( mWindow->pushGui(new GuiTextEditPopup(
mWindow, getHelpStyle(), titleMediaDir, getHelpStyle(), titleMediaDir, Settings::getInstance()->getString("MediaDirectory"),
Settings::getInstance()->getString("MediaDirectory"), updateValMediaDir, updateValMediaDir, multiLineMediaDir, "SAVE", "SAVE CHANGES?",
multiLineMediaDir, "SAVE", "SAVE CHANGES?", mediaDirectoryStaticText, mediaDirectoryStaticText, defaultDirectoryText, "load default directory"));
defaultDirectoryText, "load default directory"));
} }
}); });
s->addRow(rowMediaDir); s->addRow(rowMediaDir);
// Maximum VRAM. // Maximum VRAM.
auto max_vram = std::make_shared<SliderComponent>(mWindow, 80.f, 1024.f, 8.f, "MiB"); auto max_vram = std::make_shared<SliderComponent>(80.f, 1024.f, 8.f, "MiB");
max_vram->setValue(static_cast<float>(Settings::getInstance()->getInt("MaxVRAM"))); max_vram->setValue(static_cast<float>(Settings::getInstance()->getInt("MaxVRAM")));
s->addWithLabel("VRAM LIMIT", max_vram); s->addWithLabel("VRAM LIMIT", max_vram);
s->addSaveFunc([max_vram, s] { s->addSaveFunc([max_vram, s] {
@ -867,7 +861,7 @@ void GuiMenu::openOtherOptions()
// Display/monitor. // Display/monitor.
auto display_index = std::make_shared<OptionListComponent<std::string>>( auto display_index = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "DISPLAY/MONITOR INDEX", false); getHelpStyle(), "DISPLAY/MONITOR INDEX", false);
std::vector<std::string> displayIndex; std::vector<std::string> displayIndex;
displayIndex.push_back("1"); displayIndex.push_back("1");
displayIndex.push_back("2"); displayIndex.push_back("2");
@ -888,7 +882,7 @@ void GuiMenu::openOtherOptions()
// Exit button configuration. // Exit button configuration.
auto exit_button_config = std::make_shared<OptionListComponent<std::string>>( auto exit_button_config = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "EXIT BUTTON COMBO", false); getHelpStyle(), "EXIT BUTTON COMBO", false);
std::string selectedExitButtonCombo = Settings::getInstance()->getString("ExitButtonCombo"); std::string selectedExitButtonCombo = Settings::getInstance()->getString("ExitButtonCombo");
exit_button_config->add("F4", "F4", selectedExitButtonCombo == "F4"); exit_button_config->add("F4", "F4", selectedExitButtonCombo == "F4");
exit_button_config->add("Alt + F4", "AltF4", selectedExitButtonCombo == "AltF4"); exit_button_config->add("Alt + F4", "AltF4", selectedExitButtonCombo == "AltF4");
@ -910,7 +904,7 @@ void GuiMenu::openOtherOptions()
// When to save game metadata. // When to save game metadata.
auto save_gamelist_mode = std::make_shared<OptionListComponent<std::string>>( auto save_gamelist_mode = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "WHEN TO SAVE METADATA", false); getHelpStyle(), "WHEN TO SAVE METADATA", false);
std::vector<std::string> saveModes; std::vector<std::string> saveModes;
saveModes.push_back("on exit"); saveModes.push_back("on exit");
saveModes.push_back("always"); saveModes.push_back("always");
@ -938,7 +932,7 @@ void GuiMenu::openOtherOptions()
#if defined(_WIN64) #if defined(_WIN64)
// Hide taskbar during the program session. // Hide taskbar during the program session.
auto hide_taskbar = std::make_shared<SwitchComponent>(mWindow); auto hide_taskbar = std::make_shared<SwitchComponent>();
hide_taskbar->setState(Settings::getInstance()->getBool("HideTaskbar")); hide_taskbar->setState(Settings::getInstance()->getBool("HideTaskbar"));
s->addWithLabel("HIDE TASKBAR (REQUIRES RESTART)", hide_taskbar); s->addWithLabel("HIDE TASKBAR (REQUIRES RESTART)", hide_taskbar);
s->addSaveFunc([hide_taskbar, s] { s->addSaveFunc([hide_taskbar, s] {
@ -950,7 +944,7 @@ void GuiMenu::openOtherOptions()
#endif #endif
// Run ES in the background when a game has been launched. // Run ES in the background when a game has been launched.
auto run_in_background = std::make_shared<SwitchComponent>(mWindow); auto run_in_background = std::make_shared<SwitchComponent>();
run_in_background->setState(Settings::getInstance()->getBool("RunInBackground")); run_in_background->setState(Settings::getInstance()->getBool("RunInBackground"));
s->addWithLabel("RUN IN BACKGROUND (WHILE GAME IS LAUNCHED)", run_in_background); s->addWithLabel("RUN IN BACKGROUND (WHILE GAME IS LAUNCHED)", run_in_background);
s->addSaveFunc([run_in_background, s] { s->addSaveFunc([run_in_background, s] {
@ -962,7 +956,7 @@ void GuiMenu::openOtherOptions()
#if defined(VIDEO_HW_DECODING) #if defined(VIDEO_HW_DECODING)
// Whether to enable hardware decoding for the FFmpeg video player. // Whether to enable hardware decoding for the FFmpeg video player.
auto video_hardware_decoding = std::make_shared<SwitchComponent>(mWindow); auto video_hardware_decoding = std::make_shared<SwitchComponent>();
video_hardware_decoding->setState(Settings::getInstance()->getBool("VideoHardwareDecoding")); video_hardware_decoding->setState(Settings::getInstance()->getBool("VideoHardwareDecoding"));
s->addWithLabel("VIDEO HARDWARE DECODING (EXPERIMENTAL)", video_hardware_decoding); s->addWithLabel("VIDEO HARDWARE DECODING (EXPERIMENTAL)", video_hardware_decoding);
s->addSaveFunc([video_hardware_decoding, s] { s->addSaveFunc([video_hardware_decoding, s] {
@ -976,7 +970,7 @@ void GuiMenu::openOtherOptions()
#endif #endif
// Whether to upscale the video frame rate to 60 FPS. // Whether to upscale the video frame rate to 60 FPS.
auto video_upscale_frame_rate = std::make_shared<SwitchComponent>(mWindow); auto video_upscale_frame_rate = std::make_shared<SwitchComponent>();
video_upscale_frame_rate->setState(Settings::getInstance()->getBool("VideoUpscaleFrameRate")); video_upscale_frame_rate->setState(Settings::getInstance()->getBool("VideoUpscaleFrameRate"));
s->addWithLabel("UPSCALE VIDEO FRAME RATE TO 60 FPS", video_upscale_frame_rate); s->addWithLabel("UPSCALE VIDEO FRAME RATE TO 60 FPS", video_upscale_frame_rate);
s->addSaveFunc([video_upscale_frame_rate, s] { s->addSaveFunc([video_upscale_frame_rate, s] {
@ -989,7 +983,7 @@ void GuiMenu::openOtherOptions()
}); });
// Whether to preload the gamelists on application startup. // Whether to preload the gamelists on application startup.
auto preloadGamelists = std::make_shared<SwitchComponent>(mWindow); auto preloadGamelists = std::make_shared<SwitchComponent>();
preloadGamelists->setState(Settings::getInstance()->getBool("PreloadGamelists")); preloadGamelists->setState(Settings::getInstance()->getBool("PreloadGamelists"));
s->addWithLabel("PRELOAD GAMELISTS ON STARTUP", preloadGamelists); s->addWithLabel("PRELOAD GAMELISTS ON STARTUP", preloadGamelists);
s->addSaveFunc([preloadGamelists, s] { s->addSaveFunc([preloadGamelists, s] {
@ -1001,7 +995,7 @@ void GuiMenu::openOtherOptions()
// Whether to enable alternative emulators per game (the option to disable this is intended // Whether to enable alternative emulators per game (the option to disable this is intended
// primarily for testing purposes). // primarily for testing purposes).
auto alternativeEmulatorPerGame = std::make_shared<SwitchComponent>(mWindow); auto alternativeEmulatorPerGame = std::make_shared<SwitchComponent>();
alternativeEmulatorPerGame->setState( alternativeEmulatorPerGame->setState(
Settings::getInstance()->getBool("AlternativeEmulatorPerGame")); Settings::getInstance()->getBool("AlternativeEmulatorPerGame"));
s->addWithLabel("ENABLE ALTERNATIVE EMULATORS PER GAME", alternativeEmulatorPerGame); s->addWithLabel("ENABLE ALTERNATIVE EMULATORS PER GAME", alternativeEmulatorPerGame);
@ -1017,7 +1011,7 @@ void GuiMenu::openOtherOptions()
}); });
// Show hidden files. // Show hidden files.
auto show_hidden_files = std::make_shared<SwitchComponent>(mWindow); auto show_hidden_files = std::make_shared<SwitchComponent>();
show_hidden_files->setState(Settings::getInstance()->getBool("ShowHiddenFiles")); show_hidden_files->setState(Settings::getInstance()->getBool("ShowHiddenFiles"));
s->addWithLabel("SHOW HIDDEN FILES AND FOLDERS (REQUIRES RESTART)", show_hidden_files); s->addWithLabel("SHOW HIDDEN FILES AND FOLDERS (REQUIRES RESTART)", show_hidden_files);
s->addSaveFunc([show_hidden_files, s] { s->addSaveFunc([show_hidden_files, s] {
@ -1028,7 +1022,7 @@ void GuiMenu::openOtherOptions()
}); });
// Show hidden games. // Show hidden games.
auto show_hidden_games = std::make_shared<SwitchComponent>(mWindow); auto show_hidden_games = std::make_shared<SwitchComponent>();
show_hidden_games->setState(Settings::getInstance()->getBool("ShowHiddenGames")); show_hidden_games->setState(Settings::getInstance()->getBool("ShowHiddenGames"));
s->addWithLabel("SHOW HIDDEN GAMES (REQUIRES RESTART)", show_hidden_games); s->addWithLabel("SHOW HIDDEN GAMES (REQUIRES RESTART)", show_hidden_games);
s->addSaveFunc([show_hidden_games, s] { s->addSaveFunc([show_hidden_games, s] {
@ -1039,7 +1033,7 @@ void GuiMenu::openOtherOptions()
}); });
// Custom event scripts, fired using Scripting::fireEvent(). // Custom event scripts, fired using Scripting::fireEvent().
auto custom_eventscripts = std::make_shared<SwitchComponent>(mWindow); auto custom_eventscripts = std::make_shared<SwitchComponent>();
custom_eventscripts->setState(Settings::getInstance()->getBool("CustomEventScripts")); custom_eventscripts->setState(Settings::getInstance()->getBool("CustomEventScripts"));
s->addWithLabel("ENABLE CUSTOM EVENT SCRIPTS", custom_eventscripts); s->addWithLabel("ENABLE CUSTOM EVENT SCRIPTS", custom_eventscripts);
s->addSaveFunc([custom_eventscripts, s] { s->addSaveFunc([custom_eventscripts, s] {
@ -1051,7 +1045,7 @@ void GuiMenu::openOtherOptions()
}); });
// Only show ROMs included in the gamelist.xml files. // Only show ROMs included in the gamelist.xml files.
auto parse_gamelist_only = std::make_shared<SwitchComponent>(mWindow); auto parse_gamelist_only = std::make_shared<SwitchComponent>();
parse_gamelist_only->setState(Settings::getInstance()->getBool("ParseGamelistOnly")); parse_gamelist_only->setState(Settings::getInstance()->getBool("ParseGamelistOnly"));
s->addWithLabel("ONLY SHOW ROMS FROM GAMELIST.XML FILES", parse_gamelist_only); s->addWithLabel("ONLY SHOW ROMS FROM GAMELIST.XML FILES", parse_gamelist_only);
s->addSaveFunc([parse_gamelist_only, s] { s->addSaveFunc([parse_gamelist_only, s] {
@ -1064,7 +1058,7 @@ void GuiMenu::openOtherOptions()
#if defined(__unix__) #if defined(__unix__)
// Whether to disable desktop composition. // Whether to disable desktop composition.
auto disable_composition = std::make_shared<SwitchComponent>(mWindow); auto disable_composition = std::make_shared<SwitchComponent>();
disable_composition->setState(Settings::getInstance()->getBool("DisableComposition")); disable_composition->setState(Settings::getInstance()->getBool("DisableComposition"));
s->addWithLabel("DISABLE DESKTOP COMPOSITION (REQUIRES RESTART)", disable_composition); s->addWithLabel("DISABLE DESKTOP COMPOSITION (REQUIRES RESTART)", disable_composition);
s->addSaveFunc([disable_composition, s] { s->addSaveFunc([disable_composition, s] {
@ -1077,7 +1071,7 @@ void GuiMenu::openOtherOptions()
#endif #endif
// GPU statistics overlay. // GPU statistics overlay.
auto display_gpu_statistics = std::make_shared<SwitchComponent>(mWindow); auto display_gpu_statistics = std::make_shared<SwitchComponent>();
display_gpu_statistics->setState(Settings::getInstance()->getBool("DisplayGPUStatistics")); display_gpu_statistics->setState(Settings::getInstance()->getBool("DisplayGPUStatistics"));
s->addWithLabel("DISPLAY GPU STATISTICS OVERLAY", display_gpu_statistics); s->addWithLabel("DISPLAY GPU STATISTICS OVERLAY", display_gpu_statistics);
s->addSaveFunc([display_gpu_statistics, s] { s->addSaveFunc([display_gpu_statistics, s] {
@ -1090,7 +1084,7 @@ void GuiMenu::openOtherOptions()
}); });
// Whether to enable the menu in Kid mode. // Whether to enable the menu in Kid mode.
auto enable_menu_kid_mode = std::make_shared<SwitchComponent>(mWindow); auto enable_menu_kid_mode = std::make_shared<SwitchComponent>();
enable_menu_kid_mode->setState(Settings::getInstance()->getBool("EnableMenuKidMode")); enable_menu_kid_mode->setState(Settings::getInstance()->getBool("EnableMenuKidMode"));
s->addWithLabel("ENABLE MENU IN KID MODE", enable_menu_kid_mode); s->addWithLabel("ENABLE MENU IN KID MODE", enable_menu_kid_mode);
s->addSaveFunc([enable_menu_kid_mode, s] { s->addSaveFunc([enable_menu_kid_mode, s] {
@ -1105,7 +1099,7 @@ void GuiMenu::openOtherOptions()
// sense to enable this setting and menu entry for that operating system. // sense to enable this setting and menu entry for that operating system.
#if !defined(__APPLE__) #if !defined(__APPLE__)
// Whether to show the quit menu with the options to reboot and shutdown the computer. // Whether to show the quit menu with the options to reboot and shutdown the computer.
auto show_quit_menu = std::make_shared<SwitchComponent>(mWindow); auto show_quit_menu = std::make_shared<SwitchComponent>();
show_quit_menu->setState(Settings::getInstance()->getBool("ShowQuitMenu")); show_quit_menu->setState(Settings::getInstance()->getBool("ShowQuitMenu"));
s->addWithLabel("SHOW QUIT MENU (REBOOT AND POWER OFF ENTRIES)", show_quit_menu); s->addWithLabel("SHOW QUIT MENU (REBOOT AND POWER OFF ENTRIES)", show_quit_menu);
s->addSaveFunc([this, show_quit_menu, s] { s->addSaveFunc([this, show_quit_menu, s] {
@ -1123,7 +1117,7 @@ void GuiMenu::openOtherOptions()
void GuiMenu::openUtilitiesMenu() void GuiMenu::openUtilitiesMenu()
{ {
auto s = new GuiSettings(mWindow, "UTILITIES"); auto s = new GuiSettings("UTILITIES");
s->setSize(mSize); s->setSize(mSize);
mWindow->pushGui(s); mWindow->pushGui(s);
} }
@ -1132,7 +1126,7 @@ void GuiMenu::openQuitMenu()
{ {
if (!Settings::getInstance()->getBool("ShowQuitMenu")) { if (!Settings::getInstance()->getBool("ShowQuitMenu")) {
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
mWindow, this->getHelpStyle(), "REALLY QUIT?", "YES", this->getHelpStyle(), "REALLY QUIT?", "YES",
[this] { [this] {
Scripting::fireEvent("quit"); Scripting::fireEvent("quit");
close(true); close(true);
@ -1141,16 +1135,16 @@ void GuiMenu::openQuitMenu()
"NO", nullptr)); "NO", nullptr));
} }
else { else {
auto s = new GuiSettings(mWindow, "QUIT"); auto s = new GuiSettings("QUIT");
Window* window = mWindow; Window* window {mWindow};
HelpStyle style = getHelpStyle(); HelpStyle style = getHelpStyle();
ComponentListRow row; ComponentListRow row;
row.makeAcceptInputHandler([window, this] { row.makeAcceptInputHandler([window, this] {
window->pushGui(new GuiMsgBox( window->pushGui(new GuiMsgBox(
window, this->getHelpStyle(), "REALLY QUIT?", "YES", this->getHelpStyle(), "REALLY QUIT?", "YES",
[this] { [this] {
Scripting::fireEvent("quit"); Scripting::fireEvent("quit");
close(true); close(true);
@ -1158,7 +1152,7 @@ void GuiMenu::openQuitMenu()
}, },
"NO", nullptr)); "NO", nullptr));
}); });
auto quitText = std::make_shared<TextComponent>(window, "QUIT EMULATIONSTATION", auto quitText = std::make_shared<TextComponent>("QUIT EMULATIONSTATION",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF); Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
quitText->setSelectable(true); quitText->setSelectable(true);
row.addElement(quitText, true); row.addElement(quitText, true);
@ -1167,7 +1161,7 @@ void GuiMenu::openQuitMenu()
row.elements.clear(); row.elements.clear();
row.makeAcceptInputHandler([window, this] { row.makeAcceptInputHandler([window, this] {
window->pushGui(new GuiMsgBox( window->pushGui(new GuiMsgBox(
window, this->getHelpStyle(), "REALLY REBOOT?", "YES", this->getHelpStyle(), "REALLY REBOOT?", "YES",
[] { [] {
Scripting::fireEvent("quit", "reboot"); Scripting::fireEvent("quit", "reboot");
Scripting::fireEvent("reboot"); Scripting::fireEvent("reboot");
@ -1177,7 +1171,7 @@ void GuiMenu::openQuitMenu()
}, },
"NO", nullptr)); "NO", nullptr));
}); });
auto rebootText = std::make_shared<TextComponent>(window, "REBOOT SYSTEM", auto rebootText = std::make_shared<TextComponent>("REBOOT SYSTEM",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF); Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
rebootText->setSelectable(true); rebootText->setSelectable(true);
row.addElement(rebootText, true); row.addElement(rebootText, true);
@ -1186,7 +1180,7 @@ void GuiMenu::openQuitMenu()
row.elements.clear(); row.elements.clear();
row.makeAcceptInputHandler([window, this] { row.makeAcceptInputHandler([window, this] {
window->pushGui(new GuiMsgBox( window->pushGui(new GuiMsgBox(
window, this->getHelpStyle(), "REALLY POWER OFF?", "YES", this->getHelpStyle(), "REALLY POWER OFF?", "YES",
[] { [] {
Scripting::fireEvent("quit", "poweroff"); Scripting::fireEvent("quit", "poweroff");
Scripting::fireEvent("poweroff"); Scripting::fireEvent("poweroff");
@ -1197,7 +1191,7 @@ void GuiMenu::openQuitMenu()
"NO", nullptr)); "NO", nullptr));
}); });
auto powerOffText = std::make_shared<TextComponent>( auto powerOffText = std::make_shared<TextComponent>(
window, "POWER OFF SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); "POWER OFF SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
powerOffText->setSelectable(true); powerOffText->setSelectable(true);
row.addElement(powerOffText, true); row.addElement(powerOffText, true);
s->addRow(row); s->addRow(row);
@ -1218,17 +1212,17 @@ void GuiMenu::addVersionInfo()
void GuiMenu::openMediaViewerOptions() void GuiMenu::openMediaViewerOptions()
{ {
mWindow->pushGui(new GuiMediaViewerOptions(mWindow, "MEDIA VIEWER SETTINGS")); mWindow->pushGui(new GuiMediaViewerOptions("MEDIA VIEWER SETTINGS"));
} }
void GuiMenu::openScreensaverOptions() void GuiMenu::openScreensaverOptions()
{ {
mWindow->pushGui(new GuiScreensaverOptions(mWindow, "SCREENSAVER SETTINGS")); mWindow->pushGui(new GuiScreensaverOptions("SCREENSAVER SETTINGS"));
} }
void GuiMenu::openCollectionSystemOptions() void GuiMenu::openCollectionSystemOptions()
{ {
mWindow->pushGui(new GuiCollectionSystemsOptions(mWindow, "GAME COLLECTION SETTINGS")); mWindow->pushGui(new GuiCollectionSystemsOptions("GAME COLLECTION SETTINGS"));
} }
void GuiMenu::onSizeChanged() void GuiMenu::onSizeChanged()
@ -1246,10 +1240,10 @@ void GuiMenu::addEntry(const std::string& name,
// Populate the list. // Populate the list.
ComponentListRow row; ComponentListRow row;
row.addElement(std::make_shared<TextComponent>(mWindow, name, font, color), true); row.addElement(std::make_shared<TextComponent>(name, font, color), true);
if (add_arrow) { if (add_arrow) {
std::shared_ptr<ImageComponent> bracket = makeArrow(mWindow); std::shared_ptr<ImageComponent> bracket {makeArrow()};
row.addElement(bracket, false); row.addElement(bracket, false);
} }
@ -1264,7 +1258,7 @@ void GuiMenu::close(bool closeAllWindows)
closeFunc = [this] { delete this; }; closeFunc = [this] { delete this; };
} }
else { else {
Window* window = mWindow; Window* window {mWindow};
closeFunc = [window] { closeFunc = [window] {
while (window->peekGui() != ViewController::getInstance()) while (window->peekGui() != ViewController::getInstance())
delete window->peekGui(); delete window->peekGui();

View file

@ -17,7 +17,7 @@
class GuiMenu : public GuiComponent class GuiMenu : public GuiComponent
{ {
public: public:
GuiMenu(Window* window); GuiMenu();
~GuiMenu(); ~GuiMenu();
bool input(InputConfig* config, Input input) override; bool input(InputConfig* config, Input input) override;

View file

@ -34,16 +34,14 @@
#define TITLE_HEIGHT (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.060f) #define TITLE_HEIGHT (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.060f)
GuiMetaDataEd::GuiMetaDataEd(Window* window, GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
MetaDataList* md,
const std::vector<MetaDataDecl>& mdd, const std::vector<MetaDataDecl>& mdd,
ScraperSearchParams scraperParams, ScraperSearchParams scraperParams,
std::function<void()> saveCallback, std::function<void()> saveCallback,
std::function<void()> clearGameFunc, std::function<void()> clearGameFunc,
std::function<void()> deleteGameFunc) std::function<void()> deleteGameFunc)
: GuiComponent {window} : mBackground {":/graphics/frame.svg"}
, mBackground {window, ":/graphics/frame.svg"} , mGrid {glm::ivec2 {2, 6}}
, mGrid {window, glm::ivec2 {2, 6}}
, mScraperParams {scraperParams} , mScraperParams {scraperParams}
, mControllerBadges {BadgeComponent::getGameControllers()} , mControllerBadges {BadgeComponent::getGameControllers()}
, mMetaDataDecl {mdd} , mMetaDataDecl {mdd}
@ -68,7 +66,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
addChild(&mBackground); addChild(&mBackground);
addChild(&mGrid); addChild(&mGrid);
mTitle = std::make_shared<TextComponent>(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), mTitle = std::make_shared<TextComponent>("EDIT METADATA", Font::get(FONT_SIZE_LARGE),
0x555555FF, ALIGN_CENTER); 0x555555FF, ALIGN_CENTER);
mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2}); mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2});
@ -88,7 +86,6 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
} }
mSubtitle = std::make_shared<TextComponent>( mSubtitle = std::make_shared<TextComponent>(
mWindow,
folderPath + Utils::FileSystem::getFileName(scraperParams.game->getPath()) + " [" + folderPath + Utils::FileSystem::getFileName(scraperParams.game->getPath()) + " [" +
Utils::String::toUpper(scraperParams.system->getName()) + "]" + Utils::String::toUpper(scraperParams.system->getName()) + "]" +
(scraperParams.game->getType() == FOLDER ? " " + ViewController::FOLDER_CHAR : ""), (scraperParams.game->getType() == FOLDER ? " " + ViewController::FOLDER_CHAR : ""),
@ -96,12 +93,12 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
mGrid.setEntry(mSubtitle, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1}); mGrid.setEntry(mSubtitle, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1});
mList = std::make_shared<ComponentList>(mWindow); mList = std::make_shared<ComponentList>();
mGrid.setEntry(mList, glm::ivec2 {0, 4}, true, true, glm::ivec2 {2, 1}); mGrid.setEntry(mList, glm::ivec2 {0, 4}, true, true, glm::ivec2 {2, 1});
// Set up scroll indicators. // Set up scroll indicators.
mScrollUp = std::make_shared<ImageComponent>(mWindow); mScrollUp = std::make_shared<ImageComponent>();
mScrollDown = std::make_shared<ImageComponent>(mWindow); mScrollDown = std::make_shared<ImageComponent>();
mScrollIndicator = std::make_shared<ScrollIndicatorComponent>(mList, mScrollUp, mScrollDown); mScrollIndicator = std::make_shared<ScrollIndicatorComponent>(mList, mScrollUp, mScrollDown);
mScrollUp->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f); mScrollUp->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f);
@ -132,8 +129,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
// Don't show the alternative emulator entry if the corresponding option has been disabled. // Don't show the alternative emulator entry if the corresponding option has been disabled.
if (!Settings::getInstance()->getBool("AlternativeEmulatorPerGame") && if (!Settings::getInstance()->getBool("AlternativeEmulatorPerGame") &&
it->type == MD_ALT_EMULATOR) { it->type == MD_ALT_EMULATOR) {
ed = std::make_shared<TextComponent>( ed = std::make_shared<TextComponent>("", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT),
window, "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT); 0x777777FF, ALIGN_RIGHT);
assert(ed); assert(ed);
ed->setValue(mMetaData->get(it->key)); ed->setValue(mMetaData->get(it->key));
mEditors.push_back(ed); mEditors.push_back(ed);
@ -144,13 +141,13 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
// entry instead of for instance the spacer. That is so because ComponentList // entry instead of for instance the spacer. That is so because ComponentList
// always looks for the help prompt at the back of the element stack. // always looks for the help prompt at the back of the element stack.
ComponentListRow row; ComponentListRow row;
auto lbl = std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(it->displayName), auto lbl = std::make_shared<TextComponent>(Utils::String::toUpper(it->displayName),
Font::get(FONT_SIZE_SMALL), 0x777777FF); Font::get(FONT_SIZE_SMALL), 0x777777FF);
row.addElement(lbl, true); // Label. row.addElement(lbl, true); // Label.
switch (it->type) { switch (it->type) {
case MD_BOOL: { case MD_BOOL: {
ed = std::make_shared<SwitchComponent>(window); ed = std::make_shared<SwitchComponent>();
// Make the switches slightly smaller. // Make the switches slightly smaller.
glm::vec2 switchSize {ed->getSize() * 0.9f}; glm::vec2 switchSize {ed->getSize() * 0.9f};
ed->setResize(ceilf(switchSize.x), switchSize.y); ed->setResize(ceilf(switchSize.x), switchSize.y);
@ -160,11 +157,11 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
break; break;
} }
case MD_RATING: { case MD_RATING: {
auto spacer = std::make_shared<GuiComponent>(mWindow); auto spacer = std::make_shared<GuiComponent>();
spacer->setSize(Renderer::getScreenWidth() * 0.0025f, 0.0f); spacer->setSize(Renderer::getScreenWidth() * 0.0025f, 0.0f);
row.addElement(spacer, false); row.addElement(spacer, false);
ed = std::make_shared<RatingComponent>(window, true); ed = std::make_shared<RatingComponent>(true);
ed->setChangedColor(ICONCOLOR_USERMARKED); ed->setChangedColor(ICONCOLOR_USERMARKED);
const float height = lbl->getSize().y * 0.71f; const float height = lbl->getSize().y * 0.71f;
ed->setSize(0.0f, height); ed->setSize(0.0f, height);
@ -176,11 +173,11 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
break; break;
} }
case MD_DATE: { case MD_DATE: {
auto spacer = std::make_shared<GuiComponent>(mWindow); auto spacer = std::make_shared<GuiComponent>();
spacer->setSize(Renderer::getScreenWidth() * 0.0025f, 0.0f); spacer->setSize(Renderer::getScreenWidth() * 0.0025f, 0.0f);
row.addElement(spacer, false); row.addElement(spacer, false);
ed = std::make_shared<DateTimeEditComponent>(window, true); ed = std::make_shared<DateTimeEditComponent>(true);
ed->setOriginalColor(DEFAULT_TEXTCOLOR); ed->setOriginalColor(DEFAULT_TEXTCOLOR);
ed->setChangedColor(TEXTCOLOR_USERMARKED); ed->setChangedColor(TEXTCOLOR_USERMARKED);
row.addElement(ed, false); row.addElement(ed, false);
@ -191,16 +188,15 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
break; break;
} }
case MD_CONTROLLER: { case MD_CONTROLLER: {
ed = std::make_shared<TextComponent>(window, "", ed = std::make_shared<TextComponent>(
Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT);
0x777777FF, ALIGN_RIGHT);
row.addElement(ed, true); row.addElement(ed, true);
auto spacer = std::make_shared<GuiComponent>(mWindow); auto spacer = std::make_shared<GuiComponent>();
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f); spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f);
row.addElement(spacer, false); row.addElement(spacer, false);
auto bracket = std::make_shared<ImageComponent>(mWindow); auto bracket = std::make_shared<ImageComponent>();
bracket->setImage(":/graphics/arrow.svg"); bracket->setImage(":/graphics/arrow.svg");
bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()});
row.addElement(bracket, false); row.addElement(bracket, false);
@ -217,7 +213,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
}; };
row.makeAcceptInputHandler([this, title, ed, updateVal] { row.makeAcceptInputHandler([this, title, ed, updateVal] {
GuiSettings* s = new GuiSettings(mWindow, title); GuiSettings* s = new GuiSettings(title);
for (auto controller : mControllerBadges) { for (auto controller : mControllerBadges) {
std::string selectedLabel = ed->getValue(); std::string selectedLabel = ed->getValue();
@ -225,7 +221,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
ComponentListRow row; ComponentListRow row;
std::shared_ptr<TextComponent> labelText = std::make_shared<TextComponent>( std::shared_ptr<TextComponent> labelText = std::make_shared<TextComponent>(
mWindow, label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF); label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
labelText->setSelectable(true); labelText->setSelectable(true);
labelText->setValue(controller.displayName); labelText->setValue(controller.displayName);
@ -249,7 +245,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
if (ed->getValue() != "") { if (ed->getValue() != "") {
ComponentListRow row; ComponentListRow row;
std::shared_ptr<TextComponent> clearText = std::make_shared<TextComponent>( std::shared_ptr<TextComponent> clearText = std::make_shared<TextComponent>(
mWindow, ViewController::CROSSEDCIRCLE_CHAR + " CLEAR ENTRY", ViewController::CROSSEDCIRCLE_CHAR + " CLEAR ENTRY",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF); Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
clearText->setSelectable(true); clearText->setSelectable(true);
row.addElement(clearText, true); row.addElement(clearText, true);
@ -275,16 +271,15 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
case MD_ALT_EMULATOR: { case MD_ALT_EMULATOR: {
mInvalidEmulatorEntry = false; mInvalidEmulatorEntry = false;
ed = std::make_shared<TextComponent>(window, "", ed = std::make_shared<TextComponent>(
Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT);
0x777777FF, ALIGN_RIGHT);
row.addElement(ed, true); row.addElement(ed, true);
auto spacer = std::make_shared<GuiComponent>(mWindow); auto spacer = std::make_shared<GuiComponent>();
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f); spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f);
row.addElement(spacer, false); row.addElement(spacer, false);
auto bracket = std::make_shared<ImageComponent>(mWindow); auto bracket = std::make_shared<ImageComponent>();
bracket->setImage(":/graphics/arrow.svg"); bracket->setImage(":/graphics/arrow.svg");
bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()});
row.addElement(bracket, false); row.addElement(bracket, false);
@ -326,9 +321,9 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
scraperParams.system->getSystemEnvData()->mLaunchCommands.size() == 1; scraperParams.system->getSystemEnvData()->mLaunchCommands.size() == 1;
if (mInvalidEmulatorEntry && singleEntry) if (mInvalidEmulatorEntry && singleEntry)
s = new GuiSettings(mWindow, "CLEAR INVALID ENTRY"); s = new GuiSettings("CLEAR INVALID ENTRY");
else else
s = new GuiSettings(mWindow, title); s = new GuiSettings(title);
if (!mInvalidEmulatorEntry && ed->getValue() == "" && singleEntry) if (!mInvalidEmulatorEntry && ed->getValue() == "" && singleEntry)
return; return;
@ -359,8 +354,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
label = entry.second; label = entry.second;
std::shared_ptr<TextComponent> labelText = std::shared_ptr<TextComponent> labelText =
std::make_shared<TextComponent>( std::make_shared<TextComponent>(label, Font::get(FONT_SIZE_MEDIUM),
mWindow, label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF); 0x777777FF);
labelText->setSelectable(true); labelText->setSelectable(true);
if (scraperParams.system->getAlternativeEmulator() == "" && if (scraperParams.system->getAlternativeEmulator() == "" &&
@ -413,16 +408,15 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
case MD_MULTILINE_STRING: case MD_MULTILINE_STRING:
default: { default: {
// MD_STRING. // MD_STRING.
ed = std::make_shared<TextComponent>(window, "", ed = std::make_shared<TextComponent>(
Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT);
0x777777FF, ALIGN_RIGHT);
row.addElement(ed, true); row.addElement(ed, true);
auto spacer = std::make_shared<GuiComponent>(mWindow); auto spacer = std::make_shared<GuiComponent>();
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f); spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f);
row.addElement(spacer, false); row.addElement(spacer, false);
auto bracket = std::make_shared<ImageComponent>(mWindow); auto bracket = std::make_shared<ImageComponent>();
bracket->setImage(":/graphics/arrow.svg"); bracket->setImage(":/graphics/arrow.svg");
bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()});
row.addElement(bracket, false); row.addElement(bracket, false);
@ -477,15 +471,15 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
if (Settings::getInstance()->getBool("VirtualKeyboard")) { if (Settings::getInstance()->getBool("VirtualKeyboard")) {
row.makeAcceptInputHandler([this, title, ed, updateVal, multiLine] { row.makeAcceptInputHandler([this, title, ed, updateVal, multiLine] {
mWindow->pushGui(new GuiTextEditKeyboardPopup( mWindow->pushGui(new GuiTextEditKeyboardPopup(
mWindow, getHelpStyle(), title, ed->getValue(), updateVal, multiLine, getHelpStyle(), title, ed->getValue(), updateVal, multiLine, "apply",
"apply", "APPLY CHANGES?", "", "")); "APPLY CHANGES?", "", ""));
}); });
} }
else { else {
row.makeAcceptInputHandler([this, title, ed, updateVal, multiLine] { row.makeAcceptInputHandler([this, title, ed, updateVal, multiLine] {
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), title, mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), title, ed->getValue(),
ed->getValue(), updateVal, multiLine, updateVal, multiLine, "APPLY",
"APPLY", "APPLY CHANGES?")); "APPLY CHANGES?"));
}); });
} }
break; break;
@ -516,15 +510,15 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
if (!scraperParams.system->hasPlatformId(PlatformIds::PLATFORM_IGNORE)) if (!scraperParams.system->hasPlatformId(PlatformIds::PLATFORM_IGNORE))
buttons.push_back(std::make_shared<ButtonComponent>( buttons.push_back(std::make_shared<ButtonComponent>(
mWindow, "SCRAPE", "scrape", std::bind(&GuiMetaDataEd::fetch, this))); "SCRAPE", "scrape", std::bind(&GuiMetaDataEd::fetch, this)));
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "SAVE", "save metadata", [&] { buttons.push_back(std::make_shared<ButtonComponent>("SAVE", "save metadata", [&] {
save(); save();
ViewController::getInstance()->onPauseVideo(); ViewController::getInstance()->onPauseVideo();
delete this; delete this;
})); }));
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CANCEL", "cancel changes", buttons.push_back(
[&] { delete this; })); std::make_shared<ButtonComponent>("CANCEL", "cancel changes", [&] { delete this; }));
if (scraperParams.game->getType() == FOLDER) { if (scraperParams.game->getType() == FOLDER) {
if (mClearGameFunc) { if (mClearGameFunc) {
auto clearSelf = [&] { auto clearSelf = [&] {
@ -532,7 +526,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
delete this; delete this;
}; };
auto clearSelfBtnFunc = [this, clearSelf] { auto clearSelfBtnFunc = [this, clearSelf] {
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), mWindow->pushGui(new GuiMsgBox(getHelpStyle(),
"THIS WILL DELETE ANY MEDIA FILES AND\n" "THIS WILL DELETE ANY MEDIA FILES AND\n"
"THE GAMELIST.XML ENTRY FOR THIS FOLDER,\n" "THE GAMELIST.XML ENTRY FOR THIS FOLDER,\n"
"BUT NEITHER THE FOLDER ITSELF OR ANY\n" "BUT NEITHER THE FOLDER ITSELF OR ANY\n"
@ -540,8 +534,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
"ARE YOU SURE?", "ARE YOU SURE?",
"YES", clearSelf, "NO", nullptr)); "YES", clearSelf, "NO", nullptr));
}; };
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CLEAR", "clear folder", buttons.push_back(
clearSelfBtnFunc)); std::make_shared<ButtonComponent>("CLEAR", "clear folder", clearSelfBtnFunc));
} }
} }
else { else {
@ -551,7 +545,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
delete this; delete this;
}; };
auto clearSelfBtnFunc = [this, clearSelf] { auto clearSelfBtnFunc = [this, clearSelf] {
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), mWindow->pushGui(new GuiMsgBox(getHelpStyle(),
"THIS WILL DELETE ANY MEDIA FILES\n" "THIS WILL DELETE ANY MEDIA FILES\n"
"AND THE GAMELIST.XML ENTRY FOR\n" "AND THE GAMELIST.XML ENTRY FOR\n"
"THIS GAME, BUT THE GAME FILE\n" "THIS GAME, BUT THE GAME FILE\n"
@ -559,8 +553,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
"ARE YOU SURE?", "ARE YOU SURE?",
"YES", clearSelf, "NO", nullptr)); "YES", clearSelf, "NO", nullptr));
}; };
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CLEAR", "clear file", buttons.push_back(
clearSelfBtnFunc)); std::make_shared<ButtonComponent>("CLEAR", "clear file", clearSelfBtnFunc));
} }
// For the special case where a directory has a supported file extension and is therefore // For the special case where a directory has a supported file extension and is therefore
@ -571,19 +565,19 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
delete this; delete this;
}; };
auto deleteGameBtnFunc = [this, deleteFilesAndSelf] { auto deleteGameBtnFunc = [this, deleteFilesAndSelf] {
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), mWindow->pushGui(new GuiMsgBox(getHelpStyle(),
"THIS WILL DELETE THE GAME\n" "THIS WILL DELETE THE GAME\n"
"FILE, ANY MEDIA FILES AND\n" "FILE, ANY MEDIA FILES AND\n"
"THE GAMELIST.XML ENTRY\n" "THE GAMELIST.XML ENTRY\n"
"ARE YOU SURE?", "ARE YOU SURE?",
"YES", deleteFilesAndSelf, "NO", nullptr)); "YES", deleteFilesAndSelf, "NO", nullptr));
}; };
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "DELETE", "delete game", buttons.push_back(
deleteGameBtnFunc)); std::make_shared<ButtonComponent>("DELETE", "delete game", deleteGameBtnFunc));
} }
} }
mButtons = makeButtonGrid(mWindow, buttons); mButtons = makeButtonGrid(buttons);
mGrid.setEntry(mButtons, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1}); mGrid.setEntry(mButtons, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1});
// Resize + center. // Resize + center.
@ -748,7 +742,7 @@ void GuiMetaDataEd::save()
void GuiMetaDataEd::fetch() void GuiMetaDataEd::fetch()
{ {
GuiScraperSingle* scr = new GuiScraperSingle( GuiScraperSingle* scr = new GuiScraperSingle(
mWindow, mScraperParams, std::bind(&GuiMetaDataEd::fetchDone, this, std::placeholders::_1), mScraperParams, std::bind(&GuiMetaDataEd::fetchDone, this, std::placeholders::_1),
mSavedMediaAndAborted); mSavedMediaAndAborted);
mWindow->pushGui(scr); mWindow->pushGui(scr);
} }
@ -856,7 +850,7 @@ void GuiMetaDataEd::close()
if (metadataUpdated) { if (metadataUpdated) {
// Changes were made, ask if the user wants to save them. // Changes were made, ask if the user wants to save them.
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
mWindow, getHelpStyle(), "SAVE CHANGES?", "YES", getHelpStyle(), "SAVE CHANGES?", "YES",
[this, closeFunc] { [this, closeFunc] {
save(); save();
closeFunc(); closeFunc();

View file

@ -26,8 +26,7 @@ class TextComponent;
class GuiMetaDataEd : public GuiComponent class GuiMetaDataEd : public GuiComponent
{ {
public: public:
GuiMetaDataEd(Window* window, GuiMetaDataEd(MetaDataList* md,
MetaDataList* md,
const std::vector<MetaDataDecl>& mdd, const std::vector<MetaDataDecl>& mdd,
ScraperSearchParams params, ScraperSearchParams params,
std::function<void()> savedCallback, std::function<void()> savedCallback,

View file

@ -13,11 +13,10 @@
#include "components/MenuComponent.h" #include "components/MenuComponent.h"
#include "views/ViewController.h" #include "views/ViewController.h"
GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue<FileData*>& gameQueue) GuiOfflineGenerator::GuiOfflineGenerator(const std::queue<FileData*>& gameQueue)
: GuiComponent {window} : mGameQueue {gameQueue}
, mGameQueue {gameQueue} , mBackground {":/graphics/frame.svg"}
, mBackground {window, ":/graphics/frame.svg"} , mGrid {glm::ivec2 {6, 13}}
, mGrid {window, glm::ivec2 {6, 13}}
{ {
addChild(&mBackground); addChild(&mBackground);
addChild(&mGrid); addChild(&mGrid);
@ -36,133 +35,129 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue<FileDa
mGame = nullptr; mGame = nullptr;
// Header. // Header.
mTitle = std::make_shared<TextComponent>(mWindow, "MIXIMAGE OFFLINE GENERATOR", mTitle = std::make_shared<TextComponent>("MIXIMAGE OFFLINE GENERATOR",
Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {6, 1}); mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {6, 1});
mStatus = std::make_shared<TextComponent>(mWindow, "NOT STARTED", Font::get(FONT_SIZE_MEDIUM), mStatus = std::make_shared<TextComponent>("NOT STARTED", Font::get(FONT_SIZE_MEDIUM),
0x777777FF, ALIGN_CENTER); 0x777777FF, ALIGN_CENTER);
mGrid.setEntry(mStatus, glm::ivec2 {0, 1}, false, true, glm::ivec2 {6, 1}); mGrid.setEntry(mStatus, glm::ivec2 {0, 1}, false, true, glm::ivec2 {6, 1});
mGameCounter = std::make_shared<TextComponent>( mGameCounter = std::make_shared<TextComponent>(
mWindow,
std::to_string(mGamesProcessed) + " OF " + std::to_string(mTotalGames) + std::to_string(mGamesProcessed) + " OF " + std::to_string(mTotalGames) +
(mTotalGames == 1 ? " GAME " : " GAMES ") + "PROCESSED", (mTotalGames == 1 ? " GAME " : " GAMES ") + "PROCESSED",
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
mGrid.setEntry(mGameCounter, glm::ivec2 {0, 2}, false, true, glm::ivec2 {6, 1}); mGrid.setEntry(mGameCounter, glm::ivec2 {0, 2}, false, true, glm::ivec2 {6, 1});
// Spacer row with top border. // Spacer row with top border.
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {0, 3}, false, false, mGrid.setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {0, 3}, false, false,
glm::ivec2 {6, 1}, GridFlags::BORDER_TOP); glm::ivec2 {6, 1}, GridFlags::BORDER_TOP);
// Left spacer. // Left spacer.
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {0, 4}, false, false, mGrid.setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {0, 4}, false, false,
glm::ivec2 {1, 7}); glm::ivec2 {1, 7});
// Generated label. // Generated label.
mGeneratedLbl = std::make_shared<TextComponent>( mGeneratedLbl = std::make_shared<TextComponent>("Generated:", Font::get(FONT_SIZE_SMALL),
mWindow, "Generated:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); 0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mGeneratedLbl, glm::ivec2 {1, 4}, false, true, glm::ivec2 {1, 1}); mGrid.setEntry(mGeneratedLbl, glm::ivec2 {1, 4}, false, true, glm::ivec2 {1, 1});
// Generated value/counter. // Generated value/counter.
mGeneratedVal = mGeneratedVal = std::make_shared<TextComponent>(
std::make_shared<TextComponent>(mWindow, std::to_string(mGamesProcessed), std::to_string(mGamesProcessed), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mGeneratedVal, glm::ivec2 {2, 4}, false, true, glm::ivec2 {1, 1}); mGrid.setEntry(mGeneratedVal, glm::ivec2 {2, 4}, false, true, glm::ivec2 {1, 1});
// Overwritten label. // Overwritten label.
mOverwrittenLbl = std::make_shared<TextComponent>( mOverwrittenLbl = std::make_shared<TextComponent>("Overwritten:", Font::get(FONT_SIZE_SMALL),
mWindow, "Overwritten:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); 0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mOverwrittenLbl, glm::ivec2 {1, 5}, false, true, glm::ivec2 {1, 1}); mGrid.setEntry(mOverwrittenLbl, glm::ivec2 {1, 5}, false, true, glm::ivec2 {1, 1});
// Overwritten value/counter. // Overwritten value/counter.
mOverwrittenVal = mOverwrittenVal = std::make_shared<TextComponent>(
std::make_shared<TextComponent>(mWindow, std::to_string(mImagesOverwritten), std::to_string(mImagesOverwritten), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mOverwrittenVal, glm::ivec2 {2, 5}, false, true, glm::ivec2 {1, 1}); mGrid.setEntry(mOverwrittenVal, glm::ivec2 {2, 5}, false, true, glm::ivec2 {1, 1});
// Skipping label. // Skipping label.
mSkippedLbl = std::make_shared<TextComponent>( mSkippedLbl = std::make_shared<TextComponent>("Skipped (existing):", Font::get(FONT_SIZE_SMALL),
mWindow, "Skipped (existing):", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); 0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mSkippedLbl, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1}); mGrid.setEntry(mSkippedLbl, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1});
// Skipping value/counter. // Skipping value/counter.
mSkippedVal = std::make_shared<TextComponent>( mSkippedVal = std::make_shared<TextComponent>(
mWindow, std::to_string(mGamesSkipped), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); std::to_string(mGamesSkipped), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mSkippedVal, glm::ivec2 {2, 6}, false, true, glm::ivec2 {1, 1}); mGrid.setEntry(mSkippedVal, glm::ivec2 {2, 6}, false, true, glm::ivec2 {1, 1});
// Failed label. // Failed label.
mFailedLbl = std::make_shared<TextComponent>(mWindow, "Failed:", Font::get(FONT_SIZE_SMALL), mFailedLbl = std::make_shared<TextComponent>("Failed:", Font::get(FONT_SIZE_SMALL), 0x888888FF,
0x888888FF, ALIGN_LEFT); ALIGN_LEFT);
mGrid.setEntry(mFailedLbl, glm::ivec2 {1, 7}, false, true, glm::ivec2 {1, 1}); mGrid.setEntry(mFailedLbl, glm::ivec2 {1, 7}, false, true, glm::ivec2 {1, 1});
// Failed value/counter. // Failed value/counter.
mFailedVal = std::make_shared<TextComponent>( mFailedVal = std::make_shared<TextComponent>(
mWindow, std::to_string(mGamesFailed), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); std::to_string(mGamesFailed), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mFailedVal, glm::ivec2 {2, 7}, false, true, glm::ivec2 {1, 1}); mGrid.setEntry(mFailedVal, glm::ivec2 {2, 7}, false, true, glm::ivec2 {1, 1});
// Processing label. // Processing label.
mProcessingLbl = std::make_shared<TextComponent>( mProcessingLbl = std::make_shared<TextComponent>("Processing: ", Font::get(FONT_SIZE_SMALL),
mWindow, "Processing: ", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); 0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mProcessingLbl, glm::ivec2 {3, 4}, false, true, glm::ivec2 {1, 1}); mGrid.setEntry(mProcessingLbl, glm::ivec2 {3, 4}, false, true, glm::ivec2 {1, 1});
// Processing value. // Processing value.
mProcessingVal = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_SMALL), mProcessingVal =
0x888888FF, ALIGN_LEFT); std::make_shared<TextComponent>("", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mProcessingVal, glm::ivec2 {4, 4}, false, true, glm::ivec2 {1, 1}); mGrid.setEntry(mProcessingVal, glm::ivec2 {4, 4}, false, true, glm::ivec2 {1, 1});
// Spacer row. // Spacer row.
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 8}, false, false, mGrid.setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {1, 8}, false, false,
glm::ivec2 {4, 1}); glm::ivec2 {4, 1});
// Last error message label. // Last error message label.
mLastErrorLbl = std::make_shared<TextComponent>( mLastErrorLbl = std::make_shared<TextComponent>(
mWindow, "Last error message:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); "Last error message:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mLastErrorLbl, glm::ivec2 {1, 9}, false, true, glm::ivec2 {4, 1}); mGrid.setEntry(mLastErrorLbl, glm::ivec2 {1, 9}, false, true, glm::ivec2 {4, 1});
// Last error message value. // Last error message value.
mLastErrorVal = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_SMALL), mLastErrorVal =
0x888888FF, ALIGN_LEFT); std::make_shared<TextComponent>("", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mLastErrorVal, glm::ivec2 {1, 10}, false, true, glm::ivec2 {4, 1}); mGrid.setEntry(mLastErrorVal, glm::ivec2 {1, 10}, false, true, glm::ivec2 {4, 1});
// Right spacer. // Right spacer.
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {5, 4}, false, false, mGrid.setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {5, 4}, false, false,
glm::ivec2 {1, 7}); glm::ivec2 {1, 7});
// Spacer row with bottom border. // Spacer row with bottom border.
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {0, 11}, false, false, mGrid.setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {0, 11}, false, false,
glm::ivec2 {6, 1}, GridFlags::BORDER_BOTTOM); glm::ivec2 {6, 1}, GridFlags::BORDER_BOTTOM);
// Buttons. // Buttons.
std::vector<std::shared_ptr<ButtonComponent>> buttons; std::vector<std::shared_ptr<ButtonComponent>> buttons;
mStartPauseButton = mStartPauseButton = std::make_shared<ButtonComponent>("START", "start processing", [this]() {
std::make_shared<ButtonComponent>(mWindow, "START", "start processing", [this]() { if (!mProcessing) {
if (!mProcessing) { mProcessing = true;
mProcessing = true; mPaused = false;
mPaused = false; mStartPauseButton->setText("PAUSE", "pause processing");
mStartPauseButton->setText("PAUSE", "pause processing"); mCloseButton->setText("CLOSE", "close (abort processing)");
mCloseButton->setText("CLOSE", "close (abort processing)"); mStatus->setText("RUNNING...");
mStatus->setText("RUNNING..."); if (mGamesProcessed == 0) {
if (mGamesProcessed == 0) { LOG(LogInfo) << "GuiOfflineGenerator: Processing " << mTotalGames << " games";
LOG(LogInfo) << "GuiOfflineGenerator: Processing " << mTotalGames << " games";
}
} }
else { }
if (mMiximageGeneratorThread.joinable()) else {
mMiximageGeneratorThread.join(); if (mMiximageGeneratorThread.joinable())
mPaused = true; mMiximageGeneratorThread.join();
update(1); mPaused = true;
mProcessing = false; update(1);
this->mStartPauseButton->setText("START", "start processing"); mProcessing = false;
this->mCloseButton->setText("CLOSE", "close (abort processing)"); this->mStartPauseButton->setText("START", "start processing");
mStatus->setText("PAUSED"); this->mCloseButton->setText("CLOSE", "close (abort processing)");
} mStatus->setText("PAUSED");
}); }
});
buttons.push_back(mStartPauseButton); buttons.push_back(mStartPauseButton);
mCloseButton = std::make_shared<ButtonComponent>(mWindow, "CLOSE", "close", [this]() { mCloseButton = std::make_shared<ButtonComponent>("CLOSE", "close", [this]() {
if (mGamesProcessed != 0 && mGamesProcessed != mTotalGames) { if (mGamesProcessed != 0 && mGamesProcessed != mTotalGames) {
LOG(LogInfo) << "GuiOfflineGenerator: Aborted after processing " << mGamesProcessed LOG(LogInfo) << "GuiOfflineGenerator: Aborted after processing " << mGamesProcessed
<< (mGamesProcessed == 1 ? " game (" : " games (") << mImagesGenerated << (mGamesProcessed == 1 ? " game (" : " games (") << mImagesGenerated
@ -175,7 +170,7 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue<FileDa
}); });
buttons.push_back(mCloseButton); buttons.push_back(mCloseButton);
mButtonGrid = makeButtonGrid(mWindow, buttons); mButtonGrid = makeButtonGrid(buttons);
mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 12}, true, false, glm::ivec2 {6, 1}); mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 12}, true, false, glm::ivec2 {6, 1});

View file

@ -22,7 +22,7 @@ class TextComponent;
class GuiOfflineGenerator : public GuiComponent class GuiOfflineGenerator : public GuiComponent
{ {
public: public:
GuiOfflineGenerator(Window* window, const std::queue<FileData*>& gameQueue); GuiOfflineGenerator(const std::queue<FileData*>& gameQueue);
~GuiOfflineGenerator(); ~GuiOfflineGenerator();
private: private:

View file

@ -20,13 +20,12 @@
#include "guis/GuiScraperMulti.h" #include "guis/GuiScraperMulti.h"
#include "views/ViewController.h" #include "views/ViewController.h"
GuiScraperMenu::GuiScraperMenu(Window* window, std::string title) GuiScraperMenu::GuiScraperMenu(std::string title)
: GuiComponent {window} : mMenu {title}
, mMenu {window, title}
{ {
// Scraper service. // Scraper service.
mScraper = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(), mScraper =
"SCRAPE FROM", false); std::make_shared<OptionListComponent<std::string>>(getHelpStyle(), "SCRAPE FROM", false);
std::vector<std::string> scrapers = getScraperList(); std::vector<std::string> scrapers = getScraperList();
// Select either the first entry or the one read from the settings, // Select either the first entry or the one read from the settings,
// just in case the scraper from settings has vanished. // just in case the scraper from settings has vanished.
@ -41,7 +40,7 @@ GuiScraperMenu::GuiScraperMenu(Window* window, std::string title)
// Search filters, getSearches() will generate a queue of games to scrape // Search filters, getSearches() will generate a queue of games to scrape
// based on the outcome of the checks below. // based on the outcome of the checks below.
mFilters = std::make_shared<OptionListComponent<GameFilterFunc>>(mWindow, getHelpStyle(), mFilters = std::make_shared<OptionListComponent<GameFilterFunc>>(getHelpStyle(),
"SCRAPE THESE GAMES", false); "SCRAPE THESE GAMES", false);
mFilters->add( mFilters->add(
"ALL GAMES", "ALL GAMES",
@ -102,7 +101,7 @@ GuiScraperMenu::GuiScraperMenu(Window* window, std::string title)
}); });
// Add systems (all systems with an existing platform ID are listed). // Add systems (all systems with an existing platform ID are listed).
mSystems = std::make_shared<OptionListComponent<SystemData*>>(mWindow, getHelpStyle(), mSystems = std::make_shared<OptionListComponent<SystemData*>>(getHelpStyle(),
"SCRAPE THESE SYSTEMS", true); "SCRAPE THESE SYSTEMS", true);
for (unsigned int i = 0; i < SystemData::sSystemVector.size(); ++i) { for (unsigned int i = 0; i < SystemData::sSystemVector.size(); ++i) {
if (!SystemData::sSystemVector[i]->hasPlatformId(PlatformIds::PLATFORM_IGNORE)) { if (!SystemData::sSystemVector[i]->hasPlatformId(PlatformIds::PLATFORM_IGNORE)) {
@ -166,11 +165,11 @@ GuiScraperMenu::~GuiScraperMenu()
void GuiScraperMenu::openAccountOptions() void GuiScraperMenu::openAccountOptions()
{ {
auto s = new GuiSettings(mWindow, "ACCOUNT SETTINGS"); auto s = new GuiSettings("ACCOUNT SETTINGS");
// ScreenScraper username. // ScreenScraper username.
auto scraper_username_screenscraper = std::make_shared<TextComponent>( auto scraper_username_screenscraper =
mWindow, "", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_RIGHT); std::make_shared<TextComponent>("", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_RIGHT);
s->addEditableTextComponent("SCREENSCRAPER USERNAME", scraper_username_screenscraper, s->addEditableTextComponent("SCREENSCRAPER USERNAME", scraper_username_screenscraper,
Settings::getInstance()->getString("ScraperUsernameScreenScraper")); Settings::getInstance()->getString("ScraperUsernameScreenScraper"));
s->addSaveFunc([scraper_username_screenscraper, s] { s->addSaveFunc([scraper_username_screenscraper, s] {
@ -183,8 +182,8 @@ void GuiScraperMenu::openAccountOptions()
}); });
// ScreenScraper password. // ScreenScraper password.
auto scraper_password_screenscraper = std::make_shared<TextComponent>( auto scraper_password_screenscraper =
mWindow, "", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_RIGHT); std::make_shared<TextComponent>("", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_RIGHT);
std::string passwordMasked; std::string passwordMasked;
if (Settings::getInstance()->getString("ScraperPasswordScreenScraper") != "") { if (Settings::getInstance()->getString("ScraperPasswordScreenScraper") != "") {
passwordMasked = "********"; passwordMasked = "********";
@ -203,7 +202,7 @@ void GuiScraperMenu::openAccountOptions()
}); });
// Whether to use the ScreenScraper account when scraping. // Whether to use the ScreenScraper account when scraping.
auto scraper_use_account_screenscraper = std::make_shared<SwitchComponent>(mWindow); auto scraper_use_account_screenscraper = std::make_shared<SwitchComponent>();
scraper_use_account_screenscraper->setState( scraper_use_account_screenscraper->setState(
Settings::getInstance()->getBool("ScraperUseAccountScreenScraper")); Settings::getInstance()->getBool("ScraperUseAccountScreenScraper"));
s->addWithLabel("USE THIS ACCOUNT FOR SCREENSCRAPER", scraper_use_account_screenscraper); s->addWithLabel("USE THIS ACCOUNT FOR SCREENSCRAPER", scraper_use_account_screenscraper);
@ -221,10 +220,10 @@ void GuiScraperMenu::openAccountOptions()
void GuiScraperMenu::openContentOptions() void GuiScraperMenu::openContentOptions()
{ {
auto s = new GuiSettings(mWindow, "CONTENT SETTINGS"); auto s = new GuiSettings("CONTENT SETTINGS");
// Scrape game names. // Scrape game names.
auto scrape_game_names = std::make_shared<SwitchComponent>(mWindow); auto scrape_game_names = std::make_shared<SwitchComponent>();
scrape_game_names->setState(Settings::getInstance()->getBool("ScrapeGameNames")); scrape_game_names->setState(Settings::getInstance()->getBool("ScrapeGameNames"));
s->addWithLabel("GAME NAMES", scrape_game_names); s->addWithLabel("GAME NAMES", scrape_game_names);
s->addSaveFunc([scrape_game_names, s] { s->addSaveFunc([scrape_game_names, s] {
@ -235,7 +234,7 @@ void GuiScraperMenu::openContentOptions()
}); });
// Scrape ratings. // Scrape ratings.
auto scrape_ratings = std::make_shared<SwitchComponent>(mWindow); auto scrape_ratings = std::make_shared<SwitchComponent>();
scrape_ratings->setState(Settings::getInstance()->getBool("ScrapeRatings")); scrape_ratings->setState(Settings::getInstance()->getBool("ScrapeRatings"));
s->addWithLabel("RATINGS", scrape_ratings); s->addWithLabel("RATINGS", scrape_ratings);
s->addSaveFunc([scrape_ratings, s] { s->addSaveFunc([scrape_ratings, s] {
@ -255,7 +254,7 @@ void GuiScraperMenu::openContentOptions()
} }
// Scrape controllers (arcade systems only). // Scrape controllers (arcade systems only).
auto scrapeControllers = std::make_shared<SwitchComponent>(mWindow); auto scrapeControllers = std::make_shared<SwitchComponent>();
scrapeControllers->setState(Settings::getInstance()->getBool("ScrapeControllers")); scrapeControllers->setState(Settings::getInstance()->getBool("ScrapeControllers"));
s->addWithLabel("CONTROLLERS (ARCADE SYSTEMS ONLY)", scrapeControllers); s->addWithLabel("CONTROLLERS (ARCADE SYSTEMS ONLY)", scrapeControllers);
s->addSaveFunc([scrapeControllers, s] { s->addSaveFunc([scrapeControllers, s] {
@ -277,7 +276,7 @@ void GuiScraperMenu::openContentOptions()
} }
// Scrape other metadata. // Scrape other metadata.
auto scrape_metadata = std::make_shared<SwitchComponent>(mWindow); auto scrape_metadata = std::make_shared<SwitchComponent>();
scrape_metadata->setState(Settings::getInstance()->getBool("ScrapeMetadata")); scrape_metadata->setState(Settings::getInstance()->getBool("ScrapeMetadata"));
s->addWithLabel("OTHER METADATA", scrape_metadata); s->addWithLabel("OTHER METADATA", scrape_metadata);
s->addSaveFunc([scrape_metadata, s] { s->addSaveFunc([scrape_metadata, s] {
@ -288,7 +287,7 @@ void GuiScraperMenu::openContentOptions()
}); });
// Scrape videos. // Scrape videos.
auto scrape_videos = std::make_shared<SwitchComponent>(mWindow); auto scrape_videos = std::make_shared<SwitchComponent>();
scrape_videos->setState(Settings::getInstance()->getBool("ScrapeVideos")); scrape_videos->setState(Settings::getInstance()->getBool("ScrapeVideos"));
s->addWithLabel("VIDEOS", scrape_videos); s->addWithLabel("VIDEOS", scrape_videos);
s->addSaveFunc([scrape_videos, s] { s->addSaveFunc([scrape_videos, s] {
@ -308,7 +307,7 @@ void GuiScraperMenu::openContentOptions()
} }
// Scrape screenshots images. // Scrape screenshots images.
auto scrape_screenshots = std::make_shared<SwitchComponent>(mWindow); auto scrape_screenshots = std::make_shared<SwitchComponent>();
scrape_screenshots->setState(Settings::getInstance()->getBool("ScrapeScreenshots")); scrape_screenshots->setState(Settings::getInstance()->getBool("ScrapeScreenshots"));
s->addWithLabel("SCREENSHOT IMAGES", scrape_screenshots); s->addWithLabel("SCREENSHOT IMAGES", scrape_screenshots);
s->addSaveFunc([scrape_screenshots, s] { s->addSaveFunc([scrape_screenshots, s] {
@ -320,7 +319,7 @@ void GuiScraperMenu::openContentOptions()
}); });
// Scrape title screen images. // Scrape title screen images.
auto scrapeTitleScreens = std::make_shared<SwitchComponent>(mWindow); auto scrapeTitleScreens = std::make_shared<SwitchComponent>();
scrapeTitleScreens->setState(Settings::getInstance()->getBool("ScrapeTitleScreens")); scrapeTitleScreens->setState(Settings::getInstance()->getBool("ScrapeTitleScreens"));
s->addWithLabel("TITLE SCREEN IMAGES", scrapeTitleScreens); s->addWithLabel("TITLE SCREEN IMAGES", scrapeTitleScreens);
s->addSaveFunc([scrapeTitleScreens, s] { s->addSaveFunc([scrapeTitleScreens, s] {
@ -332,7 +331,7 @@ void GuiScraperMenu::openContentOptions()
}); });
// Scrape box cover images. // Scrape box cover images.
auto scrape_covers = std::make_shared<SwitchComponent>(mWindow); auto scrape_covers = std::make_shared<SwitchComponent>();
scrape_covers->setState(Settings::getInstance()->getBool("ScrapeCovers")); scrape_covers->setState(Settings::getInstance()->getBool("ScrapeCovers"));
s->addWithLabel("BOX COVER IMAGES", scrape_covers); s->addWithLabel("BOX COVER IMAGES", scrape_covers);
s->addSaveFunc([scrape_covers, s] { s->addSaveFunc([scrape_covers, s] {
@ -343,7 +342,7 @@ void GuiScraperMenu::openContentOptions()
}); });
// Scrape box back cover images. // Scrape box back cover images.
auto scrapeBackCovers = std::make_shared<SwitchComponent>(mWindow); auto scrapeBackCovers = std::make_shared<SwitchComponent>();
scrapeBackCovers->setState(Settings::getInstance()->getBool("ScrapeBackCovers")); scrapeBackCovers->setState(Settings::getInstance()->getBool("ScrapeBackCovers"));
s->addWithLabel("BOX BACK COVER IMAGES", scrapeBackCovers); s->addWithLabel("BOX BACK COVER IMAGES", scrapeBackCovers);
s->addSaveFunc([scrapeBackCovers, s] { s->addSaveFunc([scrapeBackCovers, s] {
@ -354,7 +353,7 @@ void GuiScraperMenu::openContentOptions()
}); });
// Scrape marquee images. // Scrape marquee images.
auto scrape_marquees = std::make_shared<SwitchComponent>(mWindow); auto scrape_marquees = std::make_shared<SwitchComponent>();
scrape_marquees->setState(Settings::getInstance()->getBool("ScrapeMarquees")); scrape_marquees->setState(Settings::getInstance()->getBool("ScrapeMarquees"));
s->addWithLabel("MARQUEE (WHEEL) IMAGES", scrape_marquees); s->addWithLabel("MARQUEE (WHEEL) IMAGES", scrape_marquees);
s->addSaveFunc([scrape_marquees, s] { s->addSaveFunc([scrape_marquees, s] {
@ -365,7 +364,7 @@ void GuiScraperMenu::openContentOptions()
}); });
// Scrape 3D box images. // Scrape 3D box images.
auto scrape_3dboxes = std::make_shared<SwitchComponent>(mWindow); auto scrape_3dboxes = std::make_shared<SwitchComponent>();
scrape_3dboxes->setState(Settings::getInstance()->getBool("Scrape3DBoxes")); scrape_3dboxes->setState(Settings::getInstance()->getBool("Scrape3DBoxes"));
s->addWithLabel("3D BOX IMAGES", scrape_3dboxes); s->addWithLabel("3D BOX IMAGES", scrape_3dboxes);
s->addSaveFunc([scrape_3dboxes, s] { s->addSaveFunc([scrape_3dboxes, s] {
@ -386,7 +385,7 @@ void GuiScraperMenu::openContentOptions()
} }
// Scrape physical media images. // Scrape physical media images.
auto scrapePhysicalMedia = std::make_shared<SwitchComponent>(mWindow); auto scrapePhysicalMedia = std::make_shared<SwitchComponent>();
scrapePhysicalMedia->setState(Settings::getInstance()->getBool("ScrapePhysicalMedia")); scrapePhysicalMedia->setState(Settings::getInstance()->getBool("ScrapePhysicalMedia"));
s->addWithLabel("PHYSICAL MEDIA IMAGES", scrapePhysicalMedia); s->addWithLabel("PHYSICAL MEDIA IMAGES", scrapePhysicalMedia);
s->addSaveFunc([scrapePhysicalMedia, s] { s->addSaveFunc([scrapePhysicalMedia, s] {
@ -409,7 +408,7 @@ void GuiScraperMenu::openContentOptions()
} }
// Scrape fan art images. // Scrape fan art images.
auto scrapeFanArt = std::make_shared<SwitchComponent>(mWindow); auto scrapeFanArt = std::make_shared<SwitchComponent>();
scrapeFanArt->setState(Settings::getInstance()->getBool("ScrapeFanArt")); scrapeFanArt->setState(Settings::getInstance()->getBool("ScrapeFanArt"));
s->addWithLabel("FAN ART IMAGES", scrapeFanArt); s->addWithLabel("FAN ART IMAGES", scrapeFanArt);
s->addSaveFunc([scrapeFanArt, s] { s->addSaveFunc([scrapeFanArt, s] {
@ -424,11 +423,11 @@ void GuiScraperMenu::openContentOptions()
void GuiScraperMenu::openMiximageOptions() void GuiScraperMenu::openMiximageOptions()
{ {
auto s = new GuiSettings(mWindow, "MIXIMAGE SETTINGS"); auto s = new GuiSettings("MIXIMAGE SETTINGS");
// Miximage resolution. // Miximage resolution.
auto miximage_resolution = std::make_shared<OptionListComponent<std::string>>( auto miximage_resolution = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "MIXIMAGE RESOLUTION", false); getHelpStyle(), "MIXIMAGE RESOLUTION", false);
std::string selectedResolution = Settings::getInstance()->getString("MiximageResolution"); std::string selectedResolution = Settings::getInstance()->getString("MiximageResolution");
miximage_resolution->add("1280x960", "1280x960", selectedResolution == "1280x960"); miximage_resolution->add("1280x960", "1280x960", selectedResolution == "1280x960");
miximage_resolution->add("1920x1440", "1920x1440", selectedResolution == "1920x1440"); miximage_resolution->add("1920x1440", "1920x1440", selectedResolution == "1920x1440");
@ -449,7 +448,7 @@ void GuiScraperMenu::openMiximageOptions()
// Screenshot scaling method. // Screenshot scaling method.
auto miximage_scaling = std::make_shared<OptionListComponent<std::string>>( auto miximage_scaling = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "SCREENSHOT SCALING", false); getHelpStyle(), "SCREENSHOT SCALING", false);
std::string selectedScaling = Settings::getInstance()->getString("MiximageScreenshotScaling"); std::string selectedScaling = Settings::getInstance()->getString("MiximageScreenshotScaling");
miximage_scaling->add("sharp", "sharp", selectedScaling == "sharp"); miximage_scaling->add("sharp", "sharp", selectedScaling == "sharp");
miximage_scaling->add("smooth", "smooth", selectedScaling == "smooth"); miximage_scaling->add("smooth", "smooth", selectedScaling == "smooth");
@ -468,8 +467,8 @@ void GuiScraperMenu::openMiximageOptions()
}); });
// Box/cover size. // Box/cover size.
auto miximageBoxSize = std::make_shared<OptionListComponent<std::string>>( auto miximageBoxSize =
mWindow, getHelpStyle(), "BOX SIZE", false); std::make_shared<OptionListComponent<std::string>>(getHelpStyle(), "BOX SIZE", false);
std::string selectedBoxSize = Settings::getInstance()->getString("MiximageBoxSize"); std::string selectedBoxSize = Settings::getInstance()->getString("MiximageBoxSize");
miximageBoxSize->add("small", "small", selectedBoxSize == "small"); miximageBoxSize->add("small", "small", selectedBoxSize == "small");
miximageBoxSize->add("medium", "medium", selectedBoxSize == "medium"); miximageBoxSize->add("medium", "medium", selectedBoxSize == "medium");
@ -489,7 +488,7 @@ void GuiScraperMenu::openMiximageOptions()
// Physical media size. // Physical media size.
auto miximagePhysicalMediaSize = std::make_shared<OptionListComponent<std::string>>( auto miximagePhysicalMediaSize = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "PHYSICAL MEDIA SIZE", false); getHelpStyle(), "PHYSICAL MEDIA SIZE", false);
std::string selectedPhysicalMediaSize = std::string selectedPhysicalMediaSize =
Settings::getInstance()->getString("MiximagePhysicalMediaSize"); Settings::getInstance()->getString("MiximagePhysicalMediaSize");
miximagePhysicalMediaSize->add("small", "small", selectedPhysicalMediaSize == "small"); miximagePhysicalMediaSize->add("small", "small", selectedPhysicalMediaSize == "small");
@ -510,7 +509,7 @@ void GuiScraperMenu::openMiximageOptions()
}); });
// Whether to generate miximages when scraping. // Whether to generate miximages when scraping.
auto miximage_generate = std::make_shared<SwitchComponent>(mWindow); auto miximage_generate = std::make_shared<SwitchComponent>();
miximage_generate->setState(Settings::getInstance()->getBool("MiximageGenerate")); miximage_generate->setState(Settings::getInstance()->getBool("MiximageGenerate"));
s->addWithLabel("GENERATE MIXIMAGES WHEN SCRAPING", miximage_generate); s->addWithLabel("GENERATE MIXIMAGES WHEN SCRAPING", miximage_generate);
s->addSaveFunc([miximage_generate, s] { s->addSaveFunc([miximage_generate, s] {
@ -521,7 +520,7 @@ void GuiScraperMenu::openMiximageOptions()
}); });
// Whether to overwrite miximages (both for the scraper and offline generator). // Whether to overwrite miximages (both for the scraper and offline generator).
auto miximage_overwrite = std::make_shared<SwitchComponent>(mWindow); auto miximage_overwrite = std::make_shared<SwitchComponent>();
miximage_overwrite->setState(Settings::getInstance()->getBool("MiximageOverwrite")); miximage_overwrite->setState(Settings::getInstance()->getBool("MiximageOverwrite"));
s->addWithLabel("OVERWRITE MIXIMAGES (SCRAPER/OFFLINE GENERATOR)", miximage_overwrite); s->addWithLabel("OVERWRITE MIXIMAGES (SCRAPER/OFFLINE GENERATOR)", miximage_overwrite);
s->addSaveFunc([miximage_overwrite, s] { s->addSaveFunc([miximage_overwrite, s] {
@ -533,7 +532,7 @@ void GuiScraperMenu::openMiximageOptions()
}); });
// Whether to remove letterboxes from the screenshots. // Whether to remove letterboxes from the screenshots.
auto remove_letterboxes = std::make_shared<SwitchComponent>(mWindow); auto remove_letterboxes = std::make_shared<SwitchComponent>();
remove_letterboxes->setState(Settings::getInstance()->getBool("MiximageRemoveLetterboxes")); remove_letterboxes->setState(Settings::getInstance()->getBool("MiximageRemoveLetterboxes"));
s->addWithLabel("REMOVE LETTERBOXES FROM SCREENSHOTS", remove_letterboxes); s->addWithLabel("REMOVE LETTERBOXES FROM SCREENSHOTS", remove_letterboxes);
s->addSaveFunc([remove_letterboxes, s] { s->addSaveFunc([remove_letterboxes, s] {
@ -546,7 +545,7 @@ void GuiScraperMenu::openMiximageOptions()
}); });
// Whether to remove pillarboxes from the screenshots. // Whether to remove pillarboxes from the screenshots.
auto remove_pillarboxes = std::make_shared<SwitchComponent>(mWindow); auto remove_pillarboxes = std::make_shared<SwitchComponent>();
remove_pillarboxes->setState(Settings::getInstance()->getBool("MiximageRemovePillarboxes")); remove_pillarboxes->setState(Settings::getInstance()->getBool("MiximageRemovePillarboxes"));
s->addWithLabel("REMOVE PILLARBOXES FROM SCREENSHOTS", remove_pillarboxes); s->addWithLabel("REMOVE PILLARBOXES FROM SCREENSHOTS", remove_pillarboxes);
s->addSaveFunc([remove_pillarboxes, s] { s->addSaveFunc([remove_pillarboxes, s] {
@ -559,7 +558,7 @@ void GuiScraperMenu::openMiximageOptions()
}); });
// Whether to rotate horizontally oriented boxes. // Whether to rotate horizontally oriented boxes.
auto miximageRotateBoxes = std::make_shared<SwitchComponent>(mWindow); auto miximageRotateBoxes = std::make_shared<SwitchComponent>();
miximageRotateBoxes->setState( miximageRotateBoxes->setState(
Settings::getInstance()->getBool("MiximageRotateHorizontalBoxes")); Settings::getInstance()->getBool("MiximageRotateHorizontalBoxes"));
s->addWithLabel("ROTATE HORIZONTALLY ORIENTED BOXES", miximageRotateBoxes); s->addWithLabel("ROTATE HORIZONTALLY ORIENTED BOXES", miximageRotateBoxes);
@ -573,7 +572,7 @@ void GuiScraperMenu::openMiximageOptions()
}); });
// Whether to include marquee images. // Whether to include marquee images.
auto miximage_marquee = std::make_shared<SwitchComponent>(mWindow); auto miximage_marquee = std::make_shared<SwitchComponent>();
miximage_marquee->setState(Settings::getInstance()->getBool("MiximageIncludeMarquee")); miximage_marquee->setState(Settings::getInstance()->getBool("MiximageIncludeMarquee"));
s->addWithLabel("INCLUDE MARQUEE IMAGE", miximage_marquee); s->addWithLabel("INCLUDE MARQUEE IMAGE", miximage_marquee);
s->addSaveFunc([miximage_marquee, s] { s->addSaveFunc([miximage_marquee, s] {
@ -586,7 +585,7 @@ void GuiScraperMenu::openMiximageOptions()
}); });
// Whether to include box images. // Whether to include box images.
auto miximage_box = std::make_shared<SwitchComponent>(mWindow); auto miximage_box = std::make_shared<SwitchComponent>();
miximage_box->setState(Settings::getInstance()->getBool("MiximageIncludeBox")); miximage_box->setState(Settings::getInstance()->getBool("MiximageIncludeBox"));
s->addWithLabel("INCLUDE BOX IMAGE", miximage_box); s->addWithLabel("INCLUDE BOX IMAGE", miximage_box);
s->addSaveFunc([miximage_box, s] { s->addSaveFunc([miximage_box, s] {
@ -597,7 +596,7 @@ void GuiScraperMenu::openMiximageOptions()
}); });
// Whether to use cover image if there is no 3D box image. // Whether to use cover image if there is no 3D box image.
auto miximage_cover_fallback = std::make_shared<SwitchComponent>(mWindow); auto miximage_cover_fallback = std::make_shared<SwitchComponent>();
miximage_cover_fallback->setState(Settings::getInstance()->getBool("MiximageCoverFallback")); miximage_cover_fallback->setState(Settings::getInstance()->getBool("MiximageCoverFallback"));
s->addWithLabel("USE COVER IMAGE IF 3D BOX IS MISSING", miximage_cover_fallback); s->addWithLabel("USE COVER IMAGE IF 3D BOX IS MISSING", miximage_cover_fallback);
s->addSaveFunc([miximage_cover_fallback, s] { s->addSaveFunc([miximage_cover_fallback, s] {
@ -610,7 +609,7 @@ void GuiScraperMenu::openMiximageOptions()
}); });
// Whether to include physical media images. // Whether to include physical media images.
auto miximagePhysicalMedia = std::make_shared<SwitchComponent>(mWindow); auto miximagePhysicalMedia = std::make_shared<SwitchComponent>();
miximagePhysicalMedia->setState( miximagePhysicalMedia->setState(
Settings::getInstance()->getBool("MiximageIncludePhysicalMedia")); Settings::getInstance()->getBool("MiximageIncludePhysicalMedia"));
s->addWithLabel("INCLUDE PHYSICAL MEDIA IMAGE", miximagePhysicalMedia); s->addWithLabel("INCLUDE PHYSICAL MEDIA IMAGE", miximagePhysicalMedia);
@ -626,11 +625,11 @@ void GuiScraperMenu::openMiximageOptions()
// Miximage offline generator. // Miximage offline generator.
ComponentListRow offline_generator_row; ComponentListRow offline_generator_row;
offline_generator_row.elements.clear(); offline_generator_row.elements.clear();
offline_generator_row.addElement(std::make_shared<TextComponent>(mWindow, "OFFLINE GENERATOR", offline_generator_row.addElement(std::make_shared<TextComponent>("OFFLINE GENERATOR",
Font::get(FONT_SIZE_MEDIUM), Font::get(FONT_SIZE_MEDIUM),
0x777777FF), 0x777777FF),
true); true);
offline_generator_row.addElement(makeArrow(mWindow), false); offline_generator_row.addElement(makeArrow(), false);
offline_generator_row.makeAcceptInputHandler( offline_generator_row.makeAcceptInputHandler(
std::bind(&GuiScraperMenu::openOfflineGenerator, this, s)); std::bind(&GuiScraperMenu::openOfflineGenerator, this, s));
s->addRow(offline_generator_row); s->addRow(offline_generator_row);
@ -641,7 +640,7 @@ void GuiScraperMenu::openMiximageOptions()
void GuiScraperMenu::openOfflineGenerator(GuiSettings* settings) void GuiScraperMenu::openOfflineGenerator(GuiSettings* settings)
{ {
if (mSystems->getSelectedObjects().empty()) { if (mSystems->getSelectedObjects().empty()) {
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), mWindow->pushGui(new GuiMsgBox(getHelpStyle(),
"THE OFFLINE GENERATOR USES THE SAME SYSTEM\n" "THE OFFLINE GENERATOR USES THE SAME SYSTEM\n"
"SELECTIONS AS THE SCRAPER, SO PLEASE SELECT\n" "SELECTIONS AS THE SCRAPER, SO PLEASE SELECT\n"
"AT LEAST ONE SYSTEM TO GENERATE IMAGES FOR")); "AT LEAST ONE SYSTEM TO GENERATE IMAGES FOR"));
@ -669,16 +668,16 @@ void GuiScraperMenu::openOfflineGenerator(GuiSettings* settings)
gameQueue.push(game); gameQueue.push(game);
} }
mWindow->pushGui(new GuiOfflineGenerator(mWindow, gameQueue)); mWindow->pushGui(new GuiOfflineGenerator(gameQueue));
} }
void GuiScraperMenu::openOtherOptions() void GuiScraperMenu::openOtherOptions()
{ {
auto s = new GuiSettings(mWindow, "OTHER SETTINGS"); auto s = new GuiSettings("OTHER SETTINGS");
// Scraper region. // Scraper region.
auto scraper_region = std::make_shared<OptionListComponent<std::string>>( auto scraper_region =
mWindow, getHelpStyle(), "REGION", false); std::make_shared<OptionListComponent<std::string>>(getHelpStyle(), "REGION", false);
std::string selectedScraperRegion = Settings::getInstance()->getString("ScraperRegion"); std::string selectedScraperRegion = Settings::getInstance()->getString("ScraperRegion");
// clang-format off // clang-format off
scraper_region->add("Europe", "eu", selectedScraperRegion == "eu"); scraper_region->add("Europe", "eu", selectedScraperRegion == "eu");
@ -709,7 +708,7 @@ void GuiScraperMenu::openOtherOptions()
// Scraper language. // Scraper language.
auto scraper_language = std::make_shared<OptionListComponent<std::string>>( auto scraper_language = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "PREFERRED LANGUAGE", false); getHelpStyle(), "PREFERRED LANGUAGE", false);
std::string selectedScraperLanguage = Settings::getInstance()->getString("ScraperLanguage"); std::string selectedScraperLanguage = Settings::getInstance()->getString("ScraperLanguage");
// clang-format off // clang-format off
scraper_language->add("English", "en", selectedScraperLanguage == "en"); scraper_language->add("English", "en", selectedScraperLanguage == "en");
@ -757,7 +756,7 @@ void GuiScraperMenu::openOtherOptions()
} }
// Overwrite files and data. // Overwrite files and data.
auto scraper_overwrite_data = std::make_shared<SwitchComponent>(mWindow); auto scraper_overwrite_data = std::make_shared<SwitchComponent>();
scraper_overwrite_data->setState(Settings::getInstance()->getBool("ScraperOverwriteData")); scraper_overwrite_data->setState(Settings::getInstance()->getBool("ScraperOverwriteData"));
s->addWithLabel("OVERWRITE FILES AND DATA", scraper_overwrite_data); s->addWithLabel("OVERWRITE FILES AND DATA", scraper_overwrite_data);
s->addSaveFunc([scraper_overwrite_data, s] { s->addSaveFunc([scraper_overwrite_data, s] {
@ -770,7 +769,7 @@ void GuiScraperMenu::openOtherOptions()
}); });
// Halt scraping on invalid media files. // Halt scraping on invalid media files.
auto scraper_halt_on_invalid_media = std::make_shared<SwitchComponent>(mWindow); auto scraper_halt_on_invalid_media = std::make_shared<SwitchComponent>();
scraper_halt_on_invalid_media->setState( scraper_halt_on_invalid_media->setState(
Settings::getInstance()->getBool("ScraperHaltOnInvalidMedia")); Settings::getInstance()->getBool("ScraperHaltOnInvalidMedia"));
s->addWithLabel("HALT ON INVALID MEDIA FILES", scraper_halt_on_invalid_media); s->addWithLabel("HALT ON INVALID MEDIA FILES", scraper_halt_on_invalid_media);
@ -784,7 +783,7 @@ void GuiScraperMenu::openOtherOptions()
}); });
// Search using metadata names. // Search using metadata names.
auto scraper_search_metadata_name = std::make_shared<SwitchComponent>(mWindow); auto scraper_search_metadata_name = std::make_shared<SwitchComponent>();
scraper_search_metadata_name->setState( scraper_search_metadata_name->setState(
Settings::getInstance()->getBool("ScraperSearchMetadataName")); Settings::getInstance()->getBool("ScraperSearchMetadataName"));
s->addWithLabel("SEARCH USING METADATA NAMES", scraper_search_metadata_name); s->addWithLabel("SEARCH USING METADATA NAMES", scraper_search_metadata_name);
@ -798,7 +797,7 @@ void GuiScraperMenu::openOtherOptions()
}); });
// Include actual folders when scraping. // Include actual folders when scraping.
auto scraper_include_folders = std::make_shared<SwitchComponent>(mWindow); auto scraper_include_folders = std::make_shared<SwitchComponent>();
scraper_include_folders->setState(Settings::getInstance()->getBool("ScraperIncludeFolders")); scraper_include_folders->setState(Settings::getInstance()->getBool("ScraperIncludeFolders"));
s->addWithLabel("SCRAPE ACTUAL FOLDERS", scraper_include_folders); s->addWithLabel("SCRAPE ACTUAL FOLDERS", scraper_include_folders);
s->addSaveFunc([scraper_include_folders, s] { s->addSaveFunc([scraper_include_folders, s] {
@ -811,7 +810,7 @@ void GuiScraperMenu::openOtherOptions()
}); });
// Interactive scraping. // Interactive scraping.
auto scraper_interactive = std::make_shared<SwitchComponent>(mWindow); auto scraper_interactive = std::make_shared<SwitchComponent>();
scraper_interactive->setState(Settings::getInstance()->getBool("ScraperInteractive")); scraper_interactive->setState(Settings::getInstance()->getBool("ScraperInteractive"));
s->addWithLabel("INTERACTIVE MODE", scraper_interactive); s->addWithLabel("INTERACTIVE MODE", scraper_interactive);
s->addSaveFunc([scraper_interactive, s] { s->addSaveFunc([scraper_interactive, s] {
@ -823,7 +822,7 @@ void GuiScraperMenu::openOtherOptions()
}); });
// Semi-automatic scraping. // Semi-automatic scraping.
auto scraper_semiautomatic = std::make_shared<SwitchComponent>(mWindow); auto scraper_semiautomatic = std::make_shared<SwitchComponent>();
scraper_semiautomatic->setState(Settings::getInstance()->getBool("ScraperSemiautomatic")); scraper_semiautomatic->setState(Settings::getInstance()->getBool("ScraperSemiautomatic"));
s->addWithLabel("AUTO-ACCEPT SINGLE GAME MATCHES", scraper_semiautomatic); s->addWithLabel("AUTO-ACCEPT SINGLE GAME MATCHES", scraper_semiautomatic);
s->addSaveFunc([scraper_semiautomatic, s] { s->addSaveFunc([scraper_semiautomatic, s] {
@ -845,7 +844,7 @@ void GuiScraperMenu::openOtherOptions()
} }
// Respect the per-file multi-scraper exclusion flag. // Respect the per-file multi-scraper exclusion flag.
auto scraper_respect_exclusions = std::make_shared<SwitchComponent>(mWindow); auto scraper_respect_exclusions = std::make_shared<SwitchComponent>();
scraper_respect_exclusions->setState( scraper_respect_exclusions->setState(
Settings::getInstance()->getBool("ScraperRespectExclusions")); Settings::getInstance()->getBool("ScraperRespectExclusions"));
s->addWithLabel("RESPECT PER-FILE SCRAPER EXCLUSIONS", scraper_respect_exclusions); s->addWithLabel("RESPECT PER-FILE SCRAPER EXCLUSIONS", scraper_respect_exclusions);
@ -859,7 +858,7 @@ void GuiScraperMenu::openOtherOptions()
}); });
// Exclude files recursively for excluded folders. // Exclude files recursively for excluded folders.
auto scraper_exclude_recursively = std::make_shared<SwitchComponent>(mWindow); auto scraper_exclude_recursively = std::make_shared<SwitchComponent>();
scraper_exclude_recursively->setState( scraper_exclude_recursively->setState(
Settings::getInstance()->getBool("ScraperExcludeRecursively")); Settings::getInstance()->getBool("ScraperExcludeRecursively"));
s->addWithLabel("EXCLUDE FOLDERS RECURSIVELY", scraper_exclude_recursively); s->addWithLabel("EXCLUDE FOLDERS RECURSIVELY", scraper_exclude_recursively);
@ -882,7 +881,7 @@ void GuiScraperMenu::openOtherOptions()
} }
// Retry search on peer verification errors (TLS/certificate issues). // Retry search on peer verification errors (TLS/certificate issues).
auto retry_peer_verification = std::make_shared<SwitchComponent>(mWindow); auto retry_peer_verification = std::make_shared<SwitchComponent>();
retry_peer_verification->setState( retry_peer_verification->setState(
Settings::getInstance()->getBool("ScraperRetryPeerVerification")); Settings::getInstance()->getBool("ScraperRetryPeerVerification"));
s->addWithLabel("AUTO-RETRY ON PEER VERIFICATION ERRORS", retry_peer_verification); s->addWithLabel("AUTO-RETRY ON PEER VERIFICATION ERRORS", retry_peer_verification);
@ -968,9 +967,9 @@ void GuiScraperMenu::pressedStart()
"set, results may be inaccurate\n" "set, results may be inaccurate\n"
"Continue anyway?"; "Continue anyway?";
} }
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(warningString),
Utils::String::toUpper(warningString), "YES", "YES", std::bind(&GuiScraperMenu::start, this), "NO",
std::bind(&GuiScraperMenu::start, this), "NO", nullptr)); nullptr));
return; return;
} }
} }
@ -981,7 +980,7 @@ void GuiScraperMenu::start()
{ {
if (mSystems->getSelectedObjects().empty()) { if (mSystems->getSelectedObjects().empty()) {
mWindow->pushGui( mWindow->pushGui(
new GuiMsgBox(mWindow, getHelpStyle(), "PLEASE SELECT AT LEAST ONE SYSTEM TO SCRAPE")); new GuiMsgBox(getHelpStyle(), "PLEASE SELECT AT LEAST ONE SYSTEM TO SCRAPE"));
return; return;
} }
@ -1049,8 +1048,8 @@ void GuiScraperMenu::start()
} while (0); } while (0);
if (!contentToScrape) { if (!contentToScrape) {
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), mWindow->pushGui(
"PLEASE SELECT AT LEAST ONE CONTENT TYPE TO SCRAPE")); new GuiMsgBox(getHelpStyle(), "PLEASE SELECT AT LEAST ONE CONTENT TYPE TO SCRAPE"));
return; return;
} }
@ -1059,11 +1058,11 @@ void GuiScraperMenu::start()
if (searches.empty()) { if (searches.empty()) {
mWindow->pushGui( mWindow->pushGui(
new GuiMsgBox(mWindow, getHelpStyle(), "ALL GAMES WERE FILTERED, NOTHING TO SCRAPE")); new GuiMsgBox(getHelpStyle(), "ALL GAMES WERE FILTERED, NOTHING TO SCRAPE"));
} }
else { else {
GuiScraperMulti* gsm = new GuiScraperMulti( GuiScraperMulti* gsm =
mWindow, searches, Settings::getInstance()->getBool("ScraperInteractive")); new GuiScraperMulti(searches, Settings::getInstance()->getBool("ScraperInteractive"));
mWindow->pushGui(gsm); mWindow->pushGui(gsm);
mMenu.setCursorToList(); mMenu.setCursorToList();
mMenu.setCursorToFirstListEntry(); mMenu.setCursorToFirstListEntry();
@ -1101,10 +1100,10 @@ void GuiScraperMenu::addEntry(const std::string& name,
// Populate the list. // Populate the list.
ComponentListRow row; ComponentListRow row;
row.addElement(std::make_shared<TextComponent>(mWindow, name, font, color), true); row.addElement(std::make_shared<TextComponent>(name, font, color), true);
if (add_arrow) { if (add_arrow) {
std::shared_ptr<ImageComponent> bracket = makeArrow(mWindow); std::shared_ptr<ImageComponent> bracket {makeArrow()};
row.addElement(bracket, false); row.addElement(bracket, false);
} }

View file

@ -25,7 +25,7 @@ using GameFilterFunc = std::function<bool(SystemData*, FileData*)>;
class GuiScraperMenu : public GuiComponent class GuiScraperMenu : public GuiComponent
{ {
public: public:
GuiScraperMenu(Window* window, std::string title); GuiScraperMenu(std::string title);
~GuiScraperMenu(); ~GuiScraperMenu();
bool input(InputConfig* config, Input input) override; bool input(InputConfig* config, Input input) override;

View file

@ -24,12 +24,10 @@
#include "guis/GuiScraperSearch.h" #include "guis/GuiScraperSearch.h"
#include "views/ViewController.h" #include "views/ViewController.h"
GuiScraperMulti::GuiScraperMulti(Window* window, GuiScraperMulti::GuiScraperMulti(const std::queue<ScraperSearchParams>& searches,
const std::queue<ScraperSearchParams>& searches,
bool approveResults) bool approveResults)
: GuiComponent {window} : mBackground {":/graphics/frame.svg"}
, mBackground {window, ":/graphics/frame.svg"} , mGrid {glm::ivec2 {2, 6}}
, mGrid {window, glm::ivec2 {2, 6}}
, mSearchQueue {searches} , mSearchQueue {searches}
, mApproveResults {approveResults} , mApproveResults {approveResults}
{ {
@ -46,27 +44,27 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
mTotalSkipped = 0; mTotalSkipped = 0;
// Set up grid. // Set up grid.
mTitle = std::make_shared<TextComponent>(mWindow, "SCRAPING IN PROGRESS", mTitle = std::make_shared<TextComponent>("SCRAPING IN PROGRESS", Font::get(FONT_SIZE_LARGE),
Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); 0x555555FF, ALIGN_CENTER);
mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2}); mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2});
mSystem = std::make_shared<TextComponent>(mWindow, "SYSTEM", Font::get(FONT_SIZE_MEDIUM), mSystem = std::make_shared<TextComponent>("SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF,
0x777777FF, ALIGN_CENTER); ALIGN_CENTER);
mGrid.setEntry(mSystem, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1}); mGrid.setEntry(mSystem, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1});
mSubtitle = std::make_shared<TextComponent>( mSubtitle = std::make_shared<TextComponent>("subtitle text", Font::get(FONT_SIZE_SMALL),
mWindow, "subtitle text", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); 0x888888FF, ALIGN_CENTER);
mGrid.setEntry(mSubtitle, glm::ivec2 {0, 3}, false, true, glm::ivec2 {2, 1}); mGrid.setEntry(mSubtitle, glm::ivec2 {0, 3}, false, true, glm::ivec2 {2, 1});
if (mApproveResults && !Settings::getInstance()->getBool("ScraperSemiautomatic")) if (mApproveResults && !Settings::getInstance()->getBool("ScraperSemiautomatic"))
mSearchComp = std::make_shared<GuiScraperSearch>( mSearchComp =
mWindow, GuiScraperSearch::NEVER_AUTO_ACCEPT, mTotalGames); std::make_shared<GuiScraperSearch>(GuiScraperSearch::NEVER_AUTO_ACCEPT, mTotalGames);
else if (mApproveResults && Settings::getInstance()->getBool("ScraperSemiautomatic")) else if (mApproveResults && Settings::getInstance()->getBool("ScraperSemiautomatic"))
mSearchComp = std::make_shared<GuiScraperSearch>( mSearchComp = std::make_shared<GuiScraperSearch>(GuiScraperSearch::ACCEPT_SINGLE_MATCHES,
mWindow, GuiScraperSearch::ACCEPT_SINGLE_MATCHES, mTotalGames); mTotalGames);
else if (!mApproveResults) else if (!mApproveResults)
mSearchComp = std::make_shared<GuiScraperSearch>( mSearchComp = std::make_shared<GuiScraperSearch>(
mWindow, GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT, mTotalGames); GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT, mTotalGames);
mSearchComp->setAcceptCallback( mSearchComp->setAcceptCallback(
std::bind(&GuiScraperMulti::acceptResult, this, std::placeholders::_1)); std::bind(&GuiScraperMulti::acceptResult, this, std::placeholders::_1));
mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this)); mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this));
@ -84,8 +82,8 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
mResultList = mSearchComp->getResultList(); mResultList = mSearchComp->getResultList();
// Set up scroll indicators. // Set up scroll indicators.
mScrollUp = std::make_shared<ImageComponent>(mWindow); mScrollUp = std::make_shared<ImageComponent>();
mScrollDown = std::make_shared<ImageComponent>(mWindow); mScrollDown = std::make_shared<ImageComponent>();
mScrollIndicator = mScrollIndicator =
std::make_shared<ScrollIndicatorComponent>(mResultList, mScrollUp, mScrollDown); std::make_shared<ScrollIndicatorComponent>(mResultList, mScrollUp, mScrollDown);
@ -102,42 +100,38 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
std::vector<std::shared_ptr<ButtonComponent>> buttons; std::vector<std::shared_ptr<ButtonComponent>> buttons;
if (mApproveResults) { if (mApproveResults) {
buttons.push_back( buttons.push_back(std::make_shared<ButtonComponent>("REFINE SEARCH", "refine search", [&] {
std::make_shared<ButtonComponent>(mWindow, "REFINE SEARCH", "refine search", [&] { // Check whether we should allow a refine of the game name.
// Check whether we should allow a refine of the game name. if (!mSearchComp->getAcceptedResult()) {
if (!mSearchComp->getAcceptedResult()) { bool allowRefine = false;
bool allowRefine = false;
// Previously refined. // Previously refined.
if (mSearchComp->getRefinedSearch()) if (mSearchComp->getRefinedSearch())
allowRefine = true; allowRefine = true;
// Interactive mode and "Auto-accept single game matches" not enabled. // Interactive mode and "Auto-accept single game matches" not enabled.
else if (mSearchComp->getSearchType() != else if (mSearchComp->getSearchType() != GuiScraperSearch::ACCEPT_SINGLE_MATCHES)
GuiScraperSearch::ACCEPT_SINGLE_MATCHES) allowRefine = true;
allowRefine = true; // Interactive mode with "Auto-accept single game matches" enabled and more
// Interactive mode with "Auto-accept single game matches" enabled and more // than one result.
// than one result. else if (mSearchComp->getSearchType() == GuiScraperSearch::ACCEPT_SINGLE_MATCHES &&
else if (mSearchComp->getSearchType() == mSearchComp->getScraperResultsSize() > 1)
GuiScraperSearch::ACCEPT_SINGLE_MATCHES && allowRefine = true;
mSearchComp->getScraperResultsSize() > 1) // Dito but there were no games found, or the search has not been completed.
allowRefine = true; else if (mSearchComp->getSearchType() == GuiScraperSearch::ACCEPT_SINGLE_MATCHES &&
// Dito but there were no games found, or the search has not been completed. !mSearchComp->getFoundGame())
else if (mSearchComp->getSearchType() == allowRefine = true;
GuiScraperSearch::ACCEPT_SINGLE_MATCHES &&
!mSearchComp->getFoundGame())
allowRefine = true;
if (allowRefine) { if (allowRefine) {
// Copy any search refine that may have been previously entered by opening // Copy any search refine that may have been previously entered by opening
// the input screen using the "Y" button shortcut. // the input screen using the "Y" button shortcut.
mSearchQueue.front().nameOverride = mSearchComp->getNameOverride(); mSearchQueue.front().nameOverride = mSearchComp->getNameOverride();
mSearchComp->openInputScreen(mSearchQueue.front()); mSearchComp->openInputScreen(mSearchQueue.front());
mGrid.resetCursor(); mGrid.resetCursor();
}
} }
})); }
}));
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "SKIP", "skip game", [&] { buttons.push_back(std::make_shared<ButtonComponent>("SKIP", "skip game", [&] {
// Skip game, unless the result has already been accepted. // Skip game, unless the result has already been accepted.
if (!mSearchComp->getAcceptedResult()) { if (!mSearchComp->getAcceptedResult()) {
skip(); skip();
@ -146,10 +140,10 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
})); }));
} }
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "STOP", "stop", buttons.push_back(std::make_shared<ButtonComponent>("STOP", "stop",
std::bind(&GuiScraperMulti::finish, this))); std::bind(&GuiScraperMulti::finish, this)));
mButtonGrid = makeButtonGrid(mWindow, buttons); mButtonGrid = makeButtonGrid(buttons);
mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1}); mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1});
// Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is // Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is
@ -309,7 +303,7 @@ void GuiScraperMulti::finish()
<< mTotalSkipped << " GAME" << ((mTotalSkipped > 1) ? "S" : "") << " SKIPPED"; << mTotalSkipped << " GAME" << ((mTotalSkipped > 1) ? "S" : "") << " SKIPPED";
} }
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), ss.str(), "OK", [&] { mWindow->pushGui(new GuiMsgBox(getHelpStyle(), ss.str(), "OK", [&] {
mIsProcessing = false; mIsProcessing = false;
delete this; delete this;
})); }));

View file

@ -25,9 +25,7 @@ class TextComponent;
class GuiScraperMulti : public GuiComponent class GuiScraperMulti : public GuiComponent
{ {
public: public:
GuiScraperMulti(Window* window, GuiScraperMulti(const std::queue<ScraperSearchParams>& searches, bool approveResults);
const std::queue<ScraperSearchParams>& searches,
bool approveResults);
virtual ~GuiScraperMulti(); virtual ~GuiScraperMulti();

View file

@ -37,15 +37,13 @@
#define FAILED_VERIFICATION_RETRIES 8 #define FAILED_VERIFICATION_RETRIES 8
GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int scrapeCount) GuiScraperSearch::GuiScraperSearch(SearchType type, unsigned int scrapeCount)
: GuiComponent {window} : mGrid {glm::ivec2 {5, 3}}
, mGrid {window, glm::ivec2 {5, 3}}
, mSearchType {type} , mSearchType {type}
, mScrapeCount {scrapeCount} , mScrapeCount {scrapeCount}
, mRefinedSearch {false} , mRefinedSearch {false}
, mFoundGame {false} , mFoundGame {false}
, mScrapeRatings {false} , mScrapeRatings {false}
, mBusyAnim {window}
{ {
addChild(&mGrid); addChild(&mGrid);
@ -55,19 +53,19 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
mRetryCount = 0; mRetryCount = 0;
// Left spacer (empty component, needed for borders). // Left spacer (empty component, needed for borders).
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {0, 0}, false, false, mGrid.setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {0, 0}, false, false,
glm::ivec2 {1, 3}, GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM); glm::ivec2 {1, 3}, GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
// Selected result name. // Selected result name.
mResultName = std::make_shared<TextComponent>(mWindow, "Result name", mResultName =
Font::get(FONT_SIZE_MEDIUM), 0x777777FF); std::make_shared<TextComponent>("Result name", Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
// Selected result thumbnail. // Selected result thumbnail.
mResultThumbnail = std::make_shared<ImageComponent>(mWindow); mResultThumbnail = std::make_shared<ImageComponent>();
mGrid.setEntry(mResultThumbnail, glm::ivec2 {1, 1}, false, false, glm::ivec2 {1, 1}); mGrid.setEntry(mResultThumbnail, glm::ivec2 {1, 1}, false, false, glm::ivec2 {1, 1});
// Selected result description and container. // Selected result description and container.
mDescContainer = std::make_shared<ScrollableContainer>(mWindow); mDescContainer = std::make_shared<ScrollableContainer>();
// Adjust the game description text scrolling parameters depending on the search type. // Adjust the game description text scrolling parameters depending on the search type.
if (mSearchType == NEVER_AUTO_ACCEPT) if (mSearchType == NEVER_AUTO_ACCEPT)
@ -75,8 +73,8 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
else else
mDescContainer->setScrollParameters(6000.0f, 3000.0f, 0.8f); mDescContainer->setScrollParameters(6000.0f, 3000.0f, 0.8f);
mResultDesc = std::make_shared<TextComponent>(mWindow, "Result desc", mResultDesc =
Font::get(FONT_SIZE_SMALL), 0x777777FF); std::make_shared<TextComponent>("Result desc", Font::get(FONT_SIZE_SMALL), 0x777777FF);
mDescContainer->addChild(mResultDesc.get()); mDescContainer->addChild(mResultDesc.get());
mDescContainer->setAutoScroll(true); mDescContainer->setAutoScroll(true);
@ -84,44 +82,42 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
auto font = Font::get(FONT_SIZE_SMALL); // Placeholder, gets replaced in onSizeChanged(). auto font = Font::get(FONT_SIZE_SMALL); // Placeholder, gets replaced in onSizeChanged().
const unsigned int mdColor = 0x777777FF; const unsigned int mdColor = 0x777777FF;
const unsigned int mdLblColor = 0x666666FF; const unsigned int mdLblColor = 0x666666FF;
mMD_Rating = std::make_shared<RatingComponent>(mWindow); mMD_Rating = std::make_shared<RatingComponent>();
mMD_ReleaseDate = std::make_shared<DateTimeEditComponent>(mWindow); mMD_ReleaseDate = std::make_shared<DateTimeEditComponent>();
mMD_ReleaseDate->setColor(mdColor); mMD_ReleaseDate->setColor(mdColor);
mMD_ReleaseDate->setUppercase(true); mMD_ReleaseDate->setUppercase(true);
mMD_Developer = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT); mMD_Developer = std::make_shared<TextComponent>("", font, mdColor, ALIGN_LEFT);
mMD_Publisher = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT); mMD_Publisher = std::make_shared<TextComponent>("", font, mdColor, ALIGN_LEFT);
mMD_Genre = mMD_Genre = std::make_shared<TextComponent>("", font, mdColor, ALIGN_LEFT, glm::vec3 {});
std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3 {}); mMD_Players = std::make_shared<TextComponent>("", font, mdColor, ALIGN_LEFT);
mMD_Players = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT); mMD_Filler = std::make_shared<TextComponent>("", font, mdColor);
mMD_Filler = std::make_shared<TextComponent>(mWindow, "", font, mdColor);
if (Settings::getInstance()->getString("Scraper") != "thegamesdb") if (Settings::getInstance()->getString("Scraper") != "thegamesdb")
mScrapeRatings = true; mScrapeRatings = true;
if (mScrapeRatings) if (mScrapeRatings)
mMD_Pairs.push_back( mMD_Pairs.push_back(MetaDataPair(
MetaDataPair(std::make_shared<TextComponent>(mWindow, "RATING:", font, mdLblColor), std::make_shared<TextComponent>("RATING:", font, mdLblColor), mMD_Rating, false));
mMD_Rating, false));
mMD_Pairs.push_back(MetaDataPair(std::make_shared<TextComponent>("RELEASED:", font, mdLblColor),
mMD_ReleaseDate));
mMD_Pairs.push_back(MetaDataPair( mMD_Pairs.push_back(MetaDataPair(
std::make_shared<TextComponent>(mWindow, "RELEASED:", font, mdLblColor), mMD_ReleaseDate)); std::make_shared<TextComponent>("DEVELOPER:", font, mdLblColor), mMD_Developer));
mMD_Pairs.push_back(MetaDataPair( mMD_Pairs.push_back(MetaDataPair(
std::make_shared<TextComponent>(mWindow, "DEVELOPER:", font, mdLblColor), mMD_Developer)); std::make_shared<TextComponent>("PUBLISHER:", font, mdLblColor), mMD_Publisher));
mMD_Pairs.push_back(MetaDataPair( mMD_Pairs.push_back(
std::make_shared<TextComponent>(mWindow, "PUBLISHER:", font, mdLblColor), mMD_Publisher)); MetaDataPair(std::make_shared<TextComponent>("GENRE:", font, mdLblColor), mMD_Genre));
mMD_Pairs.push_back(MetaDataPair( mMD_Pairs.push_back(
std::make_shared<TextComponent>(mWindow, "GENRE:", font, mdLblColor), mMD_Genre)); MetaDataPair(std::make_shared<TextComponent>("PLAYERS:", font, mdLblColor), mMD_Players));
mMD_Pairs.push_back(MetaDataPair(
std::make_shared<TextComponent>(mWindow, "PLAYERS:", font, mdLblColor), mMD_Players));
// If no rating is being scraped, add a filler to make sure that the fonts keep the same // If no rating is being scraped, add a filler to make sure that the fonts keep the same
// size so the GUI looks consistent. // size so the GUI looks consistent.
if (!mScrapeRatings) if (!mScrapeRatings)
mMD_Pairs.push_back(MetaDataPair( mMD_Pairs.push_back(
std::make_shared<TextComponent>(mWindow, "", font, mdLblColor), mMD_Filler)); MetaDataPair(std::make_shared<TextComponent>("", font, mdLblColor), mMD_Filler));
mMD_Grid = std::make_shared<ComponentGrid>( mMD_Grid =
mWindow, glm::ivec2 {2, static_cast<int>(mMD_Pairs.size() * 2 - 1)}); std::make_shared<ComponentGrid>(glm::ivec2 {2, static_cast<int>(mMD_Pairs.size() * 2 - 1)});
unsigned int i = 0; unsigned int i = 0;
for (auto it = mMD_Pairs.cbegin(); it != mMD_Pairs.cend(); ++it) { for (auto it = mMD_Pairs.cbegin(); it != mMD_Pairs.cend(); ++it) {
mMD_Grid->setEntry(it->first, glm::ivec2 {0, i}, false, true); mMD_Grid->setEntry(it->first, glm::ivec2 {0, i}, false, true);
@ -132,7 +128,7 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
mGrid.setEntry(mMD_Grid, glm::ivec2 {2, 1}, false, false); mGrid.setEntry(mMD_Grid, glm::ivec2 {2, 1}, false, false);
// Result list. // Result list.
mResultList = std::make_shared<ComponentList>(mWindow); mResultList = std::make_shared<ComponentList>();
mResultList->setCursorChangedCallback([this](CursorState state) { mResultList->setCursorChangedCallback([this](CursorState state) {
if (state == CURSOR_STOPPED) if (state == CURSOR_STOPPED)
updateInfoPane(); updateInfoPane();
@ -292,7 +288,7 @@ void GuiScraperSearch::updateViewStyle()
GridFlags::BORDER_TOP); GridFlags::BORDER_TOP);
// Need a border on the bottom left. // Need a border on the bottom left.
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {0, 2}, false, false, mGrid.setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {0, 2}, false, false,
glm::ivec2 {4, 1}, GridFlags::BORDER_BOTTOM); glm::ivec2 {4, 1}, GridFlags::BORDER_BOTTOM);
// Show description on the right. // Show description on the right.
@ -303,7 +299,7 @@ void GuiScraperSearch::updateViewStyle()
} }
else { else {
// Fake row where name would be. // Fake row where name would be.
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 0}, false, true, mGrid.setEntry(std::make_shared<GuiComponent>(), glm::ivec2 {1, 0}, false, true,
glm::ivec2 {3, 1}, GridFlags::BORDER_TOP); glm::ivec2 {3, 1}, GridFlags::BORDER_TOP);
// Show result list on the right. // Show result list on the right.
@ -364,7 +360,7 @@ void GuiScraperSearch::onSearchDone(std::vector<ScraperSearchResult>& results)
// Check if the scraper used is still valid. // Check if the scraper used is still valid.
if (!isValidConfiguredScraper()) { if (!isValidConfiguredScraper()) {
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
mWindow, getHelpStyle(), getHelpStyle(),
Utils::String::toUpper("Configured scraper is no longer available.\n" Utils::String::toUpper("Configured scraper is no longer available.\n"
"Please change the scraping source in the settings."), "Please change the scraping source in the settings."),
"FINISH", mSkipCallback)); "FINISH", mSkipCallback));
@ -372,8 +368,7 @@ void GuiScraperSearch::onSearchDone(std::vector<ScraperSearchResult>& results)
else { else {
mFoundGame = false; mFoundGame = false;
ComponentListRow row; ComponentListRow row;
row.addElement(std::make_shared<TextComponent>(mWindow, "NO GAMES FOUND", font, color), row.addElement(std::make_shared<TextComponent>("NO GAMES FOUND", font, color), true);
true);
if (mSkipCallback) if (mSkipCallback)
row.makeAcceptInputHandler(mSkipCallback); row.makeAcceptInputHandler(mSkipCallback);
@ -434,9 +429,9 @@ void GuiScraperSearch::onSearchDone(std::vector<ScraperSearchResult>& results)
gameName.append(" [").append(otherPlatforms).append("]"); gameName.append(" [").append(otherPlatforms).append("]");
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent>( row.addElement(
mWindow, Utils::String::toUpper(gameName), font, color), std::make_shared<TextComponent>(Utils::String::toUpper(gameName), font, color),
false); false);
row.makeAcceptInputHandler([this, i] { returnResult(mScraperResults.at(i)); }); row.makeAcceptInputHandler([this, i] { returnResult(mScraperResults.at(i)); });
mResultList->addRow(row); mResultList->addRow(row);
} }
@ -498,15 +493,13 @@ void GuiScraperSearch::onSearchError(const std::string& error, HttpReq::Status s
if (mScrapeCount > 1) { if (mScrapeCount > 1) {
LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", ""); LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", "");
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), Utils::String::toUpper(error), mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), "RETRY",
"RETRY",
std::bind(&GuiScraperSearch::search, this, mLastSearch), std::bind(&GuiScraperSearch::search, this, mLastSearch),
"SKIP", mSkipCallback, "CANCEL", mCancelCallback, true)); "SKIP", mSkipCallback, "CANCEL", mCancelCallback, true));
} }
else { else {
LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", ""); LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", "");
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), Utils::String::toUpper(error), mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), "RETRY",
"RETRY",
std::bind(&GuiScraperSearch::search, this, mLastSearch), std::bind(&GuiScraperSearch::search, this, mLastSearch),
"CANCEL", mCancelCallback, "", nullptr, true)); "CANCEL", mCancelCallback, "", nullptr, true));
} }
@ -899,13 +892,13 @@ void GuiScraperSearch::openInputScreen(ScraperSearchParams& params)
} }
if (Settings::getInstance()->getBool("VirtualKeyboard")) { if (Settings::getInstance()->getBool("VirtualKeyboard")) {
mWindow->pushGui(new GuiTextEditKeyboardPopup(mWindow, getHelpStyle(), "REFINE SEARCH", mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), "REFINE SEARCH", searchString,
searchString, searchForFunc, false, "SEARCH", searchForFunc, false, "SEARCH",
"SEARCH USING REFINED NAME?")); "SEARCH USING REFINED NAME?"));
} }
else { else {
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), "REFINE SEARCH", mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), "REFINE SEARCH", searchString,
searchString, searchForFunc, false, "SEARCH", searchForFunc, false, "SEARCH",
"SEARCH USING REFINED NAME?")); "SEARCH USING REFINED NAME?"));
} }
} }

View file

@ -41,7 +41,7 @@ public:
NEVER_AUTO_ACCEPT // Manual mode. NEVER_AUTO_ACCEPT // Manual mode.
}; };
GuiScraperSearch(Window* window, SearchType searchType, unsigned int scrapeCount = 1); GuiScraperSearch(SearchType searchType, unsigned int scrapeCount = 1);
~GuiScraperSearch(); ~GuiScraperSearch();
void search(const ScraperSearchParams& params); void search(const ScraperSearchParams& params);

View file

@ -18,18 +18,16 @@
#include "components/TextComponent.h" #include "components/TextComponent.h"
#include "views/ViewController.h" #include "views/ViewController.h"
GuiScraperSingle::GuiScraperSingle(Window* window, GuiScraperSingle::GuiScraperSingle(ScraperSearchParams& params,
ScraperSearchParams& params,
std::function<void(const ScraperSearchResult&)> doneFunc, std::function<void(const ScraperSearchResult&)> doneFunc,
bool& savedMediaAndAborted) bool& savedMediaAndAborted)
: GuiComponent {window} : mClose {false}
, mClose {false} , mGrid {glm::ivec2 {2, 6}}
, mGrid {window, glm::ivec2 {2, 6}} , mBackground {":/graphics/frame.svg"}
, mBox {window, ":/graphics/frame.svg"}
, mSearchParams {params} , mSearchParams {params}
, mSavedMediaAndAborted {savedMediaAndAborted} , mSavedMediaAndAborted {savedMediaAndAborted}
{ {
addChild(&mBox); addChild(&mBackground);
addChild(&mGrid); addChild(&mGrid);
std::string scrapeName; std::string scrapeName;
@ -48,29 +46,28 @@ GuiScraperSingle::GuiScraperSingle(Window* window,
} }
mGameName = std::make_shared<TextComponent>( mGameName = std::make_shared<TextComponent>(
mWindow,
scrapeName + scrapeName +
((mSearchParams.game->getType() == FOLDER) ? " " + ViewController::FOLDER_CHAR : ""), ((mSearchParams.game->getType() == FOLDER) ? " " + ViewController::FOLDER_CHAR : ""),
Font::get(FONT_SIZE_LARGE), 0x777777FF, ALIGN_CENTER); Font::get(FONT_SIZE_LARGE), 0x777777FF, ALIGN_CENTER);
mGameName->setColor(0x555555FF); mGameName->setColor(0x555555FF);
mGrid.setEntry(mGameName, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2}); mGrid.setEntry(mGameName, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2});
mSystemName = std::make_shared<TextComponent>( mSystemName =
mWindow, Utils::String::toUpper(mSearchParams.system->getFullName()), std::make_shared<TextComponent>(Utils::String::toUpper(mSearchParams.system->getFullName()),
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
mGrid.setEntry(mSystemName, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1}); mGrid.setEntry(mSystemName, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1});
// Row 3 is a spacer. // Row 3 is a spacer.
// GuiScraperSearch. // GuiScraperSearch.
mSearch = std::make_shared<GuiScraperSearch>(window, GuiScraperSearch::NEVER_AUTO_ACCEPT, 1); mSearch = std::make_shared<GuiScraperSearch>(GuiScraperSearch::NEVER_AUTO_ACCEPT, 1);
mGrid.setEntry(mSearch, glm::ivec2 {0, 4}, true, true, glm::ivec2 {2, 1}); mGrid.setEntry(mSearch, glm::ivec2 {0, 4}, true, true, glm::ivec2 {2, 1});
mResultList = mSearch->getResultList(); mResultList = mSearch->getResultList();
// Set up scroll indicators. // Set up scroll indicators.
mScrollUp = std::make_shared<ImageComponent>(mWindow); mScrollUp = std::make_shared<ImageComponent>();
mScrollDown = std::make_shared<ImageComponent>(mWindow); mScrollDown = std::make_shared<ImageComponent>();
mScrollIndicator = mScrollIndicator =
std::make_shared<ScrollIndicatorComponent>(mResultList, mScrollUp, mScrollDown); std::make_shared<ScrollIndicatorComponent>(mResultList, mScrollUp, mScrollDown);
@ -86,18 +83,17 @@ GuiScraperSingle::GuiScraperSingle(Window* window,
// Buttons // Buttons
std::vector<std::shared_ptr<ButtonComponent>> buttons; std::vector<std::shared_ptr<ButtonComponent>> buttons;
buttons.push_back( buttons.push_back(std::make_shared<ButtonComponent>("REFINE SEARCH", "refine search", [&] {
std::make_shared<ButtonComponent>(mWindow, "REFINE SEARCH", "refine search", [&] { // Refine the search, unless the result has already been accepted.
// Refine the search, unless the result has already been accepted. if (!mSearch->getAcceptedResult()) {
if (!mSearch->getAcceptedResult()) { // Copy any search refine that may have been previously entered by opening
// Copy any search refine that may have been previously entered by opening // the input screen using the "Y" button shortcut.
// the input screen using the "Y" button shortcut. mSearchParams.nameOverride = mSearch->getNameOverride();
mSearchParams.nameOverride = mSearch->getNameOverride(); mSearch->openInputScreen(mSearchParams);
mSearch->openInputScreen(mSearchParams); mGrid.resetCursor();
mGrid.resetCursor(); }
} }));
})); buttons.push_back(std::make_shared<ButtonComponent>("CANCEL", "cancel", [&] {
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CANCEL", "cancel", [&] {
if (mSearch->getSavedNewMedia()) { if (mSearch->getSavedNewMedia()) {
// If the user aborted the scraping but there was still some media downloaded, // If the user aborted the scraping but there was still some media downloaded,
// then flag to GuiMetaDataEd that the image and marquee textures need to be // then flag to GuiMetaDataEd that the image and marquee textures need to be
@ -107,7 +103,7 @@ GuiScraperSingle::GuiScraperSingle(Window* window,
} }
delete this; delete this;
})); }));
mButtonGrid = makeButtonGrid(mWindow, buttons); mButtonGrid = makeButtonGrid(buttons);
mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1}); mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1});
@ -156,7 +152,7 @@ void GuiScraperSingle::onSizeChanged()
mGrid.setColWidthPerc(1, 0.04f); mGrid.setColWidthPerc(1, 0.04f);
mGrid.setSize(glm::round(mSize)); mGrid.setSize(glm::round(mSize));
mBox.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
// Add some extra margins to the game name. // Add some extra margins to the game name.
const float newSizeX = mSize.x * 0.96f; const float newSizeX = mSize.x * 0.96f;

View file

@ -19,8 +19,7 @@
class GuiScraperSingle : public GuiComponent class GuiScraperSingle : public GuiComponent
{ {
public: public:
GuiScraperSingle(Window* window, GuiScraperSingle(ScraperSearchParams& params,
ScraperSearchParams& params,
std::function<void(const ScraperSearchResult&)> doneFunc, std::function<void(const ScraperSearchResult&)> doneFunc,
bool& savedMediaAndAborted); bool& savedMediaAndAborted);
@ -37,7 +36,7 @@ private:
void close(); void close();
ComponentGrid mGrid; ComponentGrid mGrid;
NinePatchComponent mBox; NinePatchComponent mBackground;
std::shared_ptr<TextComponent> mGameName; std::shared_ptr<TextComponent> mGameName;
std::shared_ptr<ImageComponent> mScrollUp; std::shared_ptr<ImageComponent> mScrollUp;

View file

@ -10,17 +10,17 @@
#include "guis/GuiScreensaverOptions.h" #include "guis/GuiScreensaverOptions.h"
#include "Settings.h" #include "Settings.h"
#include "Window.h"
#include "components/OptionListComponent.h" #include "components/OptionListComponent.h"
#include "components/SliderComponent.h" #include "components/SliderComponent.h"
#include "components/SwitchComponent.h" #include "components/SwitchComponent.h"
#include "guis/GuiMsgBox.h" #include "guis/GuiMsgBox.h"
GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string& title) GuiScreensaverOptions::GuiScreensaverOptions(const std::string& title)
: GuiSettings {window, title} : GuiSettings {title}
, mWindow {window}
{ {
// Screensaver timer. // Screensaver timer.
auto screensaver_timer = std::make_shared<SliderComponent>(mWindow, 0.0f, 30.0f, 1.0f, "m"); auto screensaver_timer = std::make_shared<SliderComponent>(0.0f, 30.0f, 1.0f, "m");
screensaver_timer->setValue( screensaver_timer->setValue(
static_cast<float>(Settings::getInstance()->getInt("ScreensaverTimer") / (1000 * 60))); static_cast<float>(Settings::getInstance()->getInt("ScreensaverTimer") / (1000 * 60)));
addWithLabel("START SCREENSAVER AFTER (MINUTES)", screensaver_timer); addWithLabel("START SCREENSAVER AFTER (MINUTES)", screensaver_timer);
@ -36,7 +36,7 @@ GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string&
// Screensaver type. // Screensaver type.
auto screensaver_type = std::make_shared<OptionListComponent<std::string>>( auto screensaver_type = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "SCREENSAVER TYPE", false); getHelpStyle(), "SCREENSAVER TYPE", false);
std::vector<std::string> screensavers; std::vector<std::string> screensavers;
screensavers.push_back("dim"); screensavers.push_back("dim");
screensavers.push_back("black"); screensavers.push_back("black");
@ -52,7 +52,7 @@ GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string&
if (screensaver_type->getSelected() == "video") { if (screensaver_type->getSelected() == "video") {
// If before it wasn't risky but now there's a risk of problems, show warning. // If before it wasn't risky but now there's a risk of problems, show warning.
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
mWindow, getHelpStyle(), getHelpStyle(),
"THE 'VIDEO' SCREENSAVER SHOWS\n" "THE 'VIDEO' SCREENSAVER SHOWS\n"
"VIDEOS FROM YOUR GAMELISTS\n\n" "VIDEOS FROM YOUR GAMELISTS\n\n"
"IF YOU DO NOT HAVE ANY VIDEOS, THE\n" "IF YOU DO NOT HAVE ANY VIDEOS, THE\n"
@ -65,7 +65,7 @@ GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string&
}); });
// Whether to enable screensaver controls. // Whether to enable screensaver controls.
auto screensaver_controls = std::make_shared<SwitchComponent>(mWindow); auto screensaver_controls = std::make_shared<SwitchComponent>();
screensaver_controls->setState(Settings::getInstance()->getBool("ScreensaverControls")); screensaver_controls->setState(Settings::getInstance()->getBool("ScreensaverControls"));
addWithLabel("ENABLE SCREENSAVER CONTROLS", screensaver_controls); addWithLabel("ENABLE SCREENSAVER CONTROLS", screensaver_controls);
addSaveFunc([screensaver_controls, this] { addSaveFunc([screensaver_controls, this] {
@ -80,19 +80,19 @@ GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string&
// Show filtered menu. // Show filtered menu.
ComponentListRow row; ComponentListRow row;
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, "SLIDESHOW SCREENSAVER SETTINGS", row.addElement(std::make_shared<TextComponent>("SLIDESHOW SCREENSAVER SETTINGS",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF), Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
true); true);
row.addElement(makeArrow(mWindow), false); row.addElement(makeArrow(), false);
row.makeAcceptInputHandler( row.makeAcceptInputHandler(
std::bind(&GuiScreensaverOptions::openSlideshowScreensaverOptions, this)); std::bind(&GuiScreensaverOptions::openSlideshowScreensaverOptions, this));
addRow(row); addRow(row);
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, "VIDEO SCREENSAVER SETTINGS", row.addElement(std::make_shared<TextComponent>("VIDEO SCREENSAVER SETTINGS",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF), Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
true); true);
row.addElement(makeArrow(mWindow), false); row.addElement(makeArrow(), false);
row.makeAcceptInputHandler( row.makeAcceptInputHandler(
std::bind(&GuiScreensaverOptions::openVideoScreensaverOptions, this)); std::bind(&GuiScreensaverOptions::openVideoScreensaverOptions, this));
addRow(row); addRow(row);
@ -102,11 +102,11 @@ GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string&
void GuiScreensaverOptions::openSlideshowScreensaverOptions() void GuiScreensaverOptions::openSlideshowScreensaverOptions()
{ {
auto s = new GuiSettings(mWindow, "SLIDESHOW SCREENSAVER"); auto s = new GuiSettings("SLIDESHOW SCREENSAVER");
// Timer for swapping images (in seconds). // Timer for swapping images (in seconds).
auto screensaver_swap_image_timeout = auto screensaver_swap_image_timeout =
std::make_shared<SliderComponent>(mWindow, 2.0f, 120.0f, 2.0f, "s"); std::make_shared<SliderComponent>(2.0f, 120.0f, 2.0f, "s");
screensaver_swap_image_timeout->setValue(static_cast<float>( screensaver_swap_image_timeout->setValue(static_cast<float>(
Settings::getInstance()->getInt("ScreensaverSwapImageTimeout") / (1000))); Settings::getInstance()->getInt("ScreensaverSwapImageTimeout") / (1000)));
s->addWithLabel("SWAP IMAGES AFTER (SECONDS)", screensaver_swap_image_timeout); s->addWithLabel("SWAP IMAGES AFTER (SECONDS)", screensaver_swap_image_timeout);
@ -122,7 +122,7 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions()
}); });
// Stretch images to screen resolution. // Stretch images to screen resolution.
auto screensaver_stretch_images = std::make_shared<SwitchComponent>(mWindow); auto screensaver_stretch_images = std::make_shared<SwitchComponent>();
screensaver_stretch_images->setState( screensaver_stretch_images->setState(
Settings::getInstance()->getBool("ScreensaverStretchImages")); Settings::getInstance()->getBool("ScreensaverStretchImages"));
s->addWithLabel("STRETCH IMAGES TO SCREEN RESOLUTION", screensaver_stretch_images); s->addWithLabel("STRETCH IMAGES TO SCREEN RESOLUTION", screensaver_stretch_images);
@ -136,7 +136,7 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions()
}); });
// Show game info overlay for slideshow screensaver. // Show game info overlay for slideshow screensaver.
auto screensaver_slideshow_game_info = std::make_shared<SwitchComponent>(mWindow); auto screensaver_slideshow_game_info = std::make_shared<SwitchComponent>();
screensaver_slideshow_game_info->setState( screensaver_slideshow_game_info->setState(
Settings::getInstance()->getBool("ScreensaverSlideshowGameInfo")); Settings::getInstance()->getBool("ScreensaverSlideshowGameInfo"));
s->addWithLabel("DISPLAY GAME INFO OVERLAY", screensaver_slideshow_game_info); s->addWithLabel("DISPLAY GAME INFO OVERLAY", screensaver_slideshow_game_info);
@ -151,7 +151,7 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions()
#if defined(USE_OPENGL_21) #if defined(USE_OPENGL_21)
// Render scanlines using a shader. // Render scanlines using a shader.
auto screensaver_slideshow_scanlines = std::make_shared<SwitchComponent>(mWindow); auto screensaver_slideshow_scanlines = std::make_shared<SwitchComponent>();
screensaver_slideshow_scanlines->setState( screensaver_slideshow_scanlines->setState(
Settings::getInstance()->getBool("ScreensaverSlideshowScanlines")); Settings::getInstance()->getBool("ScreensaverSlideshowScanlines"));
s->addWithLabel("RENDER SCANLINES", screensaver_slideshow_scanlines); s->addWithLabel("RENDER SCANLINES", screensaver_slideshow_scanlines);
@ -166,7 +166,7 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions()
#endif #endif
// Whether to use custom images. // Whether to use custom images.
auto screensaver_slideshow_custom_images = std::make_shared<SwitchComponent>(mWindow); auto screensaver_slideshow_custom_images = std::make_shared<SwitchComponent>();
screensaver_slideshow_custom_images->setState( screensaver_slideshow_custom_images->setState(
Settings::getInstance()->getBool("ScreensaverSlideshowCustomImages")); Settings::getInstance()->getBool("ScreensaverSlideshowCustomImages"));
s->addWithLabel("USE CUSTOM IMAGES", screensaver_slideshow_custom_images); s->addWithLabel("USE CUSTOM IMAGES", screensaver_slideshow_custom_images);
@ -180,7 +180,7 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions()
}); });
// Whether to recurse the custom image directory. // Whether to recurse the custom image directory.
auto screensaver_slideshow_recurse = std::make_shared<SwitchComponent>(mWindow); auto screensaver_slideshow_recurse = std::make_shared<SwitchComponent>();
screensaver_slideshow_recurse->setState( screensaver_slideshow_recurse->setState(
Settings::getInstance()->getBool("ScreensaverSlideshowRecurse")); Settings::getInstance()->getBool("ScreensaverSlideshowRecurse"));
s->addWithLabel("CUSTOM IMAGE DIRECTORY RECURSIVE SEARCH", screensaver_slideshow_recurse); s->addWithLabel("CUSTOM IMAGE DIRECTORY RECURSIVE SEARCH", screensaver_slideshow_recurse);
@ -194,8 +194,8 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions()
}); });
// Custom image directory. // Custom image directory.
auto screensaver_slideshow_image_dir = std::make_shared<TextComponent>( auto screensaver_slideshow_image_dir =
mWindow, "", Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_RIGHT); std::make_shared<TextComponent>("", Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_RIGHT);
s->addEditableTextComponent( s->addEditableTextComponent(
"CUSTOM IMAGE DIRECTORY", screensaver_slideshow_image_dir, "CUSTOM IMAGE DIRECTORY", screensaver_slideshow_image_dir,
Settings::getInstance()->getString("ScreensaverSlideshowImageDir"), Settings::getInstance()->getString("ScreensaverSlideshowImageDir"),
@ -215,11 +215,11 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions()
void GuiScreensaverOptions::openVideoScreensaverOptions() void GuiScreensaverOptions::openVideoScreensaverOptions()
{ {
auto s = new GuiSettings(mWindow, "VIDEO SCREENSAVER"); auto s = new GuiSettings("VIDEO SCREENSAVER");
// Timer for swapping videos (in seconds). // Timer for swapping videos (in seconds).
auto screensaver_swap_video_timeout = auto screensaver_swap_video_timeout =
std::make_shared<SliderComponent>(mWindow, 0.0f, 120.0f, 2.0f, "s"); std::make_shared<SliderComponent>(0.0f, 120.0f, 2.0f, "s");
screensaver_swap_video_timeout->setValue(static_cast<float>( screensaver_swap_video_timeout->setValue(static_cast<float>(
Settings::getInstance()->getInt("ScreensaverSwapVideoTimeout") / (1000))); Settings::getInstance()->getInt("ScreensaverSwapVideoTimeout") / (1000)));
s->addWithLabel("SWAP VIDEOS AFTER (SECONDS)", screensaver_swap_video_timeout); s->addWithLabel("SWAP VIDEOS AFTER (SECONDS)", screensaver_swap_video_timeout);
@ -235,7 +235,7 @@ void GuiScreensaverOptions::openVideoScreensaverOptions()
}); });
// Stretch videos to screen resolution. // Stretch videos to screen resolution.
auto screensaver_stretch_videos = std::make_shared<SwitchComponent>(mWindow); auto screensaver_stretch_videos = std::make_shared<SwitchComponent>();
screensaver_stretch_videos->setState( screensaver_stretch_videos->setState(
Settings::getInstance()->getBool("ScreensaverStretchVideos")); Settings::getInstance()->getBool("ScreensaverStretchVideos"));
s->addWithLabel("STRETCH VIDEOS TO SCREEN RESOLUTION", screensaver_stretch_videos); s->addWithLabel("STRETCH VIDEOS TO SCREEN RESOLUTION", screensaver_stretch_videos);
@ -249,7 +249,7 @@ void GuiScreensaverOptions::openVideoScreensaverOptions()
}); });
// Show game info overlay for video screensaver. // Show game info overlay for video screensaver.
auto screensaver_video_game_info = std::make_shared<SwitchComponent>(mWindow); auto screensaver_video_game_info = std::make_shared<SwitchComponent>();
screensaver_video_game_info->setState( screensaver_video_game_info->setState(
Settings::getInstance()->getBool("ScreensaverVideoGameInfo")); Settings::getInstance()->getBool("ScreensaverVideoGameInfo"));
s->addWithLabel("DISPLAY GAME INFO OVERLAY", screensaver_video_game_info); s->addWithLabel("DISPLAY GAME INFO OVERLAY", screensaver_video_game_info);
@ -264,7 +264,7 @@ void GuiScreensaverOptions::openVideoScreensaverOptions()
#if defined(USE_OPENGL_21) #if defined(USE_OPENGL_21)
// Render scanlines using a shader. // Render scanlines using a shader.
auto screensaver_video_scanlines = std::make_shared<SwitchComponent>(mWindow); auto screensaver_video_scanlines = std::make_shared<SwitchComponent>();
screensaver_video_scanlines->setState( screensaver_video_scanlines->setState(
Settings::getInstance()->getBool("ScreensaverVideoScanlines")); Settings::getInstance()->getBool("ScreensaverVideoScanlines"));
s->addWithLabel("RENDER SCANLINES", screensaver_video_scanlines); s->addWithLabel("RENDER SCANLINES", screensaver_video_scanlines);
@ -278,7 +278,7 @@ void GuiScreensaverOptions::openVideoScreensaverOptions()
}); });
// Render blur using a shader. // Render blur using a shader.
auto screensaver_video_blur = std::make_shared<SwitchComponent>(mWindow); auto screensaver_video_blur = std::make_shared<SwitchComponent>();
screensaver_video_blur->setState(Settings::getInstance()->getBool("ScreensaverVideoBlur")); screensaver_video_blur->setState(Settings::getInstance()->getBool("ScreensaverVideoBlur"));
s->addWithLabel("RENDER BLUR", screensaver_video_blur); s->addWithLabel("RENDER BLUR", screensaver_video_blur);
s->addSaveFunc([screensaver_video_blur, s] { s->addSaveFunc([screensaver_video_blur, s] {

View file

@ -15,11 +15,9 @@
class GuiScreensaverOptions : public GuiSettings class GuiScreensaverOptions : public GuiSettings
{ {
public: public:
GuiScreensaverOptions(Window* window, const std::string& title); GuiScreensaverOptions(const std::string& title);
private: private:
Window* mWindow;
void openSlideshowScreensaverOptions(); void openSlideshowScreensaverOptions();
void openVideoScreensaverOptions(); void openVideoScreensaverOptions();
}; };

View file

@ -21,21 +21,20 @@
#include "views/GamelistView.h" #include "views/GamelistView.h"
#include "views/ViewController.h" #include "views/ViewController.h"
GuiSettings::GuiSettings(Window* window, std::string title) GuiSettings::GuiSettings(std::string title)
: GuiComponent(window) : mMenu {title}
, mMenu(window, title) , mGoToSystem {nullptr}
, mGoToSystem(nullptr) , mNeedsSaving {false}
, mNeedsSaving(false) , mNeedsReloadHelpPrompts {false}
, mNeedsReloadHelpPrompts(false) , mNeedsCollectionsUpdate {false}
, mNeedsCollectionsUpdate(false) , mNeedsSorting {false}
, mNeedsSorting(false) , mNeedsSortingCollections {false}
, mNeedsSortingCollections(false) , mNeedsResetFilters {false}
, mNeedsResetFilters(false) , mNeedsReloading {false}
, mNeedsReloading(false) , mNeedsGoToStart {false}
, mNeedsGoToStart(false) , mNeedsGoToSystem {false}
, mNeedsGoToSystem(false) , mNeedsGoToGroupedCollections {false}
, mNeedsGoToGroupedCollections(false) , mInvalidateCachedBackground {false}
, mInvalidateCachedBackground(false)
{ {
addChild(&mMenu); addChild(&mMenu);
mMenu.addButton("BACK", "back", [this] { delete this; }); mMenu.addButton("BACK", "back", [this] { delete this; });
@ -159,17 +158,17 @@ void GuiSettings::addEditableTextComponent(const std::string label,
ComponentListRow row; ComponentListRow row;
row.elements.clear(); row.elements.clear();
auto lbl = std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(label), auto lbl = std::make_shared<TextComponent>(Utils::String::toUpper(label),
Font::get(FONT_SIZE_MEDIUM), 0x777777FF); Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
row.addElement(lbl, true); row.addElement(lbl, true);
row.addElement(ed, true); row.addElement(ed, true);
auto spacer = std::make_shared<GuiComponent>(mWindow); auto spacer = std::make_shared<GuiComponent>();
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0); spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0);
row.addElement(spacer, false); row.addElement(spacer, false);
auto bracket = std::make_shared<ImageComponent>(mWindow); auto bracket = std::make_shared<ImageComponent>();
bracket->setImage(":/graphics/arrow.svg"); bracket->setImage(":/graphics/arrow.svg");
bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()});
row.addElement(bracket, false); row.addElement(bracket, false);
@ -198,23 +197,22 @@ void GuiSettings::addEditableTextComponent(const std::string label,
row.makeAcceptInputHandler([this, label, ed, updateVal, isPassword] { row.makeAcceptInputHandler([this, label, ed, updateVal, isPassword] {
// Never display the value if it's a password, instead set it to blank. // Never display the value if it's a password, instead set it to blank.
if (isPassword) if (isPassword)
mWindow->pushGui(new GuiTextEditKeyboardPopup( mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), label, "", updateVal,
mWindow, getHelpStyle(), label, "", updateVal, false, "SAVE", "SAVE CHANGES?")); false, "SAVE", "SAVE CHANGES?"));
else else
mWindow->pushGui(new GuiTextEditKeyboardPopup(mWindow, getHelpStyle(), label, mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), label, ed->getValue(),
ed->getValue(), updateVal, false, updateVal, false, "SAVE",
"SAVE", "SAVE CHANGES?")); "SAVE CHANGES?"));
}); });
} }
else { else {
row.makeAcceptInputHandler([this, label, ed, updateVal, isPassword] { row.makeAcceptInputHandler([this, label, ed, updateVal, isPassword] {
if (isPassword) if (isPassword)
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), label, "", updateVal, mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), label, "", updateVal, false,
false, "SAVE", "SAVE CHANGES?")); "SAVE", "SAVE CHANGES?"));
else else
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), label, mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), label, ed->getValue(),
ed->getValue(), updateVal, false, "SAVE", updateVal, false, "SAVE", "SAVE CHANGES?"));
"SAVE CHANGES?"));
}); });
} }

View file

@ -18,7 +18,7 @@
class GuiSettings : public GuiComponent class GuiSettings : public GuiComponent
{ {
public: public:
GuiSettings(Window* window, std::string title); GuiSettings(std::string title);
virtual ~GuiSettings(); virtual ~GuiSettings();
void save(); void save();

View file

@ -437,7 +437,7 @@ void applicationLoop()
#endif #endif
if (SDL_PollEvent(&event)) { if (SDL_PollEvent(&event)) {
do { do {
InputManager::getInstance().parseEvent(event, window); InputManager::getInstance().parseEvent(event);
if (event.type == SDL_QUIT) if (event.type == SDL_QUIT)
#if !defined(__EMSCRIPTEN__) #if !defined(__EMSCRIPTEN__)
@ -611,7 +611,7 @@ int main(int argc, char* argv[])
bool splashScreen = Settings::getInstance()->getBool("SplashScreen"); bool splashScreen = Settings::getInstance()->getBool("SplashScreen");
bool splashScreenProgress = Settings::getInstance()->getBool("SplashScreenProgress"); bool splashScreenProgress = Settings::getInstance()->getBool("SplashScreenProgress");
InputManager::getInstance().parseEvent(event, window); InputManager::getInstance().parseEvent(event);
if (event.type == SDL_QUIT) if (event.type == SDL_QUIT)
return 1; return 1;
@ -681,7 +681,7 @@ int main(int argc, char* argv[])
if (!loadSystemsStatus) { if (!loadSystemsStatus) {
if (forceInputConfig) { if (forceInputConfig) {
window->pushGui(new GuiDetectDevice( window->pushGui(new GuiDetectDevice(
window, false, true, [] { ViewController::getInstance()->goToStart(true); })); false, true, [] { ViewController::getInstance()->goToStart(true); }));
} }
else { else {
ViewController::getInstance()->goToStart(true); ViewController::getInstance()->goToStart(true);

View file

@ -14,10 +14,8 @@
#include "guis/GuiGamelistOptions.h" #include "guis/GuiGamelistOptions.h"
#include "views/ViewController.h" #include "views/ViewController.h"
GamelistBase::GamelistBase(Window* window, FileData* root) GamelistBase::GamelistBase(FileData* root)
: GuiComponent {window} : mRoot {root}
, mRoot {root}
, mList {window}
, mRandomGame {nullptr} , mRandomGame {nullptr}
, mLastUpdated {nullptr} , mLastUpdated {nullptr}
, mGameCount {0} , mGameCount {0}
@ -460,7 +458,7 @@ bool GamelistBase::input(InputConfig* config, Input input)
config->isMappedTo("back", input) && input.value) { config->isMappedTo("back", input) && input.value) {
ViewController::getInstance()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
stopListScrolling(); stopListScrolling();
mWindow->pushGui(new GuiGamelistOptions(mWindow, this->mRoot->getSystem())); mWindow->pushGui(new GuiGamelistOptions(this->mRoot->getSystem()));
return true; return true;
} }

View file

@ -57,7 +57,7 @@ public:
const std::vector<std::string>& getFirstLetterIndex() { return mFirstLetterIndex; } const std::vector<std::string>& getFirstLetterIndex() { return mFirstLetterIndex; }
protected: protected:
GamelistBase(Window* window, FileData* root); GamelistBase(FileData* root);
~GamelistBase(); ~GamelistBase();
// Called when a FileData* is added, has its metadata changed, or is removed. // Called when a FileData* is added, has its metadata changed, or is removed.

View file

@ -15,37 +15,10 @@
#define FADE_IN_START_OPACITY 0.5f #define FADE_IN_START_OPACITY 0.5f
#define FADE_IN_TIME 650 #define FADE_IN_TIME 650
GamelistView::GamelistView(Window* window, FileData* root) GamelistView::GamelistView(FileData* root)
: GamelistBase {window, root} : GamelistBase {root}
, mViewStyle {ViewController::BASIC} , mViewStyle {ViewController::BASIC}
, mHeaderText {window} , mVideo {nullptr}
, mHeaderImage {window}
, mBackground {window}
, mThumbnail {window}
, mMarquee {window}
, mImage {window}
, mVideo(nullptr)
, mLblRating {window}
, mLblReleaseDate {window}
, mLblDeveloper {window}
, mLblPublisher {window}
, mLblGenre {window}
, mLblPlayers {window}
, mLblLastPlayed {window}
, mLblPlayCount {window}
, mRating {window}
, mReleaseDate {window}
, mDeveloper {window}
, mPublisher {window}
, mGenre {window}
, mPlayers {window}
, mLastPlayed {window}
, mPlayCount {window}
, mName {window}
, mBadges {window}
, mDescContainer {window}
, mDescription {window}
, mGamelistInfo {window}
{ {
mViewStyle = ViewController::getInstance()->getState().viewstyle; mViewStyle = ViewController::getInstance()->getState().viewstyle;
@ -72,7 +45,7 @@ GamelistView::GamelistView(Window* window, FileData* root)
if (mViewStyle == ViewController::VIDEO) { if (mViewStyle == ViewController::VIDEO) {
// Create the video window. // Create the video window.
mVideo = new VideoFFmpegComponent(window); mVideo = new VideoFFmpegComponent;
} }
mList.setPosition(mSize.x * (0.50f + padding), mList.getPosition().y); mList.setPosition(mSize.x * (0.50f + padding), mList.getPosition().y);
@ -235,7 +208,7 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
mThemeExtras.clear(); mThemeExtras.clear();
// Add new theme extras. // Add new theme extras.
mThemeExtras = ThemeData::makeExtras(theme, getName(), mWindow); mThemeExtras = ThemeData::makeExtras(theme, getName());
for (auto extra : mThemeExtras) for (auto extra : mThemeExtras)
addChild(extra); addChild(extra);
@ -304,8 +277,6 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
void GamelistView::update(int deltaTime) void GamelistView::update(int deltaTime)
{ {
mImage.update(deltaTime);
if (ViewController::getInstance()->getGameLaunchTriggered() && mImage.isAnimationPlaying(0)) if (ViewController::getInstance()->getGameLaunchTriggered() && mImage.isAnimationPlaying(0))
mImage.finishAnimation(0); mImage.finishAnimation(0);
@ -315,12 +286,12 @@ void GamelistView::update(int deltaTime)
else if (mVideoPlaying && !mVideo->isVideoPaused() && !mWindow->isScreensaverActive()) else if (mVideoPlaying && !mVideo->isVideoPaused() && !mWindow->isScreensaverActive())
mVideo->onShow(); mVideo->onShow();
mVideo->update(deltaTime);
if (ViewController::getInstance()->getGameLaunchTriggered() && if (ViewController::getInstance()->getGameLaunchTriggered() &&
mVideo->isAnimationPlaying(0)) mVideo->isAnimationPlaying(0))
mVideo->finishAnimation(0); mVideo->finishAnimation(0);
} }
updateChildren(deltaTime);
} }
void GamelistView::render(const glm::mat4& parentTrans) void GamelistView::render(const glm::mat4& parentTrans)

View file

@ -17,7 +17,7 @@
class GamelistView : public GamelistBase class GamelistView : public GamelistBase
{ {
public: public:
GamelistView(Window* window, FileData* root); GamelistView(FileData* root);
~GamelistView(); ~GamelistView();
// Called when a FileData* is added, has its metadata changed, or is removed. // Called when a FileData* is added, has its metadata changed, or is removed.

View file

@ -22,13 +22,17 @@
#include <cmath> #include <cmath>
#endif #endif
// Buffer values for scrolling velocity (left, stopped, right). namespace
const int logoBuffersLeft[] = {-5, -2, -1}; {
const int logoBuffersRight[] = {1, 2, 5}; // Buffer values for scrolling velocity (left, stopped, right).
const int logoBuffersLeft[] = {-5, -2, -1};
const int logoBuffersRight[] = {1, 2, 5};
SystemView::SystemView(Window* window) } // namespace
: IList<SystemViewData, SystemData*> {window, LIST_SCROLL_STYLE_SLOW, LIST_ALWAYS_LOOP}
, mSystemInfo {window, "SYSTEM INFO", Font::get(FONT_SIZE_SMALL), 0x33333300, ALIGN_CENTER} SystemView::SystemView()
: IList<SystemViewData, SystemData*> {LIST_SCROLL_STYLE_SLOW, LIST_ALWAYS_LOOP}
, mSystemInfo {"SYSTEM INFO", Font::get(FONT_SIZE_SMALL), 0x33333300, ALIGN_CENTER}
, mPreviousScrollVelocity {0} , mPreviousScrollVelocity {0}
, mUpdatedGameCount {false} , mUpdatedGameCount {false}
, mViewNeedsReload {true} , mViewNeedsReload {true}
@ -80,7 +84,7 @@ void SystemView::populate()
if ((!path.empty() && ResourceManager::getInstance().fileExists(path)) || if ((!path.empty() && ResourceManager::getInstance().fileExists(path)) ||
(!defaultPath.empty() && (!defaultPath.empty() &&
ResourceManager::getInstance().fileExists(defaultPath))) { ResourceManager::getInstance().fileExists(defaultPath))) {
auto* logo = new ImageComponent(mWindow, false, false); auto* logo = new ImageComponent(false, false);
logo->setMaxSize(glm::round(mCarousel.logoSize * mCarousel.logoScale)); logo->setMaxSize(glm::round(mCarousel.logoSize * mCarousel.logoScale));
logo->applyTheme(theme, "system", "logo", ThemeFlags::PATH | ThemeFlags::COLOR); logo->applyTheme(theme, "system", "logo", ThemeFlags::PATH | ThemeFlags::COLOR);
logo->setRotateByTargetSize(true); logo->setRotateByTargetSize(true);
@ -104,7 +108,7 @@ void SystemView::populate()
if ((!path.empty() && ResourceManager::getInstance().fileExists(path)) || if ((!path.empty() && ResourceManager::getInstance().fileExists(path)) ||
(!defaultPath.empty() && (!defaultPath.empty() &&
ResourceManager::getInstance().fileExists(defaultPath))) { ResourceManager::getInstance().fileExists(defaultPath))) {
auto* logo = new ImageComponent(mWindow, false, false); auto* logo = new ImageComponent(false, false);
logo->applyTheme(theme, "system", "logoPlaceholderImage", ThemeFlags::ALL); logo->applyTheme(theme, "system", "logoPlaceholderImage", ThemeFlags::ALL);
if (!logoElem->has("size")) if (!logoElem->has("size"))
logo->setMaxSize(mCarousel.logoSize * mCarousel.logoScale); logo->setMaxSize(mCarousel.logoSize * mCarousel.logoScale);
@ -119,9 +123,8 @@ void SystemView::populate()
theme->getElement("system", "logoPlaceholderText", "text"); theme->getElement("system", "logoPlaceholderText", "text");
if (logoPlaceholderText) { if (logoPlaceholderText) {
// Element 'logoPlaceholderText' found in theme: place text // Element 'logoPlaceholderText' found in theme: place text
auto* text = auto* text = new TextComponent(it->getName(), Font::get(FONT_SIZE_LARGE),
new TextComponent(mWindow, it->getName(), Font::get(FONT_SIZE_LARGE), 0x000000FF, ALIGN_CENTER);
0x000000FF, ALIGN_CENTER);
text->setSize(mCarousel.logoSize * mCarousel.logoScale); text->setSize(mCarousel.logoSize * mCarousel.logoScale);
if (mCarousel.type == VERTICAL || mCarousel.type == VERTICAL_WHEEL) { if (mCarousel.type == VERTICAL || mCarousel.type == VERTICAL_WHEEL) {
text->setHorizontalAlignment(mCarousel.logoAlignment); text->setHorizontalAlignment(mCarousel.logoAlignment);
@ -144,9 +147,8 @@ void SystemView::populate()
} }
else { else {
// Fallback to legacy centered placeholder text. // Fallback to legacy centered placeholder text.
auto* text = auto* text = new TextComponent(it->getName(), Font::get(FONT_SIZE_LARGE),
new TextComponent(mWindow, it->getName(), Font::get(FONT_SIZE_LARGE), 0x000000FF, ALIGN_CENTER);
0x000000FF, ALIGN_CENTER);
text->setSize(mCarousel.logoSize * mCarousel.logoScale); text->setSize(mCarousel.logoSize * mCarousel.logoScale);
text->applyTheme(it->getTheme(), "system", "logoText", text->applyTheme(it->getTheme(), "system", "logoText",
ThemeFlags::FONT_PATH | ThemeFlags::FONT_SIZE | ThemeFlags::FONT_PATH | ThemeFlags::FONT_SIZE |
@ -189,7 +191,7 @@ void SystemView::populate()
e.data.logoPlaceholderText->setPosition(v + offsetLogoPlaceholderText); e.data.logoPlaceholderText->setPosition(v + offsetLogoPlaceholderText);
// Make background extras. // Make background extras.
e.data.backgroundExtras = ThemeData::makeExtras(it->getTheme(), "system", mWindow); e.data.backgroundExtras = ThemeData::makeExtras(it->getTheme(), "system");
// Sort the extras by z-index. // Sort the extras by z-index.
std::stable_sort( std::stable_sort(
@ -204,7 +206,7 @@ void SystemView::populate()
if (!UIModeController::getInstance()->isUIModeFull()) { if (!UIModeController::getInstance()->isUIModeFull()) {
Settings::getInstance()->setString("UIMode", "full"); Settings::getInstance()->setString("UIMode", "full");
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
mWindow, getHelpStyle(), getHelpStyle(),
"The selected UI mode has nothing to show,\n returning to UI mode \"Full\"", "OK", "The selected UI mode has nothing to show,\n returning to UI mode \"Full\"", "OK",
nullptr)); nullptr));
} }

View file

@ -17,7 +17,6 @@
#include <memory> #include <memory>
class AnimatedImageComponent;
class SystemData; class SystemData;
enum CarouselType : unsigned int { enum CarouselType : unsigned int {
@ -54,7 +53,7 @@ struct SystemViewCarousel {
class SystemView : public IList<SystemViewData, SystemData*> class SystemView : public IList<SystemViewData, SystemData*>
{ {
public: public:
SystemView(Window* window); SystemView();
~SystemView(); ~SystemView();
void onShow() override { mShowing = true; } void onShow() override { mShowing = true; }

View file

@ -30,15 +30,8 @@
#include "views/GamelistView.h" #include "views/GamelistView.h"
#include "views/SystemView.h" #include "views/SystemView.h"
ViewController* ViewController::getInstance()
{
static ViewController instance;
return &instance;
}
ViewController::ViewController() noexcept ViewController::ViewController() noexcept
: GuiComponent {Window::getInstance()} : mNoGamesMessageBox {nullptr}
, mNoGamesMessageBox {nullptr}
, mCurrentView {nullptr} , mCurrentView {nullptr}
, mPreviousView {nullptr} , mPreviousView {nullptr}
, mSkipView {nullptr} , mSkipView {nullptr}
@ -55,6 +48,12 @@ ViewController::ViewController() noexcept
mState.viewstyle = AUTOMATIC; mState.viewstyle = AUTOMATIC;
} }
ViewController* ViewController::getInstance()
{
static ViewController instance;
return &instance;
}
void ViewController::invalidSystemsFileDialog() void ViewController::invalidSystemsFileDialog()
{ {
std::string errorMessage = "COULDN'T PARSE THE SYSTEMS CONFIGURATION FILE.\n" std::string errorMessage = "COULDN'T PARSE THE SYSTEMS CONFIGURATION FILE.\n"
@ -65,7 +64,7 @@ void ViewController::invalidSystemsFileDialog()
"APPLICATION LOG FILE es_log.txt FOR ADDITIONAL INFO."; "APPLICATION LOG FILE es_log.txt FOR ADDITIONAL INFO.";
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
mWindow, HelpStyle(), errorMessage.c_str(), "QUIT", HelpStyle(), errorMessage.c_str(), "QUIT",
[] { [] {
SDL_Event quit; SDL_Event quit;
quit.type = SDL_QUIT; quit.type = SDL_QUIT;
@ -91,7 +90,7 @@ void ViewController::noGamesDialog()
#endif #endif
mNoGamesMessageBox = new GuiMsgBox( mNoGamesMessageBox = new GuiMsgBox(
mWindow, HelpStyle(), mNoGamesErrorMessage + mRomDirectory, "CHANGE ROM DIRECTORY", HelpStyle(), mNoGamesErrorMessage + mRomDirectory, "CHANGE ROM DIRECTORY",
[this] { [this] {
std::string currentROMDirectory; std::string currentROMDirectory;
#if defined(_WIN64) #if defined(_WIN64)
@ -101,7 +100,7 @@ void ViewController::noGamesDialog()
#endif #endif
if (Settings::getInstance()->getBool("VirtualKeyboard")) { if (Settings::getInstance()->getBool("VirtualKeyboard")) {
mWindow->pushGui(new GuiTextEditKeyboardPopup( mWindow->pushGui(new GuiTextEditKeyboardPopup(
mWindow, HelpStyle(), "ENTER ROM DIRECTORY PATH", currentROMDirectory, HelpStyle(), "ENTER ROM DIRECTORY PATH", currentROMDirectory,
[this](const std::string& newROMDirectory) { [this](const std::string& newROMDirectory) {
Settings::getInstance()->setString("ROMDirectory", Settings::getInstance()->setString("ROMDirectory",
Utils::String::trim(newROMDirectory)); Utils::String::trim(newROMDirectory));
@ -113,7 +112,7 @@ void ViewController::noGamesDialog()
mRomDirectory = FileData::getROMDirectory(); mRomDirectory = FileData::getROMDirectory();
#endif #endif
mNoGamesMessageBox->changeText(mNoGamesErrorMessage + mRomDirectory); mNoGamesMessageBox->changeText(mNoGamesErrorMessage + mRomDirectory);
mWindow->pushGui(new GuiMsgBox(mWindow, HelpStyle(), mWindow->pushGui(new GuiMsgBox(HelpStyle(),
"ROM DIRECTORY SETTING SAVED, RESTART\n" "ROM DIRECTORY SETTING SAVED, RESTART\n"
"THE APPLICATION TO RESCAN THE SYSTEMS", "THE APPLICATION TO RESCAN THE SYSTEMS",
"OK", nullptr, "", nullptr, "", nullptr, "OK", nullptr, "", nullptr, "", nullptr,
@ -125,7 +124,7 @@ void ViewController::noGamesDialog()
} }
else { else {
mWindow->pushGui(new GuiTextEditPopup( mWindow->pushGui(new GuiTextEditPopup(
mWindow, HelpStyle(), "ENTER ROM DIRECTORY PATH", currentROMDirectory, HelpStyle(), "ENTER ROM DIRECTORY PATH", currentROMDirectory,
[this](const std::string& newROMDirectory) { [this](const std::string& newROMDirectory) {
Settings::getInstance()->setString("ROMDirectory", Settings::getInstance()->setString("ROMDirectory",
Utils::String::trim(newROMDirectory)); Utils::String::trim(newROMDirectory));
@ -137,7 +136,7 @@ void ViewController::noGamesDialog()
mRomDirectory = FileData::getROMDirectory(); mRomDirectory = FileData::getROMDirectory();
#endif #endif
mNoGamesMessageBox->changeText(mNoGamesErrorMessage + mRomDirectory); mNoGamesMessageBox->changeText(mNoGamesErrorMessage + mRomDirectory);
mWindow->pushGui(new GuiMsgBox(mWindow, HelpStyle(), mWindow->pushGui(new GuiMsgBox(HelpStyle(),
"ROM DIRECTORY SETTING SAVED, RESTART\n" "ROM DIRECTORY SETTING SAVED, RESTART\n"
"THE APPLICATION TO RESCAN THE SYSTEMS", "THE APPLICATION TO RESCAN THE SYSTEMS",
"OK", nullptr, "", nullptr, "", nullptr, "OK", nullptr, "", nullptr, "", nullptr,
@ -151,7 +150,7 @@ void ViewController::noGamesDialog()
"CREATE DIRECTORIES", "CREATE DIRECTORIES",
[this] { [this] {
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
mWindow, HelpStyle(), HelpStyle(),
"THIS WILL CREATE DIRECTORIES FOR ALL THE\n" "THIS WILL CREATE DIRECTORIES FOR ALL THE\n"
"GAME SYSTEMS DEFINED IN es_systems.xml\n\n" "GAME SYSTEMS DEFINED IN es_systems.xml\n\n"
"THIS MAY CREATE A LOT OF FOLDERS SO IT'S\n" "THIS MAY CREATE A LOT OF FOLDERS SO IT'S\n"
@ -160,7 +159,7 @@ void ViewController::noGamesDialog()
"YES", "YES",
[this] { [this] {
if (!SystemData::createSystemDirectories()) { if (!SystemData::createSystemDirectories()) {
mWindow->pushGui(new GuiMsgBox(mWindow, HelpStyle(), mWindow->pushGui(new GuiMsgBox(HelpStyle(),
"THE SYSTEM DIRECTORIES WERE SUCCESSFULLY\n" "THE SYSTEM DIRECTORIES WERE SUCCESSFULLY\n"
"GENERATED, EXIT THE APPLICATION AND PLACE\n" "GENERATED, EXIT THE APPLICATION AND PLACE\n"
"YOUR GAMES IN THE NEWLY CREATED FOLDERS", "YOUR GAMES IN THE NEWLY CREATED FOLDERS",
@ -168,7 +167,7 @@ void ViewController::noGamesDialog()
true)); true));
} }
else { else {
mWindow->pushGui(new GuiMsgBox(mWindow, HelpStyle(), mWindow->pushGui(new GuiMsgBox(HelpStyle(),
"ERROR CREATING THE SYSTEM DIRECTORIES,\n" "ERROR CREATING THE SYSTEM DIRECTORIES,\n"
"PERMISSION PROBLEMS OR DISK FULL?\n\n" "PERMISSION PROBLEMS OR DISK FULL?\n\n"
"SEE THE LOG FILE FOR MORE DETAILS", "SEE THE LOG FILE FOR MORE DETAILS",
@ -191,13 +190,12 @@ void ViewController::noGamesDialog()
void ViewController::invalidAlternativeEmulatorDialog() void ViewController::invalidAlternativeEmulatorDialog()
{ {
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), mWindow->pushGui(new GuiMsgBox(getHelpStyle(), "AT LEAST ONE OF YOUR SYSTEMS HAS AN\n"
"AT LEAST ONE OF YOUR SYSTEMS HAS AN\n" "INVALID ALTERNATIVE EMULATOR CONFIGURED\n"
"INVALID ALTERNATIVE EMULATOR CONFIGURED\n" "WITH NO MATCHING ENTRY IN THE SYSTEMS\n"
"WITH NO MATCHING ENTRY IN THE SYSTEMS\n" "CONFIGURATION FILE, PLEASE REVIEW YOUR\n"
"CONFIGURATION FILE, PLEASE REVIEW YOUR\n" "SETUP USING THE 'ALTERNATIVE EMULATORS'\n"
"SETUP USING THE 'ALTERNATIVE EMULATORS'\n" "INTERFACE IN THE 'OTHER SETTINGS' MENU"));
"INTERFACE IN THE 'OTHER SETTINGS' MENU"));
} }
void ViewController::goToStart(bool playTransition) void ViewController::goToStart(bool playTransition)
@ -694,7 +692,7 @@ void ViewController::launch(FileData* game)
// to be displayed briefly, and for the navigation sound playing to be able to complete. // to be displayed briefly, and for the navigation sound playing to be able to complete.
// During this time period, all user input is blocked. // During this time period, all user input is blocked.
setAnimation(new LambdaAnimation([](float t) {}, duration), 0, [this, game] { setAnimation(new LambdaAnimation([](float t) {}, duration), 0, [this, game] {
game->launchGame(mWindow); game->launchGame();
// If the launch screen is disabled then this will do nothing. // If the launch screen is disabled then this will do nothing.
mWindow->closeLaunchScreen(); mWindow->closeLaunchScreen();
onFileChanged(game, true); onFileChanged(game, true);
@ -769,7 +767,7 @@ std::shared_ptr<GamelistView> ViewController::getGamelistView(SystemData* system
} }
} }
view = std::shared_ptr<GamelistView>(new GamelistView(mWindow, system->getRootFolder())); view = std::shared_ptr<GamelistView>(new GamelistView(system->getRootFolder()));
view->setTheme(system->getTheme()); view->setTheme(system->getTheme());
@ -790,7 +788,7 @@ std::shared_ptr<SystemView> ViewController::getSystemListView()
if (mSystemListView) if (mSystemListView)
return mSystemListView; return mSystemListView;
mSystemListView = std::shared_ptr<SystemView>(new SystemView(mWindow)); mSystemListView = std::shared_ptr<SystemView>(new SystemView);
addChild(mSystemListView.get()); addChild(mSystemListView.get());
mSystemListView->setPosition(0, static_cast<float>(Renderer::getScreenHeight())); mSystemListView->setPosition(0, static_cast<float>(Renderer::getScreenHeight()));
return mSystemListView; return mSystemListView;
@ -835,7 +833,7 @@ bool ViewController::input(InputConfig* config, Input input)
// Finally, if the camera is currently moving, reset its position. // Finally, if the camera is currently moving, reset its position.
cancelViewTransitions(); cancelViewTransitions();
mWindow->pushGui(new GuiMenu(mWindow)); mWindow->pushGui(new GuiMenu);
return true; return true;
} }

View file

@ -16,8 +16,8 @@
#include <algorithm> #include <algorithm>
GuiComponent::GuiComponent(Window* window) GuiComponent::GuiComponent()
: mWindow {window} : mWindow {Window::getInstance()}
, mParent {nullptr} , mParent {nullptr}
, mOpacity {255} , mOpacity {255}
, mColor {0} , mColor {0}

View file

@ -37,7 +37,7 @@ class Window;
class GuiComponent class GuiComponent
{ {
public: public:
GuiComponent(Window* window); GuiComponent();
virtual ~GuiComponent(); virtual ~GuiComponent();
virtual void textInput(const std::string& text); virtual void textInput(const std::string& text);

View file

@ -21,10 +21,10 @@ std::map<CURL*, HttpReq*> HttpReq::s_requests;
std::string HttpReq::urlEncode(const std::string& s) std::string HttpReq::urlEncode(const std::string& s)
{ {
const std::string unreserved = const std::string unreserved {
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~"};
std::string escaped = ""; std::string escaped {""};
for (size_t i = 0; i < s.length(); ++i) { for (size_t i = 0; i < s.length(); ++i) {
if (unreserved.find_first_of(s[i]) != std::string::npos) { if (unreserved.find_first_of(s[i]) != std::string::npos) {
escaped.push_back(s[i]); escaped.push_back(s[i]);

View file

@ -28,11 +28,12 @@ int SDL_USER_CECBUTTONDOWN = -1;
int SDL_USER_CECBUTTONUP = -1; int SDL_USER_CECBUTTONUP = -1;
// Save button states for combo-button exit support and predefine exit option-function map. // Save button states for combo-button exit support and predefine exit option-function map.
static bool sAltDown = false; static bool sAltDown {false};
static bool sLguiDown = false; static bool sLguiDown {false};
InputManager::InputManager() noexcept InputManager::InputManager() noexcept
: mKeyboardInputConfig(nullptr) : mWindow {Window::getInstance()}
, mKeyboardInputConfig {nullptr}
{ {
} }
@ -331,7 +332,7 @@ InputConfig* InputManager::getInputConfigByDevice(int device)
return mInputConfigs[device].get(); return mInputConfigs[device].get();
} }
bool InputManager::parseEvent(const SDL_Event& event, Window* window) bool InputManager::parseEvent(const SDL_Event& event)
{ {
bool causedEvent = false; bool causedEvent = false;
int32_t axisValue; int32_t axisValue;
@ -380,7 +381,7 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window)
normValue = -1; normValue = -1;
} }
window->input( mWindow->input(
getInputConfigByDevice(event.caxis.which), getInputConfigByDevice(event.caxis.which),
Input(event.caxis.which, TYPE_AXIS, event.caxis.axis, normValue, false)); Input(event.caxis.which, TYPE_AXIS, event.caxis.axis, normValue, false));
causedEvent = true; causedEvent = true;
@ -410,9 +411,9 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window)
mPrevButtonValues[std::make_pair(event.cbutton.which, event.cbutton.button)] = mPrevButtonValues[std::make_pair(event.cbutton.which, event.cbutton.button)] =
event.cbutton.state; event.cbutton.state;
window->input(getInputConfigByDevice(event.cbutton.which), mWindow->input(getInputConfigByDevice(event.cbutton.which),
Input(event.cbutton.which, TYPE_BUTTON, event.cbutton.button, Input(event.cbutton.which, TYPE_BUTTON, event.cbutton.button,
event.cbutton.state == SDL_PRESSED, false)); event.cbutton.state == SDL_PRESSED, false));
return true; return true;
} }
@ -425,7 +426,7 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window)
sLguiDown = true; sLguiDown = true;
if (event.key.keysym.sym == SDLK_BACKSPACE && SDL_IsTextInputActive()) if (event.key.keysym.sym == SDLK_BACKSPACE && SDL_IsTextInputActive())
window->textInput("\b"); mWindow->textInput("\b");
if (event.key.repeat) if (event.key.repeat)
return false; return false;
@ -448,8 +449,8 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window)
return false; return false;
} }
window->input(getInputConfigByDevice(DEVICE_KEYBOARD), mWindow->input(getInputConfigByDevice(DEVICE_KEYBOARD),
Input(DEVICE_KEYBOARD, TYPE_KEY, event.key.keysym.sym, 1, false)); Input(DEVICE_KEYBOARD, TYPE_KEY, event.key.keysym.sym, 1, false));
return true; return true;
} }
case SDL_KEYUP: { case SDL_KEYUP: {
@ -460,30 +461,30 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window)
if (event.key.keysym.sym == SDLK_LGUI) if (event.key.keysym.sym == SDLK_LGUI)
sLguiDown = false; sLguiDown = false;
window->input(getInputConfigByDevice(DEVICE_KEYBOARD), mWindow->input(getInputConfigByDevice(DEVICE_KEYBOARD),
Input(DEVICE_KEYBOARD, TYPE_KEY, event.key.keysym.sym, 0, false)); Input(DEVICE_KEYBOARD, TYPE_KEY, event.key.keysym.sym, 0, false));
return true; return true;
} }
case SDL_TEXTINPUT: { case SDL_TEXTINPUT: {
window->textInput(event.text.text); mWindow->textInput(event.text.text);
break; break;
} }
case SDL_CONTROLLERDEVICEADDED: { case SDL_CONTROLLERDEVICEADDED: {
addControllerByDeviceIndex(window, event.cdevice.which); addControllerByDeviceIndex(mWindow, event.cdevice.which);
return true; return true;
} }
case SDL_CONTROLLERDEVICEREMOVED: { case SDL_CONTROLLERDEVICEREMOVED: {
removeControllerByJoystickID(window, event.cdevice.which); removeControllerByJoystickID(mWindow, event.cdevice.which);
return false; return false;
} }
} }
if ((event.type == static_cast<unsigned int>(SDL_USER_CECBUTTONDOWN)) || if ((event.type == static_cast<unsigned int>(SDL_USER_CECBUTTONDOWN)) ||
(event.type == static_cast<unsigned int>(SDL_USER_CECBUTTONUP))) { (event.type == static_cast<unsigned int>(SDL_USER_CECBUTTONUP))) {
window->input(getInputConfigByDevice(DEVICE_CEC), mWindow->input(getInputConfigByDevice(DEVICE_CEC),
Input(DEVICE_CEC, TYPE_CEC_BUTTON, event.user.code, Input(DEVICE_CEC, TYPE_CEC_BUTTON, event.user.code,
event.type == static_cast<unsigned int>(SDL_USER_CECBUTTONDOWN), event.type == static_cast<unsigned int>(SDL_USER_CECBUTTONDOWN),
false)); false));
return true; return true;
} }

View file

@ -45,7 +45,7 @@ public:
std::string getDeviceGUIDString(int deviceId); std::string getDeviceGUIDString(int deviceId);
InputConfig* getInputConfigByDevice(int deviceId); InputConfig* getInputConfigByDevice(int deviceId);
bool parseEvent(const SDL_Event& event, Window* window); bool parseEvent(const SDL_Event& event);
int getNumJoysticks() { return static_cast<int>(mJoysticks.size()); } int getNumJoysticks() { return static_cast<int>(mJoysticks.size()); }
@ -62,6 +62,7 @@ private:
void addControllerByDeviceIndex(Window* window, int deviceIndex); void addControllerByDeviceIndex(Window* window, int deviceIndex);
void removeControllerByJoystickID(Window* window, SDL_JoystickID joyID); void removeControllerByJoystickID(Window* window, SDL_JoystickID joyID);
Window* mWindow;
CECInput mCECInput; CECInput mCECInput;
static const int DEADZONE_TRIGGERS = 18000; static const int DEADZONE_TRIGGERS = 18000;

View file

@ -26,7 +26,7 @@ MameNames& MameNames::getInstance()
MameNames::MameNames() MameNames::MameNames()
{ {
std::string xmlpath = ResourceManager::getInstance().getResourcePath(":/MAME/mamenames.xml"); std::string xmlpath {ResourceManager::getInstance().getResourcePath(":/MAME/mamenames.xml")};
if (!Utils::FileSystem::exists(xmlpath)) if (!Utils::FileSystem::exists(xmlpath))
return; return;

View file

@ -644,8 +644,7 @@ const std::shared_ptr<ThemeData> ThemeData::getDefault()
} }
std::vector<GuiComponent*> ThemeData::makeExtras(const std::shared_ptr<ThemeData>& theme, std::vector<GuiComponent*> ThemeData::makeExtras(const std::shared_ptr<ThemeData>& theme,
const std::string& view, const std::string& view)
Window* window)
{ {
std::vector<GuiComponent*> comps; std::vector<GuiComponent*> comps;
@ -655,16 +654,16 @@ std::vector<GuiComponent*> ThemeData::makeExtras(const std::shared_ptr<ThemeData
for (auto it = viewIt->second.orderedKeys.cbegin(); // Line break. for (auto it = viewIt->second.orderedKeys.cbegin(); // Line break.
it != viewIt->second.orderedKeys.cend(); ++it) { it != viewIt->second.orderedKeys.cend(); ++it) {
ThemeElement& elem = viewIt->second.elements.at(*it); ThemeElement& elem {viewIt->second.elements.at(*it)};
if (elem.extra) { if (elem.extra) {
GuiComponent* comp = nullptr; GuiComponent* comp {nullptr};
const std::string& t = elem.type; const std::string& t {elem.type};
if (t == "image") if (t == "image")
comp = new ImageComponent(window); comp = new ImageComponent;
else if (t == "text") else if (t == "text")
comp = new TextComponent(window); comp = new TextComponent;
else if (t == "animation") else if (t == "animation")
comp = new LottieComponent(window); comp = new LottieComponent;
if (comp) { if (comp) {
comp->setDefaultZIndex(10.0f); comp->setDefaultZIndex(10.0f);

View file

@ -196,8 +196,7 @@ public:
const std::string& expectedType) const; const std::string& expectedType) const;
static std::vector<GuiComponent*> makeExtras(const std::shared_ptr<ThemeData>& theme, static std::vector<GuiComponent*> makeExtras(const std::shared_ptr<ThemeData>& theme,
const std::string& view, const std::string& view);
Window* window);
static const std::shared_ptr<ThemeData> getDefault(); static const std::shared_ptr<ThemeData> getDefault();

View file

@ -119,8 +119,8 @@ bool Window::init()
ResourceManager::getInstance().reloadAll(); ResourceManager::getInstance().reloadAll();
mHelp = new HelpComponent(this); mHelp = new HelpComponent;
mBackgroundOverlay = new ImageComponent(this); mBackgroundOverlay = new ImageComponent;
mBackgroundOverlayOpacity = 0; mBackgroundOverlayOpacity = 0;
// Keep a reference to the default fonts, so they don't keep getting destroyed/recreated. // Keep a reference to the default fonts, so they don't keep getting destroyed/recreated.
@ -367,8 +367,8 @@ void Window::update(int deltaTime)
if (!popupIsRunning) { if (!popupIsRunning) {
delete mInfoPopup; delete mInfoPopup;
mInfoPopup = new GuiInfoPopup(this, mInfoPopupQueue.front().first, mInfoPopup =
mInfoPopupQueue.front().second); new GuiInfoPopup(mInfoPopupQueue.front().first, mInfoPopupQueue.front().second);
mInfoPopupQueue.pop(); mInfoPopupQueue.pop();
} }
} }
@ -618,7 +618,7 @@ void Window::renderLoadingScreen(std::string text)
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()), Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF); static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
ImageComponent splash(this, true); ImageComponent splash(true);
splash.setImage(":/graphics/splash.svg"); splash.setImage(":/graphics/splash.svg");
splash.setResize(Renderer::getScreenWidth() * 0.6f, 0.0f); splash.setResize(Renderer::getScreenWidth() * 0.6f, 0.0f);
splash.setPosition((Renderer::getScreenWidth() - splash.getSize().x) / 2.0f, splash.setPosition((Renderer::getScreenWidth() - splash.getSize().x) / 2.0f,
@ -723,7 +723,7 @@ void Window::reloadHelpPrompts()
{ {
if (mHelp) { if (mHelp) {
delete mHelp; delete mHelp;
mHelp = new HelpComponent(this); mHelp = new HelpComponent;
} }
} }

View file

@ -19,8 +19,8 @@ class LambdaAnimation : public Animation
{ {
public: public:
LambdaAnimation(const std::function<void(float t)>& func, int duration) LambdaAnimation(const std::function<void(float t)>& func, int duration)
: mFunction(func) : mFunction {func}
, mDuration(duration) , mDuration {duration}
{ {
} }

View file

@ -16,9 +16,9 @@ class MoveCameraAnimation : public Animation
{ {
public: public:
MoveCameraAnimation(glm::mat4& camera, const glm::vec3& target) MoveCameraAnimation(glm::mat4& camera, const glm::vec3& target)
: mCameraStart(camera) : mCameraStart {camera}
, cameraPosition(camera) , cameraPosition {camera}
, mTarget(target) , mTarget {target}
{ {
} }

View file

@ -12,9 +12,8 @@
#include "components/ImageComponent.h" #include "components/ImageComponent.h"
#include "resources/ResourceManager.h" #include "resources/ResourceManager.h"
AnimatedImageComponent::AnimatedImageComponent(Window* window) AnimatedImageComponent::AnimatedImageComponent()
: GuiComponent {window} : mEnabled {false}
, mEnabled {false}
{ {
} }
@ -32,7 +31,7 @@ void AnimatedImageComponent::load(const AnimationDef* def)
continue; continue;
} }
auto img = std::unique_ptr<ImageComponent>(new ImageComponent(mWindow)); auto img = std::unique_ptr<ImageComponent>(new ImageComponent);
img->setResize(mSize.x, mSize.y); img->setResize(mSize.x, mSize.y);
img->setImage(std::string(def->frames[i].path), false); img->setImage(std::string(def->frames[i].path), false);

View file

@ -27,7 +27,7 @@ struct AnimationDef {
class AnimatedImageComponent : public GuiComponent class AnimatedImageComponent : public GuiComponent
{ {
public: public:
AnimatedImageComponent(Window* window); AnimatedImageComponent();
void load(const AnimationDef* def); // No reference to def is kept after loading is complete. void load(const AnimationDef* def); // No reference to def is kept after loading is complete.

View file

@ -17,7 +17,9 @@
#include "components/BadgeComponent.h" #include "components/BadgeComponent.h"
#include "Log.h" #include "Log.h"
#include "Settings.h"
#include "ThemeData.h" #include "ThemeData.h"
#include "resources/TextureResource.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
namespace namespace
@ -61,10 +63,9 @@ namespace
// clang-format on // clang-format on
} // namespace } // namespace
BadgeComponent::BadgeComponent(Window* window) BadgeComponent::BadgeComponent()
: GuiComponent {window} : mFlexboxItems {}
, mFlexboxItems {} , mFlexboxComponent {mFlexboxItems}
, mFlexboxComponent {window, mFlexboxItems}
, mBadgeTypes {{SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDGAME, SLOT_BROKEN, SLOT_CONTROLLER, , mBadgeTypes {{SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDGAME, SLOT_BROKEN, SLOT_CONTROLLER,
SLOT_ALTEMULATOR}} SLOT_ALTEMULATOR}}
{ {
@ -295,10 +296,10 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
FlexboxComponent::FlexboxItem item; FlexboxComponent::FlexboxItem item;
item.label = slot; item.label = slot;
ImageComponent badgeImage {mWindow, false, false}; ImageComponent badgeImage {false, false};
badgeImage.setImage(mBadgeIcons[slot]); badgeImage.setImage(mBadgeIcons[slot]);
item.baseImage = badgeImage; item.baseImage = badgeImage;
item.overlayImage = ImageComponent {mWindow}; item.overlayImage = ImageComponent {};
mFlexboxItems.emplace_back(std::move(item)); mFlexboxItems.emplace_back(std::move(item));
} }

View file

@ -22,7 +22,7 @@ struct GameControllers {
class BadgeComponent : public GuiComponent class BadgeComponent : public GuiComponent
{ {
public: public:
BadgeComponent(Window* window); BadgeComponent();
struct BadgeInfo { struct BadgeInfo {
std::string badgeType; std::string badgeType;

View file

@ -22,15 +22,13 @@ AnimationFrame BUSY_ANIMATION_FRAMES[] {
const AnimationDef BUSY_ANIMATION_DEF = {BUSY_ANIMATION_FRAMES, 4, true}; const AnimationDef BUSY_ANIMATION_DEF = {BUSY_ANIMATION_FRAMES, 4, true};
BusyComponent::BusyComponent(Window* window) BusyComponent::BusyComponent()
: GuiComponent {window} : mBackground {":/graphics/frame.png"}
, mBackground {window, ":/graphics/frame.png"} , mGrid {glm::ivec2 {5, 3}}
, mGrid {window, glm::ivec2 {5, 3}}
{ {
mAnimation = std::make_shared<AnimatedImageComponent>(mWindow); mAnimation = std::make_shared<AnimatedImageComponent>();
mAnimation->load(&BUSY_ANIMATION_DEF); mAnimation->load(&BUSY_ANIMATION_DEF);
mText = std::make_shared<TextComponent>(mWindow, "WORKING...", Font::get(FONT_SIZE_MEDIUM), mText = std::make_shared<TextComponent>("WORKING...", Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
0x777777FF);
// Col 0 = animation, col 1 = spacer, col 2 = text. // Col 0 = animation, col 1 = spacer, col 2 = text.
mGrid.setEntry(mAnimation, glm::ivec2 {1, 1}, false, true); mGrid.setEntry(mAnimation, glm::ivec2 {1, 1}, false, true);

View file

@ -19,7 +19,7 @@ class TextComponent;
class BusyComponent : public GuiComponent class BusyComponent : public GuiComponent
{ {
public: public:
BusyComponent(Window* window); BusyComponent();
void onSizeChanged() override; void onSizeChanged() override;

View file

@ -12,14 +12,12 @@
#include "resources/Font.h" #include "resources/Font.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
ButtonComponent::ButtonComponent(Window* window, ButtonComponent::ButtonComponent(const std::string& text,
const std::string& text,
const std::string& helpText, const std::string& helpText,
const std::function<void()>& func, const std::function<void()>& func,
bool upperCase, bool upperCase,
bool flatStyle) bool flatStyle)
: GuiComponent {window} : mBox {":/graphics/button.svg"}
, mBox {window, ":/graphics/button.svg"}
, mFont {Font::get(FONT_SIZE_MEDIUM)} , mFont {Font::get(FONT_SIZE_MEDIUM)}
, mPadding {0.0f, 0.0f, 0.0f, 0.0f} , mPadding {0.0f, 0.0f, 0.0f, 0.0f}
, mFocused {false} , mFocused {false}

View file

@ -17,8 +17,7 @@ class TextCache;
class ButtonComponent : public GuiComponent class ButtonComponent : public GuiComponent
{ {
public: public:
ButtonComponent(Window* window, ButtonComponent(const std::string& text = "",
const std::string& text = "",
const std::string& helpText = "", const std::string& helpText = "",
const std::function<void()>& func = nullptr, const std::function<void()>& func = nullptr,
bool upperCase = true, bool upperCase = true,

View file

@ -12,9 +12,8 @@
using namespace GridFlags; using namespace GridFlags;
ComponentGrid::ComponentGrid(Window* window, const glm::ivec2& gridDimensions) ComponentGrid::ComponentGrid(const glm::ivec2& gridDimensions)
: GuiComponent {window} : mGridSize {gridDimensions}
, mGridSize {gridDimensions}
, mCursor {0, 0} , mCursor {0, 0}
{ {
assert(gridDimensions.x > 0 && gridDimensions.y > 0); assert(gridDimensions.x > 0 && gridDimensions.y > 0);

View file

@ -33,7 +33,7 @@ namespace GridFlags
class ComponentGrid : public GuiComponent class ComponentGrid : public GuiComponent
{ {
public: public:
ComponentGrid(Window* window, const glm::ivec2& gridDimensions); ComponentGrid(const glm::ivec2& gridDimensions);
virtual ~ComponentGrid(); virtual ~ComponentGrid();
bool removeEntry(const std::shared_ptr<GuiComponent>& comp); bool removeEntry(const std::shared_ptr<GuiComponent>& comp);

View file

@ -12,8 +12,8 @@
#define TOTAL_HORIZONTAL_PADDING_PX 20.0f #define TOTAL_HORIZONTAL_PADDING_PX 20.0f
ComponentList::ComponentList(Window* window) ComponentList::ComponentList()
: IList<ComponentListRow, void*> {window, LIST_SCROLL_STYLE_SLOW, LIST_NEVER_LOOP} : IList<ComponentListRow, void*> {LIST_SCROLL_STYLE_SLOW, LIST_NEVER_LOOP}
, mFocused {false} , mFocused {false}
, mSetupCompleted {false} , mSetupCompleted {false}
, mBottomCameraOffset {false} , mBottomCameraOffset {false}

View file

@ -59,7 +59,7 @@ struct ComponentListRow {
class ComponentList : public IList<ComponentListRow, void*> class ComponentList : public IList<ComponentListRow, void*>
{ {
public: public:
ComponentList(Window* window); ComponentList();
enum ScrollIndicator { enum ScrollIndicator {
SCROLL_NONE, // Replace with AllowShortEnumsOnASingleLine: false (clang-format >=11.0). SCROLL_NONE, // Replace with AllowShortEnumsOnASingleLine: false (clang-format >=11.0).

View file

@ -14,23 +14,21 @@
#include "Settings.h" #include "Settings.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
DateTimeComponent::DateTimeComponent(Window* window) DateTimeComponent::DateTimeComponent()
: TextComponent {window} : mDisplayRelative {false}
, mDisplayRelative {false}
{ {
// ISO 8601 date format. // ISO 8601 date format.
setFormat("%Y-%m-%d"); setFormat("%Y-%m-%d");
} }
DateTimeComponent::DateTimeComponent(Window* window, DateTimeComponent::DateTimeComponent(const std::string& text,
const std::string& text,
const std::shared_ptr<Font>& font, const std::shared_ptr<Font>& font,
unsigned int color, unsigned int color,
Alignment align, Alignment align,
glm::vec3 pos, glm::vec3 pos,
glm::vec2 size, glm::vec2 size,
unsigned int bgcolor) unsigned int bgcolor)
: TextComponent {window, text, font, color, align, pos, size, bgcolor} : TextComponent {text, font, color, align, pos, size, bgcolor}
, mDisplayRelative {false} , mDisplayRelative {false}
{ {
// ISO 8601 date format. // ISO 8601 date format.

View file

@ -20,9 +20,8 @@ class ThemeData;
class DateTimeComponent : public TextComponent class DateTimeComponent : public TextComponent
{ {
public: public:
DateTimeComponent(Window* window); DateTimeComponent();
DateTimeComponent(Window* window, DateTimeComponent(const std::string& text,
const std::string& text,
const std::shared_ptr<Font>& font, const std::shared_ptr<Font>& font,
unsigned int color = 0x000000FF, unsigned int color = 0x000000FF,
Alignment align = ALIGN_LEFT, Alignment align = ALIGN_LEFT,

View file

@ -15,9 +15,8 @@
#include "resources/Font.h" #include "resources/Font.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
DateTimeEditComponent::DateTimeEditComponent(Window* window, bool alignRight, DisplayMode dispMode) DateTimeEditComponent::DateTimeEditComponent(bool alignRight, DisplayMode dispMode)
: GuiComponent {window} : mEditing {false}
, mEditing {false}
, mEditIndex {0} , mEditIndex {0}
, mDisplayMode {dispMode} , mDisplayMode {dispMode}
, mKeyRepeatDir {0} , mKeyRepeatDir {0}

View file

@ -24,9 +24,7 @@ public:
DISP_RELATIVE_TO_NOW DISP_RELATIVE_TO_NOW
}; };
DateTimeEditComponent(Window* window, DateTimeEditComponent(bool alignRight = false, DisplayMode dispMode = DISP_DATE);
bool alignRight = false,
DisplayMode dispMode = DISP_DATE);
void onSizeChanged() override; void onSizeChanged() override;

View file

@ -19,9 +19,8 @@
#include "Settings.h" #include "Settings.h"
#include "ThemeData.h" #include "ThemeData.h"
FlexboxComponent::FlexboxComponent(Window* window, std::vector<FlexboxItem>& items) FlexboxComponent::FlexboxComponent(std::vector<FlexboxItem>& items)
: GuiComponent {window} : mItems {items}
, mItems {items}
, mDirection {DEFAULT_DIRECTION} , mDirection {DEFAULT_DIRECTION}
, mAlignment {DEFAULT_ALIGNMENT} , mAlignment {DEFAULT_ALIGNMENT}
, mLines {DEFAULT_LINES} , mLines {DEFAULT_LINES}

View file

@ -10,7 +10,6 @@
#define ES_CORE_COMPONENTS_FLEXBOX_COMPONENT_H #define ES_CORE_COMPONENTS_FLEXBOX_COMPONENT_H
#include "GuiComponent.h" #include "GuiComponent.h"
#include "Window.h"
#include "components/ImageComponent.h" #include "components/ImageComponent.h"
class FlexboxComponent : public GuiComponent class FlexboxComponent : public GuiComponent
@ -20,13 +19,13 @@ public:
// Optional label, mostly a convenience for the calling class to track items. // Optional label, mostly a convenience for the calling class to track items.
std::string label; std::string label;
// Main image that governs grid sizing and placement. // Main image that governs grid sizing and placement.
ImageComponent baseImage {nullptr}; ImageComponent baseImage;
// Optional overlay image that can be sized and positioned relative to the base image. // Optional overlay image that can be sized and positioned relative to the base image.
ImageComponent overlayImage {nullptr}; ImageComponent overlayImage;
bool visible = false; bool visible = false;
}; };
FlexboxComponent(Window* window, std::vector<FlexboxItem>& items); FlexboxComponent(std::vector<FlexboxItem>& items);
// Getters/setters for the layout. // Getters/setters for the layout.
const std::string& getDirection() const { return mDirection; } const std::string& getDirection() const { return mDirection; }

View file

@ -12,9 +12,8 @@
#include "animations/LambdaAnimation.h" #include "animations/LambdaAnimation.h"
#include "resources/TextureResource.h" #include "resources/TextureResource.h"
GridTileComponent::GridTileComponent(Window* window) GridTileComponent::GridTileComponent()
: GuiComponent {window} : mBackground {":/graphics/frame.png"}
, mBackground {window, ":/graphics/frame.png"}
{ {
mDefaultProperties.mSize = getDefaultTileSize(); mDefaultProperties.mSize = getDefaultTileSize();
mDefaultProperties.mPadding = glm::vec2 {16.0f * Renderer::getScreenWidthModifier(), mDefaultProperties.mPadding = glm::vec2 {16.0f * Renderer::getScreenWidthModifier(),
@ -34,7 +33,7 @@ GridTileComponent::GridTileComponent(Window* window)
mSelectedProperties.mBackgroundCenterColor = 0xFFFFFFFF; mSelectedProperties.mBackgroundCenterColor = 0xFFFFFFFF;
mSelectedProperties.mBackgroundEdgeColor = 0xFFFFFFFF; mSelectedProperties.mBackgroundEdgeColor = 0xFFFFFFFF;
mImage = std::make_shared<ImageComponent>(mWindow); mImage = std::make_shared<ImageComponent>();
mImage->setOrigin(0.5f, 0.5f); mImage->setOrigin(0.5f, 0.5f);
mBackground.setOrigin(0.5f, 0.5f); mBackground.setOrigin(0.5f, 0.5f);

View file

@ -25,7 +25,7 @@ struct GridTileProperties {
class GridTileComponent : public GuiComponent class GridTileComponent : public GuiComponent
{ {
public: public:
GridTileComponent(Window* window); GridTileComponent();
void render(const glm::mat4& parentTrans) override; void render(const glm::mat4& parentTrans) override;
void applyTheme(const std::shared_ptr<ThemeData>& theme, void applyTheme(const std::shared_ptr<ThemeData>& theme,

View file

@ -19,17 +19,17 @@
static std::map<std::string, std::string> sIconPathMap {}; static std::map<std::string, std::string> sIconPathMap {};
HelpComponent::HelpComponent(Window* window) HelpComponent::HelpComponent()
: GuiComponent {window}
{ {
// Assign icons.
assignIcons(); assignIcons();
} }
void HelpComponent::assignIcons() void HelpComponent::assignIcons()
{ {
std::string controllerType = Settings::getInstance()->getString("InputControllerType"); std::string controllerType {Settings::getInstance()->getString("InputControllerType")};
std::map<std::string, std::string> sIconPathMapOld(sIconPathMap); std::map<std::string, std::string> sIconPathMapOld {sIconPathMap};
sIconPathMap.clear(); sIconPathMap.clear();
// These graphics files are common between all controller types. // These graphics files are common between all controller types.
@ -202,8 +202,7 @@ void HelpComponent::updateGrid()
std::shared_ptr<Font>& font = mStyle.font; std::shared_ptr<Font>& font = mStyle.font;
mGrid = std::make_shared<ComponentGrid>(mWindow, mGrid = std::make_shared<ComponentGrid>(glm::ivec2 {static_cast<int>(mPrompts.size()) * 4, 1});
glm::ivec2 {static_cast<int>(mPrompts.size()) * 4, 1});
// [icon] [spacer1] [text] [spacer2] // [icon] [spacer1] [text] [spacer2]
@ -217,7 +216,7 @@ void HelpComponent::updateGrid()
bool isDimmed = mWindow->isBackgroundDimmed(); bool isDimmed = mWindow->isBackgroundDimmed();
for (auto it = mPrompts.cbegin(); it != mPrompts.cend(); ++it) { for (auto it = mPrompts.cbegin(); it != mPrompts.cend(); ++it) {
auto icon = std::make_shared<ImageComponent>(mWindow); auto icon = std::make_shared<ImageComponent>();
icon->setImage(getIconTexture(it->first.c_str()), false); icon->setImage(getIconTexture(it->first.c_str()), false);
icon->setColorShift(isDimmed ? mStyle.iconColorDimmed : mStyle.iconColor); icon->setColorShift(isDimmed ? mStyle.iconColorDimmed : mStyle.iconColor);
icon->setResize(0, height); icon->setResize(0, height);
@ -232,7 +231,7 @@ void HelpComponent::updateGrid()
else else
lblInput = Utils::String::toUpper(lblInput); lblInput = Utils::String::toUpper(lblInput);
auto lbl = std::make_shared<TextComponent>( auto lbl = std::make_shared<TextComponent>(
mWindow, lblInput, font, isDimmed ? mStyle.textColorDimmed : mStyle.textColor); lblInput, font, isDimmed ? mStyle.textColorDimmed : mStyle.textColor);
labels.push_back(lbl); labels.push_back(lbl);
width += width +=

View file

@ -19,7 +19,7 @@ class TextureResource;
class HelpComponent : public GuiComponent class HelpComponent : public GuiComponent
{ {
public: public:
HelpComponent(Window* window); HelpComponent();
void assignIcons(); void assignIcons();

View file

@ -83,13 +83,11 @@ protected:
Window* mWindow; Window* mWindow;
public: public:
IList(Window* window, IList(const ScrollTierList& tierList = LIST_SCROLL_STYLE_QUICK,
const ScrollTierList& tierList = LIST_SCROLL_STYLE_QUICK,
const ListLoopType& loopType = LIST_PAUSE_AT_END) const ListLoopType& loopType = LIST_PAUSE_AT_END)
: GuiComponent {window} : mTierList {tierList}
, mTierList {tierList}
, mLoopType {loopType} , mLoopType {loopType}
, mWindow {window} , mWindow {Window::getInstance()}
{ {
mCursor = 0; mCursor = 0;
mScrollTier = 0; mScrollTier = 0;

View file

@ -28,9 +28,8 @@ glm::vec2 ImageComponent::getSize() const
return GuiComponent::getSize() * (mBottomRightCrop - mTopLeftCrop); return GuiComponent::getSize() * (mBottomRightCrop - mTopLeftCrop);
} }
ImageComponent::ImageComponent(Window* window, bool forceLoad, bool dynamic) ImageComponent::ImageComponent(bool forceLoad, bool dynamic)
: GuiComponent {window} : mTargetSize {0, 0}
, mTargetSize {0, 0}
, mFlipX {false} , mFlipX {false}
, mFlipY {false} , mFlipY {false}
, mTargetIsMax {false} , mTargetIsMax {false}

View file

@ -17,7 +17,7 @@ class TextureResource;
class ImageComponent : public GuiComponent class ImageComponent : public GuiComponent
{ {
public: public:
ImageComponent(Window* window, bool forceLoad = false, bool dynamic = true); ImageComponent(bool forceLoad = false, bool dynamic = true);
virtual ~ImageComponent() {} virtual ~ImageComponent() {}
void setDefaultImage(const std::string& path) { mDefaultPath = path; } void setDefaultImage(const std::string& path) { mDefaultPath = path; }

View file

@ -55,7 +55,7 @@ public:
using IList<ImageGridData, T>::isScrolling; using IList<ImageGridData, T>::isScrolling;
using IList<ImageGridData, T>::stopScrolling; using IList<ImageGridData, T>::stopScrolling;
ImageGridComponent(Window* window); ImageGridComponent();
void add(const std::string& name, const std::string& imagePath, const T& obj); void add(const std::string& name, const std::string& imagePath, const T& obj);
@ -122,9 +122,7 @@ private:
std::function<void(CursorState state)> mCursorChangedCallback; std::function<void(CursorState state)> mCursorChangedCallback;
}; };
template <typename T> template <typename T> ImageGridComponent<T>::ImageGridComponent()
ImageGridComponent<T>::ImageGridComponent(Window* window)
: IList<ImageGridData, T>(window)
{ {
glm::vec2 screen {static_cast<float>(Renderer::getScreenWidth()), glm::vec2 screen {static_cast<float>(Renderer::getScreenWidth()),
static_cast<float>(Renderer::getScreenHeight())}; static_cast<float>(Renderer::getScreenHeight())};
@ -556,7 +554,7 @@ template <typename T> void ImageGridComponent<T>::buildTiles()
for (int y = 0; y < (vert ? mGridDimension.y : mGridDimension.x); ++y) { for (int y = 0; y < (vert ? mGridDimension.y : mGridDimension.x); ++y) {
for (int x = 0; x < (vert ? mGridDimension.x : mGridDimension.y); ++x) { for (int x = 0; x < (vert ? mGridDimension.x : mGridDimension.y); ++x) {
// Create tiles. // Create tiles.
auto tile = std::make_shared<GridTileComponent>(mWindow); auto tile = std::make_shared<GridTileComponent>();
// In Vertical mode, tiles are ordered from left to right, then from top to bottom. // In Vertical mode, tiles are ordered from left to right, then from top to bottom.
// In Horizontal mode, tiles are ordered from top to bottom, then from left to right. // In Horizontal mode, tiles are ordered from top to bottom, then from left to right.

View file

@ -18,9 +18,8 @@
#include <chrono> #include <chrono>
LottieComponent::LottieComponent(Window* window) LottieComponent::LottieComponent()
: GuiComponent {window} : mCacheFrames {true}
, mCacheFrames {true}
, mMaxCacheSize {0} , mMaxCacheSize {0}
, mCacheSize {0} , mCacheSize {0}
, mFrameSize {0} , mFrameSize {0}

View file

@ -23,7 +23,7 @@
class LottieComponent : public GuiComponent class LottieComponent : public GuiComponent
{ {
public: public:
LottieComponent(Window* window); LottieComponent();
~LottieComponent(); ~LottieComponent();
void setAnimation(const std::string& path); void setAnimation(const std::string& path);

View file

@ -17,12 +17,8 @@
#define TITLE_HEIGHT (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f) #define TITLE_HEIGHT (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f)
MenuComponent::MenuComponent(Window* window, MenuComponent::MenuComponent(std::string title, const std::shared_ptr<Font>& titleFont)
std::string title, : mGrid {glm::ivec2 {2, 4}}
const std::shared_ptr<Font>& titleFont)
: GuiComponent {window}
, mBackground {window}
, mGrid {window, glm::ivec2 {2, 4}}
, mNeedsSaving {false} , mNeedsSaving {false}
{ {
addChild(&mBackground); addChild(&mBackground);
@ -31,19 +27,19 @@ MenuComponent::MenuComponent(Window* window,
mBackground.setImagePath(":/graphics/frame.svg"); mBackground.setImagePath(":/graphics/frame.svg");
// Set up title. // Set up title.
mTitle = std::make_shared<TextComponent>(mWindow); mTitle = std::make_shared<TextComponent>();
mTitle->setHorizontalAlignment(ALIGN_CENTER); mTitle->setHorizontalAlignment(ALIGN_CENTER);
mTitle->setColor(0x555555FF); mTitle->setColor(0x555555FF);
setTitle(title, titleFont); setTitle(title, titleFont);
mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2}); mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2});
// Set up list which will never change (externally, anyway). // Set up list which will never change (externally, anyway).
mList = std::make_shared<ComponentList>(mWindow); mList = std::make_shared<ComponentList>();
mGrid.setEntry(mList, glm::ivec2 {0, 2}, true, true, glm::ivec2 {2, 1}); mGrid.setEntry(mList, glm::ivec2 {0, 2}, true, true, glm::ivec2 {2, 1});
// Set up scroll indicators. // Set up scroll indicators.
mScrollUp = std::make_shared<ImageComponent>(mWindow); mScrollUp = std::make_shared<ImageComponent>();
mScrollDown = std::make_shared<ImageComponent>(mWindow); mScrollDown = std::make_shared<ImageComponent>();
mScrollIndicator = std::make_shared<ScrollIndicatorComponent>(mList, mScrollUp, mScrollDown); mScrollIndicator = std::make_shared<ScrollIndicatorComponent>(mList, mScrollUp, mScrollDown);
mScrollUp->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f); mScrollUp->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f);
@ -136,8 +132,8 @@ void MenuComponent::addButton(const std::string& name,
const std::string& helpText, const std::string& helpText,
const std::function<void()>& callback) const std::function<void()>& callback)
{ {
mButtons.push_back(std::make_shared<ButtonComponent>(mWindow, Utils::String::toUpper(name), mButtons.push_back(
helpText, callback)); std::make_shared<ButtonComponent>(Utils::String::toUpper(name), helpText, callback));
updateGrid(); updateGrid();
updateSize(); updateSize();
} }
@ -150,16 +146,16 @@ void MenuComponent::updateGrid()
mButtonGrid.reset(); mButtonGrid.reset();
if (mButtons.size()) { if (mButtons.size()) {
mButtonGrid = makeButtonGrid(mWindow, mButtons); mButtonGrid = makeButtonGrid(mButtons);
mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 3}, true, false, glm::ivec2 {2, 1}); mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 3}, true, false, glm::ivec2 {2, 1});
} }
} }
std::shared_ptr<ComponentGrid> makeButtonGrid( std::shared_ptr<ComponentGrid> makeButtonGrid(
Window* window, const std::vector<std::shared_ptr<ButtonComponent>>& buttons) const std::vector<std::shared_ptr<ButtonComponent>>& buttons)
{ {
std::shared_ptr<ComponentGrid> buttonGrid = std::shared_ptr<ComponentGrid> buttonGrid =
std::make_shared<ComponentGrid>(window, glm::ivec2 {static_cast<int>(buttons.size()), 2}); std::make_shared<ComponentGrid>(glm::ivec2 {static_cast<int>(buttons.size()), 2});
// Initialize to padding. // Initialize to padding.
float buttonGridWidth = BUTTON_GRID_HORIZ_PADDING * buttons.size(); float buttonGridWidth = BUTTON_GRID_HORIZ_PADDING * buttons.size();
@ -180,9 +176,9 @@ std::shared_ptr<ComponentGrid> makeButtonGrid(
return buttonGrid; return buttonGrid;
} }
std::shared_ptr<ImageComponent> makeArrow(Window* window) std::shared_ptr<ImageComponent> makeArrow()
{ {
auto bracket = std::make_shared<ImageComponent>(window); auto bracket = std::make_shared<ImageComponent>();
bracket->setImage(":/graphics/arrow.svg"); bracket->setImage(":/graphics/arrow.svg");
bracket->setResize(0, std::round(Font::get(FONT_SIZE_MEDIUM)->getLetterHeight())); bracket->setResize(0, std::round(Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()));
return bracket; return bracket;

View file

@ -22,14 +22,13 @@ class ButtonComponent;
class ImageComponent; class ImageComponent;
std::shared_ptr<ComponentGrid> makeButtonGrid( std::shared_ptr<ComponentGrid> makeButtonGrid(
Window* window, const std::vector<std::shared_ptr<ButtonComponent>>& buttons); const std::vector<std::shared_ptr<ButtonComponent>>& buttons);
std::shared_ptr<ImageComponent> makeArrow(Window* window); std::shared_ptr<ImageComponent> makeArrow();
class MenuComponent : public GuiComponent class MenuComponent : public GuiComponent
{ {
public: public:
MenuComponent(Window* window, MenuComponent(std::string title,
std::string title,
const std::shared_ptr<Font>& titleFont = Font::get(FONT_SIZE_LARGE)); const std::shared_ptr<Font>& titleFont = Font::get(FONT_SIZE_LARGE));
virtual ~MenuComponent(); virtual ~MenuComponent();
@ -51,7 +50,7 @@ public:
bool invert_when_selected = true) bool invert_when_selected = true)
{ {
ComponentListRow row; ComponentListRow row;
row.addElement(std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(label), row.addElement(std::make_shared<TextComponent>(Utils::String::toUpper(label),
Font::get(FONT_SIZE_MEDIUM), 0x777777FF), Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
true); true);
row.addElement(comp, false, invert_when_selected); row.addElement(comp, false, invert_when_selected);

View file

@ -13,12 +13,10 @@
#include "resources/Font.h" #include "resources/Font.h"
#include "resources/TextureResource.h" #include "resources/TextureResource.h"
NinePatchComponent::NinePatchComponent(Window* window, NinePatchComponent::NinePatchComponent(const std::string& path,
const std::string& path,
unsigned int edgeColor, unsigned int edgeColor,
unsigned int centerColor) unsigned int centerColor)
: GuiComponent {window} : mVertices {nullptr}
, mVertices {nullptr}
, mPath {path} , mPath {path}
, mCornerSize {16.0f, 16.0f} , mCornerSize {16.0f, 16.0f}
, mSharpCorners {false} , mSharpCorners {false}

View file

@ -29,8 +29,7 @@ class TextureResource;
class NinePatchComponent : public GuiComponent class NinePatchComponent : public GuiComponent
{ {
public: public:
NinePatchComponent(Window* window, NinePatchComponent(const std::string& path = "",
const std::string& path = "",
unsigned int edgeColor = 0xFFFFFFFF, unsigned int edgeColor = 0xFFFFFFFF,
unsigned int centerColor = 0xFFFFFFFF); unsigned int centerColor = 0xFFFFFFFF);
virtual ~NinePatchComponent(); virtual ~NinePatchComponent();

View file

@ -27,14 +27,12 @@
template <typename T> class OptionListComponent : public GuiComponent template <typename T> class OptionListComponent : public GuiComponent
{ {
public: public:
OptionListComponent(Window* window, OptionListComponent(const HelpStyle& helpstyle,
const HelpStyle& helpstyle,
const std::string& name, const std::string& name,
bool multiSelect = false, bool multiSelect = false,
bool multiExclusiveSelect = false, bool multiExclusiveSelect = false,
bool multiShowTotal = false) bool multiShowTotal = false)
: GuiComponent {window} : mHelpStyle {helpstyle}
, mHelpStyle {helpstyle}
, mMultiSelect {multiSelect} , mMultiSelect {multiSelect}
, mMultiExclusiveSelect {multiExclusiveSelect} , mMultiExclusiveSelect {multiExclusiveSelect}
, mMultiShowTotal {multiShowTotal} , mMultiShowTotal {multiShowTotal}
@ -44,9 +42,6 @@ public:
, mKeyRepeatStartDelay {OPTIONLIST_REPEAT_START_DELAY} , mKeyRepeatStartDelay {OPTIONLIST_REPEAT_START_DELAY}
, mKeyRepeatSpeed {OPTIONLIST_REPEAT_SPEED} , mKeyRepeatSpeed {OPTIONLIST_REPEAT_SPEED}
, mName {name} , mName {name}
, mText {window}
, mLeftArrow {window}
, mRightArrow {window}
{ {
auto font {Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)}; auto font {Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)};
mText.setFont(font); mText.setFont(font);
@ -306,7 +301,7 @@ private:
void open() void open()
{ {
// Open the list popup. // Open the list popup.
mWindow->pushGui(new OptionListPopup(mWindow, getHelpStyle(), this, mName)); mWindow->pushGui(new OptionListPopup(getHelpStyle(), this, mName));
} }
void onSelectedChanged() void onSelectedChanged()
@ -412,12 +407,10 @@ private:
class OptionListPopup : public GuiComponent class OptionListPopup : public GuiComponent
{ {
public: public:
OptionListPopup(Window* window, OptionListPopup(const HelpStyle& helpstyle,
const HelpStyle& helpstyle,
OptionListComponent<T>* parent, OptionListComponent<T>* parent,
const std::string& title) const std::string& title)
: GuiComponent(window) : mMenu(title.c_str())
, mMenu(window, title.c_str())
, mParent(parent) , mParent(parent)
, mHelpStyle(helpstyle) , mHelpStyle(helpstyle)
{ {
@ -444,7 +437,7 @@ private:
for (auto it = mParent->mEntries.begin(); it != mParent->mEntries.end(); ++it) { for (auto it = mParent->mEntries.begin(); it != mParent->mEntries.end(); ++it) {
row.elements.clear(); row.elements.clear();
auto textComponent = std::make_shared<TextComponent>( auto textComponent = std::make_shared<TextComponent>(
mWindow, Utils::String::toUpper(it->name), font, 0x777777FF); Utils::String::toUpper(it->name), font, 0x777777FF);
row.addElement(textComponent, true); row.addElement(textComponent, true);
if (mParent->mMultiExclusiveSelect && hasSelectedRow && !(*it).selected) { if (mParent->mMultiExclusiveSelect && hasSelectedRow && !(*it).selected) {
@ -456,7 +449,7 @@ private:
if (mParent->mMultiSelect) { if (mParent->mMultiSelect) {
// Add checkbox. // Add checkbox.
auto checkbox = std::make_shared<ImageComponent>(mWindow); auto checkbox = std::make_shared<ImageComponent>();
checkbox->setImage(it->selected ? CHECKED_PATH : UNCHECKED_PATH); checkbox->setImage(it->selected ? CHECKED_PATH : UNCHECKED_PATH);
checkbox->setResize(0, font->getLetterHeight()); checkbox->setResize(0, font->getLetterHeight());
row.addElement(checkbox, false); row.addElement(checkbox, false);

View file

@ -13,9 +13,8 @@
#include "ThemeData.h" #include "ThemeData.h"
#include "resources/TextureResource.h" #include "resources/TextureResource.h"
RatingComponent::RatingComponent(Window* window, bool colorizeChanges) RatingComponent::RatingComponent(bool colorizeChanges)
: GuiComponent {window} : mColorOriginalValue {DEFAULT_COLORSHIFT}
, mColorOriginalValue {DEFAULT_COLORSHIFT}
, mColorChangedValue {DEFAULT_COLORSHIFT} , mColorChangedValue {DEFAULT_COLORSHIFT}
, mColorShift {DEFAULT_COLORSHIFT} , mColorShift {DEFAULT_COLORSHIFT}
, mColorShiftEnd {DEFAULT_COLORSHIFT} , mColorShiftEnd {DEFAULT_COLORSHIFT}

View file

@ -20,7 +20,7 @@ class TextureResource;
class RatingComponent : public GuiComponent class RatingComponent : public GuiComponent
{ {
public: public:
RatingComponent(Window* window, bool colorizeChanges = false); RatingComponent(bool colorizeChanges = false);
std::string getValue() const override; std::string getValue() const override;
// Should be a normalized float (in the range [0..1]) - if it's not, it will be clamped. // Should be a normalized float (in the range [0..1]) - if it's not, it will be clamped.

View file

@ -14,9 +14,8 @@
#include "renderers/Renderer.h" #include "renderers/Renderer.h"
#include "resources/Font.h" #include "resources/Font.h"
ScrollableContainer::ScrollableContainer(Window* window) ScrollableContainer::ScrollableContainer()
: GuiComponent {window} : mScrollPos {0.0f, 0.0f}
, mScrollPos {0.0f, 0.0f}
, mScrollDir {0.0f, 0.0f} , mScrollDir {0.0f, 0.0f}
, mClipSpacing {0.0f} , mClipSpacing {0.0f}
, mAutoScrollDelay {0} , mAutoScrollDelay {0}

View file

@ -22,7 +22,7 @@
class ScrollableContainer : public GuiComponent class ScrollableContainer : public GuiComponent
{ {
public: public:
ScrollableContainer(Window* window); ScrollableContainer();
glm::vec2 getScrollPos() const { return mScrollPos; } glm::vec2 getScrollPos() const { return mScrollPos; }
void setScrollPos(const glm::vec2& pos) { mScrollPos = pos; } void setScrollPos(const glm::vec2& pos) { mScrollPos = pos; }

View file

@ -14,15 +14,12 @@
#define MOVE_REPEAT_DELAY 500 #define MOVE_REPEAT_DELAY 500
#define MOVE_REPEAT_RATE 40 #define MOVE_REPEAT_RATE 40
SliderComponent::SliderComponent( SliderComponent::SliderComponent(float min, float max, float increment, const std::string& suffix)
Window* window, float min, float max, float increment, const std::string& suffix) : mMin {min}
: GuiComponent {window}
, mMin {min}
, mMax {max} , mMax {max}
, mSingleIncrement {increment} , mSingleIncrement {increment}
, mMoveRate {0.0f} , mMoveRate {0.0f}
, mBarHeight {0.0f} , mBarHeight {0.0f}
, mKnob {window}
, mSuffix {suffix} , mSuffix {suffix}
{ {
assert((min - max) != 0.0f); assert((min - max) != 0.0f);
@ -33,7 +30,8 @@ SliderComponent::SliderComponent(
mKnob.setOrigin(0.5f, 0.5f); mKnob.setOrigin(0.5f, 0.5f);
mKnob.setImage(":/graphics/slider_knob.svg"); mKnob.setImage(":/graphics/slider_knob.svg");
setSize(window->peekGui()->getSize().x * 0.26f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()); setSize(mWindow->peekGui()->getSize().x * 0.26f,
Font::get(FONT_SIZE_MEDIUM)->getLetterHeight());
} }
bool SliderComponent::input(InputConfig* config, Input input) bool SliderComponent::input(InputConfig* config, Input input)

View file

@ -15,17 +15,16 @@
class Font; class Font;
class TextCache; class TextCache;
// Used to display/edit a value between some min and max values. // Slider to set value in a predefined range.
class SliderComponent : public GuiComponent class SliderComponent : public GuiComponent
{ {
public: public:
using GuiComponent::getValue; using GuiComponent::getValue;
using GuiComponent::setValue; using GuiComponent::setValue;
// Minimum value (far left of the slider), maximum value (far right of the slider), // Minimum and maximum values, how much to increment each step the knob is moved and
// increment size (how much pressing L/R moves by), unit to display (optional). // an optional unit.
SliderComponent( SliderComponent(float min, float max, float increment, const std::string& suffix = "");
Window* window, float min, float max, float increment, const std::string& suffix = "");
void setValue(float value); void setValue(float value);
float getValue() { return mValue; } float getValue() { return mValue; }

View file

@ -10,10 +10,8 @@
#include "resources/Font.h" #include "resources/Font.h"
SwitchComponent::SwitchComponent(Window* window, bool state) SwitchComponent::SwitchComponent(bool state)
: GuiComponent {window} : mState {state}
, mImage {window}
, mState {state}
, mOriginalValue {state} , mOriginalValue {state}
, mColorOriginalValue {DEFAULT_COLORSHIFT} , mColorOriginalValue {DEFAULT_COLORSHIFT}
, mColorChangedValue {DEFAULT_COLORSHIFT} , mColorChangedValue {DEFAULT_COLORSHIFT}

View file

@ -16,7 +16,7 @@
class SwitchComponent : public GuiComponent class SwitchComponent : public GuiComponent
{ {
public: public:
SwitchComponent(Window* window, bool state = false); SwitchComponent(bool state = false);
bool input(InputConfig* config, Input input) override; bool input(InputConfig* config, Input input) override;
void render(const glm::mat4& parentTrans) override; void render(const glm::mat4& parentTrans) override;

View file

@ -12,9 +12,8 @@
#include "Settings.h" #include "Settings.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
TextComponent::TextComponent(Window* window) TextComponent::TextComponent()
: GuiComponent {window} : mFont {Font::get(FONT_SIZE_MEDIUM)}
, mFont {Font::get(FONT_SIZE_MEDIUM)}
, mColor {0x000000FF} , mColor {0x000000FF}
, mBgColor {0} , mBgColor {0}
, mRenderBackground {false} , mRenderBackground {false}
@ -28,16 +27,14 @@ TextComponent::TextComponent(Window* window)
{ {
} }
TextComponent::TextComponent(Window* window, TextComponent::TextComponent(const std::string& text,
const std::string& text,
const std::shared_ptr<Font>& font, const std::shared_ptr<Font>& font,
unsigned int color, unsigned int color,
Alignment align, Alignment align,
glm::vec3 pos, glm::vec3 pos,
glm::vec2 size, glm::vec2 size,
unsigned int bgcolor) unsigned int bgcolor)
: GuiComponent {window} : mFont {nullptr}
, mFont {nullptr}
, mColor {0x000000FF} , mColor {0x000000FF}
, mBgColor {0} , mBgColor {0}
, mRenderBackground {false} , mRenderBackground {false}

View file

@ -24,9 +24,8 @@ class ThemeData;
class TextComponent : public GuiComponent class TextComponent : public GuiComponent
{ {
public: public:
TextComponent(Window* window); TextComponent();
TextComponent(Window* window, TextComponent(const std::string& text,
const std::string& text,
const std::shared_ptr<Font>& font, const std::shared_ptr<Font>& font,
unsigned int color = 0x000000FF, unsigned int color = 0x000000FF,
Alignment align = ALIGN_LEFT, Alignment align = ALIGN_LEFT,

View file

@ -18,15 +18,14 @@
#define BLINKTIME 1000 #define BLINKTIME 1000
TextEditComponent::TextEditComponent(Window* window) TextEditComponent::TextEditComponent()
: GuiComponent {window} : mFocused {false}
, mFocused {false}
, mEditing {false} , mEditing {false}
, mCursor {0} , mCursor {0}
, mBlinkTime {0} , mBlinkTime {0}
, mCursorRepeatDir {0} , mCursorRepeatDir {0}
, mScrollOffset {0.0f, 0.0f} , mScrollOffset {0.0f, 0.0f}
, mBox {window, ":/graphics/textinput.svg"} , mBox {":/graphics/textinput.svg"}
, mFont {Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)} , mFont {Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)}
{ {
mBox.setSharpCorners(true); mBox.setSharpCorners(true);

View file

@ -20,7 +20,7 @@ class TextCache;
class TextEditComponent : public GuiComponent class TextEditComponent : public GuiComponent
{ {
public: public:
TextEditComponent(Window* window); TextEditComponent();
void textInput(const std::string& text) override; void textInput(const std::string& text) override;
bool input(InputConfig* config, Input input) override; bool input(InputConfig* config, Input input) override;

View file

@ -39,7 +39,7 @@ public:
using GuiComponent::setColor; using GuiComponent::setColor;
using List::size; using List::size;
TextListComponent(Window* window); TextListComponent();
bool input(InputConfig* config, Input input) override; bool input(InputConfig* config, Input input) override;
void update(int deltaTime) override; void update(int deltaTime) override;
@ -128,10 +128,7 @@ private:
ImageComponent mSelectorImage; ImageComponent mSelectorImage;
}; };
template <typename T> template <typename T> TextListComponent<T>::TextListComponent()
TextListComponent<T>::TextListComponent(Window* window)
: IList<TextListData, T> {window}
, mSelectorImage {window}
{ {
mLoopOffset = 0; mLoopOffset = 0;
mLoopOffset2 = 0; mLoopOffset2 = 0;

Some files were not shown because too many files have changed in this diff Show more