diff --git a/NEWS.md b/NEWS.md index dcba97dce..e3a374659 100644 --- a/NEWS.md +++ b/NEWS.md @@ -39,6 +39,7 @@ v1.0.0 Note: The editor will still ask for save confirmations after automatically rounding fractional game ratings to half-star values * Game images were sometimes scaled incorrectly * Non-transparent favorite icons were not rendered correctly -* Restart and power-off menu entries not working (at least not on my desktop OS) +* Restart and power-off menu entries not working * Toggling the screensaver didn't work as expected +* Deleting a game did not delete the game media files or its entry in the gamelist.xml file * Lots and lots of small bugs and inconsistencies fixed diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 1e15abfa7..8da4ad139 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -36,6 +36,7 @@ FileData::FileData( mEnvData(envData), mSourceFileData(nullptr), mParent(nullptr), + mDeletionFlag(false), // Metadata is REALLY set in the constructor! metadata(type == GAME ? GAME_METADATA : FOLDER_METADATA) { diff --git a/es-app/src/FileData.h b/es-app/src/FileData.h index be649aa73..2297c0ce4 100644 --- a/es-app/src/FileData.h +++ b/es-app/src/FileData.h @@ -39,16 +39,14 @@ FileType stringToFileType(const char* str); class FileData { public: - FileData(FileType type, - const std::string& path, - SystemEnvironmentData* envData, - SystemData* system); + FileData(FileType type, const std::string& path, + SystemEnvironmentData* envData, SystemData* system); virtual ~FileData(); virtual const std::string& getName(); - virtual const std::string& getSortName(); - virtual const bool getFavorite(); + const std::string& getSortName(); + const bool getFavorite(); inline FileType getType() const { return mType; } inline const std::string& getPath() const { return mPath; } inline FileData* getParent() const { return mParent; } @@ -61,16 +59,18 @@ public: { return mFirstLetterIndex; }; static const std::string getROMDirectory(); static const std::string getMediaDirectory(); - virtual const std::string getMediafilePath( - std::string subdirectory, std::string mediatype) const; - virtual const std::string getImagePath() const; - virtual const std::string get3DBoxPath() const; - virtual const std::string getCoverPath() const; - virtual const std::string getMarqueePath() const; - virtual const std::string getMiximagePath() const; - virtual const std::string getScreenshotPath() const; - virtual const std::string getThumbnailPath() const; - virtual const std::string getVideoPath() const; + const std::string getMediafilePath(std::string subdirectory, std::string mediatype) const; + const std::string getImagePath() const; + const std::string get3DBoxPath() const; + const std::string getCoverPath() const; + const std::string getMarqueePath() const; + const std::string getMiximagePath() const; + const std::string getScreenshotPath() const; + const std::string getThumbnailPath() const; + const std::string getVideoPath() const; + + bool getDeletionFlag() { return mDeletionFlag; }; + void setDeletionFlag() { mDeletionFlag = true; }; const std::vector& getChildrenListToDisplay(); std::vector getFilesRecursive(unsigned int typeMask, @@ -135,6 +135,8 @@ private: std::vector mChildren; std::vector mFilteredChildren; std::vector mFirstLetterIndex; + // Used for flagging a game for deletion from its gamelist.xml file. + bool mDeletionFlag; const std::string FAVORITE_CHAR = "\uF005"; }; diff --git a/es-app/src/Gamelist.cpp b/es-app/src/Gamelist.cpp index c4b026c1d..9d561d114 100644 --- a/es-app/src/Gamelist.cpp +++ b/es-app/src/Gamelist.cpp @@ -233,8 +233,8 @@ void updateGamelist(SystemData* system) fit != files.cend(); ++fit) { const char* tag = ((*fit)->getType() == GAME) ? "game" : "folder"; - // Do not touch if it wasn't changed. - if (!(*fit)->metadata.wasChanged()) + // Do not touch if it wasn't changed and is not flagged for deletion. + if (!(*fit)->metadata.wasChanged() && !(*fit)->getDeletionFlag()) continue; // Check if the file already exists in the XML file. @@ -248,20 +248,24 @@ void updateGamelist(SystemData* system) } std::string nodePath =Utils::FileSystem::getCanonicalPath( - Utils::FileSystem::resolveRelativePath(pathNode.text().get(), - system->getStartPath(), true)); + Utils::FileSystem::resolveRelativePath(pathNode.text().get(), + system->getStartPath(), true)); std::string gamePath = Utils::FileSystem::getCanonicalPath((*fit)->getPath()); + if (nodePath == gamePath) { // Found it root.remove_child(fileNode); + if ((*fit)->getDeletionFlag()) + ++numUpdated; break; } } - // It was either removed or never existed to begin with. - // Either way, we can add it now. - addFileDataNode(root, *fit, tag, system); - ++numUpdated; + // Add the game to the file, unless it's flagged for deletion. + if (!(*fit)->getDeletionFlag()) { + addFileDataNode(root, *fit, tag, system); + ++numUpdated; + } } // Now write the file. diff --git a/es-app/src/SystemData.h b/es-app/src/SystemData.h index e2f6de484..6251adf9f 100644 --- a/es-app/src/SystemData.h +++ b/es-app/src/SystemData.h @@ -94,6 +94,7 @@ public: FileFilterIndex* getIndex() { return mFilterIndex; }; void onMetaDataSavePoint(); + void writeMetaData(); void setupSystemSortType(FileData* mRootFolder); @@ -110,7 +111,6 @@ private: bool populateFolder(FileData* folder); void indexAllGameFilters(const FileData* folder); void setIsGameSystemStatus(); - void writeMetaData(); FileFilterIndex* mFilterIndex;