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 arumoon-server
- Loading branch information
Showing
41 changed files
with
157,966 additions
and
26,866 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,21 @@ | ||
<PanelContainer xmlns="https://spacestation14.io" | ||
HorizontalExpand="True"> | ||
<BoxContainer Name="Content" | ||
Orientation="Horizontal" | ||
HorizontalExpand="True"> | ||
<TextureRect Name="Icon" | ||
Access="Public" | ||
MinSize="32 32" | ||
RectClipContent="True" /> | ||
<BoxContainer Orientation="Vertical" | ||
HorizontalExpand="True" | ||
VerticalExpand="False"> | ||
<Label Name="ProductName" | ||
Access="Public" | ||
HorizontalExpand="True" | ||
ClipText="True" | ||
Margin="0 4 0 0"/> | ||
</BoxContainer> | ||
<!--Here go buttons which added in c#--> | ||
</BoxContainer> | ||
</PanelContainer> |
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,64 @@ | ||
using Content.Shared.Materials; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.Lathe.UI; | ||
|
||
/// <summary> | ||
/// This widget is one row in the lathe eject menu. | ||
/// </summary> | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class LatheMaterialEjector : PanelContainer | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
|
||
public string Material; | ||
public Action<string, int>? OnEjectPressed; | ||
public int VolumePerSheet; | ||
|
||
public LatheMaterialEjector(string material, Action<string, int>? onEjectPressed, int volumePerSheet, int maxEjectableSheets) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
|
||
Material = material; | ||
OnEjectPressed = onEjectPressed; | ||
VolumePerSheet = volumePerSheet; | ||
|
||
PopulateButtons(maxEjectableSheets); | ||
} | ||
|
||
public void PopulateButtons(int maxEjectableSheets) | ||
{ | ||
int[] sheetsToEjectArray = { 1, 5, 10, 30 }; | ||
|
||
foreach (int sheetsToEject in sheetsToEjectArray) | ||
{ | ||
var button = new Button() | ||
{ | ||
Name = $"{sheetsToEject}", | ||
Access = AccessLevel.Public, | ||
Text = Loc.GetString($"{sheetsToEject}"), | ||
MinWidth = 45, | ||
}; | ||
|
||
button.OnPressed += (_) => | ||
{ | ||
OnEjectPressed?.Invoke(Material, sheetsToEject); | ||
}; | ||
|
||
button.Disabled = maxEjectableSheets < sheetsToEject; | ||
|
||
if (_prototypeManager.TryIndex<MaterialPrototype>(Material, out var proto)) | ||
{ | ||
button.ToolTip = Loc.GetString("lathe-menu-tooltip-display", ("amount", sheetsToEject * VolumePerSheet), ("material", Loc.GetString(proto.Name))); | ||
} | ||
|
||
Content.AddChild(button); | ||
} | ||
} | ||
} |
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,16 @@ | ||
<DefaultWindow | ||
xmlns="https://spacestation14.io" | ||
Title="{Loc 'lathe-menu-materials-ejection-title'}" | ||
MinSize="300 100" | ||
SetSize="350 475"> | ||
<ScrollContainer MinHeight="80"> | ||
<BoxContainer | ||
Name="MaterialsList" | ||
Orientation="Vertical" | ||
SizeFlagsStretchRatio="8" | ||
HorizontalExpand="True" | ||
VerticalExpand="True"> | ||
<!-- Materials populated in C# file --> | ||
</BoxContainer> | ||
</ScrollContainer> | ||
</DefaultWindow> |
74 changes: 74 additions & 0 deletions
74
Content.Client/Lathe/UI/LatheMaterialsEjectionMenu.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,74 @@ | ||
using Content.Shared.Materials; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Prototypes; | ||
using System.Linq; | ||
|
||
namespace Content.Client.Lathe.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class LatheMaterialsEjectionMenu : DefaultWindow | ||
{ | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
|
||
private readonly SpriteSystem _spriteSystem; | ||
|
||
public event Action<string, int>? OnEjectPressed; | ||
|
||
public LatheMaterialsEjectionMenu() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
_spriteSystem = _entityManager.EntitySysManager.GetEntitySystem<SpriteSystem>(); | ||
} | ||
|
||
public void PopulateMaterials(EntityUid lathe) | ||
{ | ||
if (!_entityManager.TryGetComponent<MaterialStorageComponent>(lathe, out var materials)) | ||
return; | ||
|
||
MaterialsList.DisposeAllChildren(); | ||
|
||
foreach (var (materialId, volume) in materials.Storage) | ||
{ | ||
if (volume <= 0) | ||
continue; | ||
|
||
if (!_prototypeManager.TryIndex(materialId, out MaterialPrototype? material)) | ||
continue; | ||
|
||
var name = Loc.GetString(material.Name); | ||
int volumePerSheet = 0; | ||
int maxEjectableSheets = 0; | ||
|
||
if (material.StackEntity != null) | ||
{ | ||
var proto = _prototypeManager.Index<EntityPrototype>(material.StackEntity); | ||
name = proto.Name; | ||
|
||
if (proto.TryGetComponent<PhysicalCompositionComponent>(out var composition)) | ||
{ | ||
volumePerSheet = composition.MaterialComposition.FirstOrDefault(kvp => kvp.Key == materialId).Value; | ||
maxEjectableSheets = (int) MathF.Floor(volume / volumePerSheet); | ||
} | ||
} | ||
|
||
var row = new LatheMaterialEjector(materialId, OnEjectPressed, volumePerSheet, maxEjectableSheets) | ||
{ | ||
Icon = { Texture = _spriteSystem.Frame0(material.Icon) }, | ||
ProductName = { Text = name } | ||
}; | ||
|
||
MaterialsList.AddChild(row); | ||
} | ||
|
||
if (MaterialsList.ChildCount == 0) | ||
{ | ||
Close(); | ||
} | ||
} | ||
} | ||
|
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,13 +1,13 @@ | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Client.Message | ||
namespace Content.Client.Message; | ||
|
||
public static class RichTextLabelExt | ||
{ | ||
public static class RichTextLabelExt | ||
public static RichTextLabel SetMarkup(this RichTextLabel label, string markup) | ||
{ | ||
public static void SetMarkup(this RichTextLabel label, string markup) | ||
{ | ||
label.SetMessage(FormattedMessage.FromMarkup(markup)); | ||
} | ||
label.SetMessage(FormattedMessage.FromMarkup(markup)); | ||
return label; | ||
} | ||
} |
Oops, something went wrong.