Ломает панель накрутки

This commit is contained in:
Hero010h
2025-01-04 22:15:12 +03:00
parent bde21739fb
commit e178961cd2
6 changed files with 119 additions and 2 deletions

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,6 +7,8 @@ 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;
namespace Content.Client._White.Administration;
@@ -16,19 +18,43 @@ public sealed partial class HoursPanel : DefaultWindow
{
public HoursPanel()
{
var owner = new HoursPanelSystem(this);
RobustXamlLoader.Load(this);
var roles = new Dictionary<int, string>();
PlayerNameLine.OnTextChanged += _ => OnNamesChanged();
PlayerNameLine.OnTextEntered += _ => OnNameSubmited(owner, roles);
PlayerList.OnSelectionChanged += OnPlayerSelectionChanged;
HourButton.OnPressed += _ => AddMinutes(60);
MinutesLine.OnTextChanged += UpdateButtonsText;
RoleOption.OnItemSelected += args => RoleOption.SelectId(args.Id);
RoleOption.OnItemSelected += args => OnItemSelected(args, owner, roles);
SubmitButton.OnPressed += _ => OnSubmitButtonOnPressed(roles);
SaveButton.OnPressed += _ => OnSaveButtonOnPressed();
OnNamesChanged();
InitRoleList(roles);
}
public void UpdateTime(TimeSpan? time)
{
if (time == null)
TimeDisplayer.Text = $"Время игры: нет данных";
else
TimeDisplayer.Text = $"Время игры: {time}";
}
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 HoursPanelMessage(PlayerNameLine.Text, roles[RoleOption.SelectedId]));
}
private void InitRoleList(Dictionary<int, string> roles)
{
var roleInd = 0;
@@ -101,4 +127,10 @@ public sealed partial class HoursPanel : DefaultWindow
$"playtime_save {PlayerNameLine.Text}");
SaveButton.Disabled = true;
}
private void GetPlayerTime()
{
if (string.IsNullOrWhiteSpace(PlayerNameLine.Text))
return;
}
}

View File

@@ -0,0 +1,23 @@
using Content.Shared._White.Administration;
namespace Content.Client._White.Administration;
public sealed class HoursPanelSystem : SharedHoursPanelSystem
{
public HoursPanel Panel { get; }
public HoursPanelSystem(HoursPanel panel)
{
Panel = panel;
}
protected override void OnHoursPanelMessage(HoursPanelMessage message, EntitySessionEventArgs eventArgs)
{
if (message.Time != null)
Panel.UpdateTime(message.Time);
}
public void SendPlayerTimeRequest(HoursPanelMessage message)
{
RaiseNetworkEvent(message);
}
}