Merge remote-tracking branch 'WD-core/master' into upstream-core

This commit is contained in:
BIGZi0348
2025-02-09 20:09:27 +03:00
37 changed files with 1981 additions and 497 deletions

View File

@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:at="clr-namespace:Content.Client.Administration.UI.Tabs.AdminTab"
xmlns:wd="clr-namespace:Content.Client._White.Administration"
xmlns:wd="clr-namespace:Content.Client._White.Administration.HoursPanelSystems"
Margin="4"
MinSize="50 50">
<BoxContainer Orientation="Vertical">

View File

@@ -134,7 +134,7 @@ public abstract class RequirementsSelector<T> : BoxContainer where T : IPrototyp
_loadoutWindow = new LoadoutWindow(profile, _loadout, protoManager.Index(_loadout.Role), session, collection)
{
Title = Loc.GetString(Proto.ID + "-loadout"),
Title = Loc.GetString("Job" + Proto.ID), //WD edit
};
_loadoutWindow.RefreshLoadouts(_loadout, session, collection);

View File

@@ -23,7 +23,7 @@
HorizontalAlignment="Right"
Text="Refund" />
</BoxContainer>
<LineEdit Name="SearchBar" Margin="4" PlaceHolder="Search" HorizontalExpand="True"/>
<LineEdit Name="SearchBar" Margin="4" PlaceHolder="Поиск" HorizontalExpand="True"/>
<PanelContainer VerticalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#000000FF" />

View File

@@ -14,6 +14,7 @@
<LineEdit Name="MinutesLine" MinWidth="100" HorizontalExpand="True" PlaceHolder="минуты" />
<Button Name="HourButton" Text="+1h (0)"/>
</BoxContainer>
<Label Name="TimeDisplayer" Text="Время игры: " />
<OptionButton Name="RoleOption" />
<cc:PlayerListControl Name="PlayerList" VerticalExpand="True" MinWidth="200"/>
<Button Name="SubmitButton" Text="Добавить время" />

View File

@@ -7,8 +7,12 @@ using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using static Robust.Client.UserInterface.Controls.LineEdit;
using Content.Shared._White.Administration;
using Robust.Client.UserInterface.Controls;
using System.Diagnostics.CodeAnalysis;
using Robust.Client.Graphics.Clyde;
namespace Content.Client._White.Administration;
namespace Content.Client._White.Administration.HoursPanelSystems;
[GenerateTypedNameReferences]
[UsedImplicitly]
@@ -17,18 +21,48 @@ public sealed partial class HoursPanel : DefaultWindow
public HoursPanel()
{
RobustXamlLoader.Load(this);
var entityManager = IoCManager.Resolve<IEntityManager>();
var hoursPanelSystem = entityManager.System<HoursPanelSystem>();
hoursPanelSystem.Panel = this;
var roles = new Dictionary<int, string>();
PlayerNameLine.OnTextChanged += _ => OnNamesChanged();
PlayerNameLine.OnTextEntered += _ => OnNameSubmited(hoursPanelSystem, roles);
PlayerList.OnSelectionChanged += OnPlayerSelectionChanged;
HourButton.OnPressed += _ => AddMinutes(60);
MinutesLine.OnTextChanged += UpdateButtonsText;
RoleOption.OnItemSelected += args => RoleOption.SelectId(args.Id);
SubmitButton.OnPressed += _ => OnSubmitButtonOnPressed(roles);
RoleOption.OnItemSelected += args => OnItemSelected(args, hoursPanelSystem, roles);
SubmitButton.OnPressed += _ => OnSubmitButtonOnPressed(roles, hoursPanelSystem);
SaveButton.OnPressed += _ => OnSaveButtonOnPressed();
OnNamesChanged();
InitRoleList(roles);
}
public void UpdateTime(TimeSpan? time)
{
if (time != null)
{
var t = (TimeSpan) time;
TimeDisplayer.Text = $"Время игры: {Math.Floor(t.TotalHours) + string.Format(" ч {0:%m} м", t)}";
}
else
TimeDisplayer.Text = $"Время игры: нет данных";
}
private void OnItemSelected(OptionButton.ItemSelectedEventArgs args, HoursPanelSystem owner, Dictionary<int, string> roles)
{
RoleOption.SelectId(args.Id);
OnNameSubmited(owner, roles);
}
private void OnNameSubmited(HoursPanelSystem owner, Dictionary<int, string> roles)
{
if (string.IsNullOrWhiteSpace(PlayerNameLine.Text))
return;
owner.SendPlayerTimeRequest(new HoursPanelMessageToServer(PlayerNameLine.Text, roles[RoleOption.SelectedId]));
}
private void InitRoleList(Dictionary<int, string> roles)
{
var roleInd = 0;
@@ -88,11 +122,13 @@ public sealed partial class HoursPanel : DefaultWindow
OnNamesChanged();
}
private void OnSubmitButtonOnPressed(Dictionary<int, string> roles)
private void OnSubmitButtonOnPressed(Dictionary<int, string> roles, HoursPanelSystem owner)
{
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
$"playtime_addrole {PlayerNameLine.Text} {roles[RoleOption.SelectedId]} {MinutesLine.Text}");
SaveButton.Disabled = false;
owner.SendPlayerTimeRequest(new HoursPanelMessageToServer(PlayerNameLine.Text, roles[RoleOption.SelectedId]));
}
private void OnSaveButtonOnPressed()

View File

@@ -0,0 +1,25 @@
using Content.Shared._White.Administration;
namespace Content.Client._White.Administration.HoursPanelSystems;
public sealed class HoursPanelSystem : EntitySystem
{
public HoursPanel? Panel;
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<HoursPanelMessageToClient>(OnHoursPanelMessage);
}
private void OnHoursPanelMessage(HoursPanelMessageToClient message, EntitySessionEventArgs eventArgs)
{
Panel?.UpdateTime(message.Time);
}
public void SendPlayerTimeRequest(HoursPanelMessageToServer message)
{
RaiseNetworkEvent(message);
}
}

View File

@@ -8,7 +8,7 @@
<Button Name="BackButton" Text="{Loc 'messages-pda-ui-back'}" HorizontalExpand="False"/>
<Label Name="HeaderLabel"/>
</BoxContainer>
<LineEdit Name="SearchBar" PlaceHolder="Search" HorizontalExpand="True" Margin="0 4" />
<LineEdit Name="SearchBar" PlaceHolder="Поиск" HorizontalExpand="True" Margin="0 4" />
<ScrollContainer Name="MessagesScroll" HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="True">
<BoxContainer Orientation="Vertical" Name="MessageContainer" HorizontalExpand="True" VerticalExpand="True"/>
</ScrollContainer>