Skip to content

Commit

Permalink
Merge branch 'space-wizards:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
RonRonstation authored Apr 3, 2024
2 parents 6c0ae16 + 70ec12f commit c7c39c3
Show file tree
Hide file tree
Showing 195 changed files with 1,632 additions and 690 deletions.
11 changes: 8 additions & 3 deletions Content.Client/Options/UI/Tabs/MiscTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
<CheckBox Name="ReducedMotionCheckBox" Text="{Loc 'ui-options-reduced-motion'}" />
<CheckBox Name="EnableColorNameCheckBox" Text="{Loc 'ui-options-enable-color-name'}" />
<CheckBox Name="ColorblindFriendlyCheckBox" Text="{Loc 'ui-options-colorblind-friendly'}" />
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'ui-options-chat-window-opacity'}" Margin="8 0" />
<Slider Name="ChatWindowOpacitySlider"
MinValue="0"
MaxValue="1"
MinWidth="200" />
<Label Name="ChatWindowOpacityLabel" Margin="8 0" />
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'ui-options-screen-shake-intensity'}" Margin="8 0" />
<Slider Name="ScreenShakeIntensitySlider"
Expand Down Expand Up @@ -65,6 +73,3 @@
</controls:StripeBack>
</BoxContainer>
</tabs:MiscTab>



12 changes: 12 additions & 0 deletions Content.Client/Options/UI/Tabs/MiscTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public MiscTab()
EnableColorNameCheckBox.OnToggled += OnCheckBoxToggled;
ColorblindFriendlyCheckBox.OnToggled += OnCheckBoxToggled;
ReducedMotionCheckBox.OnToggled += OnCheckBoxToggled;
ChatWindowOpacitySlider.OnValueChanged += OnChatWindowOpacitySliderChanged;
ScreenShakeIntensitySlider.OnValueChanged += OnScreenShakeIntensitySliderChanged;
// ToggleWalk.OnToggled += OnCheckBoxToggled;
StaticStorageUI.OnToggled += OnCheckBoxToggled;
Expand All @@ -81,6 +82,7 @@ public MiscTab()
EnableColorNameCheckBox.Pressed = _cfg.GetCVar(CCVars.ChatEnableColorName);
ColorblindFriendlyCheckBox.Pressed = _cfg.GetCVar(CCVars.AccessibilityColorblindFriendly);
ReducedMotionCheckBox.Pressed = _cfg.GetCVar(CCVars.ReducedMotion);
ChatWindowOpacitySlider.Value = _cfg.GetCVar(CCVars.ChatWindowOpacity);
ScreenShakeIntensitySlider.Value = _cfg.GetCVar(CCVars.ScreenShakeIntensity) * 100f;
// ToggleWalk.Pressed = _cfg.GetCVar(CCVars.ToggleWalk);
StaticStorageUI.Pressed = _cfg.GetCVar(CCVars.StaticStorageUI);
Expand All @@ -101,6 +103,13 @@ private void OnHudThemeChanged(OptionButton.ItemSelectedEventArgs args)
UpdateApplyButton();
}

private void OnChatWindowOpacitySliderChanged(Range range)
{
ChatWindowOpacityLabel.Text = Loc.GetString("ui-options-chat-window-opacity-percent",
("opacity", range.Value));
UpdateApplyButton();
}

