mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 22:15:32 +00:00
Eliminated game & addon keys from profile configuration
This commit is contained in:
parent
dace904490
commit
ed913936f8
5 changed files with 59 additions and 45 deletions
|
@ -42,44 +42,19 @@ void Launcher::DataFilesPage::loadSettings()
|
||||||
|
|
||||||
QString profileName = ui.profilesComboBox->currentText();
|
QString profileName = ui.profilesComboBox->currentText();
|
||||||
|
|
||||||
QStringList files = mLauncherSettings.values(QString("Profiles/") + profileName + QString("/game"), Qt::MatchExactly);
|
QStringList files = mLauncherSettings.values(QString("Profiles/") + profileName, Qt::MatchExactly);
|
||||||
QStringList addons = mLauncherSettings.values(QString("Profiles/") + profileName + QString("/addon"), Qt::MatchExactly);
|
|
||||||
|
|
||||||
mSelector->clearCheckStates();
|
QStringList filepaths;
|
||||||
|
|
||||||
QString gameFile ("");
|
foreach (const QString &file, files)
|
||||||
|
|
||||||
if (files.size()>0)
|
|
||||||
{
|
{
|
||||||
gameFile = pathIterator.findFirstPath (files.at(0));
|
QString filepath = pathIterator.findFirstPath (file);
|
||||||
|
|
||||||
if (!gameFile.isEmpty())
|
if (!filepath.isEmpty())
|
||||||
mSelector->setGameFile (gameFile);
|
filepaths << filepath;
|
||||||
/* else
|
|
||||||
{
|
|
||||||
//throw gamefile error here.
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList missingFiles;
|
mSelector->setProfileContent (filepaths);
|
||||||
QStringList foundFiles;
|
|
||||||
|
|
||||||
foreach (const QString &addon, addons)
|
|
||||||
{
|
|
||||||
QString filePath = pathIterator.findFirstPath (addon);
|
|
||||||
|
|
||||||
if (filePath.isEmpty())
|
|
||||||
missingFiles << addon;
|
|
||||||
else
|
|
||||||
foundFiles << filePath;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
if (missingFiles.size() > 0)
|
|
||||||
{
|
|
||||||
//throw addons error here.
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
mSelector->setCheckStates (foundFiles);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::DataFilesPage::saveSettings(const QString &profile)
|
void Launcher::DataFilesPage::saveSettings(const QString &profile)
|
||||||
|
@ -94,8 +69,7 @@ void Launcher::DataFilesPage::saveSettings(const QString &profile)
|
||||||
|
|
||||||
removeProfile (profileName);
|
removeProfile (profileName);
|
||||||
|
|
||||||
mGameSettings.remove(QString("game"));
|
mGameSettings.remove(QString("content"));
|
||||||
mGameSettings.remove(QString("addon"));
|
|
||||||
|
|
||||||
//set the value of the current profile (not necessarily the profile being saved!)
|
//set the value of the current profile (not necessarily the profile being saved!)
|
||||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), ui.profilesComboBox->currentText());
|
mLauncherSettings.setValue(QString("Profiles/currentprofile"), ui.profilesComboBox->currentText());
|
||||||
|
@ -103,10 +77,10 @@ void Launcher::DataFilesPage::saveSettings(const QString &profile)
|
||||||
foreach(const ContentSelectorModel::EsmFile *item, items) {
|
foreach(const ContentSelectorModel::EsmFile *item, items) {
|
||||||
|
|
||||||
if (item->gameFiles().size() == 0) {
|
if (item->gameFiles().size() == 0) {
|
||||||
mLauncherSettings.setMultiValue(QString("Profiles/") + profileName + QString("/game"), item->fileName());
|
mLauncherSettings.setMultiValue(QString("Profiles/") + profileName, item->fileName());
|
||||||
mGameSettings.setMultiValue(QString("content"), item->fileName());
|
mGameSettings.setMultiValue(QString("content"), item->fileName());
|
||||||
} else {
|
} else {
|
||||||
mLauncherSettings.setMultiValue(QString("Profiles/") + profileName + QString("/addon"), item->fileName());
|
mLauncherSettings.setMultiValue(QString("Profiles/") + profileName, item->fileName());
|
||||||
mGameSettings.setMultiValue(QString("content"), item->fileName());
|
mGameSettings.setMultiValue(QString("content"), item->fileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,13 +199,26 @@ void Launcher::DataFilesPage::setupDataFiles()
|
||||||
if (!mDataLocal.isEmpty())
|
if (!mDataLocal.isEmpty())
|
||||||
mSelector->addFiles(mDataLocal);
|
mSelector->addFiles(mDataLocal);
|
||||||
|
|
||||||
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
|
QStringList profiles;
|
||||||
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
QString currentProfile = mLauncherSettings.getSettings().value("Profiles/currentprofile");
|
||||||
|
|
||||||
|
foreach (QString key, mLauncherSettings.getSettings().keys())
|
||||||
|
{
|
||||||
|
if (key.contains("Profiles/"))
|
||||||
|
{
|
||||||
|
QString profile = key.mid (9);
|
||||||
|
if (profile != "currentprofile")
|
||||||
|
{
|
||||||
|
if (!profiles.contains(profile))
|
||||||
|
profiles << profile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (const QString &item, profiles)
|
foreach (const QString &item, profiles)
|
||||||
addProfile (item, false);
|
addProfile (item, false);
|
||||||
|
|
||||||
setProfile (ui.profilesComboBox->findText(profile), false);
|
setProfile (ui.profilesComboBox->findText(currentProfile), false);
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Workaround for problems with whitespaces in paths in older versions of Boost library
|
* Workaround for problems with whitespaces in paths in older versions of Boost library
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
Launcher::LauncherSettings::LauncherSettings()
|
Launcher::LauncherSettings::LauncherSettings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -44,12 +46,9 @@ QStringList Launcher::LauncherSettings::subKeys(const QString &key)
|
||||||
QStringList result;
|
QStringList result;
|
||||||
|
|
||||||
foreach (const QString ¤tKey, keys) {
|
foreach (const QString ¤tKey, keys) {
|
||||||
|
|
||||||
if (keyRe.indexIn(currentKey) != -1) {
|
if (keyRe.indexIn(currentKey) != -1) {
|
||||||
|
|
||||||
QString prefixedKey = keyRe.cap(1);
|
QString prefixedKey = keyRe.cap(1);
|
||||||
if(prefixedKey.startsWith(key)) {
|
if(prefixedKey.startsWith(key)) {
|
||||||
|
|
||||||
QString subKey = prefixedKey.remove(key);
|
QString subKey = prefixedKey.remove(key);
|
||||||
if (!subKey.isEmpty())
|
if (!subKey.isEmpty())
|
||||||
result.append(subKey);
|
result.append(subKey);
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) :
|
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +61,35 @@ void ContentSelectorView::ContentSelector::buildAddonView()
|
||||||
connect(ui.addonView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotAddonTableItemClicked(const QModelIndex &)));
|
connect(ui.addonView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotAddonTableItemClicked(const QModelIndex &)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContentSelectorView::ContentSelector::setProfileContent(const QStringList &fileList)
|
||||||
|
{
|
||||||
|
clearCheckStates();
|
||||||
|
bool foundGamefile = false;
|
||||||
|
|
||||||
|
foreach (const QString &filepath, fileList)
|
||||||
|
{
|
||||||
|
if (!foundGamefile)
|
||||||
|
{
|
||||||
|
const ContentSelectorModel::EsmFile *file = mContentModel->item(filepath);
|
||||||
|
|
||||||
|
foundGamefile = (file->isGameFile());
|
||||||
|
|
||||||
|
if (foundGamefile)
|
||||||
|
{
|
||||||
|
setGameFile (filepath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if (!foundGameFile)
|
||||||
|
{
|
||||||
|
//throw gamefile error here.
|
||||||
|
}*/
|
||||||
|
|
||||||
|
setCheckStates (fileList);
|
||||||
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::setGameFile(const QString &filename)
|
void ContentSelectorView::ContentSelector::setGameFile(const QString &filename)
|
||||||
{
|
{
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
@ -92,7 +119,6 @@ void ContentSelectorView::ContentSelector::setCheckStates(const QStringList &lis
|
||||||
{
|
{
|
||||||
if (list.isEmpty())
|
if (list.isEmpty())
|
||||||
{
|
{
|
||||||
qDebug() << "refreshing model";
|
|
||||||
slotCurrentGameFileIndexChanged (ui.gameFileView->currentIndex());
|
slotCurrentGameFileIndexChanged (ui.gameFileView->currentIndex());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace ContentSelectorView
|
||||||
QString currentFile() const;
|
QString currentFile() const;
|
||||||
|
|
||||||
void addFiles(const QString &path);
|
void addFiles(const QString &path);
|
||||||
|
void setProfileContent (const QStringList &fileList);
|
||||||
|
|
||||||
void clearCheckStates();
|
void clearCheckStates();
|
||||||
void setCheckStates (const QStringList &list);
|
void setCheckStates (const QStringList &list);
|
||||||
|
|
Loading…
Reference in a new issue