Правк
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
<cc:CommandButton Command="adminlogs" Text="{Loc admin-player-actions-window-admin-logs}"/>
|
||||
<cc:CommandButton Command="faxui" Text="{Loc admin-player-actions-window-admin-fax}"/>
|
||||
<cc:UICommandButton Command="enableShuttleCall" Text="{Loc admin-player-actions-window-shuttle-call}" WindowType="{x:Type at:AdminShuttleCallEnableWindow}"/>
|
||||
<cc:UICommandButton Command="" Text="Накрутка времени" WindowType="{x:Type at:HoursPanel }"/>
|
||||
</GridContainer>
|
||||
</BoxContainer>
|
||||
</Control>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<DefaultWindow
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||
Title="Накрутка времени" MinSize="300 300">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="Игрок" MinWidth="100" />
|
||||
<Control MinWidth="50" />
|
||||
<LineEdit Name="PlayerNameLine" MinWidth="100" HorizontalExpand="True" />
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="Время" MinWidth="100" />
|
||||
<Control MinWidth="50" />
|
||||
<LineEdit Name="MinutesLine" MinWidth="100" HorizontalExpand="True" />
|
||||
<Button Name="HourButton" Text="+1h (0)"/>
|
||||
</BoxContainer>
|
||||
<OptionButton Name="RoleOption" />
|
||||
<cc:PlayerListControl Name="PlayerList" VerticalExpand="True" MinWidth="200"/>
|
||||
<Control VerticalExpand="True" Margin="10" />
|
||||
<Button Name="SubmitButton" Text="Добавить время" />
|
||||
</BoxContainer>
|
||||
</DefaultWindow>
|
||||
@@ -0,0 +1,145 @@
|
||||
using System.Linq;
|
||||
using Content.Client.Administration.UI.CustomControls;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Roles;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Robust.Client.UserInterface.Controls.LineEdit;
|
||||
using Content.Shared.Players.PlayTimeTracking;
|
||||
|
||||
namespace Content.Client.Administration.UI.Tabs.AdminTab;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
[UsedImplicitly]
|
||||
public sealed partial class HoursPanel : DefaultWindow
|
||||
{
|
||||
private enum Roles
|
||||
{
|
||||
Overall,
|
||||
|
||||
//Write in alphabetical order!
|
||||
|
||||
AtmosphericTechnician,
|
||||
Bartender,
|
||||
Bomzh,
|
||||
Borg,
|
||||
Botanist,
|
||||
Boxer,
|
||||
Brigmedic,
|
||||
Captain,
|
||||
CargoTechnician,
|
||||
Chaplain,
|
||||
Chef,
|
||||
Chemist,
|
||||
ChiefEngineer,
|
||||
ChiefMedicalOfficer,
|
||||
Clown,
|
||||
Detective,
|
||||
HeadOfPersonnel,
|
||||
HeadOfSecurity,
|
||||
Inspector,
|
||||
Janitor,
|
||||
Lawyer,
|
||||
Librarian,
|
||||
Maid,
|
||||
MedicalDoctor,
|
||||
MedicalIntern,
|
||||
Mime,
|
||||
Musician,
|
||||
Paramedic,
|
||||
Passenger,
|
||||
Psychologist,
|
||||
Quartermaster,
|
||||
Reporter,
|
||||
ResearchAssistant,
|
||||
ResearchDirector,
|
||||
SalvageSpecialist,
|
||||
Scientist,
|
||||
SecurityCadet,
|
||||
SecurityOfficer,
|
||||
SeniorEngineer,
|
||||
SeniorOfficer,
|
||||
SeniorPhysician,
|
||||
SeniorResearcher,
|
||||
ServiceWorker,
|
||||
StationEngineer,
|
||||
TechnicalAssistant,
|
||||
Visitor,
|
||||
Warden,
|
||||
Zookeeper
|
||||
}
|
||||
|
||||
|
||||
public HoursPanel()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
PlayerList.OnSelectionChanged += OnPlayerSelectionChanged;
|
||||
HourButton.OnPressed += _ => AddMinutes(60);
|
||||
MinutesLine.OnTextChanged += UpdateButtonsText;
|
||||
|
||||
RoleOption.AddItem("OverAll");
|
||||
foreach (var dep in IoCManager.Resolve<IPrototypeManager>().EnumeratePrototypes<DepartmentPrototype>())
|
||||
{
|
||||
foreach (var role in dep.Roles)
|
||||
{
|
||||
RoleOption.AddItem(role.Id);
|
||||
}
|
||||
}
|
||||
RoleOption.RemoveItem(RoleOption.GetItemId());
|
||||
RoleOption.Select(0);
|
||||
|
||||
}
|
||||
private void SetRoles()
|
||||
{
|
||||
int roleInd = 0;
|
||||
foreach (var dep in IoCManager.Resolve<IPrototypeManager>().EnumeratePrototypes<DepartmentPrototype>())
|
||||
{
|
||||
|
||||
foreach (var role in dep.Roles)
|
||||
{
|
||||
RoleOption.AddItem(role.Id, roleInd++);
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool TryGetMinutes(string str, out uint minutes)
|
||||
{
|
||||
minutes = 0;
|
||||
return string.IsNullOrWhiteSpace(str) || uint.TryParse(str, out minutes);
|
||||
}
|
||||
private void AddMinutes(uint add)
|
||||
{
|
||||
if (!TryGetMinutes(MinutesLine.Text, out var minutes))
|
||||
return;
|
||||
|
||||
MinutesLine.Text = $"{minutes + add}";
|
||||
UpdateButtons(minutes + add);
|
||||
}
|
||||
private void UpdateButtonsText(LineEditEventArgs obj)
|
||||
{
|
||||
if (!TryGetMinutes(obj.Text, out var minutes))
|
||||
return;
|
||||
|
||||
UpdateButtons(minutes);
|
||||
}
|
||||
private void UpdateButtons(uint minutes)
|
||||
{
|
||||
HourButton.Text = $"+1h ({minutes / 60})";
|
||||
}
|
||||
private void OnNamesChanged()
|
||||
{
|
||||
SubmitButton.Disabled = string.IsNullOrEmpty(PlayerNameLine.Text);
|
||||
}
|
||||
private void OnPlayerSelectionChanged(PlayerInfo? player)
|
||||
{
|
||||
PlayerNameLine.Text = player?.Username ?? string.Empty;
|
||||
OnNamesChanged();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user