From dfc3493907e28d532bca70d704c9e54b56294c22 Mon Sep 17 00:00:00 2001 From: Emerson Pinter Date: Mon, 22 Jan 2024 21:14:09 -0300 Subject: [PATCH] Initial commit --- .clang-format | 23 + .clang-tidy | 22 + .gitattributes | 14 + .gitignore | 531 ++++++++++++++++++ CMakeLists.txt | 31 + CMakePresets.json | 167 ++++++ LICENSE | 165 ++++++ README.md | 80 +++ cmake/Plugin.h.in | 45 ++ cmake/addpluginsources.cmake | 37 ++ cmake/build.ps1 | 33 ++ cmake/pluginconfig.cmake | 8 + cmake/pluginpackage.cmake | 26 + cmake/plugintarget.cmake | 54 ++ cmake/ports/commonlibsse-ng/portfile.cmake | 29 + cmake/ports/commonlibsse-ng/vcpkg.json | 20 + cmake/version.rc.in | 33 ++ .../MCM/Config/WikiMapIntegration/config.json | 47 ++ .../Config/WikiMapIntegration/settings.ini | 24 + dist/Data/SKSE/Plugins/WikiMap.ini | 80 +++ dist/Data/Scripts/WikiMapIntegration_MCM.pex | Bin 0 -> 1504 bytes .../Source/Scripts/WikiMapIntegration_MCM.psc | 27 + dist/Data/WikiMapIntegration.esp | Bin 0 -> 358 bytes .../WikiMapIntegration_chinese.txt | Bin 0 -> 1354 bytes .../WikiMapIntegration_english.txt | Bin 0 -> 1354 bytes .../WikiMapIntegration_french.txt | Bin 0 -> 1354 bytes .../WikiMapIntegration_german.txt | Bin 0 -> 1354 bytes .../WikiMapIntegration_italian.txt | Bin 0 -> 1354 bytes .../WikiMapIntegration_japanese.txt | Bin 0 -> 1354 bytes .../WikiMapIntegration_polish.txt | Bin 0 -> 1354 bytes .../WikiMapIntegration_russian.txt | Bin 0 -> 1354 bytes .../WikiMapIntegration_spanish.txt | Bin 0 -> 1354 bytes src/Config.cpp | 189 +++++++ src/Config.h | 140 +++++ src/GameEventHandler.cpp | 45 ++ src/GameEventHandler.h | 31 + src/Hooks.cpp | 43 ++ src/Hooks.h | 18 + src/InputListener.cpp | 68 +++ src/InputListener.h | 26 + src/MCM.cpp | 15 + src/MCM.h | 11 + src/MapMenuHook.cpp | 213 +++++++ src/MapMenuHook.h | 24 + src/PCH.h | 157 ++++++ src/PlayerLocation.cpp | 156 +++++ src/PlayerLocation.h | 46 ++ src/Plugin.cpp | 65 +++ src/QuestMenuHook.cpp | 237 ++++++++ src/QuestMenuHook.h | 40 ++ src/SelectedItem.cpp | 76 +++ src/SelectedItem.h | 39 ++ src/SkseMessagingListener.h | 104 ++++ src/SteamApi.h | 160 ++++++ src/UrlProvider.cpp | 251 +++++++++ src/UrlProvider.h | 23 + vcpkg.json | 24 + 57 files changed, 3697 insertions(+) create mode 100644 .clang-format create mode 100644 .clang-tidy create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 CMakePresets.json create mode 100644 LICENSE create mode 100644 README.md create mode 100644 cmake/Plugin.h.in create mode 100644 cmake/addpluginsources.cmake create mode 100644 cmake/build.ps1 create mode 100644 cmake/pluginconfig.cmake create mode 100644 cmake/pluginpackage.cmake create mode 100644 cmake/plugintarget.cmake create mode 100644 cmake/ports/commonlibsse-ng/portfile.cmake create mode 100644 cmake/ports/commonlibsse-ng/vcpkg.json create mode 100644 cmake/version.rc.in create mode 100644 dist/Data/MCM/Config/WikiMapIntegration/config.json create mode 100644 dist/Data/MCM/Config/WikiMapIntegration/settings.ini create mode 100644 dist/Data/SKSE/Plugins/WikiMap.ini create mode 100644 dist/Data/Scripts/WikiMapIntegration_MCM.pex create mode 100644 dist/Data/Source/Scripts/WikiMapIntegration_MCM.psc create mode 100644 dist/Data/WikiMapIntegration.esp create mode 100644 dist/Data/interface/translations/WikiMapIntegration_chinese.txt create mode 100644 dist/Data/interface/translations/WikiMapIntegration_english.txt create mode 100644 dist/Data/interface/translations/WikiMapIntegration_french.txt create mode 100644 dist/Data/interface/translations/WikiMapIntegration_german.txt create mode 100644 dist/Data/interface/translations/WikiMapIntegration_italian.txt create mode 100644 dist/Data/interface/translations/WikiMapIntegration_japanese.txt create mode 100644 dist/Data/interface/translations/WikiMapIntegration_polish.txt create mode 100644 dist/Data/interface/translations/WikiMapIntegration_russian.txt create mode 100644 dist/Data/interface/translations/WikiMapIntegration_spanish.txt create mode 100644 src/Config.cpp create mode 100644 src/Config.h create mode 100644 src/GameEventHandler.cpp create mode 100644 src/GameEventHandler.h create mode 100644 src/Hooks.cpp create mode 100644 src/Hooks.h create mode 100644 src/InputListener.cpp create mode 100644 src/InputListener.h create mode 100644 src/MCM.cpp create mode 100644 src/MCM.h create mode 100644 src/MapMenuHook.cpp create mode 100644 src/MapMenuHook.h create mode 100644 src/PCH.h create mode 100644 src/PlayerLocation.cpp create mode 100644 src/PlayerLocation.h create mode 100644 src/Plugin.cpp create mode 100644 src/QuestMenuHook.cpp create mode 100644 src/QuestMenuHook.h create mode 100644 src/SelectedItem.cpp create mode 100644 src/SelectedItem.h create mode 100644 src/SkseMessagingListener.h create mode 100644 src/SteamApi.h create mode 100644 src/UrlProvider.cpp create mode 100644 src/UrlProvider.h create mode 100644 vcpkg.json diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..99c8204 --- /dev/null +++ b/.clang-format @@ -0,0 +1,23 @@ +IndentAccessModifiers: true +AccessModifierOffset: 0 +BasedOnStyle: Google +ColumnLimit: 140 +IndentWidth: 4 +NamespaceIndentation: All +TabWidth: 4 +UseTab: Never +AllowAllArgumentsOnNextLine: false +PackConstructorInitializers: NextLineOnly +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +SortIncludes: false +PointerAlignment: Right +ReferenceAlignment: Right +ReflowComments: false +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceBeforeRangeBasedForLoopColon: false +SpaceInEmptyParentheses: false \ No newline at end of file diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..27d304e --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,22 @@ +Checks: '-modernize-use-trailing-return-type, + -bugprone-easily-swappable-parameters, + readability-identifier-naming + ' +FormatStyle: file +CheckOptions: + - key: readability-identifier-naming.EnumCase + value: 'CamelCase' + - key: readability-identifier-naming.EnumConstantCase + value: 'UPPER_CASE' + - key: readability-identifier-naming.ClassCase + value: 'CamelCase' + - key: readability-identifier-naming.FunctionCase + value: 'camelBack' + - key: readability-identifier-naming.GlobalFunctionCase + value: 'aNy_CasE' + - key: readability-identifier-naming.ClassMemberCase + value: 'camelBack' + - key: readability-identifier-naming.MemberCase + value: 'camelBack' + - key: readability-identifier-naming.ClassMethodCase + value: 'camelBack' diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8519726 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,14 @@ +* text=auto +*.c text +*.h text +*.cpp text +*.hpp text +*.cc text +*.txt text +*.sln text eol=crlf +*.csproj text eol=crlf +*.csproj.user text eol=crlf +*.editorconfig text eol=crlf +app.config text eol=crlf +packages.config text eol=crlf +*.cs text \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d8734f5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,531 @@ +/local.cmake +/out/ +/build/ +/.vscode +/vcpkg_installed/ +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### CLion Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +### CMake ### +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +### CMake Patch ### +# External projects +*-prefix/ + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# Local History for Visual Studio Code +.history/ + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# Support for Project snippet scope +!.vscode/*.code-snippets + +### VisualStudio ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Nuget personal access tokens and Credentials +# nuget.config + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools + +# Local History for Visual Studio Code + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +.idea/ +*.sln.iml + +### VisualStudio Patch ### +# Additional files built by Visual Studio +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..59c0fce --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.25) + +project( + WikiMap + VERSION 1.0.0 + LANGUAGES CXX) +set(PROJECT_LICENSE "LGPLv3") +set(PROJECT_FRIENDLY_NAME ${PROJECT_NAME}) +set(PROJECT_LONG_NAME "Wiki and Map") +set(PROJECT_DESCRIPTION ${PROJECT_LONG_NAME}) +set(PROJECT_COPYRIGHT "Emerson Pinter") + +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") +include(GNUInstallDirs) +include(addpluginsources) +include(pluginconfig) +include(plugintarget) +include(pluginpackage) +include("${PROJECT_SOURCE_DIR}/local.cmake" OPTIONAL) + +######## dependencies +set(Boost_NO_WARN_NEW_VERSIONS 1) +set(Boost_USE_STATIC_LIBS ON) +set(Boost_USE_MULTITHREADED ON) +find_package(Boost REQUIRED COMPONENTS url) +if(Boost_FOUND) + target_link_libraries(${PROJECT_NAME} PRIVATE ${Boost_LIBRARIES}) + target_include_directories(${PROJECT_NAME} PRIVATE ${Boost_INCLUDE_DIRS}) +endif() + + diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..2f0f0e2 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,167 @@ +{ + "version": 5, + "cmakeMinimumRequired": { + "major": 3, + "minor": 25, + "patch": 0 + }, + "buildPresets": [ + { + "name": "release", + "displayName": "Release NG", + "configurePreset": "default", + "configuration": "Release" + }, + { + "name": "debug", + "displayName": "Debug NG", + "configurePreset": "default", + "configuration": "Debug" + }, + { + "name": "relwithdebinfo", + "displayName": "RelWithDebInfo NG", + "configurePreset": "default", + "configuration": "RelWithDebInfo" + }, + { + "name": "release-novr", + "displayName": "Release NG-NoVR", + "configurePreset": "no-vr", + "configuration": "Release" + }, + { + "name": "debug-novr", + "displayName": "Debug NG-NoVR", + "configurePreset": "no-vr", + "configuration": "Debug" + }, + { + "name": "relwithdebinfo-novr", + "displayName": "RelWithDebInfo NG-NoVR", + "configurePreset": "no-vr", + "configuration": "RelWithDebInfo" + }, + { + "name": "release-vr", + "displayName": "Release VR", + "configurePreset": "vr", + "configuration": "Release" + }, + { + "name": "debug-vr", + "displayName": "Debug VR", + "configurePreset": "vr", + "configuration": "Debug" + }, + { + "name": "relwithdebinfo-vr", + "displayName": "RelWithDebInfo VR", + "configurePreset": "vr", + "configuration": "RelWithDebInfo" + } + ], + "configurePresets": [ + { + "name": "common", + "hidden": true, + "binaryDir": "${sourceDir}/build", + "installDir": "${sourceDir}/build/install" + }, + { + "name": "vcpkg", + "hidden": true, + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": { + "type": "STRING", + "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + }, + "VCPKG_OVERLAY_PORTS": { + "type": "STRING", + "value": "${sourceDir}/cmake/ports/" + }, + "VCPKG_TARGET_TRIPLET": "x64-windows-static-md" + } + }, + { + "name": "win64", + "hidden": true, + "architecture": "x64", + "cacheVariables": { + "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$:Debug>DLL" + } + }, + { + "name": "msvc", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /WX $penv{CXXFLAGS}" + }, + "generator": "Visual Studio 17 2022", + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "intelliSenseMode": "windows-msvc-x64", + "enableMicrosoftCodeAnalysis": true, + "enableClangTidyCodeAnalysis": true + } + } + }, + { + "name": "build-ng", + "hidden": true, + "cacheVariables": { + "SKYRIM_SUPPORT_AE": "ON", + "ENABLE_SKYRIM_AE": "ON", + "ENABLE_SKYRIM_SE": "ON" + } + }, + { + "name": "build-vr", + "hidden": true, + "cacheVariables": { + "ENABLE_SKYRIM_VR": "ON" + } + }, + { + "name": "build-novr", + "hidden": true, + "cacheVariables": { + "ENABLE_SKYRIM_VR": "OFF" + } + }, + { + "name": "default", + "hidden": false, + "inherits": [ + "common", + "vcpkg", + "win64", + "msvc", + "build-ng" + ] + }, + { + "name": "vr", + "hidden": false, + "inherits": [ + "common", + "vcpkg", + "win64", + "msvc", + "build-vr" + ] + }, + { + "name": "no-vr", + "hidden": false, + "inherits": [ + "common", + "vcpkg", + "win64", + "msvc", + "build-ng", + "build-novr" + ] + } + ] +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0a04128 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c315c7f --- /dev/null +++ b/README.md @@ -0,0 +1,80 @@ +# ***Wiki & Map Integration for Skyrim*** +[![C++20](https://img.shields.io/static/v1?label=standard&message=C%2B%2B20&color=blue&logo=c%2B%2B&&logoColor=white&style=flat)](https://en.cppreference.com/w/cpp/compiler_support) +[![Latest Release](https://img.shields.io/github/release/epinter/wikimap.svg)](https://github.com/epinter/wikimap/releases/latest) +[![Downloads](https://img.shields.io/github/downloads/epinter/wikimap/total.svg)](https://github.com/epinter/wikimap/releases/latest) +[![Release Date](https://img.shields.io/github/release-date/epinter/wikimap.svg)](https://github.com/epinter/wikimap/releases/latest) +[![License](https://img.shields.io/github/license/epinter/wikimap.svg)](https://github.com/epinter/wikimap/blob/main/LICENSE) +[![Site](https://img.shields.io/static/v1?label=site&message=NexusMods&color=blue)](https://www.nexusmods.com/skyrimspecialedition/mods/121342) + +A shortcut to online map and information about quests and locations, with support for Steam overlay. + +## ***Runtime requirements*** + +- [Skyrim Script Extender (SKSE)](https://skse.silverlock.org/) +- [Address Library for SKSE Plugins](https://www.nexusmods.com/skyrimspecialedition/mods/32444) +- [SkyUI](https://www.nexusmods.com/skyrimspecialedition/mods/12604) +- [Latest VC++ Redist](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist) + +## ***Build requirements*** + +- [CMake](https://cmake.org/) +- [vcpkg](https://vcpkg.io/en/) +- [Visual Studio Community 2022](https://visualstudio.microsoft.com/vs/community/) +- [CommonLibSSE-NG](https://github.com/CharmedBaryon/CommonLibSSE-NG) + +## **How to use** + +This mod works when Map or Quests menus are open, nothing happens outside these menus. +To view information about a quest, highlight the quest using mouse and press the configured key. Steam overlay or default browser should open. +For the map, position the cursor over a map marker and press the shortcut. If you press the key when the cursor is not over a map marker, the online map will open displaying your current position. +Steam overlay support is enabled by default. If steam is not detected Windows API will be used to open the URL, then you will see your default browser over the game. There's no way to configure default browser. ***This mod doesn't execute any program, it only requests to open an http or https url, Steam or Windows handle it.*** + +This mod is pre-configured to use uesp.net, but can be used with any wiki (like elderscrolls.fandom.com), see configuration. + +## ***Configuration*** +The WikiMap.ini has the following options: + +- Debug: Send more information to logs. +- UpdateBottomBar: Set to false to disable menu changes. +- UrlSelected: Url used when mouse is over a map marker. +- UrlInterior: Url used when player location is interior. +- UrlQuest: Url used for quests. +- Worldspaces: Urls used for exterior (map), one for each worldspace, Tamriel and Solstheim are preconfigured. If you have mods that adds worlds to the game and you know a web site with an online map for that mod, add the url to the ini. + +Other options like key shortcut are configurable using MCM Helper. + +## ***Building*** + +In `Developer Command Prompt for VS 2022` or `Developer PowerShell for VS 2022`, run: + +~~~ +git clone https://github.com/epinter/wikimap.git +cd wikimap +~~~ + +then + +~~~ +.\cmake\build.ps1 +~~~ + +or + +~~~ +.\cmake\build.ps1 -buildPreset ALL-relwithdebinfo +~~~ + +or + +~~~ +.\cmake\build.ps1 -buildPreset ALL-debug +~~~ + +or + +~~~ +cmake -B build -S . --preset ALL --fresh +cmake --build build --preset ALL-release +~~~ + +Then get the .dll in build/Release, or the .zip (ready to install using mod manager) in build. \ No newline at end of file diff --git a/cmake/Plugin.h.in b/cmake/Plugin.h.in new file mode 100644 index 0000000..57f6b1e --- /dev/null +++ b/cmake/Plugin.h.in @@ -0,0 +1,45 @@ +#pragma once + +#include +#include + +namespace Plugin { + using namespace std::string_view_literals; + + static constexpr auto Name{ "@PROJECT_NAME@"sv }; + static constexpr auto Author{ "@PROJECT_AUTHOR@"sv }; + static constexpr auto Version{ + REL::Version{@PROJECT_VERSION_MAJOR@u, @PROJECT_VERSION_MINOR@u, @PROJECT_VERSION_PATCH@u, 0} + }; + static constexpr auto VersionString{ "@PROJECT_VERSION@"sv }; +} + +#if defined(SKSEPluginInfo) +SKSEPluginInfo( + .Version = Plugin::Version, + .Name = Plugin::Name, + .Author = Plugin::Author, + .SupportEmail = ""sv, + .StructCompatibility = SKSE::StructCompatibility::Independent, + .RuntimeCompatibility = SKSE::VersionIndependence::AddressLibrary, + .MinimumSKSEVersion = REL::Version{ 0, 0, 0, 0 } +) +#elif defined(ENABLE_SKYRIM_AE) || defined(SKYRIM_SUPPORT_AE) +extern "C" DLLEXPORT constinit auto SKSEPlugin_Version = []() { + SKSE::PluginVersionData v; + v.PluginVersion(Plugin::Version); + v.PluginName(Plugin::Name); + v.AuthorName(Plugin::Author); + v.UsesAddressLibrary(); + v.UsesUpdatedStructs(); + v.CompatibleVersions({ SKSE::RUNTIME_LATEST }); + return v; +}(); +#else +extern "C" [[maybe_unused]] __declspec(dllexport) bool SKSEPlugin_Query(::SKSE::QueryInterface*, ::SKSE::PluginInfo* pluginInfo) { + pluginInfo->infoVersion = SKSE::PluginInfo::kVersion; + pluginInfo->name = "@PROJECT_NAME@"; + pluginInfo->version = Plugin::Version.pack(); + return true; \ +} +#endif diff --git a/cmake/addpluginsources.cmake b/cmake/addpluginsources.cmake new file mode 100644 index 0000000..55bb39e --- /dev/null +++ b/cmake/addpluginsources.cmake @@ -0,0 +1,37 @@ +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/cmake/version.rc + @ONLY) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Plugin.h.in + ${CMAKE_CURRENT_BINARY_DIR}/cmake/Plugin.h + @ONLY) + +file(GLOB_RECURSE PUBLIC_HEADER_FILES + LIST_DIRECTORIES false + CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h" + ) + +file(GLOB_RECURSE HEADER_FILES + LIST_DIRECTORIES false + CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h" + "${CMAKE_CURRENT_SOURCE_DIR}/external/*.h" + ) + +file(GLOB_RECURSE SOURCE_FILES + LIST_DIRECTORIES false + CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc" + ${CMAKE_CURRENT_BINARY_DIR}/cmake/Plugin.h + ${CMAKE_CURRENT_BINARY_DIR}/cmake/version.rc) + +source_group("Source" + TREE ${CMAKE_CURRENT_SOURCE_DIR} + FILES + ${PUBLIC_HEADER_FILES} + ${HEADER_FILES} + ${SOURCE_FILES}) diff --git a/cmake/build.ps1 b/cmake/build.ps1 new file mode 100644 index 0000000..00ec542 --- /dev/null +++ b/cmake/build.ps1 @@ -0,0 +1,33 @@ +param([string]$buildPreset="release", [string]$configPreset="default", [string]$packConfig, [string]$packPreset, [string]$toolset) +$ErrorActionPreference = "Stop" +Set-StrictMode -Version 3.0 + +Write-Warning "Using buildPreset='$buildPreset' and configPreset='$configPreset'" + +$projectRoot = Resolve-Path "$PSScriptRoot/.." + +if(!$packPreset -and !$packConfig) { + $packConfig=$buildPreset +} +$toolsetParam="" +if($toolset) { + $toolsetParam="-T $toolset" +} + +Set-Location $projectRoot +Write-Warning "Starting cmake" +cmake -B build -S "$projectRoot" --preset $configPreset --fresh $toolsetParam + +Write-Warning "Starting cmake --build with preset '$($buildPreset)'" +cmake --build "$projectRoot/build" --preset "$($buildPreset)" --install $toolsetParam +Set-Location "$projectRoot/build" + +if($packPreset) { + Write-Warning "Starting cpack with preset '$($packPreset)'" + cpack --preset "$($packPreset)" +} elseif($packConfig) { + Write-Warning "Starting cpack with config '$($packConfig)'" + cpack -C "$($packConfig)" +} + +Set-Location $projectRoot diff --git a/cmake/pluginconfig.cmake b/cmake/pluginconfig.cmake new file mode 100644 index 0000000..268a384 --- /dev/null +++ b/cmake/pluginconfig.cmake @@ -0,0 +1,8 @@ +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) +SET(PLUGIN_INSTALL_DEST "SKSE/Plugins") +set(PLUGIN_INSTALL_PDB true) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) diff --git a/cmake/pluginpackage.cmake b/cmake/pluginpackage.cmake new file mode 100644 index 0000000..31821de --- /dev/null +++ b/cmake/pluginpackage.cmake @@ -0,0 +1,26 @@ +######## install and distribution +install(FILES + "${CMAKE_CURRENT_SOURCE_DIR}/dist/${PROJECT_NAME}.ini" + "${CMAKE_CURRENT_SOURCE_DIR}/dist/${PROJECT_NAME}.toml" + CONFIGURATIONS Debug Release RelWithDebInfo + DESTINATION ${PLUGIN_INSTALL_DEST} OPTIONAL) + +if(PLUGIN_INSTALL_PDB) + install(FILES $ + CONFIGURATIONS Release Debug RelWithDebInfo + DESTINATION ${PLUGIN_INSTALL_DEST} OPTIONAL) +endif() + +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${PLUGIN_INSTALL_DEST}) + +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/dist/Data") + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/dist/Data/" + DESTINATION ".") +endif() + +set(CPACK_GENERATOR ZIP) +set(CPACK_PACKAGE_NAME ${PROJECT_LONG_NAME}) +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CMAKE_PROJECT_VERSION}") +set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0) +include(CPack) \ No newline at end of file diff --git a/cmake/plugintarget.cmake b/cmake/plugintarget.cmake new file mode 100644 index 0000000..a0cc209 --- /dev/null +++ b/cmake/plugintarget.cmake @@ -0,0 +1,54 @@ +######## target +add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES}) +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_${CMAKE_CXX_STANDARD}) + +find_path(CommonLibSSEPath "include/REL/Relocation.h" + PATHS "${CMAKE_SOURCE_DIR}/extern/CommonLibSSE" + "${CMAKE_SOURCE_DIR}/extern/CommonLibSSE-NG" + "${CMAKE_SOURCE_DIR}/external/CommonLibSSE" + "${CMAKE_SOURCE_DIR}/external/CommonLibSSE-NG" NO_DEFAULT_PATH) +find_path(CommonLibVRPath "include/REL/Relocation.h" + PATHS "${CMAKE_SOURCE_DIR}/extern/CommonLibVR" + "${CMAKE_SOURCE_DIR}/external/CommonLibVR" NO_DEFAULT_PATH) +if(EXISTS "${CommonLibSSEPath}") + set(BUILD_TESTS OFF CACHE BOOL "Disable CommonLibSSE build tests") + add_subdirectory("${CommonLibSSEPath}" CommonLibSSE EXCLUDE_FROM_ALL) + target_link_libraries(${PROJECT_NAME} PRIVATE CommonLibSSE::CommonLibSSE) + target_include_directories(${PROJECT_NAME} PRIVATE CommonLibSSE::CommonLibSSE) +elseif(EXISTS "${CommonLibVRPath}" AND ENABLE_SKYRIM_VR) + set(BUILD_SKYRIMVR ON CACHE BOOL "Build VR") + add_subdirectory("${CMAKE_SOURCE_DIR}/extern/CommonLibVR" CommonLibVR EXCLUDE_FROM_ALL) + target_link_libraries(${PROJECT_NAME} PRIVATE CommonLibVR::CommonLibVR) + target_include_directories(${PROJECT_NAME} PRIVATE CommonLibVR::CommonLibVR) + target_compile_definitions(CommonLibVR PUBLIC SKYRIMVR) +else() + ##use vcpkg + find_package(CommonLibSSE REQUIRED) + target_link_libraries(${PROJECT_NAME} PRIVATE CommonLibSSE::CommonLibSSE) + target_include_directories(${PROJECT_NAME} PRIVATE CommonLibSSE::CommonLibSSE) +endif() + +if(MSVC) + target_compile_options(${PROJECT_NAME} PRIVATE /Zi) + target_link_options(${PROJECT_NAME} PRIVATE "$<$:/DEBUG:FULL;/INCREMENTAL:NO;/OPT:REF,ICF>") +endif() + +target_include_directories(${PROJECT_NAME} + PRIVATE + $ + $ + $ + $ + $ + $) + +target_include_directories(${PROJECT_NAME} + PUBLIC + $ + $ + $ + ) + +if(EXISTS "${CMAKE_SOURCE_DIR}/src/PCH.h") + target_precompile_headers(${PROJECT_NAME} PRIVATE "${CMAKE_SOURCE_DIR}/src/PCH.h") +endif() \ No newline at end of file diff --git a/cmake/ports/commonlibsse-ng/portfile.cmake b/cmake/ports/commonlibsse-ng/portfile.cmake new file mode 100644 index 0000000..62f49b2 --- /dev/null +++ b/cmake/ports/commonlibsse-ng/portfile.cmake @@ -0,0 +1,29 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO CharmedBaryon/CommonLibSSE + REF 9b7c386d0355e756b4153416a76b0532f755f8de + SHA512 6c9e4861a985eda04074ee157996a5f5294d3e2ce5c79ff481c4b11c86caf5a49847d31d9b5509fc1ae786c01438364f98de6ed3dc28b84dc408bde23dbfa057 + HEAD_REF main +) + +vcpkg_configure_cmake( + SOURCE_PATH "${SOURCE_PATH}" + PREFER_NINJA + OPTIONS -DBUILD_TESTS=off -DSKSE_SUPPORT_XBYAK=on -DENABLE_SKYRIM_VR=off +) + +vcpkg_install_cmake() +vcpkg_cmake_config_fixup(PACKAGE_NAME CommonLibSSE CONFIG_PATH lib/cmake) +vcpkg_copy_pdbs() + +file(GLOB CMAKE_CONFIGS "${CURRENT_PACKAGES_DIR}/share/CommonLibSSE/CommonLibSSE/*.cmake") +file(INSTALL ${CMAKE_CONFIGS} DESTINATION "${CURRENT_PACKAGES_DIR}/share/CommonLibSSE") +file(INSTALL "${SOURCE_PATH}/cmake/CommonLibSSE.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/CommonLibSSE") + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/CommonLibSSE/CommonLibSSE") + +file( + INSTALL "${SOURCE_PATH}/LICENSE" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" + RENAME copyright) diff --git a/cmake/ports/commonlibsse-ng/vcpkg.json b/cmake/ports/commonlibsse-ng/vcpkg.json new file mode 100644 index 0000000..d44ebc4 --- /dev/null +++ b/cmake/ports/commonlibsse-ng/vcpkg.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json", + "name": "commonlibsse-ng", + "version-semver": "3.7.0", + "port-version": 0, + "description": "A reverse engineered resource for developing SKSE plugins, supporting portable plugins that work across AE, SE, and VR.", + "homepage": "https://github.com/CharmedBaryon/CommonLibSSE", + "license": "MIT", + "supports": "windows & x64", + "dependencies": [ + { + "name": "vcpkg-cmake-config", + "host": true + }, + "fmt", + "rapidcsv", + "spdlog", + "xbyak" + ] +} diff --git a/cmake/version.rc.in b/cmake/version.rc.in new file mode 100644 index 0000000..aeb7e8e --- /dev/null +++ b/cmake/version.rc.in @@ -0,0 +1,33 @@ +#include + +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_DESCRIPTION@" + VALUE "FileVersion", "@PROJECT_VERSION@" + VALUE "InternalName", "@PROJECT_NAME@" + VALUE "LegalCopyright", "@PROJECT_COPYRIGHT@" + VALUE "License", "@PROJECT_LICENSE@" + VALUE "ProductName", "@PROJECT_NAME@" + VALUE "ProductVersion", "@PROJECT_VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/dist/Data/MCM/Config/WikiMapIntegration/config.json b/dist/Data/MCM/Config/WikiMapIntegration/config.json new file mode 100644 index 0000000..9cf2d53 --- /dev/null +++ b/dist/Data/MCM/Config/WikiMapIntegration/config.json @@ -0,0 +1,47 @@ +{ + "$schema": "https://raw.githubusercontent.com/Exit-9B/MCM-Helper/main/docs/config.schema.json", + "modName": "WikiMapIntegration", + "displayName": "Wiki & Map", + "minMcmVersion": 13, + "cursorFillMode": "topToBottom", + "content": [ + { + "id": "bEnableSteam:General", + "text": "$EnableSteam", + "type": "toggle", + "help": "$EnableSteamHelp", + "valueOptions": { + "sourceType": "ModSettingBool" + } + }, + { + "id": "bUseSteamModal:General", + "text": "$UseSteamModal", + "type": "toggle", + "help": "$UseSteamModalHelp", + "valueOptions": { + "sourceType": "ModSettingBool" + } + }, + { + "id": "iKeyCode:General", + "text": "$Key", + "type": "keymap", + "ignoreConflicts": true, + "valueOptions": { + "sourceType": "ModSettingInt" + }, + "help": "$KeyCodeHelp" + }, + { + "id": "iModifierKeyCode:General", + "text": "$Modifier", + "type": "keymap", + "ignoreConflicts": true, + "valueOptions": { + "sourceType": "ModSettingInt" + }, + "help": "$ModifierHelp" + } + ] +} \ No newline at end of file diff --git a/dist/Data/MCM/Config/WikiMapIntegration/settings.ini b/dist/Data/MCM/Config/WikiMapIntegration/settings.ini new file mode 100644 index 0000000..17707e3 --- /dev/null +++ b/dist/Data/MCM/Config/WikiMapIntegration/settings.ini @@ -0,0 +1,24 @@ +[General] +;;KeyCode +;; Slash = 53 +;; Period = 52 +;; Comma = 51 +;; https://learn.microsoft.com/en-us/previous-versions/windows/desktop/bb321074(v=vs.85) +iKeyCode=53 + +;; Modifier key (CTRL,ALT,SHIFT) +;; Set to -1 if you don't want to use a modifier key +;; RightAlt = 184 +;; LeftAlt = 56 +;; RightControl = 157 +;; LeftControl = 29 +;; LeftShift = 42 +;; RightShift = 54 +iModifierKeyCode=-1 + +;; Use Steam overlay to open the web page. When false, will open the default browser over the game. +bEnableSteam=1 + +;; When true, opens the web page on a dedicated Steam browser window without the other overlay options. +;; Steam has a bug and don't close the browser tab properly sometimes. Disable if you have issues on Steam overlay. +bUseSteamModal=0 diff --git a/dist/Data/SKSE/Plugins/WikiMap.ini b/dist/Data/SKSE/Plugins/WikiMap.ini new file mode 100644 index 0000000..6cdbad1 --- /dev/null +++ b/dist/Data/SKSE/Plugins/WikiMap.ini @@ -0,0 +1,80 @@ +[General] +Debug = false + +;; Set to false to disable the 'Wiki' button on Map and Quests menus. Useful if an incompatible menu is installed. +;; Keyboard shortcut will still work +UpdateBottomBar = true + +;; Url template for selected locations (using mouse cursor and hotkey). +;; %L is replaced by the location name, like "Dead Man's Drink" +;; The player location name is URL-encoded when replaced. +;UrlSelected="https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%L" +;UrlSelected="https://en.uesp.net/wiki/Skyrim:%L" +;UrlSelected="https://elderscrolls.fandom.com/wiki/Special:Search?query=%L" +UrlSelected = https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%L + +;; Url template for interiors (CURRENT PLAYER LOCATION). +;; %L is replaced by the location name, like "Dead Man's Drink" +;; %I is replaced by the interior location editorid, like "FalkreathDeadMansDrink" +;; Current Player Position: %X is replaced by the x coordinate, %Y by the y coordinate, and %Z by z coordinate. +;; The player location name is URL-encoded when replaced. +;UrlInterior="https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%L" +;UrlInterior="https://en.uesp.net/wiki/Skyrim:%L" +;UrlInterior="https://elderscrolls.fandom.com/wiki/Special:Search?query=%L" +;UrlInterior="https://elderscrolls.fandom.com/wiki/%L" +UrlInterior = https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%L + +;; Url template for quests. +;; %Q is replaced by the quest name, like "Before the Storm" +;; %I is replaced by the quest editorid, like "MQ102" +;; The quest name is URL-encoded when replaced. +;UrlQuest="https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%Q" +;UrlQuest="https://en.uesp.net/wiki/Skyrim:%Q" +;UrlQuest="https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%I" +;UrlQuest="https://en.uesp.net/wiki/Skyrim:%I" +;UrlQuest="https://elderscrolls.fandom.com/wiki/Special:Search?query=%I" +;UrlQuest="https://elderscrolls.fandom.com/wiki/%Q" +UrlQuest = https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%Q + + +[User] + +;; KeyCode +;; Slash = 53 +;; Period = 52 +;; Comma = 51 +;; https://learn.microsoft.com/en-us/previous-versions/windows/desktop/bb321074(v=vs.85) +;; This option is overwritten by MCM settings, configure in-game if you have MCM Helper installed +KeyCode = 53 + +;; Modifier key (CTRL,ALT,SHIFT) +;; Set to 0 if you don't want to use a modifier key +;; RightAlt = 184 +;; LeftAlt = 56 +;; RightControl = 157 +;; LeftControl = 29 +;; LeftShift = 42 +;; RightShift = 54 +;; This option is overwritten by MCM settings, configure in-game if you have MCM Helper installed +ModifierKeyCode = 0 + +;; Use Steam overlay to open the web page. When false, will open the default browser over the game. +;; This option is overwritten by MCM settings, configure in-game if you have MCM Helper installed +EnableSteam = true + +;; When true, opens the web page on a dedicated Steam browser window without the other overlay options. +;; Steam has a bug and don't close the browser tab properly sometimes. Disable if you have issues on Steam overlay. +;; This option is overwritten by MCM settings, configure in-game if you have MCM Helper installed +UseSteamModal = false + + +;; Url templates for exteriors (CURRENT PLAYER LOCATION) +;; Each option has the format "World_" with the Worldspace EditorID appended. +;; The key for Skyrim worldspace is "World_Tamriel". For Solstheim, is "World_DLC2SolstheimWorld". +;; %L is replaced by the location name, like "Dead Man's Drink" +;; %W is replaced by the worldspace name, like "Skyrim" and "Solstheim" +;; Current Player Position: %X is replaced by the x coordinate, %Y by the y coordinate, and %Z by z coordinate. +;; The player location name and worldspace name are URL-encoded when replaced. +[Worldspaces] +World_Tamriel = https://gamemap.uesp.net/sr?world=skyrim&zoom=17&x=%X&y=%Y +World_DLC2SolstheimWorld = https://gamemap.uesp.net/sr/?world=solstheim&zoom=17&x=%X&y=%Y diff --git a/dist/Data/Scripts/WikiMapIntegration_MCM.pex b/dist/Data/Scripts/WikiMapIntegration_MCM.pex new file mode 100644 index 0000000000000000000000000000000000000000..f6bace8844944652ce5a305d4f6d74300dc7b868 GIT binary patch literal 1504 zcmbVK-A)rh6h7N6Ev1weq@|^zOEj8zVGyIy^{x#PV+sjP;M zl7n8i_jnrlROG2ZI;7%GZ|9)Dzek(YxEzmm^SiA3+S5#>U8PmxR`+F}wH9*J9eZ-b zRN0qZC5K|vov4VZ>?;`vGu4|=VJw1xB`tx#AVGCJfbx4vGQE5~lfFSZdhBT@IuY6* zbA(7lj(Y!reeGz4kez7Cz8DG)oG2zVFZm?lQ|RjuWT@o2rs+E`qy;5+WRR5e5l@Cx zbloIeRI?`96NK6@1U5cIauL8tw=?x!j@qxu+@LCI@M_nW?0P`RyitI z=$CxDcAMrC@9f_KS({3Fd0eK+&Ce9Xq>+sFoHqH*Ft^$~&+YNYT{yhxdhzB=JXrTl~ znAQNc3D0D|EW~~jypd|+-KI(B0coX>7l6QTC6M&E6#4na$c-B#AKe)F{30@2#oWrB zbNzFW!9K+kYh=0XC=!+O9xF_Mvsj@v~-|l`%KHW0X;}XtfwN{$(_Wt`$=u} b3dqX!kj?8M*7cC>6!Le49J9`|D-`+(nKR1# literal 0 HcmV?d00001 diff --git a/dist/Data/Source/Scripts/WikiMapIntegration_MCM.psc b/dist/Data/Source/Scripts/WikiMapIntegration_MCM.psc new file mode 100644 index 0000000..2a62364 --- /dev/null +++ b/dist/Data/Source/Scripts/WikiMapIntegration_MCM.psc @@ -0,0 +1,27 @@ +Scriptname WikiMapIntegration_MCM extends MCM_ConfigBase + +Event OnSettingChange(string id) + if id == "iModifierKeyCode:General" + int k = GetModSettingInt("iModifierKeyCode:General") + if k != 184 && k != 56 && k != 157 && k != 29 && k!= 42 && k !=54 + SetModSettingInt("iModifierKeyCode:General", -1) + endIf + ;; RightAlt = 184 + ;; LeftAlt = 56 + ;; RightControl = 157 + ;; LeftControl = 29 + ;; LeftShift = 42 + ;; RightShift = 54 + self.RefreshMenu() + endIf + if id == "iKeyCode:General" + int k = GetModSettingInt("iKeyCode:General") + ;;L=38, J=36, E=18, F=33, M=50, ESC=1 + if k == 38 || k == 36 || k == 18 || k == 33 || k == 1 || k == 50 + SetModSettingInt("iKeyCode:General", 53) + endIf + self.RefreshMenu() + endIf +EndEvent + +function OnConfigClose() native diff --git a/dist/Data/WikiMapIntegration.esp b/dist/Data/WikiMapIntegration.esp new file mode 100644 index 0000000000000000000000000000000000000000..c9380aef93f15d895bb1f085be16861135e1dcc7 GIT binary patch literal 358 zcmZ`!L2kk@5FDda;*etnALt1oPV`(^v6EWZ5hPB^4OwbbMNOdsE`3V*Qy1t+R*N;=9}9LtFAojXnyiK$9rmXydQ1JzU!A+ zWv|Ehty4+SotvMIOuWaqv z7o6AlO!;;5BpjJNd#yt|v8d{j%p1_h+LiT)IzZc27&gDD;)W`xUiq463)omXF4cYw zk~wRR&4BfmiiYTGx0$gokt{))**|=xllR0sH*36;-Dgyl=a#it348TVIMk)F_er`w zc^1SDjXK^kCw$2}R#hQR+gNRPW&5(NBO|vaOF2f{=%w!!w?MXX4#j(7w6S&q!)9#EBkXFlly(#wktQy?Gwv2Q=sa1 z@1N?@go;hw0I|{Mq?baI+Tz|v5w}nCtQ#38`-5YdqAom~OEn?)!AK!Y=BXGi~uU>BZVK6ZrwDlI&9e literal 0 HcmV?d00001 diff --git a/dist/Data/interface/translations/WikiMapIntegration_english.txt b/dist/Data/interface/translations/WikiMapIntegration_english.txt new file mode 100644 index 0000000000000000000000000000000000000000..502da14d751c16fb204edb4ddf3057cf45d132e9 GIT binary patch literal 1354 zcmb7^*-qm?5Jl@1r1=Lw@QC<_Q3L`3V%Ws9orOe`*dcL<^7FvCRqogci-e-MyKB8w zx4Pfoj_k=M_MiX3cK62)?Z{58wA>1t+R*N;=9}9LtFAojXnyiK$9rmXydQ1JzU!A+ zWv|Ehty4+SotvMIOuWaqv z7o6AlO!;;5BpjJNd#yt|v8d{j%p1_h+LiT)IzZc27&gDD;)W`xUiq463)omXF4cYw zk~wRR&4BfmiiYTGx0$gokt{))**|=xllR0sH*36;-Dgyl=a#it348TVIMk)F_er`w zc^1SDjXK^kCw$2}R#hQR+gNRPW&5(NBO|vaOF2f{=%w!!w?MXX4#j(7w6S&q!)9#EBkXFlly(#wktQy?Gwv2Q=sa1 z@1N?@go;hw0I|{Mq?baI+Tz|v5w}nCtQ#38`-5YdqAom~OEn?)!AK!Y=BXGi~uU>BZVK6ZrwDlI&9e literal 0 HcmV?d00001 diff --git a/dist/Data/interface/translations/WikiMapIntegration_french.txt b/dist/Data/interface/translations/WikiMapIntegration_french.txt new file mode 100644 index 0000000000000000000000000000000000000000..502da14d751c16fb204edb4ddf3057cf45d132e9 GIT binary patch literal 1354 zcmb7^*-qm?5Jl@1r1=Lw@QC<_Q3L`3V%Ws9orOe`*dcL<^7FvCRqogci-e-MyKB8w zx4Pfoj_k=M_MiX3cK62)?Z{58wA>1t+R*N;=9}9LtFAojXnyiK$9rmXydQ1JzU!A+ zWv|Ehty4+SotvMIOuWaqv z7o6AlO!;;5BpjJNd#yt|v8d{j%p1_h+LiT)IzZc27&gDD;)W`xUiq463)omXF4cYw zk~wRR&4BfmiiYTGx0$gokt{))**|=xllR0sH*36;-Dgyl=a#it348TVIMk)F_er`w zc^1SDjXK^kCw$2}R#hQR+gNRPW&5(NBO|vaOF2f{=%w!!w?MXX4#j(7w6S&q!)9#EBkXFlly(#wktQy?Gwv2Q=sa1 z@1N?@go;hw0I|{Mq?baI+Tz|v5w}nCtQ#38`-5YdqAom~OEn?)!AK!Y=BXGi~uU>BZVK6ZrwDlI&9e literal 0 HcmV?d00001 diff --git a/dist/Data/interface/translations/WikiMapIntegration_german.txt b/dist/Data/interface/translations/WikiMapIntegration_german.txt new file mode 100644 index 0000000000000000000000000000000000000000..502da14d751c16fb204edb4ddf3057cf45d132e9 GIT binary patch literal 1354 zcmb7^*-qm?5Jl@1r1=Lw@QC<_Q3L`3V%Ws9orOe`*dcL<^7FvCRqogci-e-MyKB8w zx4Pfoj_k=M_MiX3cK62)?Z{58wA>1t+R*N;=9}9LtFAojXnyiK$9rmXydQ1JzU!A+ zWv|Ehty4+SotvMIOuWaqv z7o6AlO!;;5BpjJNd#yt|v8d{j%p1_h+LiT)IzZc27&gDD;)W`xUiq463)omXF4cYw zk~wRR&4BfmiiYTGx0$gokt{))**|=xllR0sH*36;-Dgyl=a#it348TVIMk)F_er`w zc^1SDjXK^kCw$2}R#hQR+gNRPW&5(NBO|vaOF2f{=%w!!w?MXX4#j(7w6S&q!)9#EBkXFlly(#wktQy?Gwv2Q=sa1 z@1N?@go;hw0I|{Mq?baI+Tz|v5w}nCtQ#38`-5YdqAom~OEn?)!AK!Y=BXGi~uU>BZVK6ZrwDlI&9e literal 0 HcmV?d00001 diff --git a/dist/Data/interface/translations/WikiMapIntegration_italian.txt b/dist/Data/interface/translations/WikiMapIntegration_italian.txt new file mode 100644 index 0000000000000000000000000000000000000000..502da14d751c16fb204edb4ddf3057cf45d132e9 GIT binary patch literal 1354 zcmb7^*-qm?5Jl@1r1=Lw@QC<_Q3L`3V%Ws9orOe`*dcL<^7FvCRqogci-e-MyKB8w zx4Pfoj_k=M_MiX3cK62)?Z{58wA>1t+R*N;=9}9LtFAojXnyiK$9rmXydQ1JzU!A+ zWv|Ehty4+SotvMIOuWaqv z7o6AlO!;;5BpjJNd#yt|v8d{j%p1_h+LiT)IzZc27&gDD;)W`xUiq463)omXF4cYw zk~wRR&4BfmiiYTGx0$gokt{))**|=xllR0sH*36;-Dgyl=a#it348TVIMk)F_er`w zc^1SDjXK^kCw$2}R#hQR+gNRPW&5(NBO|vaOF2f{=%w!!w?MXX4#j(7w6S&q!)9#EBkXFlly(#wktQy?Gwv2Q=sa1 z@1N?@go;hw0I|{Mq?baI+Tz|v5w}nCtQ#38`-5YdqAom~OEn?)!AK!Y=BXGi~uU>BZVK6ZrwDlI&9e literal 0 HcmV?d00001 diff --git a/dist/Data/interface/translations/WikiMapIntegration_japanese.txt b/dist/Data/interface/translations/WikiMapIntegration_japanese.txt new file mode 100644 index 0000000000000000000000000000000000000000..502da14d751c16fb204edb4ddf3057cf45d132e9 GIT binary patch literal 1354 zcmb7^*-qm?5Jl@1r1=Lw@QC<_Q3L`3V%Ws9orOe`*dcL<^7FvCRqogci-e-MyKB8w zx4Pfoj_k=M_MiX3cK62)?Z{58wA>1t+R*N;=9}9LtFAojXnyiK$9rmXydQ1JzU!A+ zWv|Ehty4+SotvMIOuWaqv z7o6AlO!;;5BpjJNd#yt|v8d{j%p1_h+LiT)IzZc27&gDD;)W`xUiq463)omXF4cYw zk~wRR&4BfmiiYTGx0$gokt{))**|=xllR0sH*36;-Dgyl=a#it348TVIMk)F_er`w zc^1SDjXK^kCw$2}R#hQR+gNRPW&5(NBO|vaOF2f{=%w!!w?MXX4#j(7w6S&q!)9#EBkXFlly(#wktQy?Gwv2Q=sa1 z@1N?@go;hw0I|{Mq?baI+Tz|v5w}nCtQ#38`-5YdqAom~OEn?)!AK!Y=BXGi~uU>BZVK6ZrwDlI&9e literal 0 HcmV?d00001 diff --git a/dist/Data/interface/translations/WikiMapIntegration_polish.txt b/dist/Data/interface/translations/WikiMapIntegration_polish.txt new file mode 100644 index 0000000000000000000000000000000000000000..502da14d751c16fb204edb4ddf3057cf45d132e9 GIT binary patch literal 1354 zcmb7^*-qm?5Jl@1r1=Lw@QC<_Q3L`3V%Ws9orOe`*dcL<^7FvCRqogci-e-MyKB8w zx4Pfoj_k=M_MiX3cK62)?Z{58wA>1t+R*N;=9}9LtFAojXnyiK$9rmXydQ1JzU!A+ zWv|Ehty4+SotvMIOuWaqv z7o6AlO!;;5BpjJNd#yt|v8d{j%p1_h+LiT)IzZc27&gDD;)W`xUiq463)omXF4cYw zk~wRR&4BfmiiYTGx0$gokt{))**|=xllR0sH*36;-Dgyl=a#it348TVIMk)F_er`w zc^1SDjXK^kCw$2}R#hQR+gNRPW&5(NBO|vaOF2f{=%w!!w?MXX4#j(7w6S&q!)9#EBkXFlly(#wktQy?Gwv2Q=sa1 z@1N?@go;hw0I|{Mq?baI+Tz|v5w}nCtQ#38`-5YdqAom~OEn?)!AK!Y=BXGi~uU>BZVK6ZrwDlI&9e literal 0 HcmV?d00001 diff --git a/dist/Data/interface/translations/WikiMapIntegration_russian.txt b/dist/Data/interface/translations/WikiMapIntegration_russian.txt new file mode 100644 index 0000000000000000000000000000000000000000..502da14d751c16fb204edb4ddf3057cf45d132e9 GIT binary patch literal 1354 zcmb7^*-qm?5Jl@1r1=Lw@QC<_Q3L`3V%Ws9orOe`*dcL<^7FvCRqogci-e-MyKB8w zx4Pfoj_k=M_MiX3cK62)?Z{58wA>1t+R*N;=9}9LtFAojXnyiK$9rmXydQ1JzU!A+ zWv|Ehty4+SotvMIOuWaqv z7o6AlO!;;5BpjJNd#yt|v8d{j%p1_h+LiT)IzZc27&gDD;)W`xUiq463)omXF4cYw zk~wRR&4BfmiiYTGx0$gokt{))**|=xllR0sH*36;-Dgyl=a#it348TVIMk)F_er`w zc^1SDjXK^kCw$2}R#hQR+gNRPW&5(NBO|vaOF2f{=%w!!w?MXX4#j(7w6S&q!)9#EBkXFlly(#wktQy?Gwv2Q=sa1 z@1N?@go;hw0I|{Mq?baI+Tz|v5w}nCtQ#38`-5YdqAom~OEn?)!AK!Y=BXGi~uU>BZVK6ZrwDlI&9e literal 0 HcmV?d00001 diff --git a/dist/Data/interface/translations/WikiMapIntegration_spanish.txt b/dist/Data/interface/translations/WikiMapIntegration_spanish.txt new file mode 100644 index 0000000000000000000000000000000000000000..502da14d751c16fb204edb4ddf3057cf45d132e9 GIT binary patch literal 1354 zcmb7^*-qm?5Jl@1r1=Lw@QC<_Q3L`3V%Ws9orOe`*dcL<^7FvCRqogci-e-MyKB8w zx4Pfoj_k=M_MiX3cK62)?Z{58wA>1t+R*N;=9}9LtFAojXnyiK$9rmXydQ1JzU!A+ zWv|Ehty4+SotvMIOuWaqv z7o6AlO!;;5BpjJNd#yt|v8d{j%p1_h+LiT)IzZc27&gDD;)W`xUiq463)omXF4cYw zk~wRR&4BfmiiYTGx0$gokt{))**|=xllR0sH*36;-Dgyl=a#it348TVIMk)F_er`w zc^1SDjXK^kCw$2}R#hQR+gNRPW&5(NBO|vaOF2f{=%w!!w?MXX4#j(7w6S&q!)9#EBkXFlly(#wktQy?Gwv2Q=sa1 z@1N?@go;hw0I|{Mq?baI+Tz|v5w}nCtQ#38`-5YdqAom~OEn?)!AK!Y=BXGi~uU>BZVK6ZrwDlI&9e literal 0 HcmV?d00001 diff --git a/src/Config.cpp b/src/Config.cpp new file mode 100644 index 0000000..78e96ca --- /dev/null +++ b/src/Config.cpp @@ -0,0 +1,189 @@ +#include + +namespace wmh { + Config::Config() { + readConfig(); + } + + void Config::readConfig() { + using namespace constants; + + // main ini file + CSimpleIniA ini{}; + ini.SetQuotes(true); + ini.SetAllowKeyOnly(false); + ini.SetUnicode(true); + ini.SetMultiKey(false); + std::string fileName = std::string{"Data\\SKSE\\Plugins\\"}.append(CONFIG_FILE); + + logger::debug("loading config from: '{}';", fileName); + bool save = false; + if (ini.LoadFile(fileName.c_str()) == 0) { + debug = ini.GetBoolValue(INI_SECTION_GENERAL, INI_OPT_DEBUG, debug); + urlInterior = ini.GetValue(INI_SECTION_GENERAL, INI_OPTINTERIORURL, urlInterior.c_str()); + urlSelected = ini.GetValue(INI_SECTION_GENERAL, INI_OPTSELECTEDURL, urlSelected.c_str()); + urlQuest = ini.GetValue(INI_SECTION_GENERAL, INI_OPTQUESTURL, urlQuest.c_str()); + enableSteam = ini.GetBoolValue(INI_SECTION_USER, INI_OPTENABLESTEAM, enableSteam); + useSteamModal = ini.GetBoolValue(INI_SECTION_USER, INI_OPTUSESTEAMMODAL, useSteamModal); + keyCode = ini.GetLongValue(INI_SECTION_USER, INI_OPTKEYCODE, keyCode); + modCode = ini.GetLongValue(INI_SECTION_USER, INI_OPTMODCODE, modCode); + updateBottomBar = ini.GetBoolValue(INI_SECTION_GENERAL, INI_OPTBOTTOMBAR, updateBottomBar); + + if (ini.SectionExists(INI_SECTION_WORLD)) { + for (auto const& e: *ini.GetSection(INI_SECTION_WORLD)) { + if (e.first.pItem && e.second && boost::algorithm::istarts_with(e.first.pItem, INI_OPTPREFIX_WORLD)) { + std::string worldId{e.first.pItem}; + boost::algorithm::replace_first(worldId, INI_OPTPREFIX_WORLD, ""); + if (!worldId.empty()) { + worldUrl.emplace(std::make_pair(worldId, e.second)); + logger::debug("world found: editorID:'{}'; url:'{}';", worldId, e.second); + } + } + } + } + } else { + logger::error("Can't open config file '{}'. Trying to create it.", CONFIG_FILE); + } + + //create default config + if (!ini.KeyExists(INI_SECTION_GENERAL, INI_OPT_DEBUG)) { + ini.SetBoolValue(INI_SECTION_GENERAL, INI_OPT_DEBUG, debug, nullptr, false); + save = true; + } + if (!ini.KeyExists(INI_SECTION_GENERAL, INI_OPTBOTTOMBAR)) { + ini.SetBoolValue(INI_SECTION_GENERAL, INI_OPTBOTTOMBAR, updateBottomBar, INI_COMMENT_OPTBOTTOMBAR, false); + save = true; + } + if (!ini.KeyExists(INI_SECTION_USER, INI_OPTKEYCODE)) { + ini.SetLongValue(INI_SECTION_USER, INI_OPTKEYCODE, keyCode, INI_COMMENT_OPTKEYCODE, false); + save = true; + } + if (!ini.KeyExists(INI_SECTION_USER, INI_OPTMODCODE)) { + ini.SetLongValue(INI_SECTION_USER, INI_OPTMODCODE, modCode, INI_COMMENT_OPTMODCODE, false); + save = true; + } + if (!ini.KeyExists(INI_SECTION_USER, INI_OPTENABLESTEAM)) { + ini.SetBoolValue(INI_SECTION_USER, INI_OPTENABLESTEAM, enableSteam, INI_COMMENT_OPTENABLESTEAM, false); + save = true; + } + if (!ini.KeyExists(INI_SECTION_USER, INI_OPTUSESTEAMMODAL)) { + ini.SetBoolValue(INI_SECTION_USER, INI_OPTUSESTEAMMODAL, useSteamModal, INI_COMMENT_OPTUSESTEAMMODAL, false); + save = true; + } + if (!ini.KeyExists(INI_SECTION_GENERAL, INI_OPTSELECTEDURL)) { + ini.SetValue(INI_SECTION_GENERAL, INI_OPTSELECTEDURL, urlSelected.c_str(), INI_COMMENT_OPTSELECTEDURL, false); + save = true; + } + if (!ini.KeyExists(INI_SECTION_GENERAL, INI_OPTINTERIORURL)) { + ini.SetValue(INI_SECTION_GENERAL, INI_OPTINTERIORURL, urlInterior.c_str(), INI_COMMENT_OPTINTERIORURL, false); + save = true; + } + if (!ini.KeyExists(INI_SECTION_GENERAL, INI_OPTQUESTURL)) { + ini.SetValue(INI_SECTION_GENERAL, INI_OPTQUESTURL, urlQuest.c_str(), INI_COMMENT_OPTQUESTURL, false); + save = true; + } + if (!ini.SectionExists(INI_SECTION_WORLD)) { + ini.SetValue(INI_SECTION_WORLD, nullptr, nullptr, INI_COMMENT_WORLD); + save = true; + } + if (!ini.KeyExists(INI_SECTION_WORLD, std::format("{}Tamriel", INI_OPTPREFIX_WORLD).c_str())) { + ini.SetValue(INI_SECTION_WORLD, std::format("{}Tamriel", INI_OPTPREFIX_WORLD).c_str(), INI_DEF_URL_TAMRIEL, nullptr, false); + save = true; + } + if (!ini.KeyExists(INI_SECTION_WORLD, std::format("{}DLC2SolstheimWorld", INI_OPTPREFIX_WORLD).c_str())) { + ini.SetValue(INI_SECTION_WORLD, std::format("{}DLC2SolstheimWorld", INI_OPTPREFIX_WORLD).c_str(), INI_DEF_URL_SOLSTHEIM, + nullptr, false); + save = true; + } + + if (save) { + ini.SaveFile(fileName.c_str()); + } + + CSimpleIniA settings{}; + settings.SetQuotes(true); + settings.SetAllowKeyOnly(false); + settings.SetUnicode(true); + settings.SetMultiKey(false); + + std::string mcmConfig = std::string{"Data\\MCM\\Settings\\"}.append(MCM_CONFIG_FILE); + if (ini.LoadFile(mcmConfig.c_str()) == 0) { + logger::debug("loading config from:'{}';", mcmConfig); + enableSteam = ini.GetBoolValue(INI_SECTION_GENERAL, std::string("b").append(INI_OPTENABLESTEAM).c_str(), enableSteam); + useSteamModal = ini.GetBoolValue(INI_SECTION_GENERAL, std::string("b").append(INI_OPTUSESTEAMMODAL).c_str(), useSteamModal); + keyCode = ini.GetLongValue(INI_SECTION_GENERAL, std::string("i").append(INI_OPTKEYCODE).c_str(), keyCode); + modCode = ini.GetLongValue(INI_SECTION_GENERAL, std::string("i").append(INI_OPTMODCODE).c_str(), modCode); + } + + logger::info("config enableSteam:'{}'; useSteamModal:'{}'; keyCode:'{}'; modCode:'{}';", enableSteam, useSteamModal, keyCode, + modCode); + + try { + logger::debug("calling onConfigLoad event handler"); + configLoadFunc(); + } catch (const std::exception& e) { + logger::error("Exception calling onConfigLoad handler: '{}'", e.what()); + } + } + + const std::multimap& Config::getMapUrlWorld() { + return worldUrl; + } + + const std::string Config::getUrlInterior() { + return urlInterior; + } + + const std::string Config::getUrlSelected() { + return urlSelected; + } + + const std::string Config::getUrlQuest() { + return urlQuest; + } + + bool Config::isEnableSteam() { + return enableSteam; + } + + void Config::setEnableSteam(bool b) { + enableSteam = b; + } + + bool Config::isUseSteamModal() { + return useSteamModal; + } + + void Config::setUseSteamModal(bool b) { + useSteamModal = b; + } + + int Config::getKeyCode() { + return keyCode; + } + + void Config::setKeyCode(int newCode) { + keyCode = newCode; + } + + int Config::getModCode() { + return modCode; + } + + void Config::setModCode(int newMod) { + modCode = newMod; + } + + [[nodiscard]] bool Config::isDebug() const { + return debug; + } + + int Config::isUpdateBottomBar() { + return updateBottomBar; + } + + void Config::setConfigLoadHandler(std::function func) { + configLoadFunc = func; + configLoadFunc(); + } +} // namespace wmh diff --git a/src/Config.h b/src/Config.h new file mode 100644 index 0000000..56cd88a --- /dev/null +++ b/src/Config.h @@ -0,0 +1,140 @@ +#pragma once + +#include + +#include + +namespace wmh { + class Config { + private: + Config(); + Config(Config&) = delete; + Config& operator=(Config&&) = delete; + void operator=(Config&) = delete; + + bool enableSteam = true; + bool useSteamModal = false; + bool updateBottomBar = true; + std::string urlInterior = "https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%L"; + std::string urlSelected = "https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%L"; + std::multimap worldUrl{}; + std::string urlQuest = "https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%Q"; + int keyCode = 53; + int modCode = 0; + std::function configLoadFunc = []() {}; + + bool debug = false; + + public: + [[nodiscard]] static Config& get() { + static Config instance; + return instance; + } + + void readConfig(); + + [[nodiscard]] const std::multimap& getMapUrlWorld(); + [[nodiscard]] const std::string getUrlInterior(); + [[nodiscard]] const std::string getUrlSelected(); + [[nodiscard]] const std::string getUrlQuest(); + + [[nodiscard]] bool isEnableSteam(); + void setEnableSteam(bool b); + + [[nodiscard]] bool isUseSteamModal(); + void setUseSteamModal(bool b); + + [[nodiscard]] int getKeyCode(); + void setKeyCode(int newCode); + + [[nodiscard]] int getModCode(); + void setModCode(int newMod); + + [[nodiscard]] int isUpdateBottomBar(); + + [[nodiscard]] bool isDebug() const; + void setConfigLoadHandler(std::function func); + }; +} // namespace wmh + +namespace constants { + static constexpr const char* CONFIG_FILE = "WikiMap.ini"; + static constexpr const char* MCM_CONFIG_FILE = "WikiMapIntegration.ini"; + static constexpr const char* INI_SECTION_GENERAL = "General"; + static constexpr const char* INI_SECTION_USER = "User"; + static constexpr const char* INI_SECTION_WORLD = "Worldspaces"; + static constexpr const char* INI_OPT_DEBUG = "Debug"; + static constexpr const char* INI_OPTENABLESTEAM = "EnableSteam"; + static constexpr const char* INI_OPTUSESTEAMMODAL = "UseSteamModal"; + static constexpr const char* INI_OPTSELECTEDURL = "UrlSelected"; + static constexpr const char* INI_OPTINTERIORURL = "UrlInterior"; + static constexpr const char* INI_OPTQUESTURL = "UrlQuest"; + static constexpr const char* INI_OPTPREFIX_WORLD = "World_"; + static constexpr const char* INI_OPTKEYCODE = "KeyCode"; + static constexpr const char* INI_OPTMODCODE = "ModifierKeyCode"; + static constexpr const char* INI_OPTBOTTOMBAR = "UpdateBottomBar"; + static constexpr const char* INI_DEF_URL_TAMRIEL = "https://gamemap.uesp.net/sr?world=skyrim&zoom=17&x=%X&y=%Y"; + static constexpr const char* INI_DEF_URL_SOLSTHEIM = "https://gamemap.uesp.net/sr/?world=solstheim&zoom=17&x=%X&y=%Y"; + static constexpr const char* INI_COMMENT_OPTBOTTOMBAR = + ";; Set to false to disable the 'Wiki' button on Map and Quests menus. Useful if an incompatible menu is installed.\n" + ";; Keyboard shortcut will still work"; + static constexpr const char* INI_COMMENT_OPTKEYCODE = + ";; KeyCode\n" + ";; Slash = 53\n" + ";; Period = 52\n" + ";; Comma = 51\n" + ";; https://learn.microsoft.com/en-us/previous-versions/windows/desktop/bb321074(v=vs.85)\n" + ";; This option is overwritten by MCM settings, configure in-game if you have MCM Helper installed"; + static constexpr const char* INI_COMMENT_OPTMODCODE = + ";; Modifier key (CTRL,ALT,SHIFT)\n" + ";; Set to 0 if you don't want to use a modifier key\n" + ";; RightAlt = 184\n" + ";; LeftAlt = 56\n" + ";; RightControl = 157\n" + ";; LeftControl = 29\n" + ";; LeftShift = 42\n" + ";; RightShift = 54\n" + ";; This option is overwritten by MCM settings, configure in-game if you have MCM Helper installed"; + static constexpr const char* INI_COMMENT_OPTENABLESTEAM = + ";; Use Steam overlay to open the web page. When false, will open the default browser over the game.\n" + ";; This option is overwritten by MCM settings, configure in-game if you have MCM Helper installed"; + static constexpr const char* INI_COMMENT_OPTUSESTEAMMODAL = + ";; When true, opens the web page on a dedicated Steam browser window without the other overlay options.\n" + ";; Steam has a bug and don't close the browser tab properly sometimes. Disable if you have issues on Steam overlay."; + static constexpr const char* INI_COMMENT_OPTSELECTEDURL = + ";; Url template for selected locations (using mouse cursor and hotkey).\n" + ";; %L is replaced by the location name, like \"Dead Man's Drink\"\n" + ";; The player location name is URL-encoded when replaced.\n" + ";UrlSelected=\"https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%L\"\n" + ";UrlSelected=\"https://en.uesp.net/wiki/Skyrim:%L\"\n" + ";UrlSelected=\"https://elderscrolls.fandom.com/wiki/Special:Search?query=%L\""; + static constexpr const char* INI_COMMENT_OPTINTERIORURL = + ";; Url template for interiors (CURRENT PLAYER LOCATION).\n" + ";; %L is replaced by the location name, like \"Dead Man's Drink\"\n" + ";; %I is replaced by the interior location editorid, like \"FalkreathDeadMansDrink\"\n" + ";; Current Player Position: %X is replaced by the x coordinate, %Y by the y coordinate, and %Z by z coordinate.\n" + ";; The player location name is URL-encoded when replaced.\n" + ";UrlInterior=\"https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%L\"\n" + ";UrlInterior=\"https://en.uesp.net/wiki/Skyrim:%L\"\n" + ";UrlInterior=\"https://elderscrolls.fandom.com/wiki/Special:Search?query=%L\"\n" + ";UrlInterior=\"https://elderscrolls.fandom.com/wiki/%L\""; + static constexpr const char* INI_COMMENT_OPTQUESTURL = + ";; Url template for quests.\n" + ";; %Q is replaced by the quest name, like \"Before the Storm\"\n" + ";; %I is replaced by the quest editorid, like \"MQ102\"\n" + ";; The quest name is URL-encoded when replaced.\n" + ";UrlQuest=\"https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%Q\"\n" + ";UrlQuest=\"https://en.uesp.net/wiki/Skyrim:%Q\"\n" + ";UrlQuest=\"https://en.uesp.net/w/index.php?title=Special:Search&search=Skyrim:%I\"\n" + ";UrlQuest=\"https://en.uesp.net/wiki/Skyrim:%I\"\n" + ";UrlQuest=\"https://elderscrolls.fandom.com/wiki/Special:Search?query=%I\"\n" + ";UrlQuest=\"https://elderscrolls.fandom.com/wiki/%Q\""; + static constexpr const char* INI_COMMENT_WORLD = + ";; Url templates for exteriors (CURRENT PLAYER LOCATION)\n" + ";; Each option has the format \"World_\" with the Worldspace EditorID appended.\n" + ";; The key for Skyrim worldspace is \"World_Tamriel\". For Solstheim, is \"World_DLC2SolstheimWorld\".\n" + ";; %L is replaced by the location name, like \"Dead Man's Drink\"\n" + ";; %W is replaced by the worldspace name, like \"Skyrim\" and \"Solstheim\"\n" + ";; Current Player Position: %X is replaced by the x coordinate, %Y by the y coordinate, and %Z by z coordinate.\n" + ";; The player location name and worldspace name are URL-encoded when replaced."; +} // namespace constants \ No newline at end of file diff --git a/src/GameEventHandler.cpp b/src/GameEventHandler.cpp new file mode 100644 index 0000000..84471f5 --- /dev/null +++ b/src/GameEventHandler.cpp @@ -0,0 +1,45 @@ +#include "GameEventHandler.h" + +#include "Config.h" +#include "MCM.h" +#include "Hooks.h" + +namespace wmh { + void GameEventHandler::onLoad() { + if (Config::get().isDebug()) { + spdlog::set_level(spdlog::level::debug); + spdlog::flush_on(spdlog::level::debug); + spdlog::set_pattern(PLUGIN_LOGPATTERN_DEBUG); + } + + logger::trace("registering papyrus callback"); + SKSE::GetPapyrusInterface()->Register(MCM::registerFunctions); + + Config::get().setConfigLoadHandler([this]() { + logger::debug("setting inputhandler key-codes: modKey:'{}'; key:'{}';", Config::get().getModCode(), Config::get().getKeyCode()); + inputListener.setKey(Config::get().getKeyCode()); + inputListener.setModifier(Config::get().getModCode()); + }); + } + + void GameEventHandler::onInputLoaded() { + logger::debug("configuring input handler: modKey:'{}'; key:'{}';", Config::get().getModCode(), Config::get().getKeyCode()); + inputListener.setHandler(urlProvider.inputHandler(), Config::get().getModCode(), Config::get().getKeyCode()); + + Hooks::installMovieHook(); + } + + void GameEventHandler::onDataLoaded() {} + + void GameEventHandler::onNewGame() { + inputListener.setEnabled(true); + } + + void GameEventHandler::onPreLoadGame() { + inputListener.setEnabled(false); + } + + void GameEventHandler::onPostLoadGame() { + inputListener.setEnabled(true); + } +} // namespace wmh \ No newline at end of file diff --git a/src/GameEventHandler.h b/src/GameEventHandler.h new file mode 100644 index 0000000..9a06e47 --- /dev/null +++ b/src/GameEventHandler.h @@ -0,0 +1,31 @@ +#pragma once +#include "SkseMessagingListener.h" +#include "InputListener.h" +#include "UrlProvider.h" + +namespace wmh { + class GameEventHandler : public SkseMessagingListener { + private: + GameEventHandler() { + registerListener(); + }; + GameEventHandler(GameEventHandler&) = delete; + GameEventHandler& operator=(GameEventHandler&&) = delete; + void operator=(GameEventHandler&) = delete; + UrlProvider urlProvider{}; + InputListener inputListener{}; + + public: + [[nodiscard]] static GameEventHandler& getInstance() { + static GameEventHandler instance; + return instance; + } + + void onLoad() override; + void onInputLoaded() override; + void onDataLoaded() override; + void onNewGame() override; + void onPreLoadGame() override; + void onPostLoadGame() override; + }; +} // namespace wmh diff --git a/src/Hooks.cpp b/src/Hooks.cpp new file mode 100644 index 0000000..ade47bf --- /dev/null +++ b/src/Hooks.cpp @@ -0,0 +1,43 @@ +#include "Hooks.h" +#include "MapMenuHook.h" +#include "QuestMenuHook.h" + +namespace wmh { + void Hooks::setViewScaleModeHook(RE::GFxMovieView* movieView, RE::GFxMovieView::ScaleModeType scaleMode) { + setViewScaleMode(movieView, scaleMode); + + RE::GFxValue mapMenu{}; + movieView->GetVariable(&mapMenu, "_global.Map.MapMenu.prototype"); + if (mapMenu.IsObject()) { + MapMenuHook::installMapMenuHook(movieView); + } + + RE::GFxValue questsMenu{}; + movieView->GetVariable(&questsMenu, "_global.QuestsPage.prototype"); + if (questsMenu.IsObject()) { + QuestMenuHook::installQuestMenuHook(movieView); + } + + RE::GFxValue journalMenu{}; + movieView->GetVariable(&journalMenu, "_global.Quest_Journal.prototype"); + if (journalMenu.IsObject()) { + QuestMenuHook::installJournalMenuHook(movieView); + } + } + + void Hooks::installMovieHook() { + REL::RelocationID hookFuncAddr = REL::RelocationID(ADDR_LOADMOVIE_SE, ADDR_LOADMOVIE_AE); + int hookFuncOffset = REL::Relocate(OFFSET_LOADMOVIE_AESE, OFFSET_LOADMOVIE_AESE, OFFSET_LOADMOVIE_VR); + std::uintptr_t hook = hookFuncAddr.address() + hookFuncOffset; + if (REL::make_pattern().match(hook)) { + auto& trampoline = SKSE::GetTrampoline(); + trampoline.create(64); + setViewScaleMode = *reinterpret_cast(trampoline.write_call<6>(hook, setViewScaleModeHook)); + logger::debug("Hook installed at address 0x{:X} (id {})", hookFuncAddr.offset(), hookFuncAddr.id()); + } else { + logger::error("Hook NOT installed, address 0x{:X} (id {}, offset 0x{:X}) doesn't match.", hookFuncAddr.offset(), + hookFuncAddr.id(), hookFuncOffset); + } + } + +} // namespace wmh \ No newline at end of file diff --git a/src/Hooks.h b/src/Hooks.h new file mode 100644 index 0000000..e2be96e --- /dev/null +++ b/src/Hooks.h @@ -0,0 +1,18 @@ +#pragma once + +namespace wmh { + class Hooks { + private: + static constexpr int ADDR_LOADMOVIE_SE = 80302; + static constexpr int ADDR_LOADMOVIE_AE = 82325; + static constexpr int OFFSET_LOADMOVIE_AESE = 0x1DD; + static constexpr int OFFSET_LOADMOVIE_VR = 0x1D9; + static constexpr SKSE::stl::nttp::string PATTERN_CHECK_LOADMOVIE = "FF 15"; + + static void setViewScaleModeHook(RE::GFxMovieView* movieView, RE::GFxMovieView::ScaleModeType scaleMode); + static inline REL::Relocation setViewScaleMode; + + public: + static void installMovieHook(); + }; +} // namespace wmh diff --git a/src/InputListener.cpp b/src/InputListener.cpp new file mode 100644 index 0000000..35b71a1 --- /dev/null +++ b/src/InputListener.cpp @@ -0,0 +1,68 @@ +#include "InputListener.h" + +namespace wmh { + void InputListener::setHandler(std::function function, int newModifier, int newKey) { + if (handlerSet) { + logger::warn("InputListener already configured!"); + return; + } + keyPressEventFunc = function; + setModifier(newModifier); + setKey(newKey); + RE::BSInputDeviceManager::GetSingleton()->AddEventSink(this); + handlerSet = true; + } + + bool InputListener::isEnabled() const { + return enabled; + } + + void InputListener::setEnabled(bool b) { + enabled = b; + } + + void InputListener::setModifier(int newMod) { + modifier = newMod < 0 ? 0 : newMod; + } + + void InputListener::setKey(int newKey) { + key = newKey < 0 ? 0 : newKey; + } + + RE::BSEventNotifyControl InputListener::ProcessEvent(RE::InputEvent* const* evtPtr, RE::BSTEventSource*) { + auto ui = RE::UI::GetSingleton(); + + if (!evtPtr || !*evtPtr || !enabled || key <= 0 || !ui) { + return RE::BSEventNotifyControl::kContinue; + } + auto* evt = *evtPtr; + + if ((!ui->IsMenuOpen(RE::MapMenu::MENU_NAME) && !ui->IsMenuOpen(RE::JournalMenu::MENU_NAME)) || + ui->IsMenuOpen(RE::Console::MENU_NAME) || !RE::PlayerCharacter::GetSingleton()->Is3DLoaded()) { + return RE::BSEventNotifyControl::kContinue; + } + + if (evt->GetEventType() == RE::INPUT_EVENT_TYPE::kButton) { + const RE::ButtonEvent* bEvent = evt->AsButtonEvent(); + int code = bEvent->GetIDCode(); + + if (RE::BSInputDeviceManager::GetSingleton()->IsGamepadEnabled()) { + code = SKSE::InputMap::GamepadMaskToKeycode(code); + } else { + if (modifier > 0 && code == modifier) { + modifierHeld = bEvent->IsHeld(); + } + } + + if (bEvent->IsUp() && code == key && + ((modifier > 0 && modifierHeld) || + (modifier <= 0 && !((GetAsyncKeyState(VK_MENU) & 0x8000) || (GetAsyncKeyState(VK_SHIFT) & 0x8000) || + (GetAsyncKeyState(VK_CONTROL) & 0x8000))))) { + modifierHeld = false; + keyPressEventFunc(); + } + } + + return RE::BSEventNotifyControl::kContinue; + } +} // namespace wmh \ No newline at end of file diff --git a/src/InputListener.h b/src/InputListener.h new file mode 100644 index 0000000..a61299b --- /dev/null +++ b/src/InputListener.h @@ -0,0 +1,26 @@ +#pragma once + +namespace wmh { + class InputListener : public RE::BSTEventSink { + private: + bool enabled = false; + int modifier = 0; + int key = 0; + bool modifierHeld = false; + bool handlerSet = false; + std::function keyPressEventFunc = []() {}; + + public: + InputListener() = default; + InputListener(InputListener&) = delete; + InputListener& operator=(InputListener&&) = delete; + void operator=(InputListener&) = delete; + + void setHandler(std::function function, int modifier, int key); + [[nodiscard]] bool isEnabled() const; + void setEnabled(bool b); + void setModifier(int modifier); + void setKey(int key); + RE::BSEventNotifyControl ProcessEvent(RE::InputEvent* const* eventPtr, RE::BSTEventSource*); + }; +} // namespace wmh \ No newline at end of file diff --git a/src/MCM.cpp b/src/MCM.cpp new file mode 100644 index 0000000..43dad7a --- /dev/null +++ b/src/MCM.cpp @@ -0,0 +1,15 @@ +#include "MCM.h" + +#include "Config.h" + +namespace wmh { + bool MCM::registerFunctions(RE::BSScript::IVirtualMachine* vm) { + logger::trace("registering OnConfigClose function"); + vm->RegisterFunction("OnConfigClose", "WikiMapIntegration_MCM", MCM::onConfigClose); + return true; + } + + void MCM::onConfigClose([[maybe_unused]] RE::TESQuest* quest) { + Config::get().readConfig(); + } +} // namespace wmh diff --git a/src/MCM.h b/src/MCM.h new file mode 100644 index 0000000..9bd163d --- /dev/null +++ b/src/MCM.h @@ -0,0 +1,11 @@ +#pragma once + +namespace wmh { + class MCM { + private: + static void onConfigClose(RE::TESQuest* quest); + + public: + static bool registerFunctions(RE::BSScript::IVirtualMachine* vm); + }; +} // namespace wmh diff --git a/src/MapMenuHook.cpp b/src/MapMenuHook.cpp new file mode 100644 index 0000000..1414f88 --- /dev/null +++ b/src/MapMenuHook.cpp @@ -0,0 +1,213 @@ +#include "MapMenuHook.h" +#include "SelectedItem.h" +#include "Config.h" + +namespace wmh { + void MapMenuHook::installMapMenuHook(RE::GFxMovieView* movieView) { + SelectedItem::getInstance().reset(); + + RE::GFxValue mapMenu{}; + movieView->GetVariable(&mapMenu, "_global.Map.MapMenu.prototype"); + if (mapMenu.IsObject()) { + RE::GFxValue setSelectedMarkerOrig{}; + mapMenu.GetMember("SetSelectedMarker", &setSelectedMarkerOrig); + if (setSelectedMarkerOrig.IsObject()) { + RE::GFxValue setSelectedMarkerNew{}; + RE::GPtr funcSetSelectedMarker = + RE::make_gptr(setSelectedMarkerOrig); + movieView->CreateFunction(&setSelectedMarkerNew, funcSetSelectedMarker.get()); + mapMenu.SetMember("SetSelectedMarker", setSelectedMarkerNew); + } + } + } + + void MapMenuHook::MapSetSelectedMarker::Call([[maybe_unused]] Params& params) { + if (origFunction.IsObject()) { + logger::trace("calling MapSetSelectedMarker::origFunction function"); + origFunction.Invoke("call", params.retVal, params.argsWithThisRef, params.argCount + 1); + } + + bool unsetMarker = false; + if (params.argCount == 0 || !params.args[0].IsNumber() || params.args[0].GetNumber() < 0) { + unsetMarker = true; + } + + int localMap = -1; + RE::GFxValue localMapMenu{}; + params.thisPtr->GetMember("LocalMapMenu", &localMapMenu); + if (localMapMenu.IsObject()) { + RE::GFxValue localMapState{}; + localMapMenu.GetMember("_state", &localMapState); //0 = hidden, 1 = localMap, 2=locationFinder + if (localMapState.IsNumber()) { + localMap = static_cast(localMapState.GetNumber()); + } else { + logger::error("LocalMap._state not found"); + } + if (isLocalMapOpen && localMap == 1) { + //stop if local map is open and current is world map + return; + } else if (localMap == 0) { + isLocalMapOpen = false; + } + } else if (params.thisPtr->HasMember("LocalMapMenu")) { + //LocalMapMenu member has no value when local map is open + localMap = 1; + isLocalMapOpen = true; + } + + if (unsetMarker && localMap != 1) { + //reset SelectedItem when we are in MapMenu and LocalMap is not open + logger::trace("resetting SelectedItem: unsetMarker:'{}'; localMap:'{}'", unsetMarker, localMap); + SelectedItem::getInstance().setMapNone(); + } + + if (!unsetMarker) { + int markerIdx = static_cast(params.args[0].GetNumber()); + RE::GFxValue markerList{}; + params.thisPtr->GetMember("_markerList", &markerList); + if (!markerList.IsArray()) { + logger::trace("markerList not found, idx:{};", markerIdx); + return; + } + + RE::GFxValue marker{}; + markerList.GetElement(markerIdx, &marker); + if (!marker.IsObject()) { + logger::trace("marker not found: idx:{};", markerIdx); + return; + } + + RE::GFxValue markerName{}; + marker.GetMember("label", &markerName); + + RE::GFxValue createIconType{}; + params.movie->GetVariable(&createIconType, "_global.Map.MapMenu.CREATE_ICONTYPE"); + if (!createIconType.IsNumber()) { + logger::error("CREATE_ICONTYPE not found"); + return; + } + + RE::GFxValue markerType{}; + marker.GetMember("markerType", &markerType); + if (!markerType.IsNumber()) { + logger::error("markerType not found"); + return; + } + + if (markerType.GetNumber() > 64 && markerType.GetNumber() <= 67) { + logger::trace("marker type = {}, ignoring", markerType.GetNumber()); + SelectedItem::getInstance().setMapNone(); + return; + } + + logger::trace("markerIdx:{}; markerName:{}", markerIdx, markerName.GetString()); + SelectedItem::getInstance().setMap(std::string{markerName.GetString()}, markerIdx, static_cast(markerType.GetNumber())); + + if (localMap == 0 || localMap == 1) { + RE::GPtr uiMapMenu = RE::UI::GetSingleton()->GetMenu(RE::MapMenu::MENU_NAME); + RE::BSTArray markers = localMap == 0 ? uiMapMenu->mapMarkers : uiMapMenu->localMapMenu.mapMarkers; + + if (markers.size() > 0 && markerIdx >= 0 && markerIdx < static_cast(markers.size())) { + RE::TESForm* questForm = markers[markerIdx].form; + RE::TESFullName* fn = markers[markerIdx].fullName; + if (questForm && fn && fn->GetFullName() && !std::string{fn->GetFullName()}.contains("<")) { + SelectedItem::getInstance().setMapQuest(fn->GetFullName(), questForm->GetFormID()); + } else if (questForm && markers[markerIdx].customMarker && strlen(markers[markerIdx].customMarker) > 0) { + SelectedItem::getInstance().setMapQuest(markers[markerIdx].customMarker, questForm->GetFormID()); + } + } + } + } + + if (!Config::get().isUpdateBottomBar()) { + return; + } + + RE::GFxValue bottomBar{}; + params.thisPtr->GetMember("_bottomBar", &bottomBar); + if (!bottomBar.IsObject()) { + logger::error("bottomBar NOT found"); + return; + } + + RE::GFxValue buttonPanel{}; + bottomBar.GetMember("buttonPanel", &buttonPanel); + if (!buttonPanel.IsDisplayObject()) { + logger::error("buttonPanel NOT found"); + return; + } + + RE::GFxValue buttons{}; + buttonPanel.GetMember("buttons", &buttons); + if (!buttons.IsArray()) { + logger::error("buttons NOT found"); + return; + } + + bool locationFinderShown = false; + RE::GFxValue locationFinder{}; + params.thisPtr->GetMember("_locationFinder", &locationFinder); + if (locationFinder.IsObject()) { + RE::GFxValue finderShown{}; + locationFinder.GetMember("_bShown", &finderShown); + if (!finderShown.IsBool()) { + logger::error("locationFinder NOT found"); + return; + } + locationFinderShown = finderShown.GetBool(); + } + + for (uint32_t i = 0; i < buttons.GetArraySize(); i++) { + RE::GFxValue btn{}; + buttons.GetElement(i, &btn); + if (btn.IsDisplayObject()) { + RE::GFxValue label{}; + if (!btn.GetMember("label", &label)) { + continue; + } + if (label.IsString() && (label.GetString() == "$Search"sv || label.GetString() == "$Wiki"sv)) { + RE::GFxValue control{}; + if (!btn.GetMember("_keyCodes", &control)) { + continue; + } + if ((unsetMarker || locationFinderShown) && originalSet) { + control.SetArraySize(1); + control.SetElement(0, originalCode); + btn.SetMember("_visible", (locationFinderShown || origVisible)); + btn.SetMember("label", originalLabel.c_str()); + } else { + RE::GFxValue btnVis{}; + btn.GetMember("_visible", &btnVis); + if (!originalSet) { + originalSet = true; + originalLabel = label.GetString(); + if (btnVis.IsBool()) { + origVisible = btnVis.GetBool(); + } + RE::GFxValue origCode{}; + control.GetElement(0, &origCode); + originalCode = origCode.GetUInt(); + } + int k = 0; + if (Config::get().getModCode() > 0) { + control.SetArraySize(2); + control.SetElement(k++, Config::get().getModCode()); + } + control.SetElement(k, Config::get().getKeyCode()); + if (btnVis.IsBool() && !btnVis.GetBool()) { + btn.SetMember("_visible", true); + } + if (label != "$Wiki") { + btn.SetMember("label", "$Wiki"); + } + } + } + } + } + + RE::GFxValue updateButtonArg(RE::GFxValue::ValueType::kBoolean); + updateButtonArg.SetBoolean(true); + buttonPanel.Invoke("updateButtons", &updateButtonArg); + } + +} // namespace wmh diff --git a/src/MapMenuHook.h b/src/MapMenuHook.h new file mode 100644 index 0000000..ef2fd5e --- /dev/null +++ b/src/MapMenuHook.h @@ -0,0 +1,24 @@ +#pragma once + +namespace wmh { + class MapMenuHook { + private: + class MapSetSelectedMarker : public RE::GFxFunctionHandler { + private: + RE::GFxValue origFunction{}; + std::atomic originalSet = false; + std::atomic isLocalMapOpen = false; + bool origVisible = false; + std::string originalLabel{}; + size_t originalCode{}; + + public: + explicit MapSetSelectedMarker(RE::GFxValue& origFunc) + : origFunction(origFunc) {} + void Call(Params& params) override; + }; + + public: + static void installMapMenuHook(RE::GFxMovieView* movieView); + }; +} // namespace wmh \ No newline at end of file diff --git a/src/PCH.h b/src/PCH.h new file mode 100644 index 0000000..8bf2958 --- /dev/null +++ b/src/PCH.h @@ -0,0 +1,157 @@ +#pragma once + +//Standard Library C++20 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define WIN32_LEAN_AND_MEAN +#define NOGDICAPMASKS // CC_*, LC_*, PC_*, CP_*, TC_*, RC_ +#define NOWINSTYLES // WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_* +#define NOSYSMETRICS // SM_* +#define NOMENUS // MF_* +#define NOICONS // IDI_* +#define NOSYSCOMMANDS // SC_* +#define NORASTEROPS // Binary and Tertiary raster ops +#define NOSHOWWINDOW // SW_* +#define OEMRESOURCE // OEM Resource values +#define NOATOM // Atom Manager routines +#define NOCLIPBOARD // Clipboard routines +#define NOCOLOR // Screen colors +#define NODRAWTEXT // DrawText() and DT_* +#define NOGDI // All GDI defines and routines +#define NOMB // MB_* and MessageBox() +#define NOMETAFILE // typedef METAFILEPICT +#define NOMINMAX // Macros min(a,b) and max(a,b) +#define NOSCROLL // SB_* and scrolling routines +#define NOSERVICE // All Service Controller routines, SERVICE_ equates, etc. +#define NOSOUND // Sound driver routines +#define NOTEXTMETRIC // typedef TEXTMETRIC and associated routines +#define NOWINOFFSETS // GWL_*, GCL_*, associated routines +#define NOCOMM // COMM driver routines +#define NOKANJI // Kanji support stuff. +#define NOHELP // Help engine interface. +#define NOPROFILER // Profiler interface. +#define NODEFERWINDOWPOS // DeferWindowPos routines +#define NOMCX // Modem Configuration Extensions + +//spdlog +#include +#include +#include + +#define PLUGIN_LOGPATTERN_DEFAULT "[%b %d %H:%M:%S.%e] [%l] [%t] %v" +#define PLUGIN_LOGPATTERN_DEBUG "[%b %d %H:%M:%S.%e] [%l] [%t] [%s:%#] %v" + +//commonlibsse-ng and skse +#include +#include +#include + +//winapi +#include +#include +#include +#include + +#undef cdecl // Workaround for Clang 14 CMake configure error. + +#define DLLEXPORT __declspec(dllexport) + +using namespace std::literals; +namespace logger = SKSE::log; diff --git a/src/PlayerLocation.cpp b/src/PlayerLocation.cpp new file mode 100644 index 0000000..46081ea --- /dev/null +++ b/src/PlayerLocation.cpp @@ -0,0 +1,156 @@ +#include "PlayerLocation.h" + +namespace wmh { + const float& PlayerLocation::getX() const { + return x; + } + + void PlayerLocation::setX(float newX) { + x = newX; + } + + const float& PlayerLocation::getY() const { + return y; + } + + void PlayerLocation::setY(float newY) { + y = newY; + } + + const float& PlayerLocation::getZ() const { + return z; + } + + void PlayerLocation::setZ(float newZ) { + z = newZ; + } + + const std::string& PlayerLocation::getLocationName() const { + return locationName; + } + + void PlayerLocation::setLocationName(std::string newLocationName) { + locationName = newLocationName; + } + + const std::string& PlayerLocation::getLocationEditorId() const { + return locationEditorId; + } + + void PlayerLocation::setLocationEditorId(std::string newLocationEditorId) { + locationEditorId = newLocationEditorId; + } + + const std::string& PlayerLocation::getWorldName() const { + return worldName; + } + + void PlayerLocation::setWorldName(std::string newWorldName) { + worldName = newWorldName; + } + + const std::string& PlayerLocation::getWorldEditorId() const { + return worldEditorId; + } + + void PlayerLocation::setWorldEditorId(std::string newWorldEditorId) { + worldEditorId = newWorldEditorId; + } + + const std::string& PlayerLocation::getParentWorldName() const { + return parentWorldName; + } + + void PlayerLocation::setParentWorldName(std::string newParentWorldName) { + parentWorldName = newParentWorldName; + } + + const std::string& PlayerLocation::getParentWorldEditorId() const { + return parentWorldEditorId; + } + + void PlayerLocation::setParentWorldEditorId(std::string newParentWorldEditorId) { + parentWorldEditorId = newParentWorldEditorId; + } + + const bool& PlayerLocation::isLocationInterior() const { + return locationInterior; + } + + void PlayerLocation::setLocationInterior(bool newInterior) { + locationInterior = newInterior; + } + + const bool& PlayerLocation::isLocationHasMapData() const { + return locationHasMapData; + } + + void PlayerLocation::setLocationHasMapData(bool b) { + locationHasMapData = b; + } + + void PlayerLocation::reset() { + x = 0.0; + y = 0.0; + z = 0.0; + locationName = ""; + locationEditorId = ""; + worldName = ""; + worldEditorId = ""; + parentWorldName = ""; + parentWorldEditorId = ""; + locationHasMapData = ""; + locationInterior = ""; + } + + bool PlayerLocation::update() { + RE::PlayerCharacter* player = RE::PlayerCharacter::GetSingleton(); + + reset(); + + setX(player->GetPositionX()); + setY(player->GetPositionY()); + setZ(player->GetPositionZ()); + + if (player->GetParentCell() && player->GetParentCell()->IsInteriorCell()) { + logger::debug("interior: true; cell:'{}'; location:'{}';", player->GetParentCell()->GetFullName(), + player->GetCurrentLocation() ? player->GetCurrentLocation()->GetFullName() : ""); + setLocationInterior(true); + if (player->GetParentCell()->GetFullName()) { + setLocationName(player->GetParentCell()->GetFullName()); + } + setLocationEditorId(player->GetParentCell()->GetFormEditorID()); + } else { + logger::debug("interior: false;"); + setLocationInterior(false); + if (player->GetCurrentLocation()) { + if (player->GetCurrentLocation()->GetFullName()) { + setLocationName(player->GetCurrentLocation()->GetFullName()); + } + setLocationEditorId(player->GetCurrentLocation()->GetFormEditorID()); + } + } + + if (player->GetWorldspace()) { + logger::debug("world:'{}'; location:'{}';", player->GetWorldspace()->GetFullName(), getLocationName()); + setWorldName(player->GetWorldspace()->GetFullName()); + setWorldEditorId(player->GetWorldspace()->GetFormEditorID()); + if (player->GetWorldspace()->parentWorld) { + setParentWorldName(player->GetWorldspace()->parentWorld->GetFullName()); + setParentWorldEditorId(player->GetWorldspace()->parentWorld->GetFormEditorID()); + } + + RE::WORLD_MAP_DATA mapData = player->GetWorldspace()->worldMapData; + if (!(mapData.cameraData.initialPitch == 0 && mapData.cameraData.maxHeight == 0 && mapData.cameraData.minHeight && + mapData.nwCellX == 0 && mapData.nwCellY == 0 && mapData.seCellX == 0 && mapData.seCellY == 0 && + mapData.usableHeight == 0 && mapData.usableWidth == 0)) { + setLocationHasMapData(true); + logger::debug("world has map data"); + } + } else if (!isLocationInterior()) { + // if !worldspace, player must be in an interior cell, or something is wrong + return false; + } + return true; + } +} // namespace wmh \ No newline at end of file diff --git a/src/PlayerLocation.h b/src/PlayerLocation.h new file mode 100644 index 0000000..fb30ca3 --- /dev/null +++ b/src/PlayerLocation.h @@ -0,0 +1,46 @@ +#pragma once + +namespace wmh { + class PlayerLocation { + private: + float x = 0.0; + float y = 0.0; + float z = 0.0; + std::string locationName{}; + std::string locationEditorId{}; + std::string worldName{}; + std::string worldEditorId{}; + std::string parentWorldName{}; + std::string parentWorldEditorId{}; + bool locationHasMapData = false; + bool locationInterior = false; + + public: + PlayerLocation() = default; + PlayerLocation(const PlayerLocation&) = delete; + [[nodiscard]] const float& getX() const; + void setX(float newX); + [[nodiscard]] const float& getY() const; + void setY(float newY); + [[nodiscard]] const float& getZ() const; + void setZ(float newZ); + [[nodiscard]] const std::string& getLocationName() const; + void setLocationName(std::string newLocationName); + [[nodiscard]] const std::string& getLocationEditorId() const; + void setLocationEditorId(std::string newLocationEditorId); + [[nodiscard]] const std::string& getWorldName() const; + void setWorldName(std::string newWorldName); + [[nodiscard]] const std::string& getWorldEditorId() const; + void setWorldEditorId(std::string newWorldEditorId); + [[nodiscard]] const std::string& getParentWorldName() const; + void setParentWorldName(std::string newParentWorldName); + [[nodiscard]] const std::string& getParentWorldEditorId() const; + void setParentWorldEditorId(std::string newParentWorldEditorId); + [[nodiscard]] const bool& isLocationInterior() const; + void setLocationInterior(bool interior); + [[nodiscard]] const bool& isLocationHasMapData() const; + void setLocationHasMapData(bool b); + void reset(); + bool update(); + }; +} // namespace wmh \ No newline at end of file diff --git a/src/Plugin.cpp b/src/Plugin.cpp new file mode 100644 index 0000000..593d6a2 --- /dev/null +++ b/src/Plugin.cpp @@ -0,0 +1,65 @@ +using namespace SKSE; +using namespace SKSE::log; +using namespace SKSE::stl; + +#include "Plugin.h" +#include "GameEventHandler.h" + +namespace wmh { + std::optional getLogDirectory() { + using namespace std::filesystem; + PWSTR buf; + SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_DEFAULT, nullptr, &buf); + std::unique_ptr documentsPath{buf, CoTaskMemFree}; + path directory{documentsPath.get()}; + directory.append("My Games"sv); + + if (exists("steam_api64.dll"sv)) { + if (exists("openvr_api.dll") || exists("Data/SkyrimVR.esm")) { + directory.append("Skyrim VR"sv); + } else { + directory.append("Skyrim Special Edition"sv); + } + } else if (exists("Galaxy64.dll"sv)) { + directory.append("Skyrim Special Edition GOG"sv); + } else if (exists("eossdk-win64-shipping.dll"sv)) { + directory.append("Skyrim Special Edition EPIC"sv); + } else { + return current_path().append("skselogs"); + } + return directory.append("SKSE"sv).make_preferred(); + } + + void initializeLogging() { + auto path = getLogDirectory(); + if (!path) { + report_and_fail("Can't find SKSE log directory"); + } + *path /= std::format("{}.log"sv, Plugin::Name); + + std::shared_ptr log; + if (IsDebuggerPresent()) { + log = std::make_shared("Global", std::make_shared()); + } else { + log = std::make_shared("Global", std::make_shared(path->string(), true)); + } + log->set_level(spdlog::level::info); + log->flush_on(spdlog::level::info); + + spdlog::set_default_logger(std::move(log)); + spdlog::set_pattern(PLUGIN_LOGPATTERN_DEFAULT); + } +} // namespace wmh + +using namespace wmh; + +extern "C" DLLEXPORT bool SKSEPlugin_Load(const LoadInterface* skse) { + initializeLogging(); + + logger::info("'{} {}' is loading, game version '{}'...", Plugin::Name, Plugin::VersionString, REL::Module::get().version().string()); + Init(skse); + + GameEventHandler::getInstance().onLoad(); + logger::info("{} has finished loading.", Plugin::Name); + return true; +} \ No newline at end of file diff --git a/src/QuestMenuHook.cpp b/src/QuestMenuHook.cpp new file mode 100644 index 0000000..e4d4d7b --- /dev/null +++ b/src/QuestMenuHook.cpp @@ -0,0 +1,237 @@ +#include "QuestMenuHook.h" +#include "SelectedItem.h" +#include "Config.h" + +namespace wmh { + void QuestMenuHook::installJournalMenuHook(RE::GFxMovieView* movieView) { + SelectedItem::getInstance().reset(); + + RE::GFxValue journalMenu{}; + movieView->GetVariable(&journalMenu, "_global.Quest_Journal.prototype"); + if (!journalMenu.IsObject()) { + return; + } + + RE::GFxValue onTabClickOrig{}; + journalMenu.GetMember("onTabClick", &onTabClickOrig); + if (onTabClickOrig.IsObject()) { + RE::GFxValue onTabClickNew{}; + RE::GPtr funcOnTabClick = RE::make_gptr(onTabClickOrig); + movieView->CreateFunction(&onTabClickNew, funcOnTabClick.get()); + journalMenu.SetMember("onTabClick", onTabClickNew); + } + } + + void QuestMenuHook::installQuestMenuHook(RE::GFxMovieView* movieView) { + SelectedItem::getInstance().reset(); + + RE::GFxValue questsMenu{}; + movieView->GetVariable(&questsMenu, "_global.QuestsPage.prototype"); + if (!questsMenu.IsObject()) { + return; + } + + //on mouse over quest + RE::GFxValue onQuestHighlightOrig{}; + questsMenu.GetMember("onTitleListMouseSelectionChange", &onQuestHighlightOrig); + if (onQuestHighlightOrig.IsObject()) { + RE::GFxValue onQuestHighlightNew{}; + RE::GPtr funcOnQuestHighlight = RE::make_gptr(onQuestHighlightOrig); + movieView->CreateFunction(&onQuestHighlightNew, funcOnQuestHighlight.get()); + questsMenu.SetMember("onTitleListMouseSelectionChange", onQuestHighlightNew); + } + + //on keyboard + RE::GFxValue onTitleMoveDownOrig{}; + questsMenu.GetMember("onTitleListMoveDown", &onTitleMoveDownOrig); + if (onTitleMoveDownOrig.IsObject()) { + RE::GFxValue onTitleMoveDownNew{}; + RE::GPtr funcOnTitleMoveDownNew = RE::make_gptr(onTitleMoveDownOrig); + movieView->CreateFunction(&onTitleMoveDownNew, funcOnTitleMoveDownNew.get()); + questsMenu.SetMember("onTitleListMoveDown", onTitleMoveDownNew); + } + + //on keyboard + RE::GFxValue onTitleMoveUpOrig{}; + questsMenu.GetMember("onTitleListMoveUp", &onTitleMoveUpOrig); + if (onTitleMoveUpOrig.IsObject()) { + RE::GFxValue onTitleMoveUpNew{}; + RE::GPtr funcOnTitleMoveUpNew = RE::make_gptr(onTitleMoveUpOrig); + movieView->CreateFunction(&onTitleMoveUpNew, funcOnTitleMoveUpNew.get()); + questsMenu.SetMember("onTitleListMoveUp", onTitleMoveUpNew); + } + + if (Config::get().isUpdateBottomBar()) { + //set wiki button during tab creation + RE::GFxValue startPageOrig{}; + questsMenu.GetMember("startPage", &startPageOrig); + if (startPageOrig.IsObject()) { + RE::GFxValue startPageNew{}; + RE::GPtr funcOnStartPage = RE::make_gptr(startPageOrig); + movieView->CreateFunction(&startPageNew, funcOnStartPage.get()); + questsMenu.SetMember("startPage", startPageNew); + } + } + } + + void QuestMenuHook::QuestOnTabClick::Call([[maybe_unused]] Params& params) { + if (origFunction.IsObject()) { + logger::trace("calling QuestOnTabClick::origFunction function"); + origFunction.Invoke("call", params.retVal, params.argsWithThisRef, params.argCount + 1); + } + + SelectedItem::getInstance().setQuestNone(); + } + + void QuestMenuHook::QuestStartPage::Call([[maybe_unused]] Params& params) { + if (origFunction.IsObject()) { + logger::trace("calling QuestStartPage::origFunction function"); + origFunction.Invoke("call", params.retVal, params.argsWithThisRef, params.argCount + 1); + } + + RE::GFxValue bottomBar{}; + params.thisPtr->GetMember("_bottomBar", &bottomBar); + if (!bottomBar.IsObject()) { + logger::error("bottomBar NOT found"); + return; + } + + RE::GFxValue buttonPanel{}; + bottomBar.GetMember("buttonPanel", &buttonPanel); + if (!buttonPanel.IsDisplayObject()) { + logger::error("buttonPanel NOT found"); + return; + } + + RE::GFxValue buttons{}; + buttonPanel.GetMember("buttons", &buttons); + if (!buttons.IsArray()) { + logger::error("buttons NOT found"); + return; + } + + // the third button of QuestsPages bottomBar is unused on PC + RE::GFxValue updateButtonArg(RE::GFxValue::ValueType::kBoolean); + updateButtonArg.SetBoolean(true); + RE::GFxValue third{}; + RE::GFxValue labelThird{}; + buttons.GetElement(2, &third); + RE::GFxValue control{}; + if (third.IsObject() && third.GetMember("label", &labelThird) && third.GetMember("_keyCodes", &control) && + labelThird.GetString() == ""sv) { + third.SetMember("_visible", false); + int k = 0; + if (Config::get().getModCode() > 0) { + control.SetArraySize(2); + control.SetElement(k++, Config::get().getModCode()); + } + control.SetElement(k, Config::get().getKeyCode()); + third.SetMember("label", "$Wiki"); + buttonPanel.Invoke("updateButtons", &updateButtonArg); + } + } + + void QuestMenuHook::QuestOnSelectedId::Call([[maybe_unused]] Params& params) { + if (origFunction.IsObject()) { + logger::trace("calling QuestOnSelectedId::origFunction function"); + origFunction.Invoke("call", params.retVal, params.argsWithThisRef, params.argCount + 1); + } + + if (params.argCount == 0 || !params.args[0].IsObject()) { + logger::info("QuestOnSelectedId: invalid argument"); + SelectedItem::getInstance().setQuestNone(); + return; + } + + RE::GFxValue event = params.args[0]; + RE::GFxValue eventIndex{}; + + bool isQuestHighLight = false; + bool isValidQuest = false; + if (event.GetMember("index", &eventIndex) && eventIndex.IsNumber() && eventIndex.GetNumber() >= 0) { + logger::trace("eventIndex: {}", eventIndex.GetNumber()); + isQuestHighLight = true; + } else { + SelectedItem::getInstance().setQuestNone(); + } + + RE::GFxValue titleList{}; + params.thisPtr->GetMember("TitleList", &titleList); + if (!titleList.IsObject()) { + logger::error("titleList not found"); + return; + } + + RE::GFxValue selectedEntry{}; + titleList.GetMember("selectedEntry", &selectedEntry); + if (!selectedEntry.IsObject()) { + logger::error("selectedEntry not found"); + return; + } + + RE::GFxValue questName{}; + selectedEntry.GetMember("text", &questName); + if (!questName.IsString()) { + logger::error("formId not found"); + return; + } + + RE::GFxValue formId{}; + selectedEntry.GetMember("formID", &formId); + if (!formId.IsObject() && !formId.IsNumber()) { + logger::error("formId not found"); + return; + } + + if (formId.GetSInt() >= 0) { + SelectedItem::getInstance().setQuest(questName.GetString(), static_cast(formId.GetSInt())); + } + + if (formId.GetSInt() > 0) { + isValidQuest = true; + } + + if (!Config::get().isUpdateBottomBar()) { + return; + } + + RE::GFxValue bottomBar{}; + params.thisPtr->GetMember("_bottomBar", &bottomBar); + if (!bottomBar.IsObject()) { + logger::error("bottomBar NOT found"); + return; + } + + RE::GFxValue buttonPanel{}; + bottomBar.GetMember("buttonPanel", &buttonPanel); + if (!buttonPanel.IsDisplayObject()) { + logger::error("buttonPanel NOT found"); + return; + } + + RE::GFxValue buttons{}; + buttonPanel.GetMember("buttons", &buttons); + if (!buttons.IsArray()) { + logger::error("buttons NOT found"); + return; + } + + for (uint32_t i = 0; i < buttons.GetArraySize(); i++) { + RE::GFxValue btn{}; + RE::GFxValue label{}; + buttons.GetElement(i, &btn); + if (btn.IsObject() && btn.GetMember("label", &label)) { + if (label.GetString() == "$Toggle Active"sv || label.GetString() == "$Show on Map"sv) { + btn.SetMember("_visible", true); + } else if (label.GetString() == "$Wiki"sv) { + btn.SetMember("_visible", isValidQuest); + } + } + } + + RE::GFxValue updateButtonArg(RE::GFxValue::ValueType::kBoolean); + updateButtonArg.SetBoolean(true); + buttonPanel.Invoke("updateButtons", &updateButtonArg); + } + +} // namespace wmh diff --git a/src/QuestMenuHook.h b/src/QuestMenuHook.h new file mode 100644 index 0000000..886734f --- /dev/null +++ b/src/QuestMenuHook.h @@ -0,0 +1,40 @@ +#pragma once + +namespace wmh { + class QuestMenuHook { + private: + class QuestOnSelectedId : public RE::GFxFunctionHandler { + private: + RE::GFxValue origFunction{}; + + public: + explicit QuestOnSelectedId(RE::GFxValue& aOldFunc) + : origFunction(aOldFunc) {} + void Call(Params& a_params) override; + }; + + class QuestOnTabClick : public RE::GFxFunctionHandler { + private: + RE::GFxValue origFunction{}; + + public: + explicit QuestOnTabClick(RE::GFxValue& aOldFunc) + : origFunction(aOldFunc) {} + void Call(Params& a_params) override; + }; + + class QuestStartPage : public RE::GFxFunctionHandler { + private: + RE::GFxValue origFunction{}; + + public: + explicit QuestStartPage(RE::GFxValue& aOldFunc) + : origFunction(aOldFunc) {} + void Call(Params& a_params) override; + }; + + public: + static void installJournalMenuHook(RE::GFxMovieView* movieView); + static void installQuestMenuHook(RE::GFxMovieView* movieView); + }; +} // namespace wmh \ No newline at end of file diff --git a/src/SelectedItem.cpp b/src/SelectedItem.cpp new file mode 100644 index 0000000..f4b179c --- /dev/null +++ b/src/SelectedItem.cpp @@ -0,0 +1,76 @@ +#include "SelectedItem.h" + +namespace wmh { + void SelectedItem::setMap(std::string aLabel, int aIdx, int aType) { + label = aLabel; + idx = aIdx; + type = aType; + mapQuestId = 0; + mapQuestLabel = ""; + logger::trace("SelectedItem::setMap {}", aLabel); + } + + void SelectedItem::setMapNone() { + label = ""; + idx = -1; + type = -1; + mapQuestId = 0; + mapQuestLabel = ""; + logger::trace("SelectedItem::setMapNone"); + } + + std::string SelectedItem::getMapLabel() { + return label; + } + + int SelectedItem::getMapIndex() { + return idx; + } + + int SelectedItem::getMapType() { + return type; + } + + uint32_t SelectedItem::getMapQuestId() { + return mapQuestId; + } + + std::string SelectedItem::getMapQuestLabel() { + return mapQuestLabel; + } + + std::string SelectedItem::toString() { + return std::format("[label:'{}'; idx:'{}'; type:'{}'; mapQuestId:'{}'; mapQuestLabel:'{}'; questId:'{}'; questName:'{}']", label, + idx, type, mapQuestId, mapQuestLabel, questId, questName); + } + + void SelectedItem::setMapQuest(std::string questLabel, uint32_t id) { + mapQuestId = id; + mapQuestLabel = questLabel; + logger::trace("SelectedItem::setMapQuest {}", questLabel); + } + + uint32_t SelectedItem::getQuestId() { + return questId; + } + + std::string SelectedItem::getQuestName() { + return questName; + } + + void SelectedItem::setQuest(std::string name, uint32_t id) { + questName = name; + questId = id; + logger::trace("SelectedItem::setQuestId {}", id); + } + + void SelectedItem::setQuestNone() { + questName = ""; + questId = 0; + } + + void SelectedItem::reset() { + setMapNone(); + setQuest("", 0); + } +} // namespace wmh \ No newline at end of file diff --git a/src/SelectedItem.h b/src/SelectedItem.h new file mode 100644 index 0000000..d821765 --- /dev/null +++ b/src/SelectedItem.h @@ -0,0 +1,39 @@ +#pragma once + +namespace wmh { + class SelectedItem { + private: + SelectedItem() = default; + SelectedItem(SelectedItem&) = delete; + SelectedItem& operator=(SelectedItem&&) = delete; + void operator=(SelectedItem&) = delete; + std::string label{}; + int idx = -1; + int type = -1; + uint32_t questId = 0; + std::string questName{}; + uint32_t mapQuestId = 0; + std::string mapQuestLabel{}; + + public: + [[nodiscard]] static SelectedItem& getInstance() { + static SelectedItem instance; + return instance; + } + + void setMap(std::string aLabel, int aIdx, int aType); + void setMapNone(); + void reset(); + void setQuest(std::string name, uint32_t id); + void setQuestNone(); + [[nodiscard]] uint32_t getQuestId(); + [[nodiscard]] std::string getQuestName(); + [[nodiscard]] std::string getMapLabel(); + [[nodiscard]] int getMapIndex(); + [[nodiscard]] int getMapType(); + void setMapQuest(std::string label, uint32_t id); + [[nodiscard]] uint32_t getMapQuestId(); + [[nodiscard]] std::string getMapQuestLabel(); + [[nodiscard]] std::string toString(); + }; +} // namespace wmh \ No newline at end of file diff --git a/src/SkseMessagingListener.h b/src/SkseMessagingListener.h new file mode 100644 index 0000000..0c5528c --- /dev/null +++ b/src/SkseMessagingListener.h @@ -0,0 +1,104 @@ + +/* +MIT License + +Copyright (c) 2023 Emerson Pinter + +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. + */ + +template +class SkseMessagingListener { + protected: + SkseMessagingListener() = default; + + private: + SkseMessagingListener(SkseMessagingListener&) = delete; + SkseMessagingListener& operator=(SkseMessagingListener&&) = delete; + void operator=(SkseMessagingListener&) = delete; + + public: + ~SkseMessagingListener() = default; + + // This plugin is finishing load. + virtual void onLoad(){}; + + // All plugins have finished running SKSEPlugin_Load. + virtual void onPostLoad(){}; + + // All kPostLoad message handlers have run. + virtual void onPostPostLoad(){}; + + // All game data has been found. + virtual void onInputLoaded(){}; + + // All ESM/ESL/ESP plugins have loaded, main menu is now active. + virtual void onDataLoaded(){}; + + // Player starts a new game from main menu. + virtual void onNewGame(){}; + + // Player selected a game to load, but it hasn't loaded yet. + virtual void onPreLoadGame(){}; + + // Player selected save game has finished loading. + virtual void onPostLoadGame(){}; + + // Player has saved a game. + virtual void onSaveGame(){}; + + // Player deleted a saved game from within the load menu. + virtual void onDeleteGame(){}; + + auto registerListener() { + if (!SKSE::GetMessagingInterface()->RegisterListener([](SKSE::MessagingInterface::Message* message) { + switch (message->type) { + case SKSE::MessagingInterface::kPostLoad: + T::getInstance().onPostLoad(); + break; + case SKSE::MessagingInterface::kPostPostLoad: + T::getInstance().onPostPostLoad(); + break; + case SKSE::MessagingInterface::kInputLoaded: + T::getInstance().onInputLoaded(); + break; + case SKSE::MessagingInterface::kDataLoaded: + T::getInstance().onDataLoaded(); + break; + case SKSE::MessagingInterface::kNewGame: + T::getInstance().onNewGame(); + break; + case SKSE::MessagingInterface::kPreLoadGame: + T::getInstance().onPreLoadGame(); + break; + case SKSE::MessagingInterface::kPostLoadGame: + T::getInstance().onPostLoadGame(); + break; + case SKSE::MessagingInterface::kSaveGame: + T::getInstance().onSaveGame(); + break; + case SKSE::MessagingInterface::kDeleteGame: + T::getInstance().onDeleteGame(); + break; + } + })) { + SKSE::stl::report_and_fail("Unable to register message listener."); + } + } +}; diff --git a/src/SteamApi.h b/src/SteamApi.h new file mode 100644 index 0000000..eb25a5e --- /dev/null +++ b/src/SteamApi.h @@ -0,0 +1,160 @@ +#pragma once + +namespace fsteam { + class SteamApi { + private: + static constexpr const char *SKYRIM_640_STEAMFRIENDS_INTERFACE_VERSION = "SteamFriends015"; + static constexpr const char *SKYRIM_640_STEAMUTILS_INTERFACE_VERSION = "SteamUtils007"; + static constexpr const char *LATEST_STEAMFRIENDS_INTERFACE_VERSION = "SteamFriends017"; + static constexpr const char *LATEST_STEAMUTILS_INTERFACE_VERSION = "SteamUtils010"; + static constexpr const char *STEAMAPI_DLL = "steam_api64.dll"; + + template + T getPtr(std::string function) { + return reinterpret_cast(GetProcAddress(GetModuleHandle(STEAMAPI_DLL), function.c_str())); + } + + using ISteamClient = uintptr_t; + using ISteamUtils = uintptr_t; + using ISteamFriends = uintptr_t; + using HSteamPipe = uint32_t; + using HSteamUser = uint32_t; + using FuncSteamClient = std::add_pointer::type; + using FuncGetHSteamPipe = std::add_pointer::type; + using FuncGetHSteamUser = std::add_pointer::type; + using FuncGetISteamFriends = std::add_pointer::type; + using FuncGetISteamUtils = std::add_pointer::type; + using FuncActivateGameOverlayToWebPage = std::add_pointer::type; + using FuncIsOverlayEnabled = std::add_pointer::type; + using FuncSetRichPresence = std::add_pointer::type; + + FuncSteamClient SteamAPI_SteamClient = getPtr("SteamClient"); + FuncGetHSteamPipe SteamAPI_GetHSteamPipe = getPtr("GetHSteamPipe"); + FuncGetHSteamUser SteamAPI_GetHSteamUser = getPtr("GetHSteamUser"); + FuncGetISteamFriends SteamAPI_ISteamClient_GetISteamFriends = + getPtr("SteamAPI_ISteamClient_GetISteamFriends"); + FuncGetISteamUtils SteamAPI_ISteamClient_GetISteamUtils = getPtr("SteamAPI_ISteamClient_GetISteamUtils"); + FuncActivateGameOverlayToWebPage SteamAPI_ISteamFriends_ActivateGameOverlayToWebPage = + getPtr("SteamAPI_ISteamFriends_ActivateGameOverlayToWebPage"); + FuncIsOverlayEnabled SteamAPI_ISteamUtils_IsOverlayEnabled = + getPtr("SteamAPI_ISteamUtils_IsOverlayEnabled"); + FuncSetRichPresence SteamAPI_ISteamFriends_SetRichPresence = + getPtr("SteamAPI_ISteamFriends_SetRichPresence"); + + // when false, use older api version + bool useLatestApi = true; + + public: + SteamApi() = default; + SteamApi(bool b) + : useLatestApi(b){}; + + enum OverlayWebPageMode { // ignored on SteamFriends015 + OverlayWebPageMode_Default = 0, + OverlayWebPageMode_Modal = 1 //buggy since steam user interface update 2023, window don't close + }; + + [[maybe_unused]] inline bool isSteamApiLoaded() { + return (GetModuleHandle(STEAMAPI_DLL) != NULL); + } + + [[nodiscard]] inline const bool isUseLatestApi() { + return useLatestApi; + } + + inline void setUseLatestApi(bool b) { + useLatestApi = b; + } + + [[maybe_unused]] inline bool isSteamOverlayEnabled() { + if (!isSteamApiLoaded()) { + return false; + } + ISteamClient steamClient = SteamAPI_SteamClient(); + HSteamPipe steamPipe = SteamAPI_GetHSteamPipe(); + + if (!steamClient || !steamPipe) { + return false; + } + + ISteamUtils steamUtils = SteamAPI_ISteamClient_GetISteamUtils(steamClient, steamPipe, LATEST_STEAMUTILS_INTERFACE_VERSION); + if (!steamUtils) { + return false; + } + + return SteamAPI_ISteamUtils_IsOverlayEnabled(steamUtils); + } + + [[maybe_unused]] inline ISteamFriends getSteamFriends(ISteamClient client, HSteamUser user, HSteamPipe pipe) { + std::string apiVersion = LATEST_STEAMFRIENDS_INTERFACE_VERSION; + + if (!useLatestApi) { + apiVersion = SKYRIM_640_STEAMFRIENDS_INTERFACE_VERSION; + } + + return SteamAPI_ISteamClient_GetISteamFriends(client, user, pipe, apiVersion.c_str()); + } + + [[maybe_unused]] inline ISteamFriends getSteamFriends() { + std::string apiVersion = LATEST_STEAMFRIENDS_INTERFACE_VERSION; + + if (!useLatestApi) { + apiVersion = SKYRIM_640_STEAMFRIENDS_INTERFACE_VERSION; + } + + ISteamClient steamClient = SteamAPI_SteamClient(); + HSteamPipe steamPipe = SteamAPI_GetHSteamPipe(); + HSteamUser steamUser = SteamAPI_GetHSteamUser(); + if (!steamClient || !steamPipe || !steamUser) { + logger::error("can't get SteamClient instance"); + return 0; + } + + return SteamAPI_ISteamClient_GetISteamFriends(steamClient, steamUser, steamPipe, apiVersion.c_str()); + } + + [[maybe_unused]] inline ISteamUtils getSteamUtils(ISteamClient client, HSteamPipe pipe) { + std::string apiVersion = LATEST_STEAMUTILS_INTERFACE_VERSION; + + if (!useLatestApi) { + apiVersion = SKYRIM_640_STEAMUTILS_INTERFACE_VERSION; + } + + return SteamAPI_ISteamClient_GetISteamUtils(client, pipe, apiVersion.c_str()); + } + + [[maybe_unused]] [[nodiscard]] inline void openUrlOnSteamOverlay(std::string url, bool modal) { + openUrlOnSteamOverlay(url, modal ? OverlayWebPageMode_Modal : OverlayWebPageMode_Default); + } + + [[maybe_unused]] [[nodiscard]] inline void openUrlOnSteamOverlay(std::string url, + OverlayWebPageMode modal = OverlayWebPageMode_Default) { + if (url.empty() || !isSteamApiLoaded()) { + return; + } + + ISteamClient steamClient = SteamAPI_SteamClient(); + HSteamPipe steamPipe = SteamAPI_GetHSteamPipe(); + + HSteamUser steamUser = SteamAPI_GetHSteamUser(); + if (!steamClient || !steamPipe || !steamUser) { + logger::error("can't get SteamClient instance"); + return; + } + + ISteamUtils steamUtils = getSteamUtils(steamClient, steamPipe); + if (!steamUtils || !(SteamAPI_ISteamUtils_IsOverlayEnabled(steamUtils))) { + logger::error("can't get ISteamUtils instance"); + return; + } + + ISteamFriends steamFriends = getSteamFriends(steamClient, steamUser, steamPipe); + if (steamFriends) { + SteamAPI_ISteamFriends_ActivateGameOverlayToWebPage(steamFriends, url.c_str(), modal); + } else { + logger::error("can't get ISteamFriends instance"); + } + } + }; + +} // namespace fsteam diff --git a/src/UrlProvider.cpp b/src/UrlProvider.cpp new file mode 100644 index 0000000..586542a --- /dev/null +++ b/src/UrlProvider.cpp @@ -0,0 +1,251 @@ +#include "UrlProvider.h" + +#include +#include +#include +#include + +#include "Config.h" +#include "SteamApi.h" +#include "SelectedItem.h" + +namespace wmh { + std::function UrlProvider::inputHandler() { + return [this]() { + using namespace fsteam; + + if (!playerLocation.update()) { + logger::error("unable to update player location"); + return; + } + + std::string url{}; + + if (RE::UI::GetSingleton()->IsMenuOpen(RE::MapMenu::MENU_NAME) && !RE::UI::GetSingleton()->IsMenuOpen(RE::Console::MENU_NAME) && + !RE::UI::GetSingleton()->IsMenuOpen(RE::JournalMenu::MENU_NAME)) { + try { + logger::debug("SelectedItem: {}", SelectedItem::getInstance().toString()); + if (SelectedItem::getInstance().getMapIndex() >= 0 && !SelectedItem::getInstance().getMapLabel().empty() && + SelectedItem::getInstance().getMapQuestId() <= 0) { + url = buildLocationUrl(SelectedItem::getInstance().getMapLabel()); + } else if (SelectedItem::getInstance().getMapQuestId() > 0) { + RE::TESQuest* quest = RE::TESForm::LookupByID(SelectedItem::getInstance().getMapQuestId()); + if (quest) { + logger::debug("quest selected: '{}' ({})", quest->GetFullName(), quest->GetFormEditorID()); + if (quest && std::string{quest->GetFullName()}.contains("<")) { + url = buildQuestUrl(SelectedItem::getInstance().getMapQuestLabel(), quest->GetFormEditorID()); + } else if (quest) { + url = buildQuestUrl(quest->GetFullName(), quest->GetFormEditorID()); + } + } else { + url = buildLocationUrl(); + } + } else { + url = buildLocationUrl(); + } + + if (url.empty()) { + return; + } + } catch (const std::exception& e) { + logger::error("Exception building map url: '{}'", e.what()); + return; + } catch (...) { + logger::error("Unknown error while building map url"); + return; + } + } else if (RE::UI::GetSingleton()->IsMenuOpen(RE::JournalMenu::MENU_NAME)) { + try { + if (SelectedItem::getInstance().getQuestId() > 0) { + RE::TESQuest* quest = RE::TESForm::LookupByID(SelectedItem::getInstance().getQuestId()); + if (quest && std::string{quest->GetFullName()}.contains("<")) { + url = buildQuestUrl(SelectedItem::getInstance().getQuestName(), quest->GetFormEditorID()); + } else if (quest) { + url = buildQuestUrl(quest->GetFullName(), quest->GetFormEditorID()); + } + } + if (url.empty()) { + return; + } + } catch (const std::exception& e) { + logger::error("Exception building quest url: '{}'", e.what()); + return; + } catch (...) { + logger::error("Unknown error while building quest url"); + return; + } + } else { + return; + } + + SteamApi api{}; + + if (Config::get().isEnableSteam() && api.isSteamOverlayEnabled()) { + api.openUrlOnSteamOverlay(url, Config::get().isUseSteamModal()); + } else { + logger::info("opening url using shell: '{}'", url); + ShellExecute(0, "open", url.c_str(), 0, 0, 3); + } + }; + } + + const std::string UrlProvider::buildQuestUrl(std::string name, std::string editorId) { + std::string templateQuest{Config::get().getUrlQuest()}; + std::string encodedQuest{}; + std::string encodedQuestId{}; + + try { + encodedQuest = boost::urls::encode(name, boost::urls::grammar::alnum_chars); + encodedQuestId = boost::urls::encode(editorId, boost::urls::grammar::alnum_chars); + logger::debug("encodedQuest: '{}'", encodedQuest); + boost::algorithm::replace_all(templateQuest, "%Q", encodedQuest); + boost::algorithm::replace_all(templateQuest, "%I", encodedQuestId); + logger::debug("building url quest: '{}'", templateQuest); + return validateUrl(boost::url{boost::url_view{templateQuest}}.c_str()); + } catch (const std::exception& e) { + logger::error("Exception building quest url: '{}'", e.what()); + return std::string{}; + } catch (const boost::exception& e) { + logger::error("Exception building quest url: '{}';", boost::diagnostic_information(e)); + return std::string{}; + } catch (...) { + logger::error("Unknown error while building quest url"); + return std::string{}; + } + } + + const std::string UrlProvider::buildLocationUrl(std::string locationName) { + std::string templateLocation{Config::get().getUrlSelected()}; + std::string encodedLocation{}; + + try { + encodedLocation = boost::urls::encode(locationName, boost::urls::grammar::alnum_chars); + logger::debug("encodedLocation: '{}'", encodedLocation); + boost::algorithm::replace_all(templateLocation, "%L", encodedLocation); + logger::debug("building url for selected location: '{}'", templateLocation); + return validateUrl(boost::url{boost::url_view{templateLocation}}.c_str()); + } catch (const std::exception& e) { + logger::error("Exception building selected url: '{}'", e.what()); + return std::string{}; + } catch (const boost::exception& e) { + logger::error("Exception building selected url: '{}';", boost::diagnostic_information(e)); + return std::string{}; + } catch (...) { + logger::error("Unknown error while building selected url"); + return std::string{}; + } + } + + const std::string UrlProvider::buildLocationUrl() { + std::string url{}; + + std::string templateLocation{Config::get().getUrlInterior()}; + std::string templateWorld{}; + + bool worldWithoutMapConfig = false; + + auto worldUrlMap = Config::get().getMapUrlWorld(); + if (auto search = worldUrlMap.find(playerLocation.getWorldEditorId()); search != worldUrlMap.end()) { + templateWorld = search->second; + } else if (auto searchParent = worldUrlMap.find(playerLocation.getParentWorldEditorId()); searchParent != worldUrlMap.end()) { + templateWorld = searchParent->second; + } else if (!playerLocation.isLocationInterior()) { + worldWithoutMapConfig = true; + } + + logger::debug("templateWorld: '{}'", templateWorld); + + bool worldWithoutMap = (!playerLocation.isLocationInterior() && worldWithoutMapConfig && + playerLocation.getParentWorldEditorId().empty() && playerLocation.isLocationHasMapData()) || + (!playerLocation.isLocationInterior() && worldWithoutMapConfig && + !playerLocation.getParentWorldEditorId().empty() && !playerLocation.isLocationHasMapData()); + + if (playerLocation.isLocationInterior() || worldWithoutMap) { + url = buildInteriorUrl(templateLocation); + } else { + url = buildExteriorUrl(templateWorld); + } + + logger::debug("url:'{}'; isInterior:'{}'; world:'{}'; location:'{}'; x:'{}'; y:'{}'; z:'{}';", url, + playerLocation.isLocationInterior(), playerLocation.getWorldName(), playerLocation.getLocationName(), + playerLocation.getX(), playerLocation.getY(), playerLocation.getZ()); + return validateUrl(url); + } + + std::string UrlProvider::buildInteriorUrl(std::string templateLocation) { + using namespace boost::algorithm; + std::string encodedLocation{}; + + try { + replace_all(templateLocation, "%X", std::to_string(static_cast(playerLocation.getX()))); + replace_all(templateLocation, "%Y", std::to_string(static_cast(playerLocation.getY()))); + replace_all(templateLocation, "%Z", std::to_string(static_cast(playerLocation.getZ()))); + replace_all(templateLocation, "%I", playerLocation.getLocationEditorId()); + encodedLocation = boost::urls::encode(playerLocation.getLocationName(), boost::urls::grammar::alnum_chars); + logger::debug("encodedLocation: '{}'", encodedLocation); + replace_all(templateLocation, "%L", encodedLocation); + logger::debug("building url for interior: '{}'", templateLocation); + return std::string{boost::url{boost::url_view{templateLocation}}.c_str()}; + } catch (const std::exception& e) { + logger::error("Exception building interior url: '{}'", e.what()); + return std::string{}; + } catch (const boost::exception& e) { + logger::error("Exception building interior url: '{}';", boost::diagnostic_information(e)); + return std::string{}; + } catch (...) { + logger::error("Unknown error while building interior url"); + return std::string{}; + } + } + + std::string UrlProvider::buildExteriorUrl(std::string templateWorld) { + using namespace boost::algorithm; + std::string encodedWorldName{}; + std::string encodedLocation{}; + + try { + replace_all(templateWorld, "%X", std::to_string(static_cast(playerLocation.getX()))); + replace_all(templateWorld, "%Y", std::to_string(static_cast(playerLocation.getY()))); + replace_all(templateWorld, "%Z", std::to_string(static_cast(playerLocation.getZ()))); + replace_all(templateWorld, "%I", playerLocation.getWorldEditorId()); + encodedLocation = boost::urls::encode(playerLocation.getLocationName(), boost::urls::grammar::alnum_chars); + encodedWorldName = boost::urls::encode(playerLocation.getWorldName(), boost::urls::grammar::alnum_chars); + logger::debug("encodedLocation: '{}'", encodedLocation); + logger::debug("encodedWorldName: '{}'", encodedWorldName); + replace_all(templateWorld, "%W", encodedWorldName); + replace_all(templateWorld, "%L", encodedLocation); + logger::debug("building url for exterior: '{}'", templateWorld); + return std::string{boost::url{boost::url_view{templateWorld}}.c_str()}; + } catch (const std::exception& e) { + logger::error("Exception building exterior url: '{}'", e.what()); + return std::string{}; + } catch (const boost::exception& e) { + logger::error("Exception building exterior url: '{}';", boost::diagnostic_information(e)); + return std::string{}; + } catch (...) { + logger::error("Unknown error while building exterior url"); + return std::string{}; + } + } + + std::string UrlProvider::validateUrl(std::string url) { + try { + if (url.empty() || + (!boost::algorithm::istarts_with(url.c_str(), "http:") && !boost::algorithm::istarts_with(url.c_str(), "https:"))) { + logger::error("Invalid url: '{}'", url.c_str()); + return std::string{}; + } + } catch (const std::exception& e) { + logger::error("Exception validating url: '{}'", e.what()); + return std::string{}; + } catch (const boost::exception& e) { + logger::error("Exception validating url: '{}';", boost::diagnostic_information(e)); + return std::string{}; + } catch (...) { + logger::error("Unknown error while validating url"); + return std::string{}; + } + + return url; + } +} // namespace wmh \ No newline at end of file diff --git a/src/UrlProvider.h b/src/UrlProvider.h new file mode 100644 index 0000000..7d36fcd --- /dev/null +++ b/src/UrlProvider.h @@ -0,0 +1,23 @@ +#pragma once +#include "PlayerLocation.h" + +namespace wmh { + class UrlProvider { + private: + UrlProvider(UrlProvider&) = delete; + UrlProvider& operator=(UrlProvider&&) = delete; + void operator=(UrlProvider&) = delete; + + PlayerLocation playerLocation{}; + [[nodiscard]] std::string buildInteriorUrl(std::string templateLocation); + [[nodiscard]] std::string buildExteriorUrl(std::string templateWorld); + [[nodiscard]] const std::string buildLocationUrl(); + [[nodiscard]] const std::string buildLocationUrl(std::string locationName); + [[nodiscard]] const std::string buildQuestUrl(std::string name, std::string editorId); + [[nodiscard]] std::string validateUrl(std::string url); + + public: + UrlProvider() = default; + std::function inputHandler(); + }; +} // namespace wmh \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..686556c --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", + "name": "wiki-map", + "version-string": "1.0.0", + "description": "Wiki & Map Integration", + "homepage": "https://github.com/epinter/wikimap", + "license": "LGPL-3.0-or-later", + "features": { + "plugin": { + "description": "SKSE plugin", + "dependencies": [ + "commonlibsse-ng", + "spdlog", + "simpleini", + "boost-url", + "boost-algorithm" + ] + } + }, + "default-features": [ + "plugin" + ], + "builtin-baseline": "a4275b7eee79fb24ec2e135481ef5fce8b41c339" +} \ No newline at end of file