Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
oblivioncth committed Dec 1, 2024
1 parent 75ff165 commit 089155b
Show file tree
Hide file tree
Showing 45 changed files with 514 additions and 280 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ endif()

include(OB/FetchQx)
ob_fetch_qx(
REF "0572d288936afd63ff6f5b6ce4b1fbfc0f03b0eb"
REF "62f9e486d8a850123d9a4d834509282ad15e3382"
COMPONENTS
${FIL_QX_COMPONENTS}
)
Expand Down Expand Up @@ -104,7 +104,7 @@ ob_fetch_clifp("7139ae998b292eb595e751ba4cb8599230435358")

# Fetch Neargye's Magic Enum
include(OB/FetchMagicEnum)
ob_fetch_magicenum("v0.9.3")
ob_fetch_magicenum("v0.9.7")

# Process Targets
set(APP_TARGET_NAME ${PROJECT_NAMESPACE_LC}_${PROJECT_NAMESPACE_LC})
Expand Down
73 changes: 41 additions & 32 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,52 @@ add_custom_target(fil_copy_clifp

# ------------------ Setup FIL --------------------------
set(FIL_SOURCE
frontend/fe-data.h
frontend/fe-data.cpp
frontend/fe-installfoundation.h
frontend/fe-installfoundation.cpp
frontend/fe-installfoundation_win.cpp
frontend/fe-installfoundation_linux.cpp
frontend/fe-install.h
frontend/fe-install.cpp
frontend/fe-items.h
frontend/fe-items.cpp
frontend/attractmode/am-data.h
frontend/attractmode/am-data.cpp
frontend/attractmode/am-install.h
frontend/attractmode/am-install.cpp
frontend/attractmode/am-install_win.cpp
frontend/attractmode/am-install_linux.cpp
frontend/attractmode/am-items.h
frontend/attractmode/am-items.cpp
frontend/attractmode/am-settings-data.h
frontend/attractmode/am-settings-data.cpp
frontend/attractmode/am-settings-items.h
frontend/attractmode/am-settings-items.cpp
launcher/fe-data.h
launcher/fe-data.cpp
launcher/fe-installfoundation.h
launcher/fe-installfoundation.cpp
launcher/fe-installfoundation_win.cpp
launcher/fe-installfoundation_linux.cpp
launcher/fe-install.h
launcher/fe-install.cpp
launcher/fe-items.h
launcher/fe-items.cpp
launcher/attractmode/am-data.h
launcher/attractmode/am-data.cpp
launcher/attractmode/am-install.h
launcher/attractmode/am-install.cpp
launcher/attractmode/am-install_win.cpp
launcher/attractmode/am-install_linux.cpp
launcher/attractmode/am-items.h
launcher/attractmode/am-items.cpp
launcher/attractmode/am-settings-data.h
launcher/attractmode/am-settings-data.cpp
launcher/attractmode/am-settings-items.h
launcher/attractmode/am-settings-items.cpp
ui/mainwindow.h
ui/mainwindow.cpp
ui/mainwindow.ui
ui/progresspresenter.h
ui/progresspresenter.cpp
clifp.h
clifp.cpp
import-worker.h
import-worker.cpp
kernel/controller.h
kernel/controller.cpp
kernel/clifp.h
kernel/clifp.cpp
kernel/import-properties.h
kernel/import-properties.cpp
kernel/import-worker.h
kernel/import-worker.cpp
main.cpp
)

if(CMAKE_SYSTEM_NAME STREQUAL Windows)
list(APPEND FIL_SOURCE
frontend/launchbox/lb-data.h
frontend/launchbox/lb-data.cpp
frontend/launchbox/lb-install.h
frontend/launchbox/lb-install.cpp
frontend/launchbox/lb-items.h
frontend/launchbox/lb-items.cpp
launcher/launchbox/lb-data.h
launcher/launchbox/lb-data.cpp
launcher/launchbox/lb-install.h
launcher/launchbox/lb-install.cpp
launcher/launchbox/lb-items.h
launcher/launchbox/lb-items.cpp
)
endif()

Expand Down Expand Up @@ -104,6 +108,11 @@ ob_add_standard_executable(${APP_TARGET_NAME}
WIN32
)

target_sources(fil_fil
PRIVATE

)

# Note that the executable depends on CLIFp being copied into its build dir
add_dependencies(${APP_TARGET_NAME} fil_copy_clifp)

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
6 changes: 3 additions & 3 deletions app/res/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<file>ui/CLIFp.png</file>
<file>ui/Exit.png</file>
<file>ui/GitHub.png</file>
<file>frontend/LaunchBox/icon.svg</file>
<file>frontend/AttractMode/icon.png</file>
<file>frontend/AttractMode/marquee.png</file>
<file>launcher/LaunchBox/icon.svg</file>
<file>launcher/AttractMode/icon.png</file>
<file>launcher/AttractMode/marquee.png</file>
<file>flashpoint/icon.png</file>
<file>ui/About.png</file>
</qresource>
Expand Down
File renamed without changes.
File renamed without changes.
131 changes: 131 additions & 0 deletions app/src/kernel/controller.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// Unit Include
#include "controller.h"

// libfp Includes
#include <fp/fp-install.h>

// Project Includes
#include "launcher/fe-install.h"

//===============================================================================================================
// Controller
//===============================================================================================================

//-Constructor-------------------------------------------------------------
//Public:
Controller::Controller()
{
// Setup properties
mImportProperties.setHasLinkPermissions(testForLinkPermissions());
mImportProperties.bindableIsLauncherPresent().setBinding([this]{ return mLauncher.value(); });
mImportProperties.bindableIsLauncherValid().setBinding([this]{ return mLauncher.value() && mLauncher->isValid(); });
mImportProperties.bindableIsFlashpointPresent().setBinding([this]{ return mFlashpoint.value(); });
mImportProperties.bindableIsFlashpointValid().setBinding([this]{ return mFlashpoint.value() && mFlashpoint->isValid(); });
mImportProperties.bindableIsFlashpointTargetSeries().setBinding([this]{ return mFlashpoint.value() && mFlashpoint->isValid() && installMatchesTargetSeries(*mFlashpoint.value()); });
mImportProperties.bindableImageModeOrder().setBinding([this]{
/* Even though technically we only need the launcher, check for both installs to prevent the selection
* from moving until its section is available
*/
static QList<Fe::ImageMode> defOrder{Fe::ImageMode::Link, Fe::ImageMode::Reference, Fe::ImageMode::Copy};
bool def = !(mLauncher.value() && mLauncher->isValid() && mFlashpoint.value() && mFlashpoint->isValid());
auto order = def ? defOrder : mLauncher->preferredImageModeOrder();
if(!mImportProperties.hasLinkPermissions())
order.removeAll(Fe::ImageMode::Link);

return order;
});
mImportProperties.bindableIsImageDownloadable().setBinding([this]{
return mFlashpoint.value() && mFlashpoint->isValid() && mFlashpoint->preferences().onDemandImages;
} );
mImportProperties.bindableLauncherInfo().setBinding([this]{ return (mLauncher.value() && mLauncher->isValid()) ? mLauncher->name() + ' ' + mLauncher->versionString() : QString(); });
mImportProperties.bindableLauncherInfo().setBinding([this]{ return (mFlashpoint.value() && mFlashpoint->isValid()) ? mFlashpoint->versionInfo()->fullString() : QString(); });
}

//-Class Functions-------------------------------------------------------------
//Private:
bool Controller::testForLinkPermissions()
{
QTemporaryDir testLinkDir;
if(testLinkDir.isValid())
{
QFile testLinkTarget(testLinkDir.filePath(u"linktarget.tmp"_s));

if(testLinkTarget.open(QIODevice::WriteOnly))
{
testLinkTarget.close();
std::error_code symlinkError;
std::filesystem::create_symlink(testLinkTarget.fileName().toStdString(), testLinkDir.filePath(u"testlink.tmp"_s).toStdString(), symlinkError);

if(!symlinkError)
return true;
}
}

// Default
return false;
}

bool Controller::installMatchesTargetSeries(const Fp::Install& fpInstall)
{
Qx::VersionNumber fpVersion = fpInstall.versionInfo()->version();
return TARGET_FP_VERSION_PREFIX.isPrefixOf(fpVersion) ||
TARGET_FP_VERSION_PREFIX.normalized() == fpVersion; // Accounts for if FP doesn't use a trailing zero for major releases
}


//-Instance Functions-------------------------------------------------------------
//Public:

//-Signals & Slots-------------------------------------------------------------
//Public slots:
void Controller::updateInstallPath(const QString& installPath, ImportProperties::Install type)
{
QString cleanPath = QDir::cleanPath(installPath);

using enum ImportProperties::Install;
switch(type)
{
case Launcher:
{
std::shared_ptr<Fe::Install> launcher;
if(cleanPath.isEmpty())
launcher = nullptr;
else
{
launcher = Fe::Install::acquireMatch(cleanPath);
if(!launcher->isValid())
NOTIFY
}

if(!launcher || !launcher->isValid())
invalidateInstall(install, true); // MIGHT NOT NEED DUE TO SUBSCRIBE AS IN NOTEPAD++

mLauncher = launcher;
break;
}
case Flashpoint:
{
std::shared_ptr<Fp::Install> flashpoint;
if(cleanPath.isEmpty())
flashpoint = nullptr;
else
{
flashpoint = std::make_shared<Fp::Install>(cleanPath, true);
if(!flashpoint->isValid())
NOTIFY
}

if(!flashpoint || !flashpoint->isValid())
invalidateInstall(install, true); // MIGHT NOT NEED DUE TO SUBSCRIBE AS IN NOTEPAD++

mFlashpoint = flashpoint; // Update target series property
if(!mImportProperties.isFlashpointTargetSeries())
QMessageBox::warning(this, QApplication::applicationName(), MSG_FP_VER_NOT_TARGET);
}
}

refreshEnableStates();

if(mFrontendInstall && mFlashpointInstall)
gatherInstallInfo();
}
51 changes: 51 additions & 0 deletions app/src/kernel/controller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#ifndef CONTROLLER_H
#define CONTROLLER_H

// Qt Includes
#include <QObject>
#include <QProperty>

// Qx Includes
#include <qx/core/qx-versionnumber.h>

// Project Includes
#include "kernel/import-properties.h"
#include "project_vars.h"

namespace Fe { class Install; }
namespace Fp { class Install; }

class Controller : public QObject
{
Q_OBJECT
Q_OBJECT_BINDABLE_PROPERTY(Controller, std::shared_ptr<Fe::Install>, mLauncher);
Q_OBJECT_BINDABLE_PROPERTY(Controller, std::shared_ptr<Fp::Install>, mFlashpoint);

//-Class Variables---------------------------------------------------------------
// Flashpoint version check
static inline const Qx::VersionNumber TARGET_FP_VERSION_PREFIX = Qx::VersionNumber::fromString(PROJECT_TARGET_FP_VER_PFX_STR);

//-Instance Variables-------------------------------------------------------------
private:
ImportProperties mImportProperties;

//-Constructor-------------------------------------------------------------
public:
Controller();

//-Class Functions-------------------------------------------------------------
private:
bool testForLinkPermissions();
bool installMatchesTargetSeries(const Fp::Install& fpInstall);

//-Instance Functions-------------------------------------------------------------
private:

public:

//-Signals & Slots-------------------------------------------------------------
public slots:
void updateInstallPath(const QString& installPath, ImportProperties::Install type);
};

#endif // CONTROLLER_H
45 changes: 45 additions & 0 deletions app/src/kernel/import-properties.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Unit Include
#include "import-properties.h"

//===============================================================================================================
// ImportProperties
//===============================================================================================================

//-Constructor-------------------------------------------------------------
//Public:
ImportProperties::ImportProperties() :
mHasLinkPerms(false)
{}

//-Instance Functions-------------------------------------------------------------
//Public:
void ImportProperties::setHasLinkPermissions(bool perms) { mHasLinkPerms = perms; }
bool ImportProperties::hasLinkPermissions() const { return mHasLinkPerms; }

QBindable<bool> ImportProperties::bindableIsLauncherPresent() { return &mLauncherPresent; }
bool ImportProperties::isLauncherPresent() const { return mLauncherPresent; }

QBindable<bool> ImportProperties::bindableIsLauncherValid() { return &mLauncherValid; }
bool ImportProperties::isLauncherValid() const { return mLauncherValid; }

QBindable<bool> ImportProperties::bindableIsFlashpointPresent() { return &mFlashpointPresent; }
bool ImportProperties::isFlashpointPresent() const { return mFlashpointPresent; }

QBindable<bool> ImportProperties::bindableIsFlashpointValid() { return &mFlashpointValid; }
bool ImportProperties::isFlashpointValid() const { return mFlashpointValid; }

QBindable<bool> ImportProperties::bindableIsFlashpointTargetSeries() { return &mFlashpointTargetSeries; }
bool ImportProperties::isFlashpointTargetSeries() const { return mFlashpointTargetSeries; }

QBindable<QList<Fe::ImageMode>> ImportProperties::bindableImageModeOrder() { return &mImageModeOrder; }
const QBindable<bool> ImportProperties::bindableIsImageModeOrder() const { return &mImageModeOrder; }
QList<Fe::ImageMode> ImportProperties::imageModeOrder() const { return mImageModeOrder; }

QBindable<bool> ImportProperties::bindableIsImageDownloadable() { return &mImageDownloadable; }
bool ImportProperties::isImageDownloadable() const { return mImageDownloadable; }

QBindable<QString> ImportProperties::bindableLauncherInfo() { return &mLauncherInfo; }
QString ImportProperties::launcherInfo() const { return mLauncherInfo; }

QBindable<QString> ImportProperties::bindableFlashpointInfo() { return &mFlashpointInfo; }
QString ImportProperties::flashpointInfo() const { return mFlashpointInfo; }
Loading

0 comments on commit 089155b

Please sign in to comment.