mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
Fixed lots of code formatting issues.
This commit is contained in:
parent
a928142d5b
commit
f6dd49071e
|
@ -550,7 +550,8 @@ bool CollectionSystemsManager::isThemeCustomCollectionCompatible(
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string CollectionSystemsManager::getValidNewCollectionName(std::string inName, int index) {
|
||||
std::string CollectionSystemsManager::getValidNewCollectionName(std::string inName, int index)
|
||||
{
|
||||
std::string name = inName;
|
||||
|
||||
// Trim leading and trailing whitespaces.
|
||||
|
@ -569,7 +570,8 @@ std::string CollectionSystemsManager::getValidNewCollectionName(std::string inNa
|
|||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-[]()' ")) !=
|
||||
std::string::npos)
|
||||
name.erase(remove, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
name += " (" + std::to_string(index) + ")";
|
||||
}
|
||||
|
||||
|
@ -1331,7 +1333,8 @@ void CollectionSystemsManager::addEnabledCollectionsToDisplayedSystems(
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> CollectionSystemsManager::getSystemsFromConfig() {
|
||||
std::vector<std::string> CollectionSystemsManager::getSystemsFromConfig()
|
||||
{
|
||||
std::vector<std::string> systems;
|
||||
std::vector<std::string> configPaths = SystemData::getConfigPath(false);
|
||||
|
||||
|
|
|
@ -33,8 +33,15 @@ FileData::FileData(FileType type,
|
|||
const std::string& path,
|
||||
SystemEnvironmentData* envData,
|
||||
SystemData* system)
|
||||
: metadata(type == GAME ? GAME_METADATA : FOLDER_METADATA), mSourceFileData(nullptr), mParent(nullptr),
|
||||
mType(type), mPath(path), mEnvData(envData), mSystem(system), mOnlyFolders(false), mDeletionFlag(false)
|
||||
: metadata(type == GAME ? GAME_METADATA : FOLDER_METADATA)
|
||||
, mSourceFileData(nullptr)
|
||||
, mParent(nullptr)
|
||||
, mType(type)
|
||||
, mPath(path)
|
||||
, mEnvData(envData)
|
||||
, mSystem(system)
|
||||
, mOnlyFolders(false)
|
||||
, mDeletionFlag(false)
|
||||
{
|
||||
// Metadata needs at least a name field (since that's what getName() will return).
|
||||
if (metadata.get("name").empty()) {
|
||||
|
@ -735,7 +742,8 @@ FileData::SortType FileData::getSortTypeFromString(std::string desc)
|
|||
return FileSorts::SortTypes.at(0);
|
||||
}
|
||||
|
||||
void FileData::launchGame(Window *window) {
|
||||
void FileData::launchGame(Window* window)
|
||||
{
|
||||
LOG(LogInfo) << "Launching game \"" << this->metadata.get("name") << "\"...";
|
||||
|
||||
SystemData* gameSystem = nullptr;
|
||||
|
|
|
@ -20,9 +20,17 @@
|
|||
#define INCLUDE_UNKNOWN false;
|
||||
|
||||
FileFilterIndex::FileFilterIndex()
|
||||
: mFilterByText(false), mTextRemoveSystem(false), mFilterByFavorites(false), mFilterByGenre(false),
|
||||
mFilterByPlayers(false), mFilterByPubDev(false), mFilterByRatings(false), mFilterByKidGame(false),
|
||||
mFilterByCompleted(false), mFilterByBroken(false), mFilterByHidden(false)
|
||||
: mFilterByText(false)
|
||||
, mTextRemoveSystem(false)
|
||||
, mFilterByFavorites(false)
|
||||
, mFilterByGenre(false)
|
||||
, mFilterByPlayers(false)
|
||||
, mFilterByPubDev(false)
|
||||
, mFilterByRatings(false)
|
||||
, mFilterByKidGame(false)
|
||||
, mFilterByCompleted(false)
|
||||
, mFilterByBroken(false)
|
||||
, mFilterByHidden(false)
|
||||
{
|
||||
clearAllFilters();
|
||||
|
||||
|
@ -359,7 +367,8 @@ bool FileFilterIndex::showFile(FileData* game)
|
|||
!(Utils::String::toUpper(game->getName().substr(0, game->getName().find_last_of("[")))
|
||||
.find(mTextFilter) != std::string::npos)) {
|
||||
return false;
|
||||
} else if (mTextFilter != "" &&
|
||||
}
|
||||
else if (mTextFilter != "" &&
|
||||
!(Utils::String::toUpper(game->getName()).find(mTextFilter) != std::string::npos)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -372,7 +381,8 @@ bool FileFilterIndex::showFile(FileData* game)
|
|||
FilterDataDecl filterData = (*it);
|
||||
if (filterData.primaryKey == "kidgame" && UIModeController::getInstance()->isUIModeKid()) {
|
||||
return (getIndexableKey(game, filterData.type, false) != "FALSE");
|
||||
} else if (*(filterData.filteredByRef)) {
|
||||
}
|
||||
else if (*(filterData.filteredByRef)) {
|
||||
// Try to find a match.
|
||||
std::string key = getIndexableKey(game, filterData.type, false);
|
||||
keepGoing = isKeyBeingFilteredBy(key, filterData.type);
|
||||
|
|
|
@ -227,7 +227,8 @@ namespace FileSorts
|
|||
return system1.compare(system2) < 0;
|
||||
}
|
||||
|
||||
bool compareSystemDescending(const FileData *file1, const FileData *file2) {
|
||||
bool compareSystemDescending(const FileData* file1, const FileData* file2)
|
||||
{
|
||||
std::string system1 = Utils::String::toUpper(file1->getSystemName());
|
||||
std::string system2 = Utils::String::toUpper(file2->getSystemName());
|
||||
return system1.compare(system2) > 0;
|
||||
|
|
|
@ -216,7 +216,8 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
|
|||
mWindow, getHelpStyle(), "New Collection Name", "", createCollectionCall, false,
|
||||
"CREATE", "CREATE COLLECTION?"));
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
row.makeAcceptInputHandler([this, createCollectionCall] {
|
||||
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), "New Collection Name",
|
||||
"", createCollectionCall, false, "CREATE",
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
GuiGameScraper::GuiGameScraper(Window* window,
|
||||
ScraperSearchParams params,
|
||||
std::function<void(const ScraperSearchResult&)> doneFunc)
|
||||
: GuiComponent(window), mClose(false), mGrid(window, glm::ivec2{1, 7}), mBox(window, ":/graphics/frame.svg"),
|
||||
mSearchParams(params)
|
||||
: GuiComponent(window)
|
||||
, mClose(false)
|
||||
, mGrid(window, glm::ivec2{1, 7})
|
||||
, mBox(window, ":/graphics/frame.svg")
|
||||
, mSearchParams(params)
|
||||
{
|
||||
addChild(&mBox);
|
||||
addChild(&mGrid);
|
||||
|
|
|
@ -29,7 +29,8 @@ GuiGamelistFilter::GuiGamelistFilter(Window* window,
|
|||
initializeMenu();
|
||||
}
|
||||
|
||||
void GuiGamelistFilter::initializeMenu() {
|
||||
void GuiGamelistFilter::initializeMenu()
|
||||
{
|
||||
addChild(&mMenu);
|
||||
|
||||
// Get filters from system.
|
||||
|
@ -93,7 +94,8 @@ void GuiGamelistFilter::resetAllFilters()
|
|||
|
||||
GuiGamelistFilter::~GuiGamelistFilter() { mFilterOptions.clear(); }
|
||||
|
||||
void GuiGamelistFilter::addFiltersToMenu() {
|
||||
void GuiGamelistFilter::addFiltersToMenu()
|
||||
{
|
||||
ComponentListRow row;
|
||||
|
||||
auto lbl = std::make_shared<TextComponent>(
|
||||
|
@ -132,7 +134,8 @@ void GuiGamelistFilter::addFiltersToMenu() {
|
|||
mTextFilterField->getValue(), updateVal,
|
||||
false, "OK", "APPLY CHANGES?"));
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
row.makeAcceptInputHandler([this, updateVal] {
|
||||
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), "GAME NAME",
|
||||
mTextFilterField->getValue(), updateVal, false,
|
||||
|
|
|
@ -26,8 +26,14 @@
|
|||
#include "views/gamelist/IGameListView.h"
|
||||
|
||||
GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
|
||||
: GuiComponent(window), mMenu(window, "OPTIONS"), mSystem(system), mFiltersChanged(false), mCancelled(false),
|
||||
mIsCustomCollection(false), mIsCustomCollectionGroup(false), mCustomCollectionSystem(nullptr)
|
||||
: GuiComponent(window)
|
||||
, mMenu(window, "OPTIONS")
|
||||
, mSystem(system)
|
||||
, mFiltersChanged(false)
|
||||
, mCancelled(false)
|
||||
, mIsCustomCollection(false)
|
||||
, mIsCustomCollectionGroup(false)
|
||||
, mCustomCollectionSystem(nullptr)
|
||||
{
|
||||
addChild(&mMenu);
|
||||
|
||||
|
|
|
@ -15,8 +15,11 @@
|
|||
#include "utils/StringUtil.h"
|
||||
|
||||
GuiLaunchScreen::GuiLaunchScreen(Window* window)
|
||||
: GuiComponent(window), mWindow(window), mBackground(window, ":/graphics/frame.svg"), mGrid(nullptr),
|
||||
mMarquee(nullptr)
|
||||
: GuiComponent(window)
|
||||
, mWindow(window)
|
||||
, mBackground(window, ":/graphics/frame.svg")
|
||||
, mGrid(nullptr)
|
||||
, mMarquee(nullptr)
|
||||
{
|
||||
addChild(&mBackground);
|
||||
mWindow->setLaunchScreen(this);
|
||||
|
@ -217,7 +220,8 @@ void GuiLaunchScreen::update(int deltaTime)
|
|||
mScaleUp = glm::clamp(mScaleUp + 0.07f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void GuiLaunchScreen::render(const glm::mat4 & /*parentTrans*/) {
|
||||
void GuiLaunchScreen::render(const glm::mat4& /*parentTrans*/)
|
||||
{
|
||||
// Scale up animation.
|
||||
if (mScaleUp < 1.0f)
|
||||
setScale(mScaleUp);
|
||||
|
|
|
@ -37,7 +37,9 @@
|
|||
#include <algorithm>
|
||||
|
||||
GuiMenu::GuiMenu(Window* window)
|
||||
: GuiComponent(window), mMenu(window, "MAIN MENU"), mVersion(window)
|
||||
: GuiComponent(window)
|
||||
, mMenu(window, "MAIN MENU")
|
||||
, mVersion(window)
|
||||
{
|
||||
bool isFullUI = UIModeController::getInstance()->isUIModeFull();
|
||||
|
||||
|
@ -826,7 +828,8 @@ void GuiMenu::openOtherOptions()
|
|||
Settings::getInstance()->getString("MediaDirectory"), updateValMediaDir,
|
||||
multiLineMediaDir, "SAVE", "SAVE CHANGES?", mediaDirectoryStaticText,
|
||||
defaultDirectoryText, "load default directory"));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mWindow->pushGui(new GuiTextEditPopup(
|
||||
mWindow, getHelpStyle(), titleMediaDir,
|
||||
Settings::getInstance()->getString("MediaDirectory"), updateValMediaDir,
|
||||
|
|
|
@ -39,10 +39,17 @@ GuiMetaDataEd::GuiMetaDataEd(Window *window,
|
|||
std::function<void()> saveCallback,
|
||||
std::function<void()> clearGameFunc,
|
||||
std::function<void()> deleteGameFunc)
|
||||
: GuiComponent(window), mBackground(window, ":/graphics/frame.svg"), mGrid(window, glm::ivec2{1, 3}),
|
||||
mScraperParams(scraperParams), mMetaDataDecl(mdd), mMetaData(md), mSavedCallback(saveCallback),
|
||||
mClearGameFunc(clearGameFunc), mDeleteGameFunc(deleteGameFunc), mMediaFilesUpdated(false),
|
||||
mInvalidEmulatorEntry(false)
|
||||
: GuiComponent(window)
|
||||
, mBackground(window, ":/graphics/frame.svg")
|
||||
, mGrid(window, glm::ivec2{1, 3})
|
||||
, mScraperParams(scraperParams)
|
||||
, mMetaDataDecl(mdd)
|
||||
, mMetaData(md)
|
||||
, mSavedCallback(saveCallback)
|
||||
, mClearGameFunc(clearGameFunc)
|
||||
, mDeleteGameFunc(deleteGameFunc)
|
||||
, mMediaFilesUpdated(false)
|
||||
, mInvalidEmulatorEntry(false)
|
||||
{
|
||||
addChild(&mBackground);
|
||||
addChild(&mGrid);
|
||||
|
@ -356,7 +363,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window *window,
|
|||
ed->setColor(DEFAULT_TEXTCOLOR);
|
||||
else
|
||||
ed->setColor(TEXTCOLOR_USERMARKED);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ed->setValue(newVal);
|
||||
if (newVal == originalValue)
|
||||
ed->setColor(DEFAULT_TEXTCOLOR);
|
||||
|
@ -371,7 +379,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window *window,
|
|||
mWindow, getHelpStyle(), title, ed->getValue(), updateVal, multiLine,
|
||||
"apply", "APPLY CHANGES?", "", ""));
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
row.makeAcceptInputHandler([this, title, ed, updateVal, multiLine] {
|
||||
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), title,
|
||||
ed->getValue(), updateVal, multiLine,
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
#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})
|
||||
: GuiComponent(window)
|
||||
, mGameQueue(gameQueue)
|
||||
, mBackground(window, ":/graphics/frame.svg")
|
||||
, mGrid(window, glm::ivec2{6, 13})
|
||||
{
|
||||
addChild(&mBackground);
|
||||
addChild(&mGrid);
|
||||
|
|
|
@ -38,8 +38,14 @@
|
|||
#define FAILED_VERIFICATION_RETRIES 8
|
||||
|
||||
GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int scrapeCount)
|
||||
: GuiComponent(window), mGrid(window, glm::ivec2{4, 3}), mSearchType(type), mScrapeCount(scrapeCount),
|
||||
mRefinedSearch(false), mFoundGame(false), mScrapeRatings(false), mBusyAnim(window)
|
||||
: GuiComponent(window)
|
||||
, mGrid(window, glm::ivec2{4, 3})
|
||||
, mSearchType(type)
|
||||
, mScrapeCount(scrapeCount)
|
||||
, mRefinedSearch(false)
|
||||
, mFoundGame(false)
|
||||
, mScrapeRatings(false)
|
||||
, mBusyAnim(window)
|
||||
{
|
||||
addChild(&mGrid);
|
||||
|
||||
|
@ -784,7 +790,8 @@ void GuiScraperSearch::updateThumbnail()
|
|||
}
|
||||
}
|
||||
|
||||
void GuiScraperSearch::openInputScreen(ScraperSearchParams ¶ms) {
|
||||
void GuiScraperSearch::openInputScreen(ScraperSearchParams& params)
|
||||
{
|
||||
auto searchForFunc = [&](std::string name) {
|
||||
// Trim leading and trailing whitespaces.
|
||||
name.erase(name.begin(), std::find_if(name.begin(), name.end(), [](char c) {
|
||||
|
@ -810,7 +817,8 @@ void GuiScraperSearch::openInputScreen(ScraperSearchParams ¶ms) {
|
|||
// regardless of whether the entry is an arcade game and TheGamesDB is used.
|
||||
if (Settings::getInstance()->getBool("ScraperSearchMetadataName")) {
|
||||
searchString = Utils::String::removeParenthesis(params.game->metadata.get("name"));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// If searching based on the actual file name, then expand to the full game name
|
||||
// in case the scraper is set to TheGamesDB and it's an arcade game. This is
|
||||
// required as TheGamesDB does not support searches using the short MAME names.
|
||||
|
@ -820,7 +828,8 @@ void GuiScraperSearch::openInputScreen(ScraperSearchParams ¶ms) {
|
|||
else
|
||||
searchString = params.game->getCleanName();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
searchString = params.nameOverride;
|
||||
}
|
||||
|
||||
|
@ -828,7 +837,8 @@ void GuiScraperSearch::openInputScreen(ScraperSearchParams ¶ms) {
|
|||
mWindow->pushGui(new GuiTextEditKeyboardPopup(mWindow, getHelpStyle(), "REFINE SEARCH",
|
||||
searchString, searchForFunc, false, "SEARCH",
|
||||
"SEARCH USING REFINED NAME?"));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), "REFINE SEARCH",
|
||||
searchString, searchForFunc, false, "SEARCH",
|
||||
"SEARCH USING REFINED NAME?"));
|
||||
|
@ -918,7 +928,8 @@ bool GuiScraperSearch::saveMetadata(const ScraperSearchResult& result,
|
|||
return metadataUpdated;
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> GuiScraperSearch::getHelpPrompts() {
|
||||
std::vector<HelpPrompt> GuiScraperSearch::getHelpPrompts()
|
||||
{
|
||||
std::vector<HelpPrompt> prompts;
|
||||
|
||||
prompts.push_back(HelpPrompt("y", "refine search"));
|
||||
|
|
|
@ -64,11 +64,13 @@ public:
|
|||
mAcceptCallback = acceptCallback;
|
||||
}
|
||||
|
||||
void setSkipCallback(const std::function<void()> &skipCallback) {
|
||||
void setSkipCallback(const std::function<void()>& skipCallback)
|
||||
{
|
||||
mSkipCallback = skipCallback;
|
||||
}
|
||||
|
||||
void setCancelCallback(const std::function<void()> &cancelCallback) {
|
||||
void setCancelCallback(const std::function<void()>& cancelCallback)
|
||||
{
|
||||
mCancelCallback = cancelCallback;
|
||||
}
|
||||
|
||||
|
@ -84,7 +86,8 @@ public:
|
|||
|
||||
void onSizeChanged() override;
|
||||
|
||||
void decreaseScrapeCount() {
|
||||
void decreaseScrapeCount()
|
||||
{
|
||||
if (mScrapeCount > 0)
|
||||
mScrapeCount--;
|
||||
}
|
||||
|
|
|
@ -22,10 +22,20 @@
|
|||
#include "views/gamelist/IGameListView.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)
|
||||
: 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)
|
||||
{
|
||||
addChild(&mMenu);
|
||||
mMenu.addButton("BACK", "back", [this] { delete this; });
|
||||
|
@ -174,10 +184,12 @@ void GuiSettings::addEditableTextComponent(const std::string label,
|
|||
else if (isPassword && newVal == "") {
|
||||
ed->setValue("");
|
||||
ed->setHiddenValue("");
|
||||
} else if (isPassword) {
|
||||
}
|
||||
else if (isPassword) {
|
||||
ed->setValue("********");
|
||||
ed->setHiddenValue(newVal);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ed->setValue(newVal);
|
||||
}
|
||||
};
|
||||
|
@ -193,7 +205,8 @@ void GuiSettings::addEditableTextComponent(const std::string label,
|
|||
ed->getValue(), updateVal, false,
|
||||
"SAVE", "SAVE CHANGES?"));
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
row.makeAcceptInputHandler([this, label, ed, updateVal, isPassword] {
|
||||
if (isPassword)
|
||||
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), label, "", updateVal,
|
||||
|
|
|
@ -147,7 +147,8 @@ void thegamesdb_generate_json_scraper_requests(
|
|||
// using this regardless of whether the entry is an arcade game.
|
||||
if (Settings::getInstance()->getBool("ScraperSearchMetadataName")) {
|
||||
cleanName = Utils::String::removeParenthesis(params.game->metadata.get("name"));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// If not searching based on the metadata name, then check whether it's an
|
||||
// arcade game and if so expand to the full game name. This is required as
|
||||
// TheGamesDB has issues with searching using the short MAME names.
|
||||
|
|
|
@ -17,12 +17,32 @@
|
|||
#define FADE_IN_TIME 650
|
||||
|
||||
DetailedGameListView::DetailedGameListView(Window* window, FileData* root)
|
||||
: BasicGameListView(window, root), mThumbnail(window), mMarquee(window), mImage(window), mLblRating(window),
|
||||
mLblReleaseDate(window), mLblDeveloper(window), mLblPublisher(window), mLblGenre(window), mLblPlayers(window),
|
||||
mLblLastPlayed(window), mLblPlayCount(window), mBadges(window), mRating(window), mReleaseDate(window),
|
||||
mDeveloper(window),
|
||||
mPublisher(window), mGenre(window), mPlayers(window), mLastPlayed(window), mPlayCount(window), mName(window),
|
||||
mDescContainer(window), mDescription(window), mGamelistInfo(window), mLastUpdated(nullptr)
|
||||
: BasicGameListView(window, root)
|
||||
, mThumbnail(window)
|
||||
, mMarquee(window)
|
||||
, mImage(window)
|
||||
, mLblRating(window)
|
||||
, mLblReleaseDate(window)
|
||||
, mLblDeveloper(window)
|
||||
, mLblPublisher(window)
|
||||
, mLblGenre(window)
|
||||
, mLblPlayers(window)
|
||||
, mLblLastPlayed(window)
|
||||
, mLblPlayCount(window)
|
||||
, mBadges(window)
|
||||
, mRating(window)
|
||||
, mReleaseDate(window)
|
||||
, mDeveloper(window)
|
||||
, mPublisher(window)
|
||||
, mGenre(window)
|
||||
, mPlayers(window)
|
||||
, mLastPlayed(window)
|
||||
, mPlayCount(window)
|
||||
, mName(window)
|
||||
, mDescContainer(window)
|
||||
, mDescription(window)
|
||||
, mGamelistInfo(window)
|
||||
, mLastUpdated(nullptr)
|
||||
{
|
||||
const float padding = 0.01f;
|
||||
|
||||
|
@ -111,7 +131,8 @@ DetailedGameListView::DetailedGameListView(Window* window, FileData* root)
|
|||
initMDValues();
|
||||
}
|
||||
|
||||
void DetailedGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme) {
|
||||
void DetailedGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||
{
|
||||
BasicGameListView::onThemeChanged(theme);
|
||||
|
||||
using namespace ThemeFlags;
|
||||
|
@ -402,7 +423,8 @@ void DetailedGameListView::updateInfoPanel()
|
|||
mLastPlayed.setValue(file->metadata.get("lastplayed"));
|
||||
mPlayCount.setValue(file->metadata.get("playcount"));
|
||||
}
|
||||
} else if (file->getType() == FOLDER) {
|
||||
}
|
||||
else if (file->getType() == FOLDER) {
|
||||
if (!hideMetaDataFields) {
|
||||
mLastPlayed.setValue(file->metadata.get("lastplayed"));
|
||||
mLblPlayCount.setVisible(false);
|
||||
|
|
|
@ -20,12 +20,31 @@
|
|||
#define FADE_IN_TIME 650
|
||||
|
||||
GridGameListView::GridGameListView(Window* window, FileData* root)
|
||||
: ISimpleGameListView(window, root), mGrid(window), mMarquee(window), mImage(window), mLblRating(window),
|
||||
mLblReleaseDate(window), mLblDeveloper(window), mLblPublisher(window), mLblGenre(window), mLblPlayers(window),
|
||||
mLblLastPlayed(window), mLblPlayCount(window), mBadges(window), mRating(window), mReleaseDate(window),
|
||||
mDeveloper(window),
|
||||
mPublisher(window), mGenre(window), mPlayers(window), mLastPlayed(window), mPlayCount(window), mName(window),
|
||||
mDescContainer(window), mDescription(window), mGamelistInfo(window)
|
||||
: ISimpleGameListView(window, root)
|
||||
, mGrid(window)
|
||||
, mMarquee(window)
|
||||
, mImage(window)
|
||||
, mLblRating(window)
|
||||
, mLblReleaseDate(window)
|
||||
, mLblDeveloper(window)
|
||||
, mLblPublisher(window)
|
||||
, mLblGenre(window)
|
||||
, mLblPlayers(window)
|
||||
, mLblLastPlayed(window)
|
||||
, mLblPlayCount(window)
|
||||
, mBadges(window)
|
||||
, mRating(window)
|
||||
, mReleaseDate(window)
|
||||
, mDeveloper(window)
|
||||
, mPublisher(window)
|
||||
, mGenre(window)
|
||||
, mPlayers(window)
|
||||
, mLastPlayed(window)
|
||||
, mPlayCount(window)
|
||||
, mName(window)
|
||||
, mDescContainer(window)
|
||||
, mDescription(window)
|
||||
, mGamelistInfo(window)
|
||||
{
|
||||
const float padding = 0.01f;
|
||||
|
||||
|
|
|
@ -17,10 +17,21 @@
|
|||
#include <algorithm>
|
||||
|
||||
GuiComponent::GuiComponent(Window* window)
|
||||
: mWindow(window), mParent(nullptr), mOpacity(255), mColor(0), mSaturation(1.0f), mColorShift(0),
|
||||
mColorShiftEnd(0),
|
||||
mPosition({}), mOrigin({}), mRotationOrigin(0.5f, 0.5f), mSize({}), mIsProcessing(false), mVisible(true),
|
||||
mEnabled(true), mTransform(Renderer::getIdentity())
|
||||
: mWindow(window)
|
||||
, mParent(nullptr)
|
||||
, mOpacity(255)
|
||||
, mColor(0)
|
||||
, mSaturation(1.0f)
|
||||
, mColorShift(0)
|
||||
, mColorShiftEnd(0)
|
||||
, mPosition({})
|
||||
, mOrigin({})
|
||||
, mRotationOrigin(0.5f, 0.5f)
|
||||
, mSize({})
|
||||
, mIsProcessing(false)
|
||||
, mVisible(true)
|
||||
, mEnabled(true)
|
||||
, mTransform(Renderer::getIdentity())
|
||||
{
|
||||
for (unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
||||
mAnimationMap[i] = nullptr;
|
||||
|
|
|
@ -14,11 +14,12 @@
|
|||
#include "resources/TextureResource.h"
|
||||
|
||||
// Available slot definitions.
|
||||
std::vector<std::string> BadgesComponent::mSlots = {SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDS, SLOT_BROKEN,
|
||||
SLOT_ALTERNATIVE_EMULATOR};
|
||||
std::vector<std::string> BadgesComponent::mSlots = {SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDS,
|
||||
SLOT_BROKEN, SLOT_ALTERNATIVE_EMULATOR};
|
||||
|
||||
BadgesComponent::BadgesComponent(Window* window)
|
||||
: FlexboxComponent(window) {
|
||||
: FlexboxComponent(window)
|
||||
{
|
||||
|
||||
mBadgeIcons = std::map<std::string, std::string>();
|
||||
mBadgeIcons[SLOT_FAVORITE] = ":/graphics/badge_favorite.svg";
|
||||
|
@ -45,7 +46,8 @@ BadgesComponent::BadgesComponent(Window *window)
|
|||
mImageComponents.insert({SLOT_ALTERNATIVE_EMULATOR, mImageAltEmu});
|
||||
}
|
||||
|
||||
BadgesComponent::~BadgesComponent() noexcept {
|
||||
BadgesComponent::~BadgesComponent() noexcept
|
||||
{
|
||||
for (GuiComponent* c : mChildren)
|
||||
c->clearChildren();
|
||||
clearChildren();
|
||||
|
@ -53,8 +55,8 @@ BadgesComponent::~BadgesComponent() noexcept {
|
|||
mImageComponents.clear();
|
||||
}
|
||||
|
||||
|
||||
void BadgesComponent::setValue(const std::string &value) {
|
||||
void BadgesComponent::setValue(const std::string& value)
|
||||
{
|
||||
mChildren.clear();
|
||||
if (!value.empty()) {
|
||||
std::string temp;
|
||||
|
@ -94,7 +96,8 @@ void BadgesComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
|
||||
bool imgChanged = false;
|
||||
for (auto& slot : mSlots) {
|
||||
if (properties & PATH && elem->has(slot) && mBadgeIcons[slot] != elem->get<std::string>(slot)) {
|
||||
if (properties & PATH && elem->has(slot) &&
|
||||
mBadgeIcons[slot] != elem->get<std::string>(slot)) {
|
||||
mBadgeIcons[slot] = elem->get<std::string>(slot);
|
||||
mImageComponents.find(slot)->second.setImage(mBadgeIcons[slot], false, true, true);
|
||||
imgChanged = true;
|
||||
|
|
|
@ -18,9 +18,18 @@ ButtonComponent::ButtonComponent(Window *window,
|
|||
const std::function<void()>& func,
|
||||
bool upperCase,
|
||||
bool flatStyle)
|
||||
: GuiComponent{window}, mBox{window, ":/graphics/button.svg"}, mFont{Font::get(FONT_SIZE_MEDIUM)}, mPadding{{}},
|
||||
mFocused{false}, mEnabled{true}, mFlatStyle{flatStyle}, mTextColorFocused{0xFFFFFFFF},
|
||||
mTextColorUnfocused{0x777777FF}, mFlatColorFocused{0x878787FF}, mFlatColorUnfocused{0x60606025} {
|
||||
: GuiComponent{window}
|
||||
, mBox{window, ":/graphics/button.svg"}
|
||||
, mFont{Font::get(FONT_SIZE_MEDIUM)}
|
||||
, mPadding{{}}
|
||||
, mFocused{false}
|
||||
, mEnabled{true}
|
||||
, mFlatStyle{flatStyle}
|
||||
, mTextColorFocused{0xFFFFFFFF}
|
||||
, mTextColorUnfocused{0x777777FF}
|
||||
, mFlatColorFocused{0x878787FF}
|
||||
, mFlatColorUnfocused{0x60606025}
|
||||
{
|
||||
setPressedFunc(func);
|
||||
setText(text, helpText, upperCase);
|
||||
|
||||
|
@ -28,7 +37,8 @@ ButtonComponent::ButtonComponent(Window *window,
|
|||
updateImage();
|
||||
}
|
||||
|
||||
void ButtonComponent::onSizeChanged() {
|
||||
void ButtonComponent::onSizeChanged()
|
||||
{
|
||||
if (mFlatStyle)
|
||||
return;
|
||||
|
||||
|
@ -39,19 +49,22 @@ void ButtonComponent::onSizeChanged() {
|
|||
glm::vec2{-cornerSize.x * 2.0f, -cornerSize.y * 2.0f});
|
||||
}
|
||||
|
||||
void ButtonComponent::onFocusGained() {
|
||||
void ButtonComponent::onFocusGained()
|
||||
{
|
||||
mFocused = true;
|
||||
if (!mFlatStyle)
|
||||
updateImage();
|
||||
}
|
||||
|
||||
void ButtonComponent::onFocusLost() {
|
||||
void ButtonComponent::onFocusLost()
|
||||
{
|
||||
mFocused = false;
|
||||
if (!mFlatStyle)
|
||||
updateImage();
|
||||
}
|
||||
|
||||
void ButtonComponent::setText(const std::string &text, const std::string &helpText, bool upperCase) {
|
||||
void ButtonComponent::setText(const std::string& text, const std::string& helpText, bool upperCase)
|
||||
{
|
||||
mText = upperCase ? Utils::String::toUpper(text) : text;
|
||||
mHelpText = helpText;
|
||||
|
||||
|
@ -66,13 +79,15 @@ void ButtonComponent::setText(const std::string &text, const std::string &helpTe
|
|||
updateHelpPrompts();
|
||||
}
|
||||
|
||||
void ButtonComponent::setEnabled(bool state) {
|
||||
void ButtonComponent::setEnabled(bool state)
|
||||
{
|
||||
mEnabled = state;
|
||||
if (!mFlatStyle)
|
||||
updateImage();
|
||||
}
|
||||
|
||||
void ButtonComponent::setPadding(const glm::vec4 padding) {
|
||||
void ButtonComponent::setPadding(const glm::vec4 padding)
|
||||
{
|
||||
if (mPadding == padding)
|
||||
return;
|
||||
|
||||
|
@ -80,7 +95,8 @@ void ButtonComponent::setPadding(const glm::vec4 padding) {
|
|||
onSizeChanged();
|
||||
}
|
||||
|
||||
bool ButtonComponent::input(InputConfig *config, Input input) {
|
||||
bool ButtonComponent::input(InputConfig* config, Input input)
|
||||
{
|
||||
if (config->isMappedTo("a", input) && input.value != 0) {
|
||||
if (mPressedFunc && mEnabled)
|
||||
mPressedFunc();
|
||||
|
@ -90,7 +106,8 @@ bool ButtonComponent::input(InputConfig *config, Input input) {
|
|||
return GuiComponent::input(config, input);
|
||||
}
|
||||
|
||||
void ButtonComponent::render(const glm::mat4 &parentTrans) {
|
||||
void ButtonComponent::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
|
||||
if (mFlatStyle) {
|
||||
|
@ -99,13 +116,15 @@ void ButtonComponent::render(const glm::mat4 &parentTrans) {
|
|||
Renderer::drawRect(mPadding.x, mPadding.y, mSize.x - mPadding.x - mPadding.z,
|
||||
mSize.y - mPadding.y - mPadding.w, mFlatColorFocused,
|
||||
mFlatColorFocused);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(mPadding.x, mPadding.y, mSize.x - mPadding.x - mPadding.z,
|
||||
mSize.y - mPadding.y - mPadding.w, mFlatColorUnfocused,
|
||||
mFlatColorUnfocused);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mBox.render(trans);
|
||||
}
|
||||
|
||||
|
@ -131,20 +150,23 @@ void ButtonComponent::render(const glm::mat4 &parentTrans) {
|
|||
renderChildren(trans);
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> ButtonComponent::getHelpPrompts() {
|
||||
std::vector<HelpPrompt> ButtonComponent::getHelpPrompts()
|
||||
{
|
||||
std::vector<HelpPrompt> prompts;
|
||||
prompts.push_back(HelpPrompt("a", mHelpText.empty() ? mText.c_str() : mHelpText.c_str()));
|
||||
return prompts;
|
||||
}
|
||||
|
||||
unsigned int ButtonComponent::getCurTextColor() const {
|
||||
unsigned int ButtonComponent::getCurTextColor() const
|
||||
{
|
||||
if (!mFocused)
|
||||
return mTextColorUnfocused;
|
||||
else
|
||||
return mTextColorFocused;
|
||||
}
|
||||
|
||||
void ButtonComponent::updateImage() {
|
||||
void ButtonComponent::updateImage()
|
||||
{
|
||||
if (!mEnabled || !mPressedFunc) {
|
||||
mBox.setImagePath(":/graphics/button_filled.svg");
|
||||
mBox.setCenterColor(0x770000FF);
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
|
||||
class TextCache;
|
||||
|
||||
class ButtonComponent : public GuiComponent {
|
||||
class ButtonComponent : public GuiComponent
|
||||
{
|
||||
public:
|
||||
ButtonComponent(Window* window,
|
||||
const std::string& text = "",
|
||||
|
|
|
@ -287,7 +287,8 @@ void ComponentGrid::resetCursor()
|
|||
}
|
||||
}
|
||||
|
||||
bool ComponentGrid::moveCursor(glm::ivec2 dir) {
|
||||
bool ComponentGrid::moveCursor(glm::ivec2 dir)
|
||||
{
|
||||
assert(dir.x || dir.y);
|
||||
|
||||
const glm::ivec2 origCursor{mCursor};
|
||||
|
@ -367,7 +368,8 @@ bool ComponentGrid::moveCursor(glm::ivec2 dir) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void ComponentGrid::moveCursorTo(int xPos, int yPos, bool selectLeftCell) {
|
||||
void ComponentGrid::moveCursorTo(int xPos, int yPos, bool selectLeftCell)
|
||||
{
|
||||
const glm::ivec2 origCursor{mCursor};
|
||||
|
||||
if (xPos != -1)
|
||||
|
@ -384,13 +386,15 @@ void ComponentGrid::moveCursorTo(int xPos, int yPos, bool selectLeftCell) {
|
|||
onCursorMoved(origCursor, mCursor);
|
||||
}
|
||||
|
||||
void ComponentGrid::onFocusLost() {
|
||||
void ComponentGrid::onFocusLost()
|
||||
{
|
||||
const GridEntry* cursorEntry = getCellAt(mCursor);
|
||||
if (cursorEntry)
|
||||
cursorEntry->component->onFocusLost();
|
||||
}
|
||||
|
||||
void ComponentGrid::onFocusGained() {
|
||||
void ComponentGrid::onFocusGained()
|
||||
{
|
||||
const GridEntry* cursorEntry = getCellAt(mCursor);
|
||||
if (cursorEntry)
|
||||
cursorEntry->component->onFocusGained();
|
||||
|
|
|
@ -30,7 +30,8 @@ namespace GridFlags
|
|||
} // namespace GridFlags
|
||||
|
||||
// Provides basic layout of components in an X*Y grid.
|
||||
class ComponentGrid : public GuiComponent {
|
||||
class ComponentGrid : public GuiComponent
|
||||
{
|
||||
public:
|
||||
ComponentGrid(Window* window, const glm::ivec2& gridDimensions);
|
||||
|
||||
|
@ -46,7 +47,8 @@ public:
|
|||
unsigned int border = GridFlags::BORDER_NONE,
|
||||
GridFlags::UpdateType updateType = GridFlags::UPDATE_ALWAYS);
|
||||
|
||||
void setPastBoundaryCallback(const std::function<bool(InputConfig *config, Input input)> &func) {
|
||||
void setPastBoundaryCallback(const std::function<bool(InputConfig* config, Input input)>& func)
|
||||
{
|
||||
mPastBoundaryCallback = func;
|
||||
}
|
||||
|
||||
|
@ -82,7 +84,8 @@ public:
|
|||
|
||||
void setCursorTo(const std::shared_ptr<GuiComponent>& comp);
|
||||
|
||||
std::shared_ptr<GuiComponent> getSelectedComponent() {
|
||||
std::shared_ptr<GuiComponent> getSelectedComponent()
|
||||
{
|
||||
const GridEntry* e = getCellAt(mCursor);
|
||||
if (e)
|
||||
return e->component;
|
||||
|
|
|
@ -71,7 +71,8 @@ bool ComponentList::input(InputConfig* config, Input input)
|
|||
if (mEntries.at(mCursor).data.input_handler) {
|
||||
if (mEntries.at(mCursor).data.input_handler(config, input))
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// No input handler assigned, do the default, which is to give it
|
||||
// to the rightmost element in the row.
|
||||
auto& row = mEntries.at(mCursor).data;
|
||||
|
|
|
@ -13,9 +13,16 @@
|
|||
#include "utils/StringUtil.h"
|
||||
|
||||
DateTimeEditComponent::DateTimeEditComponent(Window* window, bool alignRight, DisplayMode dispMode)
|
||||
: GuiComponent(window), mEditing(false), mEditIndex(0), mDisplayMode(dispMode), mRelativeUpdateAccumulator(0),
|
||||
mColor(0x777777FF), mFont(Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)), mAlignRight(alignRight),
|
||||
mUppercase(false), mAutoSize(true)
|
||||
: GuiComponent(window)
|
||||
, mEditing(false)
|
||||
, mEditIndex(0)
|
||||
, mDisplayMode(dispMode)
|
||||
, mRelativeUpdateAccumulator(0)
|
||||
, mColor(0x777777FF)
|
||||
, mFont(Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT))
|
||||
, mAlignRight(alignRight)
|
||||
, mUppercase(false)
|
||||
, mAutoSize(true)
|
||||
{
|
||||
updateTextCache();
|
||||
}
|
||||
|
|
|
@ -60,9 +60,7 @@ void FlexboxComponent::setItemWidth(float value)
|
|||
}
|
||||
float FlexboxComponent::getItemWidth() { return mItemWidth; }
|
||||
|
||||
void FlexboxComponent::onSizeChanged() {
|
||||
mLayoutValid = false;
|
||||
}
|
||||
void FlexboxComponent::onSizeChanged() { mLayoutValid = false; }
|
||||
|
||||
void FlexboxComponent::computeLayout()
|
||||
{
|
||||
|
@ -106,7 +104,8 @@ void FlexboxComponent::computeLayout()
|
|||
if (mDirection == "row") {
|
||||
totalSize.x += (mItemMargin.x + mItemWidth) * mItemsPerLine;
|
||||
totalSize.y += (mItemMargin.y + maxItemSize.y) * nLines;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
totalSize.x += (mItemMargin.x + mItemWidth) * nLines;
|
||||
totalSize.y += (mItemMargin.y + maxItemSize.y) * mItemsPerLine;
|
||||
}
|
||||
|
@ -132,10 +131,12 @@ void FlexboxComponent::computeLayout()
|
|||
if (mAlign == ITEM_ALIGN_END) {
|
||||
x += directionLine.x == 0 ? (maxItemSize.x - size.x) : 0;
|
||||
y += directionLine.y == 0 ? (maxItemSize.y - size.y) : 0;
|
||||
} else if (mAlign == ITEM_ALIGN_CENTER) {
|
||||
}
|
||||
else if (mAlign == ITEM_ALIGN_CENTER) {
|
||||
x += directionLine.x == 0 ? (maxItemSize.x - size.x) / 2 : 0;
|
||||
y += directionLine.y == 0 ? (maxItemSize.y - size.y) / 2 : 0;
|
||||
} else if (mAlign == ITEM_ALIGN_STRETCH && mDirection == "row") {
|
||||
}
|
||||
else if (mAlign == ITEM_ALIGN_STRETCH && mDirection == "row") {
|
||||
child->setSize(child->getSize().x, maxItemSize.y);
|
||||
}
|
||||
|
||||
|
@ -159,7 +160,8 @@ void FlexboxComponent::computeLayout()
|
|||
if (directionRow.x == 0) {
|
||||
anchorY += lineWidth * directionRow.y;
|
||||
anchorX = anchorXStart;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
anchorX += lineWidth * directionRow.x;
|
||||
anchorY = anchorYStart;
|
||||
}
|
||||
|
@ -169,7 +171,8 @@ void FlexboxComponent::computeLayout()
|
|||
mLayoutValid = true;
|
||||
}
|
||||
|
||||
void FlexboxComponent::render(const glm::mat4& parentTrans) {
|
||||
void FlexboxComponent::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
if (!isVisible())
|
||||
return;
|
||||
|
||||
|
|
|
@ -28,10 +28,22 @@ glm::vec2 ImageComponent::getSize() const
|
|||
}
|
||||
|
||||
ImageComponent::ImageComponent(Window* window, bool forceLoad, bool dynamic)
|
||||
: GuiComponent(window), mTargetSize({}), mFlipX(false), mFlipY(false), mTargetIsMax(false), mTargetIsMin(false),
|
||||
mColorShift(0xFFFFFFFF), mColorShiftEnd(0xFFFFFFFF), mColorGradientHorizontal(true), mFadeOpacity(0),
|
||||
mFading(false), mForceLoad(forceLoad), mDynamic(dynamic), mRotateByTargetSize(false), mTopLeftCrop({}),
|
||||
mBottomRightCrop(1.0f, 1.0f)
|
||||
: GuiComponent(window)
|
||||
, mTargetSize({})
|
||||
, mFlipX(false)
|
||||
, mFlipY(false)
|
||||
, mTargetIsMax(false)
|
||||
, mTargetIsMin(false)
|
||||
, mColorShift(0xFFFFFFFF)
|
||||
, mColorShiftEnd(0xFFFFFFFF)
|
||||
, mColorGradientHorizontal(true)
|
||||
, mFadeOpacity(0)
|
||||
, mFading(false)
|
||||
, mForceLoad(forceLoad)
|
||||
, mDynamic(dynamic)
|
||||
, mRotateByTargetSize(false)
|
||||
, mTopLeftCrop({})
|
||||
, mBottomRightCrop(1.0f, 1.0f)
|
||||
{
|
||||
updateColors();
|
||||
}
|
||||
|
@ -126,7 +138,8 @@ void ImageComponent::resize()
|
|||
onSizeChanged();
|
||||
}
|
||||
|
||||
void ImageComponent::setImage(std::string path, bool tile, bool linearMagnify, bool cacheImage) {
|
||||
void ImageComponent::setImage(std::string path, bool tile, bool linearMagnify, bool cacheImage)
|
||||
{
|
||||
// Always load bundled graphic resources statically, unless mForceLoad has been set.
|
||||
// This eliminates annoying texture pop-in problems that would otherwise occur.
|
||||
if (!mForceLoad && (path[0] == ':') && (path[1] == '/')) {
|
||||
|
@ -137,11 +150,12 @@ void ImageComponent::setImage(std::string path, bool tile, bool linearMagnify, b
|
|||
if (mDefaultPath.empty() || !ResourceManager::getInstance()->fileExists(mDefaultPath))
|
||||
mTexture.reset();
|
||||
else
|
||||
mTexture =
|
||||
TextureResource::get(mDefaultPath, tile, mForceLoad, mDynamic, linearMagnify, 1.0f, cacheImage);
|
||||
mTexture = TextureResource::get(mDefaultPath, tile, mForceLoad, mDynamic, linearMagnify,
|
||||
1.0f, cacheImage);
|
||||
}
|
||||
else {
|
||||
mTexture = TextureResource::get(path, tile, mForceLoad, mDynamic, linearMagnify, 1.0f, cacheImage);
|
||||
mTexture =
|
||||
TextureResource::get(path, tile, mForceLoad, mDynamic, linearMagnify, 1.0f, cacheImage);
|
||||
}
|
||||
|
||||
resize();
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
|
||||
class TextureResource;
|
||||
|
||||
class ImageComponent : public GuiComponent {
|
||||
class ImageComponent : public GuiComponent
|
||||
{
|
||||
public:
|
||||
ImageComponent(Window* window, bool forceLoad = false, bool dynamic = true);
|
||||
|
||||
|
@ -24,7 +25,10 @@ public:
|
|||
|
||||
// Loads the image at the given filepath. Will tile if tile is true (retrieves texture
|
||||
// as tiling, creates vertices accordingly).
|
||||
void setImage(std::string path, bool tile = false, bool linearMagnify = false, bool cacheSVG = false);
|
||||
void setImage(std::string path,
|
||||
bool tile = false,
|
||||
bool linearMagnify = false,
|
||||
bool cacheSVG = false);
|
||||
|
||||
// Loads an image from memory.
|
||||
void setImage(const char* data, size_t length, bool tile = false);
|
||||
|
|
|
@ -25,8 +25,12 @@ GuiMsgBox::GuiMsgBox(Window* window,
|
|||
const std::function<void()>& func3,
|
||||
bool disableBackButton,
|
||||
bool deleteOnButtonPress)
|
||||
: GuiComponent(window), mBackground(window, ":/graphics/frame.svg"), mGrid(window, glm::ivec2{1, 2}),
|
||||
mHelpStyle(helpstyle), mDisableBackButton(disableBackButton), mDeleteOnButtonPress(deleteOnButtonPress)
|
||||
: GuiComponent(window)
|
||||
, mBackground(window, ":/graphics/frame.svg")
|
||||
, mGrid(window, glm::ivec2{1, 2})
|
||||
, mHelpStyle(helpstyle)
|
||||
, mDisableBackButton(disableBackButton)
|
||||
, mDeleteOnButtonPress(deleteOnButtonPress)
|
||||
{
|
||||
// Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent
|
||||
// regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
|
||||
|
|
|
@ -87,13 +87,27 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
const std::string& loadBtnHelpText,
|
||||
const std::string& clearBtnHelpText,
|
||||
const std::string& cancelBtnHelpText)
|
||||
: GuiComponent{window}, mBackground{window, ":/graphics/frame.svg"},
|
||||
mGrid{window, glm::ivec2{1, (infoString != "" && defaultValue != "" ? 8 : 6)}}, mHelpStyle{helpstyle},
|
||||
mInitValue{initValue}, mAcceptBtnHelpText{acceptBtnHelpText}, mSaveConfirmationText{saveConfirmationText},
|
||||
mLoadBtnHelpText{loadBtnHelpText}, mClearBtnHelpText{clearBtnHelpText}, mCancelBtnHelpText{cancelBtnHelpText},
|
||||
mOkCallback{okCallback}, mMultiLine{multiLine}, mComplexMode{(infoString != "" && defaultValue != "")},
|
||||
mDeleteRepeat{false}, mShift{false}, mAlt{false}, mDeleteRepeatTimer{0}, mNavigationRepeatTimer{0},
|
||||
mNavigationRepeatDirX{0}, mNavigationRepeatDirY{0} {
|
||||
: GuiComponent{window}
|
||||
, mBackground{window, ":/graphics/frame.svg"}
|
||||
, mGrid{window, glm::ivec2{1, (infoString != "" && defaultValue != "" ? 8 : 6)}}
|
||||
, mHelpStyle{helpstyle}
|
||||
, mInitValue{initValue}
|
||||
, mAcceptBtnHelpText{acceptBtnHelpText}
|
||||
, mSaveConfirmationText{saveConfirmationText}
|
||||
, mLoadBtnHelpText{loadBtnHelpText}
|
||||
, mClearBtnHelpText{clearBtnHelpText}
|
||||
, mCancelBtnHelpText{cancelBtnHelpText}
|
||||
, mOkCallback{okCallback}
|
||||
, mMultiLine{multiLine}
|
||||
, mComplexMode{(infoString != "" && defaultValue != "")}
|
||||
, mDeleteRepeat{false}
|
||||
, mShift{false}
|
||||
, mAlt{false}
|
||||
, mDeleteRepeatTimer{0}
|
||||
, mNavigationRepeatTimer{0}
|
||||
, mNavigationRepeatDirX{0}
|
||||
, mNavigationRepeatDirY{0}
|
||||
{
|
||||
addChild(&mBackground);
|
||||
addChild(&mGrid);
|
||||
|
||||
|
@ -164,17 +178,20 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
upper = DELETE_SYMBOL;
|
||||
alted = DELETE_SYMBOL;
|
||||
altshifted = DELETE_SYMBOL;
|
||||
} else if (lower == "OK") {
|
||||
}
|
||||
else if (lower == "OK") {
|
||||
lower = OK_SYMBOL;
|
||||
upper = OK_SYMBOL;
|
||||
alted = OK_SYMBOL;
|
||||
altshifted = OK_SYMBOL;
|
||||
} else if (lower == "SPACE") {
|
||||
}
|
||||
else if (lower == "SPACE") {
|
||||
lower = " ";
|
||||
upper = " ";
|
||||
alted = " ";
|
||||
altshifted = " ";
|
||||
} else if (lower != "SHIFT" && lower.length() > 1) {
|
||||
}
|
||||
else if (lower != "SHIFT" && lower.length() > 1) {
|
||||
lower = (lower.c_str());
|
||||
upper = (upper.c_str());
|
||||
alted = (alted.c_str());
|
||||
|
@ -185,11 +202,13 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
mShiftButton = std::make_shared<ButtonComponent>(
|
||||
mWindow, (SHIFT_SYMBOL), ("SHIFT"), [this] { shiftKeys(); }, false, true);
|
||||
button = mShiftButton;
|
||||
} else if (lower == "ALT") {
|
||||
}
|
||||
else if (lower == "ALT") {
|
||||
mAltButton = std::make_shared<ButtonComponent>(
|
||||
mWindow, (ALT_SYMBOL), ("ALT"), [this] { altKeys(); }, false, true);
|
||||
button = mAltButton;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
button = makeButton(lower, upper, alted, altshifted);
|
||||
}
|
||||
|
||||
|
@ -239,7 +258,8 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
mKeyboardGrid->moveCursorTo(mHorizontalKeyCount - 1, -1, true);
|
||||
return true;
|
||||
}
|
||||
} else if (config->isMappedLike("right", input)) {
|
||||
}
|
||||
else if (config->isMappedLike("right", input)) {
|
||||
if (mGrid.getSelectedComponent() == mKeyboardGrid) {
|
||||
mKeyboardGrid->moveCursorTo(0, -1);
|
||||
return true;
|
||||
|
@ -259,7 +279,8 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
|
||||
setPosition((static_cast<float>(Renderer::getScreenWidth()) - mSize.x) / 2.0f,
|
||||
(static_cast<float>(Renderer::getScreenHeight()) - mSize.y) / 2.0f);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (mComplexMode)
|
||||
setSize(width, KEYBOARD_HEIGHT + mDefaultValue->getSize().y * 3.0f);
|
||||
else
|
||||
|
@ -270,7 +291,8 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
}
|
||||
}
|
||||
|
||||
void GuiTextEditKeyboardPopup::onSizeChanged() {
|
||||
void GuiTextEditKeyboardPopup::onSizeChanged()
|
||||
{
|
||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
||||
mText->setSize(mSize.x - KEYBOARD_PADDINGX - KEYBOARD_PADDINGX, mText->getSize().y);
|
||||
|
||||
|
@ -281,7 +303,8 @@ void GuiTextEditKeyboardPopup::onSizeChanged() {
|
|||
mGrid.setRowHeightPerc(1, (mInfoString->getSize().y * 0.6f) / mSize.y);
|
||||
mGrid.setRowHeightPerc(2, (mDefaultValue->getSize().y * 1.6f) / mSize.y);
|
||||
mGrid.setRowHeightPerc(1, (mText->getSize().y * 1.0f) / mSize.y);
|
||||
} else if (mMultiLine) {
|
||||
}
|
||||
else if (mMultiLine) {
|
||||
mGrid.setRowHeightPerc(1, (mText->getSize().y * 1.15f) / mSize.y);
|
||||
}
|
||||
|
||||
|
@ -296,7 +319,8 @@ void GuiTextEditKeyboardPopup::onSizeChanged() {
|
|||
mKeyboardGrid->setPosition(KEYBOARD_PADDINGX, pos.y);
|
||||
}
|
||||
|
||||
bool GuiTextEditKeyboardPopup::input(InputConfig *config, Input input) {
|
||||
bool GuiTextEditKeyboardPopup::input(InputConfig* config, Input input)
|
||||
{
|
||||
// Enter/return key or numpad enter key accepts the changes.
|
||||
if (config->getDeviceId() == DEVICE_KEYBOARD && mText->isEditing() && !mMultiLine &&
|
||||
input.value && (input.id == SDLK_RETURN || input.id == SDLK_KP_ENTER)) {
|
||||
|
@ -341,7 +365,8 @@ bool GuiTextEditKeyboardPopup::input(InputConfig *config, Input input) {
|
|||
delete this;
|
||||
return true;
|
||||
}));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
delete this;
|
||||
return true;
|
||||
}
|
||||
|
@ -374,7 +399,8 @@ bool GuiTextEditKeyboardPopup::input(InputConfig *config, Input input) {
|
|||
|
||||
if (!editing)
|
||||
mText->stopEditing();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mDeleteRepeat = false;
|
||||
}
|
||||
return true;
|
||||
|
@ -400,7 +426,8 @@ bool GuiTextEditKeyboardPopup::input(InputConfig *config, Input input) {
|
|||
if (input.value) {
|
||||
mNavigationRepeatDirX = -1;
|
||||
mNavigationRepeatTimer = -(NAVIGATION_REPEAT_START_DELAY - NAVIGATION_REPEAT_SPEED);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mNavigationRepeatDirX = 0;
|
||||
}
|
||||
}
|
||||
|
@ -409,7 +436,8 @@ bool GuiTextEditKeyboardPopup::input(InputConfig *config, Input input) {
|
|||
if (input.value) {
|
||||
mNavigationRepeatDirX = 1;
|
||||
mNavigationRepeatTimer = -(NAVIGATION_REPEAT_START_DELAY - NAVIGATION_REPEAT_SPEED);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mNavigationRepeatDirX = 0;
|
||||
}
|
||||
}
|
||||
|
@ -418,7 +446,8 @@ bool GuiTextEditKeyboardPopup::input(InputConfig *config, Input input) {
|
|||
if (input.value) {
|
||||
mNavigationRepeatDirY = -1;
|
||||
mNavigationRepeatTimer = -(NAVIGATION_REPEAT_START_DELAY - NAVIGATION_REPEAT_SPEED);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mNavigationRepeatDirY = 0;
|
||||
}
|
||||
}
|
||||
|
@ -427,7 +456,8 @@ bool GuiTextEditKeyboardPopup::input(InputConfig *config, Input input) {
|
|||
if (input.value) {
|
||||
mNavigationRepeatDirY = 1;
|
||||
mNavigationRepeatTimer = -(NAVIGATION_REPEAT_START_DELAY - NAVIGATION_REPEAT_SPEED);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mNavigationRepeatDirY = 0;
|
||||
}
|
||||
}
|
||||
|
@ -438,19 +468,22 @@ bool GuiTextEditKeyboardPopup::input(InputConfig *config, Input input) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void GuiTextEditKeyboardPopup::update(int deltaTime) {
|
||||
void GuiTextEditKeyboardPopup::update(int deltaTime)
|
||||
{
|
||||
updateNavigationRepeat(deltaTime);
|
||||
updateDeleteRepeat(deltaTime);
|
||||
GuiComponent::update(deltaTime);
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> GuiTextEditKeyboardPopup::getHelpPrompts() {
|
||||
std::vector<HelpPrompt> GuiTextEditKeyboardPopup::getHelpPrompts()
|
||||
{
|
||||
std::vector<HelpPrompt> prompts = mGrid.getHelpPrompts();
|
||||
|
||||
if (!mText->isEditing()) {
|
||||
prompts.push_back(HelpPrompt("lt", "shift"));
|
||||
prompts.push_back(HelpPrompt("rt", "alt"));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
prompts.push_back(HelpPrompt("a", mAcceptBtnHelpText));
|
||||
}
|
||||
|
||||
|
@ -480,7 +513,8 @@ std::vector<HelpPrompt> GuiTextEditKeyboardPopup::getHelpPrompts() {
|
|||
return prompts;
|
||||
}
|
||||
|
||||
void GuiTextEditKeyboardPopup::updateDeleteRepeat(int deltaTime) {
|
||||
void GuiTextEditKeyboardPopup::updateDeleteRepeat(int deltaTime)
|
||||
{
|
||||
if (!mDeleteRepeat)
|
||||
return;
|
||||
|
||||
|
@ -500,7 +534,8 @@ void GuiTextEditKeyboardPopup::updateDeleteRepeat(int deltaTime) {
|
|||
}
|
||||
}
|
||||
|
||||
void GuiTextEditKeyboardPopup::updateNavigationRepeat(int deltaTime) {
|
||||
void GuiTextEditKeyboardPopup::updateNavigationRepeat(int deltaTime)
|
||||
{
|
||||
if (mNavigationRepeatDirX == 0 && mNavigationRepeatDirY == 0)
|
||||
return;
|
||||
|
||||
|
@ -527,13 +562,15 @@ void GuiTextEditKeyboardPopup::updateNavigationRepeat(int deltaTime) {
|
|||
}
|
||||
}
|
||||
|
||||
void GuiTextEditKeyboardPopup::shiftKeys() {
|
||||
void GuiTextEditKeyboardPopup::shiftKeys()
|
||||
{
|
||||
mShift = !mShift;
|
||||
|
||||
if (mShift) {
|
||||
mShiftButton->setFlatColorFocused(0xFF2222FF);
|
||||
mShiftButton->setFlatColorUnfocused(0xFF2222FF);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mShiftButton->setFlatColorFocused(0x878787FF);
|
||||
mShiftButton->setFlatColorUnfocused(0x60606025);
|
||||
}
|
||||
|
@ -547,7 +584,8 @@ void GuiTextEditKeyboardPopup::shiftKeys() {
|
|||
if (mAlt) {
|
||||
altKeys();
|
||||
altKeys();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
for (auto& kb : mKeyboardButtons) {
|
||||
const std::string& text = mShift ? kb.shiftedKey : kb.key;
|
||||
auto sz = kb.button->getSize();
|
||||
|
@ -557,13 +595,15 @@ void GuiTextEditKeyboardPopup::shiftKeys() {
|
|||
}
|
||||
}
|
||||
|
||||
void GuiTextEditKeyboardPopup::altKeys() {
|
||||
void GuiTextEditKeyboardPopup::altKeys()
|
||||
{
|
||||
mAlt = !mAlt;
|
||||
|
||||
if (mAlt) {
|
||||
mAltButton->setFlatColorFocused(0xFF2222FF);
|
||||
mAltButton->setFlatColorUnfocused(0xFF2222FF);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mAltButton->setFlatColorFocused(0x878787FF);
|
||||
mAltButton->setFlatColorUnfocused(0x60606025);
|
||||
}
|
||||
|
@ -577,7 +617,8 @@ void GuiTextEditKeyboardPopup::altKeys() {
|
|||
if (mShift) {
|
||||
shiftKeys();
|
||||
shiftKeys();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
for (auto& kb : mKeyboardButtons) {
|
||||
const std::string& text = mAlt ? kb.altedKey : kb.key;
|
||||
auto sz = kb.button->getSize();
|
||||
|
@ -587,7 +628,8 @@ void GuiTextEditKeyboardPopup::altKeys() {
|
|||
}
|
||||
}
|
||||
|
||||
void GuiTextEditKeyboardPopup::altShiftKeys() {
|
||||
void GuiTextEditKeyboardPopup::altShiftKeys()
|
||||
{
|
||||
for (auto& kb : mKeyboardButtons) {
|
||||
const std::string& text = kb.altshiftedKey;
|
||||
auto sz = kb.button->getSize();
|
||||
|
@ -600,7 +642,8 @@ std::shared_ptr<ButtonComponent> GuiTextEditKeyboardPopup::makeButton(
|
|||
const std::string& key,
|
||||
const std::string& shiftedKey,
|
||||
const std::string& altedKey,
|
||||
const std::string &altshiftedKey) {
|
||||
const std::string& altshiftedKey)
|
||||
{
|
||||
std::shared_ptr<ButtonComponent> button = std::make_shared<ButtonComponent>(
|
||||
mWindow, key, key,
|
||||
[this, key, shiftedKey, altedKey, altshiftedKey] {
|
||||
|
@ -608,24 +651,29 @@ std::shared_ptr<ButtonComponent> GuiTextEditKeyboardPopup::makeButton(
|
|||
mOkCallback(mText->getValue());
|
||||
delete this;
|
||||
return;
|
||||
} else if (key == (DELETE_SYMBOL) || key == "DEL") {
|
||||
}
|
||||
else if (key == (DELETE_SYMBOL) || key == "DEL") {
|
||||
mText->startEditing();
|
||||
mText->textInput("\b");
|
||||
mText->stopEditing();
|
||||
return;
|
||||
} else if (key == "SPACE" || key == " ") {
|
||||
}
|
||||
else if (key == "SPACE" || key == " ") {
|
||||
mText->startEditing();
|
||||
mText->textInput(" ");
|
||||
mText->stopEditing();
|
||||
return;
|
||||
} else if (key == "LOAD") {
|
||||
}
|
||||
else if (key == "LOAD") {
|
||||
mText->setValue(mDefaultValue->getValue());
|
||||
mText->setCursor(mDefaultValue->getValue().size());
|
||||
return;
|
||||
} else if (key == "CLEAR") {
|
||||
}
|
||||
else if (key == "CLEAR") {
|
||||
mText->setValue("");
|
||||
return;
|
||||
} else if (key == "CANCEL") {
|
||||
}
|
||||
else if (key == "CANCEL") {
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
#include "components/ComponentGrid.h"
|
||||
#include "components/TextEditComponent.h"
|
||||
|
||||
class GuiTextEditKeyboardPopup : public GuiComponent {
|
||||
class GuiTextEditKeyboardPopup : public GuiComponent
|
||||
{
|
||||
public:
|
||||
GuiTextEditKeyboardPopup(Window* window,
|
||||
const HelpStyle& helpstyle,
|
||||
|
@ -42,7 +43,8 @@ public:
|
|||
HelpStyle getHelpStyle() override { return mHelpStyle; }
|
||||
|
||||
private:
|
||||
class KeyboardButton {
|
||||
class KeyboardButton
|
||||
{
|
||||
public:
|
||||
std::shared_ptr<ButtonComponent> button;
|
||||
const std::string key;
|
||||
|
@ -55,7 +57,11 @@ private:
|
|||
const std::string& sk,
|
||||
const std::string& ak,
|
||||
const std::string& ask)
|
||||
: button{b}, key{k}, shiftedKey{sk}, altedKey{ak}, altshiftedKey{ask} {};
|
||||
: button{b}
|
||||
, key{k}
|
||||
, shiftedKey{sk}
|
||||
, altedKey{ak}
|
||||
, altshiftedKey{ask} {};
|
||||
};
|
||||
|
||||
void updateDeleteRepeat(int deltaTime);
|
||||
|
|
|
@ -28,12 +28,22 @@ GuiTextEditPopup::GuiTextEditPopup(Window *window,
|
|||
const std::string& loadBtnHelpText,
|
||||
const std::string& clearBtnHelpText,
|
||||
const std::string& cancelBtnHelpText)
|
||||
: GuiComponent{window}, mBackground{window, ":/graphics/frame.svg"},
|
||||
mGrid{window, glm::ivec2{1, (infoString != "" && defaultValue != "" ? 5 : 3)}}, mHelpStyle{helpstyle},
|
||||
mInitValue{initValue}, mAcceptBtnText{acceptBtnText}, mSaveConfirmationText{saveConfirmationText},
|
||||
mLoadBtnHelpText{loadBtnHelpText}, mClearBtnHelpText{clearBtnHelpText}, mCancelBtnHelpText{cancelBtnHelpText},
|
||||
mOkCallback{okCallback}, mMultiLine{multiLine}, mComplexMode{(infoString != "" && defaultValue != "")},
|
||||
mDeleteRepeat{false}, mDeleteRepeatTimer{0} {
|
||||
: GuiComponent{window}
|
||||
, mBackground{window, ":/graphics/frame.svg"}
|
||||
, mGrid{window, glm::ivec2{1, (infoString != "" && defaultValue != "" ? 5 : 3)}}
|
||||
, mHelpStyle{helpstyle}
|
||||
, mInitValue{initValue}
|
||||
, mAcceptBtnText{acceptBtnText}
|
||||
, mSaveConfirmationText{saveConfirmationText}
|
||||
, mLoadBtnHelpText{loadBtnHelpText}
|
||||
, mClearBtnHelpText{clearBtnHelpText}
|
||||
, mCancelBtnHelpText{cancelBtnHelpText}
|
||||
, mOkCallback{okCallback}
|
||||
, mMultiLine{multiLine}
|
||||
, mComplexMode{(infoString != "" && defaultValue != "")}
|
||||
, mDeleteRepeat{false}
|
||||
, mDeleteRepeatTimer{0}
|
||||
{
|
||||
addChild(&mBackground);
|
||||
addChild(&mGrid);
|
||||
|
||||
|
@ -109,7 +119,8 @@ GuiTextEditPopup::GuiTextEditPopup(Window *window,
|
|||
mButtonGrid->getSize().y + mButtonGrid->getSize().y * 1.85f);
|
||||
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
|
||||
(Renderer::getScreenHeight() - mSize.y) / 2.0f);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
float width = glm::clamp(0.54f * aspectValue, 0.20f, 0.70f) * Renderer::getScreenWidth();
|
||||
|
||||
setSize(width, mTitle->getFont()->getHeight() + textHeight + mButtonGrid->getSize().y +
|
||||
|
@ -124,7 +135,8 @@ GuiTextEditPopup::GuiTextEditPopup(Window *window,
|
|||
mText->startEditing();
|
||||
}
|
||||
|
||||
void GuiTextEditPopup::onSizeChanged() {
|
||||
void GuiTextEditPopup::onSizeChanged()
|
||||
{
|
||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
||||
mText->setSize(mSize.x - 40.0f * Renderer::getScreenHeightModifier(), mText->getSize().y);
|
||||
|
||||
|
@ -138,7 +150,8 @@ void GuiTextEditPopup::onSizeChanged() {
|
|||
mGrid.setSize(mSize);
|
||||
}
|
||||
|
||||
bool GuiTextEditPopup::input(InputConfig *config, Input input) {
|
||||
bool GuiTextEditPopup::input(InputConfig* config, Input input)
|
||||
{
|
||||
// Enter key (main key or via numpad) accepts the changes.
|
||||
if (config->getDeviceId() == DEVICE_KEYBOARD && mText->isEditing() && !mMultiLine &&
|
||||
input.value && (input.id == SDLK_RETURN || input.id == SDLK_KP_ENTER)) {
|
||||
|
@ -177,7 +190,8 @@ bool GuiTextEditPopup::input(InputConfig *config, Input input) {
|
|||
delete this;
|
||||
return true;
|
||||
}));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
delete this;
|
||||
return true;
|
||||
}
|
||||
|
@ -202,7 +216,8 @@ bool GuiTextEditPopup::input(InputConfig *config, Input input) {
|
|||
|
||||
if (!editing)
|
||||
mText->stopEditing();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mDeleteRepeat = false;
|
||||
}
|
||||
return true;
|
||||
|
@ -228,12 +243,14 @@ bool GuiTextEditPopup::input(InputConfig *config, Input input) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void GuiTextEditPopup::update(int deltaTime) {
|
||||
void GuiTextEditPopup::update(int deltaTime)
|
||||
{
|
||||
updateDeleteRepeat(deltaTime);
|
||||
GuiComponent::update(deltaTime);
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> GuiTextEditPopup::getHelpPrompts() {
|
||||
std::vector<HelpPrompt> GuiTextEditPopup::getHelpPrompts()
|
||||
{
|
||||
std::vector<HelpPrompt> prompts = mGrid.getHelpPrompts();
|
||||
|
||||
if (mText->isEditing())
|
||||
|
@ -245,7 +262,8 @@ std::vector<HelpPrompt> GuiTextEditPopup::getHelpPrompts() {
|
|||
return prompts;
|
||||
}
|
||||
|
||||
void GuiTextEditPopup::updateDeleteRepeat(int deltaTime) {
|
||||
void GuiTextEditPopup::updateDeleteRepeat(int deltaTime)
|
||||
{
|
||||
if (!mDeleteRepeat)
|
||||
return;
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
#include "components/ComponentGrid.h"
|
||||
#include "components/TextEditComponent.h"
|
||||
|
||||
class GuiTextEditPopup : public GuiComponent {
|
||||
class GuiTextEditPopup : public GuiComponent
|
||||
{
|
||||
public:
|
||||
GuiTextEditPopup(Window* window,
|
||||
const HelpStyle& helpstyle,
|
||||
|
|
Loading…
Reference in a new issue