Merge pull request #1075 from ctrlaltca/fix_1070
Ensure sounds are working at startup; Fix 1070
This commit is contained in:
commit
15dd3471bc
4 changed files with 12 additions and 65 deletions
|
@ -56,7 +56,7 @@ Section "Update configuration" SecUpdateConfig
|
||||||
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$LOCALAPPDATA\Cockatrice\cards.xml"
|
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$LOCALAPPDATA\Cockatrice\cards.xml"
|
||||||
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$LOCALAPPDATA\Cockatrice\decks"
|
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$LOCALAPPDATA\Cockatrice\decks"
|
||||||
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$LOCALAPPDATA\Cockatrice\pics"
|
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$LOCALAPPDATA\Cockatrice\pics"
|
||||||
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$LOCALAPPDATA\Cockatrice\sounds"
|
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$INSTDIR\sounds"
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
Section "Start menu item" SecStartMenu
|
Section "Start menu item" SecStartMenu
|
||||||
|
|
|
@ -164,42 +164,20 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if (!QDir().mkpath(settingsCache->getPicsPath() + "/CUSTOM"))
|
if (!QDir().mkpath(settingsCache->getPicsPath() + "/CUSTOM"))
|
||||||
qDebug() << "Could not create " + settingsCache->getPicsPath().toUtf8() + "/CUSTOM. Will fall back on default card images.";
|
qDebug() << "Could not create " + settingsCache->getPicsPath().toUtf8() + "/CUSTOM. Will fall back on default card images.";
|
||||||
|
|
||||||
|
if(settingsCache->getSoundPath().isEmpty() || !QDir(settingsCache->getSoundPath()).exists())
|
||||||
|
{
|
||||||
|
QDir tmpDir;
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
if(settingsCache->getHandBgPath().isEmpty() &&
|
tmpDir = app.applicationDirPath() + "/../Resources/sounds";
|
||||||
settingsCache->getStackBgPath().isEmpty() &&
|
#elif defined(Q_OS_WIN)
|
||||||
settingsCache->getTableBgPath().isEmpty() &&
|
tmpDir = app.applicationDirPath() + "/sounds";
|
||||||
settingsCache->getPlayerBgPath().isEmpty())
|
#else // linux
|
||||||
{
|
tmpDir = app.applicationDirPath() + "/../share/cockatrice/sounds/";
|
||||||
QString srcDir = QLibraryInfo::location(QLibraryInfo::DataPath);
|
|
||||||
QString destDir = dataDir + "/zonebg";
|
|
||||||
QDir tmpDir(destDir);
|
|
||||||
if(!tmpDir.exists())
|
|
||||||
{
|
|
||||||
// try to install the default images for the current user and set the settigs value
|
|
||||||
settingsCache->copyPath(srcDir + "/zonebg", destDir);
|
|
||||||
|
|
||||||
settingsCache->setHandBgPath(destDir + "/fabric_green.png");
|
|
||||||
settingsCache->setStackBgPath(destDir + "/fabric_red.png");
|
|
||||||
settingsCache->setTableBgPath(destDir + "/fabric_blue.png");
|
|
||||||
settingsCache->setPlayerBgPath(destDir + "/fabric_gray.png");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(settingsCache->getSoundPath().isEmpty())
|
|
||||||
{
|
|
||||||
QString srcDir = QLibraryInfo::location(QLibraryInfo::DataPath);
|
|
||||||
QString destDir = dataDir + "/sounds";
|
|
||||||
QDir tmpDir(destDir);
|
|
||||||
if(!tmpDir.exists())
|
|
||||||
{
|
|
||||||
// try to install the default sounds for the current user and set the settigs value
|
|
||||||
settingsCache->copyPath(srcDir + "/sounds", destDir);
|
|
||||||
|
|
||||||
settingsCache->setSoundPath(destDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
settingsCache->setSoundPath(tmpDir.canonicalPath());
|
||||||
|
}
|
||||||
|
|
||||||
if (!settingsValid() || db->getLoadStatus() != Ok) {
|
if (!settingsValid() || db->getLoadStatus() != Ok) {
|
||||||
qDebug("main(): invalid settings or load status");
|
qDebug("main(): invalid settings or load status");
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QDebug>
|
|
||||||
#include <QDir>
|
|
||||||
|
|
||||||
SettingsCache::SettingsCache()
|
SettingsCache::SettingsCache()
|
||||||
{
|
{
|
||||||
|
@ -381,31 +379,3 @@ void SettingsCache::setPixmapCacheSize(const int _pixmapCacheSize)
|
||||||
settings->setValue("personal/pixmapCacheSize", pixmapCacheSize);
|
settings->setValue("personal/pixmapCacheSize", pixmapCacheSize);
|
||||||
emit pixmapCacheSizeChanged(pixmapCacheSize);
|
emit pixmapCacheSizeChanged(pixmapCacheSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsCache::copyPath(const QString &src, const QString &dst)
|
|
||||||
{
|
|
||||||
// test source && return if inexistent
|
|
||||||
QDir dir(src);
|
|
||||||
if (! dir.exists())
|
|
||||||
return;
|
|
||||||
// test destination && create if inexistent
|
|
||||||
QDir tmpDir(dst);
|
|
||||||
if (!tmpDir.exists())
|
|
||||||
{
|
|
||||||
tmpDir.setPath(QDir::rootPath());
|
|
||||||
if (!tmpDir.mkdir(dst) && !tmpDir.exists()) {
|
|
||||||
// TODO: this is probably not good.
|
|
||||||
qDebug() << "copyPath(): Failed to create dir: " << dst;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
|
||||||
QString dst_path = dst + QDir::separator() + d;
|
|
||||||
dir.mkpath(dst_path);
|
|
||||||
copyPath(src+ QDir::separator() + d, dst_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (QString f, dir.entryList(QDir::Files)) {
|
|
||||||
QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -129,7 +129,6 @@ public:
|
||||||
QString getPicUrlHq() const { return picUrlHq; }
|
QString getPicUrlHq() const { return picUrlHq; }
|
||||||
QString getPicUrlFallback() const { return picUrlFallback; }
|
QString getPicUrlFallback() const { return picUrlFallback; }
|
||||||
QString getPicUrlHqFallback() const { return picUrlHqFallback; }
|
QString getPicUrlHqFallback() const { return picUrlHqFallback; }
|
||||||
void copyPath(const QString &src, const QString &dst);
|
|
||||||
bool getAutoConnect() const { return attemptAutoConnect; }
|
bool getAutoConnect() const { return attemptAutoConnect; }
|
||||||
int getPixmapCacheSize() const { return pixmapCacheSize; }
|
int getPixmapCacheSize() const { return pixmapCacheSize; }
|
||||||
bool getScaleCards() const { return scaleCards; }
|
bool getScaleCards() const { return scaleCards; }
|
||||||
|
|
Loading…
Reference in a new issue