Skip to content

Commit

Permalink
Version 2.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ersh1 committed Sep 7, 2024
1 parent 626c826 commit 135c30d
Show file tree
Hide file tree
Showing 25 changed files with 621 additions and 402 deletions.
14 changes: 14 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: ershin
open_collective: # Replace with a single Open Collective username
ko_fi: ershin
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
150 changes: 150 additions & 0 deletions .github/workflows/build-variant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: Build variant

on:
workflow_call:
inputs:
GIT_BRANCH:
type: string
GIT_COMMON_LIB_BRANCH:
type: string
CMAKE_PROJECT_DIR:
type: string
required: true
CMAKE_CONFIG_PRESET:
type: string
required: true
CMAKE_BUILD_PRESET:
type: string
required: true
CMAKE_CONFIG:
type: string
required: true
BINARY_DIR:
type: string
required: true
BINARY_NAME:
type: string
required: true
BINARY_NAME_VAR:
type: string
required: true
BINARY_VERSION:
type: string
required: true
BINARY_VERSION_VAR:
type: string
required: true
TARGET_DIR:
type: string
required: true
VARIANT:
type: string
required: true
VCPKG_COMMIT_ID:
type: string
required: true
secrets:
GIT_SSH_KEY:
required: false
outputs:
ARTIFACT_NAME:
value: ${{ jobs.build.outputs.ARTIFACT_NAME }}
PRODUCT_NAME:
value: ${{ jobs.build.outputs.PRODUCT_NAME }}
PRODUCT_VERSION:
value: ${{ jobs.build.outputs.PRODUCT_VERSION }}
BINARY_NAME:
value: ${{ jobs.build.outputs.BINARY_NAME }}

env:
COMMON_LIB_SSE_NAME: CommonLibSSE
COMMON_LIB_VR_NAME: CommonLibVR

jobs:
build:
runs-on: windows-latest
outputs:
ARTIFACT_NAME: ${{ steps.export.outputs.ARTIFACT_NAME }}
BINARY_NAME: ${{ steps.export.outputs.BINARY_NAME }}
PRODUCT_NAME: ${{ steps.export.outputs.PRODUCT_NAME }}
PRODUCT_VERSION: ${{ steps.export.outputs.PRODUCT_VERSION }}

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.GIT_BRANCH }}
ssh-key: ${{ secrets.GIT_SSH_KEY }}
submodules: recursive
fetch-depth: 0

- name: Use CommonLib 1.6.353
if: inputs.GIT_COMMON_LIB_BRANCH != ''
shell: pwsh
run: |
$CLibSSEName = git submodule | Select-String -Pattern ${{ env.COMMON_LIB_SSE_NAME }} | %{[string]$_} | %{$_.Split(" ")[2]}
If ([string]::IsNullOrEmpty($CLibSSEName)) { return }
cd "$CLibSSEName"
git fetch
git checkout ${{inputs.GIT_COMMON_LIB_BRANCH}}
- name: Restore artifacts, or setup vcpkg (do not install any package)
uses: lukka/run-vcpkg@v11
id: runvcpkg
with:
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
vcpkgGitCommitId: '${{ inputs.VCPKG_COMMIT_ID }}'
vcpkgJsonGlob: './${{inputs.CMAKE_PROJECT_DIR}}/vcpkg.json'

- name: Configure CMake
shell: pwsh
run: cmake --preset ${{inputs.CMAKE_CONFIG_PRESET}}

- name: Run CMake with build config
if: inputs.CMAKE_BUILD_PRESET != ''
shell: pwsh
run: cmake --build --preset ${{inputs.CMAKE_BUILD_PRESET}}

- name: Run CMake
if: inputs.CMAKE_BUILD_PRESET == ''
shell: pwsh
run: cmake --build ${{inputs.BINARY_DIR}} --config ${{inputs.CMAKE_CONFIG}}

- id: export
shell: pwsh
run: |
$PRODUCT_NAME = If (![string]::IsNullOrEmpty("${{inputs.BINARY_NAME}}")) {"${{inputs.BINARY_NAME}}"} Else { cmake -L -N ${{inputs.BINARY_DIR}} | grep "${{inputs.BINARY_NAME_VAR}}" | %{$_ -replace "${{inputs.BINARY_NAME_VAR}}:STRING=",""} }
$PRODUCT_VERSION = If (![string]::IsNullOrEmpty("${{inputs.BINARY_VERSION}}")) {"${{inputs.BINARY_VERSION}}"} Else { cmake -L -N ${{inputs.BINARY_DIR}} | grep "^${{inputs.BINARY_VERSION_VAR}}" | %{$_ -replace "${{inputs.BINARY_VERSION_VAR}}:STRING=",""} }
$PRODUCTS_DIR = "${{inputs.TARGET_DIR}}/${{inputs.CMAKE_PROJECT_DIR}}/${{inputs.CMAKE_CONFIG}}"
$BINARY_NAME = "$PRODUCT_NAME.dll"
$BINARY_PATH = "$PRODUCTS_DIR/$BINARY_NAME"
$PDB_NAME = "$PRODUCT_NAME.pdb"
$PDB_PATH = "$PRODUCTS_DIR/$PDB_NAME"
$MARKETING_SUFFIX = "${{inputs.VARIANT}}".ToUpper()
$BUILD_TYPE = "${{inputs.CMAKE_CONFIG}}"
$ARTIFACT_NAME = "$PRODUCT_NAME $MARKETING_SUFFIX $BUILD_TYPE"
echo "PRODUCT_NAME=$PRODUCT_NAME" >> $Env:GITHUB_OUTPUT
echo "PRODUCT_VERSION=$PRODUCT_VERSION" >> $Env:GITHUB_OUTPUT
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $Env:GITHUB_OUTPUT
echo "BINARY_PATH=$BINARY_PATH" >> $Env:GITHUB_OUTPUT
echo "BINARY_NAME=$BINARY_NAME" >> $Env:GITHUB_OUTPUT
echo "PDB_PATH=$PDB_PATH" >> $Env:GITHUB_OUTPUT
echo "PDB_NAME=$PDB_NAME" >> $Env:GITHUB_OUTPUT
echo "Built $BINARY_NAME ✅"
echo "Location: $BINARY_PATH"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.export.outputs.ARTIFACT_NAME }}
if-no-files-found: error
path: |
${{ steps.export.outputs.BINARY_PATH }}
${{ steps.export.outputs.PDB_PATH }}
27 changes: 27 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Main

on:
push:
branches: '**'
tags: '*'

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
run:
uses: ./.github/workflows/build-variant.yml
with:
CMAKE_PROJECT_DIR: ''
CMAKE_CONFIG_PRESET: "github-actions"
CMAKE_BUILD_PRESET: ''
CMAKE_CONFIG: "Release"
BINARY_DIR: "build"
BINARY_NAME: ''
BINARY_NAME_VAR: "NAME"
BINARY_VERSION: ''
BINARY_VERSION_VAR: "VERSION"
TARGET_DIR: "build/src"
VARIANT: "ng"
VCPKG_COMMIT_ID: "a7d99a5c3cd1456af023051d025a5643a2d6e79c"
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "extern/GreenSock-AS2"]
path = extern/GreenSock-AS2
url = https://github.com/greensock/GreenSock-AS2
[submodule "extern/CommonLibSSE"]
path = extern/CommonLibSSE
url = https://github.com/alandtse/CommonLibVR.git
branch = ng
21 changes: 14 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
cmake_minimum_required(VERSION 3.22)

set(NAME "TrueDirectionalMovement" CACHE STRING "")
set(VERSION 2.2.6 CACHE STRING "")

project(
TrueDirectionalMovement
VERSION 2.2.5
${NAME}
VERSION ${VERSION}
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_compile_definitions(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)

if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
message(FATAL_ERROR "in-source builds are not allowed")
endif()
Expand All @@ -17,17 +22,19 @@ macro(set_from_environment VARIABLE)
endif()
endmacro()

set_from_environment(CompiledPluginsPath)
if(NOT DEFINED CompiledPluginsPath)
message(FATAL_ERROR "CompiledPluginsPath is not set")
endif()

option(COPY_OUTPUT "Copy the output of build operations to the game directory" ON)
option(ENABLE_SKYRIM_SE "Enable support for Skyrim SE in the dynamic runtime feature." ON)
option(ENABLE_SKYRIM_AE "Enable support for Skyrim AE in the dynamic runtime feature." ON)
option(ENABLE_SKYRIM_VR "Enable support for Skyrim VR in the dynamic runtime feature." OFF)
set(BUILD_TESTS OFF)

if (COPY_OUTPUT)
set_from_environment(CompiledPluginsPath)
if(NOT DEFINED CompiledPluginsPath)
message(FATAL_ERROR "CompiledPluginsPath is not set")
endif()
endif()

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

add_subdirectory(src)
Expand Down
7 changes: 7 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
],
"name": "vs2022-windows",
"toolset": "v143"
},
{
"cacheVariables": {
"COPY_OUTPUT": "OFF"
},
"inherits": "vs2022-windows",
"name": "github-actions"
}
],
"version": 3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Add the environment variable `VCPKG_ROOT` with the value as the path to the folder containing vcpkg
* [Visual Studio Community 2022](https://visualstudio.microsoft.com/)
* Desktop development with C++
* [CommonLibSSE-NG](https://github.com/CharmedBaryon/CommonLibSSE-NG/tree/v3.4.0)
* [CommonLibSSE-NG](https://github.com/alandtse/CommonLibVR/tree/ng))
* Add the environment variable `CommonLibSSEPath_NG` with the value as the path to the folder containing CommonLibSSE-NG

## User Requirements
Expand Down
44 changes: 44 additions & 0 deletions src/API/APIManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "APIManager.h"

#include "DirectionalMovementHandler.h"

void APIs::RequestAPIs()
{
if (!DodgeFramework) {
DodgeFramework = reinterpret_cast<DODGEFRAMEWORK_API::IVDodgeFramework1*>(DODGEFRAMEWORK_API::RequestPluginAPI(DODGEFRAMEWORK_API::InterfaceVersion::V1));
if (DodgeFramework) {
logger::info("Obtained Dodge Framework API - {0:x}", reinterpret_cast<uintptr_t>(DodgeFramework));
} else {
logger::warn("Failed to obtain Dodge Framework API");
}
}

if (!SmoothCam) {
if (!SmoothCamAPI::RegisterInterfaceLoaderCallback(SKSE::GetMessagingInterface(),
[](void* interfaceInstance, SmoothCamAPI::InterfaceVersion interfaceVersion) {
if (interfaceVersion == SmoothCamAPI::InterfaceVersion::V3) {
SmoothCam = reinterpret_cast<SmoothCamAPI::IVSmoothCam3*>(interfaceInstance);
logger::info("Obtained SmoothCamAPI");
} else {
logger::error("Unable to acquire requested SmoothCamAPI interface version");
}
})) {
logger::warn("SmoothCamAPI::RegisterInterfaceLoaderCallback reported an error");
}

if (!SmoothCamAPI::RequestInterface(
SKSE::GetMessagingInterface(),
SmoothCamAPI::InterfaceVersion::V3)) {
logger::warn("SmoothCamAPI::RequestInterface reported an error");
}
}

if (!TrueHUD) {
TrueHUD = reinterpret_cast<TRUEHUD_API::IVTrueHUD3*>(TRUEHUD_API::RequestPluginAPI(TRUEHUD_API::InterfaceVersion::V3));
if (TrueHUD) {
logger::info("Obtained TrueHUD API - {0:x}", reinterpret_cast<uintptr_t>(TrueHUD));
} else {
logger::warn("Failed to obtain TrueHUD API");
}
}
}
14 changes: 14 additions & 0 deletions src/API/APIManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include "API/DodgeFrameworkAPI.h"
#include "API/SmoothCamAPI.h"
#include "API/TrueHUDAPI.h"

struct APIs
{
static inline SmoothCamAPI::IVSmoothCam3* SmoothCam = nullptr;
static inline DODGEFRAMEWORK_API::IVDodgeFramework1* DodgeFramework = nullptr;
static inline TRUEHUD_API::IVTrueHUD3* TrueHUD = nullptr;

static void RequestAPIs();
};
40 changes: 40 additions & 0 deletions src/API/DodgeFrameworkAPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once

/*
* For modders: Copy this file into your own project if you wish to use this API
*/
namespace DODGEFRAMEWORK_API
{
constexpr const auto DodgeFrameworkPluginName = "DodgeFramework";

// Available Dodge Framework interface versions
enum class InterfaceVersion : uint8_t
{
V1
};

// Dodge Framework's modder interface
class IVDodgeFramework1
{
public:
// just a stub, API is WIP
};

typedef void* (*_RequestPluginAPI)(const InterfaceVersion interfaceVersion);

/// <summary>
/// Request the Dodge Framework API interface.
/// Recommended: Send your request when you need to use the API and cache the pointer. SKSEMessagingInterface::kMessage_PostLoad seems to be unreliable for some users for unknown reasons.
/// </summary>
/// <param name="a_interfaceVersion">The interface version to request</param>
/// <returns>The pointer to the API singleton, or nullptr if request failed</returns>
[[nodiscard]] inline void* RequestPluginAPI(const InterfaceVersion a_interfaceVersion = InterfaceVersion::V1)
{
auto pluginHandle = GetModuleHandleA("DodgeFramework.dll");
_RequestPluginAPI requestAPIFunction = (_RequestPluginAPI)GetProcAddress(pluginHandle, "RequestPluginAPI");
if (requestAPIFunction) {
return requestAPIFunction(a_interfaceVersion);
}
return nullptr;
}
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 135c30d

Please sign in to comment.