Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Atualização no console de comunicações #129

Merged
merged 22 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8f12ce2
Tira o acesso de manutenção dos grayti- quero dizer, assistente
AgentePanela Aug 24, 2024
82630c5
bota o botao emergency maint no console de comunicação
AgentePanela Aug 24, 2024
bb106a8
Traduz o texto de tempo restante
AgentePanela Aug 24, 2024
b1648f9
Atualiza a UI do console de comunicações e adiciona lang
AgentePanela Aug 24, 2024
cd40cfc
TENTA criar um novo estilo de menu
AgentePanela Aug 24, 2024
d858498
Arruma o botao amarelo
AgentePanela Aug 24, 2024
c0191e6
arruma pequeno texto
AgentePanela Aug 24, 2024
a15d35d
faz todas as maints comun se fecharem quando apertar o botao
AgentePanela Aug 25, 2024
8ccbfdf
Arrumas algumas coisas e prepara outras
AgentePanela Aug 25, 2024
57b1f4c
Adiciona motivo pra evacuação
AgentePanela Aug 25, 2024
ca26454
Faz o botao de enviar mensagem pra cc funcionar, reason na evac e out…
AgentePanela Aug 25, 2024
5c508bf
changelog yayy
AgentePanela Aug 25, 2024
4e0acb3
Merge branch 'rbertoche:pirata' into maint-emergency
AgentePanela Aug 25, 2024
c34deb8
Remove codigo comentado
AgentePanela Aug 25, 2024
b23e564
Merge branch 'maint-emergency' of https://github.com/AgentePanela/est…
AgentePanela Aug 25, 2024
a30295b
Update Content.Client/Communications/UI/CommunicationsConsoleBoundUse…
DoutorWhite Aug 25, 2024
6ecfbc6
Update Content.Server/Communications/CommunicationsConsoleComponent.cs
DoutorWhite Aug 25, 2024
555c5df
Update Content.Server/Communications/CommunicationsConsoleSystem.cs
DoutorWhite Aug 25, 2024
c0940b5
Update Content.Server/Communications/CommunicationsConsoleSystem.cs
DoutorWhite Aug 25, 2024
2d4c220
Update Content.Server/Communications/CommunicationsConsoleSystem.cs
DoutorWhite Aug 25, 2024
18bf97a
Update Content.Shared/Communications/SharedCommunicationsConsoleCompo…
DoutorWhite Aug 25, 2024
3263b7c
Update Content.Server/Communications/CommunicationsConsoleSystem.cs
DoutorWhite Aug 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ public void BroadcastButtonPressed(string message)
SendMessage(new CommunicationsConsoleBroadcastMessage(message));
}

public void MaintEmergencyButtonPressed()
{
SendMessage(new CommunicationsConsoleToggleEmergencyMaintMessage());
}

public void CentCommButtonPressed()
{
SendMessage(new CommunicationsConsoleCentCommButtonMessage());
}

