Skip to content

Commit

Permalink
Stop!
Browse files Browse the repository at this point in the history
  • Loading branch information
mrowrpurr committed Nov 27, 2022
1 parent 8eb94d5 commit a545dc5
Show file tree
Hide file tree
Showing 19 changed files with 276 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
.idea
cmake-build*
.vs
*.pdb
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Debugger",
"type": "cppvsdbg",
"request": "attach",
}
]
}
57 changes: 57 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
cmake_minimum_required(VERSION 3.21)

project(SkyrimScripting.Stop VERSION 0.0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(DEPLOY_MOD "Copy mod .dll and resource into %SKYRIM_MODS_DEPLOY_ROOT%\\${PROJECT_NAME}" OFF)

# Override <DEPLOY_ROOT> to set the path of a mod to deploy files to.
# The SKSE plugin files will be writen to <DEPLOY_ROOT>/<PROJECT_NAME>/SKSE/Plugins
# You can use the environment variable SKYRIM_MODS_DEPLOY_ROOT to set a default <DEPLOY_ROOT>
# set(DEPLOY_ROOT "C:/some/path/to/mod/path")

set(POST_LOAD_PROJECT SkyrimScripting.Stop.PostLoad)
find_package(CommonLibSSE CONFIG REQUIRED)
add_commonlibsse_plugin(${POST_LOAD_PROJECT} SOURCES Stop_PostLoad.cpp)
target_compile_features(${POST_LOAD_PROJECT} PRIVATE cxx_std_23)
target_precompile_headers(${POST_LOAD_PROJECT} PUBLIC PCH.h)
set_target_properties(${POST_LOAD_PROJECT} PROPERTIES OUTPUT_NAME "~~~~.SkyrimScripting.Stop.PostLoad")

set(DATA_LOADED_PROJECT SkyrimScripting.Stop.DataLoaded)
find_package(CommonLibSSE CONFIG REQUIRED)
add_commonlibsse_plugin(${DATA_LOADED_PROJECT} SOURCES Stop_DataLoaded.cpp)
target_compile_features(${DATA_LOADED_PROJECT} PRIVATE cxx_std_23)
target_precompile_headers(${DATA_LOADED_PROJECT} PUBLIC PCH.h)
set_target_properties(${DATA_LOADED_PROJECT} PROPERTIES OUTPUT_NAME "~~~~.SkyrimScripting.Stop.DataLoaded")

if(DEPLOY_MOD)
if(EXISTS "${DEPLOY_ROOT}")

set(POST_LOAD_MOD_FOLDER "${DEPLOY_ROOT}/${POST_LOAD_PROJECT}")
set(POST_LOAD_DLL_FOLDER "${POST_LOAD_MOD_FOLDER}/SKSE/Plugins")
message(STATUS "Post Load plugin output directory: ${POST_LOAD_MOD_FOLDER}")
add_custom_command(
TARGET "${POST_LOAD_PROJECT}"
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory "${POST_LOAD_DLL_FOLDER}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:${POST_LOAD_PROJECT}>" "${POST_LOAD_DLL_FOLDER}/$<TARGET_FILE_NAME:${POST_LOAD_PROJECT}>"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_PDB_FILE:${POST_LOAD_PROJECT}>" "${POST_LOAD_DLL_FOLDER}/$<TARGET_PDB_FILE_NAME:${POST_LOAD_PROJECT}>"
VERBATIM
)

set(DATA_LOADED_MOD_FOLDER "${DEPLOY_ROOT}/${DATA_LOADED_PROJECT}")
set(DATA_LOADED_DLL_FOLDER "${DATA_LOADED_MOD_FOLDER}/SKSE/Plugins")
message(STATUS "Post Load plugin output directory: ${DATA_LOADED_MOD_FOLDER}")
add_custom_command(
TARGET "${DATA_LOADED_PROJECT}"
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DATA_LOADED_DLL_FOLDER}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:${DATA_LOADED_PROJECT}>" "${DATA_LOADED_DLL_FOLDER}/$<TARGET_FILE_NAME:${DATA_LOADED_PROJECT}>"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_PDB_FILE:${DATA_LOADED_PROJECT}>" "${DATA_LOADED_DLL_FOLDER}/$<TARGET_PDB_FILE_NAME:${DATA_LOADED_PROJECT}>"
VERBATIM
)

