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);
}
void FileData::launchGame(Window* window)
void FileData::launchGame()
{
Window* window {Window::getInstance()};
LOG(LogInfo) << "Launching game \"" << this->metadata.get("name") << "\"...";
SystemData* gameSystem = nullptr;

View file

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

View file

@ -13,11 +13,10 @@
#include "views/ViewController.h"
MediaViewer::MediaViewer()
: mWindow {Window::getInstance()}
, mVideo {nullptr}
: mVideo {nullptr}
, mImage {nullptr}
{
mWindow->setMediaViewer(this);
Window::getInstance()->setMediaViewer(this);
}
MediaViewer::~MediaViewer()
@ -260,7 +259,7 @@ void MediaViewer::playVideo()
mDisplayingImage = false;
ViewController::getInstance()->onStopVideo();
mVideo = new VideoFFmpegComponent(mWindow);
mVideo = new VideoFFmpegComponent;
mVideo->topWindow(true);
mVideo->setOrigin(0.5f, 0.5f);
mVideo->setPosition(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f);
@ -285,7 +284,7 @@ void MediaViewer::showImage(int index)
mDisplayingImage = true;
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->setOrigin(0.5f, 0.5f);
mImage->setPosition(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -19,11 +19,9 @@
#include "utils/StringUtil.h"
#include "views/ViewController.h"
GuiGamelistFilter::GuiGamelistFilter(Window* window,
SystemData* system,
GuiGamelistFilter::GuiGamelistFilter(SystemData* system,
std::function<void(bool)> filterChangedCallback)
: GuiComponent {window}
, mMenu {window, "FILTER GAMELIST"}
: mMenu {"FILTER GAMELIST"}
, mSystem {system}
, mFiltersChangedCallback {filterChangedCallback}
, mFiltersChanged {false}
@ -51,8 +49,8 @@ void GuiGamelistFilter::initializeMenu()
// Show filtered menu.
row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, "RESET ALL FILTERS",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
row.addElement(std::make_shared<TextComponent>("RESET ALL FILTERS", Font::get(FONT_SIZE_MEDIUM),
0x777777FF),
true);
row.makeAcceptInputHandler(std::bind(&GuiGamelistFilter::resetAllFilters, this));
mMenu.addRow(row);
@ -99,22 +97,22 @@ void GuiGamelistFilter::addFiltersToMenu()
ComponentListRow row;
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);
mTextFilterField = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_MEDIUM),
0x777777FF, ALIGN_RIGHT);
mTextFilterField =
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.
if (mSystem->getRootFolder()->getChildren().size() > 0) {
row.addElement(lbl, 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);
row.addElement(spacer, false);
auto bracket = std::make_shared<ImageComponent>(mWindow);
auto bracket = std::make_shared<ImageComponent>();
bracket->setImage(":/graphics/arrow.svg");
bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()});
row.addElement(bracket, false);
@ -130,14 +128,14 @@ void GuiGamelistFilter::addFiltersToMenu()
if (Settings::getInstance()->getBool("VirtualKeyboard")) {
row.makeAcceptInputHandler([this, updateVal] {
mWindow->pushGui(new GuiTextEditKeyboardPopup(mWindow, getHelpStyle(), "GAME NAME",
mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), "GAME NAME",
mTextFilterField->getValue(), updateVal,
false, "OK", "APPLY CHANGES?"));
});
}
else {
row.makeAcceptInputHandler([this, updateVal] {
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), "GAME NAME",
mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), "GAME NAME",
mTextFilterField->getValue(), updateVal, false,
"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
// selected at the same time. This should be changed to a SwitchComponent at some point.
if (exclusiveSelect)
optionList = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(),
optionList = std::make_shared<OptionListComponent<std::string>>(getHelpStyle(),
menuLabel, true, true);
else
optionList = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(),
optionList = std::make_shared<OptionListComponent<std::string>>(getHelpStyle(),
menuLabel, true, false);
// 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
{
public:
GuiGamelistFilter(Window* window,
SystemData* system,
std::function<void(bool)> filtersChangedCallback);
GuiGamelistFilter(SystemData* system, std::function<void(bool)> filtersChangedCallback);
~GuiGamelistFilter() { mFilterOptions.clear(); }
bool input(InputConfig* config, Input input) override;

View file

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

View file

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

View file

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

View file

@ -12,11 +12,11 @@
#include "Settings.h"
#include "components/SwitchComponent.h"
GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string& title)
: GuiSettings {window, title}
GuiMediaViewerOptions::GuiMediaViewerOptions(const std::string& title)
: GuiSettings {title}
{
// 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"));
addWithLabel("KEEP VIDEOS RUNNING WHEN VIEWING IMAGES", keep_video_running);
addSaveFunc([keep_video_running, this] {
@ -29,7 +29,7 @@ GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string&
});
// 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"));
addWithLabel("STRETCH VIDEOS TO SCREEN RESOLUTION", stretch_videos);
addSaveFunc([stretch_videos, this] {
@ -43,7 +43,7 @@ GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string&
#if defined(USE_OPENGL_21)
// 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"));
addWithLabel("RENDER SCANLINES FOR VIDEOS", video_scanlines);
addSaveFunc([video_scanlines, this] {
@ -56,7 +56,7 @@ GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string&
});
// 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"));
addWithLabel("RENDER BLUR FOR VIDEOS", video_blur);
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.
auto screenshot_scanlines = std::make_shared<SwitchComponent>(mWindow);
auto screenshot_scanlines = std::make_shared<SwitchComponent>();
screenshot_scanlines->setState(
Settings::getInstance()->getBool("MediaViewerScreenshotScanlines"));
addWithLabel("RENDER SCANLINES FOR SCREENSHOTS AND TITLES", screenshot_scanlines);

View file

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

View file

@ -39,10 +39,8 @@
#include <SDL2/SDL_events.h>
#include <algorithm>
GuiMenu::GuiMenu(Window* window)
: GuiComponent {window}
, mMenu {window, "MAIN MENU"}
, mVersion {window}
GuiMenu::GuiMenu()
: mMenu {"MAIN MENU"}
{
bool isFullUI = UIModeController::getInstance()->isUIModeFull();
@ -94,16 +92,16 @@ GuiMenu::~GuiMenu()
void GuiMenu::openScraperOptions()
{
// Open the scraper menu.
mWindow->pushGui(new GuiScraperMenu(mWindow, "SCRAPER"));
mWindow->pushGui(new GuiScraperMenu("SCRAPER"));
}
void GuiMenu::openUIOptions()
{
auto s = new GuiSettings(mWindow, "UI SETTINGS");
auto s = new GuiSettings("UI SETTINGS");
// Optionally start in selected system/gamelist.
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") == "");
for (auto it = SystemData::sSystemVector.cbegin(); // Line break.
it != SystemData::sSystemVector.cend(); ++it) {
@ -130,7 +128,7 @@ void GuiMenu::openUIOptions()
// Gamelist view style.
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");
gamelist_view_style->add("automatic", "automatic", selectedViewStyle == "automatic");
gamelist_view_style->add("basic", "basic", selectedViewStyle == "basic");
@ -154,7 +152,7 @@ void GuiMenu::openUIOptions()
// Transition style.
auto transition_style = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "TRANSITION STYLE", false);
getHelpStyle(), "TRANSITION STYLE", false);
std::vector<std::string> transitions;
transitions.push_back("slide");
transitions.push_back("fade");
@ -178,8 +176,8 @@ void GuiMenu::openUIOptions()
themeSets.find(Settings::getInstance()->getString("ThemeSet"));
if (selectedSet == themeSets.cend())
selectedSet = themeSets.cbegin();
auto theme_set = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(),
"THEME SET", false);
auto theme_set =
std::make_shared<OptionListComponent<std::string>>(getHelpStyle(), "THEME SET", false);
for (auto it = themeSets.cbegin(); it != themeSets.cend(); ++it) {
// If required, abbreviate the theme set name so it doesn't overlap the setting name.
float maxNameLength = mSize.x * 0.62f;
@ -208,8 +206,8 @@ void GuiMenu::openUIOptions()
}
// UI mode.
auto ui_mode = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(),
"UI MODE", false);
auto ui_mode =
std::make_shared<OptionListComponent<std::string>>(getHelpStyle(), "UI MODE", false);
std::vector<std::string> uiModes;
uiModes.push_back("full");
uiModes.push_back("kiosk");
@ -248,7 +246,7 @@ void GuiMenu::openUIOptions()
msg += UIModeController::getInstance()->getFormattedPassKeyStr() + "\n\n";
msg += "DO YOU WANT TO PROCEED?";
mWindow->pushGui(new GuiMsgBox(
mWindow, this->getHelpStyle(), msg, "YES",
this->getHelpStyle(), msg, "YES",
[this, selectedMode] {
LOG(LogDebug) << "GuiMenu::openUISettings(): Setting UI mode to '"
<< selectedMode << "'.";
@ -296,7 +294,7 @@ void GuiMenu::openUIOptions()
// Default gamelist sort order.
std::string sortOrder;
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.
unsigned int numSortTypes = static_cast<unsigned int>(FileSorts::SortTypes.size() - 2);
for (unsigned int i = 0; i < numSortTypes; ++i) {
@ -331,7 +329,7 @@ void GuiMenu::openUIOptions()
// Open menu effect.
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");
menu_opening_effect->add("SCALE-UP", "scale-up", selectedMenuEffect == "scale-up");
menu_opening_effect->add("NONE", "none", selectedMenuEffect == "none");
@ -351,7 +349,7 @@ void GuiMenu::openUIOptions()
// Launch screen duration.
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");
launch_screen_duration->add("NORMAL", "normal", selectedDuration == "normal");
launch_screen_duration->add("BRIEF", "brief", selectedDuration == "brief");
@ -374,28 +372,27 @@ void GuiMenu::openUIOptions()
// Media viewer.
ComponentListRow media_viewer_row;
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),
0x777777FF),
true);
media_viewer_row.addElement(makeArrow(mWindow), false);
media_viewer_row.addElement(makeArrow(), false);
media_viewer_row.makeAcceptInputHandler(std::bind(&GuiMenu::openMediaViewerOptions, this));
s->addRow(media_viewer_row);
// Screensaver.
ComponentListRow screensaver_row;
screensaver_row.elements.clear();
screensaver_row.addElement(std::make_shared<TextComponent>(mWindow, "SCREENSAVER SETTINGS",
Font::get(FONT_SIZE_MEDIUM),
0x777777FF),
screensaver_row.addElement(std::make_shared<TextComponent>(
"SCREENSAVER SETTINGS", Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
true);
screensaver_row.addElement(makeArrow(mWindow), false);
screensaver_row.addElement(makeArrow(), false);
screensaver_row.makeAcceptInputHandler(std::bind(&GuiMenu::openScreensaverOptions, this));
s->addRow(screensaver_row);
#if defined(USE_OPENGL_21)
// 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"));
s->addWithLabel("BLUR BACKGROUND WHEN MENU IS OPEN", menu_blur_background);
s->addSaveFunc([menu_blur_background, s] {
@ -410,7 +407,7 @@ void GuiMenu::openUIOptions()
#endif
// 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"));
s->addWithLabel("DISPLAY PILLARBOXES FOR GAMELIST VIDEOS", gamelist_video_pillarbox);
s->addSaveFunc([gamelist_video_pillarbox, s] {
@ -424,7 +421,7 @@ void GuiMenu::openUIOptions()
#if defined(USE_OPENGL_21)
// 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"));
s->addWithLabel("RENDER SCANLINES FOR GAMELIST VIDEOS", gamelist_video_scanlines);
s->addSaveFunc([gamelist_video_scanlines, s] {
@ -438,7 +435,7 @@ void GuiMenu::openUIOptions()
#endif
// 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"));
s->addWithLabel("SORT FOLDERS ON TOP OF GAMELISTS", folders_on_top);
s->addSaveFunc([folders_on_top, s] {
@ -451,7 +448,7 @@ void GuiMenu::openUIOptions()
});
// 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"));
s->addWithLabel("SORT FAVORITE GAMES ABOVE NON-FAVORITES", favorites_first);
s->addSaveFunc([favorites_first, s] {
@ -465,7 +462,7 @@ void GuiMenu::openUIOptions()
});
// 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"));
s->addWithLabel("ADD STAR MARKINGS TO FAVORITE GAMES", favorites_star);
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.
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"));
s->addWithLabel("USE PLAIN ASCII FOR SPECIAL GAMELIST CHARACTERS", special_chars_ascii);
s->addSaveFunc([special_chars_ascii, s] {
@ -492,7 +489,7 @@ void GuiMenu::openUIOptions()
});
// 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"));
s->addWithLabel("ENABLE QUICK LIST SCROLLING OVERLAY", list_scroll_overlay);
s->addSaveFunc([list_scroll_overlay, s] {
@ -504,7 +501,7 @@ void GuiMenu::openUIOptions()
});
// 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"));
s->addWithLabel("ENABLE VIRTUAL KEYBOARD", virtual_keyboard);
s->addSaveFunc([virtual_keyboard, s] {
@ -516,7 +513,7 @@ void GuiMenu::openUIOptions()
});
// 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"));
s->addWithLabel("ENABLE MENU SCROLL INDICATORS", scroll_indicators);
s->addSaveFunc([scroll_indicators, s] {
@ -528,7 +525,7 @@ void GuiMenu::openUIOptions()
});
// 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"));
s->addWithLabel("ENABLE TOGGLE FAVORITES BUTTON", favorites_add_button);
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.
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"));
s->addWithLabel("ENABLE RANDOM SYSTEM OR GAME BUTTON", random_add_button);
s->addSaveFunc([random_add_button, s] {
@ -552,7 +549,7 @@ void GuiMenu::openUIOptions()
});
// Gamelist filters.
auto gamelist_filters = std::make_shared<SwitchComponent>(mWindow);
auto gamelist_filters = std::make_shared<SwitchComponent>();
gamelist_filters->setState(Settings::getInstance()->getBool("GamelistFilters"));
s->addWithLabel("ENABLE GAMELIST FILTERS", gamelist_filters);
s->addSaveFunc([gamelist_filters, s] {
@ -564,7 +561,7 @@ void GuiMenu::openUIOptions()
});
// 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"));
s->addWithLabel("ENABLE QUICK SYSTEM SELECT", quick_system_select);
s->addSaveFunc([quick_system_select, s] {
@ -576,7 +573,7 @@ void GuiMenu::openUIOptions()
});
// 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"));
s->addWithLabel("DISPLAY ON-SCREEN HELP", show_help_prompts);
s->addSaveFunc([show_help_prompts, s] {
@ -587,7 +584,7 @@ void GuiMenu::openUIOptions()
});
// 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"));
s->addWithLabel("PLAY VIDEOS IMMEDIATELY (OVERRIDE THEME)", play_videos_immediately);
s->addSaveFunc([play_videos_immediately, s] {
@ -605,7 +602,7 @@ void GuiMenu::openUIOptions()
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
// implemented for these operating systems.
@ -618,7 +615,7 @@ void GuiMenu::openSoundOptions()
VolumeControl volumeControl;
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));
s->addWithLabel("SYSTEM VOLUME", systemVolume);
s->addSaveFunc([systemVolume, currentVolume] {
@ -631,7 +628,7 @@ void GuiMenu::openSoundOptions()
#endif
// 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(
static_cast<float>(Settings::getInstance()->getInt("SoundVolumeNavigation")));
s->addWithLabel("NAVIGATION SOUNDS VOLUME", sound_volume_navigation);
@ -645,7 +642,7 @@ void GuiMenu::openSoundOptions()
});
// 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(
static_cast<float>(Settings::getInstance()->getInt("SoundVolumeVideos")));
s->addWithLabel("VIDEO PLAYER VOLUME", sound_volume_videos);
@ -660,7 +657,7 @@ void GuiMenu::openSoundOptions()
if (UIModeController::getInstance()->isUIModeFull()) {
// 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"));
s->addWithLabel("PLAY AUDIO FOR VIDEOS IN THE GAMELIST VIEW", gamelist_video_audio);
s->addSaveFunc([gamelist_video_audio, s] {
@ -673,7 +670,7 @@ void GuiMenu::openSoundOptions()
});
// 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(
Settings::getInstance()->getBool("MediaViewerVideoAudio"));
s->addWithLabel("PLAY AUDIO FOR MEDIA VIEWER VIDEOS", media_viewer_video_audio);
@ -687,7 +684,7 @@ void GuiMenu::openSoundOptions()
});
// 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(
Settings::getInstance()->getBool("ScreensaverVideoAudio"));
s->addWithLabel("PLAY AUDIO FOR SCREENSAVER VIDEOS", screensaver_video_audio);
@ -701,7 +698,7 @@ void GuiMenu::openSoundOptions()
});
// Navigation sounds.
auto navigation_sounds = std::make_shared<SwitchComponent>(mWindow);
auto navigation_sounds = std::make_shared<SwitchComponent>();
navigation_sounds->setState(Settings::getInstance()->getBool("NavigationSounds"));
s->addWithLabel("ENABLE NAVIGATION SOUNDS", navigation_sounds);
s->addSaveFunc([navigation_sounds, s] {
@ -719,11 +716,11 @@ void GuiMenu::openSoundOptions()
void GuiMenu::openInputDeviceOptions()
{
auto s = new GuiSettings(mWindow, "INPUT DEVICE SETTINGS");
auto s = new GuiSettings("INPUT DEVICE SETTINGS");
// Controller type.
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");
input_controller_type->add("XBOX", "xbox", selectedPlayer == "xbox");
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.
auto input_only_first_controller = std::make_shared<SwitchComponent>(mWindow);
auto input_only_first_controller = std::make_shared<SwitchComponent>();
input_only_first_controller->setState(
Settings::getInstance()->getBool("InputOnlyFirstController"));
s->addWithLabel("ONLY ACCEPT INPUT FROM FIRST CONTROLLER", input_only_first_controller);
@ -763,10 +760,10 @@ void GuiMenu::openInputDeviceOptions()
ComponentListRow configure_input_row;
configure_input_row.elements.clear();
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),
true);
configure_input_row.addElement(makeArrow(mWindow), false);
configure_input_row.addElement(makeArrow(), false);
configure_input_row.makeAcceptInputHandler(std::bind(&GuiMenu::openConfigInput, this, s));
s->addRow(configure_input_row);
@ -789,34 +786,33 @@ void GuiMenu::openConfigInput(GuiSettings* settings)
"(THIS WILL NOT AFFECT THE HELP PROMPTS)\n"
"CONTINUE?";
Window* window = mWindow;
Window* window {mWindow};
window->pushGui(new GuiMsgBox(
window, getHelpStyle(), message, "YES",
[window] { window->pushGui(new GuiDetectDevice(window, false, false, nullptr)); }, "NO",
nullptr));
getHelpStyle(), message, "YES",
[window] { window->pushGui(new GuiDetectDevice(false, false, nullptr)); }, "NO", nullptr));
}
void GuiMenu::openOtherOptions()
{
auto s = new GuiSettings(mWindow, "OTHER SETTINGS");
auto s = new GuiSettings("OTHER SETTINGS");
// Alternative emulators GUI.
ComponentListRow alternativeEmulatorsRow;
alternativeEmulatorsRow.elements.clear();
alternativeEmulatorsRow.addElement(
std::make_shared<TextComponent>(mWindow, "ALTERNATIVE EMULATORS",
Font::get(FONT_SIZE_MEDIUM), 0x777777FF),
alternativeEmulatorsRow.addElement(std::make_shared<TextComponent>("ALTERNATIVE EMULATORS",
Font::get(FONT_SIZE_MEDIUM),
0x777777FF),
true);
alternativeEmulatorsRow.addElement(makeArrow(mWindow), false);
alternativeEmulatorsRow.addElement(makeArrow(), false);
alternativeEmulatorsRow.makeAcceptInputHandler(
std::bind([this] { mWindow->pushGui(new GuiAlternativeEmulators(mWindow)); }));
std::bind([this] { mWindow->pushGui(new GuiAlternativeEmulators); }));
s->addRow(alternativeEmulatorsRow);
// Game media directory.
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);
auto bracketMediaDirectory = std::make_shared<ImageComponent>(mWindow);
auto bracketMediaDirectory = std::make_shared<ImageComponent>();
bracketMediaDirectory->setImage(":/graphics/arrow.svg");
bracketMediaDirectory->setResize(
glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
@ -838,23 +834,21 @@ void GuiMenu::openOtherOptions()
multiLineMediaDir] {
if (Settings::getInstance()->getBool("VirtualKeyboard")) {
mWindow->pushGui(new GuiTextEditKeyboardPopup(
mWindow, getHelpStyle(), titleMediaDir,
Settings::getInstance()->getString("MediaDirectory"), updateValMediaDir,
multiLineMediaDir, "SAVE", "SAVE CHANGES?", mediaDirectoryStaticText,
defaultDirectoryText, "load default directory"));
getHelpStyle(), titleMediaDir, Settings::getInstance()->getString("MediaDirectory"),
updateValMediaDir, multiLineMediaDir, "SAVE", "SAVE CHANGES?",
mediaDirectoryStaticText, defaultDirectoryText, "load default directory"));
}
else {
mWindow->pushGui(new GuiTextEditPopup(
mWindow, getHelpStyle(), titleMediaDir,
Settings::getInstance()->getString("MediaDirectory"), updateValMediaDir,
multiLineMediaDir, "SAVE", "SAVE CHANGES?", mediaDirectoryStaticText,
defaultDirectoryText, "load default directory"));
getHelpStyle(), titleMediaDir, Settings::getInstance()->getString("MediaDirectory"),
updateValMediaDir, multiLineMediaDir, "SAVE", "SAVE CHANGES?",
mediaDirectoryStaticText, defaultDirectoryText, "load default directory"));
}
});
s->addRow(rowMediaDir);
// 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")));
s->addWithLabel("VRAM LIMIT", max_vram);
s->addSaveFunc([max_vram, s] {
@ -867,7 +861,7 @@ void GuiMenu::openOtherOptions()
// Display/monitor.
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;
displayIndex.push_back("1");
displayIndex.push_back("2");
@ -888,7 +882,7 @@ void GuiMenu::openOtherOptions()
// Exit button configuration.
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");
exit_button_config->add("F4", "F4", selectedExitButtonCombo == "F4");
exit_button_config->add("Alt + F4", "AltF4", selectedExitButtonCombo == "AltF4");
@ -910,7 +904,7 @@ void GuiMenu::openOtherOptions()
// When to save game metadata.
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;
saveModes.push_back("on exit");
saveModes.push_back("always");
@ -938,7 +932,7 @@ void GuiMenu::openOtherOptions()
#if defined(_WIN64)
// 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"));
s->addWithLabel("HIDE TASKBAR (REQUIRES RESTART)", hide_taskbar);
s->addSaveFunc([hide_taskbar, s] {
@ -950,7 +944,7 @@ void GuiMenu::openOtherOptions()
#endif
// 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"));
s->addWithLabel("RUN IN BACKGROUND (WHILE GAME IS LAUNCHED)", run_in_background);
s->addSaveFunc([run_in_background, s] {
@ -962,7 +956,7 @@ void GuiMenu::openOtherOptions()
#if defined(VIDEO_HW_DECODING)
// 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"));
s->addWithLabel("VIDEO HARDWARE DECODING (EXPERIMENTAL)", video_hardware_decoding);
s->addSaveFunc([video_hardware_decoding, s] {
@ -976,7 +970,7 @@ void GuiMenu::openOtherOptions()
#endif
// 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"));
s->addWithLabel("UPSCALE VIDEO FRAME RATE TO 60 FPS", video_upscale_frame_rate);
s->addSaveFunc([video_upscale_frame_rate, s] {
@ -989,7 +983,7 @@ void GuiMenu::openOtherOptions()
});
// 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"));
s->addWithLabel("PRELOAD GAMELISTS ON STARTUP", preloadGamelists);
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
// primarily for testing purposes).
auto alternativeEmulatorPerGame = std::make_shared<SwitchComponent>(mWindow);
auto alternativeEmulatorPerGame = std::make_shared<SwitchComponent>();
alternativeEmulatorPerGame->setState(
Settings::getInstance()->getBool("AlternativeEmulatorPerGame"));
s->addWithLabel("ENABLE ALTERNATIVE EMULATORS PER GAME", alternativeEmulatorPerGame);
@ -1017,7 +1011,7 @@ void GuiMenu::openOtherOptions()
});
// 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"));
s->addWithLabel("SHOW HIDDEN FILES AND FOLDERS (REQUIRES RESTART)", show_hidden_files);
s->addSaveFunc([show_hidden_files, s] {
@ -1028,7 +1022,7 @@ void GuiMenu::openOtherOptions()
});
// 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"));
s->addWithLabel("SHOW HIDDEN GAMES (REQUIRES RESTART)", show_hidden_games);
s->addSaveFunc([show_hidden_games, s] {
@ -1039,7 +1033,7 @@ void GuiMenu::openOtherOptions()
});
// 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"));
s->addWithLabel("ENABLE CUSTOM EVENT SCRIPTS", custom_eventscripts);
s->addSaveFunc([custom_eventscripts, s] {
@ -1051,7 +1045,7 @@ void GuiMenu::openOtherOptions()
});
// 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"));
s->addWithLabel("ONLY SHOW ROMS FROM GAMELIST.XML FILES", parse_gamelist_only);
s->addSaveFunc([parse_gamelist_only, s] {
@ -1064,7 +1058,7 @@ void GuiMenu::openOtherOptions()
#if defined(__unix__)
// 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"));
s->addWithLabel("DISABLE DESKTOP COMPOSITION (REQUIRES RESTART)", disable_composition);
s->addSaveFunc([disable_composition, s] {
@ -1077,7 +1071,7 @@ void GuiMenu::openOtherOptions()
#endif
// 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"));
s->addWithLabel("DISPLAY GPU STATISTICS OVERLAY", display_gpu_statistics);
s->addSaveFunc([display_gpu_statistics, s] {
@ -1090,7 +1084,7 @@ void GuiMenu::openOtherOptions()
});
// 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"));
s->addWithLabel("ENABLE MENU IN KID MODE", enable_menu_kid_mode);
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.
#if !defined(__APPLE__)
// 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"));
s->addWithLabel("SHOW QUIT MENU (REBOOT AND POWER OFF ENTRIES)", show_quit_menu);
s->addSaveFunc([this, show_quit_menu, s] {
@ -1123,7 +1117,7 @@ void GuiMenu::openOtherOptions()
void GuiMenu::openUtilitiesMenu()
{
auto s = new GuiSettings(mWindow, "UTILITIES");
auto s = new GuiSettings("UTILITIES");
s->setSize(mSize);
mWindow->pushGui(s);
}
@ -1132,7 +1126,7 @@ void GuiMenu::openQuitMenu()
{
if (!Settings::getInstance()->getBool("ShowQuitMenu")) {
mWindow->pushGui(new GuiMsgBox(
mWindow, this->getHelpStyle(), "REALLY QUIT?", "YES",
this->getHelpStyle(), "REALLY QUIT?", "YES",
[this] {
Scripting::fireEvent("quit");
close(true);
@ -1141,16 +1135,16 @@ void GuiMenu::openQuitMenu()
"NO", nullptr));
}
else {
auto s = new GuiSettings(mWindow, "QUIT");
auto s = new GuiSettings("QUIT");
Window* window = mWindow;
Window* window {mWindow};
HelpStyle style = getHelpStyle();
ComponentListRow row;
row.makeAcceptInputHandler([window, this] {
window->pushGui(new GuiMsgBox(
window, this->getHelpStyle(), "REALLY QUIT?", "YES",
this->getHelpStyle(), "REALLY QUIT?", "YES",
[this] {
Scripting::fireEvent("quit");
close(true);
@ -1158,7 +1152,7 @@ void GuiMenu::openQuitMenu()
},
"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);
quitText->setSelectable(true);
row.addElement(quitText, true);
@ -1167,7 +1161,7 @@ void GuiMenu::openQuitMenu()
row.elements.clear();
row.makeAcceptInputHandler([window, this] {
window->pushGui(new GuiMsgBox(
window, this->getHelpStyle(), "REALLY REBOOT?", "YES",
this->getHelpStyle(), "REALLY REBOOT?", "YES",
[] {
Scripting::fireEvent("quit", "reboot");
Scripting::fireEvent("reboot");
@ -1177,7 +1171,7 @@ void GuiMenu::openQuitMenu()
},
"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);
rebootText->setSelectable(true);
row.addElement(rebootText, true);
@ -1186,7 +1180,7 @@ void GuiMenu::openQuitMenu()
row.elements.clear();
row.makeAcceptInputHandler([window, this] {
window->pushGui(new GuiMsgBox(
window, this->getHelpStyle(), "REALLY POWER OFF?", "YES",
this->getHelpStyle(), "REALLY POWER OFF?", "YES",
[] {
Scripting::fireEvent("quit", "poweroff");
Scripting::fireEvent("poweroff");
@ -1197,7 +1191,7 @@ void GuiMenu::openQuitMenu()
"NO", nullptr));
});
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);
row.addElement(powerOffText, true);
s->addRow(row);
@ -1218,17 +1212,17 @@ void GuiMenu::addVersionInfo()
void GuiMenu::openMediaViewerOptions()
{
mWindow->pushGui(new GuiMediaViewerOptions(mWindow, "MEDIA VIEWER SETTINGS"));
mWindow->pushGui(new GuiMediaViewerOptions("MEDIA VIEWER SETTINGS"));
}
void GuiMenu::openScreensaverOptions()
{
mWindow->pushGui(new GuiScreensaverOptions(mWindow, "SCREENSAVER SETTINGS"));
mWindow->pushGui(new GuiScreensaverOptions("SCREENSAVER SETTINGS"));
}
void GuiMenu::openCollectionSystemOptions()
{
mWindow->pushGui(new GuiCollectionSystemsOptions(mWindow, "GAME COLLECTION SETTINGS"));
mWindow->pushGui(new GuiCollectionSystemsOptions("GAME COLLECTION SETTINGS"));
}
void GuiMenu::onSizeChanged()
@ -1246,10 +1240,10 @@ void GuiMenu::addEntry(const std::string& name,
// Populate the list.
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) {
std::shared_ptr<ImageComponent> bracket = makeArrow(mWindow);
std::shared_ptr<ImageComponent> bracket {makeArrow()};
row.addElement(bracket, false);
}
@ -1264,7 +1258,7 @@ void GuiMenu::close(bool closeAllWindows)
closeFunc = [this] { delete this; };
}
else {
Window* window = mWindow;
Window* window {mWindow};
closeFunc = [window] {
while (window->peekGui() != ViewController::getInstance())
delete window->peekGui();

View file

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

View file

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

View file

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

View file

@ -13,11 +13,10 @@
#include "components/MenuComponent.h"
#include "views/ViewController.h"
GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue<FileData*>& gameQueue)
: GuiComponent {window}
, mGameQueue {gameQueue}
, mBackground {window, ":/graphics/frame.svg"}
, mGrid {window, glm::ivec2 {6, 13}}
GuiOfflineGenerator::GuiOfflineGenerator(const std::queue<FileData*>& gameQueue)
: mGameQueue {gameQueue}
, mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {6, 13}}
{
addChild(&mBackground);
addChild(&mGrid);
@ -36,108 +35,104 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue<FileDa
mGame = nullptr;
// 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);
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);
mGrid.setEntry(mStatus, glm::ivec2 {0, 1}, false, true, glm::ivec2 {6, 1});
mGameCounter = std::make_shared<TextComponent>(
mWindow,
std::to_string(mGamesProcessed) + " OF " + std::to_string(mTotalGames) +
(mTotalGames == 1 ? " GAME " : " GAMES ") + "PROCESSED",
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
mGrid.setEntry(mGameCounter, glm::ivec2 {0, 2}, false, true, glm::ivec2 {6, 1});
// 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);
// 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});
// Generated label.
mGeneratedLbl = std::make_shared<TextComponent>(
mWindow, "Generated:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mGeneratedLbl = std::make_shared<TextComponent>("Generated:", Font::get(FONT_SIZE_SMALL),
0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mGeneratedLbl, glm::ivec2 {1, 4}, false, true, glm::ivec2 {1, 1});
// Generated value/counter.
mGeneratedVal =
std::make_shared<TextComponent>(mWindow, std::to_string(mGamesProcessed),
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mGeneratedVal = std::make_shared<TextComponent>(
std::to_string(mGamesProcessed), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mGeneratedVal, glm::ivec2 {2, 4}, false, true, glm::ivec2 {1, 1});
// Overwritten label.
mOverwrittenLbl = std::make_shared<TextComponent>(
mWindow, "Overwritten:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mOverwrittenLbl = std::make_shared<TextComponent>("Overwritten:", Font::get(FONT_SIZE_SMALL),
0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mOverwrittenLbl, glm::ivec2 {1, 5}, false, true, glm::ivec2 {1, 1});
// Overwritten value/counter.
mOverwrittenVal =
std::make_shared<TextComponent>(mWindow, std::to_string(mImagesOverwritten),
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mOverwrittenVal = std::make_shared<TextComponent>(
std::to_string(mImagesOverwritten), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mOverwrittenVal, glm::ivec2 {2, 5}, false, true, glm::ivec2 {1, 1});
// Skipping label.
mSkippedLbl = std::make_shared<TextComponent>(
mWindow, "Skipped (existing):", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mSkippedLbl = std::make_shared<TextComponent>("Skipped (existing):", Font::get(FONT_SIZE_SMALL),
0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mSkippedLbl, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1});
// Skipping value/counter.
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});
// Failed label.
mFailedLbl = std::make_shared<TextComponent>(mWindow, "Failed:", Font::get(FONT_SIZE_SMALL),
0x888888FF, ALIGN_LEFT);
mFailedLbl = std::make_shared<TextComponent>("Failed:", Font::get(FONT_SIZE_SMALL), 0x888888FF,
ALIGN_LEFT);
mGrid.setEntry(mFailedLbl, glm::ivec2 {1, 7}, false, true, glm::ivec2 {1, 1});
// Failed value/counter.
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});
// Processing label.
mProcessingLbl = std::make_shared<TextComponent>(
mWindow, "Processing: ", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
mProcessingLbl = std::make_shared<TextComponent>("Processing: ", Font::get(FONT_SIZE_SMALL),
0x888888FF, ALIGN_LEFT);
mGrid.setEntry(mProcessingLbl, glm::ivec2 {3, 4}, false, true, glm::ivec2 {1, 1});
// Processing value.
mProcessingVal = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_SMALL),
0x888888FF, ALIGN_LEFT);
mProcessingVal =
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});
// 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});
// Last error message label.
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});
// Last error message value.
mLastErrorVal = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_SMALL),
0x888888FF, ALIGN_LEFT);
mLastErrorVal =
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});
// 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});
// 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);
// Buttons.
std::vector<std::shared_ptr<ButtonComponent>> buttons;
mStartPauseButton =
std::make_shared<ButtonComponent>(mWindow, "START", "start processing", [this]() {
mStartPauseButton = std::make_shared<ButtonComponent>("START", "start processing", [this]() {
if (!mProcessing) {
mProcessing = true;
mPaused = false;
@ -162,7 +157,7 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue<FileDa
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) {
LOG(LogInfo) << "GuiOfflineGenerator: Aborted after processing " << mGamesProcessed
<< (mGamesProcessed == 1 ? " game (" : " games (") << mImagesGenerated
@ -175,7 +170,7 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue<FileDa
});
buttons.push_back(mCloseButton);
mButtonGrid = makeButtonGrid(mWindow, buttons);
mButtonGrid = makeButtonGrid(buttons);
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
{
public:
GuiOfflineGenerator(Window* window, const std::queue<FileData*>& gameQueue);
GuiOfflineGenerator(const std::queue<FileData*>& gameQueue);
~GuiOfflineGenerator();
private:

View file

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

View file

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

View file

@ -24,12 +24,10 @@
#include "guis/GuiScraperSearch.h"
#include "views/ViewController.h"
GuiScraperMulti::GuiScraperMulti(Window* window,
const std::queue<ScraperSearchParams>& searches,
GuiScraperMulti::GuiScraperMulti(const std::queue<ScraperSearchParams>& searches,
bool approveResults)
: GuiComponent {window}
, mBackground {window, ":/graphics/frame.svg"}
, mGrid {window, glm::ivec2 {2, 6}}
: mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {2, 6}}
, mSearchQueue {searches}
, mApproveResults {approveResults}
{
@ -46,27 +44,27 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
mTotalSkipped = 0;
// Set up grid.
mTitle = std::make_shared<TextComponent>(mWindow, "SCRAPING IN PROGRESS",
Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
mTitle = std::make_shared<TextComponent>("SCRAPING IN PROGRESS", Font::get(FONT_SIZE_LARGE),
0x555555FF, ALIGN_CENTER);
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),
0x777777FF, ALIGN_CENTER);
mSystem = std::make_shared<TextComponent>("SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF,
ALIGN_CENTER);
mGrid.setEntry(mSystem, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1});
mSubtitle = std::make_shared<TextComponent>(
mWindow, "subtitle text", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
mSubtitle = std::make_shared<TextComponent>("subtitle text", Font::get(FONT_SIZE_SMALL),
0x888888FF, ALIGN_CENTER);
mGrid.setEntry(mSubtitle, glm::ivec2 {0, 3}, false, true, glm::ivec2 {2, 1});
if (mApproveResults && !Settings::getInstance()->getBool("ScraperSemiautomatic"))
mSearchComp = std::make_shared<GuiScraperSearch>(
mWindow, GuiScraperSearch::NEVER_AUTO_ACCEPT, mTotalGames);
mSearchComp =
std::make_shared<GuiScraperSearch>(GuiScraperSearch::NEVER_AUTO_ACCEPT, mTotalGames);
else if (mApproveResults && Settings::getInstance()->getBool("ScraperSemiautomatic"))
mSearchComp = std::make_shared<GuiScraperSearch>(
mWindow, GuiScraperSearch::ACCEPT_SINGLE_MATCHES, mTotalGames);
mSearchComp = std::make_shared<GuiScraperSearch>(GuiScraperSearch::ACCEPT_SINGLE_MATCHES,
mTotalGames);
else if (!mApproveResults)
mSearchComp = std::make_shared<GuiScraperSearch>(
mWindow, GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT, mTotalGames);
GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT, mTotalGames);
mSearchComp->setAcceptCallback(
std::bind(&GuiScraperMulti::acceptResult, this, std::placeholders::_1));
mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this));
@ -84,8 +82,8 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
mResultList = mSearchComp->getResultList();
// Set up scroll indicators.
mScrollUp = std::make_shared<ImageComponent>(mWindow);
mScrollDown = std::make_shared<ImageComponent>(mWindow);
mScrollUp = std::make_shared<ImageComponent>();
mScrollDown = std::make_shared<ImageComponent>();
mScrollIndicator =
std::make_shared<ScrollIndicatorComponent>(mResultList, mScrollUp, mScrollDown);
@ -102,8 +100,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
std::vector<std::shared_ptr<ButtonComponent>> buttons;
if (mApproveResults) {
buttons.push_back(
std::make_shared<ButtonComponent>(mWindow, "REFINE SEARCH", "refine search", [&] {
buttons.push_back(std::make_shared<ButtonComponent>("REFINE SEARCH", "refine search", [&] {
// Check whether we should allow a refine of the game name.
if (!mSearchComp->getAcceptedResult()) {
bool allowRefine = false;
@ -112,18 +109,15 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
if (mSearchComp->getRefinedSearch())
allowRefine = true;
// Interactive mode and "Auto-accept single game matches" not enabled.
else if (mSearchComp->getSearchType() !=
GuiScraperSearch::ACCEPT_SINGLE_MATCHES)
else if (mSearchComp->getSearchType() != GuiScraperSearch::ACCEPT_SINGLE_MATCHES)
allowRefine = true;
// Interactive mode with "Auto-accept single game matches" enabled and more
// than one result.
else if (mSearchComp->getSearchType() ==
GuiScraperSearch::ACCEPT_SINGLE_MATCHES &&
else if (mSearchComp->getSearchType() == GuiScraperSearch::ACCEPT_SINGLE_MATCHES &&
mSearchComp->getScraperResultsSize() > 1)
allowRefine = true;
// Dito but there were no games found, or the search has not been completed.
else if (mSearchComp->getSearchType() ==
GuiScraperSearch::ACCEPT_SINGLE_MATCHES &&
else if (mSearchComp->getSearchType() == GuiScraperSearch::ACCEPT_SINGLE_MATCHES &&
!mSearchComp->getFoundGame())
allowRefine = true;
@ -137,7 +131,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
}
}));
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.
if (!mSearchComp->getAcceptedResult()) {
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)));
mButtonGrid = makeButtonGrid(mWindow, buttons);
mButtonGrid = makeButtonGrid(buttons);
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
@ -309,7 +303,7 @@ void GuiScraperMulti::finish()
<< 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;
delete this;
}));

View file

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

View file

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

View file

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

View file

@ -18,18 +18,16 @@
#include "components/TextComponent.h"
#include "views/ViewController.h"
GuiScraperSingle::GuiScraperSingle(Window* window,
ScraperSearchParams& params,
GuiScraperSingle::GuiScraperSingle(ScraperSearchParams& params,
std::function<void(const ScraperSearchResult&)> doneFunc,
bool& savedMediaAndAborted)
: GuiComponent {window}
, mClose {false}
, mGrid {window, glm::ivec2 {2, 6}}
, mBox {window, ":/graphics/frame.svg"}
: mClose {false}
, mGrid {glm::ivec2 {2, 6}}
, mBackground {":/graphics/frame.svg"}
, mSearchParams {params}
, mSavedMediaAndAborted {savedMediaAndAborted}
{
addChild(&mBox);
addChild(&mBackground);
addChild(&mGrid);
std::string scrapeName;
@ -48,29 +46,28 @@ GuiScraperSingle::GuiScraperSingle(Window* window,
}
mGameName = std::make_shared<TextComponent>(
mWindow,
scrapeName +
((mSearchParams.game->getType() == FOLDER) ? " " + ViewController::FOLDER_CHAR : ""),
Font::get(FONT_SIZE_LARGE), 0x777777FF, ALIGN_CENTER);
mGameName->setColor(0x555555FF);
mGrid.setEntry(mGameName, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2});
mSystemName = std::make_shared<TextComponent>(
mWindow, Utils::String::toUpper(mSearchParams.system->getFullName()),
mSystemName =
std::make_shared<TextComponent>(Utils::String::toUpper(mSearchParams.system->getFullName()),
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
mGrid.setEntry(mSystemName, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1});
// Row 3 is a spacer.
// 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});
mResultList = mSearch->getResultList();
// Set up scroll indicators.
mScrollUp = std::make_shared<ImageComponent>(mWindow);
mScrollDown = std::make_shared<ImageComponent>(mWindow);
mScrollUp = std::make_shared<ImageComponent>();
mScrollDown = std::make_shared<ImageComponent>();
mScrollIndicator =
std::make_shared<ScrollIndicatorComponent>(mResultList, mScrollUp, mScrollDown);
@ -86,8 +83,7 @@ GuiScraperSingle::GuiScraperSingle(Window* window,
// Buttons
std::vector<std::shared_ptr<ButtonComponent>> buttons;
buttons.push_back(
std::make_shared<ButtonComponent>(mWindow, "REFINE SEARCH", "refine search", [&] {
buttons.push_back(std::make_shared<ButtonComponent>("REFINE SEARCH", "refine search", [&] {
// Refine the search, unless the result has already been accepted.
if (!mSearch->getAcceptedResult()) {
// Copy any search refine that may have been previously entered by opening
@ -97,7 +93,7 @@ GuiScraperSingle::GuiScraperSingle(Window* window,
mGrid.resetCursor();
}
}));
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CANCEL", "cancel", [&] {
buttons.push_back(std::make_shared<ButtonComponent>("CANCEL", "cancel", [&] {
if (mSearch->getSavedNewMedia()) {
// 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
@ -107,7 +103,7 @@ GuiScraperSingle::GuiScraperSingle(Window* window,
}
delete this;
}));
mButtonGrid = makeButtonGrid(mWindow, buttons);
mButtonGrid = makeButtonGrid(buttons);
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.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.
const float newSizeX = mSize.x * 0.96f;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -57,7 +57,7 @@ public:
const std::vector<std::string>& getFirstLetterIndex() { return mFirstLetterIndex; }
protected:
GamelistBase(Window* window, FileData* root);
GamelistBase(FileData* root);
~GamelistBase();
// 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_TIME 650
GamelistView::GamelistView(Window* window, FileData* root)
: GamelistBase {window, root}
GamelistView::GamelistView(FileData* root)
: GamelistBase {root}
, mViewStyle {ViewController::BASIC}
, mHeaderText {window}
, 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}
, mVideo {nullptr}
{
mViewStyle = ViewController::getInstance()->getState().viewstyle;
@ -72,7 +45,7 @@ GamelistView::GamelistView(Window* window, FileData* root)
if (mViewStyle == ViewController::VIDEO) {
// Create the video window.
mVideo = new VideoFFmpegComponent(window);
mVideo = new VideoFFmpegComponent;
}
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();
// Add new theme extras.
mThemeExtras = ThemeData::makeExtras(theme, getName(), mWindow);
mThemeExtras = ThemeData::makeExtras(theme, getName());
for (auto extra : mThemeExtras)
addChild(extra);
@ -304,8 +277,6 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
void GamelistView::update(int deltaTime)
{
mImage.update(deltaTime);
if (ViewController::getInstance()->getGameLaunchTriggered() && mImage.isAnimationPlaying(0))
mImage.finishAnimation(0);
@ -315,12 +286,12 @@ void GamelistView::update(int deltaTime)
else if (mVideoPlaying && !mVideo->isVideoPaused() && !mWindow->isScreensaverActive())
mVideo->onShow();
mVideo->update(deltaTime);
if (ViewController::getInstance()->getGameLaunchTriggered() &&
mVideo->isAnimationPlaying(0))
mVideo->finishAnimation(0);
}
updateChildren(deltaTime);
}
void GamelistView::render(const glm::mat4& parentTrans)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -37,7 +37,7 @@ class Window;
class GuiComponent
{
public:
GuiComponent(Window* window);
GuiComponent();
virtual ~GuiComponent();
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)
{
const std::string unreserved =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~";
const std::string unreserved {
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~"};
std::string escaped = "";
std::string escaped {""};
for (size_t i = 0; i < s.length(); ++i) {
if (unreserved.find_first_of(s[i]) != std::string::npos) {
escaped.push_back(s[i]);

View file

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

View file

@ -45,7 +45,7 @@ public:
std::string getDeviceGUIDString(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()); }
@ -62,6 +62,7 @@ private:
void addControllerByDeviceIndex(Window* window, int deviceIndex);
void removeControllerByJoystickID(Window* window, SDL_JoystickID joyID);
Window* mWindow;
CECInput mCECInput;
static const int DEADZONE_TRIGGERS = 18000;

View file

@ -26,7 +26,7 @@ MameNames& MameNames::getInstance()
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))
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,
const std::string& view,
Window* window)
const std::string& view)
{
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.
it != viewIt->second.orderedKeys.cend(); ++it) {
ThemeElement& elem = viewIt->second.elements.at(*it);
ThemeElement& elem {viewIt->second.elements.at(*it)};
if (elem.extra) {
GuiComponent* comp = nullptr;
const std::string& t = elem.type;
GuiComponent* comp {nullptr};
const std::string& t {elem.type};
if (t == "image")
comp = new ImageComponent(window);
comp = new ImageComponent;
else if (t == "text")
comp = new TextComponent(window);
comp = new TextComponent;
else if (t == "animation")
comp = new LottieComponent(window);
comp = new LottieComponent;
if (comp) {
comp->setDefaultZIndex(10.0f);

View file

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

View file

@ -119,8 +119,8 @@ bool Window::init()
ResourceManager::getInstance().reloadAll();
mHelp = new HelpComponent(this);
mBackgroundOverlay = new ImageComponent(this);
mHelp = new HelpComponent;
mBackgroundOverlay = new ImageComponent;
mBackgroundOverlayOpacity = 0;
// 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) {
delete mInfoPopup;
mInfoPopup = new GuiInfoPopup(this, mInfoPopupQueue.front().first,
mInfoPopupQueue.front().second);
mInfoPopup =
new GuiInfoPopup(mInfoPopupQueue.front().first, mInfoPopupQueue.front().second);
mInfoPopupQueue.pop();
}
}
@ -618,7 +618,7 @@ void Window::renderLoadingScreen(std::string text)
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
ImageComponent splash(this, true);
ImageComponent splash(true);
splash.setImage(":/graphics/splash.svg");
splash.setResize(Renderer::getScreenWidth() * 0.6f, 0.0f);
splash.setPosition((Renderer::getScreenWidth() - splash.getSize().x) / 2.0f,
@ -723,7 +723,7 @@ void Window::reloadHelpPrompts()
{
if (mHelp) {
delete mHelp;
mHelp = new HelpComponent(this);
mHelp = new HelpComponent;
}
}

View file

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

View file

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

View file

@ -12,9 +12,8 @@
#include "components/ImageComponent.h"
#include "resources/ResourceManager.h"
AnimatedImageComponent::AnimatedImageComponent(Window* window)
: GuiComponent {window}
, mEnabled {false}
AnimatedImageComponent::AnimatedImageComponent()
: mEnabled {false}
{
}
@ -32,7 +31,7 @@ void AnimatedImageComponent::load(const AnimationDef* def)
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->setImage(std::string(def->frames[i].path), false);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -10,7 +10,6 @@
#define ES_CORE_COMPONENTS_FLEXBOX_COMPONENT_H
#include "GuiComponent.h"
#include "Window.h"
#include "components/ImageComponent.h"
class FlexboxComponent : public GuiComponent
@ -20,13 +19,13 @@ public:
// Optional label, mostly a convenience for the calling class to track items.
std::string label;
// 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.
ImageComponent overlayImage {nullptr};
ImageComponent overlayImage;
bool visible = false;
};
FlexboxComponent(Window* window, std::vector<FlexboxItem>& items);
FlexboxComponent(std::vector<FlexboxItem>& items);
// Getters/setters for the layout.
const std::string& getDirection() const { return mDirection; }

View file

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

View file

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

View file

@ -19,17 +19,17 @@
static std::map<std::string, std::string> sIconPathMap {};
HelpComponent::HelpComponent(Window* window)
: GuiComponent {window}
HelpComponent::HelpComponent()
{
// Assign icons.
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();
// These graphics files are common between all controller types.
@ -202,8 +202,7 @@ void HelpComponent::updateGrid()
std::shared_ptr<Font>& font = mStyle.font;
mGrid = std::make_shared<ComponentGrid>(mWindow,
glm::ivec2 {static_cast<int>(mPrompts.size()) * 4, 1});
mGrid = std::make_shared<ComponentGrid>(glm::ivec2 {static_cast<int>(mPrompts.size()) * 4, 1});
// [icon] [spacer1] [text] [spacer2]
@ -217,7 +216,7 @@ void HelpComponent::updateGrid()
bool isDimmed = mWindow->isBackgroundDimmed();
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->setColorShift(isDimmed ? mStyle.iconColorDimmed : mStyle.iconColor);
icon->setResize(0, height);
@ -232,7 +231,7 @@ void HelpComponent::updateGrid()
else
lblInput = Utils::String::toUpper(lblInput);
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);
width +=

View file

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

View file

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

View file

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

View file

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

View file

@ -55,7 +55,7 @@ public:
using IList<ImageGridData, T>::isScrolling;
using IList<ImageGridData, T>::stopScrolling;
ImageGridComponent(Window* window);
ImageGridComponent();
void add(const std::string& name, const std::string& imagePath, const T& obj);
@ -122,9 +122,7 @@ private:
std::function<void(CursorState state)> mCursorChangedCallback;
};
template <typename T>
ImageGridComponent<T>::ImageGridComponent(Window* window)
: IList<ImageGridData, T>(window)
template <typename T> ImageGridComponent<T>::ImageGridComponent()
{
glm::vec2 screen {static_cast<float>(Renderer::getScreenWidth()),
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 x = 0; x < (vert ? mGridDimension.x : mGridDimension.y); ++x) {
// 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 Horizontal mode, tiles are ordered from top to bottom, then from left to right.

View file

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

View file

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

View file

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

View file

@ -22,14 +22,13 @@ class ButtonComponent;
class ImageComponent;
std::shared_ptr<ComponentGrid> makeButtonGrid(
Window* window, const std::vector<std::shared_ptr<ButtonComponent>>& buttons);
std::shared_ptr<ImageComponent> makeArrow(Window* window);
const std::vector<std::shared_ptr<ButtonComponent>>& buttons);
std::shared_ptr<ImageComponent> makeArrow();
class MenuComponent : public GuiComponent
{
public:
MenuComponent(Window* window,
std::string title,
MenuComponent(std::string title,
const std::shared_ptr<Font>& titleFont = Font::get(FONT_SIZE_LARGE));
virtual ~MenuComponent();
@ -51,7 +50,7 @@ public:
bool invert_when_selected = true)
{
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),
true);
row.addElement(comp, false, invert_when_selected);

View file

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

View file

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

View file

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

View file

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

View file

@ -20,7 +20,7 @@ class TextureResource;
class RatingComponent : public GuiComponent
{
public:
RatingComponent(Window* window, bool colorizeChanges = false);
RatingComponent(bool colorizeChanges = false);
std::string getValue() const override;
// 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 "resources/Font.h"
ScrollableContainer::ScrollableContainer(Window* window)
: GuiComponent {window}
, mScrollPos {0.0f, 0.0f}
ScrollableContainer::ScrollableContainer()
: mScrollPos {0.0f, 0.0f}
, mScrollDir {0.0f, 0.0f}
, mClipSpacing {0.0f}
, mAutoScrollDelay {0}

View file

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

View file

@ -14,15 +14,12 @@
#define MOVE_REPEAT_DELAY 500
#define MOVE_REPEAT_RATE 40
SliderComponent::SliderComponent(
Window* window, float min, float max, float increment, const std::string& suffix)
: GuiComponent {window}
, mMin {min}
SliderComponent::SliderComponent(float min, float max, float increment, const std::string& suffix)
: mMin {min}
, mMax {max}
, mSingleIncrement {increment}
, mMoveRate {0.0f}
, mBarHeight {0.0f}
, mKnob {window}
, mSuffix {suffix}
{
assert((min - max) != 0.0f);
@ -33,7 +30,8 @@ SliderComponent::SliderComponent(
mKnob.setOrigin(0.5f, 0.5f);
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)

View file

@ -15,17 +15,16 @@
class Font;
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
{
public:
using GuiComponent::getValue;
using GuiComponent::setValue;
// Minimum value (far left of the slider), maximum value (far right of the slider),
// increment size (how much pressing L/R moves by), unit to display (optional).
SliderComponent(
Window* window, float min, float max, float increment, const std::string& suffix = "");
// Minimum and maximum values, how much to increment each step the knob is moved and
// an optional unit.
SliderComponent(float min, float max, float increment, const std::string& suffix = "");
void setValue(float value);
float getValue() { return mValue; }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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