Allow creating omwaddons without a dependency on an omwgame

pull/3152/head
Petr Mikheev 3 years ago
parent aa11238be1
commit 413ac067ec

@ -161,7 +161,7 @@ void CSVDoc::FileDialog::slotUpdateAcceptButton(const QString &name, bool)
bool isNew = (mAction == ContentAction_New);
if (isNew)
success = success && !(name.isEmpty());
success = !name.isEmpty();
else if (success)
{
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
// ... 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 (QListIterator<EsmFile *> dependencyIter(mFiles); dependencyIter.hasNext(); dependencyIter.next())
{
//compare filenames only. Multiple instances
//of the filename (with different paths) is not relevant here.
bool depFound = (dependencyIter.peekNext()->fileName().compare(fileName, Qt::CaseInsensitive) == 0);
if (!depFound)
EsmFile* depFile = dependencyIter.peekNext();
if (!depFile->isGameFile() || depFile->fileName().compare(fileName, Qt::CaseInsensitive) != 0)
continue;
if (!gamefileChecked)
noGameFiles = false;
if (isChecked(depFile->filePath()))
{
if (isChecked (dependencyIter.peekNext()->filePath()))
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()))
gamefileChecked = true;
break;
}
}
}
if (gamefileChecked)
if (gamefileChecked || noGameFiles)
{
returnFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled;
}

@ -29,14 +29,12 @@ void ContentSelectorView::ContentSelector::buildContentModel()
void ContentSelectorView::ContentSelector::buildGameFileView()
{
ui.gameFileView->setVisible (true);
ui.gameFileView->setPlaceholderText(QString("Select a game file..."));
ui.gameFileView->addItem("<No game file>");
ui.gameFileView->setVisible(true);
connect (ui.gameFileView, SIGNAL (currentIndexChanged(int)),
this, SLOT (slotCurrentGameFileIndexChanged(int)));
ui.gameFileView->setCurrentIndex(-1);
ui.gameFileView->setCurrentIndex(0);
}
@ -108,7 +106,7 @@ void ContentSelectorView::ContentSelector::setProfileContent(const QStringList &
void ContentSelectorView::ContentSelector::setGameFile(const QString &filename)
{
int index = -1;
int index = 0;
if (!filename.isEmpty())
{
@ -168,10 +166,11 @@ void ContentSelectorView::ContentSelector::addFiles(const QString &path)
}
}
if (ui.gameFileView->currentIndex() != -1)
ui.gameFileView->setCurrentIndex(-1);
if (ui.gameFileView->currentIndex() != 0)
ui.gameFileView->setCurrentIndex(0);
mContentModel->uncheckAll();
mContentModel->checkForLoadOrderErrors();
}
void ContentSelectorView::ContentSelector::clearFiles()
@ -183,7 +182,7 @@ QString ContentSelectorView::ContentSelector::currentFile() const
{
QModelIndex currentIdx = ui.addonView->currentIndex();
if (!currentIdx.isValid())
if (!currentIdx.isValid() && ui.gameFileView->currentIndex() > 0)
return ui.gameFileView->currentText();
QModelIndex idx = mContentModel->index(mAddonProxyModel->mapToSource(currentIdx).row(), 0, QModelIndex());

@ -40,7 +40,7 @@ namespace ContentSelectorView
void setGameFile (const QString &filename = QString(""));
bool isGamefileSelected() const
{ return ui.gameFileView->currentIndex() != -1; }
{ return ui.gameFileView->currentIndex() > 0; }
QWidget *uiWidget() const
{ return ui.contentGroupBox; }

Loading…
Cancel
Save