fish-station/Content.Client/UserInterface/Systems/Ghost/Controls/GhostTargetWindow.xaml.cs
Rinary 64f1aed90c
Большие изменения (#345)
* init

* мать масштаба тарабанил

* fix

* upd

* upd

* upd

* upd

* upd

* console spam fix

* hohohohohohohooooonkeeeeeeeeeeeeeerrrrrrrrrrrsssssssss........

* fix

* fix

* upd

* upd

* some fixes

* fix

* upd

* upd translation for steal obj

* teg translate

* upd

* fix locale + add advertisements

* translate configurator

* Fully translate

* upd

* Я манал это переводить, позже переведу

* upd en-US

* fix Linter

* upd

* fix

* upd

* fix

* fix

* fix

* Возврат ПНТ

* remove agent non silent equipment

* add acid to uplink

* carrySystem new popups

* fix

* fix

* fix disease locale

* add Disease Guide

* upd locale

* upd

* Revert "Merge branch 'master' of https://github.com/space-wizards/space-station-14 into misc"

This reverts commit 4130d241fc47fb80924c0dd3b9c9a2db85af8a25, reversing
changes made to 30abf7341ecce404f61f64e2000ad327964fcb00.

* Revert "Merge branch 'master' of https://github.com/space-wizards/space-station-14 into misc"

This reverts commit 4e5a50d21c29be8482f31e49db253b1ed17a0ae4, reversing
changes made to 449cd7bfd50f29eb653e68ba60e3f0b9310f0443.

* Revert "Merge branch 'master' of https://github.com/space-wizards/space-station-14 into misc"

This reverts commit a4679665ef441d4b63a92dc3c4e217e2cdedbc16, reversing
changes made to a80ef96cfbbc3cc737045e41a2f063a0910bf1ce.

* Revert "Merge branch 'master' of https://github.com/space-wizards/space-station-14 into misc"

This reverts commit 94f585756bb27d10a1be7fab1f340d79b7c0a213, reversing
changes made to 906d18a3f66eaed73f3a894d70971872904fad4e.

* Revert "Merge branch 'master' of https://github.com/space-wizards/space-station-14 into misc"

This reverts commit d0a7c6436ba5c175b0e00d69f495ba51f9aac645, reversing
changes made to e7933332274b336af1fc2a960264bc546c95d208.

# Conflicts:
#	Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml
#	Resources/Prototypes/Roles/Jobs/departments.yml

* fix

* upd

* upd

* Reapply "Merge branch 'master' of https://github.com/space-wizards/space-station-14 into misc"

This reverts commit 042a3f112bbc32a622108475ac28081eb0bbbf9f.

# Conflicts:
#	Content.Server/Dragon/DragonRiftSystem.cs
#	Content.Server/GameTicking/GameTicker.Spawning.cs
#	Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs
#	Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs
#	Content.Server/Spawners/EntitySystems/ContainerSpawnPointSystem.cs
#	Content.Server/Zombies/ZombieSystem.cs
#	Content.Server/_Sunrise/NPCSleep/NPCSleepSystem.cs
#	Resources/Changelog/Changelog.yml
#	Resources/Locale/en-US/_strings/store/uplink-catalog.ftl
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/secdrobe.yml
#	Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml
#	Resources/Prototypes/Entities/Clothing/Head/helmets.yml
#	Resources/Prototypes/Entities/Mobs/Player/silicon.yml
#	Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml
#	Resources/Prototypes/Entities/Stations/base.yml
#	Resources/Prototypes/Loadouts/Jobs/Security/security_officer.yml
#	Resources/Prototypes/Loadouts/loadout_groups.yml
#	Resources/Prototypes/Maps/box.yml
#	Resources/Prototypes/Maps/core.yml
#	Resources/Prototypes/Maps/fland.yml
#	Resources/Prototypes/Maps/marathon.yml
#	Resources/Prototypes/Maps/meta.yml
#	Resources/Prototypes/Maps/packed.yml
#	Resources/Prototypes/Roles/Jobs/departments.yml
#	Resources/Prototypes/Store/categories.yml
#	Resources/ServerInfo/Guidebook/Engineering/PortableGenerator.xml
#	Resources/ServerInfo/Guidebook/Security/Defusal.xml
#	Resources/ServerInfo/Guidebook/Security/Forensics.xml
#	Resources/migration.yml

* Reapply "Merge branch 'master' of https://github.com/space-wizards/space-station-14 into misc"

This reverts commit 2860e1d217a71be0c29684e020b2278c3f08685f.

# Conflicts:
#	Resources/Changelog/Changelog.yml

* Reapply "Merge branch 'master' of https://github.com/space-wizards/space-station-14 into misc"

This reverts commit 0dc7ea17e23d844ce93118db7812b844e36dda4f.

# Conflicts:
#	Resources/Changelog/Changelog.yml
#	Resources/Prototypes/Hydroponics/randomMutations.yml

* Reapply "Merge branch 'master' of https://github.com/space-wizards/space-station-14 into misc"

This reverts commit 439926b3c60e95cc2e701d84a032b17471a7c18e.

* Reapply "Merge branch 'master' of https://github.com/space-wizards/space-station-14 into misc"

This reverts commit 14160ab99909bf6b6f996f415d9dcfd5d4addbba.

# Conflicts:
#	Resources/Changelog/Changelog.yml

* fix

* upd

* upd uplink

* upd

* fix linter
2024-09-16 19:05:38 +03:00

111 lines
3.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Linq;
using System.Numerics;
using Content.Shared.Ghost;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using System.Text.RegularExpressions; //Sunrise-Edit
namespace Content.Client.UserInterface.Systems.Ghost.Controls
{
[GenerateTypedNameReferences]
public sealed partial class GhostTargetWindow : DefaultWindow
{
private List<(string, NetEntity)> _warps = new();
private string _searchText = string.Empty;
public event Action<NetEntity>? WarpClicked;
public event Action? OnGhostnadoClicked;
public GhostTargetWindow()
{
RobustXamlLoader.Load(this);
SearchBar.OnTextChanged += OnSearchTextChanged;
GhostnadoButton.OnPressed += _ => OnGhostnadoClicked?.Invoke();
}
public void UpdateWarps(IEnumerable<GhostWarp> warps)
{
// Server COULD send these sorted but how about we just use the client to do it instead
_warps = warps
.OrderBy(w => w.IsWarpPoint)
.ThenBy(w => w.DisplayName, Comparer<string>.Create(
(x, y) => string.Compare(x, y, StringComparison.Ordinal)))
.Select(w =>
{
var name = w.IsWarpPoint
? Loc.GetString("ghost-target-window-current-button", ("name", GetLocalizedName(w.DisplayName))) //Sunrise-Edit
: GetLocalizedName(w.DisplayName); //Sunrise-Edit
return (name, w.Entity);
})
.ToList();
}
//Sunrise-Start
private string GetLocalizedName(string displayName)
{
var locationKey = $"location-{Regex.Replace(displayName, @"[^a-zA-Zа-яА-Я0-9\s]", string.Empty).Replace(" ", "-").ToLower()}";
var localizedName = Loc.GetString(locationKey);
if (localizedName == locationKey)
{
localizedName = displayName;
}
return localizedName;
}
//Sunrise-End
public void Populate()
{
ButtonContainer.DisposeAllChildren();
AddButtons();
}
private void AddButtons()
{
foreach (var (name, warpTarget) in _warps)
{
var currentButtonRef = new Button
{
Text = name,
TextAlign = Label.AlignMode.Right,
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
SizeFlagsStretchRatio = 1,
MinSize = new Vector2(340, 20),
ClipText = true,
};
currentButtonRef.OnPressed += _ => WarpClicked?.Invoke(warpTarget);
currentButtonRef.Visible = ButtonIsVisible(currentButtonRef);
ButtonContainer.AddChild(currentButtonRef);
}
}
private bool ButtonIsVisible(Button button)
{
return string.IsNullOrEmpty(_searchText) || button.Text == null || button.Text.Contains(_searchText, StringComparison.OrdinalIgnoreCase);
}
private void UpdateVisibleButtons()
{
foreach (var child in ButtonContainer.Children)
{
if (child is Button button)
button.Visible = ButtonIsVisible(button);
}
}
private void OnSearchTextChanged(LineEdit.LineEditEventArgs args)
{
_searchText = args.Text;
UpdateVisibleButtons();
// Reset scroll bar so they can see the relevant results.
GhostScroll.SetScrollValue(Vector2.Zero);
}
}
}