-
Notifications
You must be signed in to change notification settings - Fork 355
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 Deep_frier
Signed-off-by: Colin-Tel <[email protected]>
- Loading branch information
Showing
848 changed files
with
21,025 additions
and
10,818 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
This file was deleted.
Oops, something went wrong.
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
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,59 @@ | ||
using System.Threading; | ||
using Content.Client.Stylesheets; | ||
using Robust.Client.UserInterface.Controls; | ||
using Timer = Robust.Shared.Timing.Timer; | ||
|
||
namespace Content.Client.Administration.UI; | ||
|
||
public static class AdminUIHelpers | ||
{ | ||
private static void ResetButton(Button button, ConfirmationData data) | ||
{ | ||
data.Cancellation.Cancel(); | ||
button.ModulateSelfOverride = null; | ||
button.Text = data.OriginalText; | ||
} | ||
|
||
public static bool RemoveConfirm(Button button, Dictionary<Button, ConfirmationData> confirmations) | ||
{ | ||
if (confirmations.Remove(button, out var data)) | ||
{ | ||
ResetButton(button, data); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public static void RemoveAllConfirms(Dictionary<Button, ConfirmationData> confirmations) | ||
{ | ||
foreach (var (button, confirmation) in confirmations) | ||
{ | ||
ResetButton(button, confirmation); | ||
} | ||
|
||
confirmations.Clear(); | ||
} | ||
|
||
public static bool TryConfirm(Button button, Dictionary<Button, ConfirmationData> confirmations) | ||
{ | ||
if (RemoveConfirm(button, confirmations)) | ||
return true; | ||
|
||
var data = new ConfirmationData(new CancellationTokenSource(), button.Text); | ||
confirmations[button] = data; | ||
|
||
Timer.Spawn(TimeSpan.FromSeconds(5), () => | ||
{ | ||
confirmations.Remove(button); | ||
button.ModulateSelfOverride = null; | ||
button.Text = data.OriginalText; | ||
}, data.Cancellation.Token); | ||
|
||
button.ModulateSelfOverride = StyleNano.ButtonColorCautionDefault; | ||
button.Text = Loc.GetString("admin-player-actions-confirm"); | ||
return false; | ||
} | ||
} | ||
|
||
public readonly record struct ConfirmationData(CancellationTokenSource Cancellation, string? OriginalText); |
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.