public void CallShuttle()
{
SendMessage(new CommunicationsConsoleCallEmergencyShuttleMessage());
Expand Down
23 changes: 19 additions & 4 deletions Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,30 @@
Title="{Loc 'comms-console-menu-title'}"
MinSize="400 225">
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True" Margin="5">
<TextEdit Name="MessageInput" HorizontalExpand="True" VerticalExpand="True" Margin="0 0 0 5" MinHeight="100" />
<Label Text="{Loc 'comms-console-menu-label-announcements'}" VerticalExpand="True"/>
<TextEdit Name="MessageInput" HorizontalExpand="True" VerticalExpand="True" Margin="0 0 0 5" MinHeight="75" />
<Button Name="AnnounceButton" Text="{Loc 'comms-console-menu-announcement-button'}" StyleClasses="OpenLeft" Access="Public" />
<Button Name="BroadcastButton" Text="{Loc 'comms-console-menu-broadcast-button'}" StyleClasses="OpenLeft" Access="Public" />
<Button Name="BroadcastButton" Text="{Loc 'comms-console-menu-broadcast-button'}" StyleClasses="OpenRight" Access="Public" />

<OptionButton Name="AlertLevelButton" StyleClasses="OpenRight" Access="Public" />
<Label Text="{Loc 'comms-console-menu-label-alerts'}" VerticalExpand="True"/>
<OptionButton Name="AlertLevelButton" Access="Public" />

<Control MinSize="10 10" />

<Label Text="{Loc 'comms-console-menu-label-others'}" VerticalExpand="True"/>
<Button Name="CentCommButton" Text="{Loc 'comms-console-menu-message-centcomm'}" StyleClasses="ButtonColorGreen" Access="Public" />
<Button Name="MaintEmergencyButton" Text="{Loc 'comms-console-menu-emergency-maint'}" StyleClasses="ButtonColorYellow" Access="Public" />
<!-- <Button Name="NuclearCodeButton" Text="{Loc 'comms-console-menu-nuclear-code'}" StyleClasses="ButtonColorRed" Access="Public" /> Se quiserem adicionar isso, ta ai-->
<Button Name="EmergencyShuttleButton" Text="Placeholder Text" StyleClasses="ButtonColorRed" Access="Public" />
<RichTextLabel Name="CountdownLabel" VerticalExpand="True" />
<Button Name="EmergencyShuttleButton" Text="Placeholder Text" Access="Public" />
<!-- Footer (microwave copy) - - - por algum motivo quebra o codigo
<BoxContainer Orientation="Vertical">
<PanelContainer StyleClasses="LowDivider" />
<BoxContainer Orientation="Horizontal" Margin="10 2 5 0" VerticalAlignment="Bottom">
<Label Text="{Loc 'comms-console-menu-footer-left'}" StyleClasses="WindowFooterText" />
<Label Text="{Loc 'comms-console-menu-footer-right'}" StyleClasses="WindowFooterText"
HorizontalAlignment="Right" HorizontalExpand="True" Margin="0 0 5 0" />
<TextureRect StyleClasses="NTLogoDark" Stretch="KeepAspectCentered" VerticalAlignment="Center" HorizontalAlignment="Right" SetSize="19 19"/>
</BoxContainer>-->
</BoxContainer>
</controls:FancyWindow>
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public CommunicationsConsoleMenu(CommunicationsConsoleBoundUserInterface owner)
};
AlertLevelButton.Disabled = !owner.AlertLevelSelectable;

MaintEmergencyButton.OnPressed += (_) => Owner.MaintEmergencyButtonPressed();

CentCommButton.OnPressed += (_) => Owner.CentCommButtonPressed();

EmergencyShuttleButton.OnPressed += (_) => Owner.EmergencyShuttleButtonPressed();
EmergencyShuttleButton.Disabled = !owner.CanCall;

Expand Down Expand Up @@ -113,7 +117,7 @@ public void UpdateCountdown()
}

EmergencyShuttleButton.Text = Loc.GetString("comms-console-menu-recall-shuttle");
CountdownLabel.SetMessage($"Time remaining\n{Owner.Countdown.ToString()}s");
CountdownLabel.SetMessage($"Tempo restante:\n{Owner.Countdown.ToString()}s");
}

public override void Close()
Expand Down
28 changes: 28 additions & 0 deletions Content.Client/Stylesheets/StyleNano.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ public sealed class StyleNano : StyleBase

public static readonly Color ButtonColorDefault = Color.FromHex("#464966");
public static readonly Color ButtonColorDefaultRed = Color.FromHex("#D43B3B");
public static readonly Color ButtonColorDefaultYellow = Color.FromHex("#9c812c");
public static readonly Color ButtonColorHovered = Color.FromHex("#575b7f");
public static readonly Color ButtonColorHoveredRed = Color.FromHex("#DF6B6B");
public static readonly Color ButtonColorHoveredYellow = Color.FromHex("#a88b4f");
public static readonly Color ButtonColorPressed = Color.FromHex("#3e6c45");
public static readonly Color ButtonColorDisabled = Color.FromHex("#30313c");

