Skip to content

Commit

Permalink
big SE/AE refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
powerof3 committed Mar 28, 2022
1 parent 9ad7c38 commit 7de592b
Show file tree
Hide file tree
Showing 21 changed files with 1,997 additions and 781 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
build/
build*/
/.vs
79 changes: 58 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
cmake_minimum_required(VERSION 3.20)
set(NAME "po3_FEC")
set(VERSION 5.0.0)
set(AE_VERSION 1)

# ---- Options ----

option(COPY_BUILD "Copy the build output to the Skyrim directory." TRUE)
option(BUILD_SKYRIMAE "Build for Skyrim AE" OFF)

# ---- Cache build vars ----

Expand All @@ -12,9 +16,39 @@ macro(set_from_environment VARIABLE)
endif ()
endmacro()

set_from_environment(Skyrim64Path)
macro(find_commonlib_path)
if (CommonLibName AND NOT ${CommonLibName} STREQUAL "")
# Check extern
find_path(CommonLibPath
include/REL/Relocation.h
PATHS external/${CommonLibName})
if (${CommonLibPath} STREQUAL "CommonLibPath-NOTFOUND")
#Check path
set_from_environment(${CommonLibName}Path)
set(CommonLibPath ${${CommonLibName}Path})
endif()
endif()
endmacro()

set_from_environment(VCPKG_ROOT)
set_from_environment(CommonLibSSEPath)
if(BUILD_SKYRIMAE)
add_compile_definitions(SKYRIM_AE)
set(CommonLibName "CommonLibSSE")
set_from_environment(SkyrimAEPath)
set(SkyrimPath ${SkyrimAEPath})
set(SkyrimVersion "Skyrim AE")
set(VERSION ${VERSION}.${AE_VERSION})
else()
set(CommonLibName "CommonLibSSE")
set_from_environment(Skyrim64Path)
set(SkyrimPath ${Skyrim64Path})
set(SkyrimVersion "Skyrim SSE")
endif()
find_commonlib_path()
message(
STATUS
"Building ${NAME} ${VERSION} for ${SkyrimVersion} at ${SkyrimPath} with ${CommonLibName} at ${CommonLibPath}."
)

if (DEFINED VCPKG_ROOT)
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
Expand All @@ -27,13 +61,12 @@ else ()
endif ()

set(Boost_USE_STATIC_RUNTIME OFF CACHE BOOL "")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STRING "")

# ---- Project ----

project(
po3_FEC
VERSION 5.0.0
${NAME}
VERSION ${VERSION}
LANGUAGES CXX
)

Expand Down Expand Up @@ -64,6 +97,12 @@ add_compile_definitions(
SKSE_SUPPORT_XBYAK
)

if (BUILD_SKYRIMAE)
add_compile_definitions(
SKYRIM_SUPPORT_AE
)
endif()

if (MSVC)
add_compile_definitions(
_UNICODE
Expand All @@ -80,20 +119,18 @@ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF)

set(Boost_USE_STATIC_LIBS ON)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STRING "")

# ---- Dependencies ----

if (DEFINED CommonLibSSEPath AND NOT ${CommonLibSSEPath} STREQUAL "" AND IS_DIRECTORY ${CommonLibSSEPath})
add_subdirectory(${CommonLibSSEPath} CommonLibSSE)
if (DEFINED CommonLibPath AND NOT ${CommonLibPath} STREQUAL "" AND IS_DIRECTORY ${CommonLibPath})
add_subdirectory(${CommonLibPath} ${CommonLibName})
else ()
message(
FATAL_ERROR
"Variable CommonLibSSEPath is not set."
"Variable ${CommonLibName}Path is not set."
)
endif ()

find_package(spdlog REQUIRED CONFIG)
find_package(xbyak REQUIRED CONFIG)
endif()

# ---- Add source files ----

