* init * fax translate * translate * translate cargo panel * road map translate * Fix cargo panel | fix bot craft translate * fix, steal objectives translate * do not break my not localized fax! * fix * radio guide translate * Better DefaultRules * Translate Criminal Records * Space luw fully translate excluding CrimeList(need to rework) * Some Guidebook translate * Перевод глоссария, некоторые термины были переписанны под РУ комьюнити игры, некоторые к сожелению остались прежними * Fix * fix, translate * Обновил структуру SpeakOnUIClosed, пофиксил перевод автоматов * update and fix * fully translate * fix * not fail but warn * fix * fix2 * фикс уже переведённого дерьма от корвахов * Добавил термин подов в глоссарий * roles translate fix * Сикей в глоссарий * Delete Resources/Locale/ru-RU/_sunrise/info/character-info.ftl * remove cluster from pool * new translation * fully translate borgs * some fixes * Mr.Chang moment * upd * upd * upd * hotfix * big fix * fix some hardcode lang * oh no shitcode language * some translation * some actions| admin commands translate start * some new translation * fully translate commands | figurines | chat-repo * upd * second upd * upd * start translating items * some fixes * translate wackpack Из-за игры слов, я не смог нормально интерпритировать это дерьмо, так что пусть будет так, да теряется смысл и смешинка, но извините, я не смог как-то придумать игру слов * translate * debug translate * upd * Актуализация всего перевода * fix * fix * upd * some fixes | guns to his folders * upd * upd * upd * upd * upd * upd * Перевод меток атмоса * Последние коррективы * fix * some hardcode localization fix * fix * some fixes * stats entry fully translate * upd * some fixes * translate server side stats entry * fix * fix * fix2 * fix * upd * upd * fix * holly shit * fix * totaly feed * upd * upd * fix * upd * init * upd * upd * access in prototypes * Sunrise comments on code * my bad * я даун
124 lines
4.2 KiB
C#
124 lines
4.2 KiB
C#
using System.Linq;
|
|
using Content.Shared.Fax;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Client.UserInterface;
|
|
//Sunrise-Start
|
|
using System;
|
|
using System.Text.RegularExpressions;
|
|
//Sunrise-end
|
|
|
|
namespace Content.Client.Fax.UI;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class FaxWindow : DefaultWindow
|
|
{
|
|
public event Action? FileButtonPressed;
|
|
public event Action? PaperButtonPressed;
|
|
public event Action? CopyButtonPressed;
|
|
public event Action? SendButtonPressed;
|
|
public event Action? RefreshButtonPressed;
|
|
public event Action<string>? PeerSelected;
|
|
|
|
public bool OfficePaper = false;
|
|
|
|
public FaxWindow()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
|
|
PaperButtonPressed += OnPaperButtonPressed;
|
|
|
|
FileButton.OnPressed += _ => FileButtonPressed?.Invoke();
|
|
PaperButton.OnPressed += _ => PaperButtonPressed?.Invoke();
|
|
CopyButton.OnPressed += _ => CopyButtonPressed?.Invoke();
|
|
SendButton.OnPressed += _ => SendButtonPressed?.Invoke();
|
|
RefreshButton.OnPressed += _ => RefreshButtonPressed?.Invoke();
|
|
PeerSelector.OnItemSelected += args =>
|
|
PeerSelected?.Invoke((string) args.Button.GetItemMetadata(args.Id)!);
|
|
}
|
|
|
|
public void UpdateState(FaxUiState state)
|
|
{
|
|
CopyButton.Disabled = !state.CanCopy;
|
|
SendButton.Disabled = !state.CanSend;
|
|
//Sunrise-Start
|
|
var Localekey = $"fax-label-{Regex.Replace(state.DeviceName, @"[*?!'%\s]", string.Empty).ToLower()}";
|
|
if (Loc.GetString($"fax-label-{Regex.Replace(state.DeviceName, @"[*?!'%\s]", string.Empty).ToLower()}") == Localekey)
|
|
{
|
|
FromLabel.Text = state.DeviceName;
|
|
}
|
|
else
|
|
{
|
|
FromLabel.Text = Loc.GetString($"fax-label-{Regex.Replace(state.DeviceName, @"[*?!'%\s]", string.Empty).ToLower()}");
|
|
}
|
|
//Sunrise-End
|
|
|
|
if (state.IsPaperInserted)
|
|
{
|
|
PaperStatusLabel.FontColorOverride = Color.Green;
|
|
PaperStatusLabel.Text = Loc.GetString("fax-machine-ui-paper-inserted");
|
|
}
|
|
else
|
|
{
|
|
PaperStatusLabel.FontColorOverride = Color.Red;
|
|
PaperStatusLabel.Text = Loc.GetString("fax-machine-ui-paper-not-inserted");
|
|
}
|
|
|
|
if (state.AvailablePeers.Count == 0)
|
|
{
|
|
PeerSelector.AddItem(Loc.GetString("fax-machine-ui-no-peers"));
|
|
PeerSelector.Disabled = true;
|
|
}
|
|
|
|
if (PeerSelector.Disabled && state.AvailablePeers.Count != 0)
|
|
{
|
|
PeerSelector.Clear();
|
|
PeerSelector.Disabled = false;
|
|
}
|
|
|
|
// always must be selected destination
|
|
if (string.IsNullOrEmpty(state.DestinationAddress) && state.AvailablePeers.Count != 0)
|
|
{
|
|
PeerSelected?.Invoke(state.AvailablePeers.First().Key);
|
|
return;
|
|
}
|
|
|
|
if (state.AvailablePeers.Count != 0)
|
|
{
|
|
PeerSelector.Clear();
|
|
|
|
foreach (var (address, name) in state.AvailablePeers)
|
|
{
|
|
var id = AddPeerSelect(name, address);
|
|
if (address == state.DestinationAddress)
|
|
PeerSelector.Select(id);
|
|
}
|
|
}
|
|
}
|
|
|
|
private int AddPeerSelect(string name, string address)
|
|
{
|
|
//Sunrise-Start
|
|
var Localekey = $"fax-label-{Regex.Replace(name, @"[*?!'%\s]", string.Empty).ToLower()}";
|
|
var loc = name;
|
|
if (Loc.GetString($"fax-label-{Regex.Replace(name, @"[*?!'%\s]", string.Empty).ToLower()}") != Localekey)
|
|
{
|
|
loc = Loc.GetString($"fax-label-{Regex.Replace(name, @"[*?!'%\s]", string.Empty).ToLower()}");
|
|
}
|
|
PeerSelector.AddItem(loc);
|
|
//Sunrise-End
|
|
PeerSelector.SetItemMetadata(PeerSelector.ItemCount - 1, address);
|
|
return PeerSelector.ItemCount - 1;
|
|
}
|
|
|
|
private void OnPaperButtonPressed()
|
|
{
|
|
OfficePaper = !OfficePaper;
|
|
|
|
if(OfficePaper)
|
|
PaperButton.Text = Loc.GetString("fax-machine-ui-paper-button-office");
|
|
else
|
|
PaperButton.Text = Loc.GetString("fax-machine-ui-paper-button-normal");
|
|
}
|
|
}
|