Skip to content

Commit

Permalink
Merge pull request #12 from oblivioncth/dev
Browse files Browse the repository at this point in the history
Merge to master for v0.8.2 release
  • Loading branch information
oblivioncth authored Aug 13, 2022
2 parents ac9b4c0 + 57b1c29 commit 0780e1e
Show file tree
Hide file tree
Showing 18 changed files with 779 additions and 331 deletions.
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.21.1)

# Project
# NOTE: DON'T USE TRAILING ZEROS IN VERSIONS
set(CLIFP_BASE_VERSION 0.8.1.1) # Required for CI/CD
set(CLIFP_BASE_VERSION 0.8.2) # Required for CI/CD
project(CLIFp
VERSION ${CLIFP_BASE_VERSION}
LANGUAGES CXX
Expand Down Expand Up @@ -90,11 +90,11 @@ add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x060000)

# Fetch Qx (build and import from source)
include(CLIFp/FetchQx)
fetch_qx("v0.3.0.3")
fetch_qx("v0.3.1")

# Fetch libfp (build and import from source)
include(CLIFp/Fetchlibfp)
fetch_libfp("v0.1")
fetch_libfp("v0.1.1")

# Fetch Neargye's Magic Enum
include(CLIFp/FetchMagicEnum)
Expand Down Expand Up @@ -122,6 +122,8 @@ set(CXX_SOURCES
src/driver.cpp
src/logger.h
src/logger.cpp
src/processwaiter.h
src/processwaiter.cpp
src/statusrelay.h
src/statusrelay.cpp
src/main.cpp
Expand Down Expand Up @@ -186,7 +188,7 @@ set_cxx_project_vars(${TARGET_NAME}
# Set target exe details
include(CLIFp/WinExecutableDetails)
set_win_executable_details(${TARGET_NAME}
ICON "res/icon/CLIFp.ico"
ICON "res/app/CLIFp.ico"
FILE_VER ${PROJECT_VERSION}
PRODUCT_VER ${TARGET_FP_VERSION_PREFIX}
COMPANY_NAME "oblivioncth"
Expand Down Expand Up @@ -217,6 +219,8 @@ write_basic_package_version_file(

#================= Install ==========================

set(TOP_LEVEL_INSTALL_COMPONENT ${PROJECT_NAME_LC})

# Install executable
install(TARGETS ${TARGET_NAME}
CONFIGURATIONS Release
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ CLIFp (pronounced "Cliff-P") is a command-line interface for [BlueMaxima's Flash

Other than a few pop-up dialogs used for alerts and errors, CLIFp runs completely in the background so that the only windows seen during use are the same ones present while running standard Flashpoint. It automatically terminates once the target application has exited, requiring no manual tasks or clean-up by the user.

[![Dev Builds](https://github.com/oblivioncth/CLIFp/actions/workflows/push-reaction.yml/badge.svg?branch=dev)](https://github.com/oblivioncth/CLIFp/actions/workflows/push-reaction.yml)

## Compatability
### General
Because it directly mimics the actions of the GUI launcher, CLIFp should provide a perfect or near-perfect experience when compared to using the standard method of launching games/animations. Additionally, this makes it fairly resilient towards Flashpoint updates and will most likely only require compatibility patches when updates that make major changes are released.
Expand Down
14 changes: 9 additions & 5 deletions cmake/module/CLIFp/WinExecutableDetails.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ function(set_win_executable_details target)
set(GENERATED_PATH "${GENERATED_DIR}/${GENERATED_NAME}")
set(TEMPLATE_FILE "__resources.rc.in")


# Additional Function inputs
set(oneValueArgs
ICON
Expand Down Expand Up @@ -36,12 +35,17 @@ function(set_win_executable_details target)
message(FATAL_ERROR "Not all required values were present!")
endif()

# Determine absolute icon path
set(EXE_ICON "${CMAKE_CURRENT_LIST_DIR}/${WIN_ED_ICON}")
# Determine absolute icon path (relative to caller)
cmake_path(ABSOLUTE_PATH WIN_ED_ICON
BASE_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}"
NORMALIZE
OUTPUT_VARIABLE __ABS_ICON_PATH
)

# Convert icon path to relative
cmake_path(RELATIVE_PATH EXE_ICON
# Determine relative icon path (relative to generated rc file)
cmake_path(RELATIVE_PATH __ABS_ICON_PATH
BASE_DIRECTORY "${GENERATED_DIR}"
OUTPUT_VARIABLE EXE_ICON
)

# Set binary file and product versions
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion res/resources.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>icon/CLIFp.ico</file>
<file>app/CLIFp.ico</file>
<file>tray/Exit.png</file>
</qresource>
</RCC>
Binary file added res/tray/Exit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion src/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ Controller::Controller(QObject* parent)
connect(driver, &Driver::downloadTotalChanged, &mStatusRelay, &StatusRelay::downloadTotalHandler);
connect(driver, &Driver::downloadStarted, &mStatusRelay, &StatusRelay::downloadStartedHandler);
connect(driver, &Driver::downloadFinished, &mStatusRelay, &StatusRelay::downloadFinishedHandler);
connect(&mStatusRelay, &StatusRelay::downloadCanceled, driver, &Driver::cancelActiveDownloads);

// Connect driver - Response Requested (BlockingQueuedConnection since response must be waited for)
connect(driver, &Driver::blockingErrorOccured, &mStatusRelay, &StatusRelay::blockingErrorHandler, Qt::BlockingQueuedConnection);
connect(driver, &Driver::authenticationRequired, &mStatusRelay, &StatusRelay::authenticationHandler, Qt::BlockingQueuedConnection);

// Connect quit handler
connect(&mStatusRelay, &StatusRelay::quitRequested, this, &Controller::quitRequestHandler);
connect(this, &Controller::quit, driver, &Driver::quitNow);

// Start thread
mWorkerThread.start();
}
Expand Down Expand Up @@ -73,10 +78,19 @@ bool Controller::windowsAreOpen()


//Public:
void Controller::run() { emit operate();}
void Controller::run() { emit operate(); }

//-Slots--------------------------------------------------------------------------------
//Private:
void Controller::quitRequestHandler()
{
// Notify driver to quit if it still exists
emit quit();

// Close all top-level windows
qApp->closeAllWindows();
}

void Controller::finisher(ErrorCode errorCode)
{
// Quit once no windows remain
Expand Down
2 changes: 2 additions & 0 deletions src/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ class Controller : public QObject

//-Signals & Slots------------------------------------------------------------------------------------------------------------
private slots:
void quitRequestHandler();
void finisher(ErrorCode errorCode);

signals:
void quit();
void operate();
};

Expand Down
29 changes: 12 additions & 17 deletions src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ ErrorCode Core::initialize(QStringList& commandLine)
commandLine.removeFirst();

// Create logger instance
mLogFile = std::make_unique<QFile>(CLIFP_DIR_PATH + '/' + LOG_FILE_NAME);
mLogger = std::make_unique<Logger>(mLogFile.get(), mRawCommandLine.isEmpty() ? LOG_NO_PARAMS : mRawCommandLine, globalOptions, LOG_HEADER, LOG_MAX_ENTRIES);
QString logPath = CLIFP_DIR_PATH + '/' + LOG_FILE_NAME;
mLogger = std::make_unique<Logger>(logPath, mRawCommandLine.isEmpty() ? LOG_NO_PARAMS : mRawCommandLine, globalOptions, LOG_HEADER, LOG_MAX_ENTRIES);

// Open log
Qx::IoOpReport logOpen = mLogger->openLog();
if(!logOpen.wasSuccessful())
if(logOpen.isFailure())
postError(NAME, Qx::GenericError(Qx::GenericError::Warning, logOpen.outcome(), logOpen.outcomeInfo()), false);

// Log initialization step
Expand Down Expand Up @@ -154,7 +154,7 @@ ErrorCode Core::initialize(QStringList& commandLine)
}
else
{
commandLine.clear(); // Clear remaining options since they are now irrelavent
commandLine.clear(); // Clear remaining options since they are now irrelevant
showHelp();
logError(NAME, Qx::GenericError(Qx::GenericError::Error, LOG_ERR_INVALID_PARAM, clParser.errorText()));
return ErrorCodes::INVALID_ARGS;
Expand Down Expand Up @@ -381,7 +381,7 @@ ErrorCode Core::enqueueDataPackTasks(QUuid targetID)
if(packFile.exists())
{
Qx::IoOpReport checksumReport = Qx::fileMatchesChecksum(checksumMatches, packFile, packSha256, QCryptographicHash::Sha256);
if(!checksumReport.wasSuccessful())
if(checksumReport.isFailure())
logError(NAME, Qx::GenericError(Qx::GenericError::Error, checksumReport.outcome(), checksumReport.outcomeInfo()));

if(!checksumMatches)
Expand Down Expand Up @@ -458,22 +458,22 @@ void Core::clearTaskQueue() { mTaskQueue = {}; }
void Core::logCommand(QString src, QString commandName)
{
Qx::IoOpReport logReport = mLogger->recordGeneralEvent(src, COMMAND_LABEL.arg(commandName));
if(!logReport.wasSuccessful())
if(logReport.isFailure())
postError(src, Qx::GenericError(Qx::GenericError::Warning, logReport.outcome(), logReport.outcomeInfo()), false);
}

void Core::logCommandOptions(QString src, QString commandOptions)
{
Qx::IoOpReport logReport = mLogger->recordGeneralEvent(src, COMMAND_OPT_LABEL.arg(commandOptions));
if(!logReport.wasSuccessful())
if(logReport.isFailure())
postError(src, Qx::GenericError(Qx::GenericError::Warning, logReport.outcome(), logReport.outcomeInfo()), false);
}

void Core::logError(QString src, Qx::GenericError error)
{
Qx::IoOpReport logReport = mLogger->recordErrorEvent(src, error);

if(!logReport.wasSuccessful())
if(logReport.isFailure())
postError(src, Qx::GenericError(Qx::GenericError::Warning, logReport.outcome(), logReport.outcomeInfo()), false);

if(error.errorLevel() == Qx::GenericError::Critical)
Expand All @@ -483,7 +483,7 @@ void Core::logError(QString src, Qx::GenericError error)
void Core::logEvent(QString src, QString event)
{
Qx::IoOpReport logReport = mLogger->recordGeneralEvent(src, event);
if(!logReport.wasSuccessful())
if(logReport.isFailure())
postError(src, Qx::GenericError(Qx::GenericError::Warning, logReport.outcome(), logReport.outcomeInfo()), false);
}

Expand All @@ -495,7 +495,7 @@ int Core::logFinish(QString src, int exitCode)
logEvent(src, LOG_ERR_CRITICAL);

Qx::IoOpReport logReport = mLogger->finish(exitCode);
if(!logReport.wasSuccessful())
if(logReport.isFailure())
postError(src, Qx::GenericError(Qx::GenericError::Warning, logReport.outcome(), logReport.outcomeInfo()), false);

// Return exit code so main function can return with this one
Expand Down Expand Up @@ -558,13 +558,8 @@ Fp::Install& Core::getFlashpointInstall() { return *mFlashpointInstall; }
Core::NotificationVerbosity Core::notifcationVerbosity() const { return mNotificationVerbosity; }
size_t Core::taskCount() const { return mTaskQueue.size(); }
bool Core::hasTasks() const { return mTaskQueue.size() > 0; }

std::shared_ptr<Core::Task> Core::takeFrontTask()
{
std::shared_ptr<Task> frontTask = mTaskQueue.front();
mTaskQueue.pop();
return frontTask;
}
std::shared_ptr<Core::Task> Core::frontTask() { return mTaskQueue.front(); }
void Core::removeFrontTask() { mTaskQueue.pop(); }

QString Core::statusHeading() { return mStatusHeading; }
QString Core::statusMessage() { return mStatusMessage;}
Expand Down
8 changes: 4 additions & 4 deletions src/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "project_vars.h"

//-Macros----------------------------------------------------------------------
#define ENUM_NAME(eenum) QString::fromStdString(std::string(magic_enum::enum_name(eenum)))
#define ENUM_NAME(eenum) QString(magic_enum::enum_name(eenum).data())
#define CLIFP_DIR_PATH QCoreApplication::applicationDirPath()

//-Typedef---------------------------------------------------------------------
Expand Down Expand Up @@ -274,7 +274,6 @@ class Core : public QObject

// Handles
std::unique_ptr<Fp::Install> mFlashpointInstall;
std::unique_ptr<QFile> mLogFile;
std::unique_ptr<Logger> mLogger;

// Processing
Expand Down Expand Up @@ -307,7 +306,7 @@ class Core : public QObject
ErrorCode enqueueConditionalWaitTask(QFileInfo precedingAppInfo);
ErrorCode enqueueDataPackTasks(QUuid targetID);
void enqueueSingleTask(std::shared_ptr<Task> task);
void clearTaskQueue();
void clearTaskQueue(); // TODO: See if this can be done away with, it's awkward (i.e. not fill queue in first place). Think I tried to before though.

void logCommand(QString src, QString commandName);
void logCommandOptions(QString src, QString commandOptions);
Expand All @@ -323,7 +322,8 @@ class Core : public QObject
NotificationVerbosity notifcationVerbosity() const;
size_t taskCount() const;
bool hasTasks() const;
std::shared_ptr<Task> takeFrontTask();
std::shared_ptr<Task> frontTask();
void removeFrontTask();

QString statusHeading();
QString statusMessage();
Expand Down
Loading

0 comments on commit 0780e1e

Please sign in to comment.