Expand Down Expand Up @@ -138,15 +175,15 @@ target_include_directories(
${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src/C++
${CMAKE_CURRENT_SOURCE_DIR}/include
${CommonLibPath}/x64/Release
)


target_link_libraries(
${PROJECT_NAME}
PRIVATE
CommonLibSSE::CommonLibSSE
spdlog::spdlog
xbyak::xbyak
${CommonLibName}::${CommonLibName}
)

if (MSVC)
Expand Down Expand Up @@ -208,23 +245,23 @@ endif ()
target_precompile_headers(
${PROJECT_NAME}
PRIVATE
src/PCH.h
include/PCH.h
)

# ---- Post build ----

if (COPY_BUILD)
if (DEFINED Skyrim64Path)
if (DEFINED SkyrimPath)
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${PROJECT_NAME}> ${Skyrim64Path}/Data/SKSE/Plugins/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PDB_FILE:${PROJECT_NAME}> ${Skyrim64Path}/Data/SKSE/Plugins/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${PROJECT_NAME}> ${SkyrimPath}/Data/SKSE/Plugins/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PDB_FILE:${PROJECT_NAME}> ${SkyrimPath}/Data/SKSE/Plugins/
)
else ()
message(
WARNING
"Variable Skyrim64Path is not defined. Skipping post-build copy command."
"Variable ${SkyrimPath} is not defined. Skipping post-build copy command."
)
endif ()
endif ()
35 changes: 32 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,21 @@
"vcpkg",
"windows"
],
"name": "vs2019-windows-vcpkg"
"name": "vs2019-windows-vcpkg-se"
},
{
"binaryDir": "${sourceDir}/buildae",
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /external:anglebrackets /external:W0 $penv{CXXFLAGS}",
"BUILD_SKYRIMAE": true
},
"generator": "Visual Studio 16 2019",
"inherits": [
"cmake-dev",
"vcpkg",
"windows"
],
"name": "vs2019-windows-vcpkg-ae"
},
{
"cacheVariables": {
Expand All @@ -64,9 +78,24 @@
"vcpkg",
"windows"
],
"name": "vs2022-windows-vcpkg",
"name": "vs2022-windows-vcpkg-se",
"toolset": "v143"
},
{
"binaryDir": "${sourceDir}/buildae",
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /WX $penv{CXXFLAGS}",
"BUILD_SKYRIMAE": true
},
"generator": "Visual Studio 17 2022",
"inherits": [
"cmake-dev",
"vcpkg",
"windows"
],
"name": "vs2022-windows-vcpkg-ae",
"toolset": "v143"
}
],
"version": 2
"version": 3
}
15 changes: 0 additions & 15 deletions CMakeSettings.json

This file was deleted.

2 changes: 2 additions & 0 deletions ProjectGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def make_cmake():
headers.append(name)
elif name.endswith(SOURCE_TYPES):
sources.append(name)
headers.sort()
sources.sort()

def do_make(a_filename, a_varname, a_files):
out = open("cmake/" + a_filename + ".cmake", "w", encoding="utf-8")
Expand Down
9 changes: 6 additions & 3 deletions cmake/headerlist.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
set(headers ${headers}
src/Graphics.h
src/Patches.h
src/PCH.h
include/Globals.h
include/Graphics.h
include/PCH.h
include/Papyrus.h
include/Patches.h
include/Serialization.h
)
6 changes: 4 additions & 2 deletions cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
set(sources ${sources}
src/Graphics.cpp
src/main.cpp
src/Patches.cpp
src/PCH.cpp
src/Papyrus.cpp
src/Patches.cpp
src/Serialization.cpp
src/main.cpp
)
136 changes: 136 additions & 0 deletions include/Globals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#pragma once

namespace FEC
{
using Slot = RE::BIPED_MODEL::BipedObjectSlot;
using Biped = RE::BIPED_OBJECT;
using HeadPart = RE::BGSHeadPart::HeadPartType;
using Feature = RE::BSShaderMaterial::Feature;
using States = RE::BSGeometry::States;
using Texture = RE::BSTextureSet::Texture;

namespace color
{
inline constexpr RE::Color falmer{ 0x8F7F75 };
inline constexpr RE::Color giant{ 0x786f6A };
inline constexpr RE::Color hagraven{ 0x72615B };
inline constexpr RE::Color riekling{ 0x374655 };
}

namespace extra
{
inline constexpr auto TOGGLE{ "PO3_TOGGLE"sv };
inline constexpr auto SKIN_TINT{ "PO3_SKINTINT"sv };
inline constexpr auto HAIR_TINT{ "PO3_HAIRTINT"sv };
inline constexpr auto SKIN_ALPHA{ "PO3_SKINALPHA"sv };
inline constexpr auto FACE_TXST{ "PO3_FACETXST"sv };
inline constexpr auto HEADPART{ "PO3_HEADPART"sv };
inline constexpr auto TXST{ "PO3_TXST"sv };
inline constexpr auto SKIN_TXST{ "PO3_SKINTXST"sv };
inline constexpr auto SHADER{ "PO3_SHADER |"sv };
inline constexpr auto ORIG_SHADER{ "PO3_ORIGINALSHADER"sv };
}

namespace faction
{
inline constexpr RE::FormID falmer{ 0x0002997E };
inline constexpr RE::FormID giant{ 0x0004359A };
inline constexpr RE::FormID hagraven{ 0x0004359E };
inline constexpr RE::FormID riekling{ 0x0401D9C9 };
}

namespace geometry
{
inline constexpr auto head{ "fec_head"sv };
inline constexpr auto headXRay{ "fec_xray_head"sv };
inline constexpr auto body{ "fec_body"sv };
inline constexpr auto bodyCharred{ "fec_charred_body"sv };
}

namespace keyword
{
inline constexpr auto Sun{ "PO3_MagicDamageSun"sv };
inline constexpr auto Fire{ "MagicDamageFire"sv };
inline constexpr auto Frost{ "MagicDamageFrost"sv };
inline constexpr auto Shock{ "MagicDamageShock"sv };
inline constexpr auto Paralysis{ "MagicParalysis"sv };
}

namespace shader
{
inline constexpr RE::FormID fireFXShader{ 0x0001B212 };
inline constexpr RE::FormID DLC1_SunCloakSpellHandFX{ 0x0200A3BD };

inline constexpr std::array<RE::FormID, 3> FEC_fireFXS = { 0x806, 0x826, 0x82F };
inline constexpr std::array<RE::FormID, 3> sunHitFXS = { 0x02019C9D, 0x0200A3BB, 0x0200A3BC };
inline constexpr std::array<RE::FormID, 2> sunHitArt = { 0x0200A3B7, 0x0200A3B8 };
}

namespace slot
{
inline constexpr std::array fxSlots = { Slot::kModMouth, Slot::kModChestPrimary, Slot::kModPelvisPrimary, Slot::kModLegRight, Slot::kModChestSecondary, Slot::kModArmRight };
inline constexpr std::array fxBiped = { Biped::kModMouth, Biped::kModChestPrimary, Biped::kModPelvisPrimary, Biped::kModLegRight, Biped::kModChestSecondary, Biped::kModArmRight };
inline constexpr std::array headparts = { HeadPart::kMisc, HeadPart::kFace, HeadPart::kEyes, HeadPart::kEyebrows };
inline constexpr std::array headSlots = { Biped::kHair, Biped::kLongHair, Biped::kCirclet };
}

namespace str
{
inline constexpr auto embersXDPath = R"(EmbersHD\mx_fireatlas02.dds)"sv;
}

namespace texture
{
inline constexpr std::array types{
Texture::kDiffuse,
Texture::kNormal,
Texture::kEnvironmentMask,
Texture::kGlowMap,
Texture::kHeight,
Texture::kEnvironment,
Texture::kMultilayer,
Texture::kBacklightMask,
Texture::kUnused08
};
}

namespace underwear
{
inline constexpr auto male0{ "MaleUnderwear_1"sv };
inline constexpr auto male1{ "MaleUnderwear"sv };
inline constexpr auto female{ "FemaleUnderwear"sv };
inline constexpr auto himboBoxers{ "HIMBO - Boxers"sv };
inline constexpr auto himboThong{ "HIMBO - Thong"sv };
inline constexpr auto himboBriefs{ "HIMBO - Briefs"sv };
inline constexpr auto bra0{ "Bra"sv };
inline constexpr auto bra1{ "BraBowTies1"sv };
inline constexpr auto bra2{ "BraBowTies2"sv };
inline constexpr auto panty0{ "Panty"sv };
inline constexpr auto panty1{ "PantyBowTies1"sv };
inline constexpr auto panty2{ "PantyBowTies2"sv };

inline constexpr std::array<std::string_view, 13> underwears{
male0,
male1,
female,
himboBoxers,
himboThong,
himboBriefs,
bra0,
bra1,
bra2,
panty0,
panty1,
panty2
};
}
}

namespace ver
{
inline constexpr auto PapyrusExtender{ "po3_PapyrusExtender"sv };
inline constexpr auto PapyrusUtil{ "PapyrusUtil"sv };
inline constexpr auto po3Tweaks{ "po3_Tweaks"sv };

inline constexpr auto PE{ "5.0"sv };
}
Loading

0 comments on commit 7de592b

Please sign in to comment.