Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of game features for better management. #15

Merged
merged 4 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/installer_bain_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
If there is a component called &quot;00 Core&quot; it is usually required. Options are ordered by priority as set up by the author.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="baincomplexinstallerdialog.ui" line="77"/>
<location filename="baincomplexinstallerdialog.ui" line="80"/>
<source>The package.txt is often part of BAIN packages and contains details about the options available.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="baincomplexinstallerdialog.ui" line="61"/>
<location filename="baincomplexinstallerdialog.ui" line="64"/>
Expand All @@ -46,6 +40,12 @@ If there is a component called &quot;00 Core&quot; it is usually required. Optio
<source>Manual</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="baincomplexinstallerdialog.ui" line="77"/>
<location filename="baincomplexinstallerdialog.ui" line="80"/>
<source>The package.txt is often part of BAIN packages and contains details about the options available.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="baincomplexinstallerdialog.ui" line="106"/>
<source>Ok</source>
Expand All @@ -60,22 +60,22 @@ If there is a component called &quot;00 Core&quot; it is usually required. Optio
<context>
<name>InstallerBAIN</name>
<message>
<location filename="installerbain.cpp" line="56"/>
<location filename="installerbain.cpp" line="58"/>
<source>BAIN Installer</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="installerbain.cpp" line="67"/>
<location filename="installerbain.cpp" line="69"/>
<source>Installer for BAIN archives (originally targeting Wrye Bash)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="installerbain.cpp" line="179"/>
<location filename="installerbain.cpp" line="183"/>
<source>May be BAIN installer</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="installerbain.cpp" line="180"/>
<location filename="installerbain.cpp" line="184"/>
<source>This installer looks like it may contain a BAIN installer but I&apos;m not sure. Install as BAIN installer?</source>
<translation type="unfinished"></translation>
</message>
Expand Down
34 changes: 20 additions & 14 deletions src/installerbain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ You should have received a copy of the GNU General Public License
along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
*/

#include "installerbain.h"

#include <iinstallationmanager.h>
#include <moddatachecker.h>
#include <iplugingame.h>
#include <igamefeatures.h>

#include <QDir>
#include <QtPlugin>
#include <QMessageBox>

#include <log.h>

#include "installerbain.h"
#include "baincomplexinstallerdialog.h"


Expand All @@ -40,7 +42,7 @@ InstallerBAIN::InstallerBAIN()
}


bool InstallerBAIN::init(IOrganizer *moInfo)
bool InstallerBAIN::init(IOrganizer* moInfo)
{
m_MOInfo = moInfo;
return true;
Expand Down Expand Up @@ -122,7 +124,7 @@ std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> InstallerBAIN::findSub
"fomod", "omod conversion data", "images", "screenshots", "docs"
};

ModDataChecker* checker = m_MOInfo->managedGame()->feature<ModDataChecker>();
auto checker = m_MOInfo->gameFeatures()->gameFeature<ModDataChecker>();

if (!checker) {
return {};
Expand Down Expand Up @@ -161,7 +163,7 @@ std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> InstallerBAIN::findSub

bool InstallerBAIN::isArchiveSupported(std::shared_ptr<const IFileTree> tree) const
{
ModDataChecker* checker = m_MOInfo->managedGame()->feature<ModDataChecker>();
auto checker = m_MOInfo->gameFeatures()->gameFeature<ModDataChecker>();

if (!checker) {
return false;
Expand All @@ -173,21 +175,23 @@ bool InstallerBAIN::isArchiveSupported(std::shared_ptr<const IFileTree> tree) co
if (subpackages.size() < 2) {
// a complex bain package contains at least 2 directories to choose from
return false;
} else if (numInvalidDirs == 0) {
}
else if (numInvalidDirs == 0) {
return true;
} else {
}
else {
return QMessageBox::question(parentWidget(), tr("May be BAIN installer"),
tr("This installer looks like it may contain a BAIN installer but I'm not sure. "
"Install as BAIN installer?"),
QMessageBox::Yes | QMessageBox::No)
== QMessageBox::Yes;
tr("This installer looks like it may contain a BAIN installer but I'm not sure. "
"Install as BAIN installer?"),
QMessageBox::Yes | QMessageBox::No)
== QMessageBox::Yes;
}

return true;
}

IPluginInstaller::EInstallResult InstallerBAIN::install(GuessedValue<QString> &modName, std::shared_ptr<IFileTree> &tree,
QString&, int&)
IPluginInstaller::EInstallResult InstallerBAIN::install(GuessedValue<QString>& modName, std::shared_ptr<IFileTree>& tree,
QString&, int&)
{
auto entry = tree->find("package.txt", FileTreeEntry::FILE);

Expand All @@ -210,11 +214,13 @@ IPluginInstaller::EInstallResult InstallerBAIN::install(GuessedValue<QString> &m
m_InstallerUsed = true;

return IPluginInstaller::RESULT_SUCCESS;
} else {
}
else {
if (dialog.manualRequested()) {
modName.update(dialog.getName(), GUESS_USER);
return IPluginInstaller::RESULT_MANUALREQUESTED;
} else {
}
else {
return IPluginInstaller::RESULT_CANCELED;
}
}
Expand Down