private void OnScreenShakeIntensitySliderChanged(Range obj)
{
ScreenShakeIntensityLabel.Text = Loc.GetString("ui-options-screen-shake-percent", ("intensity", ScreenShakeIntensitySlider.Value / 100f));
Expand All @@ -127,6 +136,7 @@ private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
_cfg.SetCVar(CCVars.ChatEnableColorName, EnableColorNameCheckBox.Pressed);
_cfg.SetCVar(CCVars.AccessibilityColorblindFriendly, ColorblindFriendlyCheckBox.Pressed);
_cfg.SetCVar(CCVars.ReducedMotion, ReducedMotionCheckBox.Pressed);
_cfg.SetCVar(CCVars.ChatWindowOpacity, ChatWindowOpacitySlider.Value);
_cfg.SetCVar(CCVars.ScreenShakeIntensity, ScreenShakeIntensitySlider.Value / 100f);
// _cfg.SetCVar(CCVars.ToggleWalk, ToggleWalk.Pressed);
_cfg.SetCVar(CCVars.StaticStorageUI, StaticStorageUI.Pressed);
Expand Down Expand Up @@ -154,6 +164,7 @@ private void UpdateApplyButton()
var isEnableColorNameSame = EnableColorNameCheckBox.Pressed == _cfg.GetCVar(CCVars.ChatEnableColorName);
var isColorblindFriendly = ColorblindFriendlyCheckBox.Pressed == _cfg.GetCVar(CCVars.AccessibilityColorblindFriendly);
var isReducedMotionSame = ReducedMotionCheckBox.Pressed == _cfg.GetCVar(CCVars.ReducedMotion);
var isChatWindowOpacitySame = Math.Abs(ChatWindowOpacitySlider.Value - _cfg.GetCVar(CCVars.ChatWindowOpacity)) < 0.01f;
var isScreenShakeIntensitySame = Math.Abs(ScreenShakeIntensitySlider.Value / 100f - _cfg.GetCVar(CCVars.ScreenShakeIntensity)) < 0.01f;
// var isToggleWalkSame = ToggleWalk.Pressed == _cfg.GetCVar(CCVars.ToggleWalk);
var isStaticStorageUISame = StaticStorageUI.Pressed == _cfg.GetCVar(CCVars.StaticStorageUI);
Expand All @@ -170,6 +181,7 @@ private void UpdateApplyButton()
isEnableColorNameSame &&
isColorblindFriendly &&
isReducedMotionSame &&
isChatWindowOpacitySame &&
isScreenShakeIntensitySame &&
// isToggleWalkSame &&
isStaticStorageUISame;
Expand Down
29 changes: 18 additions & 11 deletions Content.Client/Stylesheets/StyleNano.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public sealed class StyleNano : StyleBase
public const string StyleClassBorderedWindowPanel = "BorderedWindowPanel";
public const string StyleClassInventorySlotBackground = "InventorySlotBackground";
public const string StyleClassHandSlotHighlight = "HandSlotHighlight";
public const string StyleClassChatPanel = "ChatPanel";
public const string StyleClassChatSubPanel = "ChatSubPanel";
public const string StyleClassTransparentBorderedWindowPanel = "TransparentBorderedWindowPanel";
public const string StyleClassHotbarPanel = "HotbarPanel";
Expand Down Expand Up @@ -144,6 +145,8 @@ public sealed class StyleNano : StyleBase
public const string StyleClassButtonColorRed = "ButtonColorRed";
public const string StyleClassButtonColorGreen = "ButtonColorGreen";

public static readonly Color ChatBackgroundColor = Color.FromHex("#25252ADD");

public override Stylesheet Stylesheet { get; }

public StyleNano(IResourceCache resCache) : base(resCache)
Expand Down Expand Up @@ -346,12 +349,16 @@ public StyleNano(IResourceCache resCache) : base(resCache)
lineEdit.SetPatchMargin(StyleBox.Margin.All, 3);
lineEdit.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);

var chatSubBGTex = resCache.GetTexture("/Textures/Interface/Nano/chat_sub_background.png");
var chatSubBG = new StyleBoxTexture
var chatBg = new StyleBoxFlat
{
BackgroundColor = ChatBackgroundColor
};

var chatSubBg = new StyleBoxFlat
{
Texture = chatSubBGTex,
BackgroundColor = ChatBackgroundColor,
};
chatSubBG.SetPatchMargin(StyleBox.Margin.All, 2);
chatSubBg.SetContentMarginOverride(StyleBox.Margin.All, 2);

