Skip to content

Commit

Permalink
Add hotkey for options
Browse files Browse the repository at this point in the history
  • Loading branch information
LiZhenhuan1019 committed Mar 15, 2021
1 parent 6254f23 commit 135247c
Show file tree
Hide file tree
Showing 16 changed files with 196 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/resources/config.env
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</Children>
</SliderWidget>

<RichTextWidget WidthSizePolicy="Fixed" HeightSizePolicy="CoverChildren" SuggestedWidth="50" MarginLeft="20" VerticalAlignment="Center" Brush="SPOptions.Slider.Value.Text" IsEnabled="false" Text="@OptionValueAsString" />
<RichTextWidget WidthSizePolicy="Fixed" HeightSizePolicy="CoverChildren" SuggestedWidth="100" MarginLeft="20" VerticalAlignment="Center" Brush="SPOptions.Slider.Value.Text" IsEnabled="false" Text="@OptionValueAsString" />

</Children>
</ListPanel>
Expand Down Expand Up @@ -132,7 +132,7 @@
</Children>
</SliderWidget>

<RichTextWidget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="50" SuggestedHeight="50" MarginLeft="20" VerticalAlignment="Center" Brush="SPOptions.Slider.Value.Text" IsEnabled="false" Text="@OptionValueAsString" />
<RichTextWidget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="100" SuggestedHeight="50" MarginLeft="20" VerticalAlignment="Center" Brush="SPOptions.Slider.Value.Text" IsEnabled="false" Text="@OptionValueAsString" />

</Children>
</ListPanel>
Expand Down Expand Up @@ -166,7 +166,7 @@
</Children>
</SliderWidget>

<RichTextWidget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="50" SuggestedHeight="50" MarginLeft="20" VerticalAlignment="Center" Brush="SPOptions.Slider.Value.Text" IsEnabled="false" Text="@OptionValueAsString" />
<RichTextWidget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="100" SuggestedHeight="50" MarginLeft="20" VerticalAlignment="Center" Brush="SPOptions.Slider.Value.Text" IsEnabled="false" Text="@OptionValueAsString" />

</Children>
</ListPanel>
Expand Down Expand Up @@ -197,7 +197,7 @@
</Children>
</SliderWidget>

<RichTextWidget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="50" SuggestedHeight="50" MarginLeft="20" VerticalAlignment="Center" Brush="SPOptions.Slider.Value.Text" IsEnabled="false" Text="@OptionValueAsString" />
<RichTextWidget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="100" SuggestedHeight="50" MarginLeft="20" VerticalAlignment="Center" Brush="SPOptions.Slider.Value.Text" IsEnabled="false" Text="@OptionValueAsString" />

</Children>
</ListPanel>
Expand All @@ -219,7 +219,7 @@
</Children>
</SliderWidget>

<RichTextWidget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="50" SuggestedHeight="50" MarginLeft="20" VerticalAlignment="Center" Brush="SPOptions.Slider.Value.Text" IsEnabled="false" Text="@OptionValueAsString" />
<RichTextWidget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="100" SuggestedHeight="50" MarginLeft="20" VerticalAlignment="Center" Brush="SPOptions.Slider.Value.Text" IsEnabled="false" Text="@OptionValueAsString" />

</Children>
</ListPanel>
Expand All @@ -240,7 +240,7 @@
</Children>
</SliderWidget>

<RichTextWidget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="50" SuggestedHeight="50" MarginLeft="20" VerticalAlignment="Center" Brush="SPOptions.Slider.Value.Text" IsEnabled="false" Text="@OptionValueAsString" />
<RichTextWidget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="100" SuggestedHeight="50" MarginLeft="20" VerticalAlignment="Center" Brush="SPOptions.Slider.Value.Text" IsEnabled="false" Text="@OptionValueAsString" />

</Children>
</ListPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,24 @@
<string id="CinematicCamera_depthoffielddistance" text="景深焦距" />
<string id="CinematicCamera_depthoffieldstart" text="景深开始参数" />
<string id="CinematicCamera_depthoffieldend" text="景深结束参数" />


