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

Cluwne comm #2153

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Shared.CCVar;
using Content.Shared.Chat;
using Content.Shared.Communications;
using Robust.Client.UserInterface;
using Robust.Shared.Configuration;
using Robust.Shared.Timing;

namespace Content.Client.SS220.CluwneComms.UI
{
public sealed class CluwneCommunicationsConsoleBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IConfigurationManager _cfg = default!;

[ViewVariables]
private CluwneCommunicationsConsoleMenu? _menu;

public CluwneCommunicationsConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
base.Open();

_menu = this.CreateWindow<CluwneCommunicationsConsoleMenu>();
_menu.OnAnnounce += AnnounceButtonPressed;
}

public void AnnounceButtonPressed(string message)
{
var maxLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength);
var msg = SharedChatSystem.SanitizeAnnouncement(message, maxLength);
SendMessage(new CommunicationsConsoleAnnounceMessage(msg));
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is not CommunicationsConsoleInterfaceState commsState)
return;

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:ui220="clr-namespace:Content.Client.SS220.UserInterface"
Title="{Loc 'cluwne-comms-console-menu-title'}"
MinSize="400 225">
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True" Margin="5">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="5">
<BoxContainer Orientation="Vertical" HorizontalExpand="True" Margin="5">
<BoxContainer Orientation="Vertical" HorizontalExpand="True" Margin="5">
<ui220:ExtendedTextEdit Name="CodeInput" HorizontalExpand="True" VerticalExpand="True" Margin="0 0 0 5" MinHeight="100" />
</BoxContainer>
<BoxContainer Orientation="Vertical" HorizontalExpand="True" Margin="5">
<ui220:ExtendedTextEdit Name="InstructionInput" HorizontalExpand="True" VerticalExpand="True" Margin="0 0 0 5" MinHeight="100" />
<OptionButton Name="AlertLevelButton" StyleClasses="OpenRight" Access="Public" />
<Button Name="CodeButton" Text="{Loc 'cluwne-comms-console-menu-code-button'}" StyleClasses="OpenLeft" Access="Public" />
</BoxContainer>
</BoxContainer>
<BoxContainer Orientation="Vertical" HorizontalExpand="True" Margin="5">
<ui220:ExtendedTextEdit Name="MessageInput" HorizontalExpand="True" VerticalExpand="True" Margin="0 0 0 5" MinHeight="100" />
<Button Name="AnnounceButton" Text="{Loc 'cluwne-comms-console-menu-announcement-button'}" StyleClasses="OpenLeft" Access="Public" />
</BoxContainer>
</BoxContainer>
</BoxContainer>
</controls:FancyWindow>
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using System.Globalization;
using Content.Client.UserInterface.Controls;
using Content.Shared.CCVar;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Client.SS220.CluwneComms.UI
{
[GenerateTypedNameReferences]
public sealed partial class CluwneCommunicationsConsoleMenu : FancyWindow
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly ILocalizationManager _loc = default!;

public bool CanAnnounce;
public bool CanAllert;
public bool AlertLevelSelectable;
public bool CountdownStarted;
public string CurrentLevel = string.Empty;
public TimeSpan? CountdownEnd;

public event Action? OnEmergencyLevel;
public event Action<string>? OnAlertLevel;
public event Action<string>? OnAnnounce;
public CluwneCommunicationsConsoleMenu()
{
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);

// SS220 Text Edit Limits begin
//MessageInput.Placeholder = new Rope.Leaf(_loc.GetString("comms-console-menu-announcement-placeholder"));

//var maxAnnounceLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength);
//MessageInput.OnTextChanged += (args) =>
MessageInput.Edit.Placeholder = new Rope.Leaf(_loc.GetString("comms-console-menu-announcement-placeholder"));

var maxAnnounceLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength);
MessageInput.MaxLength = maxAnnounceLength;
MessageInput.Edit.OnTextChanged += (args) =>
// SS220 Text Edit Limits end
{
if (args.Control.TextLength > maxAnnounceLength)
{
AnnounceButton.Disabled = true;
AnnounceButton.ToolTip = Loc.GetString("comms-console-message-too-long");
}
else
{
AnnounceButton.Disabled = !CanAnnounce;
AnnounceButton.ToolTip = null;
}
};