Expand Down Expand Up @@ -145,6 +147,7 @@ public sealed class StyleNano : StyleBase
//Buttons
public const string StyleClassCrossButtonRed = "CrossButtonRed";
public const string StyleClassButtonColorRed = "ButtonColorRed";
public const string StyleClassButtonColorYellow = "ButtonColorYellow";
public const string StyleClassButtonColorGreen = "ButtonColorGreen";

public static readonly Color ChatBackgroundColor = Color.FromHex("#25252ADD");
Expand Down Expand Up @@ -1176,6 +1179,13 @@ public StyleNano(IResourceCache resCache) : base(resCache)
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorDefaultRed),
}),

new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassYellowTopButton}, null, new[] {Button.StylePseudoClassNormal}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorDefaultYellow),
}),

new StyleRule(
new SelectorElement(typeof(MenuButton), null, null, new[] {Button.StylePseudoClassNormal}),
new[]
Expand Down Expand Up @@ -1204,6 +1214,13 @@ public StyleNano(IResourceCache resCache) : base(resCache)
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorHoveredRed),
}),

new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassYellowTopButton}, null, new[] {Button.StylePseudoClassHover}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorHoveredYellow),
}),

new StyleRule(
new SelectorElement(typeof(Label), new[] {MenuButton.StyleClassLabelTopButton}, null, null),
new[]
Expand Down Expand Up @@ -1463,6 +1480,17 @@ public StyleNano(IResourceCache resCache) : base(resCache)
.Prop(Control.StylePropertyModulateSelf, ButtonColorHoveredRed),
// ---

// Yellow Button ---
Element<Button>().Class("ButtonColorYellow")
.Prop(Control.StylePropertyModulateSelf, ButtonColorDefaultYellow),

Element<Button>().Class("ButtonColorYellow").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorDefaultYellow),

Element<Button>().Class("ButtonColorYellow").Pseudo(ContainerButton.StylePseudoClassHover)
.Prop(Control.StylePropertyModulateSelf, ButtonColorHoveredYellow),
// ---

// Green Button ---
Element<Button>().Class("ButtonColorGreen")
.Prop(Control.StylePropertyModulateSelf, ButtonColorGoodDefault),
Expand Down
6 changes: 6 additions & 0 deletions Content.Client/UserInterface/Controls/MenuButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ public sealed class MenuButton : ContainerButton
[Dependency] private readonly IInputManager _inputManager = default!;
public const string StyleClassLabelTopButton = "topButtonLabel";
public const string StyleClassRedTopButton = "topButtonLabel";
public const string StyleClassYellowTopButton = "topButtonLabel";


private static readonly Color ColorNormal = Color.FromHex("#7b7e9e");
private static readonly Color ColorRedNormal = Color.FromHex("#FEFEFE");
private static readonly Color ColorYellowNormal = Color.FromHex("#FFFF00");
private static readonly Color ColorHovered = Color.FromHex("#9699bb");
private static readonly Color ColorRedHovered = Color.FromHex("#FFFFFF");
private static readonly Color ColorYellowHovered = Color.FromHex("#FFFF00");
private static readonly Color ColorPressed = Color.FromHex("#789B8C");

private const float VertPad = 8f;
private Color NormalColor => HasStyleClass(StyleClassRedTopButton) ? ColorRedNormal : ColorNormal;
private Color HoveredColor => HasStyleClass(StyleClassRedTopButton) ? ColorRedHovered : ColorHovered;
private Color NormalColorYellow => HasStyleClass(StyleClassYellowTopButton) ? ColorYellowNormal : NormalColorYellow;
private Color HoveredColorYellow => HasStyleClass(StyleClassYellowTopButton) ? ColorYellowHovered : ColorHovered;

private BoundKeyFunction _function;
private readonly BoxContainer _root;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public sealed partial class CommunicationsConsoleComponent : SharedCommunication
[DataField]
public int InitialDelay = 30;

[DataField]
public double ToggleAcessTimer;

