mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-25 16:43:33 +00:00
Merge branch 'omwaddon_dep' into 'master'
Allow creating omwaddons without a dependency on an omwgame See merge request OpenMW/openmw!1243
This commit is contained in:
commit
fc7e13d76a
@ -161,7 +161,7 @@ void CSVDoc::FileDialog::slotUpdateAcceptButton(const QString &name, bool)
|
|||||||
bool isNew = (mAction == ContentAction_New);
|
bool isNew = (mAction == ContentAction_New);
|
||||||
|
|
||||||
if (isNew)
|
if (isNew)
|
||||||
success = success && !(name.isEmpty());
|
success = !name.isEmpty();
|
||||||
else if (success)
|
else if (success)
|
||||||
{
|
{
|
||||||
ContentSelectorModel::EsmFile *file = mSelector->selectedFiles().back();
|
ContentSelectorModel::EsmFile *file = mSelector->selectedFiles().back();
|
||||||
|
@ -107,34 +107,28 @@ Qt::ItemFlags ContentSelectorModel::ContentModel::flags(const QModelIndex &index
|
|||||||
|
|
||||||
// addon can be checked if its gamefile is
|
// addon can be checked if its gamefile is
|
||||||
// ... special case, addon with no dependency can be used with any gamefile.
|
// ... special case, addon with no dependency can be used with any gamefile.
|
||||||
bool gamefileChecked = (file->gameFiles().count() == 0);
|
bool gamefileChecked = false;
|
||||||
|
bool noGameFiles = true;
|
||||||
for (const QString &fileName : file->gameFiles())
|
for (const QString &fileName : file->gameFiles())
|
||||||
{
|
{
|
||||||
for (QListIterator<EsmFile *> dependencyIter(mFiles); dependencyIter.hasNext(); dependencyIter.next())
|
for (QListIterator<EsmFile *> dependencyIter(mFiles); dependencyIter.hasNext(); dependencyIter.next())
|
||||||
{
|
{
|
||||||
//compare filenames only. Multiple instances
|
//compare filenames only. Multiple instances
|
||||||
//of the filename (with different paths) is not relevant here.
|
//of the filename (with different paths) is not relevant here.
|
||||||
bool depFound = (dependencyIter.peekNext()->fileName().compare(fileName, Qt::CaseInsensitive) == 0);
|
EsmFile* depFile = dependencyIter.peekNext();
|
||||||
|
if (!depFile->isGameFile() || depFile->fileName().compare(fileName, Qt::CaseInsensitive) != 0)
|
||||||
if (!depFound)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!gamefileChecked)
|
noGameFiles = false;
|
||||||
|
if (isChecked(depFile->filePath()))
|
||||||
{
|
{
|
||||||
if (isChecked (dependencyIter.peekNext()->filePath()))
|
gamefileChecked = true;
|
||||||
gamefileChecked = (dependencyIter.peekNext()->isGameFile());
|
|
||||||
}
|
|
||||||
|
|
||||||
// force it to iterate all files in cases where the current
|
|
||||||
// dependency is a game file to ensure that a later duplicate
|
|
||||||
// game file is / is not checked.
|
|
||||||
// (i.e., break only if it's not a gamefile or the game file has been checked previously)
|
|
||||||
if (gamefileChecked || !(dependencyIter.peekNext()->isGameFile()))
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamefileChecked)
|
if (gamefileChecked || noGameFiles)
|
||||||
{
|
{
|
||||||
returnFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled;
|
returnFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled;
|
||||||
}
|
}
|
||||||
|
@ -29,14 +29,12 @@ void ContentSelectorView::ContentSelector::buildContentModel()
|
|||||||
|
|
||||||
void ContentSelectorView::ContentSelector::buildGameFileView()
|
void ContentSelectorView::ContentSelector::buildGameFileView()
|
||||||
{
|
{
|
||||||
ui.gameFileView->setVisible (true);
|
ui.gameFileView->addItem("<No game file>");
|
||||||
|
ui.gameFileView->setVisible(true);
|
||||||
ui.gameFileView->setPlaceholderText(QString("Select a game file..."));
|
|
||||||
|
|
||||||
connect (ui.gameFileView, SIGNAL (currentIndexChanged(int)),
|
connect (ui.gameFileView, SIGNAL (currentIndexChanged(int)),
|
||||||
this, SLOT (slotCurrentGameFileIndexChanged(int)));
|
this, SLOT (slotCurrentGameFileIndexChanged(int)));
|
||||||
|
|
||||||
ui.gameFileView->setCurrentIndex(-1);
|
|
||||||
ui.gameFileView->setCurrentIndex(0);
|
ui.gameFileView->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +106,7 @@ void ContentSelectorView::ContentSelector::setProfileContent(const QStringList &
|
|||||||
|
|
||||||
void ContentSelectorView::ContentSelector::setGameFile(const QString &filename)
|
void ContentSelectorView::ContentSelector::setGameFile(const QString &filename)
|
||||||
{
|
{
|
||||||
int index = -1;
|
int index = 0;
|
||||||
|
|
||||||
if (!filename.isEmpty())
|
if (!filename.isEmpty())
|
||||||
{
|
{
|
||||||
@ -168,10 +166,11 @@ void ContentSelectorView::ContentSelector::addFiles(const QString &path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui.gameFileView->currentIndex() != -1)
|
if (ui.gameFileView->currentIndex() != 0)
|
||||||
ui.gameFileView->setCurrentIndex(-1);
|
ui.gameFileView->setCurrentIndex(0);
|
||||||
|
|
||||||
mContentModel->uncheckAll();
|
mContentModel->uncheckAll();
|
||||||
|
mContentModel->checkForLoadOrderErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::clearFiles()
|
void ContentSelectorView::ContentSelector::clearFiles()
|
||||||
@ -183,7 +182,7 @@ QString ContentSelectorView::ContentSelector::currentFile() const
|
|||||||
{
|
{
|
||||||
QModelIndex currentIdx = ui.addonView->currentIndex();
|
QModelIndex currentIdx = ui.addonView->currentIndex();
|
||||||
|
|
||||||
if (!currentIdx.isValid())
|
if (!currentIdx.isValid() && ui.gameFileView->currentIndex() > 0)
|
||||||
return ui.gameFileView->currentText();
|
return ui.gameFileView->currentText();
|
||||||
|
|
||||||
QModelIndex idx = mContentModel->index(mAddonProxyModel->mapToSource(currentIdx).row(), 0, QModelIndex());
|
QModelIndex idx = mContentModel->index(mAddonProxyModel->mapToSource(currentIdx).row(), 0, QModelIndex());
|
||||||
|
@ -40,7 +40,7 @@ namespace ContentSelectorView
|
|||||||
void setGameFile (const QString &filename = QString(""));
|
void setGameFile (const QString &filename = QString(""));
|
||||||
|
|
||||||
bool isGamefileSelected() const
|
bool isGamefileSelected() const
|
||||||
{ return ui.gameFileView->currentIndex() != -1; }
|
{ return ui.gameFileView->currentIndex() > 0; }
|
||||||
|
|
||||||
QWidget *uiWidget() const
|
QWidget *uiWidget() const
|
||||||
{ return ui.contentGroupBox; }
|
{ return ui.contentGroupBox; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user