Skip to content

Commit

Permalink
Merge remote-tracking branch 'EE-Master/master' into Update-2-8-2025
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed Feb 8, 2025
2 parents da4319b + 06ac422 commit 145e856
Show file tree
Hide file tree
Showing 733 changed files with 468,315 additions and 5,120 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Arcade/BlockGameMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private Control SetupGameGrid(Texture panelTex)
{
PanelOverride = back,
HorizontalExpand = true,
SizeFlagsStretchRatio = 60
SizeFlagsStretchRatio = 34.25f
};
var backgroundPanel = new PanelContainer
{
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Arcade/UI/BlockGameBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ protected override void Open()
base.Open();

_menu = this.CreateWindow<BlockGameMenu>();
_menu.OnAction += SendAction;
}

protected override void ReceiveMessage(BoundUserInterfaceMessage message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ protected override void Open()
base.Open();

_menu = this.CreateWindow<SpaceVillainArcadeMenu>();
_menu.OnPlayerAction += SendAction;
}

protected override void ReceiveMessage(BoundUserInterfaceMessage message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected override void Open()
_window.OnReagentButtonPressed += (_, button, amount, isOutput) => SendMessage(new ChemMasterReagentAmountButtonMessage(button.Id, amount, button.IsBuffer, isOutput));
_window.OnSortMethodChanged += sortMethod => SendMessage(new ChemMasterSortMethodUpdated(sortMethod));
_window.OnTransferAmountChanged += amount => SendMessage(new ChemMasterTransferringAmountUpdated(amount));
_window.OnUpdateAmounts += amounts => SendMessage(new ChemMasterAmountsUpdated(amounts));
}

/// <summary>
Expand Down
8 changes: 7 additions & 1 deletion Content.Client/Chemistry/UI/ChemMasterWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,18 @@
</PanelContainer>
<RichTextLabel Name="AmountLabel" Text="{Loc 'chem-master-window-transferring-default-label'}" Margin="0 0 7 0" />
<LineEdit MinSize="140 0" Name="AmountLineEdit" Access="Public" PlaceHolder="{Loc 'chem-master-window-amount-placeholder'}" />
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Button Name="SetAmountButton" Text="{Loc 'chem-master-window-set-amount-label'}" HorizontalExpand="True" StyleClasses="OpenRight"/>
<Button Name="SaveAsFrequentButton" Text="{Loc 'chem-master-window-save-as-frequent-label'}" HorizontalExpand="True" StyleClasses="OpenLeft"/>
</BoxContainer>
<RichTextLabel Text="Both of the above buttons use the textbox" />
<Control MinSize="0 5" />
<GridContainer
Name="AmountButtons"
VerticalExpand="True"
HorizontalExpand="True"
Margin="2 2 2 2"
Columns="5" />
Columns="4" />
</BoxContainer>
</BoxContainer>
</controls:FancyWindow>
55 changes: 42 additions & 13 deletions Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ public sealed partial class ChemMasterWindow : FancyWindow
public event Action<int>? OnAmountButtonPressed;
public event Action<int>? OnSortMethodChanged;
public event Action<int>? OnTransferAmountChanged;
public event Action<List<int>>? OnUpdateAmounts;

public readonly Button[] PillTypeButtons;

private List<int> _amounts = new();

private const string TransferringAmountColor = "#ffffff";
private ReagentSortMethod _currentSortMethod = ReagentSortMethod.Alphabetical;
private ChemMasterBoundUserInterfaceState? _lastState;
Expand All @@ -48,7 +52,9 @@ public ChemMasterWindow()

AmountLabel.HorizontalAlignment = HAlignment.Center;
AmountLineEdit.OnTextEntered += SetAmount;
AmountLineEdit.OnFocusExit += SetAmount;

SetAmountButton.OnPressed += _ => SetAmountText(AmountLineEdit.Text);
SaveAsFrequentButton.OnPressed += HandleSaveAsFrequentPressed;

// Pill type selection buttons, in total there are 20 pills.
// Pill rsi file should have states named as pill1, pill2, and so on.
Expand Down Expand Up @@ -130,15 +136,19 @@ public ChemMasterWindow()
BufferTransferButton.OnPressed += HandleDiscardTransferPress;
BufferDiscardButton.OnPressed += HandleDiscardTransferPress;

var amounts = new List<int>()
{
1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 125, 150, 175, 200, 225, 250, 275, 300, 500
};
CreateAmountButtons();

OnAmountButtonPressed += amount => SetAmountText(amount.ToString());
}

private void CreateAmountButtons()
{
AmountButtons.DisposeAllChildren();

for (int i = 0; i < amounts.Count; i++)
for (int i = 0; i < _amounts.Count; i++)
{
var styleClass = StyleBase.ButtonOpenBoth;
var amount = amounts[i];
var amount = _amounts[i];
var columns = AmountButtons.Columns;

if (i == 0 || i % columns == 0)
Expand All @@ -158,8 +168,17 @@ public ChemMasterWindow()
button.OnPressed += _ => OnAmountButtonPressed?.Invoke(amount);
AmountButtons.AddChild(button);
}
}

OnAmountButtonPressed += amount => SetAmountText(amount.ToString());
private void HandleSaveAsFrequentPressed(BaseButton.ButtonEventArgs args)
{
if (!int.TryParse(AmountLineEdit.Text, out var amount)
|| _amounts.Any(a => amount == a))
return;

_amounts.Add(amount);
_amounts.Sort();
CreateAmountButtons();
}

private void HandleDiscardTransferPress(BaseButton.ButtonEventArgs args)
Expand Down Expand Up @@ -201,7 +220,7 @@ private void SortUpdated()
UpdatePanelInfo(_lastState);
}

private bool ValidateAmount(string newText)
private bool ValidateAmount(string newText, bool invokeEvent = true)
{
if (string.IsNullOrWhiteSpace(newText) || !int.TryParse(newText, out int amount))
{
Expand All @@ -210,16 +229,19 @@ private bool ValidateAmount(string newText)
}

_transferAmount = amount;
OnTransferAmountChanged?.Invoke(amount);

if (invokeEvent)
OnTransferAmountChanged?.Invoke(amount);

return true;
}

private void SetAmount(LineEdit.LineEditEventArgs args) =>
SetAmountText(args.Text);

private void SetAmountText(string newText)
private void SetAmountText(string newText, bool invokeEvent = true)
{
if (newText == _transferAmount.ToString() || !ValidateAmount(newText))
if (newText == _transferAmount.ToString() || !ValidateAmount(newText, invokeEvent))
return;

var localizedAmount = Loc.GetString(
Expand Down Expand Up @@ -274,7 +296,14 @@ public void UpdateState(BoundUserInterfaceState state)
// Ensure the Panel Info is updated, including UI elements for Buffer Volume, Output Container and so on
UpdatePanelInfo(castState);
HandleSortMethodChange(castState.SortMethod);
SetAmountText(castState.TransferringAmount.ToString());
SetAmountText(castState.TransferringAmount.ToString(), false);

if (_amounts != castState.Amounts)
{
_amounts = castState.Amounts;
_amounts.Sort();
CreateAmountButtons();
}

BufferCurrentVolume.Text = $" {castState.PillBufferCurrentVolume?.Int() ?? 0}u";

Expand Down
11 changes: 11 additions & 0 deletions Content.Client/Crayon/CrayonSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ protected override void FrameUpdate(FrameEventArgs args)
}

_parent.UIUpdateNeeded = false;

// Frontier: unlimited crayon, Delta V Port
if (_parent.Capacity == int.MaxValue)
{
_label.SetMarkup(Robust.Shared.Localization.Loc.GetString("crayon-drawing-label-unlimited",
("color", _parent.Color),
("state", _parent.SelectedState)));
return;
}
// End Frontier, Delta V Port

_label.SetMarkup(Robust.Shared.Localization.Loc.GetString("crayon-drawing-label",
("color",_parent.Color),
("state",_parent.SelectedState),
Expand Down
37 changes: 37 additions & 0 deletions Content.Client/DeltaV/AACTablet/UI/AACBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Content.Shared.DeltaV.AACTablet;
using Content.Shared.DeltaV.QuickPhrase;
using Robust.Shared.Prototypes;

namespace Content.Client.DeltaV.AACTablet.UI;

public sealed class AACBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private AACWindow? _window;

public AACBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
base.Open();
_window?.Close();
_window = new AACWindow();
_window.OpenCentered();

_window.PhraseButtonPressed += OnPhraseButtonPressed;
_window.OnClose += Close;
}

private void OnPhraseButtonPressed(ProtoId<QuickPhrasePrototype> phraseId)
{
SendMessage(new AACTabletSendPhraseMessage(phraseId));
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_window?.Orphan();
}
}
9 changes: 9 additions & 0 deletions Content.Client/DeltaV/AACTablet/UI/AACWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="AAC Tablet"
Resizable="False"
SetSize="540 300"
MinSize="540 300">
<ScrollContainer HScrollEnabled="False" Name="WindowBody">
</ScrollContainer>
</controls:FancyWindow>
152 changes: 152 additions & 0 deletions Content.Client/DeltaV/AACTablet/UI/AACWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
using System.Linq;
using System.Numerics;
using Content.Client.UserInterface.Controls;
using Content.Shared.DeltaV.QuickPhrase;
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.DeltaV.AACTablet.UI;

[GenerateTypedNameReferences]
public sealed partial class AACWindow : FancyWindow
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
public event Action<ProtoId<QuickPhrasePrototype>>? PhraseButtonPressed;

private const float SpaceWidth = 10f;
private const float ParentWidth = 540f;
private const int ColumnCount = 4;

private const int ButtonWidth =
(int)((ParentWidth - SpaceWidth * 2) / ColumnCount - SpaceWidth * ((ColumnCount - 1f) / ColumnCount));

public AACWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
PopulateGui();
}

private void PopulateGui()
{
var phrases = _prototype.EnumeratePrototypes<QuickPhrasePrototype>().ToList();

// take ALL phrases and turn them into tabs and groups, so the buttons are sorted and tabbed
var sortedTabs = phrases
.GroupBy(p => p.Tab)
.OrderBy(g => g.Key)
.ToDictionary(
g => g.Key,
g => g.GroupBy(p => p.Group)
.OrderBy(gg => gg.Key)
.ToDictionary(
gg => gg.Key,
gg => gg.OrderBy(p => Loc.GetString(p.Text)).ToList()
)
);

var tabContainer = CreateTabContainer(sortedTabs);
WindowBody.AddChild(tabContainer);
}

private TabContainer CreateTabContainer(Dictionary<string, Dictionary<string, List<QuickPhrasePrototype>>> sortedTabs)
{
var tabContainer = new TabContainer();

foreach (var tab in sortedTabs)
{
var tabName = Loc.GetString(tab.Key);
var boxContainer = CreateBoxContainerForTab(tab.Value);
tabContainer.AddChild(boxContainer);
tabContainer.SetTabTitle(tabContainer.ChildCount - 1, tabName);
}

return tabContainer;
}

private BoxContainer CreateBoxContainerForTab(Dictionary<string, List<QuickPhrasePrototype>> groups)
{
var boxContainer = new BoxContainer
{
HorizontalExpand = true,
Orientation = BoxContainer.LayoutOrientation.Vertical
};

foreach (var group in groups)
{
var header = CreateHeaderForGroup(group.Key);
var buttonContainer = CreateButtonContainerForGroup(group.Value);
boxContainer.AddChild(header);
boxContainer.AddChild(buttonContainer);
}

return boxContainer;
}

private static Label CreateHeaderForGroup(string groupName)
{
var header = new Label
{
HorizontalExpand = true,
Text = groupName,
Margin = new Thickness(10, 10, 10, 0),
StyleClasses = { "LabelBig" }
};

return header;
}

private GridContainer CreateButtonContainerForGroup(List<QuickPhrasePrototype> phrases)
{
var buttonContainer = CreateButtonContainer();
foreach (var phrase in phrases)
{
var text = Loc.GetString(phrase.Text);
var button = CreatePhraseButton(text, phrase.StyleClass);
button.OnPressed += _ => OnPhraseButtonPressed(new ProtoId<QuickPhrasePrototype>(phrase.ID));
buttonContainer.AddChild(button);
}
return buttonContainer;
}

private static GridContainer CreateButtonContainer()
{
var buttonContainer = new GridContainer
{
Margin = new Thickness(10),
Columns = 4
};

return buttonContainer;
}

private static Button CreatePhraseButton(string text, string styleClass)
{
var phraseButton = new Button
{
Access = AccessLevel.Public,
MaxSize = new Vector2(ButtonWidth, ButtonWidth),
ClipText = false,
HorizontalExpand = true,
StyleClasses = { styleClass }
};

var buttonLabel = new RichTextLabel
{
Margin = new Thickness(0, 5),
StyleClasses = { "WhiteText" }
};

buttonLabel.SetMessage(text);
phraseButton.AddChild(buttonLabel);
return phraseButton;
}

private void OnPhraseButtonPressed(ProtoId<QuickPhrasePrototype> phraseId)
{
PhraseButtonPressed?.Invoke(phraseId);
}
}
Loading

0 comments on commit 145e856

Please sign in to comment.