[DataField]
public double ToggleAcessDelay = 5;

/// <summary>
/// Can call or recall the shuttle
/// </summary>
Expand Down
104 changes: 100 additions & 4 deletions Content.Server/Communications/CommunicationsConsoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
using Content.Shared.Popups;
using Robust.Server.GameObjects;
using Robust.Shared.Configuration;
using Content.Shared.Doors.Components; //importa as portas iradas
using Content.Server.Doors.Systems; //importa o sistema das airlock pra botar o modo de emergencia
using System.Collections; //parao array de prototypes
using Robust.Shared.Audio;
using Content.Server.Administration;
using Robust.Shared.Player;
using Content.Server.Chat.Managers; //pra falar com centcom
using Robust.Shared.Timing; // para cooldown

namespace Content.Server.Communications
{
Expand All @@ -42,9 +50,22 @@
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly AirlockSystem _airlock = default!;
[Dependency] private readonly QuickDialogSystem _quickDialog = default!; //cria dependencia na mensagem de popup igual eu tenho com a -----------
[Dependency] private readonly IChatManager _chatManager = default!; // avbiso admin
[Dependency] private readonly IGameTiming _timing = default!; // cooldown




private const float UIUpdateInterval = 5.0f;

// array dos prototypes que vao ficar em manutenção
private ArrayList _maintDoorPrototypeList = new ArrayList();

//audios ref
private static readonly SoundSpecifier? AnnouncementChime = new SoundPathSpecifier("/Audio/Misc/notice1.ogg");

public override void Initialize()
{
// All events that refresh the BUI
Expand All @@ -59,9 +80,16 @@
SubscribeLocalEvent<CommunicationsConsoleComponent, CommunicationsConsoleBroadcastMessage>(OnBroadcastMessage);
SubscribeLocalEvent<CommunicationsConsoleComponent, CommunicationsConsoleCallEmergencyShuttleMessage>(OnCallShuttleMessage);
SubscribeLocalEvent<CommunicationsConsoleComponent, CommunicationsConsoleRecallEmergencyShuttleMessage>(OnRecallShuttleMessage);
SubscribeLocalEvent<CommunicationsConsoleComponent, CommunicationsConsoleToggleEmergencyMaintMessage>(OnToggleEmergencyMaintMessage);
SubscribeLocalEvent<CommunicationsConsoleComponent, CommunicationsConsoleCentCommButtonMessage>(OnCentCommMessage);

// On console init, set cooldown
SubscribeLocalEvent<CommunicationsConsoleComponent, MapInitEvent>(OnCommunicationsConsoleMapInit);

// adicione os prototypes das portas que vao entrar em modo de emergencia aqui:
_maintDoorPrototypeList.Add("AirlockMaintGlassLocked");
_maintDoorPrototypeList.Add("AirlockMaintLocked");
_maintDoorPrototypeList.Add("AirlockMaintCommonLocked");
}

public override void Update(float frameTime)
Expand Down Expand Up @@ -297,9 +325,65 @@
_adminLogger.Add(LogType.DeviceNetwork, LogImpact.Low, $"{ToPrettyString(message.Actor):player} has sent the following broadcast: {message.Message:msg}");
}

private void OnCentCommMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleCentCommButtonMessage message)
{
if (!EntityManager.TryGetComponent(message.Actor, out ActorComponent? actor))
return;

var mob = message.Actor;
if (!CanUse(mob, uid))
{
_popupSystem.PopupEntity(Loc.GetString("comms-console-permission-denied"), uid, message.Actor);
return;
}
//dialogo
_quickDialog.OpenDialog(actor.PlayerSession, Loc.GetString("comms-console-menu-dialog-centcom-tittle"), Loc.GetString("comms-console-menu-dialog-centcom-message"), (string centMessage) =>
{
if (!centMessage.Equals("")) //se nao tiver vazio
{
_chatManager.SendAdminAnnouncement($"{ToPrettyString(mob):player}: Enviou mensagem para CENTCOM '{centMessage}'"); // mensagem de admin (muito uim usar pray)
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(mob):player} has sent a message to centcom, message: '{centMessage}'."); //log
_popupSystem.PopupEntity(Loc.GetString("comns-console-centcom-send"), uid, message.Actor);
return;
} //pop up avisando q ta vazio
_popupSystem.PopupEntity(Loc.GetString("comns-console-empty-input"), uid, message.Actor);
});
}

