|
|
|
@ -27,6 +27,11 @@ CS::Editor::Editor (int argc, char **argv)
|
|
|
|
|
std::pair<Files::PathContainer, std::vector<std::string> > config = readConfig();
|
|
|
|
|
|
|
|
|
|
mViewManager = new CSVDoc::ViewManager(mDocumentManager);
|
|
|
|
|
if (argc > 1)
|
|
|
|
|
{
|
|
|
|
|
mFileToLoad = argv[1];
|
|
|
|
|
mDataDirs = config.first;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NifOsg::Loader::setShowMarkers(true);
|
|
|
|
|
|
|
|
|
@ -103,9 +108,9 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
|
|
|
|
|
|
|
|
|
|
Fallback::Map::init(variables["fallback"].as<FallbackMap>().mMap);
|
|
|
|
|
|
|
|
|
|
const std::string encoding = variables["encoding"].as<Files::EscapeHashString>().toStdString();
|
|
|
|
|
mDocumentManager.setEncoding (ToUTF8::calculateEncoding (encoding));
|
|
|
|
|
mFileDialog.setEncoding (QString::fromUtf8(encoding.c_str()));
|
|
|
|
|
mEncodingName = variables["encoding"].as<Files::EscapeHashString>().toStdString();
|
|
|
|
|
mDocumentManager.setEncoding(ToUTF8::calculateEncoding(mEncodingName));
|
|
|
|
|
mFileDialog.setEncoding (QString::fromUtf8(mEncodingName.c_str()));
|
|
|
|
|
|
|
|
|
|
mDocumentManager.setResourceDir (mResources = variables["resources"].as<Files::EscapeHashString>().toStdString());
|
|
|
|
|
|
|
|
|
@ -217,12 +222,19 @@ void CS::Editor::loadDocument()
|
|
|
|
|
mFileDialog.showDialog (CSVDoc::ContentAction_Edit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CS::Editor::openFiles (const boost::filesystem::path &savePath)
|
|
|
|
|
void CS::Editor::openFiles (const boost::filesystem::path &savePath, const std::vector<boost::filesystem::path> &discoveredFiles)
|
|
|
|
|
{
|
|
|
|
|
std::vector<boost::filesystem::path> files;
|
|
|
|
|
|
|
|
|
|
foreach (const QString &path, mFileDialog.selectedFilePaths())
|
|
|
|
|
files.push_back(path.toUtf8().constData());
|
|
|
|
|
if(discoveredFiles.empty())
|
|
|
|
|
{
|
|
|
|
|
foreach(const QString &path, mFileDialog.selectedFilePaths())
|
|
|
|
|
files.push_back(path.toUtf8().constData());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
files = discoveredFiles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mDocumentManager.addDocument (files, savePath, false);
|
|
|
|
|
|
|
|
|
@ -348,9 +360,53 @@ int CS::Editor::run()
|
|
|
|
|
|
|
|
|
|
Misc::Rng::init();
|
|
|
|
|
|
|
|
|
|
mStartup.show();
|
|
|
|
|
QApplication::setQuitOnLastWindowClosed(true);
|
|
|
|
|
|
|
|
|
|
if (mFileToLoad.empty())
|
|
|
|
|
{
|
|
|
|
|
mStartup.show();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ESM::ESMReader fileReader;
|
|
|
|
|
ToUTF8::Utf8Encoder encoder = ToUTF8::calculateEncoding(mEncodingName);
|
|
|
|
|
fileReader.setEncoder(&encoder);
|
|
|
|
|
fileReader.open(mFileToLoad.string());
|
|
|
|
|
|
|
|
|
|
QApplication::setQuitOnLastWindowClosed (true);
|
|
|
|
|
std::vector<boost::filesystem::path> discoveredFiles;
|
|
|
|
|
|
|
|
|
|
for (std::vector<ESM::Header::MasterData>::const_iterator itemIter = fileReader.getGameFiles().begin();
|
|
|
|
|
itemIter != fileReader.getGameFiles().end(); ++itemIter)
|
|
|
|
|
{
|
|
|
|
|
for (Files::PathContainer::const_iterator pathIter = mDataDirs.begin();
|
|
|
|
|
pathIter != mDataDirs.end(); ++pathIter)
|
|
|
|
|
{
|
|
|
|
|
const boost::filesystem::path masterPath = *pathIter / itemIter->name;
|
|
|
|
|
if (boost::filesystem::exists(masterPath))
|
|
|
|
|
{
|
|
|
|
|
discoveredFiles.push_back(masterPath);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
discoveredFiles.push_back(mFileToLoad);
|
|
|
|
|
|
|
|
|
|
QString extension = QString::fromStdString(mFileToLoad.extension().string()).toLower();
|
|
|
|
|
if (extension == ".esm")
|
|
|
|
|
{
|
|
|
|
|
mFileToLoad.replace_extension(".omwgame");
|
|
|
|
|
mDocumentManager.addDocument(discoveredFiles, mFileToLoad, false);
|
|
|
|
|
}
|
|
|
|
|
else if (extension == ".esp")
|
|
|
|
|
{
|
|
|
|
|
mFileToLoad.replace_extension(".omwaddon");
|
|
|
|
|
mDocumentManager.addDocument(discoveredFiles, mFileToLoad, false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
openFiles(mFileToLoad, discoveredFiles);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QApplication::exec();
|
|
|
|
|
}
|
|
|
|
|