Skip to content

Commit

Permalink
feat: remove steam integration + most mod functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
craftablescience committed Jun 26, 2024
1 parent c13d36c commit 3500a15
Show file tree
Hide file tree
Showing 15 changed files with 104 additions and 330 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

91 changes: 12 additions & 79 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ include(GNUInstallDirs)

# Set up variables
set(PROJECT_NAME_PRETTY "SDK Launcher" CACHE STRING "" FORCE)
set(PROJECT_TARGET_NAME "SDKLauncher" CACHE STRING "" FORCE)

# Helper for creating enum options (pick between certain strings)
macro(option_enum)
Expand All @@ -29,11 +30,10 @@ endmacro()
# Options
option(SDK_LAUNCHER_USE_LTO "Build SDK Launcher with link-time optimization enabled" OFF)
option_enum(
NAME "SDK_LAUNCHER_DEFAULT_APPID"
DESCRIPTION "The default game AppID to use when not in the bin directory"
DEFAULT "440000"
OPTIONS "440000" "601360" "1802710")
# P2CE ^ REVO ^ MMOD ^
NAME "SDK_LAUNCHER_DEFAULT_MOD"
DESCRIPTION "The default game folder to use"
DEFAULT "p2ce"
OPTIONS "p2ce" "revolution" "momentum")

# Global CMake options
if(PROJECT_IS_TOP_LEVEL)
Expand Down Expand Up @@ -96,7 +96,7 @@ function(sdk_launcher_configure_target TARGET)
# Don't show the console when running the executable
if(MSVC AND TARGET_IS_GUI)
target_link_options(
${PROJECT_NAME} PRIVATE
${TARGET} PRIVATE
"/ENTRY:mainCRTStartup")
endif()
endif()
Expand All @@ -116,14 +116,6 @@ if(DEFINED QT_BASEDIR)
message(STATUS "Using ${QT_INCLUDE} as the Qt include directory")
endif()

if(WIN32)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(QT_LIB_SUFFIX "d" CACHE STRING "" FORCE)
else()
set(QT_LIB_SUFFIX "" CACHE STRING "" FORCE)
endif()
endif()

# CMake has an odd policy that links a special link lib for Qt on newer versions of CMake
cmake_policy(SET CMP0020 NEW)

Expand All @@ -133,89 +125,30 @@ set(CMAKE_AUTORCC ON)

find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)

# SAPP
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/ext/sapp")

# Generate config header
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/Config.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/src/Config.h")

