mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 21:45: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();
|
||||
|
||||
QStringList files = mLauncherSettings.values(QString("Profiles/") + profileName + QString("/game"), Qt::MatchExactly);
|
||||
QStringList addons = mLauncherSettings.values(QString("Profiles/") + profileName + QString("/addon"), Qt::MatchExactly);
|
||||
QStringList files = mLauncherSettings.values(QString("Profiles/") + profileName, Qt::MatchExactly);
|
||||
|
||||
mSelector->clearCheckStates();
|
||||
QStringList filepaths;
|
||||
|
||||
QString gameFile ("");
|
||||
|
||||
if (files.size()>0)
|
||||
foreach (const QString &file, files)
|
||||
{
|
||||
gameFile = pathIterator.findFirstPath (files.at(0));
|
||||
QString filepath = pathIterator.findFirstPath (file);
|
||||
|
||||
if (!gameFile.isEmpty())
|
||||
mSelector->setGameFile (gameFile);
|
||||
/* else
|
||||
{
|
||||
//throw gamefile error here.
|
||||
}*/
|
||||
if (!filepath.isEmpty())
|
||||
filepaths << filepath;
|
||||
}
|
||||
|
||||
QStringList missingFiles;
|
||||
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);
|
||||
mSelector->setProfileContent (filepaths);
|
||||
}
|
||||
|
||||
void Launcher::DataFilesPage::saveSettings(const QString &profile)
|
||||
|
@ -94,8 +69,7 @@ void Launcher::DataFilesPage::saveSettings(const QString &profile)
|
|||
|
||||
removeProfile (profileName);
|
||||
|
||||
mGameSettings.remove(QString("game"));
|
||||
mGameSettings.remove(QString("addon"));
|
||||
mGameSettings.remove(QString("content"));
|
||||
|
||||
//set the value of the current profile (not necessarily the profile being saved!)
|
||||
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) {
|
||||
|
||||
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());
|
||||
} else {
|
||||
mLauncherSettings.setMultiValue(QString("Profiles/") + profileName + QString("/addon"), item->fileName());
|
||||
mLauncherSettings.setMultiValue(QString("Profiles/") + profileName, item->fileName());
|
||||
mGameSettings.setMultiValue(QString("content"), item->fileName());
|
||||
}
|
||||
}
|
||||
|
@ -225,13 +199,26 @@ void Launcher::DataFilesPage::setupDataFiles()
|
|||
if (!mDataLocal.isEmpty())
|
||||
mSelector->addFiles(mDataLocal);
|
||||
|
||||
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
|
||||
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
||||
QStringList profiles;
|
||||
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)
|
||||
addProfile (item, false);
|
||||
|
||||
setProfile (ui.profilesComboBox->findText(profile), false);
|
||||
setProfile (ui.profilesComboBox->findText(currentProfile), false);
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <components/files/configurationmanager.hpp>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
|
||||
/**
|
||||
* Workaround for problems with whitespaces in paths in older versions of Boost library
|
||||
*/
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include <QRegExp>
|
||||
#include <QMap>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
Launcher::LauncherSettings::LauncherSettings()
|
||||
{
|
||||
}
|
||||
|
@ -44,12 +46,9 @@ QStringList Launcher::LauncherSettings::subKeys(const QString &key)
|
|||
QStringList result;
|
||||
|
||||
foreach (const QString ¤tKey, keys) {
|
||||
|
||||
if (keyRe.indexIn(currentKey) != -1) {
|
||||
|
||||
QString prefixedKey = keyRe.cap(1);
|
||||
if(prefixedKey.startsWith(key)) {
|
||||
|
||||
QString subKey = prefixedKey.remove(key);
|
||||
if (!subKey.isEmpty())
|
||||
result.append(subKey);
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include <QModelIndex>
|
||||
#include <assert.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
|
@ -63,6 +61,35 @@ void ContentSelectorView::ContentSelector::buildAddonView()
|
|||
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)
|
||||
{
|
||||
int index = -1;
|
||||
|
@ -92,7 +119,6 @@ void ContentSelectorView::ContentSelector::setCheckStates(const QStringList &lis
|
|||
{
|
||||
if (list.isEmpty())
|
||||
{
|
||||
qDebug() << "refreshing model";
|
||||
slotCurrentGameFileIndexChanged (ui.gameFileView->currentIndex());
|
||||
}
|
||||
else
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace ContentSelectorView
|
|||
QString currentFile() const;
|
||||
|
||||
void addFiles(const QString &path);
|
||||
void setProfileContent (const QStringList &fileList);
|
||||
|
||||
void clearCheckStates();
|
||||
void setCheckStates (const QStringList &list);
|
||||
|
|
Loading…
Reference in a new issue