From 135247c162ae718e15c349c8362db00e0535100b Mon Sep 17 00:00:00 2001 From: Li Zhenhuan Date: Tue, 16 Mar 2021 01:04:20 +0800 Subject: [PATCH] Add hotkey for options --- .github/resources/config.env | 4 +- CHANGELOG.md | 5 ++ .../GUI/Prefabs/CinematicCameraMenuView.xml | 12 ++-- .../Languages/CNs/CinematicCamera-zho-CN.xml | 19 ++++++ .../Languages/std_CinematicCamera.xml | 20 ++++++ .../ModuleData/module_strings.xml | 19 ++++++ .../Modules/CinematicCamera/SubModule.xml | 10 +-- .../src/CinematicCameraSubModule.cs | 6 +- .../CinematicCameraOptionClassFactory.cs | 3 +- .../HotKey/CinematicCameraHotkeyCategory.cs | 62 ++++++++++++++++--- .../src/Config/HotKey/GameKeyConfig.cs | 2 +- .../CinematicCameraMenuView.cs | 2 +- .../MissionBehaviors/SetPlayerHealthLogic.cs | 56 ++++++++++++++++- .../ViewModel/CinematicCameraMenuVM.cs | 2 +- .../src/MissionStartingHandler.cs | 3 +- source/library/mission-library | 2 +- 16 files changed, 196 insertions(+), 31 deletions(-) diff --git a/.github/resources/config.env b/.github/resources/config.env index b0e1366..26a77a5 100644 --- a/.github/resources/config.env +++ b/.github/resources/config.env @@ -1,3 +1,3 @@ -GAME_VERSION=e1.5.8 -GAME_BRANCH=master +GAME_VERSION=e1.5.9 +GAME_BRANCH=beta MOD_VERSION=e1.0.6 diff --git a/CHANGELOG.md b/CHANGELOG.md index f4987b9..262f9e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog + +## [e1.0.6] - 2020-03-16 +### Added +- Add hot key for options. + ## [e1.0.3] - 2020-10-19 ### Fixed - Keep compatible with RTS Camera. diff --git a/source/CinematicCamera/Modules/CinematicCamera/GUI/Prefabs/CinematicCameraMenuView.xml b/source/CinematicCamera/Modules/CinematicCamera/GUI/Prefabs/CinematicCameraMenuView.xml index dcea12f..c0a13c6 100644 --- a/source/CinematicCamera/Modules/CinematicCamera/GUI/Prefabs/CinematicCameraMenuView.xml +++ b/source/CinematicCamera/Modules/CinematicCamera/GUI/Prefabs/CinematicCameraMenuView.xml @@ -46,7 +46,7 @@ - + @@ -132,7 +132,7 @@ - + @@ -166,7 +166,7 @@ - + @@ -197,7 +197,7 @@ - + @@ -219,7 +219,7 @@ - + @@ -240,7 +240,7 @@ - + diff --git a/source/CinematicCamera/Modules/CinematicCamera/ModuleData/Languages/CNs/CinematicCamera-zho-CN.xml b/source/CinematicCamera/Modules/CinematicCamera/ModuleData/Languages/CNs/CinematicCamera-zho-CN.xml index 71d89ec..dcde453 100644 --- a/source/CinematicCamera/Modules/CinematicCamera/ModuleData/Languages/CNs/CinematicCamera-zho-CN.xml +++ b/source/CinematicCamera/Modules/CinematicCamera/ModuleData/Languages/CNs/CinematicCamera-zho-CN.xml @@ -19,5 +19,24 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/CinematicCamera/Modules/CinematicCamera/ModuleData/Languages/std_CinematicCamera.xml b/source/CinematicCamera/Modules/CinematicCamera/ModuleData/Languages/std_CinematicCamera.xml index f460e23..da02a54 100644 --- a/source/CinematicCamera/Modules/CinematicCamera/ModuleData/Languages/std_CinematicCamera.xml +++ b/source/CinematicCamera/Modules/CinematicCamera/ModuleData/Languages/std_CinematicCamera.xml @@ -20,5 +20,25 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/CinematicCamera/Modules/CinematicCamera/ModuleData/module_strings.xml b/source/CinematicCamera/Modules/CinematicCamera/ModuleData/module_strings.xml index a4bd5a1..d244786 100644 --- a/source/CinematicCamera/Modules/CinematicCamera/ModuleData/module_strings.xml +++ b/source/CinematicCamera/Modules/CinematicCamera/ModuleData/module_strings.xml @@ -16,5 +16,24 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/CinematicCamera/Modules/CinematicCamera/SubModule.xml b/source/CinematicCamera/Modules/CinematicCamera/SubModule.xml index 4d88fcb..83e795f 100644 --- a/source/CinematicCamera/Modules/CinematicCamera/SubModule.xml +++ b/source/CinematicCamera/Modules/CinematicCamera/SubModule.xml @@ -6,11 +6,11 @@ - - - - - + + + + + diff --git a/source/CinematicCamera/src/CinematicCameraSubModule.cs b/source/CinematicCamera/src/CinematicCameraSubModule.cs index dbf89c3..f72884b 100644 --- a/source/CinematicCamera/src/CinematicCameraSubModule.cs +++ b/source/CinematicCamera/src/CinematicCameraSubModule.cs @@ -1,4 +1,5 @@ -using MissionLibrary; +using CinematicCamera.Config.HotKey; +using MissionLibrary; using MissionLibrary.Controller; using MissionLibrary.View; using MissionSharedLibrary; @@ -46,7 +47,8 @@ private bool SecondInitialize() { if (!Initializer.SecondInitialize()) return false; - + + CinematicCameraGameKeyCategory.RegisterGameKeyCategory(); Global.GetProvider().AddHandler(new MissionStartingHandler()); var menuClassCollection = AMenuManager.Get().MenuClassCollection; menuClassCollection.AddOptionClass(CinematicCameraOptionClassFactory.CreateOptionClassProvider(menuClassCollection)); diff --git a/source/CinematicCamera/src/Config/CinematicCameraOptionClassFactory.cs b/source/CinematicCamera/src/Config/CinematicCameraOptionClassFactory.cs index 5847f98..24813d6 100644 --- a/source/CinematicCamera/src/Config/CinematicCameraOptionClassFactory.cs +++ b/source/CinematicCamera/src/Config/CinematicCameraOptionClassFactory.cs @@ -1,4 +1,5 @@ -using MissionLibrary.Provider; +using CinematicCamera.MissionBehaviors; +using MissionLibrary.Provider; using MissionLibrary.View; using MissionSharedLibrary.Provider; using MissionSharedLibrary.View.ViewModelCollection; diff --git a/source/CinematicCamera/src/Config/HotKey/CinematicCameraHotkeyCategory.cs b/source/CinematicCamera/src/Config/HotKey/CinematicCameraHotkeyCategory.cs index dff6cb8..7495b78 100644 --- a/source/CinematicCamera/src/Config/HotKey/CinematicCameraHotkeyCategory.cs +++ b/source/CinematicCamera/src/Config/HotKey/CinematicCameraHotkeyCategory.cs @@ -1,6 +1,8 @@ using MissionLibrary.HotKey; +using MissionSharedLibrary.Config.HotKey; using MissionSharedLibrary.HotKey.Category; using System; +using System.Collections.Generic; using TaleWorlds.InputSystem; namespace CinematicCamera.Config.HotKey @@ -8,7 +10,12 @@ namespace CinematicCamera.Config.HotKey public enum GameKeyEnum { TogglePlayerInvulnerable, - ToggleMapLongPress, + IncreaseDepthOfFieldDistance, + DecreaseDepthOfFieldDistance, + IncreaseDepthOfFieldStart, + DecreaseDepthOfFieldStart, + IncreaseDepthOfFieldEnd, + DecreaseDepthOfFieldEnd, NumberOfGameKeyEnums } public class CinematicCameraGameKeyCategory @@ -21,22 +28,59 @@ public static void RegisterGameKeyCategory() { AGameKeyCategoryManager.Get()?.AddCategory(CreateCategory, new Version(1, 0)); } - - // not enabled + public static GameKeyCategory CreateCategory() { var result = new GameKeyCategory(CategoryId, (int)GameKeyEnum.NumberOfGameKeyEnums, GameKeyConfig.Get()); - result.AddGameKey(new GameKey((int)GameKeyEnum.TogglePlayerInvulnerable, nameof(GameKeyEnum.TogglePlayerInvulnerable), - CategoryId, InputKey.M, CategoryId)); - result.AddGameKey(new GameKey((int)GameKeyEnum.ToggleMapLongPress, nameof(GameKeyEnum.ToggleMapLongPress), - CategoryId, InputKey.LeftAlt, CategoryId)); + result.AddGameKeySequence(new GameKeySequence((int)GameKeyEnum.TogglePlayerInvulnerable, nameof(GameKeyEnum.TogglePlayerInvulnerable), + CategoryId, new List + { + InputKey.LeftControl, + InputKey.H + })); + result.AddGameKeySequence(new GameKeySequence((int)GameKeyEnum.IncreaseDepthOfFieldDistance, nameof(GameKeyEnum.IncreaseDepthOfFieldDistance), + CategoryId, new List + { + InputKey.Comma, + InputKey.Equals + })); + result.AddGameKeySequence(new GameKeySequence((int)GameKeyEnum.DecreaseDepthOfFieldDistance, nameof(GameKeyEnum.DecreaseDepthOfFieldDistance), + CategoryId, new List + { + InputKey.Comma, + InputKey.Minus + })); + result.AddGameKeySequence(new GameKeySequence((int)GameKeyEnum.IncreaseDepthOfFieldStart, nameof(GameKeyEnum.IncreaseDepthOfFieldStart), + CategoryId, new List + { + InputKey.Period, + InputKey.Equals + })); + result.AddGameKeySequence(new GameKeySequence((int)GameKeyEnum.DecreaseDepthOfFieldStart, nameof(GameKeyEnum.DecreaseDepthOfFieldStart), + CategoryId, new List + { + InputKey.Period, + InputKey.Minus + })); + result.AddGameKeySequence(new GameKeySequence((int)GameKeyEnum.IncreaseDepthOfFieldEnd, nameof(GameKeyEnum.IncreaseDepthOfFieldEnd), + CategoryId, new List + { + InputKey.Slash, + InputKey.Equals + })); + result.AddGameKeySequence(new GameKeySequence((int)GameKeyEnum.DecreaseDepthOfFieldEnd, nameof(GameKeyEnum.DecreaseDepthOfFieldEnd), + CategoryId, new List + { + InputKey.Slash, + InputKey.Minus + })); return result; } - public static InputKey GetKey(GameKeyEnum key) + public static IGameKeySequence GetKey(GameKeyEnum key) { - return Category?.GetKey((int)key) ?? InputKey.Invalid; + return Category?.GetGameKeySequence((int)key); } } } diff --git a/source/CinematicCamera/src/Config/HotKey/GameKeyConfig.cs b/source/CinematicCamera/src/Config/HotKey/GameKeyConfig.cs index 7537301..f4b7c63 100644 --- a/source/CinematicCamera/src/Config/HotKey/GameKeyConfig.cs +++ b/source/CinematicCamera/src/Config/HotKey/GameKeyConfig.cs @@ -4,7 +4,7 @@ namespace CinematicCamera.Config.HotKey { - class GameKeyConfig : GameKeyConfigBase + public class GameKeyConfig : GameKeyConfigBase { protected override string SaveName { get; } = Path.Combine(ConfigPath.ConfigDir, CinematicCameraSubModule.ModuleId, nameof(GameKeyConfig) + ".xml"); diff --git a/source/CinematicCamera/src/MissionBehaviors/CinematicCameraMenuView.cs b/source/CinematicCamera/src/MissionBehaviors/CinematicCameraMenuView.cs index 72688e3..ce27623 100644 --- a/source/CinematicCamera/src/MissionBehaviors/CinematicCameraMenuView.cs +++ b/source/CinematicCamera/src/MissionBehaviors/CinematicCameraMenuView.cs @@ -1,6 +1,6 @@ using MissionSharedLibrary.View; -namespace CinematicCamera +namespace CinematicCamera.MissionBehaviors { public class CinematicCameraMenuView : MissionMenuViewBase { diff --git a/source/CinematicCamera/src/MissionBehaviors/SetPlayerHealthLogic.cs b/source/CinematicCamera/src/MissionBehaviors/SetPlayerHealthLogic.cs index 05cc0b4..82f326a 100644 --- a/source/CinematicCamera/src/MissionBehaviors/SetPlayerHealthLogic.cs +++ b/source/CinematicCamera/src/MissionBehaviors/SetPlayerHealthLogic.cs @@ -1,4 +1,6 @@ -using MissionLibrary.Event; +using CinematicCamera.Config.HotKey; +using MissionLibrary.Event; +using TaleWorlds.Library; using TaleWorlds.MountAndBlade; namespace CinematicCamera @@ -23,6 +25,58 @@ public override void OnRemoveBehaviour() MissionEvent.MainAgentWillBeChangedToAnotherOne -= MainAgentWillBeChangedToAnotherOne; } + public override void OnMissionTick(float dt) + { + base.OnMissionTick(dt); + + if (CinematicCameraGameKeyCategory.GetKey(GameKeyEnum.TogglePlayerInvulnerable) + .IsKeyPressed(Mission.InputManager)) + { + _config.PlayerInvulnerable = !_config.PlayerInvulnerable; + UpdateInvulnerable(_config.PlayerInvulnerable); + } + if (CinematicCameraGameKeyCategory.GetKey(GameKeyEnum.IncreaseDepthOfFieldDistance) + .IsKeyDown(Mission.InputManager)) + { + _config.DepthOfFieldDistance = MathF.Clamp(_config.DepthOfFieldDistance + 0.05f, 0, 1000); + ModifyCameraHelper.UpdateDepthOfFieldDistance(); + ModifyCameraHelper.UpdateDepthOfFieldParameters(); + } + if (CinematicCameraGameKeyCategory.GetKey(GameKeyEnum.DecreaseDepthOfFieldDistance) + .IsKeyDown(Mission.InputManager)) + { + _config.DepthOfFieldDistance = MathF.Clamp(_config.DepthOfFieldDistance - 0.05f, 0, 1000); + ModifyCameraHelper.UpdateDepthOfFieldDistance(); + ModifyCameraHelper.UpdateDepthOfFieldParameters(); + } + if (CinematicCameraGameKeyCategory.GetKey(GameKeyEnum.IncreaseDepthOfFieldStart) + .IsKeyDown(Mission.InputManager)) + { + _config.DepthOfFieldStart = MathF.Clamp(_config.DepthOfFieldStart + 0.05f, 0, 1000); + ModifyCameraHelper.UpdateDepthOfFieldDistance(); + ModifyCameraHelper.UpdateDepthOfFieldParameters(); + } + if (CinematicCameraGameKeyCategory.GetKey(GameKeyEnum.DecreaseDepthOfFieldStart) + .IsKeyDown(Mission.InputManager)) + { + _config.DepthOfFieldStart = MathF.Clamp(_config.DepthOfFieldStart - 0.05f, 0, 1000); + ModifyCameraHelper.UpdateDepthOfFieldDistance(); + ModifyCameraHelper.UpdateDepthOfFieldParameters(); + } + if (CinematicCameraGameKeyCategory.GetKey(GameKeyEnum.IncreaseDepthOfFieldEnd) + .IsKeyDown(Mission.InputManager)) + { + _config.DepthOfFieldEnd = MathF.Clamp(_config.DepthOfFieldEnd + 0.05f, 0, 1000); + ModifyCameraHelper.UpdateDepthOfFieldParameters(); + } + if (CinematicCameraGameKeyCategory.GetKey(GameKeyEnum.DecreaseDepthOfFieldEnd) + .IsKeyDown(Mission.InputManager)) + { + _config.DepthOfFieldEnd = MathF.Clamp(_config.DepthOfFieldEnd - 0.05f, 0, 1000); + ModifyCameraHelper.UpdateDepthOfFieldParameters(); + } + } + private void MainAgentWillBeChangedToAnotherOne(Agent newAgent) { if (_config.PlayerInvulnerable) diff --git a/source/CinematicCamera/src/MissionBehaviors/ViewModel/CinematicCameraMenuVM.cs b/source/CinematicCamera/src/MissionBehaviors/ViewModel/CinematicCameraMenuVM.cs index f129246..eeb3dd0 100644 --- a/source/CinematicCamera/src/MissionBehaviors/ViewModel/CinematicCameraMenuVM.cs +++ b/source/CinematicCamera/src/MissionBehaviors/ViewModel/CinematicCameraMenuVM.cs @@ -187,7 +187,7 @@ public CinematicCameraMenuVM(Action closeMenu) : base(closeMenu) }); var scene = Mission.Current.Scene; - DepthOfFieldDistance = new NumericVM(GameTexts.FindText("str_cinematic_camera_depth_of_field_distance").ToString(), _config.DepthOfFieldDistance, 0, 100, false, + DepthOfFieldDistance = new NumericVM(GameTexts.FindText("str_cinematic_camera_depth_of_field_distance").ToString(), _config.DepthOfFieldDistance, 0, 100f, false, v => { _config.DepthOfFieldDistance = v; diff --git a/source/CinematicCamera/src/MissionStartingHandler.cs b/source/CinematicCamera/src/MissionStartingHandler.cs index 182e74a..c27774c 100644 --- a/source/CinematicCamera/src/MissionStartingHandler.cs +++ b/source/CinematicCamera/src/MissionStartingHandler.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using CinematicCamera.MissionBehaviors; +using System.Collections.Generic; using MissionLibrary.Controller; using MissionSharedLibrary.Controller; using TaleWorlds.MountAndBlade; diff --git a/source/library/mission-library b/source/library/mission-library index 371a191..686f35d 160000 --- a/source/library/mission-library +++ b/source/library/mission-library @@ -1 +1 @@ -Subproject commit 371a191242d391e775b92b9c99251be0ccfb2a8b +Subproject commit 686f35d182b39878100aaddb1bb5baf5f840c3fd