<string id="CinematicCamera_hotkey_category" text="电影镜头快捷键" />
<string id="CinematicCamera_toggle_player_invulnerable" text="切换玩家角色无敌" />
<string id="CinematicCamera_toggle_player_invulnerable_hint" text="切换玩家角色无敌。" />
<string id="CinematicCamera_increase_dof_distance" text="增加焦距" />
<string id="CinematicCamera_increase_dof_distance_hint" text="增加景深的焦距。" />
<string id="CinematicCamera_decrease_dof_distance" text="减小焦距" />
<string id="CinematicCamera_decrease_dof_distance_hint" text="减小景深的焦距。" />

<string id="CinematicCamera_increase_dof_start" text="增加景深起始位置" />
<string id="CinematicCamera_increase_dof_start_hint" text="增加景深起始位置。" />
<string id="CinematicCamera_decrease_dof_start" text="减小景深起始位置" />
<string id="CinematicCamera_decrease_dof_start_hint" text="减小景深起始位置。" />

<string id="CinematicCamera_increase_dof_end" text="增加景深结束位置" />
<string id="CinematicCamera_increase_dof_end_hint" text="增加景深结束位置。" />
<string id="CinematicCamera_decrease_dof_end" text="减小景深结束位置" />
<string id="CinematicCamera_decrease_dof_end_hint" text="减小景深结束位置。" />
</strings>
</base>
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,25 @@
<string id="CinematicCamera_depthoffielddistance" text="Depth of Field Distance" />
<string id="CinematicCamera_depthoffieldstart" text="Depth of Field Focus Start" />
<string id="CinematicCamera_depthoffieldend" text="Depth of Field Focus End" />


<string id="CinematicCamera_hotkey_category" text="Cinematic Camera Hot Key" />
<string id="CinematicCamera_toggle_player_invulnerable" text="Toggle Player Invulnerable" />
<string id="CinematicCamera_toggle_player_invulnerable_hint" text="Toggle Player Invulnerable." />
<string id="CinematicCamera_increase_dof_distance" text="Increase DOF distance" />
<string id="CinematicCamera_increase_dof_distance_hint" text="Increase Depth Of Field Distance." />
<string id="CinematicCamera_decrease_dof_distance" text="Decrease DOF distance" />
<string id="CinematicCamera_decrease_dof_distance_hint" text="Decrease Depth Of Field Distance." />

<string id="CinematicCamera_increase_dof_start" text="Increase DOF Start" />
<string id="CinematicCamera_increase_dof_start_hint" text="Increase Depth Of Field Start Position." />
<string id="CinematicCamera_decrease_dof_start" text="Decrease DOF Start" />
<string id="CinematicCamera_decrease_dof_start_hint" text="Decrease Depth Of Field Start Position." />

<string id="CinematicCamera_increase_dof_end" text="Increase DOF End" />
<string id="CinematicCamera_increase_dof_end_hint" text="Increase Depth Of Field End Position." />
<string id="CinematicCamera_decrease_dof_end" text="Decrease DOF End" />
<string id="CinematicCamera_decrease_dof_end_hint" text="Decrease Depth Of Field End Position." />

</strings>
</base>
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,24 @@
<string id="str_cinematic_camera_depth_of_field_distance" text="{=CinematicCamera_depthoffielddistance}Depth of Field Distance" />
<string id="str_cinematic_camera_depth_of_field_start" text="{=CinematicCamera_depthoffieldstart}Depth of Field Focus Start" />
<string id="str_cinematic_camera_depth_of_field_End" text="{=CinematicCamera_depthoffieldend}Depth of Field Focus End" />


