Skip to content

Commit

Permalink
Merge pull request #76 from oblivioncth/dev
Browse files Browse the repository at this point in the history
Merge to master for v0.9.9
  • Loading branch information
oblivioncth authored Nov 7, 2023
2 parents 23c909d + 8448e2e commit 9319769
Show file tree
Hide file tree
Showing 27 changed files with 1,284 additions and 333 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-clifp-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
echo "Build complete."
- name: Get CLIFp artifact name
run: |
$artifact_name=$((Get-ChildItem -Path "${{ env.clifp_package_path }}" -Filter *.zip)[0].BaseName)
$artifact_name=$((Get-ChildItem -Path "${{ env.clifp_package_path }}" -Filter *.zip)[0].BaseName) + ' [msvc]'
echo "current_artifact_name=$artifact_name" >> $Env:GITHUB_ENV
- name: Upload CLIFp build artifact
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/master-pull-request-merge-reaction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
- name: Zip up release artifacts
shell: pwsh
run: |
$artifact_folders = Get-ChildItem -Directory -Path "${{ env.artifacts_path }}"
$artifact_folders = Get-ChildItem -Directory -Path "${{ env.artifacts_path }}" -Exclude "github-pages"
foreach($art_dir in $artifact_folders)
{
$name = $art_dir.name
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.24.0...3.26.0)
# Project
# NOTE: DON'T USE TRAILING ZEROS IN VERSIONS
project(CLIFp
VERSION 0.9.8
VERSION 0.9.9
LANGUAGES CXX
DESCRIPTION "Command-line Interface for Flashpoint Archive"
)
Expand Down Expand Up @@ -72,14 +72,14 @@ endif()

include(OB/FetchQx)
ob_fetch_qx(
REF "v0.5.4"
REF "v0.5.5.1"
COMPONENTS
${CLIFP_QX_COMPONENTS}
)

# Fetch libfp (build and import from source)
include(OB/Fetchlibfp)
ob_fetch_libfp("v0.5.1")
ob_fetch_libfp("v0.5.1.1")

