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

[Port] Log Actions In The Chat / Логирование Действий В Чат #57

Merged
merged 4 commits into from
Sep 15, 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
1 change: 1 addition & 0 deletions Content.Client/Options/UI/Tabs/MiscTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<CheckBox Name="ShowLoocAboveHeadCheckBox" Text="{Loc 'ui-options-show-looc-on-head'}" />
<CheckBox Name="FancySpeechBubblesCheckBox" Text="{Loc 'ui-options-fancy-speech'}" />
<CheckBox Name="FancyNameBackgroundsCheckBox" Text="{Loc 'ui-options-fancy-name-background'}" />
<CheckBox Name="LogInChatCheckBox" Text="{Loc 'ui-options-log-in-chat'}" /> <!-- WD EDIT -->
<Label Text="{Loc 'ui-options-general-cursor'}"
FontColorOverride="{xNamespace:Static s:StyleNano.NanoGold}"
StyleClasses="LabelKeyText"/>
Expand Down
8 changes: 7 additions & 1 deletion Content.Client/Options/UI/Tabs/MiscTab.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using Content.Client.UserInterface.Screens;
using Content.Shared._White;
using Content.Shared.CCVar;
using Content.Shared.HUD;
using Robust.Client.AutoGenerated;
Expand Down Expand Up @@ -80,6 +81,7 @@ public MiscTab()
ScreenShakeIntensitySlider.OnValueChanged += OnScreenShakeIntensitySliderChanged;
// ToggleWalk.OnToggled += OnCheckBoxToggled;
StaticStorageUI.OnToggled += OnCheckBoxToggled;
LogInChatCheckBox.OnToggled += OnCheckBoxToggled; // WD EDIT

HudThemeOption.SelectId(_hudThemeIdToIndex.GetValueOrDefault(_cfg.GetCVar(CVars.InterfaceTheme), 0));
DiscordRich.Pressed = _cfg.GetCVar(CVars.DiscordEnabled);
Expand All @@ -98,6 +100,7 @@ public MiscTab()
ScreenShakeIntensitySlider.Value = _cfg.GetCVar(CCVars.ScreenShakeIntensity) * 100f;
// ToggleWalk.Pressed = _cfg.GetCVar(CCVars.ToggleWalk);
StaticStorageUI.Pressed = _cfg.GetCVar(CCVars.StaticStorageUI);
LogInChatCheckBox.Pressed = _cfg.GetCVar(WhiteCVars.LogInChat); // WD EDIT


ApplyButton.OnPressed += OnApplyButtonPressed;
Expand Down Expand Up @@ -154,6 +157,7 @@ private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
_cfg.SetCVar(CCVars.ScreenShakeIntensity, ScreenShakeIntensitySlider.Value / 100f);
// _cfg.SetCVar(CCVars.ToggleWalk, ToggleWalk.Pressed);
_cfg.SetCVar(CCVars.StaticStorageUI, StaticStorageUI.Pressed);
_cfg.SetCVar(WhiteCVars.LogInChat, LogInChatCheckBox.Pressed); // WD EDIT

if (HudLayoutOption.SelectedMetadata is string opt)
{
Expand Down Expand Up @@ -184,6 +188,7 @@ private void UpdateApplyButton()
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);
var isLogInChatCheckBoxSame = LogInChatCheckBox.Pressed == _cfg.GetCVar(WhiteCVars.LogInChat); // WD EDIT

ApplyButton.Disabled = isHudThemeSame &&
isLayoutSame &&
Expand All @@ -202,7 +207,8 @@ private void UpdateApplyButton()
isChatWindowOpacitySame &&
isScreenShakeIntensitySame &&
// isToggleWalkSame &&
isStaticStorageUISame;
isStaticStorageUISame &&
isLogInChatCheckBoxSame; // WD EDIT
}

}
Expand Down
40 changes: 40 additions & 0 deletions Content.Client/Popups/PopupSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Linq;
using Content.Client.UserInterface.Systems.Chat;
using Content.Shared._White;
using Content.Shared.Chat;
using Content.Shared.Examine;
using Content.Shared.GameTicking;
using Content.Shared.Popups;
Expand Down Expand Up @@ -40,6 +43,18 @@ public sealed class PopupSystem : SharedPopupSystem
public const float MaximumPopupLifetime = 5f;
public const float PopupLifetimePerCharacter = 0.04f;

