Issue #913: Merge --master and --plugin switches

Launcher part of master/plugin switches merge.

Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>
actorid
Lukasz Gromanowski 11 years ago
parent 3146af34d6
commit d51c9b64dd

@ -185,9 +185,6 @@ void DataFilesPage::loadSettings()
// mContentSelector. // mContentSelector.
mContentModel->uncheckAll(); mContentModel->uncheckAll();
QStringList gameFiles = mLauncherSettings.values(QString("Profiles/") + profile + QString("/master"), Qt::MatchExactly);
QStringList addons = mLauncherSettings.values(QString("Profiles/") + profile + QString("/plugin"), Qt::MatchExactly);
} }
void DataFilesPage::saveSettings() void DataFilesPage::saveSettings()
@ -202,27 +199,14 @@ void DataFilesPage::saveSettings()
mLauncherSettings.setValue(QString("Profiles/currentprofile"), profile); mLauncherSettings.setValue(QString("Profiles/currentprofile"), profile);
} }
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/master")); mLauncherSettings.remove(QString("Profiles/") + profile + QString("/content"));
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/plugin"));
mGameSettings.remove(QString("master"));
mGameSettings.remove(QString("plugins"));
mGameSettings.remove(QString("content")); mGameSettings.remove(QString("content"));
ContentSelectorModel::ContentFileList items = mContentModel->checkedItems(); ContentSelectorModel::ContentFileList items = mContentModel->checkedItems();
foreach(const ContentSelectorModel::EsmFile *item, items) { foreach(const ContentSelectorModel::EsmFile *item, items) {
mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/content"), item->fileName());
if (item->gameFiles().size() == 0) { mGameSettings.setMultiValue(QString("content"), item->fileName());
mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/master"), item->fileName());
mGameSettings.setMultiValue(QString("content"), item->fileName());
} else {
mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/plugin"), item->fileName());
mGameSettings.setMultiValue(QString("content"), item->fileName());
}
} }
} }
void DataFilesPage::updateOkButton(const QString &text) void DataFilesPage::updateOkButton(const QString &text)
@ -281,8 +265,7 @@ void DataFilesPage::on_deleteProfileAction_triggered()
msgBox.exec(); msgBox.exec();
if (msgBox.clickedButton() == deleteButton) { if (msgBox.clickedButton() == deleteButton) {
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/master")); mLauncherSettings.remove(QString("Profiles/") + profile + QString("/content"));
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/plugin"));
// Remove the profile from the combobox // Remove the profile from the combobox
profilesComboBox->removeItem(profilesComboBox->findText(profile)); profilesComboBox->removeItem(profilesComboBox->findText(profile));
@ -348,8 +331,7 @@ void DataFilesPage::profileRenamed(const QString &previous, const QString &curre
saveSettings(); saveSettings();
// Remove the old one // Remove the old one
mLauncherSettings.remove(QString("Profiles/") + previous + QString("/master")); mLauncherSettings.remove(QString("Profiles/") + previous + QString("/content"));
mLauncherSettings.remove(QString("Profiles/") + previous + QString("/plugin"));
// Remove the profile from the combobox // Remove the profile from the combobox
profilesComboBox->removeItem(profilesComboBox->findText(previous)); profilesComboBox->removeItem(profilesComboBox->findText(previous));

@ -261,19 +261,11 @@ bool MainDialog::showFirstRunDialog()
// Add a new profile // Add a new profile
if (msgBox.isChecked()) { if (msgBox.isChecked()) {
mLauncherSettings.setValue(QString("Profiles/currentprofile"), QString("Imported")); mLauncherSettings.setValue(QString("Profiles/currentprofile"), QString("Imported"));
mLauncherSettings.remove(QString("Profiles/Imported/content"));
mLauncherSettings.remove(QString("Profiles/Imported/master")); QStringList contents = mGameSettings.values(QString("content"));
mLauncherSettings.remove(QString("Profiles/Imported/plugin")); foreach (const QString &content, contents) {
mLauncherSettings.setMultiValue(QString("Profiles/Imported/content"), content);
QStringList masters = mGameSettings.values(QString("master"));
QStringList plugins = mGameSettings.values(QString("plugin"));
foreach (const QString &master, masters) {
mLauncherSettings.setMultiValue(QString("Profiles/Imported/master"), master);
}
foreach (const QString &plugin, plugins) {
mLauncherSettings.setMultiValue(QString("Profiles/Imported/plugin"), plugin);
} }
} }

@ -139,13 +139,13 @@ bool GameSettings::writeFile(QTextStream &stream)
while (i.hasPrevious()) { while (i.hasPrevious()) {
i.previous(); i.previous();
if (i.key() == QLatin1String("master") || i.key() == QLatin1String("plugin")) if (i.key() == QLatin1String("content"))
continue; continue;
// Quote paths with spaces // Quote paths with spaces
if (i.key() == QLatin1String("data") if (i.key() == QLatin1String("data")
|| i.key() == QLatin1String("data-local") || i.key() == QLatin1String("data-local")
|| i.key() == QLatin1String("resources")) || i.key() == QLatin1String("resources"))
{ {
if (i.value().contains(QChar(' '))) if (i.value().contains(QChar(' ')))
{ {
@ -161,15 +161,24 @@ bool GameSettings::writeFile(QTextStream &stream)
} }
QStringList masters = mSettings.values(QString("master")); QStringList content = mSettings.values(QString("content"));
for (int i = masters.count(); i--;) { for (int i = content.count(); i--;) {
stream << "content=" << masters.at(i) << "\n"; stream << "content=" << content.at(i) << "\n";
} }
QStringList plugins = mSettings.values(QString("plugin")); return true;
for (int i = plugins.count(); i--;) { }
stream << "content=" << plugins.at(i) << "\n";
bool GameSettings::hasMaster()
{
bool result = false;
QStringList content = mSettings.values(QString("content"));
for (int i = 0; i < content.count(); ++i) {
if (content.at(i).contains(".omwgame") || content.at(i).contains(".esm")) {
result = true;
break;
} }
}
return true; return result;
} }

@ -8,8 +8,11 @@
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
namespace Files { typedef std::vector<boost::filesystem::path> PathContainer; namespace Files
struct ConfigurationManager;} {
typedef std::vector<boost::filesystem::path> PathContainer;
struct ConfigurationManager;
}
class GameSettings class GameSettings
{ {
@ -43,7 +46,8 @@ public:
inline QStringList getDataDirs() { return mDataDirs; } inline QStringList getDataDirs() { return mDataDirs; }
inline void addDataDir(const QString &dir) { if(!dir.isEmpty()) mDataDirs.append(dir); } inline void addDataDir(const QString &dir) { if(!dir.isEmpty()) mDataDirs.append(dir); }
inline QString getDataLocal() {return mDataLocal; } inline QString getDataLocal() {return mDataLocal; }
inline bool hasMaster() { return mSettings.count(QString("master")) > 0; }
bool hasMaster();
QStringList values(const QString &key, const QStringList &defaultValues = QStringList()); QStringList values(const QString &key, const QStringList &defaultValues = QStringList());
bool readFile(QTextStream &stream); bool readFile(QTextStream &stream);

@ -461,9 +461,17 @@ ContentSelectorModel::ContentFileList ContentSelectorModel::ContentModel::checke
{ {
ContentFileList list; ContentFileList list;
// First search for game files and next addons,
// so we get more or less correct game files vs addons order.
foreach (EsmFile *file, mFiles) foreach (EsmFile *file, mFiles)
{ {
if (isChecked(file->fileName())) if (isChecked(file->fileName()) && file->isGameFile())
list << file;
}
foreach (EsmFile *file, mFiles)
{
if (isChecked(file->fileName()) && !file->isGameFile())
list << file; list << file;
} }

Loading…
Cancel
Save