From f7635f9e4936ac96e715a2ef447a6a0ce087e71b Mon Sep 17 00:00:00 2001 From: Daenyth Date: Mon, 23 Jun 2014 21:12:25 -0400 Subject: [PATCH 1/5] Don't recursive remove program files/cockatrice. This should prevent deleting old deck files --- nsis/cockatrice.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nsis/cockatrice.nsi b/nsis/cockatrice.nsi index 33cc496b..2cce2f5e 100644 --- a/nsis/cockatrice.nsi +++ b/nsis/cockatrice.nsi @@ -115,7 +115,7 @@ SetShellVarContext all Delete "$INSTDIR\QtMultimedia4.dll" RMDir "$INSTDIR" - RMDir /r "$SMPROGRAMS\Cockatrice" + RMDir "$SMPROGRAMS\Cockatrice" DeleteRegKey HKCU "Software\Cockatrice" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" From f1e6aebabae4669652b6c5f03b7305b1be2c6306 Mon Sep 17 00:00:00 2001 From: Daenyth Date: Mon, 23 Jun 2014 21:21:08 -0400 Subject: [PATCH 2/5] Set cockatrice path settings to use appdata instead of instdir Putting user stuff in program files is bad --- nsis/cockatrice.nsi | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nsis/cockatrice.nsi b/nsis/cockatrice.nsi index 2cce2f5e..ede4c05d 100644 --- a/nsis/cockatrice.nsi +++ b/nsis/cockatrice.nsi @@ -1,7 +1,7 @@ !include "MUI2.nsh" !include "FileFunc.nsh" -!define /date TIMESTAMP "%Y%m%d" +!define /date TIMESTAMP "%Y%m%d" !searchparse /file ../build/cockatrice/version_string.cpp '= "' VERSION '";' Name "Cockatrice" @@ -52,7 +52,7 @@ Section "Application" SecApplication SetOutPath "$INSTDIR\zonebg" File /r ..\zonebg\*.* - + SetOutPath "$INSTDIR\plugins" SetOutPath "$INSTDIR\plugins\codecs" File "${QTDIR}\plugins\codecs\qcncodecs4.dll" @@ -67,7 +67,7 @@ Section "Application" SecApplication SetOutPath "$INSTDIR\sounds" File /r ..\sounds\*.* - + SetOutPath "$INSTDIR\translations" File /r ..\build\cockatrice\*.qm @@ -83,10 +83,10 @@ Section "Application" SecApplication SectionEnd Section "Update configuration" SecUpdateConfig - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$INSTDIR\cards.xml" - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$INSTDIR\decks" - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$INSTDIR\pics" - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$INSTDIR\sounds" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$APPDATA\cards.xml" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$APPDATA\decks" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$APPDATA\pics" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$APPDATA\sounds" SectionEnd Section "Start menu item" SecStartMenu From fc599972f3449f3b4ac98ac93a3a44dd96be1680 Mon Sep 17 00:00:00 2001 From: Daenyth Date: Mon, 23 Jun 2014 21:25:09 -0400 Subject: [PATCH 3/5] Write to APPDATA/Cockatrice, not APPDATA --- nsis/cockatrice.nsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nsis/cockatrice.nsi b/nsis/cockatrice.nsi index ede4c05d..88e7bdab 100644 --- a/nsis/cockatrice.nsi +++ b/nsis/cockatrice.nsi @@ -83,10 +83,10 @@ Section "Application" SecApplication SectionEnd Section "Update configuration" SecUpdateConfig - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$APPDATA\cards.xml" - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$APPDATA\decks" - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$APPDATA\pics" - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$APPDATA\sounds" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$APPDATA\Cockatrice\cards.xml" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$APPDATA\Cockatrice\decks" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$APPDATA\Cockatrice\pics" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$APPDATA\Cockatrice\sounds" SectionEnd Section "Start menu item" SecStartMenu From df659e58fe4fdf5f6e815f49a60a1b96458a5418 Mon Sep 17 00:00:00 2001 From: Daenyth Date: Tue, 24 Jun 2014 20:49:03 -0400 Subject: [PATCH 4/5] Mask set shortcodes for windows illegal filenames Ref #122 --- cockatrice/src/carddatabase.cpp | 24 ++++++++++++++++++------ cockatrice/src/carddatabase.h | 3 ++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/cockatrice/src/carddatabase.cpp b/cockatrice/src/carddatabase.cpp index 2e5c0ec7..5a942b0f 100644 --- a/cockatrice/src/carddatabase.cpp +++ b/cockatrice/src/carddatabase.cpp @@ -16,12 +16,6 @@ const int CardDatabase::versionNeeded = 3; -CardSet::CardSet(const QString &_shortName, const QString &_longName) - : shortName(_shortName), longName(_longName) -{ - updateSortKey(); -} - QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set) { xml.writeStartElement("set"); @@ -32,6 +26,24 @@ QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set) return xml; } +CardSet::CardSet(const QString &_shortName, const QString &_longName) + : shortName(_shortName), longName(_longName) +{ + updateSortKey(); +} + +QString CardSet::getCorrectedShortName() const +{ + // Because windows is horrible. + QSet invalidFileNames; + invalidFileNames << "CON" << "PRN" << "AUX" << "NUL" << "COM1" << "COM2" << + "COM3" << "COM4" << "COM5" << "COM6" << "COM7" << "COM8" << "COM9" << + "LPT1" << "LPT2" << "LPT3" << "LPT4" << "LPT5" << "LPT6" << "LPT7" << + "LPT8" << "LPT9"; + + return invalidFileNames.contains(shortName) ? shortName + "_" : shortName; +} + void CardSet::setSortKey(unsigned int _sortKey) { sortKey = _sortKey; diff --git a/cockatrice/src/carddatabase.h b/cockatrice/src/carddatabase.h index 5e83080c..70d77bca 100644 --- a/cockatrice/src/carddatabase.h +++ b/cockatrice/src/carddatabase.h @@ -26,6 +26,7 @@ private: unsigned int sortKey; public: CardSet(const QString &_shortName = QString(), const QString &_longName = QString()); + QString getCorrectedShortName() const; QString getShortName() const { return shortName; } QString getLongName() const { return longName; } int getSortKey() const { return sortKey; } @@ -51,7 +52,7 @@ public: PictureToLoad(CardInfo *_card = 0, bool _stripped = false, bool _hq = true); CardInfo *getCard() const { return card; } bool getStripped() const { return stripped; } - QString getSetName() const { return sortedSets[setIndex]->getShortName(); } + QString getSetName() const { return sortedSets[setIndex]->getCorrectedShortName(); } bool nextSet(); bool getHq() const { return hq; } void setHq(bool _hq) { hq = _hq; } From fcc62a1e1fdbc0612fcb4272df2fd7193be7ff1e Mon Sep 17 00:00:00 2001 From: Gavin Bisesi Date: Wed, 25 Jun 2014 17:09:17 -0400 Subject: [PATCH 5/5] Use defined(Q_OS_WIN) in #elif to satisfy MSVC It's always windows. --- cockatrice/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index 370c1b1a..c618c1ae 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) if (translationPath.isEmpty()) { #ifdef Q_OS_MAC translationPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); -#elif Q_OS_WIN +#elif defined(Q_OS_WIN) translationPath = app.applicationDirPath() + "/translations"; #endif }