# Fetch QI-QMP (build and import from source)
include(OB/FetchQI-QMP)
Expand Down
211 changes: 108 additions & 103 deletions README.md

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Pre-configure target
set(CLIFP_SOURCE
kernel/buildinfo.h
kernel/core.h
kernel/core.cpp
kernel/driver.h
Expand All @@ -22,6 +23,8 @@ set(CLIFP_SOURCE
command/c-share.cpp
command/c-show.cpp
command/c-show.h
command/c-update.h
command/c-update.cpp
command/title-command.h
command/title-command.cpp
task/task.h
Expand Down Expand Up @@ -126,12 +129,29 @@ ob_add_cpp_vars(${APP_TARGET_NAME}
NAME "project_vars"
PREFIX "PROJECT_"
VARS
VERSION_STR "\"${PROJECT_VERSION}\""
VERSION_STR "\"${PROJECT_VERSION_VERBOSE}\""
SHORT_NAME "\"${APP_ALIAS_NAME}\""
TARGET_FP_VER_PFX_STR "\"${TARGET_FP_VERSION_PREFIX}\""
APP_NAME "\"${PROJECT_FORMAL_NAME}\""
)

## Add build info
if(BUILD_SHARED_LIBS)
set(link_str "Shared")
else()
set(link_str "Static")
endif()

ob_add_cpp_vars(${APP_TARGET_NAME}
NAME "_buildinfo"
PREFIX "BUILDINFO_"
VARS
SYSTEM "\"${CMAKE_SYSTEM_NAME}\""
LINKAGE "\"${link_str}\""
COMPILER "u\"${CMAKE_CXX_COMPILER_ID}\"_s"
COMPILER_VER_STR "u\"${CMAKE_CXX_COMPILER_VERSION}\"_s"
)

## Add exe details on Windows
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
# Set target exe details
Expand Down
39 changes: 12 additions & 27 deletions app/src/command/c-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Qx::Error CLink::perform()
// Get database
Fp::Db* database = mCore.fpInstall().database();

// Get entry (also confirms that ID is present in database)
// Get entry (also confirms that ID is present in database, which is why we do this even if a custom name is set)
std::variant<Fp::Game, Fp::AddApp> entry_v;
Fp::DbError dbError = database->getEntry(entry_v, shortcutId);
if(dbError.isValid())
Expand All @@ -66,7 +66,7 @@ Qx::Error CLink::perform()
if(std::holds_alternative<Fp::Game>(entry_v))
{
Fp::Game game = std::get<Fp::Game>(entry_v);
shortcutName = Qx::kosherizeFileName(game.title());
shortcutName = game.title();
}
else if(std::holds_alternative<Fp::AddApp>(entry_v))
{
Expand All @@ -82,38 +82,28 @@ Qx::Error CLink::perform()
Q_ASSERT(std::holds_alternative<Fp::Game>(entry_v));

Fp::Game parent = std::get<Fp::Game>(entry_v);
shortcutName = Qx::kosherizeFileName(parent.title() + u" ("_s + addApp.name() + u")"_s);
shortcutName = parent.title() + u" ("_s + addApp.name() + u")"_s;
}
else
qCritical("Invalid variant state for std::variant<Fp::Game, Fp::AddApp>.");

// Override shortcut name with user input
if(mParser.isSet(CL_OPTION_NAME))
shortcutName = mParser.value(CL_OPTION_NAME);

// Get shortcut path
if(mParser.isSet(CL_OPTION_PATH))
{
QFileInfo inputPathInfo(mParser.value(CL_OPTION_PATH));
if(inputPathInfo.suffix() == shortcutExtension()) // Path is file
{
mCore.logEvent(NAME, LOG_EVENT_FILE_PATH);
shortcutDir = inputPathInfo.absoluteDir();
shortcutName = inputPathInfo.baseName();
}
else // Path is directory
{
mCore.logEvent(NAME, LOG_EVENT_DIR_PATH);
shortcutDir = QDir(inputPathInfo.absoluteFilePath());
}
}
shortcutDir = mParser.value(CL_OPTION_PATH);
else
{
mCore.logEvent(NAME, LOG_EVENT_NO_PATH);

// Prompt user for path
Core::SaveFileRequest sfr{
Core::ExistingDirRequest edr{
.caption = DIAG_CAPTION,
.dir = QDir::homePath() + u"/Desktop/"_s + shortcutName,
.filter = u"Shortcuts (*. "_s + shortcutExtension() + u")"_s
.dir = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)
};
QString selectedPath = mCore.requestSaveFilePath(sfr);
QString selectedPath = mCore.requestExistingDirPath(edr);

if(selectedPath.isEmpty())
{
Expand All @@ -122,13 +112,8 @@ Qx::Error CLink::perform()
}
else
{
if(!selectedPath.endsWith(u"."_s + shortcutExtension(), Qt::CaseInsensitive))
selectedPath += u"."_s + shortcutExtension();

mCore.logEvent(NAME, LOG_EVENT_SEL_PATH.arg(QDir::toNativeSeparators(selectedPath)));
QFileInfo pathInfo(selectedPath);
shortcutDir = pathInfo.absoluteDir();
shortcutName = pathInfo.baseName();
shortcutDir = selectedPath;
}
}

Expand Down
14 changes: 7 additions & 7 deletions app/src/command/c-link.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ class CLink : public TitleCommand
static inline const QString DIAG_CAPTION = u"Select a shortcut destination..."_s;

// Logging - Messages
static inline const QString LOG_EVENT_FILE_PATH = u"Shortcut path provided is for a file"_s;
static inline const QString LOG_EVENT_DIR_PATH = u"Shortcut path provided is for a folder"_s;
static inline const QString LOG_EVENT_NO_PATH = u"No shortcut path provided, user will be prompted"_s;
static inline const QString LOG_EVENT_SEL_PATH = u"Shortcut path selected: %1"_s;
static inline const QString LOG_EVENT_DIAG_CANCEL = u"Shortcut path selection canceled."_s;
Expand All @@ -71,14 +69,17 @@ class CLink : public TitleCommand
// Command line option strings
static inline const QString CL_OPT_PATH_S_NAME = u"p"_s;
static inline const QString CL_OPT_PATH_L_NAME = u"path"_s;
static inline const QString CL_OPT_PATH_DESC = u"Path to new shortcut. Path's ending with "".lnk""//"".desktop"" will be interpreted as a named shortcut file. "
"Any other path will be interpreted as a directory and the title will automatically be used "
"as the filename"_s;
static inline const QString CL_OPT_PATH_DESC = u"Path to a directory for the new shortcut"_s;

static inline const QString CL_OPT_NAME_S_NAME = u"n"_s;
static inline const QString CL_OPT_NAME_L_NAME = u"name"_s;
static inline const QString CL_OPT_NAME_DESC = u"Name of the shortcut. Defaults to the name of the title"_s;

// Command line options
static inline const QCommandLineOption CL_OPTION_PATH{{CL_OPT_PATH_S_NAME, CL_OPT_PATH_L_NAME}, CL_OPT_PATH_DESC, u"path"_s}; // Takes value
static inline const QCommandLineOption CL_OPTION_NAME{{CL_OPT_NAME_S_NAME, CL_OPT_NAME_L_NAME}, CL_OPT_NAME_DESC, u"name"_s}; // Takes value

static inline const QList<const QCommandLineOption*> CL_OPTIONS_SPECIFIC{&CL_OPTION_PATH};
static inline const QList<const QCommandLineOption*> CL_OPTIONS_SPECIFIC{&CL_OPTION_PATH, &CL_OPTION_NAME};
static inline const QSet<const QCommandLineOption*> CL_OPTIONS_REQUIRED{};

public:
Expand All @@ -93,7 +94,6 @@ class CLink : public TitleCommand
//-Instance Functions------------------------------------------------------------------------------------------------------
private:
Qx::Error createShortcut(const QString& name, const QDir& dir, QUuid id);
QString shortcutExtension() const;

protected:
QList<const QCommandLineOption*> options() override;
Expand Down
5 changes: 1 addition & 4 deletions app/src/command/c-link_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ Qx::Error CLink::createShortcut(const QString& name, const QDir& dir, QUuid id)
ade.setComment(u"Generated by "_s PROJECT_SHORT_NAME " " PROJECT_VERSION_STR);

// Create entry
QString filename = u"org.flashpoint.clifp."_s + id.toString(QUuid::WithoutBraces) +
'.' + shortcutExtension();
QString filename = u"org.flashpoint.clifp."_s + id.toString(QUuid::WithoutBraces) + u".desktop"_s;
QString fullEntryPath = dir.absoluteFilePath(filename);
Qx::IoOpReport writeReport = Qx::DesktopEntry::writeToDisk(fullEntryPath, &ade);

Expand All @@ -51,5 +50,3 @@ Qx::Error CLink::createShortcut(const QString& name, const QDir& dir, QUuid id)
// Return success
return CLinkError();
}

QString CLink::shortcutExtension() const { return u"desktop"_s; };
6 changes: 3 additions & 3 deletions app/src/command/c-link_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
//Private:
Qx::Error CLink::createShortcut(const QString& name, const QDir& dir, QUuid id)
{
QString filename = Qx::kosherizeFileName(name);

// Create shortcut properties
Qx::ShortcutProperties sp;
sp.target = CLIFP_PATH;
sp.targetArgs = CPlay::NAME + u" -"_s + TitleCommand::CL_OPTION_ID.names().constFirst() + ' ' + id.toString(QUuid::WithoutBraces);
sp.comment = name;

// Create shortcut
QString fullShortcutPath = dir.absolutePath() + '/' + name + '.' + shortcutExtension();
QString fullShortcutPath = dir.absolutePath() + '/' + filename + u".lnk"_s;
Qx::SystemError shortcutError = Qx::createShortcut(fullShortcutPath, sp);

// Check for creation failure
Expand All @@ -38,5 +40,3 @@ Qx::Error CLink::createShortcut(const QString& name, const QDir& dir, QUuid id)
// Return success
return CLinkError();
}

QString CLink::shortcutExtension() const { return u"lnk"_s; };
2 changes: 1 addition & 1 deletion app/src/command/c-play.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class CPlay : public TitleCommand
public:
// Meta
static inline const QString NAME = u"play"_s;
static inline const QString DESCRIPTION = u"Launch a title and all of it's support applications, in the same manner as using the GUI"_s;
static inline const QString DESCRIPTION = u"Launch a game/animation"_s;

//-Constructor----------------------------------------------------------------------------------------------------------
public:
Expand Down
Loading

0 comments on commit 9319769

Please sign in to comment.