-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move rejecting to offerings, remove rescan (automatic now)
- Loading branch information
deltanedas
committed
Feb 11, 2025
1 parent
d022a2e
commit 5476033
Showing
15 changed files
with
261 additions
and
154 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
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
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,17 @@ | ||
<BoxContainer xmlns="https://spacestation14.io" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
xmlns:rep="clr-namespace:Content.Client._DV.Reputation.UI" | ||
Orientation="Horizontal" | ||
HorizontalExpand="true" | ||
Align="Center" | ||
MinHeight="48" | ||
Margin="5"> | ||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" Margin="5"> | ||
<Label Name="Title"/> <!-- Set in constructor --> | ||
<rep:UnlockLabel Name="UnlockLabel"/> | ||
</BoxContainer> | ||
<BoxContainer Name="ButtonsContainer" Orientation="Vertical"> | ||
<Button Name="AcceptButton" Text="{Loc 'contracts-accept'}"/> | ||
<Button Name="RejectButton" Text="{Loc 'contracts-reject'}"/> | ||
</BoxContainer> | ||
</BoxContainer> |
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,48 @@ | ||
using Content.Shared._DV.Reputation; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client._DV.Reputation.UI; | ||
|
||
/// <summary> | ||
/// Contract control placed in a slot that with no contract. | ||
/// </summary> | ||
[GenerateTypedNameReferences] | ||
public sealed partial class ContractOffering : BoxContainer | ||
{ | ||
public event Action? OnAccept; | ||
public event Action? OnReject; | ||
public event Action? OnUnlock; | ||
|
||
public bool AcceptDisabled | ||
{ | ||
get | ||
{ | ||
return AcceptButton.Disabled; | ||
} | ||
set | ||
{ | ||
AcceptButton.Disabled = value; | ||
} | ||
} | ||
|
||
public ContractOffering(OfferingSlot slot) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
|
||
if (slot.Title is {} title) | ||
Title.Text = title; | ||
else | ||
Title.Visible = false; | ||
|
||
UnlockLabel.NextUnlock = slot.NextUnlock; | ||
UnlockLabel.OnUnlock += () => OnUnlock?.Invoke(); | ||
|
||
OnUnlock += () => ButtonsContainer.Visible = true; | ||
ButtonsContainer.Visible = !UnlockLabel.IsLocked; | ||
|
||
AcceptButton.OnPressed += _ => OnAccept?.Invoke(); | ||
RejectButton.OnPressed += _ => OnReject?.Invoke(); | ||
} | ||
} |
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
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
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
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
<BoxContainer xmlns="https://spacestation14.io" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
xmlns:rep="clr-namespace:Content.Client._DV.Reputation.UI" | ||
Orientation="Vertical" | ||
HorizontalExpand="true" | ||
Align="Center" | ||
MinHeight="64" | ||
Margin="5"> | ||
<Label Text="{Loc 'contract-slot-empty'}" HorizontalExpand="True"/> | ||
<Label Name="UnlockLabel" HorizontalExpand="True" Visible="False"/> <!-- Set in UpdateUnlock --> | ||
<rep:UnlockLabel Name="UnlockLabel"/> | ||
</BoxContainer> |
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
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,73 @@ | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client._DV.Reputation.UI; | ||
|
||
/// <summary> | ||
/// Label that updates for an unlock timer automatically. | ||
/// </summary> | ||
public sealed class UnlockLabel : Label | ||
{ | ||
[Dependency] private readonly IGameTiming _timing = default!; | ||
|
||
public event Action? OnUnlock; | ||
|
||
private TimeSpan? _nextUnlock; | ||
private TimeSpan _nextUpdate; | ||
|
||
public TimeSpan? NextUnlock | ||
{ | ||
get | ||
{ | ||
return _nextUnlock; | ||
} | ||
set | ||
{ | ||
_nextUnlock = value; | ||
_nextUpdate = _timing.CurTime; | ||
UpdateUnlock(); | ||
} | ||
} | ||
|
||
public bool IsLocked => Visible; | ||
|
||
public UnlockLabel() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
|
||
Visible = false; | ||
} | ||
|
||
private void UpdateUnlock() | ||
{ | ||
if (_nextUnlock is not {} next) | ||
return; | ||
|
||
var now = _timing.CurTime; | ||
if (now >= next) | ||
{ | ||
// unlocked now | ||
_nextUnlock = null; | ||
Visible = false; | ||
OnUnlock?.Invoke(); | ||
return; | ||
} | ||
|
||
Visible = true; | ||
var remaining = next - now; | ||
var time = $"{remaining.Minutes:00}:{remaining.Seconds:00}"; | ||
Text = Loc.GetString("contract-next-unlock", ("time", time)); | ||
} | ||
|
||
protected override void FrameUpdate(FrameEventArgs args) | ||
{ | ||
base.FrameUpdate(args); | ||
|
||
var now = _timing.CurTime; | ||
if (now < _nextUpdate) | ||
return; | ||
|
||
_nextUpdate = now + TimeSpan.FromSeconds(1); | ||
UpdateUnlock(); | ||
} | ||
} |
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
Oops, something went wrong.