mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-28 12:40:06 +00:00
Support *.omwscripts in openmw-launcher
This commit is contained in:
parent
e3cfe5d35a
commit
37386f417e
@ -32,7 +32,7 @@ Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, Config:
|
|||||||
{
|
{
|
||||||
ui.setupUi (this);
|
ui.setupUi (this);
|
||||||
setObjectName ("DataFilesPage");
|
setObjectName ("DataFilesPage");
|
||||||
mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget);
|
mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget, /*showOMWScripts=*/true);
|
||||||
const QString encoding = mGameSettings.value("encoding", "win1252");
|
const QString encoding = mGameSettings.value("encoding", "win1252");
|
||||||
mSelector->setEncoding(encoding);
|
mSelector->setEncoding(encoding);
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ QSet<QString> CellNameLoader::getCellNames(QStringList &contentPaths)
|
|||||||
|
|
||||||
// Loop through all content files
|
// Loop through all content files
|
||||||
for (auto &contentPath : contentPaths) {
|
for (auto &contentPath : contentPaths) {
|
||||||
|
if (contentPath.endsWith(".omwscripts", Qt::CaseInsensitive))
|
||||||
|
continue;
|
||||||
esmReader.open(contentPath.toStdString());
|
esmReader.open(contentPath.toStdString());
|
||||||
|
|
||||||
// Loop through all records
|
// Loop through all records
|
||||||
|
@ -24,7 +24,7 @@ CSVDoc::FileDialog::FileDialog(QWidget *parent) :
|
|||||||
resize(400, 400);
|
resize(400, 400);
|
||||||
|
|
||||||
setObjectName ("FileDialog");
|
setObjectName ("FileDialog");
|
||||||
mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget);
|
mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget, /*showOMWScripts=*/false);
|
||||||
mAdjusterWidget = new AdjusterWidget (this);
|
mAdjusterWidget = new AdjusterWidget (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,10 @@
|
|||||||
|
|
||||||
#include <components/esm/esmreader.hpp>
|
#include <components/esm/esmreader.hpp>
|
||||||
|
|
||||||
ContentSelectorModel::ContentModel::ContentModel(QObject *parent, QIcon warningIcon) :
|
ContentSelectorModel::ContentModel::ContentModel(QObject *parent, QIcon warningIcon, bool showOMWScripts) :
|
||||||
QAbstractTableModel(parent),
|
QAbstractTableModel(parent),
|
||||||
mWarningIcon(warningIcon),
|
mWarningIcon(warningIcon),
|
||||||
|
mShowOMWScripts(showOMWScripts),
|
||||||
mMimeType ("application/omwcontent"),
|
mMimeType ("application/omwcontent"),
|
||||||
mMimeTypes (QStringList() << mMimeType),
|
mMimeTypes (QStringList() << mMimeType),
|
||||||
mColumnCount (1),
|
mColumnCount (1),
|
||||||
@ -416,6 +417,8 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path)
|
|||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << "*.esp" << "*.esm" << "*.omwgame" << "*.omwaddon";
|
filters << "*.esp" << "*.esm" << "*.omwgame" << "*.omwaddon";
|
||||||
|
if (mShowOMWScripts)
|
||||||
|
filters << "*.omwscripts";
|
||||||
dir.setNameFilters(filters);
|
dir.setNameFilters(filters);
|
||||||
|
|
||||||
for (const QString &path2 : dir.entryList())
|
for (const QString &path2 : dir.entryList())
|
||||||
@ -425,6 +428,15 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path)
|
|||||||
if (item(info.fileName()))
|
if (item(info.fileName()))
|
||||||
continue;
|
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 {
|
try {
|
||||||
ESM::ESMReader fileReader;
|
ESM::ESMReader fileReader;
|
||||||
ToUTF8::Utf8Encoder encoder =
|
ToUTF8::Utf8Encoder encoder =
|
||||||
|
@ -23,7 +23,7 @@ namespace ContentSelectorModel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ContentModel(QObject *parent, QIcon warningIcon);
|
explicit ContentModel(QObject *parent, QIcon warningIcon, bool showOMWScripts);
|
||||||
~ContentModel();
|
~ContentModel();
|
||||||
|
|
||||||
void setEncoding(const QString &encoding);
|
void setEncoding(const QString &encoding);
|
||||||
@ -84,6 +84,7 @@ namespace ContentSelectorModel
|
|||||||
QSet<QString> mPluginsWithLoadOrderError;
|
QSet<QString> mPluginsWithLoadOrderError;
|
||||||
QString mEncoding;
|
QString mEncoding;
|
||||||
QIcon mWarningIcon;
|
QIcon mWarningIcon;
|
||||||
|
bool mShowOMWScripts;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -10,21 +10,21 @@
|
|||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) :
|
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent, bool showOMWScripts) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
ui.setupUi(parent);
|
ui.setupUi(parent);
|
||||||
ui.addonView->setDragDropMode(QAbstractItemView::InternalMove);
|
ui.addonView->setDragDropMode(QAbstractItemView::InternalMove);
|
||||||
|
|
||||||
buildContentModel();
|
buildContentModel(showOMWScripts);
|
||||||
buildGameFileView();
|
buildGameFileView();
|
||||||
buildAddonView();
|
buildAddonView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::buildContentModel()
|
void ContentSelectorView::ContentSelector::buildContentModel(bool showOMWScripts)
|
||||||
{
|
{
|
||||||
QIcon warningIcon(ui.addonView->style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(QSize(16, 15)));
|
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()
|
void ContentSelectorView::ContentSelector::buildGameFileView()
|
||||||
|
@ -23,7 +23,7 @@ namespace ContentSelectorView
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit ContentSelector(QWidget *parent = nullptr);
|
explicit ContentSelector(QWidget *parent = nullptr, bool showOMWScripts = false);
|
||||||
|
|
||||||
QString currentFile() const;
|
QString currentFile() const;
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ namespace ContentSelectorView
|
|||||||
|
|
||||||
Ui::ContentSelector ui;
|
Ui::ContentSelector ui;
|
||||||
|
|
||||||
void buildContentModel();
|
void buildContentModel(bool showOMWScripts);
|
||||||
void buildGameFileView();
|
void buildGameFileView();
|
||||||
void buildAddonView();
|
void buildAddonView();
|
||||||
void buildContextMenu();
|
void buildContextMenu();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user