mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 01:09:50 +00:00
Changed: Read default ryzom_installer.ini from QRC, see #279
--HG-- branch : develop
This commit is contained in:
parent
ab828febbb
commit
6e8671c55a
4 changed files with 142 additions and 65 deletions
|
@ -7,5 +7,6 @@
|
|||
</qresource>
|
||||
<qresource prefix="/templates">
|
||||
<file>template.desktop</file>
|
||||
<file>ryzom_installer.ini</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
version=1
|
||||
|
||||
[common]
|
||||
installation_directory=
|
||||
|
||||
[product]
|
||||
name=Ryzom
|
||||
publisher="Winch Gate Property Limited"
|
||||
url_about=http://ryzom.com/?lang=$LANG
|
||||
url_help=http://app.ryzom.com/app_forum/index.php?page=topic/view/22047/1&post149889=$LANG#1
|
||||
comments=Science-fantasy MMORPG
|
||||
|
||||
[servers]
|
||||
size=2
|
||||
|
||||
[server_0]
|
||||
id=ryzom_live
|
||||
name=Atys
|
||||
display_url="http://app.ryzom.com/app_releasenotes/index.php?lang=$LANG"
|
||||
data_download_url="http://downloads.sourceforge.net/project/ryzom/ryzom_live_data.7z?r=&ts=$TIMESTAMP"
|
||||
data_download_filename=ryzom_live_data.7z
|
||||
data_compressed_size=1500000000
|
||||
data_uncompressed_size=10000000000
|
||||
client_download_url="http://downloads.sourceforge.net/project/ryzom/ryzom_live_client_$ARCH.zip?r=&ts=$TIMESTAMP"
|
||||
client_download_filename=ryzom_live_client_$ARCH.zip
|
||||
client_filename_windows=ryzom_client_r.exe
|
||||
client_filename_osx=Ryzom.app/Contents/MacOS/Ryzom
|
||||
client_filename_linux=ryzom_client
|
||||
client_filename_old_windows=client_ryzom_rd.exe
|
||||
configuration_filename_windows=ryzom_configuration_qt_r.exe
|
||||
configuration_filename_osx=Ryzom.app/Contents/MacOS/RyzomConfiguration
|
||||
configuration_filename_linux=ryzom_configuration_qt
|
||||
installer_filename_windows=ryzom_installer_qt_r.exe
|
||||
installer_filename_osx=RyzomInstaller.app/Contents/MacOS/RyzomInstaller
|
||||
installer_filename_linux=ryzom_installer_qt
|
||||
comments=
|
||||
|
||||
[server_1]
|
||||
id=ryzom_dev
|
||||
name=Yubo
|
||||
display_url="http://app.ryzom.com/app_releasenotes/index.php?lang=$LANG"
|
||||
data_download_url="http://downloads.sourceforge.net/project/ryzom/ryzom_live_data.7z?r=&ts=$TIMESTAMP"
|
||||
data_download_filename=ryzom_live_data.7z
|
||||
data_compressed_size=1500000000
|
||||
data_uncompressed_size=10000000000
|
||||
client_download_url="http://downloads.sourceforge.net/project/ryzom/ryzom_live_client_$ARCH.zip?r=&ts=$TIMESTAMP"
|
||||
client_download_filename=ryzom_live_client_$ARCH.zip
|
||||
client_filename_windows=ryzom_client_r.exe
|
||||
client_filename_osx=Ryzom.app/Contents/MacOS/Ryzom
|
||||
client_filename_linux=ryzom_client
|
||||
client_filename_old_windows=client_ryzom_rd.exe
|
||||
configuration_filename_windows=ryzom_configuration_qt_r.exe
|
||||
configuration_filename_osx=Ryzom.app/Contents/MacOS/RyzomConfiguration
|
||||
configuration_filename_linux=ryzom_configuration_qt
|
||||
installer_filename_windows=ryzom_installer_qt_r.exe
|
||||
installer_filename_osx=RyzomInstaller.app/Contents/MacOS/RyzomInstaller
|
||||
installer_filename_linux=ryzom_installer_qt
|
||||
comments=Test server
|
||||
|
||||
[profiles]
|
||||
size=0
|
|
@ -142,30 +142,19 @@ void CProfile::updateShortcuts() const
|
|||
|
||||
CConfigFile *CConfigFile::s_instance = NULL;
|
||||
|
||||
CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false), m_shouldUninstallOldClient(true)
|
||||
CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_version(-1),
|
||||
m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false), m_shouldUninstallOldClient(true)
|
||||
{
|
||||
s_instance = this;
|
||||
|
||||
// only keep language ISO 639 code
|
||||
m_language = QLocale::system().name().left(2);
|
||||
|
||||
// it won't be found if run with uninstall flag, but since we already have a local installer.ini...
|
||||
QString configFile = getCurrentDirectory() + "/installer.ini";
|
||||
|
||||
if (!QFile::exists(configFile))
|
||||
{
|
||||
configFile = QApplication::applicationDirPath() + "/installer.ini";
|
||||
|
||||
if (!QFile::exists(configFile))
|
||||
{
|
||||
configFile.clear();
|
||||
}
|
||||
}
|
||||
|
||||
m_defaultConfigPath = configFile;
|
||||
// default config file in included in resources
|
||||
m_defaultConfigPath = ":/templates/ryzom_installer.ini";
|
||||
|
||||
// the config file we'll write
|
||||
m_configPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/installer.ini";
|
||||
m_configPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/ryzom_installer.ini";
|
||||
}
|
||||
|
||||
CConfigFile::~CConfigFile()
|
||||
|
@ -175,13 +164,32 @@ CConfigFile::~CConfigFile()
|
|||
|
||||
bool CConfigFile::load()
|
||||
{
|
||||
return load(m_configPath) || load(m_defaultConfigPath);
|
||||
// load default values
|
||||
load(m_defaultConfigPath);
|
||||
|
||||
return load(m_configPath);
|
||||
}
|
||||
|
||||
bool CConfigFile::load(const QString &filename)
|
||||
{
|
||||
if (!QFile::exists(filename)) return false;
|
||||
|
||||
QSettings settings(filename, QSettings::IniFormat);
|
||||
|
||||
int defaultVersion = m_version;
|
||||
int currentVersion = settings.value("version", 0).toInt();
|
||||
|
||||
bool useDefaultValues = defaultVersion > currentVersion;
|
||||
|
||||
// set default version from default config
|
||||
if (defaultVersion == -1) m_version = currentVersion;
|
||||
|
||||
if (useDefaultValues)
|
||||
{
|
||||
// TODO: make a backup of custom installer.ini
|
||||
}
|
||||
|
||||
// custom choices, always keep them
|
||||
settings.beginGroup("common");
|
||||
m_language = settings.value("language", m_language).toString();
|
||||
m_srcDirectory = settings.value("source_directory").toString();
|
||||
|
@ -190,58 +198,62 @@ bool CConfigFile::load(const QString &filename)
|
|||
m_shouldUninstallOldClient = settings.value("should_uninstall_old_client", true).toBool();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("product");
|
||||
m_productName = settings.value("name").toString();
|
||||
m_productPublisher = settings.value("publisher").toString();
|
||||
m_productAboutUrl = settings.value("url_about").toString();
|
||||
m_productUpdateUrl = settings.value("url_update").toString();
|
||||
m_productHelpUrl = settings.value("url_help").toString();
|
||||
m_productComments = settings.value("comments").toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("servers");
|
||||
int serversCount = settings.value("size").toInt();
|
||||
m_defaultServerIndex = settings.value("default").toInt();
|
||||
settings.endGroup();
|
||||
|
||||
m_servers.resize(serversCount);
|
||||
|
||||
for(int i = 0; i < serversCount; ++i)
|
||||
if (!useDefaultValues)
|
||||
{
|
||||
CServer &server = m_servers[i];
|
||||
|
||||
settings.beginGroup(QString("server_%1").arg(i));
|
||||
|
||||
server.id = settings.value("id").toString();
|
||||
server.name = settings.value("name").toString();
|
||||
server.displayUrl = settings.value("display_url").toString();
|
||||
server.dataDownloadUrl = settings.value("data_download_url").toString();
|
||||
server.dataDownloadFilename = settings.value("data_download_filename").toString();
|
||||
server.dataCompressedSize = settings.value("data_compressed_size").toULongLong();
|
||||
server.dataUncompressedSize = settings.value("data_uncompressed_size").toULongLong();
|
||||
server.clientDownloadUrl = settings.value("client_download_url").toString();
|
||||
server.clientDownloadFilename = settings.value("client_download_filename").toString();
|
||||
#if defined(Q_OS_WIN)
|
||||
server.clientFilename = settings.value("client_filename_windows").toString();
|
||||
server.clientFilenameOld = settings.value("client_filename_old_windows").toString();
|
||||
server.configurationFilename = settings.value("configuration_filename_windows").toString();
|
||||
server.installerFilename = settings.value("installer_filename_windows").toString();
|
||||
#elif defined(Q_OS_MAC)
|
||||
server.clientFilename = settings.value("client_filename_osx").toString();
|
||||
server.clientFilenameOld = settings.value("client_filename_old_osx").toString();
|
||||
server.configurationFilename = settings.value("configuration_filename_osx").toString();
|
||||
server.installerFilename = settings.value("installer_filename_osx").toString();
|
||||
#else
|
||||
server.clientFilename = settings.value("client_filename_linux").toString();
|
||||
server.clientFilenameOld = settings.value("client_filename_old_linux").toString();
|
||||
server.configurationFilename = settings.value("configuration_filename_linux").toString();
|
||||
server.installerFilename = settings.value("installer_filename_linux").toString();
|
||||
#endif
|
||||
server.comments = settings.value("comments").toString();
|
||||
|
||||
settings.beginGroup("product");
|
||||
m_productName = settings.value("name").toString();
|
||||
m_productPublisher = settings.value("publisher").toString();
|
||||
m_productAboutUrl = settings.value("url_about").toString();
|
||||
m_productUpdateUrl = settings.value("url_update").toString();
|
||||
m_productHelpUrl = settings.value("url_help").toString();
|
||||
m_productComments = settings.value("comments").toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("servers");
|
||||
int serversCount = settings.value("size").toInt();
|
||||
m_defaultServerIndex = settings.value("default").toInt();
|
||||
settings.endGroup();
|
||||
|
||||
m_servers.resize(serversCount);
|
||||
|
||||
for (int i = 0; i < serversCount; ++i)
|
||||
{
|
||||
CServer &server = m_servers[i];
|
||||
|
||||
settings.beginGroup(QString("server_%1").arg(i));
|
||||
|
||||
server.id = settings.value("id").toString();
|
||||
server.name = settings.value("name").toString();
|
||||
server.displayUrl = settings.value("display_url").toString();
|
||||
server.dataDownloadUrl = settings.value("data_download_url").toString();
|
||||
server.dataDownloadFilename = settings.value("data_download_filename").toString();
|
||||
server.dataCompressedSize = settings.value("data_compressed_size").toULongLong();
|
||||
server.dataUncompressedSize = settings.value("data_uncompressed_size").toULongLong();
|
||||
server.clientDownloadUrl = settings.value("client_download_url").toString();
|
||||
server.clientDownloadFilename = settings.value("client_download_filename").toString();
|
||||
#if defined(Q_OS_WIN)
|
||||
server.clientFilename = settings.value("client_filename_windows").toString();
|
||||
server.clientFilenameOld = settings.value("client_filename_old_windows").toString();
|
||||
server.configurationFilename = settings.value("configuration_filename_windows").toString();
|
||||
server.installerFilename = settings.value("installer_filename_windows").toString();
|
||||
#elif defined(Q_OS_MAC)
|
||||
server.clientFilename = settings.value("client_filename_osx").toString();
|
||||
server.clientFilenameOld = settings.value("client_filename_old_osx").toString();
|
||||
server.configurationFilename = settings.value("configuration_filename_osx").toString();
|
||||
server.installerFilename = settings.value("installer_filename_osx").toString();
|
||||
#else
|
||||
server.clientFilename = settings.value("client_filename_linux").toString();
|
||||
server.clientFilenameOld = settings.value("client_filename_old_linux").toString();
|
||||
server.configurationFilename = settings.value("configuration_filename_linux").toString();
|
||||
server.installerFilename = settings.value("installer_filename_linux").toString();
|
||||
#endif
|
||||
server.comments = settings.value("comments").toString();
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
// custom choices, always keep them
|
||||
settings.beginGroup("profiles");
|
||||
int profilesCounts = settings.value("size").toInt();
|
||||
m_defaultProfileIndex = settings.value("default").toInt();
|
||||
|
@ -274,6 +286,8 @@ bool CConfigFile::save() const
|
|||
{
|
||||
QSettings settings(m_configPath, QSettings::IniFormat);
|
||||
|
||||
settings.setValue("version", m_version);
|
||||
|
||||
settings.beginGroup("common");
|
||||
settings.setValue("language", m_language);
|
||||
settings.setValue("source_directory", m_srcDirectory);
|
||||
|
|
|
@ -194,6 +194,7 @@ public:
|
|||
QString getProductComments() const;
|
||||
|
||||
private:
|
||||
int m_version;
|
||||
int m_defaultServerIndex;
|
||||
int m_defaultProfileIndex;
|
||||
|
||||
|
|
Loading…
Reference in a new issue