AnnounceButton.OnPressed += _ => OnAnnounce?.Invoke(Rope.Collapse(MessageInput.TextRope));
AnnounceButton.Disabled = !CanAnnounce;

AlertLevelButton.OnItemSelected += args =>
{
var metadata = AlertLevelButton.GetItemMetadata(args.Id);
if (metadata != null && metadata is string cast)
{
OnAlertLevel?.Invoke(cast);
}
};


AlertLevelButton.Disabled = !AlertLevelSelectable;
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
UpdateCountdown();
}

public void UpdateCountdown()
{
/*
if (!CountdownStarted)
{
CountdownLabel.SetMessage(string.Empty);
return;
}

var diff = MathHelper.Max((CountdownEnd - _timing.CurTime) ?? TimeSpan.Zero, TimeSpan.Zero);

var infoText = Loc.GetString($"comms-console-menu-time-remaining",
("time", diff.ToString(@"hh\:mm\:ss", CultureInfo.CurrentCulture)));
CountdownLabel.SetMessage(infoText);
*/
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Content.Server.UserInterface;
using Content.Shared.Communications;
using Content.Shared.SS220.CluwneCommunications;
using Robust.Shared.Audio;

namespace Content.Server.SS220.CluwneCommunications
{
[RegisterComponent]
public sealed partial class CluwneCommunicationsConsoleComponent : SharedCluwneCommunicationsConsoleComponent
{
public float UIUpdateAccumulator = 0f;

/// <summary>
/// Remaining cooldown between making announcements.
/// </summary>
[ViewVariables]
[DataField]
public float AnnouncementCooldownRemaining;

/// <summary>
/// Fluent ID for the announcement title
/// If a Fluent ID isn't found, just uses the raw string
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField(required: true)]
public LocId Title = "comms-console-announcement-title-station";

/// <summary>
/// Announcement color
/// </summary>
[ViewVariables]
[DataField]
public Color Color = Color.Gold;

/// <summary>
/// Time in seconds between announcement delays on a per-console basis
/// </summary>
[ViewVariables]
[DataField]
public int Delay = 90;

/// <summary>
/// Time in seconds of announcement cooldown when a new console is created on a per-console basis
/// </summary>
[ViewVariables]
[DataField]
public int InitialDelay = 30;

/// <summary>
/// Announce on all grids (for nukies)
/// </summary>
[DataField]
public bool Global = false;

/// <summary>
/// Announce sound file path
/// </summary>
[DataField]
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Announcements/announce.ogg");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Robust.Shared.Audio;
using Robust.Shared.Serialization;

namespace Content.Shared.SS220.CluwneCommunications
{
[Virtual]
public sealed partial class SharedCluwneCommunicationsConsoleComponent : Component
{
}
[Serializable, NetSerializable]
public sealed class CluwneCommunicationsConsoleInterfaceState(bool canAnnounce) : BoundUserInterfaceState
{
public readonly bool CanAnnounce = canAnnounce;
}

[Serializable, NetSerializable]
public sealed class CluwneCommunicationsConsoleAnnounceMessage(string message) : BoundUserInterfaceMessage
{
public readonly string Message = message;
}


[Serializable, NetSerializable]
public enum CluwneCommunicationsConsoleUiKey : byte
{
Key
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Content.Shared.Communications;
using Robust.Shared.Timing;
using Robust.Shared.GameObjects;
using static Content.Shared.Access.Components.AccessOverriderComponent;
using System.ComponentModel;

namespace Content.Shared.SS220.CluwneCommunications
{
public sealed class SharedCluwneCommunicationssConsoleSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!;

public override void Initialize()
{
SubscribeLocalEvent<CluwneCommunicationsConsoleComponent, MapInitEvent>(OnMapInit);
}
public void OnMapInit(Entity<CluwneCommunicationsConsoleComponent> ent, ref MapInitEvent args)
{
ent.Comp.AnnouncementCooldownRemaining = _timing.CurTime + ent.Comp.Delay;
ent.Comp.AlertCooldownRemaining = _timing.CurTime + ent.Comp.Delay;
ent.Comp.CanAnnounce = false;
ent.Comp.CanAlert = false;
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<CluwneCommunicationsConsoleComponent>();
while (query.MoveNext(out var uid, out var comp))
{
if (!comp.CanAnnounce && _timing.CurTime >= comp.AnnouncementCooldownRemaining)
{
comp.CanAnnounce = true;
UpdateUI(uid, comp);
}

if (!comp.CanAlert && _timing.CurTime >= comp.AlertCooldownRemaining)
{
comp.CanAlert = true;
UpdateUI(uid, comp);
}
}
}

private void UpdateUI(EntityUid ent, CluwneCommunicationsConsoleComponent comp)
{
CluwneCommunicationsConsoleInterfaceState newState = new CluwneCommunicationsConsoleInterfaceState(comp.CanAnnounce);

_uiSystem.SetUiState(ent, CommunicationsConsoleUiKey.Key, newState);
}
}
}
4 changes: 4 additions & 0 deletions Resources/Audio/SS220/Announcements/attributions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- files: ["cluwne_comm_announce.ogg"]
license: "CC0-1.0"
copyright: "Downloaded from free library, modified by SkaldetSkaeg"
source: "https://sound-pack.net/imitaciya-loshadinogo-rzhaniya-na-trube-2-zvuk-mp3"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# User interface
cluwne-comms-console-menu-title = Консоль смешной связи
cluwne-comms-console-menu-announcement-placeholder = Текст смешного объявления...
cluwne-comms-console-menu-code-placeholder = Текст смешного кода...
cluwne-comms-console-menu-instruction-placeholder = Текст смешной инструкции...
cluwne-comms-console-menu-code-button = Выставить смешной код
cluwne-comms-console-menu-announcement-button = Сделать веселое объявление
cluwne-comms-console-menu-call-shuttle = Вызвать
cluwne-comms-console-menu-recall-shuttle = Отозвать
# Popup
cluwne-comms-console-permission-denied = В доступе отказано
cluwne-comms-console-shuttle-unavailable = В настоящее время шаттл недоступен
# Placeholder values
cluwne-comms-console-announcement-sent-by = Отправитель
cluwne-comms-console-announcement-unknown-sender = Неизвестный
# Comms console variant titles
cluwne-comms-console-announcement-title-station = Консоль смешной связи
12 changes: 12 additions & 0 deletions Resources/Locale/ru-RU/ss220/joke-lerts-level.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
joke-lert-level-announcement = Внимание! Уровень шуток станции теперь { $name }! { $announcement }
joke-lert-level-unknown = Неизвестный.
joke-lert-level-unknown-instructions = Неизвестно.
joke-lert-level-gamma = Ржамма
joke-lert-level-gamma-announcement = Центральное командование объявило на станции уровень угрозы "Гамма". Служба безопасности должна постоянно иметь при себе оружие, гражданский персонал обязан немедленно обратиться к главам отделов для получения указаний к эвакуации. Службе Безопасности разрешено применение летальной силы в случае неповиновения.
joke-lert-level-gamma-instructions = Гражданский персонал обязан немедленно обратиться к главам отделов для получения указаний к эвакуации. Корпорация Nanotrasen заверяет вас - опасность скоро будет нейтрализована.
joke-lert-level-delta = Хехельта
joke-lert-level-delta-announcement = Станция находится под угрозой неминуемого уничтожения. Членам экипажа рекомендуется слушать глав отделов для получения дополнительной информации. Службе Безопасности приказано работать по протоколу Дельта.
joke-lert-level-delta-instructions = Членам экипажа необходимо слушать глав отделов для получения дополнительной информации. От этого зависит ваше здоровье и безопасность.
joke-lert-level-epsilon = Пепсилон
joke-lert-level-epsilon-announcement = Центральное командование объявило на станции уровень угрозы "Эпсилон". Все контракты расторгнуты. Спасибо, что выбрали Nanotrasen.
joke-lert-level-epsilon-instructions = Все контракты расторгнуты.
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,15 @@
- type: ComputerBoard
prototype: ComputerShuttleSalvage
- type: StealTarget
stealGroup: SalvageShuttleConsoleCircuitboard
stealGroup: SalvageShuttleConsoleCircuitboard

- type: entity
parent: BaseComputerCircuitboard
id: CluwneCommsComputerCircuitboard
name: cluwne communications computer board
description: A computer printed circuit board for a joke communications console.
components:
- type: Sprite
state: cpu_command
- type: ComputerBoard
prototype: ComputerCluwneComms
Loading
Loading