Skip to content

Commit

Permalink
Merge branch 'Dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilikusHD committed Oct 21, 2023
2 parents 197775b + 84599f9 commit 6d92d1c
Show file tree
Hide file tree
Showing 26 changed files with 5,843 additions and 756 deletions.
108 changes: 21 additions & 87 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,89 +1,23 @@
# It's recommended to set a minimum CMake version.
# If you use CMake features from higher versions, update this to match.
cmake_minimum_required(VERSION 3.21)

# Set your project name. This will be the name of your SKSE .dll file.
project(ReShadeToggler VERSION 2.0.0 LANGUAGES CXX)

set(headers
include/Reshade/reshade.hpp
include/Reshade/reshade_api.hpp
include/Reshade/reshade_api_device.hpp
include/Reshade/reshade_api_format.hpp
include/Reshade/reshade_api_pipeline.hpp
include/Reshade/reshade_api_resource.hpp
include/Reshade/reshade_events.hpp
include/Reshade/reshade_overlay.hpp
include/ReShadeToggler.h
include/Processor.h
include/ReshadeIntegration.h
include/Globals.h
)


set(sources
src/ReShadeToggler.cpp
src/Processor.cpp
src/ReshadeIntegration.cpp
)

# #
# YOU DO NOT NEED TO EDIT ANYTHING BELOW HERE
# #

# If you're not using a mod manager, you probably want the SKSE plugin to go
# inside of your Skyrim "Data" folder.
#
# To do this automatically, set the `SKYRIM_FOLDER` environment variable
# to the path of your Skyrim Special Edition folder
if(DEFINED ENV{SKYRIM_FOLDER} AND IS_DIRECTORY "$ENV{SKYRIM_FOLDER}/Data")
set(OUTPUT_FOLDER "$ENV{SKYRIM_FOLDER}/Data")
endif()

# If you're using Mod Organizer 2 or Vortex, you might want this to go inside
# of your "mods" folder, inside of a subfolder named "<your mod>".
#
# To do this automatically, set the `SKYRIM_MODS_FOLDER` environment variable
# to the path of your "mods" folder
if(DEFINED ENV{SKYRIM_MODS_FOLDER} AND IS_DIRECTORY "$ENV{SKYRIM_MODS_FOLDER}")
set(OUTPUT_FOLDER "$ENV{SKYRIM_MODS_FOLDER}/${PROJECT_NAME}")
endif()

# Otherwise, you can set OUTPUT_FOLDER to any place you'd like :)
# set(OUTPUT_FOLDER "C:/path/to/any/folder")

# Setup your SKSE plugin as an SKSE plugin!
find_package(CommonLibSSE CONFIG REQUIRED)
add_commonlibsse_plugin(${PROJECT_NAME} SOURCES ${headers} ${sources}) # <--- specifies plugin.cpp
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_23) # <--- use C++23 standard
target_precompile_headers(${PROJECT_NAME} PRIVATE include/PCH.h) # <--- PCH.h is required!

# When your SKSE .dll is compiled, this will automatically copy the .dll into your mods folder.
# Only works if you configure DEPLOY_ROOT above (or set the SKYRIM_MODS_FOLDER environment variable)
if(DEFINED OUTPUT_FOLDER)
# If you specify an <OUTPUT_FOLDER> (including via environment variables)
# then we'll copy your mod files into Skyrim or a mod manager for you!

# Copy the SKSE plugin .dll files into the SKSE/Plugins/ folder
set(DLL_FOLDER "${OUTPUT_FOLDER}/SKSE/Plugins")

message(STATUS "SKSE plugin output folder: ${DLL_FOLDER}")

add_custom_command(
TARGET "${PROJECT_NAME}"
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DLL_FOLDER}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:${PROJECT_NAME}>" "${DLL_FOLDER}/$<TARGET_FILE_NAME:${PROJECT_NAME}>"
VERBATIM
)

# If you perform a "Debug" build, also copy .pdb file (for debug symbols)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_custom_command(
TARGET "${PROJECT_NAME}"
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_PDB_FILE:${PROJECT_NAME}>" "${DLL_FOLDER}/$<TARGET_PDB_FILE_NAME:${PROJECT_NAME}>"
VERBATIM
)
endif()
project(ReShadeToggler VERSION 3.0.0 LANGUAGES CXX)