var actionSearchBoxTex = resCache.GetTexture("/Textures/Interface/Nano/black_panel_dark_thin_border.png");
var actionSearchBox = new StyleBoxTexture
Expand Down Expand Up @@ -850,19 +857,19 @@ public StyleNano(IResourceCache resCache) : base(resCache)
Element<TextEdit>().Pseudo(TextEdit.StylePseudoClassPlaceholder)
.Prop("font-color", Color.Gray),

// Chat lineedit - we don't actually draw a stylebox around the lineedit itself, we put it around the
// input + other buttons, so we must clear the default stylebox
new StyleRule(new SelectorElement(typeof(LineEdit), new[] {StyleClassChatLineEdit}, null, null),
// chat subpanels (chat lineedit backing, popup backings)
new StyleRule(new SelectorElement(typeof(PanelContainer), new[] {StyleClassChatPanel}, null, null),
new[]
{
new StyleProperty(LineEdit.StylePropertyStyleBox, new StyleBoxEmpty()),
new StyleProperty(PanelContainer.StylePropertyPanel, chatBg),
}),

// chat subpanels (chat lineedit backing, popup backings)
new StyleRule(new SelectorElement(typeof(PanelContainer), new[] {StyleClassChatSubPanel}, null, null),
// Chat lineedit - we don't actually draw a stylebox around the lineedit itself, we put it around the
// input + other buttons, so we must clear the default stylebox
new StyleRule(new SelectorElement(typeof(LineEdit), new[] {StyleClassChatLineEdit}, null, null),
new[]
{
new StyleProperty(PanelContainer.StylePropertyPanel, chatSubBG),
new StyleProperty(LineEdit.StylePropertyStyleBox, new StyleBoxEmpty()),
}),

// Action searchbox lineedit
Expand Down
43 changes: 38 additions & 5 deletions Content.Client/UserInterface/Systems/Chat/ChatUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Client.Examine;
using Content.Client.Gameplay;
using Content.Client.Ghost;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Screens;
using Content.Client.UserInterface.Systems.Chat.Widgets;
using Content.Client.UserInterface.Systems.Gameplay;
Expand Down Expand Up @@ -54,7 +55,6 @@ public sealed class ChatUIController : UIController
[Dependency] private readonly IStateManager _state = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IReplayRecordingManager _replayRecording = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;

[UISystemDependency] private readonly ExamineSystem? _examine = default;
[UISystemDependency] private readonly GhostSystem? _ghost = default;
Expand Down Expand Up @@ -179,8 +179,8 @@ public override void Initialize()
_net.RegisterNetMessage<MsgChatMessage>(OnChatMessage);
_net.RegisterNetMessage<MsgDeleteChatMessagesBy>(OnDeleteChatMessagesBy);
SubscribeNetworkEvent<DamageForceSayEvent>(OnDamageForceSay);
_cfg.OnValueChanged(CCVars.ChatEnableColorName, (value) => { _chatNameColorsEnabled = value; });
_chatNameColorsEnabled = _cfg.GetCVar(CCVars.ChatEnableColorName);
_config.OnValueChanged(CCVars.ChatEnableColorName, (value) => { _chatNameColorsEnabled = value; });
_chatNameColorsEnabled = _config.GetCVar(CCVars.ChatEnableColorName);

_speechBubbleRoot = new LayoutContainer();

Expand Down Expand Up @@ -232,6 +232,9 @@ public override void Initialize()
{
_chatNameColors[i] = nameColors[i].ToHex();
}

_config.OnValueChanged(CCVars.ChatWindowOpacity, OnChatWindowOpacityChanged);

}

public void OnScreenLoad()
Expand All @@ -240,13 +243,43 @@ public void OnScreenLoad()

var viewportContainer = UIManager.ActiveScreen!.FindControl<LayoutContainer>("ViewportContainer");
SetSpeechBubbleRoot(viewportContainer);

SetChatWindowOpacity(_config.GetCVar(CCVars.ChatWindowOpacity));
}

