Skip to content

Commit

Permalink
Merge pull request RetroPie#13 from batocera-linux/master
Browse files Browse the repository at this point in the history
Merge from Batocera master
  • Loading branch information
lbrpdx authored Jul 8, 2019
2 parents 7ede94d + 8982c64 commit 71187a2
Show file tree
Hide file tree
Showing 40 changed files with 2,876 additions and 492 deletions.
37 changes: 23 additions & 14 deletions es-app/src/CollectionSystemManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ CollectionSystemManager::CollectionSystemManager(Window* window) : mWindow(windo
{
CollectionSystemDecl systemDecls[] = {
//type name long name //default sort // theme folder // isCustom
{ AUTO_ALL_GAMES, "all", "all games", "filename, ascending", "auto-allgames", false },
{ AUTO_LAST_PLAYED, "recent", "last played", "last played, descending", "auto-lastplayed", false },
{ AUTO_FAVORITES, "favorites", "favorites", "filename, ascending", "auto-favorites", false },
{ CUSTOM_COLLECTION, myCollectionsName, "collections", "filename, ascending", "custom-collections", true }
{ AUTO_ALL_GAMES, "all", _("all games"), "filename, ascending", "auto-allgames", false },
{ AUTO_LAST_PLAYED, "recent", _("last played"), "last played, descending", "auto-lastplayed", false },
{ AUTO_FAVORITES, "favorites", _("favorites"), "filename, ascending", "auto-favorites", false },
{ AUTO_AT2PLAYERS, "2players", _("2 players"), "filename, ascending", "auto-at2players", false }, // batocera
{ AUTO_AT4PLAYERS, "4players", _("4 players"), "filename, ascending", "auto-at4players", false }, // batocera
{ CUSTOM_COLLECTION, myCollectionsName, _("collections"), "filename, ascending", "custom-collections", true }
};

// create a map
Expand Down Expand Up @@ -439,22 +441,23 @@ void CollectionSystemManager::setEditMode(std::string collectionName)
// if it's bundled, this needs to be the bundle system
mEditingCollectionSystemData = sysData;

GuiInfoPopup* s = new GuiInfoPopup(mWindow, "Editing the '" + Utils::String::toUpper(collectionName) + "' Collection. Add/remove games with Y.", 10000);
GuiInfoPopup* s = new GuiInfoPopup(mWindow, _("Editing the collection. Add/remove games with Y."), 10000);
mWindow->setInfoPopup(s);
}

void CollectionSystemManager::exitEditMode()
{
GuiInfoPopup* s = new GuiInfoPopup(mWindow, "Finished editing the '" + mEditingCollection + "' Collection.", 4000);
GuiInfoPopup* s = new GuiInfoPopup(mWindow, _("Finished editing the collection."), 4000);
mWindow->setInfoPopup(s);
mIsEditingCustom = false;
mEditingCollection = "Favorites";
}

// adds or removes a game from a specific collection
bool CollectionSystemManager::toggleGameInCollection(FileData* file, bool& adding) // batocera
bool CollectionSystemManager::toggleGameInCollection(FileData* file)
{
char trstring[256];
bool adding;
if (file->getType() == GAME)
{
GuiInfoPopup* s;
Expand All @@ -477,7 +480,6 @@ bool CollectionSystemManager::toggleGameInCollection(FileData* file, bool& addin
std::string name = sysData->getName();

SystemData* systemViewToUpdate = getSystemToView(sysData);

if (found) {
adding = false;
// if we found it, we need to remove it
Expand Down Expand Up @@ -628,10 +630,11 @@ void CollectionSystemManager::updateCollectionFolderMetadata(SystemData* sys)
desc = "This collection contains " + std::to_string(games_counter) + " games, including " + games_list;

FileData* randomGame = sys->getRandomGame();

video = randomGame->getVideoPath();
thumbnail = randomGame->getThumbnailPath();
image = randomGame->getImagePath();
if(randomGame != NULL) { // batocera
video = randomGame->getVideoPath();
thumbnail = randomGame->getThumbnailPath();
image = randomGame->getImagePath();
}
}


Expand Down Expand Up @@ -724,6 +727,13 @@ void CollectionSystemManager::populateAutoCollection(CollectionSystemData* sysDa
// we may still want to add files we don't want in auto collections in "favorites"
include = (*gameIt)->metadata.get("favorite") == "true";
break;
case AUTO_AT2PLAYERS: // batocera
include = atoi((*gameIt)->metadata.get("players").c_str()) >= 2;
break;
case AUTO_AT4PLAYERS: // batocera
include = atoi((*gameIt)->metadata.get("players").c_str()) >= 4;
break;

}

if (include) {
Expand Down Expand Up @@ -798,7 +808,6 @@ void CollectionSystemManager::removeCollectionsFromDisplayedSystems()
sysIt++;
}
}

// remove all custom collections in bundle
// this should not delete the objects from memory!
FileData* customRoot = mCustomCollectionsBundle->getRootFolder();
Expand Down Expand Up @@ -833,7 +842,7 @@ void CollectionSystemManager::addEnabledCollectionsToDisplayedSystems(std::map<s
}
}
// check if it has its own view
if(!it->second.decl.isCustom || themeFolderExists(it->first) || !Settings::getInstance()->getBool("UseCustomCollectionsSystem"))
if(!it->second.decl.isCustom || themeFolderExists(it->first) /*|| !Settings::getInstance()->getBool("UseCustomCollectionsSystem")*/) // batocera
{
// exists theme folder, or we chose not to bundle it under the custom-collections system
// so we need to create a view
Expand Down
4 changes: 3 additions & 1 deletion es-app/src/CollectionSystemManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ enum CollectionSystemType
AUTO_ALL_GAMES,
AUTO_LAST_PLAYED,
AUTO_FAVORITES,
AUTO_AT2PLAYERS,
AUTO_AT4PLAYERS,
CUSTOM_COLLECTION
};

Expand Down Expand Up @@ -71,7 +73,7 @@ class CollectionSystemManager
void exitEditMode();
inline bool isEditing() { return mIsEditingCustom; };
inline std::string getEditingCollection() { return mEditingCollection; };
bool toggleGameInCollection(FileData* file, bool& adding); // batocera
bool toggleGameInCollection(FileData* file);

SystemData* getSystemToView(SystemData* sys);
void updateCollectionFolderMetadata(SystemData* sys);
Expand Down
2 changes: 1 addition & 1 deletion es-app/src/FileData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void FileData::launchGame(Window* window)
const std::string basename = Utils::FileSystem::getStem(getPath());
const std::string rom_raw = Utils::FileSystem::getPreferredPath(getPath());

command = Utils::String::replace(command, "%SYSTEM%", mSystem->getName()); // batocera
command = Utils::String::replace(command, "%SYSTEM%", getSourceFileData()->getSystem()->getName()); // batocera
command = Utils::String::replace(command, "%ROM%", rom);
command = Utils::String::replace(command, "%BASENAME%", basename);
command = Utils::String::replace(command, "%ROM_RAW%", rom_raw);
Expand Down
39 changes: 22 additions & 17 deletions es-app/src/guis/GuiCollectionSystemsOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
#include "components/OptionListComponent.h"
#include "components/SwitchComponent.h"
#include "guis/GuiSettings.h"
#include "guis/GuiTextEditPopupKeyboard.h"
#include "guis/GuiTextEditPopup.h"
#include "utils/StringUtil.h"
#include "views/ViewController.h"
#include "CollectionSystemManager.h"
#include "Window.h"

GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window) : GuiComponent(window), mMenu(window, "GAME COLLECTION SETTINGS")
GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window) : GuiComponent(window), mMenu(window, _("GAME COLLECTION SETTINGS").c_str())
{
initializeMenu();
}
Expand All @@ -25,12 +26,12 @@ void GuiCollectionSystemsOptions::initializeMenu()
// add "Create New Custom Collection from Theme"