# Add sources and create executable
list(APPEND ${PROJECT_NAME}_SOURCES
# Create executable
add_executable(${PROJECT_TARGET_NAME} WIN32
"${CMAKE_CURRENT_SOURCE_DIR}/res/res.qrc"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Config.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/GameConfig.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/GameConfig.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/GameFinder.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/GameFinder.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Main.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Window.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Window.h")

add_executable(${PROJECT_NAME} WIN32 ${${PROJECT_NAME}_SOURCES})

sdk_launcher_configure_target(${PROJECT_NAME})
sdk_launcher_configure_target(${PROJECT_TARGET_NAME})

target_link_libraries(
${PROJECT_NAME} PRIVATE
${PROJECT_TARGET_NAME} PRIVATE
Qt::Core
Qt::Gui
Qt::Widgets
SAPP)
Qt::Widgets)

target_include_directories(
${PROJECT_NAME} PRIVATE
${PROJECT_TARGET_NAME} PRIVATE
"${QT_INCLUDE}"
"${QT_INCLUDE}/QtCore"
"${QT_INCLUDE}/QtGui"
"${QT_INCLUDE}/QtWidgets")

# Copy these so the user doesn't have to
if(WIN32)
configure_file("${QT_BASEDIR}/bin/Qt6Core${QT_LIB_SUFFIX}.dll" "${CMAKE_BINARY_DIR}/Qt6Core${QT_LIB_SUFFIX}.dll" COPYONLY)
configure_file("${QT_BASEDIR}/bin/Qt6Gui${QT_LIB_SUFFIX}.dll" "${CMAKE_BINARY_DIR}/Qt6Gui${QT_LIB_SUFFIX}.dll" COPYONLY)
configure_file("${QT_BASEDIR}/bin/Qt6Widgets${QT_LIB_SUFFIX}.dll" "${CMAKE_BINARY_DIR}/Qt6Widgets${QT_LIB_SUFFIX}.dll" COPYONLY)

configure_file("${QT_BASEDIR}/plugins/imageformats/qjpeg${QT_LIB_SUFFIX}.dll" "${CMAKE_BINARY_DIR}/imageformats/qjpeg${QT_LIB_SUFFIX}.dll" COPYONLY)
configure_file("${QT_BASEDIR}/plugins/imageformats/qtga${QT_LIB_SUFFIX}.dll" "${CMAKE_BINARY_DIR}/imageformats/qtga${QT_LIB_SUFFIX}.dll" COPYONLY)

configure_file("${QT_BASEDIR}/plugins/platforms/qwindows${QT_LIB_SUFFIX}.dll" "${CMAKE_BINARY_DIR}/platforms/qwindows${QT_LIB_SUFFIX}.dll" COPYONLY)

configure_file("${QT_BASEDIR}/plugins/styles/qwindowsvistastyle${QT_LIB_SUFFIX}.dll" "${CMAKE_BINARY_DIR}/styles/qwindowsvistastyle${QT_LIB_SUFFIX}.dll" COPYONLY)
elseif(UNIX AND DEFINED QT_BASEDIR)
configure_file("${QT_BASEDIR}/lib/libQt6Core.so.6" "${CMAKE_BINARY_DIR}/libQt6Core.so.6" COPYONLY)
configure_file("${QT_BASEDIR}/lib/libQt6Gui.so.6" "${CMAKE_BINARY_DIR}/libQt6Gui.so.6" COPYONLY)
configure_file("${QT_BASEDIR}/lib/libQt6Widgets.so.6" "${CMAKE_BINARY_DIR}/libQt6Widgets.so.6" COPYONLY)

# Required by plugins
configure_file("${QT_BASEDIR}/lib/libicudata.so.56" "${CMAKE_BINARY_DIR}/libicudata.so.56" COPYONLY)
configure_file("${QT_BASEDIR}/lib/libicui18n.so.56" "${CMAKE_BINARY_DIR}/libicui18n.so.56" COPYONLY)
configure_file("${QT_BASEDIR}/lib/libicuuc.so.56" "${CMAKE_BINARY_DIR}/libicuuc.so.56" COPYONLY)
configure_file("${QT_BASEDIR}/lib/libQt6DBus.so.6" "${CMAKE_BINARY_DIR}/libQt6DBus.so.6" COPYONLY)
configure_file("${QT_BASEDIR}/lib/libQt6EglFSDeviceIntegration.so.6" "${CMAKE_BINARY_DIR}/libQt6EglFSDeviceIntegration.so.6" COPYONLY)
configure_file("${QT_BASEDIR}/lib/libQt6EglFsKmsSupport.so.6" "${CMAKE_BINARY_DIR}/libQt6EglFsKmsSupport.so.6" COPYONLY)
configure_file("${QT_BASEDIR}/lib/libQt6WaylandClient.so.6" "${CMAKE_BINARY_DIR}/libQt6WaylandClient.so.6" COPYONLY)
configure_file("${QT_BASEDIR}/lib/libQt6WaylandEglClientHwIntegration.so.6" "${CMAKE_BINARY_DIR}/libQt6WaylandEglClientHwIntegration.so.6" COPYONLY)
configure_file("${QT_BASEDIR}/lib/libQt6WlShellIntegration.so.6" "${CMAKE_BINARY_DIR}/libQt6WlShellIntegration.so.6" COPYONLY)
configure_file("${QT_BASEDIR}/lib/libQt6XcbQpa.so.6" "${CMAKE_BINARY_DIR}/libQt6XcbQpa.so.6" COPYONLY)

configure_file("${QT_BASEDIR}/plugins/imageformats/libqjpeg.so" "${CMAKE_BINARY_DIR}/imageformats/libqjpeg.so" COPYONLY)
configure_file("${QT_BASEDIR}/plugins/imageformats/libqtga.so" "${CMAKE_BINARY_DIR}/imageformats/libqtga.so" COPYONLY)

# Copy all this stuff wholesale, who knows if we need it now or later
file(GLOB ${PROJECT_NAME}_QT_PLUGINS_EGLDEVICEINTEGRATIONS "${QT_BASEDIR}/plugins/egldeviceintegrations/*.so*")
file(GLOB ${PROJECT_NAME}_QT_PLUGINS_PLATFORMINPUTCONTEXTS "${QT_BASEDIR}/plugins/platforminputcontexts/*.so*")
file(GLOB ${PROJECT_NAME}_QT_PLUGINS_PLATFORMS "${QT_BASEDIR}/plugins/platforms/*.so*")
file(GLOB ${PROJECT_NAME}_QT_PLUGINS_PLATFORMTHEMES "${QT_BASEDIR}/plugins/platformthemes/*.so*")
file(GLOB ${PROJECT_NAME}_QT_PLUGINS_WAYLANDDECORATIONCLIENT "${QT_BASEDIR}/plugins/wayland-decoration-client/*.so*")
file(GLOB ${PROJECT_NAME}_QT_PLUGINS_WAYLANDGRAPHICSINTEGRATIONCLIENT "${QT_BASEDIR}/plugins/wayland-graphics-integration-client/*.so*")
file(GLOB ${PROJECT_NAME}_QT_PLUGINS_WAYLANDSHELLINTEGRATION "${QT_BASEDIR}/plugins/wayland-shell-integration/*.so*")
file(GLOB ${PROJECT_NAME}_QT_PLUGINS_XCBGLINTEGRATIONS "${QT_BASEDIR}/plugins/xcbglintegrations/*.so*")
file(COPY ${${PROJECT_NAME}_QT_PLUGINS_EGLDEVICEINTEGRATIONS} DESTINATION "${CMAKE_BINARY_DIR}/egldeviceintegrations")
file(COPY ${${PROJECT_NAME}_QT_PLUGINS_PLATFORMINPUTCONTEXTS} DESTINATION "${CMAKE_BINARY_DIR}/platforminputcontexts")
file(COPY ${${PROJECT_NAME}_QT_PLUGINS_PLATFORMS} DESTINATION "${CMAKE_BINARY_DIR}/platforms")
file(COPY ${${PROJECT_NAME}_QT_PLUGINS_PLATFORMTHEMES} DESTINATION "${CMAKE_BINARY_DIR}/platformthemes")
file(COPY ${${PROJECT_NAME}_QT_PLUGINS_WAYLANDDECORATIONCLIENT} DESTINATION "${CMAKE_BINARY_DIR}/wayland-decoration-client")
file(COPY ${${PROJECT_NAME}_QT_PLUGINS_WAYLANDGRAPHICSINTEGRATIONCLIENT} DESTINATION "${CMAKE_BINARY_DIR}/wayland-graphics-integration-client")
file(COPY ${${PROJECT_NAME}_QT_PLUGINS_WAYLANDSHELLINTEGRATION} DESTINATION "${CMAKE_BINARY_DIR}/wayland-shell-integration")
file(COPY ${${PROJECT_NAME}_QT_PLUGINS_XCBGLINTEGRATIONS} DESTINATION "${CMAKE_BINARY_DIR}/xcbglintegrations")
endif()
29 changes: 10 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,24 @@ the executable to `bin/win64` or `bin/linux64` (depending on your OS).

### Default Config

If you are working on a mod and would like to use this SDK launcher for your mod,
you can create a config called `sdk_launcher_default.json` and place it next to the
SDK launcher executable. It will load this config file when the config history is
clean, so anyone running this application for the first time will load your mod's
provided config immediately. Alternatively, if you'd rather not ship this application
with your mod, simply ship the config and tell your developers to load it.
If you would like to modify the config loaded at startup, create a config next to
the SDK launcher executable called `SDKLauncherDefault.json`. The SDK launcher will
load this config file instead of the internal config.

### Config Format

Here is an example config file that may be imported into the SDK launcher.
Here is an example config file that may be loaded into the SDK launcher.

**Comments are added for clarity, but they are NOT allowed in actual configs!**

```json5
{
// Type can be "steam" or "custom".
"type": "steam",
// If the type is "steam", it will look for the AppId of the app here,
// as well as automatically fill out the root path.
"appid": "440000",
// If the type is "custom", rather than have an AppId, it just has the
// path to the root of the game/mod here. This path is allowed to be relative.
"root": ".",
// To be clear, if the type is steam, appid is required but root should not be
// present. If the type is custom, appid should not be present, but root should be.
// You will most likely use the custom type.

// The name of the game directory
"game": "p2ce",
// Optional, the default is game.ico (searches in the <game>/resource/ directory)
"game_icon": "game.ico",
// Optional, the default is false (set this to true if the SDK launcher is inside bin/ instead of bin/<platform>/)
"uses_legacy_bin_dir": false,
// Sections hold titled groups of buttons
"sections": [
{
Expand Down
1 change: 0 additions & 1 deletion ext/sapp
Submodule sapp deleted from 1e510b
3 changes: 1 addition & 2 deletions res/config/1802710.json → res/config/momentum.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"type": "steam",
"appid": "1802710",
"game": "momentum",
"sections": [
{
"name": "Game",
Expand Down
3 changes: 1 addition & 2 deletions res/config/440000.json → res/config/p2ce.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"type": "steam",
"appid": "440000",
"game": "p2ce",
"sections": [
{
"name": "Game",
Expand Down
29 changes: 22 additions & 7 deletions res/config/601360.json → res/config/revolution.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"type": "steam",
"appid": "601360",
"game": "revolution",
"sections": [
{
"name": "Game",
Expand All @@ -9,14 +8,21 @@
"name": "Portal: Revolution - Dev Mode",
"type": "command",
"action": "${ROOT}/bin/${PLATFORM}/revolution",
"arguments": ["-dev", "-console"],
"arguments": [
"-dev",
"-console"
],
"icon_override": "${GAME_ICON}"
},
{
"name": "Portal: Revolution - Dev && Tools Mode",
"type": "command",
"action": "${ROOT}/bin/${PLATFORM}/revolution",
"arguments": ["-dev", "-console", "-tools"],
"arguments": [
"-dev",
"-console",
"-tools"
],
"icon_override": "${GAME_ICON}"
}
]
Expand All @@ -28,21 +34,30 @@
"name": "Hammer Editor",
"type": "command",
"action": "${ROOT}/bin/win64/hammer",
"arguments": ["-game", "revolution"],
"arguments": [
"-game",
"revolution"
],
"os": "windows"
},
{
"name": "Model Viewer",
"type": "command",
"action": "${ROOT}/bin/win64/hlmv",
"arguments": ["-game", "revolution"],
"arguments": [
"-game",
"revolution"
],
"os": "windows"
},
{
"name": "Face Poser",
"type": "command",
"action": "${ROOT}/bin/win64/hlfaceposer",
"arguments": ["-game", "revolution"],
"arguments": [
"-game",
"revolution"
],
"os": "windows"
}
]
Expand Down
6 changes: 3 additions & 3 deletions res/res.qrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<RCC>
<qresource prefix="/">
<file>config/440000.json</file>
<file>config/601360.json</file>
<file>config/1802710.json</file>
<file>config/momentum.json</file>
<file>config/p2ce.json</file>
<file>config/revolution.json</file>

<file>icons/strata_dark.png</file>
<file>icons/strata_light.png</file>
Expand Down
10 changes: 5 additions & 5 deletions src/Config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <string_view>

constexpr std::string_view PROJECT_NAME = "${PROJECT_NAME_PRETTY}";
constexpr std::string_view PROJECT_VERSION = "${PROJECT_VERSION}";
constexpr std::string_view PROJECT_HOMEPAGE = "${PROJECT_HOMEPAGE_URL}";
constexpr std::string_view PROJECT_TITLE = "${PROJECT_NAME_PRETTY} v${PROJECT_VERSION}";
constexpr unsigned int PROJECT_DEFAULT_APPID = ${SDK_LAUNCHER_DEFAULT_APPID};
constexpr std::string_view PROJECT_NAME = "${PROJECT_NAME_PRETTY}";
constexpr std::string_view PROJECT_VERSION = "${PROJECT_VERSION}";
constexpr std::string_view PROJECT_HOMEPAGE = "${PROJECT_HOMEPAGE_URL}";
constexpr std::string_view PROJECT_TITLE = "${PROJECT_NAME_PRETTY} v${PROJECT_VERSION}";
constexpr std::string_view PROJECT_DEFAULT_MOD = "${SDK_LAUNCHER_DEFAULT_MOD}";
25 changes: 9 additions & 16 deletions src/GameConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <QJsonDocument>
#include <QJsonObject>

#include "GameFinder.h"

GameConfig::ActionType GameConfig::actionTypeFromString(const QString& string) {
using enum ActionType;
if (string == "command") {
Expand Down Expand Up @@ -52,24 +50,19 @@ std::optional<GameConfig> GameConfig::parse(const QString& path) {

GameConfig gameConfig;

if (!configObject.contains("type") || !configObject["type"].isString()) {
if (!configObject.contains("game") || !configObject["game"].isString()) {
return std::nullopt;
}
auto configType = configObject["type"].toString();
gameConfig.game = configObject["game"].toString();

if (configType == "steam") {
if (!configObject.contains("appid") || !configObject["appid"].isString()) {
return std::nullopt;
}
gameConfig.appId = configObject["appid"].toString().toUInt();
gameConfig.root = GameFinder::getGameInstallPath(gameConfig.appId);
} else if (configType == "custom") {
if (!configObject.contains("root") || !configObject["root"].isString()) {
return std::nullopt;
}
gameConfig.root = configObject["root"].toString();
if (configObject.contains("game_icon") && configObject["game_icon"].isString()) {
gameConfig.gameIcon = configObject["game_icon"].toString();
} else {
return std::nullopt;
gameConfig.gameIcon = "game.ico";
}

if (configObject.contains("uses_legacy_bin_dir") && configObject["uses_legacy_bin_dir"].isBool()) {
gameConfig.usesLegacyBinDir = configObject["uses_legacy_bin_dir"].toBool();
}

if (!configObject.contains("sections") || !configObject["sections"].isArray()) {
Expand Down
11 changes: 7 additions & 4 deletions src/GameConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ class GameConfig {

[[nodiscard]] static std::optional<GameConfig> parse(const QString& path);

[[nodiscard]] const QString& getRoot() const { return this->root; }
[[nodiscard]] const QString& getGame() const { return this->game; }

[[nodiscard]] unsigned int getAppId() const { return this->appId; }
[[nodiscard]] const QString& getGameIcon() const { return this->gameIcon; }

[[nodiscard]] bool getUsesLegacyBinDir() const { return this->usesLegacyBinDir; }

[[nodiscard]] const QList<Section>& getSections() const { return this->sections; }

private:
QString root;
unsigned int appId = 0;
QString game;
QString gameIcon;
bool usesLegacyBinDir = false;
QList<Section> sections;

GameConfig() = default;
Expand Down
Loading

0 comments on commit 3500a15

Please sign in to comment.