public void OnScreenUnload()
{
SetMainChat(false);
}

private void OnChatWindowOpacityChanged(float opacity)
{
SetChatWindowOpacity(opacity);
}

private void SetChatWindowOpacity(float opacity)
{
var chatBox = UIManager.ActiveScreen?.GetWidget<ChatBox>() ?? UIManager.ActiveScreen?.GetWidget<ResizableChatBox>();

var panel = chatBox?.ChatWindowPanel;
if (panel is null)
return;

Color color;
if (panel.PanelOverride is StyleBoxFlat styleBoxFlat)
color = styleBoxFlat.BackgroundColor;
else if (panel.TryGetStyleProperty<StyleBox>(PanelContainer.StylePropertyPanel, out var style)
&& style is StyleBoxFlat propStyleBoxFlat)
color = propStyleBoxFlat.BackgroundColor;
else
color = StyleNano.ChatBackgroundColor;

panel.PanelOverride = new StyleBoxFlat
{
BackgroundColor = color.WithAlpha(opacity)
};
}

public void SetMainChat(bool setting)
{
if (UIManager.ActiveScreen == null)
Expand Down Expand Up @@ -770,7 +803,7 @@ private void OnChatMessage(MsgChatMessage message)
ProcessChatMessage(msg);

if ((msg.Channel & ChatChannel.AdminRelated) == 0 ||
_cfg.GetCVar(CCVars.ReplayRecordAdminChat))
_config.GetCVar(CCVars.ReplayRecordAdminChat))
{
_replayRecording.RecordClientMessage(msg);
}
Expand Down Expand Up @@ -830,7 +863,7 @@ public void ProcessChatMessage(ChatMessage msg, bool speechBubble = true)
break;

case ChatChannel.LOOC:
if (_cfg.GetCVar(CCVars.LoocAboveHeadShow))
if (_config.GetCVar(CCVars.LoocAboveHeadShow))
AddSpeechBubble(msg, SpeechBubble.SpeechType.Looc);
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Chat;
using Content.Client.Stylesheets;
using Content.Shared.Chat;
using Content.Shared.Input;
using Robust.Client.UserInterface.Controls;

Expand Down Expand Up @@ -44,6 +45,7 @@ public ChatInputBox()
StyleClasses = {"chatFilterOptionButton"}
};
Container.AddChild(FilterButton);
AddStyleClass(StyleNano.StyleClassChatSubPanel);
ChannelSelector.OnChannelSelect += UpdateActiveChannel;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
HorizontalExpand="True"
VerticalExpand="True"
MinSize="465 225">
<PanelContainer HorizontalExpand="True" VerticalExpand="True">
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat BackgroundColor="#25252ADD" />
</PanelContainer.PanelOverride>

