mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Deletion of a game now removes its media files and its entry in the gamelist.xml file.
This commit is contained in:
parent
6199f7371d
commit
40be69cd64
3
NEWS.md
3
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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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<FileData*>& getChildrenListToDisplay();
|
||||
std::vector<FileData*> getFilesRecursive(unsigned int typeMask,
|
||||
|
@ -135,6 +135,8 @@ private:
|
|||
std::vector<FileData*> mChildren;
|
||||
std::vector<FileData*> mFilteredChildren;
|
||||
std::vector<std::string> mFirstLetterIndex;
|
||||
// Used for flagging a game for deletion from its gamelist.xml file.
|
||||
bool mDeletionFlag;
|
||||
|
||||
const std::string FAVORITE_CHAR = "\uF005";
|
||||
};
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue