-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into port-gamba-cards-ee
- Loading branch information
Showing
28 changed files
with
780 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Content.Client/_Goobstation/Administration/UI/TimeTransferPanel/TimeTransferEntry.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<BoxContainer xmlns="https://spacestation14.io" | ||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" | ||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls" | ||
Margin="5 5" | ||
HorizontalExpand="True" | ||
Visible="True"> | ||
<PanelContainer StyleClasses="AngleRect" HorizontalExpand="True"> | ||
<BoxContainer Orientation="Horizontal"> | ||
<BoxContainer Orientation="Vertical" VerticalAlignment="Center"> | ||
<CheckBox Name="GroupCheckbox" HorizontalAlignment="Center"/> | ||
</BoxContainer> | ||
<customControls:VSeparator Margin="0 0 10 0"/> | ||
<BoxContainer Orientation="Vertical" HorizontalExpand="True"> | ||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True"> | ||
<TextureRect Name="JobIcon" VerticalAlignment="Center" TextureScale="2 2"/> | ||
<Control MinWidth="4"/> | ||
<Label Name="JobLabel" Text=" " HorizontalAlignment="Center"/> | ||
</BoxContainer> | ||
<Control MinHeight="4"/> | ||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True"> | ||
<Label Name="TimeLabel" Text="{Loc time-transfer-panel-time}" HorizontalAlignment="Center"/> | ||
<Control MinWidth="5"/> | ||
<LineEdit Name="TimeEdit" PlaceHolder="0h0m" HorizontalExpand="True"/> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</PanelContainer> | ||
</BoxContainer> |
46 changes: 46 additions & 0 deletions
46
Content.Client/_Goobstation/Administration/UI/TimeTransferPanel/TimeTransferEntry.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Content.Shared.Roles; | ||
using Content.Shared.StatusIcon; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client._Goobstation.Administration.UI.TimeTransferPanel; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class TimeTransferEntry : BoxContainer | ||
{ | ||
public string PlaytimeTracker; | ||
public string JobName; | ||
|
||
public TimeTransferEntry(JobPrototype jobProto, SpriteSystem spriteSystem, IPrototypeManager prototypeManager) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
|
||
PlaytimeTracker = jobProto.PlayTimeTracker; | ||
JobLabel.Text = jobProto.LocalizedName; | ||
JobName = jobProto.LocalizedName; | ||
|
||
if (prototypeManager.TryIndex<JobIconPrototype>(jobProto.Icon, out var jobIcon)) | ||
JobIcon.Texture = spriteSystem.Frame0(jobIcon.Icon); | ||
} | ||
|
||
public void UpdateGroupVisibility(bool inGrouped) | ||
{ | ||
TimeLabel.Visible = !inGrouped; | ||
TimeEdit.Visible = !inGrouped; | ||
GroupCheckbox.Visible = inGrouped; | ||
} | ||
|
||
public string GetJobTimeString() | ||
{ | ||
return TimeEdit.Text != null ? TimeEdit.Text : ""; | ||
} | ||
|
||
public bool InGroup() | ||
{ | ||
return GroupCheckbox.Pressed; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
Content.Client/_Goobstation/Administration/UI/TimeTransferPanel/TimeTransferPanel.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<DefaultWindow xmlns="https://spacestation14.io" | ||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls" | ||
Title="{Loc time-transfer-panel-title}" | ||
MinWidth="500"> | ||
<BoxContainer Orientation="Vertical" VerticalExpand = "True"> | ||
<BoxContainer Orientation="Horizontal" Margin="2"> | ||
<Label Name="PlayerLabel" Text="{Loc time-transfer-panel-player-label}" MinWidth = "120"/> | ||
<Control MinWidth ="10"/> | ||
<LineEdit Name="PlayerLine" PlaceHolder="PlayerUid" HorizontalExpand="True" /> | ||
</BoxContainer> | ||
<BoxContainer Orientation="Horizontal" Margin="2"> | ||
<CheckBox Name="GroupCheckbox" Text="{Loc time-transfer-panel-checkbox-group}" MinWidth = "120"/> | ||
<Control MinWidth ="10"/> | ||
<LineEdit Name="GroupTimeLine" PlaceHolder="0h0m" HorizontalExpand="True" /> | ||
</BoxContainer> | ||
<Control MinHeight="5"/> | ||
<LineEdit Name="JobSearch" Access="Public" StyleClasses="actionSearchBox" HorizontalExpand="True" PlaceHolder="{Loc time-transfer-panel-search-placeholder}"/> | ||
<Control MinHeight="10"/> | ||
<PanelContainer VerticalExpand="True"> | ||
<PanelContainer.PanelOverride> | ||
<gfx:StyleBoxFlat BackgroundColor="#1b1b1e" /> | ||
</PanelContainer.PanelOverride> | ||
<ScrollContainer HScrollEnabled="False" | ||
HorizontalExpand="True" | ||
VerticalExpand="True" | ||
MinHeight="400" | ||
SizeFlagsStretchRatio="2.5"> | ||
<BoxContainer Name ="JobContainer" Orientation="Vertical"/> | ||
</ScrollContainer> | ||
</PanelContainer> | ||
<Control MinHeight="10" /> | ||
<controls:StripeBack> | ||
<Label Name="WarningLabel" Text=" " HorizontalAlignment="Center" Margin="4 4 0 4"/> | ||
</controls:StripeBack> | ||
<Control MinHeight="10" /> | ||
<Button Name="AddTimeButton" Text="{Loc time-transfer-panel-add-time}"/> | ||
<Button Name="SetTimeButton" Text="{Loc time-transfer-panel-set-time}"/> | ||
<BoxContainer Orientation="Horizontal" Margin="0 4 0 0"> | ||
<Label Text="{Loc time-transfer-panel-author}" StyleClasses="LabelSubText"/> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</DefaultWindow> |
210 changes: 210 additions & 0 deletions
210
Content.Client/_Goobstation/Administration/UI/TimeTransferPanel/TimeTransferPanel.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
using Content.Shared._Goobstation.Administration; | ||
using Content.Shared.Roles; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Timing; | ||
using System.Linq; | ||
|
||
namespace Content.Client._Goobstation.Administration.UI.TimeTransferPanel; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class TimeTransferPanel : DefaultWindow | ||
{ | ||
[Dependency] private readonly IGameTiming _gameTiming = default!; | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
|
||
private readonly SpriteSystem _spriteSystem; | ||
|
||
public Action<(string playerId, List<TimeTransferData> transferList, bool overwrite)>? OnTransferMessageSend; | ||
private TimeSpan? SetButtonResetOn { get; set; } | ||
|
||
public TimeTransferPanel() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
_spriteSystem = _entityManager.System<SpriteSystem>(); | ||
|
||
AddTimeButton.OnButtonUp += OnAddTimeButtonPressed; | ||
SetTimeButton.OnButtonUp += OnSetTimeButtonPressed; | ||
GroupCheckbox.OnPressed += OnGroupCheckboxPressed; | ||
|
||
JobSearch.OnTextChanged += OnJobSearchTextChanged; | ||
|
||
PopulateJobs(); | ||
UpdateGroup(); | ||
UpdateWarning(" ", Color.LightGreen); | ||
} | ||
|
||
public void PopulateJobs() | ||
{ | ||
var jobs = _prototypeManager.EnumeratePrototypes<JobPrototype>() | ||
.OrderBy(job => job.LocalizedName) | ||
.ToList(); | ||
|
||
foreach(var job in jobs) | ||
{ | ||
var jobEntry = new TimeTransferEntry(job, _spriteSystem, _prototypeManager); | ||
JobContainer.AddChild(jobEntry); | ||
} | ||
} | ||
|
||
public void UpdateFlag(bool hasFlag) | ||
{ | ||
AddTimeButton.Visible = hasFlag; | ||
SetTimeButton.Visible = hasFlag; | ||
|
||
if (!hasFlag) | ||
UpdateWarning(Loc.GetString("time-transfer-panel-warning-no-perms"), Color.DarkRed); | ||
else | ||
UpdateWarning(" ", Color.LightGreen); | ||
} | ||
|
||
public void TimeTransfer(bool overwrite = false) | ||
{ | ||
var player = PlayerLine.Text; | ||
|
||
if (string.IsNullOrEmpty(player)) | ||
{ | ||
UpdateWarning(Loc.GetString("time-transfer-panel-warning-no-player"), Color.DarkRed); | ||
return; | ||
} | ||
|
||
var dataList = new List<TimeTransferData>(); | ||
|
||
if (GroupCheckbox.Pressed) | ||
{ | ||
if (string.IsNullOrEmpty(GroupTimeLine.Text)) | ||
{ | ||
UpdateWarning(Loc.GetString("time-transfer-panel-warning-group-no-time"), Color.DarkRed); | ||
return; | ||
} | ||
|
||
var entryList = GetGroupEntries(); | ||
foreach (var entry in entryList) | ||
{ | ||
var data = new TimeTransferData(entry.PlaytimeTracker, GroupTimeLine.Text); | ||
dataList.Add(data); | ||
} | ||
} | ||
else | ||
{ | ||
foreach (var entry in JobContainer.Children) | ||
{ | ||
if (entry is not TimeTransferEntry jobEntry) | ||
continue; | ||
|
||
var tracker = jobEntry.PlaytimeTracker; | ||
var timeString = jobEntry.GetJobTimeString(); | ||
|
||
if (string.IsNullOrEmpty(timeString)) | ||
continue; | ||
|
||
var data = new TimeTransferData(tracker, timeString); | ||
dataList.Add(data); | ||
} | ||
} | ||
|
||
OnTransferMessageSend?.Invoke((player, dataList, overwrite)); | ||
UpdateWarning(Loc.GetString("time-transfer-panel-warning-transfer-process"), Color.Gold); | ||
} | ||
|
||
public List<TimeTransferEntry> GetGroupEntries() | ||
{ | ||
var list = new List<TimeTransferEntry>(); | ||
|
||
foreach (var entry in JobContainer.Children) | ||
{ | ||
if (entry is not TimeTransferEntry jobEntry) | ||
continue; | ||
|
||
if (jobEntry.InGroup()) | ||
list.Add(jobEntry); | ||
} | ||
|
||
return list; | ||
} | ||
|
||
public void UpdateGroup() | ||
{ | ||
GroupTimeLine.Visible = GroupCheckbox.Pressed; | ||
|
||
foreach (var entry in JobContainer.Children) | ||
{ | ||
if (entry is not TimeTransferEntry jobEntry) | ||
continue; | ||
|
||
jobEntry.UpdateGroupVisibility(GroupCheckbox.Pressed); | ||
} | ||
} | ||
|
||
public void OnJobSearchTextChanged(LineEdit.LineEditEventArgs args) | ||
{ | ||
UpdateSearch(); | ||
} | ||
|
||
public void UpdateSearch() | ||
{ | ||
foreach (var entry in JobContainer.Children) | ||
{ | ||
if (entry is not TimeTransferEntry jobEntry) | ||
continue; | ||
|
||
jobEntry.Visible = ShouldShowJob(jobEntry); | ||
} | ||
} | ||
|
||
public void UpdateWarning(string text, Color color) | ||
{ | ||
WarningLabel.FontColorOverride = color; | ||
WarningLabel.Text = text; | ||
} | ||
|
||
public bool ShouldShowJob(TimeTransferEntry jobEntry) | ||
{ | ||
return jobEntry.JobName != null && JobSearch.Text != null && jobEntry.JobName.Contains(JobSearch.Text, StringComparison.OrdinalIgnoreCase); | ||
} | ||
|
||
public void OnGroupCheckboxPressed(BaseButton.ButtonEventArgs obj) | ||
{ | ||
UpdateGroup(); | ||
} | ||
|
||
public void OnAddTimeButtonPressed(BaseButton.ButtonEventArgs obj) | ||
{ | ||
TimeTransfer(false); | ||
} | ||
|
||
public void OnSetTimeButtonPressed(BaseButton.ButtonEventArgs obj) | ||
{ | ||
if (SetButtonResetOn is null) | ||
{ | ||
SetButtonResetOn = _gameTiming.CurTime.Add(TimeSpan.FromSeconds(3)); | ||
SetTimeButton.ModulateSelfOverride = Color.DarkRed; | ||
SetTimeButton.Text = Loc.GetString("time-transfer-panel-set-time-confirm"); | ||
return; | ||
} | ||
|
||
TimeTransfer(true); | ||
ResetSetButton(); | ||
} | ||
|
||
protected override void FrameUpdate(FrameEventArgs args) | ||
{ | ||
base.FrameUpdate(args); | ||
|
||
if (SetButtonResetOn != null && _gameTiming.CurTime > SetButtonResetOn) | ||
ResetSetButton(); | ||
} | ||
|
||
private void ResetSetButton() | ||
{ | ||
SetButtonResetOn = null; | ||
SetTimeButton.ModulateSelfOverride = null; | ||
SetTimeButton.Text = Loc.GetString("time-transfer-panel-set-time"); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
Content.Client/_Goobstation/Administration/UI/TimeTransferPanel/TimeTransferPanelEui.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Content.Client.Eui; | ||
using Content.Shared._Goobstation.Administration; | ||
using Content.Shared.Eui; | ||
|
||
namespace Content.Client._Goobstation.Administration.UI.TimeTransferPanel; | ||
|
||
public sealed class TimeTransferPanelEui : BaseEui | ||
{ | ||
public TimeTransferPanel TimeTransferPanel { get; } | ||
|
||
public TimeTransferPanelEui() | ||
{ | ||
TimeTransferPanel = new TimeTransferPanel(); | ||
TimeTransferPanel.OnTransferMessageSend += args => SendMessage(new TimeTransferEuiMessage(args.playerId, args.transferList, args.overwrite)); | ||
} | ||
|
||
public override void Opened() | ||
{ | ||
TimeTransferPanel.OpenCentered(); | ||
} | ||
|
||
public override void Closed() | ||
{ | ||
TimeTransferPanel.Close(); | ||
} | ||
|
||
public override void HandleState(EuiStateBase state) | ||
{ | ||
if (state is not TimeTransferPanelEuiState cast) | ||
return; | ||
|
||
TimeTransferPanel.UpdateFlag(cast.HasFlag); | ||
} | ||
|
||
public override void HandleMessage(EuiMessageBase msg) | ||
{ | ||
base.HandleMessage(msg); | ||
|
||
if (msg is not TimeTransferWarningEuiMessage warning) | ||
return; | ||
|
||
TimeTransferPanel.UpdateWarning(warning.Message, warning.WarningColor); | ||
} | ||
} |
Oops, something went wrong.