- add: Better telescope keybind. (#618)
This commit is contained in:
@@ -98,6 +98,12 @@ namespace Content.Client.Options.UI.Tabs
|
|||||||
_deferCommands.Add(_inputManager.SaveToUserData);
|
_deferCommands.Add(_inputManager.SaveToUserData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleHoldLookUp(BaseButton.ButtonToggledEventArgs args) // WD EDIT
|
||||||
|
{
|
||||||
|
_cfg.SetCVar(WhiteCVars.HoldLookUp, args.Pressed);
|
||||||
|
_cfg.SaveToFile();
|
||||||
|
}
|
||||||
|
|
||||||
private void HandleToggleAutoGetUp(BaseButton.ButtonToggledEventArgs args) // WD EDIT
|
private void HandleToggleAutoGetUp(BaseButton.ButtonToggledEventArgs args) // WD EDIT
|
||||||
{
|
{
|
||||||
_cfg.SetCVar(WhiteCVars.AutoGetUp, args.Pressed);
|
_cfg.SetCVar(WhiteCVars.AutoGetUp, args.Pressed);
|
||||||
@@ -194,6 +200,7 @@ namespace Content.Client.Options.UI.Tabs
|
|||||||
AddButton(ContentKeyFunctions.OfferItem); // WD EDIT
|
AddButton(ContentKeyFunctions.OfferItem); // WD EDIT
|
||||||
AddButton(ContentKeyFunctions.LieDown); // WD EDIT
|
AddButton(ContentKeyFunctions.LieDown); // WD EDIT
|
||||||
AddButton(ContentKeyFunctions.LookUp); // WD EDIT
|
AddButton(ContentKeyFunctions.LookUp); // WD EDIT
|
||||||
|
AddCheckBox("ui-options-function-hold-look-up", _cfg.GetCVar(WhiteCVars.HoldLookUp), HandleHoldLookUp); // WD EDIT
|
||||||
AddCheckBox("ui-options-function-auto-get-up", _cfg.GetCVar(WhiteCVars.AutoGetUp), HandleToggleAutoGetUp); // WD EDIT
|
AddCheckBox("ui-options-function-auto-get-up", _cfg.GetCVar(WhiteCVars.AutoGetUp), HandleToggleAutoGetUp); // WD EDIT
|
||||||
|
|
||||||
AddHeader("ui-options-header-interaction-adv");
|
AddHeader("ui-options-header-interaction-adv");
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Content.Client.Viewport;
|
using Content.Client.Viewport;
|
||||||
|
using Content.Shared._White;
|
||||||
using Content.Shared._White.Telescope;
|
using Content.Shared._White.Telescope;
|
||||||
using Content.Shared.Hands.Components;
|
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.Input;
|
using Robust.Client.Input;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
|
using Robust.Shared.Input.Binding;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
namespace Content.Client._White.Telescope;
|
namespace Content.Client._White.Telescope;
|
||||||
@@ -21,9 +23,26 @@ public sealed class TelescopeSystem : SharedTelescopeSystem
|
|||||||
[Dependency] private readonly IInputManager _input = default!;
|
[Dependency] private readonly IInputManager _input = default!;
|
||||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||||
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
|
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
|
||||||
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
|
|
||||||
private ScalingViewport? _viewport;
|
private ScalingViewport? _viewport;
|
||||||
|
private bool _holdLookUp;
|
||||||
|
private bool _toggled;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
_cfg.OnValueChanged(WhiteCVars.HoldLookUp,
|
||||||
|
val =>
|
||||||
|
{
|
||||||
|
var input = val ? null : InputCmdHandler.FromDelegate(_ => _toggled = !_toggled);
|
||||||
|
_input.SetInputCommand(ContentKeyFunctions.LookUp, input);
|
||||||
|
_holdLookUp = val;
|
||||||
|
_toggled = false;
|
||||||
|
},
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
public override void FrameUpdate(float frameTime)
|
public override void FrameUpdate(float frameTime)
|
||||||
{
|
{
|
||||||
@@ -37,7 +56,10 @@ public sealed class TelescopeSystem : SharedTelescopeSystem
|
|||||||
var entity = GetRightEntity(player);
|
var entity = GetRightEntity(player);
|
||||||
|
|
||||||
if (entity == EntityUid.Invalid)
|
if (entity == EntityUid.Invalid)
|
||||||
|
{
|
||||||
|
_toggled = false;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var telescope = Comp<TelescopeComponent>(entity);
|
var telescope = Comp<TelescopeComponent>(entity);
|
||||||
|
|
||||||
@@ -46,13 +68,17 @@ public sealed class TelescopeSystem : SharedTelescopeSystem
|
|||||||
|
|
||||||
var offset = Vector2.Zero;
|
var offset = Vector2.Zero;
|
||||||
|
|
||||||
if (_inputSystem.CmdStates.GetState(ContentKeyFunctions.LookUp) != BoundKeyState.Down)
|
if (_holdLookUp)
|
||||||
{
|
{
|
||||||
RaisePredictiveEvent(new EyeOffsetChangedEvent
|
if (_inputSystem.CmdStates.GetState(ContentKeyFunctions.LookUp) != BoundKeyState.Down)
|
||||||
{
|
{
|
||||||
Offset = offset
|
RaiseEvent(offset);
|
||||||
});
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!_toggled)
|
||||||
|
{
|
||||||
|
RaiseEvent(offset);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,6 +115,11 @@ public sealed class TelescopeSystem : SharedTelescopeSystem
|
|||||||
offset = new Angle(-eye.Rotation.Theta).RotateVec(offset);
|
offset = new Angle(-eye.Rotation.Theta).RotateVec(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RaiseEvent(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RaiseEvent(Vector2 offset)
|
||||||
|
{
|
||||||
RaisePredictiveEvent(new EyeOffsetChangedEvent
|
RaisePredictiveEvent(new EyeOffsetChangedEvent
|
||||||
{
|
{
|
||||||
Offset = offset
|
Offset = offset
|
||||||
|
|||||||
@@ -320,6 +320,12 @@ public sealed class WhiteCVars
|
|||||||
public static readonly CVarDef<bool> AutoGetUp =
|
public static readonly CVarDef<bool> AutoGetUp =
|
||||||
CVarDef.Create("white.auto_get_up", true, CVar.CLIENT | CVar.ARCHIVE | CVar.REPLICATED);
|
CVarDef.Create("white.auto_get_up", true, CVar.CLIENT | CVar.ARCHIVE | CVar.REPLICATED);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether telescope functions by holing a button or via toggle
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<bool> HoldLookUp =
|
||||||
|
CVarDef.Create("white.hold_look_up", false, CVar.CLIENT | CVar.ARCHIVE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Aspects
|
* Aspects
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -144,6 +144,8 @@ ui-options-function-auto-get-up = Автоматически вставать п
|
|||||||
ui-options-function-save-item-location = Сохранить позицию предмета
|
ui-options-function-save-item-location = Сохранить позицию предмета
|
||||||
ui-options-static-storage-ui = Закрепить интерфейс хранилища на хотбаре
|
ui-options-static-storage-ui = Закрепить интерфейс хранилища на хотбаре
|
||||||
ui-options-function-offer-item = Передать что-то
|
ui-options-function-offer-item = Передать что-то
|
||||||
|
ui-options-function-look-up = Присмотреться/Прицелиться
|
||||||
|
ui-options-function-hold-look-up = Удерживать клавишу для прицеливания
|
||||||
|
|
||||||
ui-options-function-smart-equip-backpack = Умная экипировка в рюкзак
|
ui-options-function-smart-equip-backpack = Умная экипировка в рюкзак
|
||||||
ui-options-function-smart-equip-belt = Умная экипировка на пояс
|
ui-options-function-smart-equip-belt = Умная экипировка на пояс
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
version: 1 # Not used right now, whatever.
|
version: 1 # Not used right now, whatever.
|
||||||
binds:
|
binds:
|
||||||
- function: UIClick
|
- function: UIClick
|
||||||
type: State
|
type: State
|
||||||
@@ -545,5 +545,4 @@ binds:
|
|||||||
key: U
|
key: U
|
||||||
- function: LookUp
|
- function: LookUp
|
||||||
type: State
|
type: State
|
||||||
key: MouseRight
|
key: Space
|
||||||
mod1: Space
|
|
||||||
|
|||||||
Reference in New Issue
Block a user