Support *.omwscripts in openmw-launcher

pull/3210/head
Petr Mikheev 3 years ago
parent e3cfe5d35a
commit 37386f417e

@ -32,7 +32,7 @@ Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, Config:
{
ui.setupUi (this);
setObjectName ("DataFilesPage");
mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget);
mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget, /*showOMWScripts=*/true);
const QString encoding = mGameSettings.value("encoding", "win1252");
mSelector->setEncoding(encoding);

@ -10,6 +10,8 @@ QSet<QString> CellNameLoader::getCellNames(QStringList &contentPaths)
// Loop through all content files
for (auto &contentPath : contentPaths) {
if (contentPath.endsWith(".omwscripts", Qt::CaseInsensitive))
continue;
esmReader.open(contentPath.toStdString());
// Loop through all records

@ -24,7 +24,7 @@ CSVDoc::FileDialog::FileDialog(QWidget *parent) :
resize(400, 400);
setObjectName ("FileDialog");
mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget);
mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget, /*showOMWScripts=*/false);
mAdjusterWidget = new AdjusterWidget (this);
}

@ -9,9 +9,10 @@
#include <components/esm/esmreader.hpp>
ContentSelectorModel::ContentModel::ContentModel(QObject *parent, QIcon warningIcon) :
ContentSelectorModel::ContentModel::ContentModel(QObject *parent, QIcon warningIcon, bool showOMWScripts) :
QAbstractTableModel(parent),
mWarningIcon(warningIcon),
mShowOMWScripts(showOMWScripts),
mMimeType ("application/omwcontent"),
mMimeTypes (QStringList() << mMimeType),
mColumnCount (1),
@ -416,6 +417,8 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path)
QDir dir(path);
QStringList filters;
filters << "*.esp" << "*.esm" << "*.omwgame" << "*.omwaddon";
if (mShowOMWScripts)
filters << "*.omwscripts";
dir.setNameFilters(filters);
for (const QString &path2 : dir.entryList())
@ -425,6 +428,15 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path)
if (item(info.fileName()))
continue;
if (info.fileName().endsWith(".omwscripts", Qt::CaseInsensitive))
{
EsmFile *file = new EsmFile(path2);
file->setDate(info.lastModified());
file->setFilePath(info.absoluteFilePath());
addFile(file);
continue;
}
try {
ESM::ESMReader fileReader;
ToUTF8::Utf8Encoder encoder =

@ -23,7 +23,7 @@ namespace ContentSelectorModel
{
Q_OBJECT
public:
explicit ContentModel(QObject *parent, QIcon warningIcon);
explicit ContentModel(QObject *parent, QIcon warningIcon, bool showOMWScripts);
~ContentModel();
void setEncoding(const QString &encoding);
@ -84,6 +84,7 @@ namespace ContentSelectorModel
QSet<QString> mPluginsWithLoadOrderError;
QString mEncoding;
QIcon mWarningIcon;
bool mShowOMWScripts;
public:

@ -10,21 +10,21 @@
#include <QClipboard>
#include <QModelIndex>
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) :
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent, bool showOMWScripts) :
QObject(parent)
{
ui.setupUi(parent);
ui.addonView->setDragDropMode(QAbstractItemView::InternalMove);
buildContentModel();
buildContentModel(showOMWScripts);
buildGameFileView();
buildAddonView();
}
void ContentSelectorView::ContentSelector::buildContentModel()
void ContentSelectorView::ContentSelector::buildContentModel(bool showOMWScripts)
{
QIcon warningIcon(ui.addonView->style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(QSize(16, 15)));
mContentModel = new ContentSelectorModel::ContentModel(this, warningIcon);
mContentModel = new ContentSelectorModel::ContentModel(this, warningIcon, showOMWScripts);
}
void ContentSelectorView::ContentSelector::buildGameFileView()

@ -23,7 +23,7 @@ namespace ContentSelectorView
public:
explicit ContentSelector(QWidget *parent = nullptr);
explicit ContentSelector(QWidget *parent = nullptr, bool showOMWScripts = false);
QString currentFile() const;
@ -56,7 +56,7 @@ namespace ContentSelectorView
Ui::ContentSelector ui;
void buildContentModel();
void buildContentModel(bool showOMWScripts);
void buildGameFileView();
void buildAddonView();
void buildContextMenu();

Loading…
Cancel
Save