// WD EDIT START
private static readonly Dictionary<PopupType, string> FontSizeDict = new()
{
{ PopupType.Medium, "12" },
{ PopupType.MediumCaution, "12" },
{ PopupType.Large, "15" },
{ PopupType.LargeCaution, "15" }
};

private bool _shouldLogInChat;
// WD EDIT END

public override void Initialize()
{
SubscribeNetworkEvent<PopupCursorEvent>(OnPopupCursorEvent);
Expand All @@ -57,6 +72,11 @@ public override void Initialize()
_examine,
_transform,
this));

// WD EDIT START
_shouldLogInChat = _configManager.GetCVar(WhiteCVars.LogInChat);
_configManager.OnValueChanged(WhiteCVars.LogInChat, log => { _shouldLogInChat = log; });
// WD EDIT END
}

public override void Shutdown()
Expand Down Expand Up @@ -86,6 +106,26 @@ private void PopupMessage(string? message, PopupType type, EntityCoordinates coo
};

_aliveWorldLabels.Add(label);

// WD EDIT START
if (!_shouldLogInChat)
return;

if (_playerManager.LocalEntity == null)
return;

if (!_examine.InRangeUnOccluded(_playerManager.LocalEntity.Value, coordinates, 10))
return;

var fontsize = FontSizeDict.GetValueOrDefault(type, "10");
var fontcolor = type is PopupType.LargeCaution or PopupType.MediumCaution or PopupType.SmallCaution
? "#C62828"
: "#AEABC4";

var wrappedMessage = $"[font size={fontsize}][color={fontcolor}]{message}[/color][/font]";
var chatMsg = new ChatMessage(ChatChannel.Emotes, message, wrappedMessage, GetNetEntity(EntityUid.Invalid), null);
_uiManager.GetUIController<ChatUIController>().ProcessChatMessage(chatMsg);
// WD EDIT END
}

#region Abstract Method Implementations
Expand Down
9 changes: 8 additions & 1 deletion Content.Shared/_White/CVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public sealed class WhiteCVars

public static readonly CVarDef<double> AspectChance =
CVarDef.Create("aspects.chance", 0.1d, CVar.SERVERONLY);

#endregion

#region Keybind
Expand All @@ -31,4 +31,11 @@ public static readonly CVarDef<string>
ServerCulture = CVarDef.Create("white.culture", "ru-RU", CVar.REPLICATED | CVar.SERVER);

#endregion

#region OptionsMisc

public static readonly CVarDef<bool> LogInChat =
CVarDef.Create("white.log_in_chat", true, CVar.CLIENT | CVar.ARCHIVE | CVar.REPLICATED);

#endregion
}
3 changes: 2 additions & 1 deletion Resources/Locale/en-US/_white/escape-menu/options-menu.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ui-options-function-open-emotions-menu = Open emotions menu
ui-options-log-in-chat = Log actions in the chat

ui-options-function-open-emotions-menu = Open emotions menu
ui-options-function-look-up = Look up/Take aim
ui-options-function-auto-get-up = Automatically get up after falling
ui-options-function-hold-look-up = Hold down the key to aim
3 changes: 2 additions & 1 deletion Resources/Locale/ru-RU/_white/escape-menu/options-menu.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ui-options-function-open-emotions-menu = Открыть меню эмоций
ui-options-log-in-chat = Логировать действия в чат

ui-options-function-open-emotions-menu = Открыть меню эмоций
ui-options-function-look-up = Присмотреться/Прицелиться
ui-options-function-auto-get-up = Автоматически вставать при падении
ui-options-function-hold-look-up = Удерживать клавишу для прицеливания
Loading