Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

апстримец #143

Merged
merged 14 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ private void HandleToggleWalk(BaseButton.ButtonToggledEventArgs args)
_deferCommands.Add(_inputManager.SaveToUserData);
}

private void HandleDefaultWalk(BaseButton.ButtonToggledEventArgs args)
{
_cfg.SetCVar(CCVars.DefaultWalk, args.Pressed);
_cfg.SaveToFile();
}

private void HandleStaticStorageUI(BaseButton.ButtonToggledEventArgs args)
{
_cfg.SetCVar(CCVars.StaticStorageUI, args.Pressed);
Expand Down Expand Up @@ -161,6 +167,7 @@ void AddCheckBox(string checkBoxName, bool currentState, Action<BaseButton.Butto
AddButton(EngineKeyFunctions.MoveRight);
AddButton(EngineKeyFunctions.Walk);
AddCheckBox("ui-options-hotkey-toggle-walk", _cfg.GetCVar(CCVars.ToggleWalk), HandleToggleWalk);
AddCheckBox("ui-options-hotkey-default-walk", _cfg.GetCVar(CCVars.DefaultWalk), HandleDefaultWalk);
InitToggleWalk();

AddHeader("ui-options-header-camera");
Expand Down
6 changes: 6 additions & 0 deletions Content.Client/Physics/Controllers/MoverController.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using Content.Shared.CCVar;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Events;
using Content.Shared.Movement.Pulling.Components;
using Content.Shared.Movement.Systems;
using Robust.Client.GameObjects;
using Robust.Client.Physics;
using Robust.Client.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
using Robust.Shared.Timing;
Expand All @@ -12,6 +15,7 @@ namespace Content.Client.Physics.Controllers
{
public sealed class MoverController : SharedMoverController
{
[Dependency] private readonly IConfigurationManager _config = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;

Expand All @@ -26,6 +30,8 @@ public override void Initialize()
SubscribeLocalEvent<InputMoverComponent, UpdateIsPredictedEvent>(OnUpdatePredicted);
SubscribeLocalEvent<MovementRelayTargetComponent, UpdateIsPredictedEvent>(OnUpdateRelayTargetPredicted);
SubscribeLocalEvent<PullableComponent, UpdateIsPredictedEvent>(OnUpdatePullablePredicted);

Subs.CVar(_config, CCVars.DefaultWalk, _ => RaiseNetworkEvent(new UpdateInputCVarsMessage()));
}

private void OnUpdatePredicted(EntityUid uid, InputMoverComponent component, ref UpdateIsPredictedEvent args)
Expand Down
8 changes: 7 additions & 1 deletion Content.Client/RCD/RCDMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public RCDMenu(EntityUid owner, RCDMenuBoundUserInterface bui)
tooltip = Loc.GetString(entProto.Name);
}

tooltip = char.ToUpper(tooltip[0]) + tooltip.Remove(0, 1);
tooltip = OopsConcat(char.ToUpper(tooltip[0]).ToString(), tooltip.Remove(0, 1));

var button = new RCDMenuButton()
{
Expand Down Expand Up @@ -119,6 +119,12 @@ public RCDMenu(EntityUid owner, RCDMenuBoundUserInterface bui)
SendRCDSystemMessageAction += bui.SendRCDSystemMessage;
}

private static string OopsConcat(string a, string b)
{
// This exists to prevent Roslyn being clever and compiling something that fails sandbox checks.
return a + b;
}

private void AddRCDMenuButtonOnClickActions(Control control)
{
var radialContainer = control as RadialContainer;
Expand Down
2 changes: 1 addition & 1 deletion Content.IntegrationTests/Tests/Slipping/SlippingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private void OnSlip(EntityUid uid, SlipperyComponent component, ref SlipEvent ar
public async Task BananaSlipTest()
{
var sys = SEntMan.System<SlipTestSystem>();
var sprintWalks = sys.Config.GetCVar(CCVars.GamePressToSprint);
var sprintWalks = sys.Config.GetCVar(CCVars.DefaultWalk);
await SpawnTarget("TrashBananaPeel");

// var modifier = Comp<MovementSpeedModifierComponent>(Player).SprintSpeedModifier;
Expand Down
13 changes: 6 additions & 7 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,6 @@ public static readonly CVarDef<bool>
public static readonly CVarDef<bool> GameAutoEatDrinks =
CVarDef.Create("game.auto_eat_drinks", false, CVar.REPLICATED);


/// <summary>
/// When true, you have to press the change speed button to sprint.
/// </summary>
public static readonly CVarDef<bool> GamePressToSprint =
CVarDef.Create("game.press_to_sprint", true, CVar.REPLICATED);

/// <summary>
/// Whether item slots, such as power cell slots or AME fuel cell slots, should support quick swap if it is not otherwise specified in their YAML prototype.
/// </summary>
Expand Down Expand Up @@ -2006,6 +1999,12 @@ public static readonly CVarDef<string>
public static readonly CVarDef<bool> ToggleWalk =
CVarDef.Create("control.toggle_walk", true, CVar.CLIENTONLY | CVar.ARCHIVE);

/// <summary>
/// Whether the player mob is walking by default instead of running.
/// </summary>
public static readonly CVarDef<bool> DefaultWalk =
CVarDef.Create("control.default_walk", true, CVar.CLIENT | CVar.REPLICATED | CVar.ARCHIVE);

/*
* STORAGE
*/
Expand Down
8 changes: 7 additions & 1 deletion Content.Shared/Chat/SharedChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,16 @@ public string SanitizeMessageCapital(string message)
if (string.IsNullOrEmpty(message))
return message;
// Capitalize first letter
message = char.ToUpper(message[0]) + message.Remove(0, 1);
message = OopsConcat(char.ToUpper(message[0]).ToString(), message.Remove(0, 1));
return message;
}

private static string OopsConcat(string a, string b)
{
// This exists to prevent Roslyn being clever and compiling something that fails sandbox checks.
return a + b;
}

public string SanitizeMessageCapitalizeTheWordI(string message, string theWordI = "i")
{
if (string.IsNullOrEmpty(message))
Expand Down
7 changes: 4 additions & 3 deletions Content.Shared/Movement/Components/InputMoverComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ public sealed partial class InputMoverComponent : Component

public const float LerpTime = 1.0f;

//NOTE I don't think I'm supposed to do this
public bool Sprinting => IoCManager.Resolve<IConfigurationManager>().GetCVar(CCVars.GamePressToSprint)
public bool Sprinting => DefaultSprinting
? (HeldMoveButtons & MoveButtons.Walk) != 0x0
: (HeldMoveButtons & MoveButtons.Walk) == 0x0;

public bool DefaultSprinting = true;

[ViewVariables(VVAccess.ReadWrite)]
public bool CanMove = true;

Expand All @@ -94,6 +95,6 @@ public sealed class InputMoverComponentState : ComponentState
public Angle TargetRelativeRotation;
public Angle RelativeRotation;
public TimeSpan LerpTarget;
public bool CanMove;
public bool CanMove, DefaultSprinting;
}
}
9 changes: 9 additions & 0 deletions Content.Shared/Movement/Events/UpdateInputCVarsMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Robust.Shared.Serialization;

namespace Content.Shared.Movement.Events;

/// <summary>
/// Raised from the client to the server to require the server to update the client's input CVars.
/// </summary>
[Serializable, NetSerializable]
public sealed class UpdateInputCVarsMessage : EntityEventArgs { }
43 changes: 43 additions & 0 deletions Content.Shared/Movement/Systems/SharedMoverController.CVars.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Content.Shared.CCVar;
using Content.Shared.Mind.Components;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Events;
using Robust.Shared.Configuration;

namespace Content.Shared.Movement.Systems;

public abstract partial class SharedMoverController
{
[Dependency] private readonly INetConfigurationManager _netConfig = default!;

private void InitializeCVars()
{
SubscribeLocalEvent<InputMoverComponent, MindAddedMessage>(OnMindAdded);
SubscribeLocalEvent<InputMoverComponent, MindRemovedMessage>(OnMindRemoved);
SubscribeNetworkEvent<UpdateInputCVarsMessage>(OnUpdateCVars);
}

private void OnMindAdded(Entity<InputMoverComponent> ent, ref MindAddedMessage args)
{
if (args.Mind.Comp.Session?.Channel is not { } channel)
return;

ent.Comp.DefaultSprinting = _netConfig.GetClientCVar(channel, CCVars.DefaultWalk);
WalkingAlert(ent, ent.Comp);
}

private void OnMindRemoved(Entity<InputMoverComponent> ent, ref MindRemovedMessage args)
{
// If it's an ai-controlled mob, we probably want them sprinting by default.
ent.Comp.DefaultSprinting = true;
}

private void OnUpdateCVars(UpdateInputCVarsMessage msg, EntitySessionEventArgs args)
{
if (args.SenderSession.AttachedEntity is not { } uid || !TryComp<InputMoverComponent>(uid, out var mover))
return;

mover.DefaultSprinting = _netConfig.GetClientCVar(args.SenderSession.Channel, CCVars.DefaultWalk);
WalkingAlert(uid, mover);
}
}
11 changes: 7 additions & 4 deletions Content.Shared/Movement/Systems/SharedMoverController.Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Shared.Input;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Events;
using Robust.Shared.Configuration;
using Robust.Shared.GameStates;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
Expand Down Expand Up @@ -108,6 +109,7 @@ private void OnMoverHandleState(EntityUid uid, InputMoverComponent component, Co
component.TargetRelativeRotation = state.TargetRelativeRotation;
component.CanMove = state.CanMove;
component.RelativeEntity = EnsureEntity<InputMoverComponent>(state.RelativeEntity, uid);
component.DefaultSprinting = state.DefaultSprinting;

// Reset
component.LastInputTick = GameTick.Zero;
Expand All @@ -131,6 +133,7 @@ private void OnMoverGetState(EntityUid uid, InputMoverComponent component, ref C
HeldMoveButtons = component.HeldMoveButtons,
RelativeRotation = component.RelativeRotation,
TargetRelativeRotation = component.TargetRelativeRotation,
DefaultSprinting = component.DefaultSprinting
};
}

Expand Down Expand Up @@ -334,7 +337,7 @@ private void OnInputInit(EntityUid uid, InputMoverComponent component, Component

component.RelativeEntity = xform.GridUid ?? xform.MapUid;
component.TargetRelativeRotation = Angle.Zero;
WalkingAlert(uid, !component.Sprinting);
WalkingAlert(uid, component);
}

private void HandleRunChange(EntityUid uid, ushort subTick, bool walking)
Expand All @@ -346,8 +349,8 @@ private void HandleRunChange(EntityUid uid, ushort subTick, bool walking)
// if we swap to relay then stop our existing input if we ever change back.
if (moverComp != null)
{
WalkingAlert(uid, walking);
SetMoveInput(moverComp, MoveButtons.None);
WalkingAlert(uid, moverComp);
}

HandleRunChange(relayMover.RelayEntity, subTick, walking);
Expand Down Expand Up @@ -467,8 +470,8 @@ private void ResetSubtick(InputMoverComponent component)
public void SetSprinting(EntityUid entity, InputMoverComponent component, ushort subTick, bool walking)
{
// Logger.Info($"[{_gameTiming.CurTick}/{subTick}] Sprint: {enabled}");
WalkingAlert(entity, walking);
SetMoveInput(entity, component, subTick, walking, MoveButtons.Walk);
WalkingAlert(entity, component);
}

/// <summary>
Expand Down Expand Up @@ -620,7 +623,7 @@ public enum MoveButtons : byte
Down = 2,
Left = 4,
Right = 8,
Walk = 16, // This may be either a sprint button or a walk button, depending on server config
Walk = 16, // This may be either a sprint button or a walk button, depending on mover config
AnyDirection = Up | Down | Left | Right,
}

Expand Down
6 changes: 3 additions & 3 deletions Content.Shared/Movement/Systems/SharedMoverController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public override void Initialize()

InitializeInput();
InitializeRelay();
InitializeCVars();
Subs.CVar(_configManager, CCVars.RelativeMovement, value => _relativeMovement = value, true);
Subs.CVar(_configManager, CCVars.StopSpeed, value => _stopSpeed = value, true);
UpdatesBefore.Add(typeof(TileFrictionController));
Expand Down Expand Up @@ -298,10 +299,9 @@ protected void HandleMobMovement(
PhysicsSystem.SetAngularVelocity(physicsUid, 0, body: physicsComponent);
}

private void WalkingAlert(EntityUid player, bool walking)
private void WalkingAlert(EntityUid player, InputMoverComponent component)
{
walking = _configManager.GetCVar(CCVars.GamePressToSprint) ? !walking : walking;
_alerts.ShowAlert(player, AlertType.Walking, walking ? (short) 0 : (short) 1);
_alerts.ShowAlert(player, AlertType.Walking, component.Sprinting ? (short) 1 : (short) 0);
}

public void LerpRotation(EntityUid uid, InputMoverComponent mover, float frameTime)
Expand Down
54 changes: 54 additions & 0 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6271,3 +6271,57 @@ Entries:
id: 6354
time: '2024-09-12T00:15:18.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/895
- author: stellar-novas
changes:
- type: Add
message: Airlocks once again have access wires. Happy hacking!
id: 6355
time: '2024-09-14T00:48:34.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/916
- author: Mocho
changes:
- type: Add
message: >-
Science Job related items are now part of a Science loadout group, and
have all been significantly discounted.
- type: Add
message: Added more clothing to the science section in loadouts.
- type: Tweak
message: Adjusted command loadout item pricing.
- type: Tweak
message: Added localization strings for the new loadout groups.
id: 6356
time: '2024-09-14T01:00:26.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/914
- author: VMSolidus
changes:
- type: Add
message: >-
Added missing Localizations for Departments, Jobs, and Loadout Item
Groups.
- type: Add
message: >-
Bartender-Specific loadouts! Bartenders can now choose to spawn with
either their classic shotgun, or a Mosin Nagant that comes preloaded
with rubber bullets.
id: 6357
time: '2024-09-14T01:12:40.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/915
- author: CilliePaint
changes:
- type: Tweak
message: Stuffed Lawyer's Pockets with Space Law guides!
- type: Remove
message: Took away Atmos backpacks as Starting equipment.
id: 6358
time: '2024-09-14T05:41:40.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/897
- author: Mnemotechnician
changes:
- type: Add
message: >-
You can now choose whether you want to walk or run by default in the
settings.
id: 6359
time: '2024-09-14T05:44:56.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/889
1 change: 1 addition & 0 deletions Resources/Locale/en-US/escape-menu/ui/options-menu.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ ui-options-header-general = General

ui-options-hotkey-keymap = Use US QWERTY Keys
ui-options-hotkey-toggle-walk = Toggle Speed
ui-options-hotkey-default-walk = Walk by default

ui-options-function-move-up = Move Up
ui-options-function-move-left = Move Left
Expand Down
8 changes: 8 additions & 0 deletions Resources/Locale/en-US/loadouts/categories.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ loadout-category-Head = Head
loadout-category-Items = Items
loadout-category-Jobs = Jobs
loadout-category-JobsAUncategorized = Uncategorized
loadout-category-JobsCargo = Logistics
loadout-category-JobsCommand = Command
loadout-category-JobsCommandAUncategorized = Uncategorized
loadout-category-JobsCommandCaptain = Captain
Expand All @@ -17,6 +18,13 @@ loadout-category-JobsCommandHOP = Head of Personnel
loadout-category-JobsCommandHOS = Head of Security
loadout-category-JobsCommandQM = Logistics Officer
loadout-category-JobsCommandRD = Mystagogue
loadout-category-JobsEngineering = Engineering
loadout-category-JobsMedical = Medical
loadout-category-JobsScience = Epistemics
loadout-category-JobsSecurity = Security
loadout-category-JobsService = Service
loadout-category-JobsServiceUncategorized = Uncategorized
loadout-category-JobsServiceBartender = Bartender
loadout-category-Mask = Mask
loadout-category-Neck = Neck
loadout-category-Outer = Outer
Expand Down
Loading
Loading