mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-05 13:03:55 -07:00
[DeckLoader] Don't modify text deck files on load (#6888)
* [DeckLoader] Don't modify text deck files on load * formatter
This commit is contained in:
parent
7507103bb2
commit
67f6ab66f0
1 changed files with 8 additions and 11 deletions
|
|
@ -181,6 +181,11 @@ bool DeckLoader::saveToNewFile(LoadedDeck &deck, const QString &fileName, DeckFi
|
||||||
*/
|
*/
|
||||||
bool DeckLoader::updateLastLoadedTimestamp(LoadedDeck &deck)
|
bool DeckLoader::updateLastLoadedTimestamp(LoadedDeck &deck)
|
||||||
{
|
{
|
||||||
|
// text format doesn't support lastLoadedTimestamp, so there's no point in proceeding
|
||||||
|
if (deck.lastLoadInfo.fileFormat != DeckFileFormat::Cockatrice) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QString fileName = deck.lastLoadInfo.fileName;
|
QString fileName = deck.lastLoadInfo.fileName;
|
||||||
|
|
||||||
QFileInfo fileInfo(fileName);
|
QFileInfo fileInfo(fileName);
|
||||||
|
|
@ -201,15 +206,8 @@ bool DeckLoader::updateLastLoadedTimestamp(LoadedDeck &deck)
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
// Perform file modifications
|
// Perform file modifications
|
||||||
switch (deck.lastLoadInfo.fileFormat) {
|
deck.deckList.setLastLoadedTimestamp(QDateTime::currentDateTime().toString());
|
||||||
case DeckFileFormat::PlainText:
|
result = deck.deckList.saveToFile_Native(&file);
|
||||||
result = deck.deckList.saveToFile_Plain(&file);
|
|
||||||
break;
|
|
||||||
case DeckFileFormat::Cockatrice:
|
|
||||||
deck.deckList.setLastLoadedTimestamp(QDateTime::currentDateTime().toString());
|
|
||||||
result = deck.deckList.saveToFile_Native(&file);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
file.close(); // Close the file to ensure changes are flushed
|
file.close(); // Close the file to ensure changes are flushed
|
||||||
|
|
||||||
|
|
@ -429,8 +427,7 @@ void DeckLoader::saveToStream_DeckZoneCards(QTextStream &out,
|
||||||
}
|
}
|
||||||
if (addSetNameAndNumber) {
|
if (addSetNameAndNumber) {
|
||||||
if (!card->getCardSetShortName().isNull() && !card->getCardSetShortName().isEmpty()) {
|
if (!card->getCardSetShortName().isNull() && !card->getCardSetShortName().isEmpty()) {
|
||||||
out << " "
|
out << " " << "(" << card->getCardSetShortName() << ")";
|
||||||
<< "(" << card->getCardSetShortName() << ")";
|
|
||||||
}
|
}
|
||||||
if (!card->getCardCollectorNumber().isNull()) {
|
if (!card->getCardCollectorNumber().isNull()) {
|
||||||
out << " " << card->getCardCollectorNumber();
|
out << " " << card->getCardCollectorNumber();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue