mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 10:53:51 +00:00
Merge remote-tracking branch 'pvdk/datalocalfix'
This commit is contained in:
commit
2bb400eaa8
2 changed files with 86 additions and 71 deletions
|
@ -189,73 +189,8 @@ void DataFilesPage::setupConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DataFilesPage::setupDataFiles()
|
void DataFilesPage::addDataFiles(Files::Collections &fileCollections, const QString &encoding)
|
||||||
{
|
{
|
||||||
// We use the Configuration Manager to retrieve the configuration values
|
|
||||||
boost::program_options::variables_map variables;
|
|
||||||
boost::program_options::options_description desc;
|
|
||||||
|
|
||||||
desc.add_options()
|
|
||||||
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken())
|
|
||||||
("data-local", boost::program_options::value<std::string>()->default_value(""))
|
|
||||||
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
|
|
||||||
("encoding", boost::program_options::value<std::string>()->default_value("win1252"));
|
|
||||||
|
|
||||||
mCfgMgr.readConfiguration(variables, desc);
|
|
||||||
|
|
||||||
// Put the paths in a boost::filesystem vector to use with Files::Collections
|
|
||||||
mDataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>());
|
|
||||||
|
|
||||||
std::string local = variables["data-local"].as<std::string>();
|
|
||||||
if (!local.empty()) {
|
|
||||||
mDataLocal.push_back(Files::PathContainer::value_type(local));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mDataDirs.size()>1)
|
|
||||||
mDataDirs.resize (1);
|
|
||||||
|
|
||||||
mCfgMgr.processPaths(mDataDirs);
|
|
||||||
|
|
||||||
while (mDataDirs.empty()) {
|
|
||||||
QMessageBox msgBox;
|
|
||||||
msgBox.setWindowTitle("Error detecting Morrowind installation");
|
|
||||||
msgBox.setIcon(QMessageBox::Warning);
|
|
||||||
msgBox.setStandardButtons(QMessageBox::Cancel);
|
|
||||||
msgBox.setText(tr("<br><b>Could not find the Data Files location</b><br><br> \
|
|
||||||
The directory containing the data files was not found.<br><br> \
|
|
||||||
Press \"Browse...\" to specify the location manually.<br>"));
|
|
||||||
|
|
||||||
QAbstractButton *dirSelectButton =
|
|
||||||
msgBox.addButton(tr("B&rowse..."), QMessageBox::ActionRole);
|
|
||||||
|
|
||||||
msgBox.exec();
|
|
||||||
|
|
||||||
if (msgBox.clickedButton() == dirSelectButton) {
|
|
||||||
|
|
||||||
// Show a custom dir selection dialog which only accepts valid dirs
|
|
||||||
QString selectedDir = FileDialog::getExistingDirectory(
|
|
||||||
this, tr("Select Data Files Directory"),
|
|
||||||
QDir::currentPath(),
|
|
||||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
|
||||||
|
|
||||||
// Add the user selected data directory
|
|
||||||
if (!selectedDir.isEmpty()) {
|
|
||||||
mDataDirs.push_back(Files::PathContainer::value_type(selectedDir.toStdString()));
|
|
||||||
mCfgMgr.processPaths(mDataDirs);
|
|
||||||
} else {
|
|
||||||
// Cancel from within the dir selection dialog
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Cancel
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a file collection for the data dirs
|
|
||||||
Files::Collections fileCollections(mDataDirs, !variables["fs-strict"].as<bool>());
|
|
||||||
|
|
||||||
// First we add all the master files
|
// First we add all the master files
|
||||||
const Files::MultiDirCollection &esm = fileCollections.getCollection(".esm");
|
const Files::MultiDirCollection &esm = fileCollections.getCollection(".esm");
|
||||||
unsigned int i = 0; // Row number
|
unsigned int i = 0; // Row number
|
||||||
|
@ -283,7 +218,7 @@ bool DataFilesPage::setupDataFiles()
|
||||||
ESMReader fileReader;
|
ESMReader fileReader;
|
||||||
QStringList availableMasters; // Will contain all found masters
|
QStringList availableMasters; // Will contain all found masters
|
||||||
|
|
||||||
fileReader.setEncoding(variables["encoding"].as<std::string>());
|
fileReader.setEncoding(encoding.toStdString());
|
||||||
fileReader.open(iter->second.string());
|
fileReader.open(iter->second.string());
|
||||||
|
|
||||||
// First we fill the availableMasters and the mMastersWidget
|
// First we fill the availableMasters and the mMastersWidget
|
||||||
|
@ -355,6 +290,81 @@ bool DataFilesPage::setupDataFiles()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool DataFilesPage::setupDataFiles()
|
||||||
|
{
|
||||||
|
// We use the Configuration Manager to retrieve the configuration values
|
||||||
|
boost::program_options::variables_map variables;
|
||||||
|
boost::program_options::options_description desc;
|
||||||
|
|
||||||
|
desc.add_options()
|
||||||
|
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken())
|
||||||
|
("data-local", boost::program_options::value<std::string>()->default_value(""))
|
||||||
|
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
|
||||||
|
("encoding", boost::program_options::value<std::string>()->default_value("win1252"));
|
||||||
|
|
||||||
|
mCfgMgr.readConfiguration(variables, desc);
|
||||||
|
|
||||||
|
// Put the paths in a boost::filesystem vector to use with Files::Collections
|
||||||
|
mDataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>());
|
||||||
|
|
||||||
|
std::string local = variables["data-local"].as<std::string>();
|
||||||
|
if (!local.empty()) {
|
||||||
|
mDataLocal.push_back(Files::PathContainer::value_type(local));
|
||||||
|
}
|
||||||
|
|
||||||
|
mCfgMgr.processPaths(mDataDirs);
|
||||||
|
mCfgMgr.processPaths(mDataLocal);
|
||||||
|
|
||||||
|
while (mDataDirs.empty()) {
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setWindowTitle("Error detecting Morrowind installation");
|
||||||
|
msgBox.setIcon(QMessageBox::Warning);
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Cancel);
|
||||||
|
msgBox.setText(tr("<br><b>Could not find the Data Files location</b><br><br> \
|
||||||
|
The directory containing the data files was not found.<br><br> \
|
||||||
|
Press \"Browse...\" to specify the location manually.<br>"));
|
||||||
|
|
||||||
|
QAbstractButton *dirSelectButton =
|
||||||
|
msgBox.addButton(tr("B&rowse..."), QMessageBox::ActionRole);
|
||||||
|
|
||||||
|
msgBox.exec();
|
||||||
|
|
||||||
|
if (msgBox.clickedButton() == dirSelectButton) {
|
||||||
|
|
||||||
|
// Show a custom dir selection dialog which only accepts valid dirs
|
||||||
|
QString selectedDir = FileDialog::getExistingDirectory(
|
||||||
|
this, tr("Select Data Files Directory"),
|
||||||
|
QDir::currentPath(),
|
||||||
|
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||||
|
|
||||||
|
// Add the user selected data directory
|
||||||
|
if (!selectedDir.isEmpty()) {
|
||||||
|
mDataDirs.push_back(Files::PathContainer::value_type(selectedDir.toStdString()));
|
||||||
|
mCfgMgr.processPaths(mDataDirs);
|
||||||
|
} else {
|
||||||
|
// Cancel from within the dir selection dialog
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Cancel
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the plugins in the data directories
|
||||||
|
Files::Collections dataCollections(mDataDirs, !variables["fs-strict"].as<bool>());
|
||||||
|
Files::Collections dataLocalCollections(mDataLocal, !variables["fs-strict"].as<bool>());
|
||||||
|
|
||||||
|
addDataFiles(dataCollections, QString::fromStdString(variables["encoding"].as<std::string>()));
|
||||||
|
addDataFiles(dataLocalCollections, QString::fromStdString(variables["encoding"].as<std::string>()));
|
||||||
|
|
||||||
|
mDataFilesModel->sort(0);
|
||||||
|
|
||||||
readConfig();
|
readConfig();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1140,11 +1150,13 @@ void DataFilesPage::writeConfig(QString profile)
|
||||||
path = QString::fromStdString(it->string());
|
path = QString::fromStdString(it->string());
|
||||||
path.remove(QChar('\"'));
|
path.remove(QChar('\"'));
|
||||||
|
|
||||||
|
QDir dir(path);
|
||||||
|
|
||||||
// Make sure the string is quoted when it contains spaces
|
// Make sure the string is quoted when it contains spaces
|
||||||
if (path.contains(" ")) {
|
if (path.contains(" ")) {
|
||||||
gameConfig << "data=\"" << path << "\"" << endl;
|
gameConfig << "data=\"" << dir.absolutePath() << "\"" << endl;
|
||||||
} else {
|
} else {
|
||||||
gameConfig << "data=" << path << endl;
|
gameConfig << "data=" << dir.absolutePath() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1153,10 +1165,12 @@ void DataFilesPage::writeConfig(QString profile)
|
||||||
path = QString::fromStdString(mDataLocal.front().string());
|
path = QString::fromStdString(mDataLocal.front().string());
|
||||||
path.remove(QChar('\"'));
|
path.remove(QChar('\"'));
|
||||||
|
|
||||||
|
QDir dir(path);
|
||||||
|
|
||||||
if (path.contains(" ")) {
|
if (path.contains(" ")) {
|
||||||
gameConfig << "data-local=\"" << path << "\"" << endl;
|
gameConfig << "data-local=\"" << dir.absolutePath() << "\"" << endl;
|
||||||
} else {
|
} else {
|
||||||
gameConfig << "data-local=" << path << endl;
|
gameConfig << "data-local=" << dir.absolutePath() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ private:
|
||||||
const QStringList checkedPlugins();
|
const QStringList checkedPlugins();
|
||||||
const QStringList selectedMasters();
|
const QStringList selectedMasters();
|
||||||
|
|
||||||
|
void addDataFiles(Files::Collections &fileCollections, const QString &encoding);
|
||||||
void addPlugins(const QModelIndex &index);
|
void addPlugins(const QModelIndex &index);
|
||||||
void removePlugins(const QModelIndex &index);
|
void removePlugins(const QModelIndex &index);
|
||||||
void uncheckPlugins();
|
void uncheckPlugins();
|
||||||
|
|
Loading…
Reference in a new issue