mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55: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
|
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
|
* Game images were sometimes scaled incorrectly
|
||||||
* Non-transparent favorite icons were not rendered correctly
|
* 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
|
* 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
|
* Lots and lots of small bugs and inconsistencies fixed
|
||||||
|
|
|
@ -36,6 +36,7 @@ FileData::FileData(
|
||||||
mEnvData(envData),
|
mEnvData(envData),
|
||||||
mSourceFileData(nullptr),
|
mSourceFileData(nullptr),
|
||||||
mParent(nullptr),
|
mParent(nullptr),
|
||||||
|
mDeletionFlag(false),
|
||||||
// Metadata is REALLY set in the constructor!
|
// Metadata is REALLY set in the constructor!
|
||||||
metadata(type == GAME ? GAME_METADATA : FOLDER_METADATA)
|
metadata(type == GAME ? GAME_METADATA : FOLDER_METADATA)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,16 +39,14 @@ FileType stringToFileType(const char* str);
|
||||||
class FileData
|
class FileData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileData(FileType type,
|
FileData(FileType type, const std::string& path,
|
||||||
const std::string& path,
|
SystemEnvironmentData* envData, SystemData* system);
|
||||||
SystemEnvironmentData* envData,
|
|
||||||
SystemData* system);
|
|
||||||
|
|
||||||
virtual ~FileData();
|
virtual ~FileData();
|
||||||
|
|
||||||
virtual const std::string& getName();
|
virtual const std::string& getName();
|
||||||
virtual const std::string& getSortName();
|
const std::string& getSortName();
|
||||||
virtual const bool getFavorite();
|
const bool getFavorite();
|
||||||
inline FileType getType() const { return mType; }
|
inline FileType getType() const { return mType; }
|
||||||
inline const std::string& getPath() const { return mPath; }
|
inline const std::string& getPath() const { return mPath; }
|
||||||
inline FileData* getParent() const { return mParent; }
|
inline FileData* getParent() const { return mParent; }
|
||||||
|
@ -61,16 +59,18 @@ public:
|
||||||
{ return mFirstLetterIndex; };
|
{ return mFirstLetterIndex; };
|
||||||
static const std::string getROMDirectory();
|
static const std::string getROMDirectory();
|
||||||
static const std::string getMediaDirectory();
|
static const std::string getMediaDirectory();
|
||||||
virtual const std::string getMediafilePath(
|
const std::string getMediafilePath(std::string subdirectory, std::string mediatype) const;
|
||||||
std::string subdirectory, std::string mediatype) const;
|
const std::string getImagePath() const;
|
||||||
virtual const std::string getImagePath() const;
|
const std::string get3DBoxPath() const;
|
||||||
virtual const std::string get3DBoxPath() const;
|
const std::string getCoverPath() const;
|
||||||
virtual const std::string getCoverPath() const;
|
const std::string getMarqueePath() const;
|
||||||
virtual const std::string getMarqueePath() const;
|
const std::string getMiximagePath() const;
|
||||||
virtual const std::string getMiximagePath() const;
|
const std::string getScreenshotPath() const;
|
||||||
virtual const std::string getScreenshotPath() const;
|
const std::string getThumbnailPath() const;
|
||||||
virtual const std::string getThumbnailPath() const;
|
const std::string getVideoPath() const;
|
||||||
virtual const std::string getVideoPath() const;
|
|
||||||
|
bool getDeletionFlag() { return mDeletionFlag; };
|
||||||
|
void setDeletionFlag() { mDeletionFlag = true; };
|
||||||
|
|
||||||
const std::vector<FileData*>& getChildrenListToDisplay();
|
const std::vector<FileData*>& getChildrenListToDisplay();
|
||||||
std::vector<FileData*> getFilesRecursive(unsigned int typeMask,
|
std::vector<FileData*> getFilesRecursive(unsigned int typeMask,
|
||||||
|
@ -135,6 +135,8 @@ private:
|
||||||
std::vector<FileData*> mChildren;
|
std::vector<FileData*> mChildren;
|
||||||
std::vector<FileData*> mFilteredChildren;
|
std::vector<FileData*> mFilteredChildren;
|
||||||
std::vector<std::string> mFirstLetterIndex;
|
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";
|
const std::string FAVORITE_CHAR = "\uF005";
|
||||||
};
|
};
|
||||||
|
|
|
@ -233,8 +233,8 @@ void updateGamelist(SystemData* system)
|
||||||
fit != files.cend(); ++fit) {
|
fit != files.cend(); ++fit) {
|
||||||
const char* tag = ((*fit)->getType() == GAME) ? "game" : "folder";
|
const char* tag = ((*fit)->getType() == GAME) ? "game" : "folder";
|
||||||
|
|
||||||
// Do not touch if it wasn't changed.
|
// Do not touch if it wasn't changed and is not flagged for deletion.
|
||||||
if (!(*fit)->metadata.wasChanged())
|
if (!(*fit)->metadata.wasChanged() && !(*fit)->getDeletionFlag())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Check if the file already exists in the XML file.
|
// Check if the file already exists in the XML file.
|
||||||
|
@ -251,18 +251,22 @@ void updateGamelist(SystemData* system)
|
||||||
Utils::FileSystem::resolveRelativePath(pathNode.text().get(),
|
Utils::FileSystem::resolveRelativePath(pathNode.text().get(),
|
||||||
system->getStartPath(), true));
|
system->getStartPath(), true));
|
||||||
std::string gamePath = Utils::FileSystem::getCanonicalPath((*fit)->getPath());
|
std::string gamePath = Utils::FileSystem::getCanonicalPath((*fit)->getPath());
|
||||||
|
|
||||||
if (nodePath == gamePath) {
|
if (nodePath == gamePath) {
|
||||||
// Found it
|
// Found it
|
||||||
root.remove_child(fileNode);
|
root.remove_child(fileNode);
|
||||||
|
if ((*fit)->getDeletionFlag())
|
||||||
|
++numUpdated;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// It was either removed or never existed to begin with.
|
// Add the game to the file, unless it's flagged for deletion.
|
||||||
// Either way, we can add it now.
|
if (!(*fit)->getDeletionFlag()) {
|
||||||
addFileDataNode(root, *fit, tag, system);
|
addFileDataNode(root, *fit, tag, system);
|
||||||
++numUpdated;
|
++numUpdated;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now write the file.
|
// Now write the file.
|
||||||
if (numUpdated > 0) {
|
if (numUpdated > 0) {
|
||||||
|
|
|
@ -94,6 +94,7 @@ public:
|
||||||
|
|
||||||
FileFilterIndex* getIndex() { return mFilterIndex; };
|
FileFilterIndex* getIndex() { return mFilterIndex; };
|
||||||
void onMetaDataSavePoint();
|
void onMetaDataSavePoint();
|
||||||
|
void writeMetaData();
|
||||||
|
|
||||||
void setupSystemSortType(FileData* mRootFolder);
|
void setupSystemSortType(FileData* mRootFolder);
|
||||||
|
|
||||||
|
@ -110,7 +111,6 @@ private:
|
||||||
bool populateFolder(FileData* folder);
|
bool populateFolder(FileData* folder);
|
||||||
void indexAllGameFilters(const FileData* folder);
|
void indexAllGameFilters(const FileData* folder);
|
||||||
void setIsGameSystemStatus();
|
void setIsGameSystemStatus();
|
||||||
void writeMetaData();
|
|
||||||
|
|
||||||
FileFilterIndex* mFilterIndex;
|
FileFilterIndex* mFilterIndex;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue