-
Notifications
You must be signed in to change notification settings - Fork 577
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 2024-12-28-FixYaRace
- Loading branch information
Showing
32 changed files
with
397 additions
and
260 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
Content.Client/Stack/StackCustomSplitBoundUserInterface.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,41 @@ | ||
// Cherry-picked from space-station-14#32938 courtesy of Ilya246 | ||
using JetBrains.Annotations; | ||
using Content.Shared.Stacks; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.UserInterface; | ||
|
||
namespace Content.Client.Stack | ||
{ | ||
[UsedImplicitly] | ||
public sealed class StackCustomSplitBoundUserInterface : BoundUserInterface | ||
{ | ||
private IEntityManager _entManager; | ||
private EntityUid _owner; | ||
[ViewVariables] | ||
private StackCustomSplitWindow? _window; | ||
|
||
public StackCustomSplitBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
_owner = owner; | ||
_entManager = IoCManager.Resolve<IEntityManager>(); | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
_window = this.CreateWindow<StackCustomSplitWindow>(); | ||
|
||
if (_entManager.TryGetComponent<StackComponent>(_owner, out var comp)) | ||
_window.SetMax(comp.Count); | ||
|
||
_window.ApplyButton.OnPressed += _ => | ||
{ | ||
if (int.TryParse(_window.AmountLineEdit.Text, out var i)) | ||
{ | ||
SendMessage(new StackCustomSplitAmountMessage(i)); | ||
_window.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<DefaultWindow xmlns="https://spacestation14.io" | ||
Title="{Loc 'ui-custom-stack-split-title'}" | ||
Resizable="False"> | ||
<!--Cherry-picked from space-station-14#32938 courtesy of Ilya246--> | ||
|
||
<BoxContainer Orientation="Vertical" SeparationOverride="4" MinSize="240 80"> | ||
<BoxContainer Orientation="Horizontal"> | ||
<LineEdit Name="AmountLineEdit" Access="Public" HorizontalExpand="True" PlaceHolder="{Loc 'ui-custom-stack-split-line-edit-placeholder'}"/> | ||
</BoxContainer> | ||
<BoxContainer Orientation="Horizontal"> | ||
<Label Name="MaximumAmount" Access="Public" /> | ||
</BoxContainer> | ||
<Button Name="ApplyButton" Access="Public" Text="{Loc 'ui-custom-stack-split-apply'}"/> | ||
</BoxContainer> | ||
</DefaultWindow> |
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 @@ | ||
// Cherry-picked from space-station-14#32938 courtesy of Ilya246 | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client.Stack | ||
{ | ||
[GenerateTypedNameReferences] | ||
public sealed partial class StackCustomSplitWindow : DefaultWindow | ||
{ | ||
private int _max = Int32.MaxValue; | ||
private int _min = 1; | ||
|
||
public StackCustomSplitWindow() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
AmountLineEdit.OnTextChanged += OnValueChanged; | ||
} | ||
|
||
public void SetMax(int max) | ||
{ | ||
_max = max; | ||
MaximumAmount.Text = Loc.GetString("comp-stack-split-size", ("size", _max)); | ||
} | ||
|
||
private void OnValueChanged(LineEdit.LineEditEventArgs args) | ||
{ | ||
if (!int.TryParse(AmountLineEdit.Text, out var amount) || amount > _max || amount < _min) | ||
ApplyButton.Disabled = true; | ||
else | ||
ApplyButton.Disabled = false; | ||
} | ||
} | ||
} |
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 @@ | ||
using Content.Shared.Chemistry.Components; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server._NF.Chemistry; | ||
|
||
public sealed class RandomPillSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
|
||
public const int MaxPillType = 21; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<PillComponent, MapInitEvent>(OnMapInit); | ||
} | ||
|
||
private void OnMapInit(Entity<PillComponent> ent, ref MapInitEvent componentInit) | ||
{ | ||
if (ent.Comp.Random) | ||
{ | ||
ent.Comp.PillType = (uint)_random.Next(MaxPillType); | ||
Dirty(ent); | ||
} | ||
} | ||
} |
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.