-
Notifications
You must be signed in to change notification settings - Fork 70
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 blueshield
- Loading branch information
Showing
287 changed files
with
4,002 additions
and
1,659 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 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
54 changes: 54 additions & 0 deletions
54
Content.Client/_Sunrise/Pacificator/PacificatorBoundUserInterface.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,54 @@ | ||
using Content.Shared._Sunrise.Pacificator; | ||
using JetBrains.Annotations; | ||
|
||
namespace Content.Client._Sunrise.Pacificator | ||
{ | ||
[UsedImplicitly] | ||
public sealed class PacificatorBoundUserInterface : BoundUserInterface | ||
{ | ||
[ViewVariables] | ||
private PacificatorWindow? _window; | ||
|
||
public PacificatorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
|
||
_window = new PacificatorWindow(this); | ||
|
||
/* | ||
_window.Switch.OnPressed += _ => | ||
{ | ||
SendMessage(new SharedPacificatorComponent.SwitchGeneratorMessage(!IsOn)); | ||
}; | ||
*/ | ||
|
||
_window.OpenCentered(); | ||
_window.OnClose += Close; | ||
} | ||
|
||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
base.UpdateState(state); | ||
|
||
var castState = (GeneratorState) state; | ||
_window?.UpdateState(castState); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
if (!disposing) return; | ||
|
||
_window?.Dispose(); | ||
} | ||
|
||
public void SetPowerSwitch(bool on) | ||
{ | ||
SendMessage(new SwitchGeneratorMessage(on)); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
Content.Client/_Sunrise/Pacificator/PacificatorWindow.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,35 @@ | ||
<controls:FancyWindow xmlns="https://spacestation14.io" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
Title="Генератор пацифизма" | ||
MinSize="270 130" | ||
SetSize="360 180"> | ||
<BoxContainer Margin="4 0" Orientation="Horizontal"> | ||
<BoxContainer Orientation="Vertical" HorizontalExpand="True"> | ||
<GridContainer Margin="2 0 0 0" Columns="2"> | ||
<!-- Power --> | ||
<Label Text="{Loc 'gravity-generator-window-power'}" HorizontalExpand="True" StyleClasses="StatusFieldTitle" /> | ||
<BoxContainer Orientation="Horizontal" MinWidth="120"> | ||
<Button Name="OnButton" Text="{Loc 'gravity-generator-window-power-on'}" StyleClasses="OpenRight" /> | ||
<Button Name="OffButton" Text="{Loc 'gravity-generator-window-power-off'}" StyleClasses="OpenLeft" /> | ||
</BoxContainer> | ||
<Control /> <!-- Empty control to act as a spacer in the grid. --> | ||
<Label Name="PowerLabel" Text="0 / 0 W" /> | ||
<!-- Status --> | ||
<Label Text="{Loc 'gravity-generator-window-status'}" StyleClasses="StatusFieldTitle" /> | ||
<Label Name="StatusLabel" Text="{Loc 'gravity-generator-window-status-fully-charged'}" /> | ||
<!-- ETA --> | ||
<Label Text="{Loc 'gravity-generator-window-eta'}" StyleClasses="StatusFieldTitle" /> | ||
<Label Name="EtaLabel" Text="N/A" /> | ||
<!-- Charge --> | ||
<Label Text="{Loc 'gravity-generator-window-charge'}" StyleClasses="StatusFieldTitle" /> | ||
<ProgressBar Name="ChargeBar" MaxValue="255"> | ||
<Label Name="ChargeText" Margin="4 0" Text="0 %" /> | ||
</ProgressBar> | ||
</GridContainer> | ||
</BoxContainer> | ||
<PanelContainer Margin="12 0 0 0" StyleClasses="Inset" VerticalAlignment="Center"> | ||
<SpriteView Name="EntityView" SetSize="96 96" OverrideDirection="South" /> | ||
</PanelContainer> | ||
</BoxContainer> | ||
|
||
</controls:FancyWindow> |
73 changes: 73 additions & 0 deletions
73
Content.Client/_Sunrise/Pacificator/PacificatorWindow.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,73 @@ | ||
using Content.Shared._Sunrise.Pacificator; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using FancyWindow = Content.Client.UserInterface.Controls.FancyWindow; | ||
|
||
namespace Content.Client._Sunrise.Pacificator | ||
{ | ||
[GenerateTypedNameReferences] | ||
public sealed partial class PacificatorWindow : FancyWindow | ||
{ | ||
private readonly ButtonGroup _buttonGroup = new(); | ||
|
||
private readonly PacificatorBoundUserInterface _owner; | ||
|
||
public PacificatorWindow(PacificatorBoundUserInterface owner) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
|
||
_owner = owner; | ||
|
||
OnButton.Group = _buttonGroup; | ||
OffButton.Group = _buttonGroup; | ||
|
||
OnButton.OnPressed += _ => _owner.SetPowerSwitch(true); | ||
OffButton.OnPressed += _ => _owner.SetPowerSwitch(false); | ||
|
||
EntityView.SetEntity(owner.Owner); | ||
} | ||
|
||
public void UpdateState(GeneratorState state) | ||
{ | ||
if (state.On) | ||
OnButton.Pressed = true; | ||
else | ||
OffButton.Pressed = true; | ||
|
||
PowerLabel.Text = Loc.GetString( | ||
"gravity-generator-window-power-label", | ||
("draw", state.PowerDraw), | ||
("max", state.PowerDrawMax)); | ||
|
||
PowerLabel.SetOnlyStyleClass(MathHelper.CloseTo(state.PowerDraw, state.PowerDrawMax) ? "Good" : "Caution"); | ||
|
||
ChargeBar.Value = state.Charge; | ||
ChargeText.Text = (state.Charge / 255f).ToString("P0"); | ||
StatusLabel.Text = Loc.GetString(state.PowerStatus switch | ||
{ | ||
PacificatorPowerStatus.Off => "gravity-generator-window-status-off", | ||
PacificatorPowerStatus.Discharging => "gravity-generator-window-status-discharging", | ||
PacificatorPowerStatus.Charging => "gravity-generator-window-status-charging", | ||
PacificatorPowerStatus.FullyCharged => "gravity-generator-window-status-fully-charged", | ||
_ => throw new ArgumentOutOfRangeException() | ||
}); | ||
|
||
StatusLabel.SetOnlyStyleClass(state.PowerStatus switch | ||
{ | ||
PacificatorPowerStatus.Off => "Danger", | ||
PacificatorPowerStatus.Discharging => "Caution", | ||
PacificatorPowerStatus.Charging => "Caution", | ||
PacificatorPowerStatus.FullyCharged => "Good", | ||
_ => throw new ArgumentOutOfRangeException() | ||
}); | ||
|
||
EtaLabel.Text = state.EtaSeconds >= 0 | ||
? Loc.GetString("gravity-generator-window-eta-value", ("left", TimeSpan.FromSeconds(state.EtaSeconds))) | ||
: Loc.GetString("gravity-generator-window-eta-none"); | ||
|
||
EtaLabel.SetOnlyStyleClass(state.EtaSeconds >= 0 ? "Caution" : "Disabled"); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.