<PanelContainer Name="ChatWindowPanel" Access="Public" HorizontalExpand="True" VerticalExpand="True"
StyleClasses="StyleNano.StyleClassChatPanel">
<BoxContainer Orientation="Vertical" SeparationOverride="4" HorizontalExpand="True" VerticalExpand="True">
<OutputPanel Name="Contents" HorizontalExpand="True" VerticalExpand="True" Margin="8 8 8 4" />
<controls:ChatInputBox HorizontalExpand="True" Name="ChatInput" Access="Public" Margin="2"/>
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Hands/Systems/HandsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ private void GetComponentState(EntityUid uid, HandsComponent hands, ref Componen

private void OnExploded(Entity<HandsComponent> ent, ref BeforeExplodeEvent args)
{
if (ent.Comp.DisableExplosionRecursion)
return;

foreach (var hand in ent.Comp.Hands.Values)
{
if (hand.HeldEntity is { } uid)
Expand Down
14 changes: 14 additions & 0 deletions Content.Server/Paper/PaperRandomStoryComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Content.Server.Paper;

/// <summary>
/// Adds randomly generated stories to Paper component
/// </summary>
[RegisterComponent, Access(typeof(PaperRandomStorySystem))]
public sealed partial class PaperRandomStoryComponent : Component
{
[DataField]
public List<string>? StorySegments;

[DataField]
public string StorySeparator = " ";
}
29 changes: 29 additions & 0 deletions Content.Server/Paper/PaperRandomStorySystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Content.Server.RandomMetadata;

namespace Content.Server.Paper;

public sealed class PaperRandomStorySystem : EntitySystem
{

[Dependency] private readonly RandomMetadataSystem _randomMeta = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<PaperRandomStoryComponent, MapInitEvent>(OnMapinit);
}

private void OnMapinit(Entity<PaperRandomStoryComponent> paperStory, ref MapInitEvent ev)
{
if (!TryComp<PaperComponent>(paperStory, out var paper))
return;

if (paperStory.Comp.StorySegments == null)
return;

var story = _randomMeta.GetRandomFromSegments(paperStory.Comp.StorySegments, paperStory.Comp.StorySeparator);

paper.Content += $"\n{story}";
}
}
6 changes: 3 additions & 3 deletions Content.Server/RandomMetadata/RandomMetadataSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Dataset;
using Content.Shared.Dataset;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
Expand Down Expand Up @@ -48,8 +48,8 @@ public string GetRandomFromSegments(List<string> segments, string? separator)
foreach (var segment in segments)
{
outputSegments.Add(_prototype.TryIndex<DatasetPrototype>(segment, out var proto)
? _random.Pick(proto.Values)
: segment);
? Loc.GetString(_random.Pick(proto.Values))
: Loc.GetString(segment));
}
return string.Join(separator, outputSegments);
}
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Wires/WiresComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;

namespace Content.Server.Wires;

Expand All @@ -15,7 +16,7 @@ public sealed partial class WiresComponent : Component
/// The layout ID of this entity's wires.
/// </summary>
[DataField(required: true)]
public string LayoutId { get; set; } = default!;
public ProtoId<WireLayoutPrototype> LayoutId { get; set; } = default!;

/// <summary>
/// The serial number of this board. Randomly generated upon start,
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Anomaly/Components/AnomalyComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ public sealed partial class AnomalyComponent : Component
/// The minimum interval between pulses.
/// </summary>
[DataField]
public TimeSpan MinPulseLength = TimeSpan.FromMinutes(1);
public TimeSpan MinPulseLength = TimeSpan.FromMinutes(2);

/// <summary>
/// The maximum interval between pulses.
/// </summary>
[DataField]
public TimeSpan MaxPulseLength = TimeSpan.FromMinutes(2);
public TimeSpan MaxPulseLength = TimeSpan.FromMinutes(4);

/// <summary>
/// A percentage by which the length of a pulse might vary.
Expand Down
7 changes: 7 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,13 @@ public static readonly CVarDef<int>
* Accessibility
*/

/// <summary>
/// Chat window opacity slider, controlling the alpha of the chat window background.
/// Goes from to 0 (completely transparent) to 1 (completely opaque)
/// </summary>
public static readonly CVarDef<float> ChatWindowOpacity =
CVarDef.Create("accessibility.chat_window_transparency", 0.85f, CVar.CLIENTONLY | CVar.ARCHIVE);

/// <summary>
/// Toggle for visual effects that may potentially cause motion sickness.
/// Where reasonable, effects affected by this CVar should use an alternate effect.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public sealed partial class TypingIndicatorPrototype : IPrototype
public Vector2 Offset = new(0, 0);

[DataField("shader")]
public string Shader = "unshaded";
public string Shader = "shaded";

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Construction.Conditions;
using Content.Shared.Construction.Conditions;
using Content.Shared.Whitelist;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
Expand Down
Loading

0 comments on commit c7c39c3

Please sign in to comment.