# Set your project version and specify C++ standard
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Include SKSEPlugin.cmake from the same directory
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(SKSEPlugin)

# Configure MSVC-specific settings for C++23
if(MSVC_VERSION GREATER_EQUAL 1936 AND MSVC_IDE) # 17.6+
file(CONFIGURE OUTPUT "${CMAKE_BINARY_DIR}/Directory.Build.props" CONTENT [==[
<Project>
<ItemDefinitionGroup>
<ClCompile>
<BuildStlModules>false</BuildStlModules>
</ClCompile>
</ItemDefinitionGroup>
</Project>
]==] @ONLY)
endif()
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Sky
Copyright (c) 2023 SkyHorizon3

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Features
**Menu-Based Toggling:** Toggle ReShade effects when entering or leaving specific menus.
**Time-Based Toggling:** Enable or disable ReShade effects during user-defined time intervals.\
**Interior-Based Toggling:** Enable or disable ReShade effects when entering interior cells.\
**Weather-Based Toggling:** Enable or disable ReShade effects during specific weather types.\
**Custom Configuration:** Fine-tune your ReShade toggling preferences via the ImGui menu of ReShade! Save and share created presets easily!

## Requirements
[Address Library for SKSE Plugins](https://www.nexusmods.com/skyrimspecialedition/mods/32444)\
[SKSE](https://www.nexusmods.com/skyrimspecialedition/mods/30379)\
[ReShade 5.9+ with full add-on support](https://reshade.me/)

## Configuration
To configure ReShade Toggler, open the ReShade overlay and navigate to the Add-ons tab. By default, the functionality to disable all effects on the Map Menu, Main Menu, and the Loading Menu is enabled.

For each feature, you can specify whether it should toggle all ReShade effects or specific effects (.fx files). You can also save and load your configuration presets. Use the refresh button to recheck all configurations, which is necessary when adding new INI-Configs.

If you wish to create a more complex preset, we highly recommend using the toggling of specific effects. Enabling all effects can quickly become incompatible with other configuration options.

You can locate the saved presets at the following path: Data\SKSE\Plugins\TogglerConfigs\PresetName.ini.

![alt text](https://i.imgur.com/wGmqlIX.png)

## Compatibility
Compatible with everything thats also compatible with ReShade.
Not compatible with Skyrim-Upscaler-ENB-Test-Build by PureDark.
Works on SE, AE and VR.

## Credits
[crosire](https://www.patreon.com/bePatron?u=23312785&redirect_uri=https%3A%2F%2Freshade.me%2F) for [ReShade](https://reshade.me/)\
[doodlum](https://www.nexusmods.com/skyrimspecialedition/users/28038035) and [PureDark](https://github.com/PureDark) for [skyrim-reshade-helper](https://github.com/doodlum/skyrim-reshade-helper)\
[Skyrim Scripting](https://www.youtube.com/c/SkyrimScripting) for providing skse tutorials and code snippets
44 changes: 44 additions & 0 deletions cmake/AddCXXFiles.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function(add_cxx_files TARGET)
file(GLOB_RECURSE INCLUDE_FILES
LIST_DIRECTORIES false
CONFIGURE_DEPENDS
"include/*.h"
"include/*.hpp"
"include/*.hxx"
"include/*.inl"
)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/include
PREFIX "Header Files"
FILES ${INCLUDE_FILES})

target_sources("${TARGET}" PUBLIC ${INCLUDE_FILES})

file(GLOB_RECURSE HEADER_FILES
LIST_DIRECTORIES false
CONFIGURE_DEPENDS
"src/*.h"
"src/*.hpp"
"src/*.hxx"
"src/*.inl"
)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src
PREFIX "Header Files"
FILES ${HEADER_FILES})

target_sources("${TARGET}" PRIVATE ${HEADER_FILES})

file(GLOB_RECURSE SOURCE_FILES
LIST_DIRECTORIES false
CONFIGURE_DEPENDS
"src/*.cpp"
"src/*.cxx"
)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src
PREFIX "Source Files"
FILES ${SOURCE_FILES})

target_sources("${TARGET}" PRIVATE ${SOURCE_FILES})
endfunction()
19 changes: 19 additions & 0 deletions cmake/Plugin.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include <string_view>

namespace Plugin
{
using namespace std::literals;

inline constexpr REL::Version VERSION
{
// clang-format off
@PROJECT_VERSION_MAJOR@u,
@PROJECT_VERSION_MINOR@u,
@PROJECT_VERSION_PATCH@u,
// clang-format on
};

inline constexpr auto NAME = "@PROJECT_NAME@"sv;
}
68 changes: 68 additions & 0 deletions cmake/SKSEPlugin.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
add_library("${PROJECT_NAME}" SHARED)

# Set C++ standard and enable folder organization
target_compile_features("${PROJECT_NAME}" PRIVATE cxx_std_23)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Include C++ and header files from source directories
include(AddCXXFiles)
add_cxx_files("${PROJECT_NAME}")

# Generate configuration files
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Plugin.h.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake/Plugin.h" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake/version.rc" @ONLY)

# Add generated files to the target
target_sources("${PROJECT_NAME}" PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/cmake/Plugin.h ${CMAKE_CURRENT_BINARY_DIR}/cmake/version.rc)

# Precompile headers
target_precompile_headers("${PROJECT_NAME}" PRIVATE include/PCH.h)

# Enable interprocedural optimization
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF)

# Set Boost options
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)

# MSVC-specific settings
if (CMAKE_GENERATOR MATCHES "Visual Studio")
add_compile_definitions(_UNICODE)

# Set compiler definitions for debug and release builds
target_compile_definitions("${PROJECT_NAME}" PRIVATE "$<$<CONFIG:DEBUG>:DEBUG>")

# Compiler and linker options
set(SC_RELEASE_OPTS "/Zi;/fp:fast;/GL;/Gy-;/Gm-;/Gw;/sdl-;/GS-;/guard:cf-;/O2;/Ob2;/Oi;/Ot;/Oy;/fp:except-")

target_compile_options("${PROJECT_NAME}" PRIVATE
/MP /await /W4 /WX /permissive- /Zc:alignedNew /Zc:auto /Zc:__cplusplus /Zc:externC /Zc:externConstexpr
/Zc:forScope /Zc:hiddenFriend /Zc:implicitNoexcept /Zc:lambda /Zc:noexceptTypes /Zc:preprocessor /Zc:referenceBinding
/Zc:rvalueCast /Zc:sizedDealloc /Zc:strictStrings /Zc:ternary /Zc:threadSafeInit /Zc:trigraphs /Zc:wchar_t
/wd4200 # nonstandard extension used: zero-sized array in struct/union
)

target_compile_options("${PROJECT_NAME}" PUBLIC "$<$<CONFIG:DEBUG>:/fp:strict>")
target_compile_options("${PROJECT_NAME}" PUBLIC "$<$<CONFIG:DEBUG>:/ZI>")
target_compile_options("${PROJECT_NAME}" PUBLIC "$<$<CONFIG:DEBUG>:/Od>")
target_compile_options("${PROJECT_NAME}" PUBLIC "$<$<CONFIG:DEBUG>:/Gy>")
target_compile_options("${PROJECT_NAME}" PUBLIC "$<$<CONFIG:RELEASE>:${SC_RELEASE_OPTS}>")

target_link_options("${PROJECT_NAME}" PRIVATE
/WX
"$<$<CONFIG:DEBUG>:/INCREMENTAL;/OPT:NOREF;/OPT:NOICF>"
"$<$<CONFIG:RELEASE>:/LTCG;/INCREMENTAL:NO;/OPT:REF;/OPT:ICF;/DEBUG:FULL>"
)
endif()

# Find required packages (adjust as needed)
find_package(CommonLibSSE CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)

# Include directories and libraries
target_include_directories("${PROJECT_NAME}" PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories("${PROJECT_NAME}" PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/src)

# Link libraries
target_link_libraries("${PROJECT_NAME}" PUBLIC CommonLibSSE::CommonLibSSE)
32 changes: 32 additions & 0 deletions cmake/Version.rc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <winres.h>

1 VERSIONINFO
FILEVERSION @PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@, 0
PRODUCTVERSION @PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@, 0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "@PROJECT_NAME@"
VALUE "FileVersion", "@[email protected]"
VALUE "InternalName", "@PROJECT_NAME@"
VALUE "LegalCopyright", "MIT License"
VALUE "ProductName", "@PROJECT_NAME@"
VALUE "ProductVersion", "@[email protected]"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
Loading

0 comments on commit 6d92d1c

Please sign in to comment.