endif()
endif()
87 changes: 87 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"version": 2,
"cmakeMinimumRequired": { "major": 3, "minor": 21, "patch": 0 },
"configurePresets": [
{
"name": "flags",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/permissive- /Zc:preprocessor /EHsc /MP /W4 -DWIN32_LEAN_AND_MEAN -DNOMINMAX -DUNICODE -D_UNICODE"
}
},
{
"name": "vcpkg",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "x64-windows-static-md",
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/cmake",
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
}
},
{
"name": "x64",
"hidden": true,
"architecture": { "value": "x64", "strategy": "external" }
},
{
"name": "msvc",
"hidden": true,
"generator": "Visual Studio 17 2022",
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"intelliSenseMode": "windows-msvc-x64",
"enableMicrosoftCodeAnalysis": true,
"enableClangTidyCodeAnalysis": true
}
}
},
{
"name": "mod-deploy",
"hidden": true,
"cacheVariables": {
"DEPLOY_MOD": { "type": "BOOL", "value": "ON" },
"DEPLOY_ROOT": { "type": "STRING", "value": "$env{SKYRIM_MODS_DEPLOY_ROOT}" }
}
},
{
"name": "base-configuration",
"hidden": true,
"inherits": [ "flags", "vcpkg", "x64", "msvc" ]
},
{
"name": "debug-configuration",
"inherits": [ "base-configuration" ],
"displayName": "Debug",
"description": "Debug build",
"binaryDir": "${sourceDir}/build/Debug",
"cacheVariables": { "CMAKE_BUILD_TYPE": { "type": "STRING", "value": "Debug" }}
},
{
"name": "debug-configuration-deploy",
"inherits": ["debug-configuration", "mod-deploy"],
"displayName": "Debug + Deploy",
"description": "Debug and copy .dll and mod resources to SKYRIM_MODS"
},
{
"name": "release-configuration",
"inherits": [ "base-configuration" ],
"displayName": "Release",
"description": "Release build",
"binaryDir": "${sourceDir}/build/Release",
"cacheVariables": { "CMAKE_BUILD_TYPE": { "type": "STRING", "value": "Release" }}
},
{
"name": "release-configuration-deploy",
"inherits": ["release-configuration", "mod-deploy"],
"displayName": "Release + Deploy",
"description": "Release and copy .dll and mod resources to SKYRIM_MODS"
}
],
"buildPresets": [
{ "name": "build-debug", "displayName": "Debug", "configurePreset": "debug-configuration" },
{ "name": "build-debug-deploy", "displayName": "Debug Deploy", "configurePreset": "debug-configuration-deploy" },
{ "name": "build-release", "displayName": "Release", "configurePreset": "release-configuration" },
{ "name": "build-release-deploy", "displayName": "Release Deploy", "configurePreset": "release-configuration-deploy" }
]
}
1 change: 1 addition & 0 deletions Fonts/Attribution.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://www.1001fonts.com/sign-language-font.html
4 changes: 4 additions & 0 deletions Fonts/NOT_FOR_DISTRIBUTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The fonts found in this folder are
**NOT FOR DISTRIBUTION**

> They are here so that I don't lose them and can edit this mod's logo as needed.
4 changes: 4 additions & 0 deletions Fonts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The fonts found in this folder are
**NOT FOR DISTRIBUTION**

> They are here so that I don't lose them and can edit this mod's logo as needed.
Binary file added Fonts/sign-language.regular.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions Images/Attribution.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://pixabay.com/vectors/bodyguard-police-detective-agent-145447/
Binary file added Images/Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Logo.xcf
Binary file not shown.
Binary file added Images/Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/bodyguard-145447.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions PCH.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#include "RE/Skyrim.h"
#include "SKSE/SKSE.h"