<string id="str_key_category_name.CinematicCameraHotKey" text="{=CinematicCamera_hotkey_category}Cinematic Camera Hot Key" />
<string id="str_key_name.CinematicCameraHotKey_Up" text="{=CinematicCamera_toggle_player_invulnerable}Toggle Player Invulnerable" />
<string id="str_key_description.CinematicCameraHotKey_Up" text="{=CinematicCamera_toggle_player_invulnerable_hint}Toggle Player Invulnerable." />
<string id="str_key_name.CinematicCameraHotKey_Down" text="{=CinematicCamera_increase_dof_distance}Increase DOF distance" />
<string id="str_key_description.CinematicCameraHotKey_Down" text="{=CinematicCamera_increase_dof_distance_hint}Increase Depth Of Field Distance." />
<string id="str_key_name.CinematicCameraHotKey_Left" text="{=CinematicCamera_decrease_dof_distance}Decrease DOF distance" />
<string id="str_key_description.CinematicCameraHotKey_Left" text="{=CinematicCamera_decrease_dof_distance_hint}Decrease Depth Of Field Distance." />

<string id="str_key_name.CinematicCameraHotKey_Right" text="{=CinematicCamera_increase_dof_start}Increase DOF Start" />
<string id="str_key_description.CinematicCameraHotKey_Right" text="{=CinematicCamera_increase_dof_start_hint}Increase Depth Of Field Start Position." />
<string id="str_key_name.CinematicCameraHotKey_Leave" text="{=CinematicCamera_decrease_dof_start}Decrease DOF Start" />
<string id="str_key_description.CinematicCameraHotKey_Leave" text="{=CinematicCamera_decrease_dof_start_hint}Decrease Depth Of Field Start Position." />

