Simplified the code for info popups.

This commit is contained in:
Leon Styhre 2021-10-07 18:31:40 +02:00
parent 2bd4c163b1
commit 93950cf4de
10 changed files with 77 additions and 109 deletions

View file

@ -30,7 +30,6 @@ set(ES_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistFilter.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistFilter.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistOptions.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistOptions.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGameScraper.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGameScraper.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInfoPopup.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiLaunchScreen.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiLaunchScreen.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMediaViewerOptions.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMediaViewerOptions.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMenu.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMenu.h
@ -81,7 +80,6 @@ set(ES_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistFilter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistFilter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistOptions.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistOptions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGameScraper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGameScraper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInfoPopup.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiLaunchScreen.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiLaunchScreen.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMenu.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMenu.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMediaViewerOptions.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMediaViewerOptions.cpp

View file

@ -27,7 +27,7 @@
#include "Settings.h" #include "Settings.h"
#include "SystemData.h" #include "SystemData.h"
#include "ThemeData.h" #include "ThemeData.h"
#include "guis/GuiInfoPopup.h" #include "Window.h"
#include "utils/FileSystemUtil.h" #include "utils/FileSystemUtil.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include "utils/TimeUtil.h" #include "utils/TimeUtil.h"
@ -385,14 +385,12 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
parentRootFolder->sort(parentRootFolder->getSortTypeFromString( parentRootFolder->sort(parentRootFolder->getSortTypeFromString(
parentRootFolder->getSortTypeString()), parentRootFolder->getSortTypeString()),
mFavoritesSorting); mFavoritesSorting);
GuiInfoPopup* s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow,
"DISABLED '" + "DISABLED '" +
Utils::String::toUpper( Utils::String::toUpper(
Utils::String::removeParenthesis(file->getName())) + Utils::String::removeParenthesis(file->getName())) +
"' IN '" + Utils::String::toUpper(sysData.system->getName()) + "'", "' IN '" + Utils::String::toUpper(sysData.system->getName()) + "'",
4000); 4000);
mWindow->setInfoPopup(s);
} }
else { else {
ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry, ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry,
@ -621,24 +619,18 @@ void CollectionSystemsManager::setEditMode(std::string collectionName, bool show
mEditingCollectionSystemData = sysData; mEditingCollectionSystemData = sysData;
if (showPopup) { if (showPopup) {
GuiInfoPopup* s = new GuiInfoPopup(mWindow, mWindow->queueInfoPopup("EDITING '" + Utils::String::toUpper(collectionName) +
"EDITING '" + Utils::String::toUpper(collectionName) + "' COLLECTION, ADD/REMOVE GAMES WITH 'Y'",
"' COLLECTION, ADD/REMOVE GAMES WITH 'Y'", 10000);
10000);
mWindow->setInfoPopup(s);
} }
} }
void CollectionSystemsManager::exitEditMode(bool showPopup) void CollectionSystemsManager::exitEditMode(bool showPopup)
{ {
if (showPopup) { if (showPopup) {
GuiInfoPopup* s = new GuiInfoPopup( mWindow->queueInfoPopup("FINISHED EDITING '" + Utils::String::toUpper(mEditingCollection) +
mWindow, "' COLLECTION",
"FINISHED EDITING '" + Utils::String::toUpper(mEditingCollection) + "' COLLECTION", 4000);
4000);
mWindow->setInfoPopup(s);
} }
mIsEditingCustom = false; mIsEditingCustom = false;
@ -669,7 +661,6 @@ bool CollectionSystemsManager::inCustomCollection(const std::string& collectionN
bool CollectionSystemsManager::toggleGameInCollection(FileData* file) bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
{ {
if (file->getType() == GAME) { if (file->getType() == GAME) {
GuiInfoPopup* s;
bool adding = true; bool adding = true;
std::string name = file->getName(); std::string name = file->getName();
std::string sysName = mEditingCollection; std::string sysName = mEditingCollection;
@ -743,20 +734,17 @@ bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
mAutoCollectionSystemsData["favorites"].system); mAutoCollectionSystemsData["favorites"].system);
} }
if (adding) { if (adding) {
s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow,
"ADDED '" + Utils::String::toUpper(Utils::String::removeParenthesis(name)) + "ADDED '" + Utils::String::toUpper(Utils::String::removeParenthesis(name)) +
"' TO '" + Utils::String::toUpper(sysName) + "'", "' TO '" + Utils::String::toUpper(sysName) + "'",
4000); 4000);
} }
else { else {
s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow,
"REMOVED '" + Utils::String::toUpper(Utils::String::removeParenthesis(name)) + "REMOVED '" + Utils::String::toUpper(Utils::String::removeParenthesis(name)) +
"' FROM '" + Utils::String::toUpper(sysName) + "'", "' FROM '" + Utils::String::toUpper(sysName) + "'",
4000); 4000);
} }
mWindow->setInfoPopup(s);
return true; return true;
} }
return false; return false;
@ -952,9 +940,8 @@ void CollectionSystemsManager::deleteCustomCollection(std::string collectionName
"configuration file '" "configuration file '"
<< configFile << "'."; << configFile << "'.";
GuiInfoPopup* s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow, "DELETED COLLECTION '" + Utils::String::toUpper(collectionName) + "'", 5000); "DELETED COLLECTION '" + Utils::String::toUpper(collectionName) + "'", 5000);
mWindow->setInfoPopup(s);
} }
else { else {
LOG(LogError) << "Attempted to delete custom collection '" + collectionName + "' " + LOG(LogError) << "Attempted to delete custom collection '" + collectionName + "' " +

View file

@ -20,7 +20,6 @@
#include "Scripting.h" #include "Scripting.h"
#include "SystemData.h" #include "SystemData.h"
#include "Window.h" #include "Window.h"
#include "guis/GuiInfoPopup.h"
#include "utils/FileSystemUtil.h" #include "utils/FileSystemUtil.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include "utils/TimeUtil.h" #include "utils/TimeUtil.h"
@ -856,9 +855,8 @@ void FileData::launchGame(Window* window)
LOG(LogError) << "Raw emulator launch command:"; LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw; LOG(LogError) << commandRaw;
GuiInfoPopup* s = new GuiInfoPopup( window->queueInfoPopup("ERROR: MISSING EMULATOR CONFIGURATION FOR '" + emulatorEntry + "'",
window, "ERROR: MISSING EMULATOR CONFIGURATION FOR '" + emulatorEntry + "'", 6000); 6000);
window->setInfoPopup(s);
return; return;
} }
else if (binaryPath.empty()) { else if (binaryPath.empty()) {
@ -866,11 +864,8 @@ void FileData::launchGame(Window* window)
LOG(LogError) << "Raw emulator launch command:"; LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw; LOG(LogError) << commandRaw;
GuiInfoPopup* s = new GuiInfoPopup(window, window->queueInfoPopup("ERROR: COULDN'T FIND EMULATOR, HAS IT BEEN PROPERLY INSTALLED?",
"ERROR: COULDN'T FIND EMULATOR, HAS IT " 6000);
"BEEN PROPERLY INSTALLED?",
6000);
window->setInfoPopup(s);
return; return;
} }
else { else {
@ -914,12 +909,10 @@ void FileData::launchGame(Window* window)
LOG(LogError) << "Raw emulator launch command:"; LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw; LOG(LogError) << commandRaw;
GuiInfoPopup* s = new GuiInfoPopup( window->queueInfoPopup(
window,
"ERROR: COULDN'T FIND EMULATOR CORE FILE '" + "ERROR: COULDN'T FIND EMULATOR CORE FILE '" +
Utils::String::toUpper(Utils::FileSystem::getFileName(coreFile)) + "'", Utils::String::toUpper(Utils::FileSystem::getFileName(coreFile)) + "'",
6000); 6000);
window->setInfoPopup(s);
return; return;
} }
else { else {
@ -937,11 +930,7 @@ void FileData::launchGame(Window* window)
LOG(LogError) << "Raw emulator launch command:"; LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw; LOG(LogError) << commandRaw;
GuiInfoPopup* s = new GuiInfoPopup(window, window->queueInfoPopup("ERROR: INVALID ENTRY IN SYSTEMS CONFIGURATION FILE", 6000);
"ERROR: INVALID ENTRY IN SYSTEMS "
"CONFIGURATION FILE",
6000);
window->setInfoPopup(s);
return; return;
} }
} }
@ -953,9 +942,7 @@ void FileData::launchGame(Window* window)
LOG(LogError) << "Raw emulator launch command:"; LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw; LOG(LogError) << commandRaw;
GuiInfoPopup* s = new GuiInfoPopup( window->queueInfoPopup("ERROR: MISSING CORE CONFIGURATION FOR '" + coreEntry + "'", 6000);
window, "ERROR: MISSING CORE CONFIGURATION FOR '" + coreEntry + "'", 6000);
window->setInfoPopup(s);
return; return;
} }
@ -1024,11 +1011,7 @@ void FileData::launchGame(Window* window)
LOG(LogError) << "Raw emulator launch command:"; LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw; LOG(LogError) << commandRaw;
GuiInfoPopup* s = new GuiInfoPopup(window, window->queueInfoPopup("ERROR: INVALID ENTRY IN SYSTEMS CONFIGURATION FILE", 6000);
"ERROR: INVALID ENTRY IN SYSTEMS "
"CONFIGURATION FILE",
6000);
window->setInfoPopup(s);
return; return;
} }
} }
@ -1041,12 +1024,10 @@ void FileData::launchGame(Window* window)
<< "Tried to find the core file using these paths as defined by es_find_rules.xml:"; << "Tried to find the core file using these paths as defined by es_find_rules.xml:";
LOG(LogError) << Utils::String::vectorToDelimitedString(emulatorCorePaths, ", "); LOG(LogError) << Utils::String::vectorToDelimitedString(emulatorCorePaths, ", ");
GuiInfoPopup* s = window->queueInfoPopup(
new GuiInfoPopup(window, "ERROR: COULDN'T FIND EMULATOR CORE FILE '" +
"ERROR: COULDN'T FIND EMULATOR CORE FILE '" + Utils::String::toUpper(coreName.substr(0, coreName.size()) + "'"),
Utils::String::toUpper(coreName.substr(0, coreName.size()) + "'"), 6000);
6000);
window->setInfoPopup(s);
return; return;
} }
@ -1087,12 +1068,10 @@ void FileData::launchGame(Window* window)
if (returnValue != 0) { if (returnValue != 0) {
LOG(LogWarning) << "...launch terminated with nonzero return value " << returnValue; LOG(LogWarning) << "...launch terminated with nonzero return value " << returnValue;
GuiInfoPopup* s = new GuiInfoPopup( window->queueInfoPopup("ERROR LAUNCHING GAME '" +
window, Utils::String::toUpper(metadata.get("name")) + "' (ERROR CODE " +
"ERROR LAUNCHING GAME '" + Utils::String::toUpper(metadata.get("name")) + Utils::String::toUpper(std::to_string(returnValue) + ")"),
"' (ERROR CODE " + Utils::String::toUpper(std::to_string(returnValue) + ")"), 6000);
6000);
window->setInfoPopup(s);
} }
else { else {
// Stop showing the game launch notification. // Stop showing the game launch notification.

View file

@ -24,7 +24,6 @@
#include "animations/Animation.h" #include "animations/Animation.h"
#include "animations/LambdaAnimation.h" #include "animations/LambdaAnimation.h"
#include "animations/MoveCameraAnimation.h" #include "animations/MoveCameraAnimation.h"
#include "guis/GuiInfoPopup.h"
#include "guis/GuiMenu.h" #include "guis/GuiMenu.h"
#include "guis/GuiTextEditKeyboardPopup.h" #include "guis/GuiTextEditKeyboardPopup.h"
#include "guis/GuiTextEditPopup.h" #include "guis/GuiTextEditPopup.h"
@ -700,10 +699,8 @@ void ViewController::launch(FileData* game)
if (durationString == "disabled") { if (durationString == "disabled") {
// If the game launch screen has been set as disabled, show a simple info popup // If the game launch screen has been set as disabled, show a simple info popup
// notification instead. // notification instead.
GuiInfoPopup* s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow, "LAUNCHING GAME '" + Utils::String::toUpper(game->metadata.get("name") + "'"), "LAUNCHING GAME '" + Utils::String::toUpper(game->metadata.get("name") + "'"), 10000);
10000);
mWindow->setInfoPopup(s);
duration = 1700; duration = 1700;
} }
else if (durationString == "brief") { else if (durationString == "brief") {

View file

@ -13,7 +13,7 @@
#include "Settings.h" #include "Settings.h"
#include "Sound.h" #include "Sound.h"
#include "SystemData.h" #include "SystemData.h"
#include "guis/GuiInfoPopup.h" #include "Window.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include "views/UIModeController.h" #include "views/UIModeController.h"
#include "views/ViewController.h" #include "views/ViewController.h"
@ -273,18 +273,13 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER && mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER &&
getCursor()->getParent()->getPath() == "collections") { getCursor()->getParent()->getPath() == "collections") {
NavigationSounds::getInstance()->playThemeNavigationSound(FAVORITESOUND); NavigationSounds::getInstance()->playThemeNavigationSound(FAVORITESOUND);
GuiInfoPopup* s; mWindow->queueInfoPopup("CAN'T ADD CUSTOM COLLECTIONS TO CUSTOM COLLECTIONS", 4000);
s = new GuiInfoPopup(mWindow, "CAN'T ADD CUSTOM COLLECTIONS TO CUSTOM COLLECTIONS",
4000);
mWindow->setInfoPopup(s);
} }
// Notify the user if attempting to add a placeholder to a custom collection. // Notify the user if attempting to add a placeholder to a custom collection.
if (CollectionSystemsManager::get()->isEditing() && if (CollectionSystemsManager::get()->isEditing() &&
mRoot->getSystem()->isGameSystem() && getCursor()->getType() == PLACEHOLDER) { mRoot->getSystem()->isGameSystem() && getCursor()->getType() == PLACEHOLDER) {
NavigationSounds::getInstance()->playThemeNavigationSound(FAVORITESOUND); NavigationSounds::getInstance()->playThemeNavigationSound(FAVORITESOUND);
GuiInfoPopup* s; mWindow->queueInfoPopup("CAN'T ADD PLACEHOLDERS TO CUSTOM COLLECTIONS", 4000);
s = new GuiInfoPopup(mWindow, "CAN'T ADD PLACEHOLDERS TO CUSTOM COLLECTIONS", 4000);
mWindow->setInfoPopup(s);
} }
else if (mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER && else if (mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER &&
getCursor()->getParent()->getPath() != "collections") { getCursor()->getParent()->getPath() != "collections") {
@ -394,17 +389,14 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
// so it makes more sense to handle it here than to add the function to // so it makes more sense to handle it here than to add the function to
// CollectionSystemsManager. // CollectionSystemsManager.
if (entryToUpdate->getType() == FOLDER) { if (entryToUpdate->getType() == FOLDER) {
GuiInfoPopup* s;
if (isEditing) { if (isEditing) {
s = new GuiInfoPopup(mWindow, "CAN'T ADD FOLDERS TO CUSTOM COLLECTIONS", mWindow->queueInfoPopup("CAN'T ADD FOLDERS TO CUSTOM COLLECTIONS", 4000);
4000);
} }
else { else {
MetaDataList* md = &entryToUpdate->getSourceFileData()->metadata; MetaDataList* md = &entryToUpdate->getSourceFileData()->metadata;
if (md->get("favorite") == "false") { if (md->get("favorite") == "false") {
md->set("favorite", "true"); md->set("favorite", "true");
s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow,
"MARKED FOLDER '" + "MARKED FOLDER '" +
Utils::String::toUpper(Utils::String::removeParenthesis( Utils::String::toUpper(Utils::String::removeParenthesis(
entryToUpdate->getName())) + entryToUpdate->getName())) +
@ -413,8 +405,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
} }
else { else {
md->set("favorite", "false"); md->set("favorite", "false");
s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow,
"REMOVED FAVORITE MARKING FOR FOLDER '" + "REMOVED FAVORITE MARKING FOR FOLDER '" +
Utils::String::toUpper(Utils::String::removeParenthesis( Utils::String::toUpper(Utils::String::removeParenthesis(
entryToUpdate->getName())) + entryToUpdate->getName())) +
@ -423,7 +414,6 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
} }
} }
mWindow->setInfoPopup(s);
entryToUpdate->getSourceFileData()->getSystem()->onMetaDataSavePoint(); entryToUpdate->getSourceFileData()->getSystem()->onMetaDataSavePoint();
getCursor()->getParent()->sort( getCursor()->getParent()->sort(
@ -445,11 +435,9 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
return true; return true;
} }
else if (isEditing && entryToUpdate->metadata.get("nogamecount") == "true") { else if (isEditing && entryToUpdate->metadata.get("nogamecount") == "true") {
GuiInfoPopup* s = new GuiInfoPopup(mWindow, mWindow->queueInfoPopup("CAN'T ADD ENTRIES THAT ARE NOT COUNTED "
"CAN'T ADD ENTRIES THAT ARE NOT COUNTED " "AS GAMES TO CUSTOM COLLECTIONS",
"AS GAMES TO CUSTOM COLLECTIONS", 4000);
4000);
mWindow->setInfoPopup(s);
} }
else if (CollectionSystemsManager::get()->toggleGameInCollection(entryToUpdate)) { else if (CollectionSystemsManager::get()->toggleGameInCollection(entryToUpdate)) {
// As the toggling of the game destroyed this object, we need to get the view // As the toggling of the game destroyed this object, we need to get the view

View file

@ -61,6 +61,7 @@ set(CORE_HEADERS
# GUIs # GUIs
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiDetectDevice.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiDetectDevice.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInfoPopup.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInputConfig.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInputConfig.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMsgBox.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMsgBox.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiTextEditKeyboardPopup.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiTextEditKeyboardPopup.h
@ -131,6 +132,7 @@ set(CORE_SOURCES
# GUIs # GUIs
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiDetectDevice.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiDetectDevice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInfoPopup.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInputConfig.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInputConfig.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMsgBox.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMsgBox.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiTextEditKeyboardPopup.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiTextEditKeyboardPopup.cpp

View file

@ -11,6 +11,7 @@
#include "components/HelpComponent.h" #include "components/HelpComponent.h"
#include "components/ImageComponent.h" #include "components/ImageComponent.h"
#include "guis/GuiInfoPopup.h"
#if defined(BUILD_VLC_PLAYER) #if defined(BUILD_VLC_PLAYER)
#include "components/VideoVlcComponent.h" #include "components/VideoVlcComponent.h"
#endif #endif
@ -338,6 +339,24 @@ void Window::update(int deltaTime)
mTimeSinceLastInput += deltaTime; mTimeSinceLastInput += deltaTime;
// If there is a popup notification queued, then display it.
if (mInfoPopupQueue.size() > 0) {
bool popupIsRunning = false;
// If uncommenting the following, new popups will not be displayed until the one
// currently shown has reached its display duration. This will be used later when
// support for multiple GuiInfoPopup notifications is implemented.
// if (mInfoPopup != nullptr && mInfoPopup->isRunning())
// popupIsRunning = true;
if (!popupIsRunning) {
delete mInfoPopup;
mInfoPopup = new GuiInfoPopup(this, mInfoPopupQueue.front().first,
mInfoPopupQueue.front().second);
mInfoPopupQueue.pop();
}
}
if (peekGui()) if (peekGui())
peekGui()->update(deltaTime); peekGui()->update(deltaTime);
@ -689,16 +708,13 @@ void Window::reloadHelpPrompts()
} }
} }
void Window::setInfoPopup(InfoPopup* infoPopup)
{
delete mInfoPopup;
mInfoPopup = infoPopup;
}
void Window::stopInfoPopup() void Window::stopInfoPopup()
{ {
if (mInfoPopup) if (mInfoPopup)
mInfoPopup->stop(); mInfoPopup->stop();
if (mInfoPopupQueue.size() > 0)
std::queue<std::pair<std::string, int>>().swap(mInfoPopupQueue);
} }
void Window::startScreensaver() void Window::startScreensaver()

View file

@ -18,10 +18,12 @@
#include <memory> #include <memory>
#include <mutex> #include <mutex>
#include <queue>
class FileData; class FileData;
class Font; class Font;
class GuiComponent; class GuiComponent;
class GuiInfoPopup;
class HelpComponent; class HelpComponent;
class ImageComponent; class ImageComponent;
class InputConfig; class InputConfig;
@ -73,14 +75,6 @@ public:
virtual void render(const glm::mat4& parentTrans) = 0; virtual void render(const glm::mat4& parentTrans) = 0;
}; };
class InfoPopup
{
public:
virtual void render(const glm::mat4& parentTrans) = 0;
virtual void stop() = 0;
virtual ~InfoPopup() {}
};
Window(); Window();
~Window(); ~Window();
@ -113,7 +107,11 @@ public:
void setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpStyle& style); void setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpStyle& style);
void reloadHelpPrompts(); void reloadHelpPrompts();
void setInfoPopup(InfoPopup* infoPopup); // GuiInfoPopup notifications.
void queueInfoPopup(const std::string& message, const int& duration)
{
mInfoPopupQueue.emplace(std::make_pair(message, duration));
}
void stopInfoPopup(); void stopInfoPopup();
void startScreensaver(); void startScreensaver();
@ -165,7 +163,9 @@ private:
Screensaver* mScreensaver; Screensaver* mScreensaver;
MediaViewer* mMediaViewer; MediaViewer* mMediaViewer;
GuiLaunchScreen* mLaunchScreen; GuiLaunchScreen* mLaunchScreen;
InfoPopup* mInfoPopup; GuiInfoPopup* mInfoPopup;
std::queue<std::pair<std::string, int>> mInfoPopupQueue;
std::string mListScrollText; std::string mListScrollText;
std::shared_ptr<Font> mListScrollFont; std::shared_ptr<Font> mListScrollFont;

View file

@ -15,14 +15,15 @@
class ComponentGrid; class ComponentGrid;
class NinePatchComponent; class NinePatchComponent;
class GuiInfoPopup : public GuiComponent, public Window::InfoPopup class GuiInfoPopup : public GuiComponent
{ {
public: public:
GuiInfoPopup(Window* window, std::string message, int duration); GuiInfoPopup(Window* window, std::string message, int duration);
~GuiInfoPopup(); ~GuiInfoPopup();
void render(const glm::mat4& parentTrans) override; void render(const glm::mat4& parentTrans);
void stop() override { mRunning = false; } void stop() { mRunning = false; }
bool isRunning() { return mRunning; }
private: private:
bool updateState(); bool updateState();