using namespace std::literals;
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# Stop
Stop Skyrim right after it starts :)

> Stop Skyrim right after it starts :)
![Stop](Images/Logo.png)

---

Testing SKSE plugins?

Tired of typing `` `qqq<enter>`` ?

Install these 2x SKSE plugins:

![Screenshot](Images/Screenshot.png)

Using your mod manager, enable one of these mods when you want the game to automatically exit after one of these events is reached:

- `kPostLoad` - all SKSE plugins have loaded (_happens before the game UI renders at all, very fast!_)
- `kDataLoaded` - all SKSE and .esp plugins have loaded (_takes a moment, you will see the game UI render_)
31 changes: 31 additions & 0 deletions Stop_DataLoaded.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <spdlog/sinks/basic_file_sink.h>

void InitializeLog() {
auto path = SKSE::log::log_directory();
if (!path) SKSE::stl::report_and_fail("Failed to find standard logging directory"sv);
*path /= fmt::format("{}.log", SKSE::PluginDeclaration::GetSingleton()->GetName());
auto sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(path->string(), true);
const auto level = spdlog::level::trace;
auto log = std::make_shared<spdlog::logger>("global log"s, std::move(sink));
log->set_level(level);
log->flush_on(level);
spdlog::set_default_logger(std::move(log));
spdlog::set_pattern("%g(%#): [%^%l%$] %v"s);
}

SKSEPluginLoad(const SKSE::LoadInterface* skse) {
InitializeLog();
SKSE::log::info("Hold onto your butts!");

SKSE::Init(skse);

// Once all plugins and mods are loaded, then the ~ console is ready and can be printed to
SKSE::GetMessagingInterface()->RegisterListener([](SKSE::MessagingInterface::Message* message){
if (message->type == SKSE::MessagingInterface::kDataLoaded) {
SKSE::log::info("kDataLoaded, closing Skyrim!");
SKSE::WinAPI::TerminateProcess(SKSE::WinAPI::GetCurrentProcess(), EXIT_SUCCESS);
}
});

return true;
}
31 changes: 31 additions & 0 deletions Stop_PostLoad.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <spdlog/sinks/basic_file_sink.h>

void InitializeLog() {
auto path = SKSE::log::log_directory();
if (!path) SKSE::stl::report_and_fail("Failed to find standard logging directory"sv);
*path /= fmt::format("{}.log", SKSE::PluginDeclaration::GetSingleton()->GetName());
auto sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(path->string(), true);
const auto level = spdlog::level::trace;
auto log = std::make_shared<spdlog::logger>("global log"s, std::move(sink));
log->set_level(level);
log->flush_on(level);
spdlog::set_default_logger(std::move(log));
spdlog::set_pattern("%g(%#): [%^%l%$] %v"s);
}

SKSEPluginLoad(const SKSE::LoadInterface* skse) {
InitializeLog();
SKSE::log::info("Hold onto your butts!");

SKSE::Init(skse);

// Once all plugins and mods are loaded, then the ~ console is ready and can be printed to
SKSE::GetMessagingInterface()->RegisterListener([](SKSE::MessagingInterface::Message* message){
if (message->type == SKSE::MessagingInterface::kPostLoad) {
SKSE::log::info("kPostLoad, closing Skyrim!");
SKSE::WinAPI::TerminateProcess(SKSE::WinAPI::GetCurrentProcess(), EXIT_SUCCESS);
}
});

return true;
}
12 changes: 12 additions & 0 deletions vcpkg-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"registries": [
{
"kind": "git",
"repository": "https://gitlab.com/colorglass/vcpkg-colorglass",
"baseline": "6fb127f7d425ae3cf3fab0f79005d907c885c0d8",
"packages": [
"commonlibsse-ng"
]
}
]
}
8 changes: 8 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
"name": "sample-plugin",
"version-string": "0.0.1",
"dependencies": [
"commonlibsse-ng"
]
}

0 comments on commit a545dc5

Please sign in to comment.