std::vector<std::string> unusedFolders = CollectionSystemManager::get()->getUnusedSystemsFromTheme();
if (unusedFolders.size() > 0)
if (unusedFolders.size() > 0 && false) // batocera
{
addEntry("CREATE NEW CUSTOM COLLECTION FROM THEME", 0x777777FF, true,
addEntry(_("CREATE NEW CUSTOM COLLECTION FROM THEME").c_str(), 0x777777FF, true,
[this, unusedFolders] {
auto s = new GuiSettings(mWindow, "SELECT THEME FOLDER");
std::shared_ptr< OptionListComponent<std::string> > folderThemes = std::make_shared< OptionListComponent<std::string> >(mWindow, "SELECT THEME FOLDER", true);
auto s = new GuiSettings(mWindow, _("SELECT THEME FOLDER").c_str());
std::shared_ptr< OptionListComponent<std::string> > folderThemes = std::make_shared< OptionListComponent<std::string> >(mWindow, _("SELECT THEME FOLDER"), true);

// add Custom Systems
for(auto it = unusedFolders.cbegin() ; it != unusedFolders.cend() ; it++ )
Expand All @@ -52,7 +53,7 @@ void GuiCollectionSystemsOptions::initializeMenu()
}

ComponentListRow row;
row.addElement(std::make_shared<TextComponent>(mWindow, "CREATE NEW CUSTOM COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
row.addElement(std::make_shared<TextComponent>(mWindow, _("CREATE NEW CUSTOM COLLECTION"), Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
auto createCustomCollection = [this](const std::string& newVal) {
std::string name = newVal;
// we need to store the first Gui and remove it, as it'll be deleted by the actual Gui
Expand All @@ -62,28 +63,32 @@ void GuiCollectionSystemsOptions::initializeMenu()
createCollection(name);
};
row.makeAcceptInputHandler([this, createCustomCollection] {
mWindow->pushGui(new GuiTextEditPopup(mWindow, "New Collection Name", "", createCustomCollection, false));
if (Settings::getInstance()->getBool("UseOSK")) {
mWindow->pushGui(new GuiTextEditPopupKeyboard(mWindow, _("New Collection Name"), "", createCustomCollection, false));
} else {
mWindow->pushGui(new GuiTextEditPopup(mWindow, _("New Collection Name"), "", createCustomCollection, false));
}
});

mMenu.addRow(row);

bundleCustomCollections = std::make_shared<SwitchComponent>(mWindow);
bundleCustomCollections->setState(Settings::getInstance()->getBool("UseCustomCollectionsSystem"));
mMenu.addWithLabel("GROUP UNTHEMED CUSTOM COLLECTIONS", bundleCustomCollections);
//mMenu.addWithLabel(_("GROUP UNTHEMED CUSTOM COLLECTIONS"), bundleCustomCollections);

sortAllSystemsSwitch = std::make_shared<SwitchComponent>(mWindow);
sortAllSystemsSwitch->setState(Settings::getInstance()->getBool("SortAllSystems"));
mMenu.addWithLabel("SORT CUSTOM COLLECTIONS AND SYSTEMS", sortAllSystemsSwitch);
//mMenu.addWithLabel(_("SORT CUSTOM COLLECTIONS AND SYSTEMS"), sortAllSystemsSwitch);

if(CollectionSystemManager::get()->isEditing())
{
row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, "FINISH EDITING '" + Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()) + "' COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
row.addElement(std::make_shared<TextComponent>(mWindow, _("FINISH EDITING COLLECTION") + " : " + Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()), Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
row.makeAcceptInputHandler(std::bind(&GuiCollectionSystemsOptions::exitEditMode, this));
mMenu.addRow(row);
}

mMenu.addButton("BACK", "back", std::bind(&GuiCollectionSystemsOptions::applySettings, this));
mMenu.addButton(_("BACK"), "back", std::bind(&GuiCollectionSystemsOptions::applySettings, this));

mMenu.setPosition((Renderer::getScreenWidth() - mMenu.getSize().x()) / 2, Renderer::getScreenHeight() * 0.15f);
}
Expand Down Expand Up @@ -139,25 +144,25 @@ void GuiCollectionSystemsOptions::addSystemsToMenu()

std::map<std::string, CollectionSystemData> autoSystems = CollectionSystemManager::get()->getAutoCollectionSystems();

autoOptionList = std::make_shared< OptionListComponent<std::string> >(mWindow, "SELECT COLLECTIONS", true);
autoOptionList = std::make_shared< OptionListComponent<std::string> >(mWindow, _("SELECT COLLECTIONS"), true);

// add Auto Systems
for(std::map<std::string, CollectionSystemData>::const_iterator it = autoSystems.cbegin() ; it != autoSystems.cend() ; it++ )
{
autoOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
}
mMenu.addWithLabel("AUTOMATIC GAME COLLECTIONS", autoOptionList);
mMenu.addWithLabel(_("AUTOMATIC GAME COLLECTIONS"), autoOptionList);

std::map<std::string, CollectionSystemData> customSystems = CollectionSystemManager::get()->getCustomCollectionSystems();

customOptionList = std::make_shared< OptionListComponent<std::string> >(mWindow, "SELECT COLLECTIONS", true);
customOptionList = std::make_shared< OptionListComponent<std::string> >(mWindow, _("SELECT COLLECTIONS"), true);

// add Custom Systems
for(std::map<std::string, CollectionSystemData>::const_iterator it = customSystems.cbegin() ; it != customSystems.cend() ; it++ )
{
customOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
}
mMenu.addWithLabel("CUSTOM GAME COLLECTIONS", customOptionList);
mMenu.addWithLabel(_("CUSTOM GAME COLLECTIONS"), customOptionList);
}

void GuiCollectionSystemsOptions::applySettings()
Expand Down Expand Up @@ -197,7 +202,7 @@ bool GuiCollectionSystemsOptions::input(InputConfig* config, Input input)
if(consumed)
return true;

if(config->isMappedTo("b", input) && input.value != 0)
if(config->isMappedTo("a", input) && input.value != 0) // batocera
{
applySettings();
}
Expand All @@ -209,6 +214,6 @@ bool GuiCollectionSystemsOptions::input(InputConfig* config, Input input)
std::vector<HelpPrompt> GuiCollectionSystemsOptions::getHelpPrompts()
{
std::vector<HelpPrompt> prompts = mMenu.getHelpPrompts();
prompts.push_back(HelpPrompt("b", _("BACK"))); // batocera
prompts.push_back(HelpPrompt("a", _("BACK"))); // batocera
return prompts;
}
4 changes: 2 additions & 2 deletions es-app/src/guis/GuiGamelistFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void GuiGamelistFilter::initializeMenu()

addFiltersToMenu();

mMenu.addButton("BACK", "back", std::bind(&GuiGamelistFilter::applyFilters, this));
mMenu.addButton(_("BACK"), "back", std::bind(&GuiGamelistFilter::applyFilters, this));

mMenu.setPosition((Renderer::getScreenWidth() - mMenu.getSize().x()) / 2, Renderer::getScreenHeight() * 0.15f);
}
Expand Down Expand Up @@ -112,6 +112,6 @@ bool GuiGamelistFilter::input(InputConfig* config, Input input)
std::vector<HelpPrompt> GuiGamelistFilter::getHelpPrompts()
{
std::vector<HelpPrompt> prompts = mMenu.getHelpPrompts();
prompts.push_back(HelpPrompt("b", _("BACK"))); // batocera
prompts.push_back(HelpPrompt("a", _("BACK"))); // batocera
return prompts;
}
8 changes: 4 additions & 4 deletions es-app/src/guis/GuiGamelistOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui
CollectionSystemManager::get()->getCustomCollectionsBundle()->getName() == system->getName()))
{
row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, "ADD/REMOVE GAMES TO THIS GAME COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
row.addElement(std::make_shared<TextComponent>(mWindow, _("ADD/REMOVE GAMES TO THIS GAME COLLECTION"), Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::startEditMode, this));
mMenu.addRow(row);
}

if(UIModeController::getInstance()->isUIModeFull() && CollectionSystemManager::get()->isEditing())
{
row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, "FINISH EDITING '" + Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()) + "' COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
row.addElement(std::make_shared<TextComponent>(mWindow, _("FINISH EDITING COLLECTION") + " : " + Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()), Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::exitEditMode, this));
mMenu.addRow(row);
}
Expand All @@ -118,12 +118,12 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui
}

// batocera
if (UIModeController::getInstance()->isUIModeFull())
if (UIModeController::getInstance()->isUIModeFull() && !(mSystem->isCollection() && file->getType() == FOLDER))
{
row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, _("ADVANCED"), Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
row.addElement(makeArrow(mWindow), false);
row.makeAcceptInputHandler([this, file, system] { GuiMenu::popGameConfigurationGui(mWindow, Utils::FileSystem::getFileName(file->getPath()), system, ""); });
row.makeAcceptInputHandler([this, file, system] { GuiMenu::popGameConfigurationGui(mWindow, Utils::FileSystem::getFileName(file->getPath()), file->getSourceFileData()->getSystem(), ""); });
mMenu.addRow(row);
}

Expand Down
Loading

0 comments on commit 71187a2

Please sign in to comment.