<string id="str_key_name.CinematicCameraHotKey_ShowIndicators" text="{=CinematicCamera_increase_dof_end}Increase DOF End" />
<string id="str_key_description.CinematicCameraHotKey_ShowIndicators" text="{=CinematicCamera_increase_dof_end_hint}Increase Depth Of Field End Position." />
<string id="str_key_name.CinematicCameraHotKey_InitiateAllChat" text="{=CinematicCamera_decrease_dof_end}Decrease DOF End" />
<string id="str_key_description.CinematicCameraHotKey_InitiateAllChat" text="{=CinematicCamera_decrease_dof_end_hint}Decrease Depth Of Field End Position." />
</strings>
</base>
10 changes: 5 additions & 5 deletions source/CinematicCamera/Modules/CinematicCamera/SubModule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<SingleplayerModule value="true"/>
<MultiplayerModule value="false"/>
<DependedModules>
<DependedModule Id="Native" DependentVersion="e1.5.8" />
<DependedModule Id="SandBoxCore" DependentVersion="e1.5.8" />
<DependedModule Id="Sandbox" DependentVersion="e1.5.8" />
<DependedModule Id="StoryMode" DependentVersion="e1.5.8" />
<DependedModule Id="RTSCamera" DependentVersion="e3.9.25" />
<DependedModule Id="Native" DependentVersion="e1.5.9" />
<DependedModule Id="SandBoxCore" DependentVersion="e1.5.9" />
<DependedModule Id="Sandbox" DependentVersion="e1.5.9" />
<DependedModule Id="StoryMode" DependentVersion="e1.5.9" />
<DependedModule Id="RTSCamera" DependentVersion="e3.9.26" />
</DependedModules>
<SubModules>
<SubModule>
Expand Down
6 changes: 4 additions & 2 deletions source/CinematicCamera/src/CinematicCameraSubModule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MissionLibrary;
using CinematicCamera.Config.HotKey;
using MissionLibrary;
using MissionLibrary.Controller;
using MissionLibrary.View;
using MissionSharedLibrary;
Expand Down Expand Up @@ -46,7 +47,8 @@ private bool SecondInitialize()
{
if (!Initializer.SecondInitialize())
return false;


CinematicCameraGameKeyCategory.RegisterGameKeyCategory();
Global.GetProvider<AMissionStartingManager>().AddHandler(new MissionStartingHandler());
var menuClassCollection = AMenuManager.Get().MenuClassCollection;
menuClassCollection.AddOptionClass(CinematicCameraOptionClassFactory.CreateOptionClassProvider(menuClassCollection));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MissionLibrary.Provider;
using CinematicCamera.MissionBehaviors;
using MissionLibrary.Provider;
using MissionLibrary.View;
using MissionSharedLibrary.Provider;
using MissionSharedLibrary.View.ViewModelCollection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
using MissionLibrary.HotKey;
using MissionSharedLibrary.Config.HotKey;
using MissionSharedLibrary.HotKey.Category;
using System;
using System.Collections.Generic;
using TaleWorlds.InputSystem;

namespace CinematicCamera.Config.HotKey
{
public enum GameKeyEnum
{
TogglePlayerInvulnerable,
ToggleMapLongPress,
IncreaseDepthOfFieldDistance,
DecreaseDepthOfFieldDistance,
IncreaseDepthOfFieldStart,
DecreaseDepthOfFieldStart,
IncreaseDepthOfFieldEnd,
DecreaseDepthOfFieldEnd,
NumberOfGameKeyEnums
}
public class CinematicCameraGameKeyCategory
Expand All @@ -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>
{
InputKey.LeftControl,
InputKey.H
}));
result.AddGameKeySequence(new GameKeySequence((int)GameKeyEnum.IncreaseDepthOfFieldDistance, nameof(GameKeyEnum.IncreaseDepthOfFieldDistance),
CategoryId, new List<InputKey>
{
InputKey.Comma,
InputKey.Equals
}));
result.AddGameKeySequence(new GameKeySequence((int)GameKeyEnum.DecreaseDepthOfFieldDistance, nameof(GameKeyEnum.DecreaseDepthOfFieldDistance),
CategoryId, new List<InputKey>
{
InputKey.Comma,
InputKey.Minus
}));
result.AddGameKeySequence(new GameKeySequence((int)GameKeyEnum.IncreaseDepthOfFieldStart, nameof(GameKeyEnum.IncreaseDepthOfFieldStart),
CategoryId, new List<InputKey>
{
InputKey.Period,
InputKey.Equals
}));
result.AddGameKeySequence(new GameKeySequence((int)GameKeyEnum.DecreaseDepthOfFieldStart, nameof(GameKeyEnum.DecreaseDepthOfFieldStart),
CategoryId, new List<InputKey>
{
InputKey.Period,
InputKey.Minus
}));
result.AddGameKeySequence(new GameKeySequence((int)GameKeyEnum.IncreaseDepthOfFieldEnd, nameof(GameKeyEnum.IncreaseDepthOfFieldEnd),
CategoryId, new List<InputKey>
{
InputKey.Slash,
InputKey.Equals
}));
result.AddGameKeySequence(new GameKeySequence((int)GameKeyEnum.DecreaseDepthOfFieldEnd, nameof(GameKeyEnum.DecreaseDepthOfFieldEnd),
CategoryId, new List<InputKey>
{
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);
}
}
}
2 changes: 1 addition & 1 deletion source/CinematicCamera/src/Config/HotKey/GameKeyConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace CinematicCamera.Config.HotKey
{
class GameKeyConfig : GameKeyConfigBase<GameKeyConfig>
public class GameKeyConfig : GameKeyConfigBase<GameKeyConfig>
{
protected override string SaveName { get; } =
Path.Combine(ConfigPath.ConfigDir, CinematicCameraSubModule.ModuleId, nameof(GameKeyConfig) + ".xml");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using MissionSharedLibrary.View;

namespace CinematicCamera
namespace CinematicCamera.MissionBehaviors
{
public class CinematicCameraMenuView : MissionMenuViewBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using MissionLibrary.Event;
using CinematicCamera.Config.HotKey;
using MissionLibrary.Event;
using TaleWorlds.Library;
using TaleWorlds.MountAndBlade;

namespace CinematicCamera
Expand All @@ -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)
Expand Down
Loading

0 comments on commit 135247c

Please sign in to comment.