forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 32
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-ru' into 'master-ru'
Upstream update & Localization (Fuelable generators) See merge request Workbench-Team/space-station-14!99
- Loading branch information
Showing
264 changed files
with
1,618 additions
and
448 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<controls:FancyWindow xmlns="https://spacestation14.io" | ||
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
MinSize="350 130" | ||
SetSize="360 180" | ||
Title="{Loc 'generator-ui-title'}"> | ||
<BoxContainer Margin="4 0" Orientation="Horizontal"> | ||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="2" VerticalAlignment="Center" Margin="5"> | ||
<GridContainer Margin="2 0 0 0" Columns="2" HorizontalExpand="True"> | ||
<!-- Power --> | ||
<Label Text="{Loc 'generator-ui-target-power-label'}"/> | ||
<SpinBox Name="TargetPower" HorizontalExpand="True"/> | ||
<Label Text="{Loc 'generator-ui-efficiency-label'}"/> | ||
<Label Name="Efficiency" Text="???%" HorizontalExpand="True"/> | ||
<Label Text="{Loc 'generator-ui-fuel-use-label'}"/> | ||
<ProgressBar Name="FuelFraction" MinValue="0" MaxValue="1" HorizontalExpand="True"/> | ||
<Label Text="{Loc 'generator-ui-fuel-left-label'}"/> | ||
<Label Name="FuelLeft" Text="0" HorizontalExpand="True"/> | ||
</GridContainer> | ||
</BoxContainer> | ||
<cc:VSeparator StyleClasses="LowDivider"/> | ||
<PanelContainer Margin="12 0 0 0" StyleClasses="Inset" VerticalAlignment="Center"> | ||
<SpriteView Name="EntityView" SetSize="64 64" Scale="2 2" OverrideDirection="South" Margin="15"/> | ||
</PanelContainer> | ||
</BoxContainer> | ||
</controls:FancyWindow> |
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,57 @@ | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared.Power.Generator; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client.Power.Generator; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class GeneratorWindow : FancyWindow | ||
{ | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
|
||
private readonly FuelGeneratorComponent? _component; | ||
private SolidFuelGeneratorComponentBuiState? _lastState; | ||
|
||
public GeneratorWindow(SolidFuelGeneratorBoundUserInterface bui, EntityUid vis) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
|
||
_entityManager.TryGetComponent(vis, out _component); | ||
|
||
EntityView.SetEntity(vis); | ||
TargetPower.IsValid += IsValid; | ||
TargetPower.ValueChanged += (args) => | ||
{ | ||
bui.SetTargetPower(args.Value); | ||
}; | ||
} | ||
|
||
private bool IsValid(int arg) | ||
{ | ||
if (arg < 0) | ||
return false; | ||
|
||
if (arg > (_lastState?.MaximumPower / 1000.0f ?? 0)) | ||
return false; | ||
|
||
return true; | ||
} | ||
|
||
public void Update(SolidFuelGeneratorComponentBuiState state) | ||
{ | ||
if (_component == null) | ||
return; | ||
|
||
var oldState = _lastState; | ||
_lastState = state; | ||
// ReSharper disable once CompareOfFloatsByEqualityOperator | ||
if (oldState?.TargetPower != state.TargetPower) | ||
TargetPower.OverrideValue((int)(state.TargetPower / 1000.0f)); | ||
Efficiency.Text = SharedGeneratorSystem.CalcFuelEfficiency(state.TargetPower, state.OptimalPower, _component).ToString("P1"); | ||
FuelFraction.Value = state.RemainingFuel - (int) state.RemainingFuel; | ||
FuelLeft.Text = ((int) MathF.Floor(state.RemainingFuel)).ToString(); | ||
|
||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
Content.Client/Power/Generator/SolidFuelGeneratorBoundUserInterface.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,42 @@ | ||
using Content.Shared.Power.Generator; | ||
using JetBrains.Annotations; | ||
using Robust.Client.GameObjects; | ||
|
||
namespace Content.Client.Power.Generator; | ||
|
||
[UsedImplicitly] | ||
public sealed class SolidFuelGeneratorBoundUserInterface : BoundUserInterface | ||
{ | ||
private GeneratorWindow? _window; | ||
|
||
public SolidFuelGeneratorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
_window = new GeneratorWindow(this, Owner); | ||
|
||
_window.OpenCenteredLeft(); | ||
_window.OnClose += Close; | ||
} | ||
|
||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
if (state is not SolidFuelGeneratorComponentBuiState msg) | ||
return; | ||
|
||
_window?.Update(msg); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
_window?.Dispose(); | ||
} | ||
|
||
public void SetTargetPower(int target) | ||
{ | ||
SendMessage(new SetTargetPowerMessage(target)); | ||
} | ||
} |
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
Oops, something went wrong.