mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-29 19:55:37 +00:00
Merge pull request #44 from RetroPie/revert-1-direct-launch
Revert "Add direct launch option for systems that don't need a game list"
This commit is contained in:
commit
abcc9696a2
|
@ -18,7 +18,7 @@ std::vector<SystemData*> SystemData::sSystemVector;
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
SystemData::SystemData(const std::string& name, const std::string& fullName, const std::string& startPath, const std::vector<std::string>& extensions,
|
SystemData::SystemData(const std::string& name, const std::string& fullName, const std::string& startPath, const std::vector<std::string>& extensions,
|
||||||
const std::string& command, const std::vector<PlatformIds::PlatformId>& platformIds, const std::string& themeFolder, bool directLaunch)
|
const std::string& command, const std::vector<PlatformIds::PlatformId>& platformIds, const std::string& themeFolder)
|
||||||
{
|
{
|
||||||
mName = name;
|
mName = name;
|
||||||
mFullName = fullName;
|
mFullName = fullName;
|
||||||
|
@ -36,8 +36,6 @@ SystemData::SystemData(const std::string& name, const std::string& fullName, con
|
||||||
mPlatformIds = platformIds;
|
mPlatformIds = platformIds;
|
||||||
mThemeFolder = themeFolder;
|
mThemeFolder = themeFolder;
|
||||||
|
|
||||||
mDirectLaunch = directLaunch;
|
|
||||||
|
|
||||||
mRootFolder = new FileData(FOLDER, mStartPath, this);
|
mRootFolder = new FileData(FOLDER, mStartPath, this);
|
||||||
mRootFolder->metadata.set("name", mFullName);
|
mRootFolder->metadata.set("name", mFullName);
|
||||||
|
|
||||||
|
@ -108,12 +106,7 @@ std::string escapePath(const boost::filesystem::path& path)
|
||||||
|
|
||||||
void SystemData::launchGame(Window* window, FileData* game)
|
void SystemData::launchGame(Window* window, FileData* game)
|
||||||
{
|
{
|
||||||
if ( game )
|
LOG(LogInfo) << "Attempting to launch game...";
|
||||||
{
|
|
||||||
LOG(LogInfo) << "Attempting to launch game...";
|
|
||||||
}else{
|
|
||||||
LOG(LogInfo) << "Attempting to launch command...";
|
|
||||||
}
|
|
||||||
|
|
||||||
AudioManager::getInstance()->deinit();
|
AudioManager::getInstance()->deinit();
|
||||||
VolumeControl::getInstance()->deinit();
|
VolumeControl::getInstance()->deinit();
|
||||||
|
@ -121,16 +114,13 @@ void SystemData::launchGame(Window* window, FileData* game)
|
||||||
|
|
||||||
std::string command = mLaunchCommand;
|
std::string command = mLaunchCommand;
|
||||||
|
|
||||||
if ( game )
|
const std::string rom = escapePath(game->getPath());
|
||||||
{
|
const std::string basename = game->getPath().stem().string();
|
||||||
const std::string rom = escapePath(game->getPath());
|
const std::string rom_raw = fs::path(game->getPath()).make_preferred().string();
|
||||||
const std::string basename = game->getPath().stem().string();
|
|
||||||
const std::string rom_raw = fs::path(game->getPath()).make_preferred().string();
|
|
||||||
|
|
||||||
command = strreplace(command, "%ROM%", rom);
|
command = strreplace(command, "%ROM%", rom);
|
||||||
command = strreplace(command, "%BASENAME%", basename);
|
command = strreplace(command, "%BASENAME%", basename);
|
||||||
command = strreplace(command, "%ROM_RAW%", rom_raw);
|
command = strreplace(command, "%ROM_RAW%", rom_raw);
|
||||||
}
|
|
||||||
|
|
||||||
LOG(LogInfo) << " " << command;
|
LOG(LogInfo) << " " << command;
|
||||||
int exitCode = runSystemCommand(command);
|
int exitCode = runSystemCommand(command);
|
||||||
|
@ -145,26 +135,17 @@ void SystemData::launchGame(Window* window, FileData* game)
|
||||||
AudioManager::getInstance()->init();
|
AudioManager::getInstance()->init();
|
||||||
window->normalizeNextUpdate();
|
window->normalizeNextUpdate();
|
||||||
|
|
||||||
if ( game )
|
//update number of times the game has been launched
|
||||||
{
|
int timesPlayed = game->metadata.getInt("playcount") + 1;
|
||||||
//update number of times the game has been launched
|
game->metadata.set("playcount", std::to_string(static_cast<long long>(timesPlayed)));
|
||||||
int timesPlayed = game->metadata.getInt("playcount") + 1;
|
|
||||||
game->metadata.set("playcount", std::to_string(static_cast<long long>(timesPlayed)));
|
|
||||||
|
|
||||||
//update last played time
|
//update last played time
|
||||||
boost::posix_time::ptime time = boost::posix_time::second_clock::universal_time();
|
boost::posix_time::ptime time = boost::posix_time::second_clock::universal_time();
|
||||||
game->metadata.setTime("lastplayed", time);
|
game->metadata.setTime("lastplayed", time);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemData::populateFolder(FileData* folder)
|
void SystemData::populateFolder(FileData* folder)
|
||||||
{
|
{
|
||||||
if (mDirectLaunch)
|
|
||||||
{
|
|
||||||
LOG(LogInfo) << "System " << mName << " is a direct launch item, not building game lists.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fs::path& folderPath = folder->getPath();
|
const fs::path& folderPath = folder->getPath();
|
||||||
if(!fs::is_directory(folderPath))
|
if(!fs::is_directory(folderPath))
|
||||||
{
|
{
|
||||||
|
@ -280,13 +261,11 @@ bool SystemData::loadConfig()
|
||||||
for(pugi::xml_node system = systemList.child("system"); system; system = system.next_sibling("system"))
|
for(pugi::xml_node system = systemList.child("system"); system; system = system.next_sibling("system"))
|
||||||
{
|
{
|
||||||
std::string name, fullname, path, cmd, themeFolder;
|
std::string name, fullname, path, cmd, themeFolder;
|
||||||
bool directLaunch;
|
|
||||||
PlatformIds::PlatformId platformId = PlatformIds::PLATFORM_UNKNOWN;
|
PlatformIds::PlatformId platformId = PlatformIds::PLATFORM_UNKNOWN;
|
||||||
|
|
||||||
name = system.child("name").text().get();
|
name = system.child("name").text().get();
|
||||||
fullname = system.child("fullname").text().get();
|
fullname = system.child("fullname").text().get();
|
||||||
path = system.child("path").text().get();
|
path = system.child("path").text().get();
|
||||||
directLaunch = ( strcmp( system.child("directlaunch").text().get(), "true" ) == 0);
|
|
||||||
|
|
||||||
// convert extensions list from a string into a vector of strings
|
// convert extensions list from a string into a vector of strings
|
||||||
std::vector<std::string> extensions = readList(system.child("extension").text().get());
|
std::vector<std::string> extensions = readList(system.child("extension").text().get());
|
||||||
|
@ -320,29 +299,19 @@ bool SystemData::loadConfig()
|
||||||
// theme folder
|
// theme folder
|
||||||
themeFolder = system.child("theme").text().as_string(name.c_str());
|
themeFolder = system.child("theme").text().as_string(name.c_str());
|
||||||
|
|
||||||
//validate game system
|
//validate
|
||||||
if( (name.empty() || path.empty() || extensions.empty() || cmd.empty() ) && directLaunch == false )
|
if(name.empty() || path.empty() || extensions.empty() || cmd.empty())
|
||||||
{
|
{
|
||||||
LOG(LogError) << "System \"" << name << "\" is missing name, path, extension, or command!";
|
LOG(LogError) << "System \"" << name << "\" is missing name, path, extension, or command!";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//validate direct launch item
|
|
||||||
if( (name.empty() || cmd.empty() ) && directLaunch == true )
|
|
||||||
{
|
|
||||||
LOG(LogError) << "Direct Launch item \"" << name << "\" is missing name or command!";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!directLaunch)
|
//convert path to generic directory seperators
|
||||||
{
|
boost::filesystem::path genericPath(path);
|
||||||
//convert path to generic directory seperators
|
path = genericPath.generic_string();
|
||||||
boost::filesystem::path genericPath(path);
|
|
||||||
path = genericPath.generic_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
SystemData* newSys = new SystemData(name, fullname, path, extensions, cmd, platformIds, themeFolder, directLaunch);
|
SystemData* newSys = new SystemData(name, fullname, path, extensions, cmd, platformIds, themeFolder);
|
||||||
if(newSys->getRootFolder()->getChildren().size() == 0 && !directLaunch)
|
if(newSys->getRootFolder()->getChildren().size() == 0)
|
||||||
{
|
{
|
||||||
LOG(LogWarning) << "System \"" << name << "\" has no games! Ignoring it.";
|
LOG(LogWarning) << "System \"" << name << "\" has no games! Ignoring it.";
|
||||||
delete newSys;
|
delete newSys;
|
||||||
|
@ -392,10 +361,6 @@ void SystemData::writeExampleConfig(const std::string& path)
|
||||||
" <!-- The theme to load from the current theme set. See THEMES.md for more information.\n"
|
" <!-- The theme to load from the current theme set. See THEMES.md for more information.\n"
|
||||||
" This tag is optional. If not set, it will default to the value of <name>. -->\n"
|
" This tag is optional. If not set, it will default to the value of <name>. -->\n"
|
||||||
" <theme>nes</theme>\n"
|
" <theme>nes</theme>\n"
|
||||||
"\n"
|
|
||||||
" <!-- Specifies if the item is a direct launch item and won't show it's game list but instead\n"
|
|
||||||
" will launch the command given. If set to true, every tag except for name and command is optional -->\n"
|
|
||||||
" <directlaunch>false</directlaunch>\n"
|
|
||||||
" </system>\n"
|
" </system>\n"
|
||||||
"</systemList>\n";
|
"</systemList>\n";
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class SystemData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SystemData(const std::string& name, const std::string& fullName, const std::string& startPath, const std::vector<std::string>& extensions,
|
SystemData(const std::string& name, const std::string& fullName, const std::string& startPath, const std::vector<std::string>& extensions,
|
||||||
const std::string& command, const std::vector<PlatformIds::PlatformId>& platformIds, const std::string& themeFolder, bool directLaunch=false);
|
const std::string& command, const std::vector<PlatformIds::PlatformId>& platformIds, const std::string& themeFolder);
|
||||||
~SystemData();
|
~SystemData();
|
||||||
|
|
||||||
inline FileData* getRootFolder() const { return mRootFolder; };
|
inline FileData* getRootFolder() const { return mRootFolder; };
|
||||||
|
@ -21,7 +21,6 @@ public:
|
||||||
inline const std::string& getStartPath() const { return mStartPath; }
|
inline const std::string& getStartPath() const { return mStartPath; }
|
||||||
inline const std::vector<std::string>& getExtensions() const { return mSearchExtensions; }
|
inline const std::vector<std::string>& getExtensions() const { return mSearchExtensions; }
|
||||||
inline const std::string& getThemeFolder() const { return mThemeFolder; }
|
inline const std::string& getThemeFolder() const { return mThemeFolder; }
|
||||||
inline const bool getDirectLaunch() const { return mDirectLaunch; }
|
|
||||||
|
|
||||||
inline const std::vector<PlatformIds::PlatformId>& getPlatformIds() const { return mPlatformIds; }
|
inline const std::vector<PlatformIds::PlatformId>& getPlatformIds() const { return mPlatformIds; }
|
||||||
inline bool hasPlatformId(PlatformIds::PlatformId id) { return std::find(mPlatformIds.begin(), mPlatformIds.end(), id) != mPlatformIds.end(); }
|
inline bool hasPlatformId(PlatformIds::PlatformId id) { return std::find(mPlatformIds.begin(), mPlatformIds.end(), id) != mPlatformIds.end(); }
|
||||||
|
@ -74,7 +73,6 @@ private:
|
||||||
std::vector<PlatformIds::PlatformId> mPlatformIds;
|
std::vector<PlatformIds::PlatformId> mPlatformIds;
|
||||||
std::string mThemeFolder;
|
std::string mThemeFolder;
|
||||||
std::shared_ptr<ThemeData> mTheme;
|
std::shared_ptr<ThemeData> mTheme;
|
||||||
bool mDirectLaunch;
|
|
||||||
|
|
||||||
void populateFolder(FileData* folder);
|
void populateFolder(FileData* folder);
|
||||||
|
|
||||||
|
|
|
@ -119,16 +119,7 @@ bool SystemView::input(InputConfig* config, Input input)
|
||||||
if(config->isMappedTo("a", input))
|
if(config->isMappedTo("a", input))
|
||||||
{
|
{
|
||||||
stopScrolling();
|
stopScrolling();
|
||||||
|
ViewController::get()->goToGameList(getSelected());
|
||||||
SystemData *systemData = getSelected();
|
|
||||||
|
|
||||||
// decide whether to show game list or launch the command directly
|
|
||||||
if ( !systemData->getDirectLaunch() )
|
|
||||||
{
|
|
||||||
ViewController::get()->goToGameList(getSelected());
|
|
||||||
}else{
|
|
||||||
systemData->launchGame( mWindow, nullptr );
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -72,15 +72,7 @@ void ViewController::goToNextGameList()
|
||||||
assert(mState.viewing == GAME_LIST);
|
assert(mState.viewing == GAME_LIST);
|
||||||
SystemData* system = getState().getSystem();
|
SystemData* system = getState().getSystem();
|
||||||
assert(system);
|
assert(system);
|
||||||
|
goToGameList(system->getNext());
|
||||||
// skip systems that don't have a game list, this will always end since it is called
|
|
||||||
// from a system with a game list and the iterator is cyclic
|
|
||||||
do
|
|
||||||
{
|
|
||||||
system = system->getNext();
|
|
||||||
} while ( system->getDirectLaunch() );
|
|
||||||
|
|
||||||
goToGameList(system);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewController::goToPrevGameList()
|
void ViewController::goToPrevGameList()
|
||||||
|
@ -88,15 +80,7 @@ void ViewController::goToPrevGameList()
|
||||||
assert(mState.viewing == GAME_LIST);
|
assert(mState.viewing == GAME_LIST);
|
||||||
SystemData* system = getState().getSystem();
|
SystemData* system = getState().getSystem();
|
||||||
assert(system);
|
assert(system);
|
||||||
|
goToGameList(system->getPrev());
|
||||||
// skip systems that don't have a game list, this will always end since it is called
|
|
||||||
// from a system with a game list and the iterator is cyclic
|
|
||||||
do
|
|
||||||
{
|
|
||||||
system = system->getPrev();
|
|
||||||
} while ( system->getDirectLaunch() );
|
|
||||||
|
|
||||||
goToGameList(system);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewController::goToGameList(SystemData* system)
|
void ViewController::goToGameList(SystemData* system)
|
||||||
|
|
|
@ -38,12 +38,6 @@ void BasicGameListView::onFileChanged(FileData* file, FileChangeType change)
|
||||||
void BasicGameListView::populateList(const std::vector<FileData*>& files)
|
void BasicGameListView::populateList(const std::vector<FileData*>& files)
|
||||||
{
|
{
|
||||||
mList.clear();
|
mList.clear();
|
||||||
|
|
||||||
// file list can be empty if direct launch item
|
|
||||||
if (files.size()==0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mHeaderText.setText(files.at(0)->getSystem()->getFullName());
|
mHeaderText.setText(files.at(0)->getSystem()->getFullName());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue