Compare commits
No commits in common. "512842bfa5eca7b7678ff5fcc93d0fcefff477e7" and "7d152b61585363567baca8b6d3e02915a902121f" have entirely different histories.
512842bfa5
...
7d152b6158
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -8,10 +8,8 @@
|
|||||||
*.strings filter= diff= merge= -text
|
*.strings filter= diff= merge= -text
|
||||||
*.gitignore filter= diff= merge= text eol=lf
|
*.gitignore filter= diff= merge= text eol=lf
|
||||||
*.gitattributes filter= diff= merge= text eol=lf
|
*.gitattributes filter= diff= merge= text eol=lf
|
||||||
*.cmake filter= diff= merge= text eol=lf
|
|
||||||
*.xml filter= diff= merge= text eol=lf
|
*.xml filter= diff= merge= text eol=lf
|
||||||
*.json filter= diff= merge= text eol=lf
|
*.json filter= diff= merge= text eol=lf
|
||||||
*.in filter= diff= merge= text eol=crlf
|
|
||||||
*.md filter= diff= merge= text eol=crlf
|
*.md filter= diff= merge= text eol=crlf
|
||||||
*.ini filter= diff= merge= text eol=crlf
|
*.ini filter= diff= merge= text eol=crlf
|
||||||
*.txt filter= diff= merge= text eol=crlf
|
*.txt filter= diff= merge= text eol=crlf
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
ShowWarningOnInitFail = true
|
ShowWarningOnInitFail = true
|
||||||
SendAchievementsToLE = false
|
SendAchievementsToLE = false
|
||||||
TestMode = false
|
TestMode = true
|
||||||
ReloadSteamClient = true
|
|
||||||
|
|||||||
BIN
source/Enderal DLL/cmake/patch_directxtk.cmake
(Stored with Git LFS)
BIN
source/Enderal DLL/cmake/patch_directxtk.cmake
(Stored with Git LFS)
Binary file not shown.
BIN
source/Enderal DLL/cmake/version.rc.in
(Stored with Git LFS)
BIN
source/Enderal DLL/cmake/version.rc.in
(Stored with Git LFS)
Binary file not shown.
BIN
source/Enderal DLL/cmake/write_user_presets.cmake
(Stored with Git LFS)
BIN
source/Enderal DLL/cmake/write_user_presets.cmake
(Stored with Git LFS)
Binary file not shown.
3
source/Steam DLL/.gitignore
vendored
3
source/Steam DLL/.gitignore
vendored
@ -533,9 +533,6 @@ FodyWeavers.xsd
|
|||||||
|
|
||||||
build/
|
build/
|
||||||
|
|
||||||
# Machine-specific, generated by build.cmd - see cmake/write_user_presets.cmake
|
|
||||||
CMakeUserPresets.json
|
|
||||||
|
|
||||||
contrib/Distribution/**/*.dll
|
contrib/Distribution/**/*.dll
|
||||||
contrib/Distribution/**/*.pdb
|
contrib/Distribution/**/*.pdb
|
||||||
contrib/Distribution/**/*.pex
|
contrib/Distribution/**/*.pex
|
||||||
|
|||||||
@ -1,58 +1,31 @@
|
|||||||
|
option(ENABLE_VCPKG OFF)
|
||||||
cmake_minimum_required(VERSION 3.21)
|
cmake_minimum_required(VERSION 3.21)
|
||||||
|
message("Using toolchain file ${CMAKE_TOOLCHAIN_FILE}.")
|
||||||
|
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
## Define project
|
## Define project
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
|
|
||||||
# Get current version
|
|
||||||
set(ENDERAL_VERSION_INI "${CMAKE_CURRENT_SOURCE_DIR}/../../SKSE/Plugins/EnderalVersion.ini")
|
|
||||||
file(READ "${ENDERAL_VERSION_INI}" CONFIG_CONTENT)
|
|
||||||
string(REGEX MATCH "version[ \t]*=[ \t]*([0-9.]+)" _ ${CONFIG_CONTENT})
|
|
||||||
set(VERSION_NUMBER "${CMAKE_MATCH_1}")
|
|
||||||
|
|
||||||
# file(READ) does not register a dependency: without this, bumping the version in
|
|
||||||
# the INI would not re-run CMake and the DLL would keep the previous version.
|
|
||||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${ENDERAL_VERSION_INI}")
|
|
||||||
|
|
||||||
project(
|
project(
|
||||||
EnderalSteam
|
EnderalSteam
|
||||||
VERSION ${VERSION_NUMBER}
|
VERSION 2.1.4
|
||||||
DESCRIPTION "Enderal SE Steam Support"
|
DESCRIPTION "Enderal SE Steam Support"
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX)
|
||||||
)
|
|
||||||
|
|
||||||
# Shown as ProductName in the version resource.
|
|
||||||
set(PROJECT_FRIENDLY_NAME "Enderal SE")
|
|
||||||
|
|
||||||
# The binary FILEVERSION/PRODUCTVERSION fields need all four components;
|
|
||||||
# PROJECT_VERSION_TWEAK is empty when the INI carries only three.
|
|
||||||
if(NOT PROJECT_VERSION_TWEAK)
|
|
||||||
set(PROJECT_VERSION_TWEAK 0)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
|
||||||
# Link-time optimization for release builds only (debug builds stay fast).
|
|
||||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
|
|
||||||
|
|
||||||
# CommonLibSSE-NG requires the dynamic CRT. Dependencies used to be supplied by
|
|
||||||
# vcpkg (which set this via a preset); now that they come from FetchContent we
|
|
||||||
# set it here so both build.cmd and Visual Studio "Open Folder" pick it up.
|
|
||||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
|
||||||
|
|
||||||
add_compile_definitions(NOMINMAX _USE_MATH_DEFINES WIN32_LEAN_AND_MEAN)
|
add_compile_definitions(NOMINMAX _USE_MATH_DEFINES WIN32_LEAN_AND_MEAN)
|
||||||
add_definitions(-DUNICODE -D_UNICODE)
|
add_definitions(-DUNICODE -D_UNICODE)
|
||||||
add_compile_options(/Zc:preprocessor /EHsc)
|
add_compile_options(/Zc:preprocessor /EHsc)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/version.rc
|
${CMAKE_CURRENT_BINARY_DIR}/version.rc
|
||||||
@ONLY
|
@ONLY
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#include(GNUInstallDirs)
|
||||||
|
|
||||||
file(
|
file(
|
||||||
GLOB_RECURSE
|
GLOB_RECURSE
|
||||||
sources
|
sources
|
||||||
@ -68,82 +41,81 @@ source_group(
|
|||||||
)
|
)
|
||||||
|
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
## Fetch dependencies (pinned versions, no vcpkg required)
|
## Configure target DLL
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
|
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
# DirectXMath - required by DirectXTK.
|
# DirectXMath
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
DirectXMath
|
DirectXMath
|
||||||
URL "https://github.com/microsoft/DirectXMath/archive/refs/tags/apr2025.tar.gz"
|
URL "https://github.com/microsoft/DirectXMath/archive/refs/tags/apr2025.tar.gz"
|
||||||
OVERRIDE_FIND_PACKAGE
|
OVERRIDE_FIND_PACKAGE
|
||||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
DOWNLOAD_EXTRACT_TIMESTAMP 1
|
||||||
EXCLUDE_FROM_ALL
|
EXCLUDE_FROM_ALL
|
||||||
SYSTEM
|
SYSTEM
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(DirectXMath)
|
FetchContent_MakeAvailable(DirectXMath)
|
||||||
add_library("Microsoft::DirectXMath" ALIAS "DirectXMath")
|
add_library("Microsoft::DirectXMath" ALIAS "DirectXMath")
|
||||||
|
|
||||||
# DirectXTK - required by CommonLibSSE-NG (find_package(directxtk CONFIG REQUIRED)).
|
# DirectXTK
|
||||||
# PATCH_COMMAND fixes its shader-compile step under modern CMake (see the script).
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
DirectXTK
|
DirectXTK
|
||||||
URL "https://github.com/microsoft/DirectXTK/archive/refs/tags/jul2025.tar.gz"
|
URL "https://github.com/microsoft/DirectXTK/archive/refs/tags/jul2025.tar.gz"
|
||||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
DOWNLOAD_EXTRACT_TIMESTAMP 1
|
||||||
OVERRIDE_FIND_PACKAGE
|
OVERRIDE_FIND_PACKAGE
|
||||||
EXCLUDE_FROM_ALL
|
EXCLUDE_FROM_ALL
|
||||||
SYSTEM
|
SYSTEM
|
||||||
PATCH_COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/patch_directxtk.cmake"
|
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(DirectXTK)
|
FetchContent_MakeAvailable(DirectXTK)
|
||||||
add_library("Microsoft::DirectXTK" ALIAS "DirectXTK")
|
add_library("Microsoft::DirectXTK" ALIAS "DirectXTK")
|
||||||
|
|
||||||
# simpleini - used directly (Util.h).
|
# simpleini
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
simpleini
|
simpleini
|
||||||
URL "https://github.com/brofield/simpleini/archive/refs/tags/v4.22.tar.gz"
|
URL "https://github.com/brofield/simpleini/archive/refs/tags/v4.22.tar.gz"
|
||||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
DOWNLOAD_EXTRACT_TIMESTAMP 1
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(simpleini)
|
FetchContent_MakeAvailable(simpleini)
|
||||||
INCLUDE_DIRECTORIES(${simpleini_SOURCE_DIR})
|
INCLUDE_DIRECTORIES(${simpleini_SOURCE_DIR})
|
||||||
|
|
||||||
# rapidcsv - header only, required by CommonLibSSE-NG (find_path "rapidcsv.h").
|
# rapidcsv
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
rapidcsv
|
rapidcsv
|
||||||
URL "https://github.com/d99kris/rapidcsv/archive/refs/tags/v8.87.tar.gz"
|
URL "https://github.com/d99kris/rapidcsv/archive/refs/tags/v8.87.tar.gz"
|
||||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
DOWNLOAD_EXTRACT_TIMESTAMP 1
|
||||||
OVERRIDE_FIND_PACKAGE
|
OVERRIDE_FIND_PACKAGE
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(rapidcsv)
|
FetchContent_MakeAvailable(rapidcsv)
|
||||||
set(RAPIDCSV_INCLUDE_DIRS ${rapidcsv_SOURCE_DIR}/src)
|
set(RAPIDCSV_INCLUDE_DIRS ${rapidcsv_SOURCE_DIR}/src)
|
||||||
|
|
||||||
# spdlog - used directly (PCH.h) and by CommonLibSSE-NG.
|
# spdlog
|
||||||
set(SPDLOG_INSTALL ON CACHE BOOL " " FORCE)
|
set(SPDLOG_INSTALL ON CACHE INTERNAL "Install SPDLOG for CommonLibSSE")
|
||||||
set(SPDLOG_USE_STD_FORMAT ON CACHE BOOL " " FORCE)
|
set(SPDLOG_USE_STD_FORMAT ON CACHE INTERNAL "Use std::format in SPDLOG, not fmt")
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
spdlog
|
spdlog
|
||||||
URL "https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.tar.gz"
|
URL "https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.tar.gz"
|
||||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
DOWNLOAD_EXTRACT_TIMESTAMP 1
|
||||||
OVERRIDE_FIND_PACKAGE
|
OVERRIDE_FIND_PACKAGE
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(spdlog)
|
FetchContent_MakeAvailable(spdlog)
|
||||||
|
|
||||||
# xbyak - required by CommonLibSSE-NG when SKSE_SUPPORT_XBYAK is on.
|
# xbyak
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
xbyak
|
xbyak
|
||||||
URL "https://github.com/herumi/xbyak/archive/v7.28.tar.gz"
|
URL "https://github.com/herumi/xbyak/archive/v7.28.tar.gz"
|
||||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
DOWNLOAD_EXTRACT_TIMESTAMP 1
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(xbyak)
|
FetchContent_MakeAvailable(xbyak)
|
||||||
|
|
||||||
# CommonLibSSE-NG - pinned commit (SE + AE + VR runtime support).
|
# CommonLibSSE
|
||||||
set(SKSE_SUPPORT_XBYAK ON CACHE BOOL " " FORCE)
|
set(SKSE_SUPPORT_XBYAK ON CACHE BOOL " " FORCE)
|
||||||
set(ENABLE_SKYRIM_SE ON CACHE BOOL " " FORCE)
|
set(ENABLE_SKYRIM_SE ON CACHE BOOL " " FORCE)
|
||||||
set(ENABLE_SKYRIM_AE ON CACHE BOOL " " FORCE)
|
set(ENABLE_SKYRIM_AE ON CACHE BOOL " " FORCE)
|
||||||
set(ENABLE_SKYRIM_VR ON CACHE BOOL " " FORCE)
|
set(ENABLE_SKYRIM_VR ON CACHE BOOL " " FORCE)
|
||||||
set(BUILD_TESTS OFF CACHE BOOL " " FORCE)
|
set(BUILD_TESTS OFF CACHE BOOL " " FORCE)
|
||||||
message(STATUS "Fetching CommonLibSSE-NG...")
|
message(STATUS "Fetching CommonLibSSE-NG (5e5417e3585c9434295e919bdda27737244e9c5a)...")
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
CommonLibSSE
|
CommonLibSSE
|
||||||
GIT_REPOSITORY https://github.com/eddoursul/CommonLibVR.git
|
GIT_REPOSITORY https://github.com/eddoursul/CommonLibVR.git
|
||||||
@ -151,19 +123,15 @@ FetchContent_Declare(
|
|||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(CommonLibSSE)
|
FetchContent_MakeAvailable(CommonLibSSE)
|
||||||
|
|
||||||
|
|
||||||
get_target_property(COMMONLIB_SRC_DIR CommonLibSSE SOURCE_DIR)
|
get_target_property(COMMONLIB_SRC_DIR CommonLibSSE SOURCE_DIR)
|
||||||
|
|
||||||
include(${COMMONLIB_SRC_DIR}/cmake/CommonLibSSE.cmake)
|
include(${COMMONLIB_SRC_DIR}/cmake/CommonLibSSE.cmake)
|
||||||
|
|
||||||
########################################################################################################################
|
|
||||||
## Configure target DLL
|
|
||||||
########################################################################################################################
|
|
||||||
|
|
||||||
add_commonlibsse_plugin(${PROJECT_NAME} SOURCES ${headers} ${sources})
|
add_commonlibsse_plugin(${PROJECT_NAME} SOURCES ${headers} ${sources})
|
||||||
|
|
||||||
add_library("${PROJECT_NAME}::${PROJECT_NAME}" ALIAS "${PROJECT_NAME}")
|
add_library("${PROJECT_NAME}::${PROJECT_NAME}" ALIAS "${PROJECT_NAME}")
|
||||||
|
|
||||||
# Steamworks SDK import library, shipped in src/ next to the steam/ headers.
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/steam_api64.lib)
|
target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/steam_api64.lib)
|
||||||
|
|
||||||
target_link_libraries(CommonLibSSE PUBLIC
|
target_link_libraries(CommonLibSSE PUBLIC
|
||||||
@ -196,6 +164,7 @@ target_precompile_headers(${PROJECT_NAME}
|
|||||||
|
|
||||||
install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
|
||||||
|
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
## Automatic plugin deployment
|
## Automatic plugin deployment
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
|
|||||||
@ -13,6 +13,17 @@
|
|||||||
"CMAKE_CXX_FLAGS": "$env{COMMONLIBSSE_COMPILER} $env{COMMONLIBSSE_PLATFORM} $env{COMMONLIBSSE_TEXT}"
|
"CMAKE_CXX_FLAGS": "$env{COMMONLIBSSE_COMPILER} $env{COMMONLIBSSE_PLATFORM} $env{COMMONLIBSSE_TEXT}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "vcpkg",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
|
||||||
|
"VCPKG_TARGET_TRIPLET": "x64-windows-skse",
|
||||||
|
"VCPKG_HOST_TRIPLET": "x64-windows-skse",
|
||||||
|
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/cmake",
|
||||||
|
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "win32",
|
"name": "win32",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
@ -68,68 +79,100 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "build-tests",
|
||||||
|
"displayName": "Build Tests",
|
||||||
|
"hidden": true,
|
||||||
|
"description": "Include test suites in the build.",
|
||||||
|
"cacheVariables": {
|
||||||
|
"BUILD_TESTS": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "ON"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "build-release-msvc",
|
"name": "build-release-msvc",
|
||||||
"inherits": [
|
"inherits": [
|
||||||
"base",
|
"base",
|
||||||
|
"vcpkg",
|
||||||
"win32-unicode",
|
"win32-unicode",
|
||||||
"x64",
|
"x64",
|
||||||
|
"build-tests",
|
||||||
"msvc"
|
"msvc"
|
||||||
],
|
],
|
||||||
"displayName": "Release (MSVC)",
|
"displayName": "Release",
|
||||||
"description": "Optimized release build.",
|
"description": "Optimized release build.",
|
||||||
"generator": "Ninja",
|
"generator": "Ninja",
|
||||||
"binaryDir": "${sourceDir}/build/release-msvc",
|
"binaryDir": "${sourceDir}/build/release-msvc",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"CMAKE_BUILD_TYPE": "Release"
|
"CMAKE_BUILD_TYPE": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "Release"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "build-debug-msvc",
|
"name": "build-debug-msvc",
|
||||||
"inherits": [
|
"inherits": [
|
||||||
"base",
|
"base",
|
||||||
|
"vcpkg",
|
||||||
"win32-unicode",
|
"win32-unicode",
|
||||||
"x64",
|
"x64",
|
||||||
|
"build-tests",
|
||||||
"msvc"
|
"msvc"
|
||||||
],
|
],
|
||||||
"displayName": "Debug (MSVC)",
|
"displayName": "Debug",
|
||||||
"description": "Debug build for testing.",
|
"description": "Debug build for testing.",
|
||||||
"generator": "Ninja",
|
"generator": "Ninja",
|
||||||
"binaryDir": "${sourceDir}/build/debug-msvc",
|
"binaryDir": "${sourceDir}/build/debug-msvc",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"CMAKE_BUILD_TYPE": "Debug"
|
"CMAKE_BUILD_TYPE": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "Debug"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "build-release-clang-cl",
|
|
||||||
"inherits": [
|
|
||||||
"base",
|
|
||||||
"win32-unicode",
|
|
||||||
"x64",
|
|
||||||
"clang-cl"
|
|
||||||
],
|
|
||||||
"displayName": "Release (Clang)",
|
|
||||||
"description": "Optimized release build.",
|
|
||||||
"generator": "Ninja",
|
|
||||||
"binaryDir": "${sourceDir}/build/release-clang",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "build-debug-clang-cl",
|
"name": "build-debug-clang-cl",
|
||||||
"inherits": [
|
"inherits": [
|
||||||
"base",
|
"base",
|
||||||
|
"vcpkg",
|
||||||
"win32-unicode",
|
"win32-unicode",
|
||||||
"x64",
|
"x64",
|
||||||
|
"build-tests",
|
||||||
"clang-cl"
|
"clang-cl"
|
||||||
],
|
],
|
||||||
"displayName": "Debug (Clang)",
|
"displayName": "Debug",
|
||||||
"description": "Debug build for testing.",
|
"description": "Debug build for testing.",
|
||||||
"generator": "Ninja",
|
"generator": "Ninja",
|
||||||
"binaryDir": "${sourceDir}/build/debug-clang",
|
"binaryDir": "${sourceDir}/build/debug-clang",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"CMAKE_BUILD_TYPE": "Debug"
|
"CMAKE_BUILD_TYPE": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "Debug"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "build-release-clang-cl",
|
||||||
|
"inherits": [
|
||||||
|
"base",
|
||||||
|
"vcpkg",
|
||||||
|
"win32-unicode",
|
||||||
|
"x64",
|
||||||
|
"build-tests",
|
||||||
|
"clang-cl"
|
||||||
|
],
|
||||||
|
"displayName": "Release",
|
||||||
|
"description": "Optimized release build.",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"binaryDir": "${sourceDir}/build/release-clang",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "Release"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -158,5 +201,52 @@
|
|||||||
"configurePreset": "build-debug-clang-cl",
|
"configurePreset": "build-debug-clang-cl",
|
||||||
"description": "Debug build for testing."
|
"description": "Debug build for testing."
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"testPresets": [
|
||||||
|
{
|
||||||
|
"name": "tests-all",
|
||||||
|
"displayName": "All Tests",
|
||||||
|
"configurePreset": "build-debug-msvc",
|
||||||
|
"output": {
|
||||||
|
"outputOnFailure": true
|
||||||
|
},
|
||||||
|
"execution": {
|
||||||
|
"noTestsAction": "error",
|
||||||
|
"stopOnFailure": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tests-unit",
|
||||||
|
"displayName": "Unit Tests",
|
||||||
|
"description": "Runs tests that do not require any Skyrim module loaded into the process.",
|
||||||
|
"inherits": "tests-all",
|
||||||
|
"filter": {
|
||||||
|
"exclude": {
|
||||||
|
"label": "[integration],[e2e]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tests-integration",
|
||||||
|
"displayName": "Integration Tests",
|
||||||
|
"description": "Runs tests that interact with a Skyrim module at rest (do not require the Skyrim module to have run any main function).",
|
||||||
|
"inherits": "tests-all",
|
||||||
|
"filter": {
|
||||||
|
"include": {
|
||||||
|
"label": "[integration]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tests-e2e",
|
||||||
|
"displayName": "End-to-End Tests",
|
||||||
|
"description": "Runs test that depend on a fully running Skyrim engine in the process.",
|
||||||
|
"inherits": "tests-all",
|
||||||
|
"filter": {
|
||||||
|
"include": {
|
||||||
|
"label": "[e2e]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,47 +0,0 @@
|
|||||||
@echo off
|
|
||||||
rem ---------------------------------------------------------------------------
|
|
||||||
rem Command-line build wrapper.
|
|
||||||
rem
|
|
||||||
rem Sets up the MSVC x64 environment (the piece Visual Studio configures for you
|
|
||||||
rem automatically) and then drives the exact same CMake presets that Visual
|
|
||||||
rem Studio uses, so both build paths stay in sync.
|
|
||||||
rem
|
|
||||||
rem Usage: build.cmd [preset]
|
|
||||||
rem preset defaults to "release-msvc". Other options: debug-msvc,
|
|
||||||
rem release-clang-cl, debug-clang-cl (must match a name in CMakePresets.json).
|
|
||||||
rem ---------------------------------------------------------------------------
|
|
||||||
setlocal
|
|
||||||
|
|
||||||
set "PRESET=%~1"
|
|
||||||
if "%PRESET%"=="" set "PRESET=release-msvc"
|
|
||||||
set "CONFIGURE_PRESET=build-%PRESET%"
|
|
||||||
|
|
||||||
cd /d "%~dp0"
|
|
||||||
|
|
||||||
rem --- Locate Visual Studio (or the C++ Build Tools) ---
|
|
||||||
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
|
|
||||||
if not exist "%VSWHERE%" (
|
|
||||||
echo [ERROR] vswhere.exe not found. Install Visual Studio 2022 or the C++ Build Tools.
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
set "VSINSTALL="
|
|
||||||
for /f "usebackq delims=" %%i in (`"%VSWHERE%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VSINSTALL=%%i"
|
|
||||||
if not defined VSINSTALL (
|
|
||||||
echo [ERROR] No Visual Studio installation with the C++ toolset was found.
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
rem --- Import the MSVC x64 developer environment ---
|
|
||||||
call "%VSINSTALL%\VC\Auxiliary\Build\vcvars64.bat" || exit /b 1
|
|
||||||
|
|
||||||
rem --- Point Visual Studio at this same CMake, so the two drivers can share the
|
|
||||||
rem build tree incrementally (see cmake\write_user_presets.cmake) ---
|
|
||||||
cmake -P cmake\write_user_presets.cmake || exit /b 1
|
|
||||||
|
|
||||||
rem --- Configure and build using the shared presets ---
|
|
||||||
cmake --preset %CONFIGURE_PRESET% || exit /b 1
|
|
||||||
cmake --build --preset %PRESET% || exit /b 1
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo [OK] Built preset "%PRESET%". Plugin deployed to SKSE\Plugins\.
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
# Patch applied to DirectXTK's CMakeLists.txt via FetchContent PATCH_COMMAND.
|
|
||||||
#
|
|
||||||
# DirectXTK compiles its HLSL shaders by running Src/Shaders/CompileShaders.cmd
|
|
||||||
# through `cmake -E env ... CompileShaders.cmd` (a bare script name, relying on
|
|
||||||
# the custom command's WORKING_DIRECTORY). Modern CMake no longer resolves a
|
|
||||||
# bare command name against the working directory, so the step fails with
|
|
||||||
# "no such file or directory" and the whole build stops.
|
|
||||||
#
|
|
||||||
# Rewrite that single invocation to an absolute path. WORKING_DIRECTORY is left
|
|
||||||
# untouched so the script still runs with Src/Shaders as its CWD. The replace is
|
|
||||||
# idempotent: after patching, the original "CompileShaders.cmd ARGS" substring is
|
|
||||||
# gone, so re-running the patch is a no-op. It also targets only the COMMAND line
|
|
||||||
# (the MAIN_DEPENDENCY reference already uses a full path and is not matched).
|
|
||||||
set(_dxtk_cmakelists "CMakeLists.txt")
|
|
||||||
|
|
||||||
file(READ "${_dxtk_cmakelists}" _dxtk_content)
|
|
||||||
string(REPLACE
|
|
||||||
"CompileShaders.cmd ARGS"
|
|
||||||
"\"\${PROJECT_SOURCE_DIR}/Src/Shaders/CompileShaders.cmd\" ARGS"
|
|
||||||
_dxtk_content "${_dxtk_content}")
|
|
||||||
file(WRITE "${_dxtk_cmakelists}" "${_dxtk_content}")
|
|
||||||
|
|
||||||
message(STATUS "Patched DirectXTK CompileShaders.cmd invocation to use an absolute path.")
|
|
||||||
BIN
source/Steam DLL/cmake/version.rc.in
(Stored with Git LFS)
BIN
source/Steam DLL/cmake/version.rc.in
(Stored with Git LFS)
Binary file not shown.
@ -1,116 +0,0 @@
|
|||||||
# Generates CMakeUserPresets.json, pinning "cmakeExecutable" to the CMake that is
|
|
||||||
# running this script - i.e. the one build.cmd itself uses.
|
|
||||||
#
|
|
||||||
# Why: both drivers share one binaryDir per configuration, so build.cmd and Visual
|
|
||||||
# Studio write the same Ninja tree. Visual Studio otherwise uses its own bundled
|
|
||||||
# CMake, and two CMake versions generating one tree emit different compile command
|
|
||||||
# lines, which makes Ninja rebuild everything on every switch. See CLAUDE.md.
|
|
||||||
#
|
|
||||||
# Why generated rather than committed: Visual Studio resolves "cmakeExecutable"
|
|
||||||
# against the current directory only - a bare "cmake" is not looked up on PATH - so
|
|
||||||
# the value must be an absolute path, which is machine-specific and cannot live in
|
|
||||||
# the committed CMakePresets.json.
|
|
||||||
#
|
|
||||||
# Run as: cmake -P cmake/write_user_presets.cmake
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.21)
|
|
||||||
|
|
||||||
# Marks the file as ours, so a hand-written one is never clobbered.
|
|
||||||
set(GENERATED_MARKER "local-cmake")
|
|
||||||
|
|
||||||
set(TEMPLATE [==[
|
|
||||||
{
|
|
||||||
"version": 2,
|
|
||||||
"configurePresets": [
|
|
||||||
{
|
|
||||||
"name": "local-cmake",
|
|
||||||
"hidden": true,
|
|
||||||
"cmakeExecutable": "@CMAKE_COMMAND@"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "build-release-msvc-local",
|
|
||||||
"inherits": [
|
|
||||||
"local-cmake",
|
|
||||||
"build-release-msvc"
|
|
||||||
],
|
|
||||||
"displayName": "Release (MSVC) [local CMake]",
|
|
||||||
"description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "build-debug-msvc-local",
|
|
||||||
"inherits": [
|
|
||||||
"local-cmake",
|
|
||||||
"build-debug-msvc"
|
|
||||||
],
|
|
||||||
"displayName": "Debug (MSVC) [local CMake]",
|
|
||||||
"description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "build-release-clang-cl-local",
|
|
||||||
"inherits": [
|
|
||||||
"local-cmake",
|
|
||||||
"build-release-clang-cl"
|
|
||||||
],
|
|
||||||
"displayName": "Release (Clang) [local CMake]",
|
|
||||||
"description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "build-debug-clang-cl-local",
|
|
||||||
"inherits": [
|
|
||||||
"local-cmake",
|
|
||||||
"build-debug-clang-cl"
|
|
||||||
],
|
|
||||||
"displayName": "Debug (Clang) [local CMake]",
|
|
||||||
"description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit."
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"buildPresets": [
|
|
||||||
{
|
|
||||||
"name": "release-msvc-local",
|
|
||||||
"configurePreset": "build-release-msvc-local",
|
|
||||||
"displayName": "Release (MSVC) [local CMake]"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug-msvc-local",
|
|
||||||
"configurePreset": "build-debug-msvc-local",
|
|
||||||
"displayName": "Debug (MSVC) [local CMake]"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "release-clang-cl-local",
|
|
||||||
"configurePreset": "build-release-clang-cl-local",
|
|
||||||
"displayName": "Release (Clang) [local CMake]"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug-clang-cl-local",
|
|
||||||
"configurePreset": "build-debug-clang-cl-local",
|
|
||||||
"displayName": "Debug (Clang) [local CMake]"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]==])
|
|
||||||
|
|
||||||
string(CONFIGURE "${TEMPLATE}" CONTENT @ONLY)
|
|
||||||
|
|
||||||
get_filename_component(OUTPUT_FILE "${CMAKE_CURRENT_LIST_DIR}/../CMakeUserPresets.json" ABSOLUTE)
|
|
||||||
|
|
||||||
if(EXISTS "${OUTPUT_FILE}")
|
|
||||||
file(READ "${OUTPUT_FILE}" EXISTING)
|
|
||||||
|
|
||||||
# Unchanged: leave the timestamp alone, or Visual Studio reloads the presets
|
|
||||||
# after every command-line build.
|
|
||||||
if(EXISTING STREQUAL CONTENT)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
string(FIND "${EXISTING}" "\"${GENERATED_MARKER}\"" MARKER_POS)
|
|
||||||
if(MARKER_POS EQUAL -1)
|
|
||||||
message(WARNING
|
|
||||||
"CMakeUserPresets.json was not generated by build.cmd - leaving it untouched.\n"
|
|
||||||
"Delete it to let build.cmd manage it, or add \"cmakeExecutable\": \"${CMAKE_COMMAND}\" to it yourself."
|
|
||||||
)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
file(WRITE "${OUTPUT_FILE}" "${CONTENT}")
|
|
||||||
message(STATUS "Wrote CMakeUserPresets.json (cmakeExecutable: ${CMAKE_COMMAND})")
|
|
||||||
BIN
source/Steam DLL/cmake/x64-windows-skse.cmake
(Stored with Git LFS)
Normal file
BIN
source/Steam DLL/cmake/x64-windows-skse.cmake
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -1,182 +1,66 @@
|
|||||||
#include "Achievements.h"
|
#include "Achievements.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "steam/steam_api.h"
|
#include "steam/steam_api.h"
|
||||||
#include <cstdlib>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <processenv.h>
|
#include <processenv.h>
|
||||||
|
|
||||||
namespace Achievements {
|
namespace Achievements {
|
||||||
|
|
||||||
namespace {
|
|
||||||
// Enderal's own AppIDs. Skyrim SE is 489830.
|
|
||||||
constexpr const char* APPID_ENDERAL_SE = "976620";
|
|
||||||
constexpr const char* APPID_ENDERAL_LE = "933480";
|
|
||||||
|
|
||||||
bool bInitFailed = false;
|
|
||||||
bool bWarnOnInitFail = true;
|
|
||||||
|
|
||||||
constexpr const char* STEAMCLIENT_MODULE = "steamclient64.dll";
|
|
||||||
|
|
||||||
// Which app a process is registered as is decided by steamclient64.dll, and
|
|
||||||
// these variables are how it is told. It latches them when the module is
|
|
||||||
// *loaded* into the process - not when a pipe is created - so changing them
|
|
||||||
// afterwards does nothing at all. steam_api never reads them back either, it
|
|
||||||
// asks ISteamUtils::GetAppID(). (steam_appid.txt is no help: only
|
|
||||||
// SteamAPI_RestartAppIfNecessary reads it, and Skyrim does not call that.)
|
|
||||||
void setAppIdEnvironment(const char* appId)
|
|
||||||
{
|
|
||||||
SetEnvironmentVariableA("SteamAppId", appId);
|
|
||||||
SetEnvironmentVariableA("SteamGameId", appId);
|
|
||||||
SetEnvironmentVariableA("SteamOverlayGameId", appId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void logEnvironment(const char* label)
|
|
||||||
{
|
|
||||||
static const char* const vars[] = { "SteamAppId", "SteamGameId", "SteamOverlayGameId", "SteamClientLaunch" };
|
|
||||||
for (const char* name : vars) {
|
|
||||||
char value[64] = "<unset>";
|
|
||||||
GetEnvironmentVariableA(name, value, sizeof(value));
|
|
||||||
logger::info("[{}] {} = {}", label, name, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void logModuleState(const char* label)
|
|
||||||
{
|
|
||||||
logger::info("[{}] steam_api64={}, {}={}, GameOverlayRenderer64={}",
|
|
||||||
label,
|
|
||||||
GetModuleHandleA("steam_api64.dll") ? "loaded" : "absent",
|
|
||||||
STEAMCLIENT_MODULE,
|
|
||||||
GetModuleHandleA(STEAMCLIENT_MODULE) ? "loaded" : "absent",
|
|
||||||
GetModuleHandleA("GameOverlayRenderer64.dll") ? "loaded" : "absent");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drop every outstanding reference to steamclient64.dll so that the
|
|
||||||
// SteamAPI_Init() below loads a fresh copy, which then picks up the AppID we
|
|
||||||
// just put in the environment. Something loads it before SKSE gets control
|
|
||||||
// (the SteamStub DRM wrapper is the only candidate that runs that early) and
|
|
||||||
// leaves it resident with Skyrim's AppID latched in.
|
|
||||||
//
|
|
||||||
// SteamAPI_Shutdown() has to run first: it releases steam_api's own reference
|
|
||||||
// and clears its cached module handle, so it will not later FreeLibrary a
|
|
||||||
// handle we already invalidated.
|
|
||||||
bool unloadSteamClient()
|
|
||||||
{
|
|
||||||
constexpr int MAX_REFERENCES = 32;
|
|
||||||
|
|
||||||
int released = 0;
|
|
||||||
while (auto* module = GetModuleHandleA(STEAMCLIENT_MODULE)) {
|
|
||||||
if (released >= MAX_REFERENCES) {
|
|
||||||
logger::error("{} is still loaded after releasing {} references, giving up", STEAMCLIENT_MODULE, released);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
FreeLibrary(module);
|
|
||||||
++released;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (released > 0) {
|
|
||||||
logger::info("Unloaded {} after releasing {} reference(s)", STEAMCLIENT_MODULE, released);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool steamInitFailed()
|
|
||||||
{
|
|
||||||
return bInitFailed;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool shouldWarnOnInitFail()
|
|
||||||
{
|
|
||||||
return bWarnOnInitFail;
|
|
||||||
}
|
|
||||||
|
|
||||||
void startSteam()
|
void startSteam()
|
||||||
{
|
{
|
||||||
std::map<std::string, bool> settings{
|
std::map<std::string, bool> settings{
|
||||||
{ "SendAchievementsToLE", false },
|
{ "SendAchievementsToLE", false },
|
||||||
{ "TestMode", false },
|
{ "TestMode", false },
|
||||||
{ "ShowWarningOnInitFail", true },
|
{ "ShowWarningOnInitFail", true }
|
||||||
{ "ReloadSteamClient", true }
|
|
||||||
};
|
};
|
||||||
LoadINI(&settings, "Data/SKSE/Plugins/EnderalSteam.ini");
|
LoadINI(&settings, "Data/SKSE/Plugins/EnderalSteam.ini");
|
||||||
|
|
||||||
AchievementsEnabled(!settings.at("TestMode"));
|
AchievementsEnabled(!settings.at("TestMode"));
|
||||||
bWarnOnInitFail = settings.at("ShowWarningOnInitFail");
|
|
||||||
|
|
||||||
if (settings.at("TestMode")) {
|
if (settings.at("TestMode")) {
|
||||||
logger::info("{}", "TestMode is on, leaving the Steam session alone");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SteamInstance() != nullptr) {
|
|
||||||
logger::info("{}", "Already initialized steam api, skipping it");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const char* appId = settings.at("SendAchievementsToLE") ? APPID_ENDERAL_LE : APPID_ENDERAL_SE;
|
if (SteamInstance() == nullptr) {
|
||||||
|
|
||||||
logModuleState("BEFORE");
|
|
||||||
logEnvironment("BEFORE");
|
|
||||||
logger::info("[BEFORE] HSteamUser = {}", SteamAPI_GetHSteamUser());
|
|
||||||
|
|
||||||
// This runs from SKSEPluginLoad, i.e. after the CRT global initializers but
|
|
||||||
// before WinMain. Skyrim opens its own Steam session much later, from
|
|
||||||
// BSWin32SystemUtility, so we get here first and its SteamAPI_Init() then
|
|
||||||
// returns early because ours is already up.
|
|
||||||
//
|
|
||||||
// Being first is not enough on its own, though - see unloadSteamClient().
|
|
||||||
SteamAPI_Shutdown();
|
SteamAPI_Shutdown();
|
||||||
|
|
||||||
if (settings.at("ReloadSteamClient")) {
|
if (settings.at("SendAchievementsToLE")) {
|
||||||
unloadSteamClient();
|
SetEnvironmentVariable(L"SteamAppID", L"933480");
|
||||||
}
|
SetEnvironmentVariable(L"SteamGameId", L"933480");
|
||||||
|
|
||||||
setAppIdEnvironment(appId);
|
|
||||||
|
|
||||||
if (!SteamAPI_Init()) {
|
|
||||||
bInitFailed = true;
|
|
||||||
logger::error("{}", "Error while initializing the steam api");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger::info("Steam api init was successfull, requested AppID {}", appId);
|
|
||||||
|
|
||||||
// The AppID the Steam client actually gave us. Anything other than the one
|
|
||||||
// requested above means the session still belongs to another app - Enderal's
|
|
||||||
// achievement names would not resolve there - so treat it like a failed init:
|
|
||||||
// leave achievements unwired and let the main-menu warning fire.
|
|
||||||
if (auto* utils = SteamUtils()) {
|
|
||||||
const uint32 sessionAppId = utils->GetAppID();
|
|
||||||
logger::info("Steam session is registered as AppID {}", sessionAppId);
|
|
||||||
if (sessionAppId != static_cast<uint32>(std::strtoul(appId, nullptr, 10))) {
|
|
||||||
bInitFailed = true;
|
|
||||||
logger::error("{}", "Session kept a foreign AppID, not wiring up achievements");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
logger::warn("{}", "ISteamUtils is unavailable, cannot verify the session AppID");
|
SetEnvironmentVariable(L"SteamAppID", L"976620");
|
||||||
|
SetEnvironmentVariable(L"SteamGameId", L"976620");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* holder = new AchievementHolder();
|
bool success = SteamAPI_Init();
|
||||||
SteamInstance(holder);
|
|
||||||
|
|
||||||
// Steam wants the user's stats downloaded before achievements can be set.
|
if (success) {
|
||||||
// Nothing used to call this, so UserStatsReceived_t never fired.
|
logger::info("{}", "Steam api init was successfull");
|
||||||
holder->start();
|
} else {
|
||||||
|
logger::error("{}", "Error while initializing the steam api");
|
||||||
|
if (settings.at("ShowWarningOnInitFail")) {
|
||||||
|
RE::DebugMessageBox("Unable to initialize Steam achievements. Try to restart the game and the Steam client. This warning can be disabled in SKSE\\Plugins\\EnderalSteam.ini.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SteamInstance(new AchievementHolder());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger::info("{}", "Already initialized steam api, skipping it");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& ex) {
|
catch (const std::exception& ex) {
|
||||||
bInitFailed = true;
|
|
||||||
std::string msg = "Exception while initializing the Steam API, steam achievements will not be available: " + std::string(ex.what());
|
std::string msg = "Exception while initializing the Steam API, steam achievements will not be available: " + std::string(ex.what());
|
||||||
logger::error("{}", msg.c_str());
|
logger::error("{}", msg.c_str());
|
||||||
|
if (settings.at("ShowWarningOnInitFail")) {
|
||||||
|
RE::DebugMessageBox("Unable to initialize Steam achievements. Try to restart the game and the Steam client. This warning can be disabled in SKSE\\Plugins\\EnderalSteam.ini.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AchievementHolder::AchievementHolder() : stats(SteamUserStats()), callback(this, &AchievementHolder::onUserStatsReceived)
|
AchievementHolder::AchievementHolder() : stats(SteamUserStats()), callback(this, &AchievementHolder::onUserStatsReceived)
|
||||||
{
|
{
|
||||||
if (!this->stats) {
|
|
||||||
logger::error("{}", "ISteamUserStats is unavailable, achievements will not be unlocked");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AchievementHolder::onUserStatsReceived(UserStatsReceived_t * event) {
|
void AchievementHolder::onUserStatsReceived(UserStatsReceived_t * event) {
|
||||||
@ -196,11 +80,6 @@ namespace Achievements {
|
|||||||
|
|
||||||
bool AchievementHolder::setAchievementUnlocked(const char * achievementName)
|
bool AchievementHolder::setAchievementUnlocked(const char * achievementName)
|
||||||
{
|
{
|
||||||
if (!this->stats) {
|
|
||||||
logger::error("{}", "Cannot unlock achievement, ISteamUserStats is unavailable");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string msg = "Unlocking achievement: " + std::string(achievementName);
|
std::string msg = "Unlocking achievement: " + std::string(achievementName);
|
||||||
logger::info("{}", msg.c_str());
|
logger::info("{}", msg.c_str());
|
||||||
bool success = this->stats->SetAchievement(achievementName);
|
bool success = this->stats->SetAchievement(achievementName);
|
||||||
@ -217,12 +96,6 @@ namespace Achievements {
|
|||||||
|
|
||||||
void AchievementHolder::start()
|
void AchievementHolder::start()
|
||||||
{
|
{
|
||||||
if (!this->stats) {
|
this->stats->RequestCurrentStats();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this->stats->RequestCurrentStats()) {
|
|
||||||
logger::error("{}", "RequestCurrentStats failed, achievements may not unlock");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
//Steam API version 1.55, matching Skyrim SE 1.6.1170 (pre-1.6.1130 shipped 1.31)
|
//Steam API Version 1.31 matches the Skyrim Steam API version
|
||||||
#include "steam/steam_api.h"
|
#include "steam/steam_api.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace Achievements {
|
namespace Achievements {
|
||||||
|
|
||||||
@ -17,11 +18,7 @@ namespace Achievements {
|
|||||||
bool setAchievementUnlocked(const char * achievementName);
|
bool setAchievementUnlocked(const char * achievementName);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Opens the Steam session under Enderal's AppID. Must run before the game
|
static std::unique_ptr<AchievementHolder> singleton(nullptr);
|
||||||
// opens its own - see the comment inside.
|
|
||||||
void startSteam();
|
|
||||||
|
|
||||||
// Result of startSteam(), so the warning can be shown once a UI exists.
|
void startSteam();
|
||||||
bool steamInitFailed();
|
|
||||||
bool shouldWarnOnInitFail();
|
|
||||||
}
|
}
|
||||||
@ -20,12 +20,8 @@ auto EventListener::ProcessEvent(
|
|||||||
{
|
{
|
||||||
if (a_event->opening && a_event->menuName == "Main Menu") {
|
if (a_event->opening && a_event->menuName == "Main Menu") {
|
||||||
RE::UI::GetSingleton()->RemoveEventSink<RE::MenuOpenCloseEvent>(GetSingleton());
|
RE::UI::GetSingleton()->RemoveEventSink<RE::MenuOpenCloseEvent>(GetSingleton());
|
||||||
|
logger::info("{}", "Main menu opened, trying to init steam API.");
|
||||||
// Steam is started at plugin load, long before there is a UI to complain to,
|
Achievements::startSteam();
|
||||||
// so the warning waits until the main menu is up.
|
|
||||||
if (Achievements::steamInitFailed() && Achievements::shouldWarnOnInitFail()) {
|
|
||||||
RE::DebugMessageBox("Unable to initialize Steam achievements. Try to restart the game and the Steam client. This warning can be disabled in SKSE\\Plugins\\EnderalSteam.ini.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return RE::BSEventNotifyControl::kContinue;
|
return RE::BSEventNotifyControl::kContinue;
|
||||||
|
|||||||
@ -38,11 +38,6 @@ SKSEPluginLoad(const LoadInterface* skse) {
|
|||||||
|
|
||||||
Init(skse);
|
Init(skse);
|
||||||
|
|
||||||
// Has to happen here, not from a game event: the game opens its own Steam session
|
|
||||||
// from BSWin32SystemUtility during WinMain, and whichever session is opened first
|
|
||||||
// decides which AppID the process stays registered as.
|
|
||||||
Achievements::startSteam();
|
|
||||||
|
|
||||||
EventListener::Install();
|
EventListener::Install();
|
||||||
|
|
||||||
GetPapyrusInterface()->Register(Papyrus::Bind);
|
GetPapyrusInterface()->Register(Papyrus::Bind);
|
||||||
|
|||||||
@ -8,12 +8,7 @@ namespace Papyrus::PapyrusFunctions
|
|||||||
bool CallUnlockAchievement(RE::StaticFunctionTag* tag, RE::BSFixedString achievement)
|
bool CallUnlockAchievement(RE::StaticFunctionTag* tag, RE::BSFixedString achievement)
|
||||||
{
|
{
|
||||||
if (AchievementsEnabled()) {
|
if (AchievementsEnabled()) {
|
||||||
auto* steam = SteamInstance();
|
return SteamInstance()->setAchievementUnlocked(achievement.c_str());
|
||||||
if (!steam) {
|
|
||||||
logger::error("Steam is not initialized, cannot unlock achievement: {}", achievement.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return steam->setAchievementUnlocked(achievement.c_str());
|
|
||||||
} else {
|
} else {
|
||||||
RE::DebugNotification(std::format("Achievement unlocked: {}", achievement.c_str()).c_str());
|
RE::DebugNotification(std::format("Achievement unlocked: {}", achievement.c_str()).c_str());
|
||||||
logger::info("{}", std::format("Achievement unlocked: {}", achievement.c_str()).c_str());
|
logger::info("{}", std::format("Achievement unlocked: {}", achievement.c_str()).c_str());
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Achievements.h"
|
#include "Achievements.h"
|
||||||
#include <SimpleIni.h>
|
#include <SimpleIni.h>
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
inline const SKSE::LoadInterface* GetLoadInterface(const SKSE::LoadInterface* loadInterface = nullptr)
|
inline const SKSE::LoadInterface* GetLoadInterface(const SKSE::LoadInterface* loadInterface = nullptr)
|
||||||
{
|
{
|
||||||
@ -22,11 +21,11 @@ inline Achievements::AchievementHolder* SteamInstance(Achievements::AchievementH
|
|||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool AchievementsEnabled(std::optional<bool> bEnabled = std::nullopt)
|
inline bool AchievementsEnabled(bool bEnabled = NULL)
|
||||||
{
|
{
|
||||||
static bool value = false;
|
static bool value;
|
||||||
if (bEnabled.has_value()) {
|
if (bEnabled != NULL) {
|
||||||
value = *bEnabled;
|
value = bEnabled;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -69,7 +68,7 @@ inline void LoadINI(std::map<std::string, bool>* settings, const char* iniPath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bUpdateINI) {
|
if (bUpdateINI) {
|
||||||
logger::info("New settings detected, updating {}", iniPath);
|
logger::info("New settings detected, adding to ArtifactTracker.ini");
|
||||||
ini.SaveFile(iniPath);
|
ini.SaveFile(iniPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user