diff --git a/.clang-format b/.clang-format deleted file mode 100644 index f6e16bf..0000000 --- a/.clang-format +++ /dev/null @@ -1,28 +0,0 @@ ---- -# This file is optional but helps me ensure the same -# code style is used in all templates. -# -# You can find out more about these configuration files at: -# https://clang.llvm.org/docs/ClangFormatStyleOptions.html -# -# To use this file, configure your IDE to use "clang-format". -# This will be different for each IDE. -# -# You can download "clang-format" by installing LLVM from here: -# https://github.com/llvm/llvm-project/releases -# -# ^ look for the latest release which has a win64.exe installer -# and be sure to choose the option to add LLVM to your PATH -# when installing -# -UseTab: Never -TabWidth: '4' -IndentWidth: '4' -BasedOnStyle: Google -AccessModifierOffset: -4 -ColumnLimit: 120 -NamespaceIndentation: All -IndentPPDirectives: BeforeHash -FixNamespaceComments: false - -... diff --git a/.clang-tidy b/.clang-tidy deleted file mode 100644 index 77fde30..0000000 --- a/.clang-tidy +++ /dev/null @@ -1,6 +0,0 @@ -FormatStyle: google -CheckOptions: - - key: misc-definitions-in-headers.HeaderFileExtensions - value: '' - - key: misc-definitions-in-headers.UseHeaderFileExtension - value: '1' diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 58d6794..0000000 --- a/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.idea -.vs -.vscode/settings.json -build -cmake-build* \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index a2f97a0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "C++ Debugger", - "type": "cppvsdbg", - "request": "attach", - } - ] -} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 3d3f4f7..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -cmake_minimum_required(VERSION 3.21) - -project(SkyrimScripting.Plugin VERSION 0.1.0 LANGUAGES CXX) - -add_library(${PROJECT_NAME} INTERFACE) - -find_package(CommonLibSSE CONFIG REQUIRED) -target_link_libraries(${PROJECT_NAME} INTERFACE CommonLibSSE::CommonLibSSE) - -target_include_directories( - ${PROJECT_NAME} - INTERFACE - $ - $ -) - -include(GNUInstallDirs) - -install(DIRECTORY include DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/..") - -install( - TARGETS ${PROJECT_NAME} - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # static and import libs? - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # .so? - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # .dll -) - -install( - EXPORT ${PROJECT_NAME}-targets - FILE ${PROJECT_NAME}-targets.cmake - NAMESPACE "SkyrimScriptingPlugin::" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake" -) - -configure_file( - cmake/Config.cmake.in - ${PROJECT_NAME}Config.cmake - @ONLY -) - -install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake" -) - -add_subdirectory(Examples) diff --git a/CMakePresets.json b/CMakePresets.json deleted file mode 100644 index 3e5a89f..0000000 --- a/CMakePresets.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "version": 3, - "configurePresets": [ - { - "name": "base", - "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/${presetName}", - "installDir": "${sourceDir}/install/${presetName}", - "architecture": { "value": "x64", "strategy": "external" }, - "cacheVariables": { - "CMAKE_CXX_COMPILER": "cl.exe", - "CMAKE_CXX_FLAGS": "/std:c++20 /permissive- /Zc:preprocessor /EHsc /MP /W4 -DWIN32_LEAN_AND_MEAN -DNOMINMAX -DUNICODE -D_UNICODE", - "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$<$:Debug>DLL", - "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" - } - }, - { - "name": "debug", - "inherits": ["base"], - "displayName": "Debug", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } - }, - { - "name": "release", - "inherits": ["base"], - "displayName": "Release", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } - } - ] -} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 79d137f..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,128 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, religion, or sexual identity -and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the - overall community - -Examples of unacceptable behavior include: - -* The use of sexualized language or imagery, and sexual attention or - advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email - address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at -mrowr.purr@gmail.com (or, better yet, please find Mrowr Purr directly on Discord and send a DM). -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series -of actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or -permanent ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within -the community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.0, available at -https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. - -Community Impact Guidelines were inspired by [Mozilla's code of conduct -enforcement ladder](https://github.com/mozilla/diversity). - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see the FAQ at -https://www.contributor-covenant.org/faq. Translations are available at -https://www.contributor-covenant.org/translations. diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt deleted file mode 100644 index a853c8d..0000000 --- a/Examples/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(PluginDemo) \ No newline at end of file diff --git a/Examples/Plugin-with-Entrypoint/plugin.cpp b/Examples/Plugin-with-Entrypoint/plugin.cpp new file mode 100644 index 0000000..8a2c852 --- /dev/null +++ b/Examples/Plugin-with-Entrypoint/plugin.cpp @@ -0,0 +1,11 @@ +#include + +_SKSEPlugin_Init_ { + // ... +} + +_SKSEPlugin_Init_HighPriority_ { + // ... +} + +_SKSEPlugin_PreInit_(const SKSE::LoadInterface*) { return true; } diff --git a/Examples/Plugin-with-Entrypoint/secondCpp.cpp b/Examples/Plugin-with-Entrypoint/secondCpp.cpp new file mode 100644 index 0000000..893c436 --- /dev/null +++ b/Examples/Plugin-with-Entrypoint/secondCpp.cpp @@ -0,0 +1,11 @@ +#include + +__SKSEPlugin_Init__(SecondFile) { + // ... +} + +__SKSEPlugin_Init_HighPriority__(SecondFile) { + // ... +} + +__SKSEPlugin_PreInit__(SecondFile)(const SKSE::LoadInterface*) { return true; } diff --git a/Examples/Plugin-with-Entrypoint/xmake.lua b/Examples/Plugin-with-Entrypoint/xmake.lua new file mode 100644 index 0000000..00ab1ad --- /dev/null +++ b/Examples/Plugin-with-Entrypoint/xmake.lua @@ -0,0 +1,9 @@ +add_requires("skyrim-commonlib") + +target("Using_Plugin_Entrypoint") + add_files("*.cpp") + add_packages("skyrim-commonlib") + add_deps("SkyrimScripting.Plugin.Entrypoint") + add_rules("@skyrim-commonlib/plugin", { + mods_folder = os.getenv("SKYRIM_MODS_AE") + }) diff --git a/Examples/Plugin-with-Logging/Example.Plugin.WithLogging.cpp b/Examples/Plugin-with-Logging/Example.Plugin.WithLogging.cpp new file mode 100644 index 0000000..86593a0 --- /dev/null +++ b/Examples/Plugin-with-Logging/Example.Plugin.WithLogging.cpp @@ -0,0 +1,39 @@ +#include + +_OnInit_ { + SKSE::log::info("This is an SKSE log message (using SKSE::log) {}", 420); + + // Only care about _Log_ because it's what's used internally by SkyrimScripting* libraries + _Log_("This is an SKSE log message (using _Log_) {}", 69); +} + +_OnPluginsLoaded_ { _Log_("Hello from _OnPluginsLoaded_"); } +_OnAfterPluginsLoaded_ { _Log_("Hello from _OnAfterPluginsLoaded_"); } +_OnInputLoaded_ { _Log_("Hello from _OnInputLoaded_"); } + +_OnDataLoaded_ { _Log_("Hello from _OnDataLoaded_"); } + +_OnNewGame_(RE::TESQuest* quest) { + _Log_("Hello from _OnNewGame_"); + _Log_("Quest: {}", quest->GetName()); +} + +_OnSaveGame_(std::filesystem::path path) { + _Log_("Hello from _OnSaveGame_"); + _Log_("Path: {}", path.string().c_str()); +} + +_OnLoadingGame_(std::filesystem::path path) { + _Log_("Hello from _OnLoadingGame_"); + _Log_("Path: {}", path.string().c_str()); +} + +_OnLoadedGame_(bool success) { + _Log_("Hello from _OnLoadedGame_"); + _Log_("Success: {}", success); +} + +_OnDeleteGame_(std::filesystem::path path) { + _Log_("Hello from _OnDeleteGame_"); + _Log_("Path: {}", path.string().c_str()); +} diff --git a/Examples/Plugin-with-Logging/SecondFile.cpp b/Examples/Plugin-with-Logging/SecondFile.cpp new file mode 100644 index 0000000..246c9c3 --- /dev/null +++ b/Examples/Plugin-with-Logging/SecondFile.cpp @@ -0,0 +1,3 @@ +#include + +_OnInit_ { _Log_("Hello from OnInit in a second .cpp file"); } diff --git a/Examples/Plugin-with-Logging/xmake.lua b/Examples/Plugin-with-Logging/xmake.lua new file mode 100644 index 0000000..f004729 --- /dev/null +++ b/Examples/Plugin-with-Logging/xmake.lua @@ -0,0 +1,9 @@ +add_requires("skyrim-commonlib") + +target("SkyrimScripting.Plugin - Example with Logging") + add_files("*.cpp") + add_deps("SkyrimScripting.Plugin") + add_packages("skyrim-commonlib") + add_rules("@skyrim-commonlib/plugin", { + mod_folders = os.getenv("SKYRIM_SCRIPTING_MOD_FOLDERS") + }) diff --git a/Examples/PluginDemo/CMakeLists.txt b/Examples/PluginDemo/CMakeLists.txt deleted file mode 100644 index 775c9c8..0000000 --- a/Examples/PluginDemo/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -project(PluginDemo VERSION 0.0.1 LANGUAGES CXX) - -find_package(SkyrimScripting.CMake CONFIG REQUIRED) - -set(SKYRIMSCRIPTING_DEBUG true) -add_skse_plugin(${PROJECT_NAME} SOURCES plugin.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE SkyrimScripting.Plugin) diff --git a/Examples/PluginDemo/plugin.cpp b/Examples/PluginDemo/plugin.cpp deleted file mode 100644 index d9111be..0000000 --- a/Examples/PluginDemo/plugin.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// #include - -// EventHandlers { -// On([](const RE::TESActivateEvent* activation) { -// auto activator = activation ? activation->actionRef->GetBaseObject()->GetName() : ""; -// auto activated = activation->objectActivated ? activation->objectActivated->GetBaseObject()->GetName() : ""; -// logger::info("{} activated {}", activator, activated); -// }); - -// On([](const RE::TESContainerChangedEvent* event) { -// logger::info("{} {:x} transferred from {:x} to {:x}", event->itemCount, event->baseObj, event->oldContainer, -// event->newContainer); -// }); -// } - -#include - -OnInit { logger::info("INIT FROM THE MACRO!"); } - -SKSEPluginLoad(const SKSE::LoadInterface* skse) { - SKSE::Init(skse); - SkyrimScripting::Plugin::Initialize(); - return true; -} - -OnInputLoaded { ConsoleLog("Hello! {} {} {}", 1, 2, 3); } diff --git a/Examples/VcpkgDemo/.clang-format b/Examples/VcpkgDemo/.clang-format deleted file mode 100644 index f6e16bf..0000000 --- a/Examples/VcpkgDemo/.clang-format +++ /dev/null @@ -1,28 +0,0 @@ ---- -# This file is optional but helps me ensure the same -# code style is used in all templates. -# -# You can find out more about these configuration files at: -# https://clang.llvm.org/docs/ClangFormatStyleOptions.html -# -# To use this file, configure your IDE to use "clang-format". -# This will be different for each IDE. -# -# You can download "clang-format" by installing LLVM from here: -# https://github.com/llvm/llvm-project/releases -# -# ^ look for the latest release which has a win64.exe installer -# and be sure to choose the option to add LLVM to your PATH -# when installing -# -UseTab: Never -TabWidth: '4' -IndentWidth: '4' -BasedOnStyle: Google -AccessModifierOffset: -4 -ColumnLimit: 120 -NamespaceIndentation: All -IndentPPDirectives: BeforeHash -FixNamespaceComments: false - -... diff --git a/Examples/VcpkgDemo/.gitignore b/Examples/VcpkgDemo/.gitignore deleted file mode 100644 index 58d6794..0000000 --- a/Examples/VcpkgDemo/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.idea -.vs -.vscode/settings.json -build -cmake-build* \ No newline at end of file diff --git a/Examples/VcpkgDemo/.vscode/launch.json b/Examples/VcpkgDemo/.vscode/launch.json deleted file mode 100644 index a2f97a0..0000000 --- a/Examples/VcpkgDemo/.vscode/launch.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "C++ Debugger", - "type": "cppvsdbg", - "request": "attach", - } - ] -} \ No newline at end of file diff --git a/Examples/VcpkgDemo/CMakeLists.txt b/Examples/VcpkgDemo/CMakeLists.txt deleted file mode 100644 index 83a9dfd..0000000 --- a/Examples/VcpkgDemo/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.21) - -project(PluginVcpkgDemo VERSION 0.0.1 LANGUAGES CXX) - -find_package(SkyrimScripting.CMake CONFIG REQUIRED) -find_package(SkyrimScripting.Plugin CONFIG REQUIRED) - -add_skse_plugin(${PROJECT_NAME} SOURCES plugin.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE SkyrimScriptingPlugin::SkyrimScripting.Plugin) diff --git a/Examples/VcpkgDemo/CMakePresets.json b/Examples/VcpkgDemo/CMakePresets.json deleted file mode 100644 index ccad07a..0000000 --- a/Examples/VcpkgDemo/CMakePresets.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "version": 3, - "configurePresets": [ - { - "name": "base", - "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/${presetName}", - "installDir": "${sourceDir}/install/${presetName}", - "architecture": { "value": "x64", "strategy": "external" }, - "cacheVariables": { - "CMAKE_CXX_COMPILER": "cl.exe", - "CMAKE_CXX_FLAGS": "/permissive- /Zc:preprocessor /EHsc /MP /W4 -DWIN32_LEAN_AND_MEAN -DNOMINMAX -DUNICODE -D_UNICODE", - "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$<$:Debug>DLL", - "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" - } - }, - { - "name": "debug", - "inherits": ["base"], - "displayName": "Debug", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } - }, - { - "name": "release", - "inherits": ["base"], - "displayName": "Release", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } - } - ] -} diff --git a/Examples/VcpkgDemo/CODE_OF_CONDUCT.md b/Examples/VcpkgDemo/CODE_OF_CONDUCT.md deleted file mode 100644 index 2f61f36..0000000 --- a/Examples/VcpkgDemo/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,128 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, religion, or sexual identity -and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the - overall community - -Examples of unacceptable behavior include: - -* The use of sexualized language or imagery, and sexual attention or - advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email - address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at -. -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series -of actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or -permanent ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within -the community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.0, available at -https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. - -Community Impact Guidelines were inspired by [Mozilla's code of conduct -enforcement ladder](https://github.com/mozilla/diversity). - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see the FAQ at -https://www.contributor-covenant.org/faq. Translations are available at -https://www.contributor-covenant.org/translations. diff --git a/Examples/VcpkgDemo/LICENSE b/Examples/VcpkgDemo/LICENSE deleted file mode 100644 index 966fe73..0000000 --- a/Examples/VcpkgDemo/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Examples/VcpkgDemo/PCH.h b/Examples/VcpkgDemo/PCH.h deleted file mode 100644 index 58d2537..0000000 --- a/Examples/VcpkgDemo/PCH.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include "RE/Skyrim.h" -#include "SKSE/SKSE.h" - -using namespace std::literals; diff --git a/Examples/VcpkgDemo/README.md b/Examples/VcpkgDemo/README.md deleted file mode 100644 index 6d6984a..0000000 --- a/Examples/VcpkgDemo/README.md +++ /dev/null @@ -1,77 +0,0 @@ -> 📜 other templates available at https://github.com/SkyrimScripting/SKSE_Templates - -# SKSE - Game Events - -A simple SKSE plugin for Skyrim using: - -- C++ -- CMake -- [CommonLibSSE NG](https://github.com/CharmedBaryon/CommonLibSSE-NG) - - _automatically downloaded using vcpkg integration of CMake_ - -> Because this uses CommonLibSSE NG, it supports Skyrim SSE, AE, GOG, and VR! - -## What does it do? - -It writes to a log file whenever certain events in the game happen: -- Whenever the player or any NPC "activates" something (_e.g. opening a door, interacting with an object, etc_) -- Whenever a game menu is opened or closed - -There are many more events which you can easily monitor via your SKSE plugins! - -To find some, I recommend searching [CommonLibSSE](https://github.com/CharmedBaryon/CommonLibSSE-NG) for files with `TES*Event` in their names. - -1. Visit this link: https://github.com/CharmedBaryon/CommonLibSSE-NG -2. Press the `T` key to open the fuzzy find file search -3. Type `TESEvent` -4. Choose any of the files that show up! They're probably events that you can get via an event sink 😸 - -Read [`plugin.cpp`](plugin.cpp) for details on what it's doing! - -## Requirements - -- [Visual Studio 2022](https://visualstudio.microsoft.com/) (_the free Community edition is fine!_) -- [`vcpkg`](https://github.com/microsoft/vcpkg) - - 1. Clone the repository using git OR [download it as a .zip](https://github.com/microsoft/vcpkg/archive/refs/heads/master.zip) - - 2. Go into the `vcpkg` folder and double-click on `bootstrap-vcpkg.bat` - - 3. Edit your system or user Environment Variables and add a new one: - - Name: `VCPKG_ROOT` - Value: `C:\path\to\wherever\your\vcpkg\folder\is` - -Once you have Visual Studio 2022 installed, you can open this folder in basically any C++ editor, e.g. [VS Code](https://code.visualstudio.com/) or [CLion](https://www.jetbrains.com/clion/) or [Visual Studio](https://visualstudio.microsoft.com/) -- > _for VS Code, if you are not automatically prompted to install the [C++](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) and [CMake Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) extensions, please install those and then close VS Code and then open this project as a folder in VS Code_ - -You may need to click `OK` on a few windows, but the project should automatically run CMake! - -It will _automatically_ download [CommonLibSSE NG](https://github.com/CharmedBaryon/CommonLibSSE-NG) and everything you need to get started making your new plugin! - -## Project setup - -By default, when this project compiles it will output a `.dll` for your SKSE plugin into the `build/` folder. - -But you probably want to put the `.dll` into your Skyrim mods folder, e.g. the mods folder used by Mod Organizer 2 or Vortex. - -You can configure this project to _automatically_ output the SKSE plugin `.dll` into: -- `\\SKSE\Plugins\.dll` - if you set the `SKYRIM_MODS_FOLDER` environment variable to the **root of your mods folder** (i.e. ``) - -- **Example:** - - Name: `SKYRIM_MODS_FOLDER` - Value: `C:\path\to\wherever\your\Skyrim\mods\are` - -## Setup your own repository - -If you clone this template on GitHub, please: - -- Go into `LICENSE` and change the year and change `` to your name. -- Go into `CODE_OF_CONDUCT.md` and change `` to your contact information. - -It's good to have a `Code of Conduct` and GitHub will show your project's `CODE_OF_CONDUCT.md` in the project sidebar. - -If you'd like to know more about open source licenses, see: -- [Licensing a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository) -- [Choose an open source license](https://choosealicense.com/) - -**If you use this template, PLEASE release your project as a public open source project.** 💖 - -**PLEASE DO NOT RELEASE YOUR SKSE PLUGIN ON NEXUS/ETC WITHOUT MAKING THE SOURCE CODE AVAILABLE** diff --git a/Examples/VcpkgDemo/plugin.cpp b/Examples/VcpkgDemo/plugin.cpp deleted file mode 100644 index 32ebb79..0000000 --- a/Examples/VcpkgDemo/plugin.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -OnInit { logger::info("Hello, world! I am a plugin."); } - -EventHandlers { - On([](const RE::TESActivateEvent* event) { - auto activator = event->actionRef ? event->actionRef->GetBaseObject()->GetName() : ""; - auto activated = event->objectActivated ? event->objectActivated->GetBaseObject()->GetName() : ""; - logger::info("{} activated {}", activator, activated); - }); -} diff --git a/Examples/VcpkgDemo/vcpkg-configuration.json b/Examples/VcpkgDemo/vcpkg-configuration.json deleted file mode 100644 index 7a0ca41..0000000 --- a/Examples/VcpkgDemo/vcpkg-configuration.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "default-registry": { - "kind": "git", - "repository": "https://github.com/microsoft/vcpkg.git", - "baseline": "cc288af760054fa489574bd8e22d05aa8fa01e5c" - }, - "registries": [ - { - "kind": "git", - "repository": "https://gitlab.com/colorglass/vcpkg-colorglass", - "baseline": "6fb127f7d425ae3cf3fab0f79005d907c885c0d8", - "packages": [ - "commonlibsse-ng" - ] - }, - { - "kind": "git", - "repository": "https://github.com/SkyrimScripting/vcpkg.git", - "baseline": "f1f03d792aaccccd2df1334e4b09955f667f7214", - "packages": [ - "skyrimscripting-cmake" - ] - }, - { - "kind": "git", - "repository": "file://c:/Code/SkyrimScripting/vcpkg_Examples", - "baseline": "9c1a1b2a6bdefa87f12269b5084607bd6221d86e", - "packages": [ - "skyrimscripting-plugin" - ] - } - ] -} \ No newline at end of file diff --git a/Examples/VcpkgDemo/vcpkg.json b/Examples/VcpkgDemo/vcpkg.json deleted file mode 100644 index 64a30cd..0000000 --- a/Examples/VcpkgDemo/vcpkg.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json", - "name": "hello-world", - "version-string": "0.0.1", - "dependencies": [ - "commonlibsse-ng", - "skyrimscripting-cmake", - "skyrimscripting-plugin" - ] -} \ No newline at end of file diff --git a/README.md b/README.md index 7b014f7..224f8ba 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # SKSE Plugin helpers +> `v2` WIP - this is a work in progress. All of the below might change... + ![SKSE Plugin](Images/Plugin_Logo.png) - [SKSE Plugin helpers](#skse-plugin-helpers) @@ -108,18 +110,18 @@ OnNewGame { The following callback macros are available: -| | Timing | SKSE Event | -|-|-|-| -| `OnPluginLoad`
`OnInit` | Runs immediately, as soon as the SKSE plugin is loaded. | n/a | -| `OnPluginsLoaded` | Runs as soon as all SKSE plugins have been loaded.
It can be preferable to run code here, as any code run in `OnInit` may run before other SKSE plugins have loaded. | `kPostLoad` | -| `AfterPluginsLoaded` | Runs immediately after `OnPluginsLoaded`. Infrequently used, but can be useful for coordinating messaging with other plugins. | `kPostPostLoad` | -| `OnLoadingGame` | Runs _before_ the savegame is loaded by Skyrim.
`TODO: provide a way to get the size/path of the .ess save game` | `kPreLoadGame` | -| `OnLoadedGame` | Runs _after_ the savegame has been loaded by Skyrim.
`TODO: provide a way to get whether load was successful` | `kPostLoadGame` | -| `OnSaveGame` | Runs when saving a game | `kSaveGame` | -| `OnDeleteGame` | Runs when deleting a game | `kDeleteGame` | -| `OnNewGame` | Runs after a new game has been created, but before the game has loaded | `kNewGame` | -| `OnInputLoaded` | Runs after the game's input initializes, right before the Main Menu initializes | `kInputLoaded` | -| `OnDataLoaded`
`OnFormsLoaded` | Runs after all of the game mods have been loaded (all Forms are loaded) | `kDataLoaded` | +| | Timing | SKSE Event | +| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- | +| `OnPluginLoad`
`OnInit` | Runs immediately, as soon as the SKSE plugin is loaded. | n/a | +| `OnPluginsLoaded` | Runs as soon as all SKSE plugins have been loaded.
It can be preferable to run code here, as any code run in `OnInit` may run before other SKSE plugins have loaded. | `kPostLoad` | +| `AfterPluginsLoaded` | Runs immediately after `OnPluginsLoaded`. Infrequently used, but can be useful for coordinating messaging with other plugins. | `kPostPostLoad` | +| `OnLoadingGame` | Runs _before_ the savegame is loaded by Skyrim.
`TODO: provide a way to get the size/path of the .ess save game` | `kPreLoadGame` | +| `OnLoadedGame` | Runs _after_ the savegame has been loaded by Skyrim.
`TODO: provide a way to get whether load was successful` | `kPostLoadGame` | +| `OnSaveGame` | Runs when saving a game | `kSaveGame` | +| `OnDeleteGame` | Runs when deleting a game | `kDeleteGame` | +| `OnNewGame` | Runs after a new game has been created, but before the game has loaded | `kNewGame` | +| `OnInputLoaded` | Runs after the game's input initializes, right before the Main Menu initializes | `kInputLoaded` | +| `OnDataLoaded`
`OnFormsLoaded` | Runs after all of the game mods have been loaded (all Forms are loaded) | `kDataLoaded` | ### Providing your own `SKSEPluginLoad` diff --git a/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint.h b/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint.h new file mode 100644 index 0000000..be2eb70 --- /dev/null +++ b/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint.h @@ -0,0 +1,4 @@ +#pragma once + +#include "Entrypoint/Functions.h" // IWYU pragma: keep +#include "Entrypoint/Main.h" // IWYU pragma: keep diff --git a/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Functions.h b/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Functions.h new file mode 100644 index 0000000..ade86fb --- /dev/null +++ b/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Functions.h @@ -0,0 +1,3 @@ +#pragma once + +#include "Internal/EntrypointMacros.h" // IWYU pragma: keep diff --git a/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Internal/EntrypointCallbacks.h b/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Internal/EntrypointCallbacks.h new file mode 100644 index 0000000..2a13aab --- /dev/null +++ b/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Internal/EntrypointCallbacks.h @@ -0,0 +1,121 @@ +#pragma once + +#include + +#include +#include + +namespace SkyrimScripting::Plugin::Entrypoint { + + class EntrypointCallbacks { + std::vector> _preInitHighPriorityCallbacks; + std::vector> _preInitCallbacks; + std::vector> _preInitLowPriorityCallbacks; + + std::vector> _postInitHighPriorityCallbacks; + std::vector> _postInitCallbacks; + std::vector> _postInitLowPriorityCallbacks; + + std::vector> _initHighPriorityCallbacks; + std::vector> _initCallbacks; + std::vector> _initLowPriorityCallbacks; + + public: + static EntrypointCallbacks& GetSingleton() { + static EntrypointCallbacks instance; + return instance; + } + + /* Register Pre Init */ + + void RegisterPreInitHighPriorityCallback( + std::function callback + ) { + _preInitHighPriorityCallbacks.push_back(callback); + } + void RegisterPreInitCallback(std::function callback) { + _preInitCallbacks.push_back(callback); + } + void RegisterPreInitLowPriorityCallback( + std::function callback + ) { + _preInitLowPriorityCallbacks.push_back(callback); + } + + /* Register Post Init */ + + void RegisterPostInitHighPriorityCallback( + std::function callback + ) { + _postInitHighPriorityCallbacks.push_back(callback); + } + void RegisterPostInitCallback(std::function callback) { + _postInitCallbacks.push_back(callback); + } + void RegisterPostInitLowPriorityCallback( + std::function callback + ) { + _postInitLowPriorityCallbacks.push_back(callback); + } + + /* Register Post Post Init */ + + void RegisterInitHighPriorityCallback(std::function callback) { + _initHighPriorityCallbacks.push_back(callback); + } + void RegisterInitCallback(std::function callback) { + _initCallbacks.push_back(callback); + } + void RegisterInitLowPriorityCallback(std::function callback) { + _initLowPriorityCallbacks.push_back(callback); + } + + /* Run Pre Init */ + + bool RunPreInitHighPriorityCallbacks(const SKSE::LoadInterface* skse) { + for (auto& callback : _preInitHighPriorityCallbacks) + if (!callback(skse)) return false; + return true; + } + bool RunPreInitCallbacks(const SKSE::LoadInterface* skse) { + for (auto& callback : _preInitCallbacks) + if (!callback(skse)) return false; + return true; + } + bool RunPreInitLowPriorityCallbacks(const SKSE::LoadInterface* skse) { + for (auto& callback : _preInitLowPriorityCallbacks) + if (!callback(skse)) return false; + return true; + } + + /* Run Post Init */ + + bool RunPostInitHighPriorityCallbacks(const SKSE::LoadInterface* skse) { + for (auto& callback : _postInitHighPriorityCallbacks) + if (!callback(skse)) return false; + return true; + } + bool RunPostInitCallbacks(const SKSE::LoadInterface* skse) { + for (auto& callback : _postInitCallbacks) + if (!callback(skse)) return false; + return true; + } + bool RunPostInitLowPriorityCallbacks(const SKSE::LoadInterface* skse) { + for (auto& callback : _postInitLowPriorityCallbacks) + if (!callback(skse)) return false; + return true; + } + + /* Run Post Post Init */ + + void RunHighPriorityCallbacks() { + for (auto& callback : _initHighPriorityCallbacks) callback(); + } + void RunCallbacks() { + for (auto& callback : _initCallbacks) callback(); + } + void RunLowPriorityCallbacks() { + for (auto& callback : _initLowPriorityCallbacks) callback(); + } + }; +} diff --git a/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Internal/EntrypointMacros.h b/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Internal/EntrypointMacros.h new file mode 100644 index 0000000..b9d3e20 --- /dev/null +++ b/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Internal/EntrypointMacros.h @@ -0,0 +1,101 @@ +#pragma once + +#include + +#include "EntrypointCallbacks.h" // IWYU pragma: keep + +/* Register Pre Init */ + +#define __SKSEPlugin_PreInit_HighPriority__(scopeSymbol) \ + _GLOBAL_MACRO_FUNCTIONS_REGISTER_NEW_NAMED_FUNCTION_WITH_RETURN_AND_ARGUMENTS( \ + scopeSymbol, \ + SkyrimScripting::Plugin::Entrypoint::EntrypointCallbacks::GetSingleton() \ + .RegisterPreInitHighPriorityCallback, \ + bool, \ + const SKSE::LoadInterface* \ + ) + +#define _SKSEPlugin_PreInit_HighPriority_ __SKSEPlugin_PreInit_HighPriority__(DEFAULT) + +#define __SKSEPlugin_PreInit__(scopeSymbol) \ + _GLOBAL_MACRO_FUNCTIONS_REGISTER_NEW_NAMED_FUNCTION_WITH_RETURN_AND_ARGUMENTS( \ + scopeSymbol, \ + SkyrimScripting::Plugin::Entrypoint::EntrypointCallbacks::GetSingleton() \ + .RegisterPreInitCallback, \ + bool, \ + const SKSE::LoadInterface* \ + ) + +#define _SKSEPlugin_PreInit_ __SKSEPlugin_PreInit__(DEFAULT) + +#define __SKSEPlugin_PreInit_LowPriority__(scopeSymbol) \ + _GLOBAL_MACRO_FUNCTIONS_REGISTER_NEW_NAMED_FUNCTION_WITH_RETURN_AND_ARGUMENTS( \ + scopeSymbol, \ + SkyrimScripting::Plugin::Entrypoint::EntrypointCallbacks::GetSingleton() \ + .RegisterPreInitLowPriorityCallback, \ + bool, \ + const SKSE::LoadInterface* \ + ) + +#define _SKSEPlugin_PreInit_LowPriority_ __SKSEPlugin_PreInit_LowPriority__(DEFAULT) + +/* Register Post Init */ + +#define __SKSEPlugin_PostInit_HighPriority__(scopeSymbol) \ + _GLOBAL_MACRO_FUNCTIONS_REGISTER_NEW_NAMED_FUNCTION_WITH_RETURN_AND_ARGUMENTS( \ + scopeSymbol, \ + SkyrimScripting::Plugin::Entrypoint::EntrypointCallbacks::GetSingleton() \ + .RegisterPostInitHighPriorityCallback, \ + bool, \ + const SKSE::LoadInterface* \ + ) + +#define _SKSEPlugin_PostInit_HighPriority_ __SKSEPlugin_PostInit_HighPriority__(DEFAULT) + +#define __SKSEPlugin_PostInit__(scopeSymbol) \ + _GLOBAL_MACRO_FUNCTIONS_REGISTER_NEW_NAMED_FUNCTION_WITH_RETURN_AND_ARGUMENTS( \ + scopeSymbol, \ + SkyrimScripting::Plugin::Entrypoint::EntrypointCallbacks::GetSingleton() \ + .RegisterPostInitCallback, \ + bool, \ + const SKSE::LoadInterface* \ + ) + +#define _SKSEPlugin_PostInit_ __SKSEPlugin_PostInit__(DEFAULT) + +#define __SKSEPlugin_PostInit_LowPriority__(scopeSymbol) \ + _GLOBAL_MACRO_FUNCTIONS_REGISTER_NEW_NAMED_FUNCTION_WITH_RETURN_AND_ARGUMENTS( \ + scopeSymbol, \ + SkyrimScripting::Plugin::Entrypoint::EntrypointCallbacks::GetSingleton() \ + .RegisterPostInitLowPriorityCallback, \ + const SKSE::LoadInterface* \ + ) + +/* Register Post Post Init */ + +#define __SKSEPlugin_Init_HighPriority__(scopeSymbol) \ + _GLOBAL_MACRO_FUNCTIONS_REGISTER_NEW_NAMED_FUNCTION( \ + scopeSymbol, \ + SkyrimScripting::Plugin::Entrypoint::EntrypointCallbacks::GetSingleton() \ + .RegisterInitHighPriorityCallback \ + )() + +#define _SKSEPlugin_Init_HighPriority_ __SKSEPlugin_Init_HighPriority__(DEFAULT) + +#define __SKSEPlugin_Init__(scopeSymbol) \ + _GLOBAL_MACRO_FUNCTIONS_REGISTER_NEW_NAMED_FUNCTION( \ + scopeSymbol, \ + SkyrimScripting::Plugin::Entrypoint::EntrypointCallbacks::GetSingleton() \ + .RegisterInitCallback \ + )() + +#define _SKSEPlugin_Init_ __SKSEPlugin_Init__(DEFAULT) + +#define __SKSEPlugin_Init_LowPriority__(scopeSymbol) \ + _GLOBAL_MACRO_FUNCTIONS_REGISTER_NEW_NAMED_FUNCTION( \ + scopeSymbol, \ + SkyrimScripting::Plugin::Entrypoint::EntrypointCallbacks::GetSingleton() \ + .RegisterInitLowPriorityCallback \ + )() + +#define _SKSEPlugin_Init_LowPriority_ __SKSEPlugin_Init_LowPriority__(DEFAULT) \ No newline at end of file diff --git a/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Internal/SKSEPlugin_Load.h b/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Internal/SKSEPlugin_Load.h new file mode 100644 index 0000000..b4c45e7 --- /dev/null +++ b/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Internal/SKSEPlugin_Load.h @@ -0,0 +1,25 @@ +#pragma once + +#include + +#include "EntrypointCallbacks.h" + +extern "C" __declspec(dllexport) bool SKSEPlugin_Load(const SKSE::LoadInterface* skse) { + auto& callbacks = SkyrimScripting::Plugin::Entrypoint::EntrypointCallbacks::GetSingleton(); + + if (!callbacks.RunPreInitHighPriorityCallbacks(skse)) return false; + if (!callbacks.RunPreInitCallbacks(skse)) return false; + if (!callbacks.RunPreInitLowPriorityCallbacks(skse)) return false; + + SKSE::Init(skse); + + if (!callbacks.RunPostInitHighPriorityCallbacks(skse)) return false; + if (!callbacks.RunPostInitCallbacks(skse)) return false; + if (!callbacks.RunPostInitLowPriorityCallbacks(skse)) return false; + + callbacks.RunHighPriorityCallbacks(); + callbacks.RunCallbacks(); + callbacks.RunLowPriorityCallbacks(); + + return true; +} \ No newline at end of file diff --git a/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Main.h b/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Main.h new file mode 100644 index 0000000..f2bf992 --- /dev/null +++ b/SkyrimScripting.Plugin.Entrypoint/include/SkyrimScripting/Plugin/Entrypoint/Main.h @@ -0,0 +1,3 @@ +#pragma once + +#include "Internal/SKSEPlugin_Load.h" // IWYU pragma: keep diff --git a/SkyrimScripting.Plugin.Entrypoint/xmake.lua b/SkyrimScripting.Plugin.Entrypoint/xmake.lua new file mode 100644 index 0000000..9c074c7 --- /dev/null +++ b/SkyrimScripting.Plugin.Entrypoint/xmake.lua @@ -0,0 +1,7 @@ +add_requires("global_macro_functions") + +target("SkyrimScripting.Plugin.Entrypoint") + set_kind("headeronly") + add_includedirs("include", { public = true }) + add_headerfiles("include/(**.h)") + add_packages("global_macro_functions", { public = true }) diff --git a/SkyrimScripting.Plugin/include/SkyrimScripting/Plugin.h b/SkyrimScripting.Plugin/include/SkyrimScripting/Plugin.h new file mode 100644 index 0000000..c798ea0 --- /dev/null +++ b/SkyrimScripting.Plugin/include/SkyrimScripting/Plugin.h @@ -0,0 +1,3 @@ +#pragma once + +#include "Plugin/Entrypoint.h" diff --git a/SkyrimScripting.Plugin/include/SkyrimScripting/Plugin/Core.h b/SkyrimScripting.Plugin/include/SkyrimScripting/Plugin/Core.h new file mode 100644 index 0000000..95e6d20 --- /dev/null +++ b/SkyrimScripting.Plugin/include/SkyrimScripting/Plugin/Core.h @@ -0,0 +1,16 @@ +#pragma once + +#ifndef _Log_ + #define _Log_(...) SKSE::log::info(__VA_ARGS__) +#endif + +#ifndef _ConsoleLog_ + #include + #define _ConsoleLog_(...) \ + RE::ConsoleLog::GetSingleton()->Print(string_format(__VA_ARGS__).c_str()) +#endif + +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include +#include diff --git a/SkyrimScripting.Plugin/include/SkyrimScripting/Plugin/Entrypoint.h b/SkyrimScripting.Plugin/include/SkyrimScripting/Plugin/Entrypoint.h new file mode 100644 index 0000000..f4c1300 --- /dev/null +++ b/SkyrimScripting.Plugin/include/SkyrimScripting/Plugin/Entrypoint.h @@ -0,0 +1,7 @@ +#pragma once + +#include // IWYU pragma: keep + +#include "Core.h" // IWYU pragma: keep + +__OnInit__(PluginEntrypointOnInit) { SkyrimScripting::SKSE::Logging::SetupLogging(); } diff --git a/SkyrimScripting.Plugin/xmake.lua b/SkyrimScripting.Plugin/xmake.lua new file mode 100644 index 0000000..5c74e61 --- /dev/null +++ b/SkyrimScripting.Plugin/xmake.lua @@ -0,0 +1,12 @@ +add_requires("string_format") + +target("SkyrimScripting.Plugin") + set_kind("headeronly") + add_includedirs("include", { public = true }) + add_headerfiles("include/(**.h)") + add_deps( + "SkyrimScripting.SKSE.Messages", + "SkyrimScripting.SKSE.Logging", + { public = true } + ) + add_packages("string_format", { public = true }) diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in deleted file mode 100644 index 72450c4..0000000 --- a/cmake/Config.cmake.in +++ /dev/null @@ -1,2 +0,0 @@ -@PACKAGE_INIT@ -include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") diff --git a/include/SkyrimScripting/Plugin.h b/include/SkyrimScripting/Plugin.h deleted file mode 100644 index c0ad76c..0000000 --- a/include/SkyrimScripting/Plugin.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -#include "SkyrimScripting/Plugin/Core.h" -#include "SkyrimScripting/Plugin/Init.h" diff --git a/include/SkyrimScripting/Plugin/CallbackEventSink.h b/include/SkyrimScripting/Plugin/CallbackEventSink.h deleted file mode 100644 index 553011d..0000000 --- a/include/SkyrimScripting/Plugin/CallbackEventSink.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include - -#include - - -namespace SkyrimScripting::Plugin { - template - class CallbackEventSink : public RE::BSTEventSink { - std::function _callback; - - public: - CallbackEventSink(std::function callback) : _callback(callback) {} - RE::BSEventNotifyControl ProcessEvent(const Event* event, RE::BSTEventSource*) override { - _callback(event); - return RE::BSEventNotifyControl::kContinue; - } - }; -} diff --git a/include/SkyrimScripting/Plugin/Config.h b/include/SkyrimScripting/Plugin/Config.h deleted file mode 100644 index a9b28e3..0000000 --- a/include/SkyrimScripting/Plugin/Config.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -namespace SkyrimScripting::Plugin::Config { - - static bool LogToDebugConsole; - static bool LogDisabled; - static std::filesystem::path LogFullPath; - static std::filesystem::path LogFileName; - static std::filesystem::path LogFolderPath; -} diff --git a/include/SkyrimScripting/Plugin/ConsoleLogging.h b/include/SkyrimScripting/Plugin/ConsoleLogging.h deleted file mode 100644 index c17554d..0000000 --- a/include/SkyrimScripting/Plugin/ConsoleLogging.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace SkyrimScripting::Plugin::ConsoleLogging { - - template - void ConsoleLog(fmt::format_string text, Args&&... args) { - auto* log = RE::ConsoleLog::GetSingleton(); - if (log) - log->Print(fmt::format(text, std::forward(args)...).c_str()); - else - SKSE::log::error( - "Failed to get RE::ConsoleLog::GetSingleton(). Did you call ConsoleLog() before OnDataLoaded?"); - } -} diff --git a/include/SkyrimScripting/Plugin/Core.h b/include/SkyrimScripting/Plugin/Core.h deleted file mode 100644 index 8a9bf9e..0000000 --- a/include/SkyrimScripting/Plugin/Core.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "SkyrimScripting/Plugin/ConsoleLogging.h" -#include "SkyrimScripting/Plugin/EventCallback.h" -#include "SkyrimScripting/Plugin/LogInitializationMacros.h" -#include "SkyrimScripting/Plugin/SKSEPlugin.h" -#include "SkyrimScripting/Plugin/SystemEventMacros.h" - -namespace logger = SKSE::log; - -using namespace SkyrimScripting::Plugin::EventCallback; -using namespace SkyrimScripting::Plugin::ConsoleLogging; - -namespace SkyrimScripting::Plugin { - void Initialize() { SKSEPlugin::Initialize(); } -} diff --git a/include/SkyrimScripting/Plugin/EventCallback.h b/include/SkyrimScripting/Plugin/EventCallback.h deleted file mode 100644 index 661ddc3..0000000 --- a/include/SkyrimScripting/Plugin/EventCallback.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include - -// TODO: support UI and BSInputDeviceManager events (and others, if any) - -namespace SkyrimScripting::Plugin::EventCallback { - template - void On(std::function callback) { - RE::ScriptEventSourceHolder::GetSingleton()->AddEventSink( - new CallbackEventSink(callback)); - } -} diff --git a/include/SkyrimScripting/Plugin/Init.h b/include/SkyrimScripting/Plugin/Init.h deleted file mode 100644 index 054fad1..0000000 --- a/include/SkyrimScripting/Plugin/Init.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "SkyrimScripting/Plugin/SKSEPlugin.h" - -// Initializes a plugin -namespace SkyrimScripting::Plugin { - - // Initialize the plugin - SKSEPluginLoad(const SKSE::LoadInterface *skse) { - SKSE::Init(skse); - SKSEPlugin::Initialize(); - return true; - } -} diff --git a/include/SkyrimScripting/Plugin/Internal/FunctionRunner.h b/include/SkyrimScripting/Plugin/Internal/FunctionRunner.h deleted file mode 100644 index 430edeb..0000000 --- a/include/SkyrimScripting/Plugin/Internal/FunctionRunner.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - -namespace SkyrimScripting::Plugin::Internal { - - /* - * Lazy way to run arbitrary function on startup by providing a function. - * Defined by macros or inline functions. - */ - struct FunctionRunner { - FunctionRunner(std::function fn) { fn(); } - }; -} diff --git a/include/SkyrimScripting/Plugin/Internal/Macros.h b/include/SkyrimScripting/Plugin/Internal/Macros.h deleted file mode 100644 index 9241f66..0000000 --- a/include/SkyrimScripting/Plugin/Internal/Macros.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#define __SKYRIM_SCRIPTING_PLUGIN_CONCAT0(x, y) x##y -#define __SKYRIM_SCRIPTING_PLUGIN_CONCAT(x, y) __SKYRIM_SCRIPTING_PLUGIN_CONCAT0(x, y) - -// Create a "FunctionRunner" which takes a std::function which is run immediately at runtime -#define __SKYRIM_SCRIPTING_PLUGIN_FUNCTIONRUNNER(count) \ - SkyrimScripting::Plugin::Internal::FunctionRunner __SKYRIM_SCRIPTING_PLUGIN_CONCAT( \ - __skyrimScriptingPluginFunctionRunner, count) - -#define __NEW_SKYRIM_SCRIPTING_PLUGIN_FUNCTIONRUNNER __SKYRIM_SCRIPTING_PLUGIN_FUNCTIONRUNNER(__COUNTER__) diff --git a/include/SkyrimScripting/Plugin/LogInitializationMacros.h b/include/SkyrimScripting/Plugin/LogInitializationMacros.h deleted file mode 100644 index f8ccc0f..0000000 --- a/include/SkyrimScripting/Plugin/LogInitializationMacros.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include "SkyrimScripting/Plugin/Config.h" -#include "SkyrimScripting/Plugin/Internal/FunctionRunner.h" -#include "SkyrimScripting/Plugin/Internal/Macros.h" - - -// Override the full path of the log file for this plugin -#define PluginLogFullPath(fullPath) \ - __NEW_SKYRIM_SCRIPTING_PLUGIN_FUNCTIONRUNNER { \ - []() { SkyrimScripting::Plugin::Config::LogFullPath = fullPath; } \ - } - -// Override the filename of the log file for this plugin -#define PluginLogFileName(filename) \ - __NEW_SKYRIM_SCRIPTING_PLUGIN_FUNCTIONRUNNER { \ - []() { SkyrimScripting::Plugin::Config::LogFileName = filename; } \ - } - -// Override the folder path of the log file for this plugin -#define PluginLogFolder(folderPath) \ - __NEW_SKYRIM_SCRIPTING_PLUGIN_FUNCTIONRUNNER { \ - []() { SkyrimScripting::Plugin::Config::LogFolderPath = folderPath; } \ - } - -// Enables logging to debugger console when debugger is attached (default: false) -#define PluginLogToDebugConsole \ - __NEW_SKYRIM_SCRIPTING_PLUGIN_FUNCTIONRUNNER { \ - []() { SkyrimScripting::Plugin::Config::LogToDebugConsole = true; } \ - } - -// Disables logging -#define PluginLogDisable \ - __NEW_SKYRIM_SCRIPTING_PLUGIN_FUNCTIONRUNNER { \ - []() { SkyrimScripting::Plugin::Config::LogDisabled = true; } \ - } diff --git a/include/SkyrimScripting/Plugin/Logger.h b/include/SkyrimScripting/Plugin/Logger.h deleted file mode 100644 index 8bf966c..0000000 --- a/include/SkyrimScripting/Plugin/Logger.h +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once - -// Include spdlog support for a basic file logger -#include - -// Allows us to check if a debugger is attached (optional, see below) -#include -#include - -#include -#include -#include - -#include "SkyrimScripting/Plugin/Config.h" - -namespace SkyrimScripting::Plugin::Logger { - - std::atomic IsLoggerInitialized; - - std::filesystem::path GetSKSELogFolder() { - auto logsFolder = SKSE::log::log_directory(); - if (!logsFolder) SKSE::stl::report_and_fail("SKSE log_directory not provided, logs disabled."); - return *logsFolder; - } - - void InitializeLog() { - if (IsLoggerInitialized.exchange(true)) return; - if (Config::LogDisabled) return; - - std::filesystem::path logPath = Config::LogFullPath; - - if (logPath.empty()) { - if (!Config::LogFolderPath.empty() && !Config::LogFileName.empty()) - logPath = Config::LogFolderPath / Config::LogFileName; - else if (!Config::LogFolderPath.empty()) - logPath = - Config::LogFolderPath / std::format("{}.log", SKSE::PluginDeclaration::GetSingleton()->GetName()); - else if (!Config::LogFileName.empty()) - logPath = GetSKSELogFolder() / Config::LogFileName; - else - logPath = - GetSKSELogFolder() / std::format("{}.log", SKSE::PluginDeclaration::GetSingleton()->GetName()); - } - - auto fileLoggerPtr = std::make_shared(logPath.string(), true); - - std::shared_ptr loggerPtr; - if (Config::LogToDebugConsole && IsDebuggerPresent()) { - auto debugLoggerPtr = std::make_shared(); - spdlog::sinks_init_list loggers{std::move(fileLoggerPtr), std::move(debugLoggerPtr)}; - loggerPtr = std::make_shared("log", loggers); - } else { - loggerPtr = std::make_shared("log", std::move(fileLoggerPtr)); - } - - spdlog::set_default_logger(std::move(loggerPtr)); - spdlog::set_level(spdlog::level::trace); - spdlog::flush_on(spdlog::level::trace); - } -} diff --git a/include/SkyrimScripting/Plugin/SKSEPlugin.h b/include/SkyrimScripting/Plugin/SKSEPlugin.h deleted file mode 100644 index 8aaded9..0000000 --- a/include/SkyrimScripting/Plugin/SKSEPlugin.h +++ /dev/null @@ -1,93 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include -#include -#include - -#include "SkyrimScripting/Plugin/Logger.h" -#include "SkyrimScripting/Plugin/SystemEvents.h" - -namespace SkyrimScripting::Plugin { - - class SKSEPlugin { - SKSEPlugin() = default; - ~SKSEPlugin() = default; - SKSEPlugin(const SKSEPlugin&) = delete; - SKSEPlugin(SKSEPlugin&&) = delete; - SKSEPlugin& operator=(const SKSEPlugin&) = delete; - SKSEPlugin& operator=(SKSEPlugin&&) = delete; - - std::atomic _initialized; - std::unordered_map>> _systemCallbacks; - - public: - static SKSEPlugin& GetSingleton() { - static SKSEPlugin singleton; - return singleton; - } - - // TODO Add support for a OnStartGame() event which is just TESCellFullyLoaded which is reset by the main menu - // and reset by load game (maybe) - - static void Initialize() { - auto& plugin = GetSingleton(); - if (plugin._initialized.exchange(true)) return; - Logger::InitializeLog(); - plugin.RunSystemEventCallbacks(SystemEvents::Plugin_Init); - SKSE::GetMessagingInterface()->RegisterListener([](SKSE::MessagingInterface::Message* message) { - auto& plugin = GetSingleton(); - switch (message->type) { - case SKSE::MessagingInterface::kPostLoad: - plugin.RunSystemEventCallbacks(SystemEvents::SKSE_Plugins_Loaded); - break; - case SKSE::MessagingInterface::kPostPostLoad: - plugin.RunSystemEventCallbacks(SystemEvents::After_SKSE_Plugins_Loaded); - break; - case SKSE::MessagingInterface::kPreLoadGame: - plugin.RunSystemEventCallbacks(SystemEvents::Loading_Game); - break; - case SKSE::MessagingInterface::kPostLoadGame: - plugin.RunSystemEventCallbacks(SystemEvents::Loaded_Game); - break; - case SKSE::MessagingInterface::kSaveGame: - plugin.RunSystemEventCallbacks(SystemEvents::Save_Game); - break; - case SKSE::MessagingInterface::kDeleteGame: - plugin.RunSystemEventCallbacks(SystemEvents::Delete_Game); - break; - case SKSE::MessagingInterface::kInputLoaded: - plugin.RunSystemEventCallbacks(SystemEvents::Input_Loaded); - break; - case SKSE::MessagingInterface::kNewGame: - plugin.RunSystemEventCallbacks(SystemEvents::New_Game); - break; - case SKSE::MessagingInterface::kDataLoaded: - plugin.RunSystemEventCallbacks(SystemEvents::Data_Loaded); - break; - default: - SKSE::log::info("Unexpected SKSE message type {}", message->type); - break; - } - }); - } - - void RunSystemEventCallbacks(SystemEvents event) { - if (_systemCallbacks.contains(event)) { - for (auto& callback : _systemCallbacks.at(event)) { - callback(); - } - } - } - - void RegisterSystemEventCallback(SystemEvents event, std::function callback) { - if (!_systemCallbacks.contains(event)) - _systemCallbacks.insert_or_assign(event, std::vector>{}); - _systemCallbacks.at(event).emplace_back(callback); - } - }; -} diff --git a/include/SkyrimScripting/Plugin/SystemEventMacros.h b/include/SkyrimScripting/Plugin/SystemEventMacros.h deleted file mode 100644 index f1b536a..0000000 --- a/include/SkyrimScripting/Plugin/SystemEventMacros.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include "SkyrimScripting/Plugin/Internal/FunctionRunner.h" -#include "SkyrimScripting/Plugin/Internal/Macros.h" - -// Setup for a callback function to be registered, e.g. as a SystemEvent handler -#define __SKYRIM_SCRIPTING_PLUGIN_CALLBACKFN_NAME(count) \ - __SKYRIM_SCRIPTING_PLUGIN_CONCAT(__skyrimScriptingPluginCallback, count) - -// Add a System Event Callback to SKSEPlugin -// -// It'll call the function which the developer defines using the macro -// so they need access to the same __COUNTER__ (which is why we take the count as an argument) -// -#define __SKYRIM_SCRIPTING_PLUGIN_REGISTER_AND_DEFINE_CALLBACK(systemEvent, count) \ - inline void __SKYRIM_SCRIPTING_PLUGIN_CALLBACKFN_NAME(count)(); \ - __SKYRIM_SCRIPTING_PLUGIN_FUNCTIONRUNNER(count){[]() { \ - SkyrimScripting::Plugin::SKSEPlugin::GetSingleton().RegisterSystemEventCallback(systemEvent, []() { \ - __SKYRIM_SCRIPTING_PLUGIN_CALLBACKFN_NAME(count)(); \ - }); \ - }}; \ - inline void __SKYRIM_SCRIPTING_PLUGIN_CALLBACKFN_NAME(count) - -#define OnSystemEvent(systemEvent) \ - __SKYRIM_SCRIPTING_PLUGIN_REGISTER_AND_DEFINE_CALLBACK(systemEvent, __COUNTER__) \ - () - -// SKSEPluginLoad macro(s) -// OnPluginLoad() because it's SKSEPluginLoad() -#define OnPluginLoad OnSystemEvent(SkyrimScripting::Plugin::SystemEvents::Plugin_Init) -// OnInit() to be like Papyrus -#define OnInit OnPluginLoad -// Semantics for registering event handlers -#define EventHandlers OnPluginLoad - -// Other Macros -#define OnPluginsLoaded OnSystemEvent(SkyrimScripting::Plugin::SystemEvents::SKSE_Plugins_Loaded) -#define AfterPluginsLoaded OnSystemEvent(SkyrimScripting::Plugin::SystemEvents::After_SKSE_Plugins_Loaded) -#define OnLoadingGame OnSystemEvent(SkyrimScripting::Plugin::SystemEvents::Loading_Game) -#define OnLoadedGame OnSystemEvent(SkyrimScripting::Plugin::SystemEvents::Loaded_Game) -#define OnSaveGame OnSystemEvent(SkyrimScripting::Plugin::SystemEvents::Save_Game) -#define OnDeleteGame OnSystemEvent(SkyrimScripting::Plugin::SystemEvents::Delete_Game) -#define OnNewGame OnSystemEvent(SkyrimScripting::Plugin::SystemEvents::New_Game) -#define OnInputLoaded OnSystemEvent(SkyrimScripting::Plugin::SystemEvents::Input_Loaded) -#define OnDataLoaded OnSystemEvent(SkyrimScripting::Plugin::SystemEvents::Data_Loaded) -#define OnFormsLoaded OnDataLoaded diff --git a/include/SkyrimScripting/Plugin/SystemEvents.h b/include/SkyrimScripting/Plugin/SystemEvents.h deleted file mode 100644 index bbe13a9..0000000 --- a/include/SkyrimScripting/Plugin/SystemEvents.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -namespace SkyrimScripting::Plugin { - - // https://github.com/ianpatt/skse64/blob/09f520a2433747f33ae7d7c15b1164ca198932c3/skse64/PluginAPI.h#L193-L212 - enum class SystemEvents { - Plugin_Init, - SKSE_Plugins_Loaded, - After_SKSE_Plugins_Loaded, - Loading_Game, - Loaded_Game, - Save_Game, - Delete_Game, - Input_Loaded, - New_Game, - Data_Loaded - }; -} diff --git a/plugin.cpp b/plugin.cpp deleted file mode 100644 index b9ef44c..0000000 --- a/plugin.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include - -namespace logger = SKSE::log; - -void SetupLog() { - auto logsFolder = SKSE::log::log_directory(); - if (!logsFolder) { - SKSE::stl::report_and_fail("SKSE log_directory not provided, logs disabled."); - return; - } - auto pluginName = SKSE::PluginDeclaration::GetSingleton()->GetName(); - auto logFilePath = *logsFolder / std::format("{}.log", pluginName); - auto fileLoggerPtr = std::make_shared(logFilePath.string(), true); - auto loggerPtr = std::make_shared("log", std::move(fileLoggerPtr)); - spdlog::set_default_logger(std::move(loggerPtr)); - spdlog::set_level(spdlog::level::trace); - spdlog::flush_on(spdlog::level::info); -} - -// Our class which received game events -// -// Must have a *public* class inheritance for templated BSTEventSink -// for each event type you would like to receive. -// -// Also must have a `ProcessEvent` function which received a const pointer to one of the -// -// `ProcessEvent` is used to... well... process the event! You can do whatever you want with it :) -// -// It is not required to make your class a singleton, but it is very helpful! -// Otherwise, you need to be aware of where your class instance is instantiated and keep it alive. -class EventProcessor : public RE::BSTEventSink, public RE::BSTEventSink { - // Pretty typical singleton setup - // *Private* constructor/destructor - // And we *delete* the copy constructors and move constructors. - EventProcessor() = default; - ~EventProcessor() = default; - EventProcessor(const EventProcessor&) = delete; - EventProcessor(EventProcessor&&) = delete; - EventProcessor& operator=(const EventProcessor&) = delete; - EventProcessor& operator=(EventProcessor&&) = delete; - -public: - // Returns a reference to the one and only instance of EventProcessor :) - // - // Note: this is returned as a & reference. When you need this as a pointer, you'll want to use & (see below) - static EventProcessor& GetSingleton() { - static EventProcessor singleton; - return singleton; - } - - // Log information about Activate events that happen in the game - RE::BSEventNotifyControl ProcessEvent(const RE::TESActivateEvent* event, - RE::BSTEventSource*) override { - logger::info("{} activated {}", event->actionRef.get()->GetBaseObject()->GetName(), - event->objectActivated.get()->GetBaseObject()->GetName()); - return RE::BSEventNotifyControl::kContinue; - } - - // Log information about Menu open/close events that happen in the game - RE::BSEventNotifyControl ProcessEvent(const RE::MenuOpenCloseEvent* event, - RE::BSTEventSource*) override { - logger::info("Menu {} Open? {}", event->menuName, event->opening); - return RE::BSEventNotifyControl::kContinue; - } -}; - -SKSEPluginLoad(const SKSE::LoadInterface* skse) { - SKSE::Init(skse); - SetupLog(); - - // Get a reference to our Event Processor singleton - auto& eventProcessor = EventProcessor::GetSingleton(); - - // Listen for Activate events! - // - // For more events, I recommend searching CommonLibSSE for files starting with TESEvent - // - // 1. Visit this link: https://github.com/CharmedBaryon/CommonLibSSE-NG - // 2. Press the "T" key to open the fuzzy find file search - // 3. Type "TESEvent" (without the " quotes) - // 4. Choose any of the files that show up! They're probably events that you can get via an event sink :) - RE::ScriptEventSourceHolder::GetSingleton()->AddEventSink(&eventProcessor); - - // Note: a few UI events are registered via RE::UI instead of via RE::ScriptEventSourceHolder - // - MenuOpenCloseEvent - // - MenuModeChangeEvent> - // - MenuModeCounterChangedEvent (use for template and cast) - // - TutorialEvent (use for template and cast) - RE::UI::GetSingleton()->AddEventSink(&eventProcessor); - - return true; -} diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json deleted file mode 100644 index 3f2ef8d..0000000 --- a/vcpkg-configuration.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "default-registry": { - "kind": "git", - "repository": "https://github.com/microsoft/vcpkg.git", - "baseline": "cc288af760054fa489574bd8e22d05aa8fa01e5c" - }, - "registries": [ - { - "kind": "git", - "repository": "https://gitlab.com/colorglass/vcpkg-colorglass", - "baseline": "6fb127f7d425ae3cf3fab0f79005d907c885c0d8", - "packages": [ - "commonlibsse-ng" - ] - }, - { - "kind": "git", - "repository": "file://c:/Code/SkyrimScripting/vcpkg_Examples", - "baseline": "9c1a1b2a6bdefa87f12269b5084607bd6221d86e", - "packages": [ - "skyrimscripting-cmake" - ] - } - ] -} \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json deleted file mode 100644 index 60ae28d..0000000 --- a/vcpkg.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json", - "name": "sample-plugin", - "version-string": "0.0.1", - "dependencies": [ - "commonlibsse-ng", - "skyrimscripting-cmake" - ] -} \ No newline at end of file diff --git a/xmake.lua b/xmake.lua new file mode 100644 index 0000000..f4afa10 --- /dev/null +++ b/xmake.lua @@ -0,0 +1 @@ +includes("**/xmake.lua")