//função de alterar acesso de emergencia
private void OnToggleEmergencyMaintMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleToggleEmergencyMaintMessage message)
{
if ((_timing.CurTime.TotalSeconds - comp.ToggleAcessTimer) < comp.ToggleAcessDelay) //coldown
return;

var mob = message.Actor;
if (!CanUse(mob, uid))
{
_popupSystem.PopupEntity(Loc.GetString("comms-console-permission-denied"), uid, message.Actor);
return;
}
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(mob):player} has toggle the station maintance access."); //bota log de admin em ingles por que sou muito estadunidense slk

_chatSystem.DispatchStationAnnouncement(uid, Loc.GetString("comms-console-announcement-content-maint"), Loc.GetString("comms-console-announcement-title-station"), true, AnnouncementChime, colorOverride: comp.Color);

// itera as portas DO PROTOTYPE de maint da estação
var query = EntityQueryEnumerator<DoorComponent>();
while (query.MoveNext(out var doorUid, out var component))
{
if (!TryGetNetEntity(doorUid, out var netEntity)
|| !TryGetEntityData(netEntity.Value, out var entityUid, out var entityData)
|| !_maintDoorPrototypeList.Contains(entityData.EntityPrototype!.ID))

Check failure on line 375 in Content.Server/Communications/CommunicationsConsoleSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Invalid expression term '||'

Check failure on line 375 in Content.Server/Communications/CommunicationsConsoleSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Invalid expression term '||'
|| !TryComp<AirlockComponent>(doorUid, out var airlock)

Check failure on line 376 in Content.Server/Communications/CommunicationsConsoleSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

; expected

Check failure on line 376 in Content.Server/Communications/CommunicationsConsoleSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

; expected
continue;

_airlock.ToggleEmergencyAccess(doorUid, airlock);
}
comp.ToggleAcessTimer = _timing.CurTime.TotalSeconds;
}
private void OnCallShuttleMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleCallEmergencyShuttleMessage message)
{
if (!CanCallOrRecall(comp))
if (!EntityManager.TryGetComponent(message.Actor, out ActorComponent? actor)
|| !CanCallOrRecall(comp))
return;

var mob = message.Actor;
Expand All @@ -318,8 +402,18 @@
return;
}

_roundEndSystem.RequestRoundEnd(uid);
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(mob):player} has called the shuttle.");
// dialogo
_quickDialog.OpenDialog(actor.PlayerSession, Loc.GetString("comms-console-menu-dialog-shuttle-tittle"), Loc.GetString("comms-console-menu-dialog-shuttle-message"), (string reason) =>
{
if (!reason.Equals(""))
{
_roundEndSystem.RequestRoundEnd(uid, text: "round-end-system-shuttle-called-announcement-with-reason", name: "comms-console-announcement-title-station", hasReason: true, reason: reason);
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(mob):player} has called the shuttle with reason '{reason}'.");
return;
}
_roundEndSystem.RequestRoundEnd(uid, name: "comms-console-announcement-title-station");
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(mob):player} has called the shuttle.");
});
}

private void OnRecallShuttleMessage(EntityUid uid, CommunicationsConsoleComponent comp, CommunicationsConsoleRecallEmergencyShuttleMessage message)
Expand All @@ -333,11 +427,13 @@
return;
}

_roundEndSystem.CancelRoundEndCountdown(uid);
_roundEndSystem.CancelRoundEndCountdown(uid, name: "comms-console-announcement-title-station");
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(message.Actor):player} has recalled the shuttle.");
}
}



/// <summary>
/// Raised on announcement
/// </summary>
Expand Down
Loading
Loading