Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chemprentice #2646

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7310a80
Barely functional mini chemmaster
Temoffy Jan 2, 2025
72c9929
Merge branch 'chemprentice' of https://github.com/Temoffy/frontier-st…
Temoffy Jan 2, 2025
5dacf8e
temp commit, need to reset IDE
Temoffy Jan 2, 2025
baebb59
completed namespace swap
Temoffy Jan 2, 2025
75f144a
unduplicate duplicated code baby step 1
Temoffy Jan 2, 2025
30f8504
Undupicating code... done maybe?
Temoffy Jan 2, 2025
b31b338
strip pill, bottle, and output code. Limit volume and allow reactions…
Temoffy Jan 3, 2025
e91f7cb
sprite added, and I fixed the currently unused loaded chemmaster spri…
Temoffy Jan 4, 2025
65b4816
Final touches making it player-accessible? We'll find out.
Temoffy Jan 4, 2025
5a417aa
Merge branch 'master' into chemprentice
Temoffy Jan 4, 2025
8cd9d70
relax liscence
Temoffy Jan 4, 2025
bae4436
Merge branch 'chemprentice' of https://github.com/Temoffy/frontier-st…
Temoffy Jan 4, 2025
ae6d1f4
woe, horizontal line height, and woe
Temoffy Jan 4, 2025
8352f6e
bottles fit in (thank Dusty not me)
Temoffy Jan 4, 2025
843a6e8
Merge branch 'master' into chemprentice
Temoffy Jan 6, 2025
6c18746
spill on destroyed
Temoffy Jan 9, 2025
3614c9a
Merge branch 'chemprentice' of https://github.com/Temoffy/frontier-st…
Temoffy Jan 9, 2025
e128682
clean up, clean up, everybody everywhere!
Temoffy Jan 10, 2025
850fb34
unclean up unclean up, nobody, nowhere!
Temoffy Jan 12, 2025
62d0829
Merge branch 'chemprentice' of https://github.com/Temoffy/frontier-st…
Temoffy Jan 12, 2025
b2d2512
Revert "clean up, clean up, everybody everywhere!"
Temoffy Jan 12, 2025
9400677
discard args
Temoffy Jan 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Content.Client/Chemistry/UI/ChemMasterBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Content.Shared.Chemistry;
using Content.Shared.Containers.ItemSlots;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;

namespace Content.Client.Chemistry.UI
Expand Down Expand Up @@ -60,7 +59,7 @@ protected override void Open()
/// Update the ui each time new state data is sent from the server.
/// </summary>
/// <param name="state">
/// Data of the <see cref="SharedReagentDispenserComponent"/> that this ui represents.
/// Data of the <see cref="ChemMasterBoundUserInterfaceState"/> that this ui represents.
/// Sent from the server.
/// </param>
protected override void UpdateState(BoundUserInterfaceState state)
Expand Down
14 changes: 7 additions & 7 deletions Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
using Content.Client.UserInterface.Controls;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using static Robust.Client.UserInterface.Controls.BoxContainer;
using Robust.Client.UserInterface.XAML;
using Robust.Client.Utility;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using System.Linq;
using System.Numerics;
using Content.Shared.FixedPoint;
using static Robust.Client.UserInterface.Controls.BoxContainer;

namespace Content.Client.Chemistry.UI
{
/// <summary>
/// Client-side UI used to control a <see cref="SharedChemMasterComponent"/>
/// Client-side UI used to control a <see cref="ChemMasterBoundUserInterfaceState"/>
/// </summary>
[GenerateTypedNameReferences]
public sealed partial class ChemMasterWindow : FancyWindow
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
public event Action<BaseButton.ButtonEventArgs, ReagentButton>? OnReagentButtonPressed;
public readonly Button[] PillTypeButtons;

Expand Down Expand Up @@ -142,7 +142,7 @@ private string GenerateLabel(ChemMasterBoundUserInterfaceState state)
return "";

var reagent = state.BufferReagents.OrderBy(r => r.Quantity).First().Reagent;
_prototypeManager.TryIndex(reagent.Prototype, out ReagentPrototype? proto);
_prototype.TryIndex(reagent.Prototype, out ReagentPrototype? proto);
return proto?.LocalizedName ?? "";
}

Expand Down Expand Up @@ -185,7 +185,7 @@ private void UpdatePanelInfo(ChemMasterBoundUserInterfaceState state)
foreach (var (reagent, quantity) in state.BufferReagents.OrderBy(x => x.Reagent.Prototype)) // Frontier: add OrderBy
{
// Try to get the prototype for the given reagent. This gives us its name.
_prototypeManager.TryIndex(reagent.Prototype, out ReagentPrototype? proto);
_prototype.TryIndex(reagent.Prototype, out ReagentPrototype? proto);
var name = proto?.LocalizedName ?? Loc.GetString("chem-master-window-unknown-reagent-text");

if (proto != null)
Expand Down Expand Up @@ -256,7 +256,7 @@ private void BuildContainerUI(Control control, ContainerInfo? info, bool addReag
{
contents = info.Reagents.Select(x =>
{
_prototypeManager.TryIndex(x.Reagent.Prototype, out ReagentPrototype? proto);
_prototype.TryIndex(x.Reagent.Prototype, out ReagentPrototype? proto);
var name = proto?.LocalizedName
?? Loc.GetString("chem-master-window-unknown-reagent-text");

Expand Down
61 changes: 61 additions & 0 deletions Content.Client/_NF/Chemistry/UI/ChemPrenticeBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Content.Shared._NF.Chemistry;
using Content.Shared.Chemistry;
using Content.Shared.Containers.ItemSlots;
using JetBrains.Annotations;
using Robust.Client.UserInterface;

namespace Content.Client._NF.Chemistry.UI
{
/// <summary>
/// Initializes a <see cref="ChemPrenticeWindow"/> and updates it when new server messages are received.
/// </summary>
[UsedImplicitly]
public sealed class ChemPrenticeBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private ChemPrenticeWindow? _window;

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

/// <summary>
/// Called each time a chem master UI instance is opened. Generates the window and fills it with
/// relevant info. Sets the actions for static buttons.
/// </summary>
protected override void Open()
{
base.Open();

// Setup window layout/elements
_window = this.CreateWindow<ChemPrenticeWindow>();
_window.Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName;

// Setup static button actions.
_window.InputEjectButton.OnPressed += _ => SendMessage(
new ItemSlotButtonPressedEvent(SharedChemMaster.InputSlotName));
_window.BufferTransferButton.OnPressed += _ => SendMessage(
new ChemMasterSetModeMessage(ChemMasterMode.Transfer));
_window.BufferDiscardButton.OnPressed += _ => SendMessage(
new ChemMasterSetModeMessage(ChemMasterMode.Discard));

_window.OnReagentButtonPressed += (args, button) => SendMessage(new ChemMasterReagentAmountButtonMessage(button.Id, button.Amount, button.IsBuffer));
Temoffy marked this conversation as resolved.
Show resolved Hide resolved
}

/// <summary>
/// Update the ui each time new state data is sent from the server.
/// </summary>
/// <param name="state">
/// Data of the <see cref="ChemPrenticeBoundUserInterfaceState"/> that this ui represents.
/// Sent from the server.
/// </param>
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

var castState = (ChemPrenticeBoundUserInterfaceState)state;

_window?.UpdateState(castState); // Update window state
}
}
}
53 changes: 53 additions & 0 deletions Content.Client/_NF/Chemistry/UI/ChemPrenticeWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
MinSize="512 256"
Title="{Loc 'chem-master-bound-user-interface-title'}">
<BoxContainer Orientation="Vertical" HorizontalExpand="True" Margin="5" SeparationOverride="10">
<!-- Input container info -->
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'chem-master-window-container-label'}" />
<Control HorizontalExpand="True" />
<Button MinSize="80 0" Name="InputEjectButton" Access="Public" Text="{Loc 'chem-master-window-eject-button'}" />
</BoxContainer>

<PanelContainer VerticalExpand="True" MinSize="0 100">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1E1B" />
</PanelContainer.PanelOverride>

<ScrollContainer HorizontalExpand="True" MinSize="0 100">
<!-- Initially empty, when server sends state data this will have container contents and fill volume.-->
<BoxContainer Name="InputContainerInfo" Orientation="Vertical" Margin="4" HorizontalExpand="True">
<Label Text="{Loc 'chem-master-window-no-container-loaded-text'}" />
</BoxContainer>
</ScrollContainer>
</PanelContainer>

<!-- Padding -->
<Control MinSize="0 10" />

<!-- Buffer -->
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'chem-master-window-buffer-text'}" />
<Control HorizontalExpand="True" />
<Button MinSize="80 0" Name="BufferTransferButton" Access="Public" Text="{Loc 'chem-master-window-transfer-button'}" ToggleMode="True" StyleClasses="OpenRight" />
<Button MinSize="80 0" Name="BufferDiscardButton" Access="Public" Text="{Loc 'chem-master-window-discard-button'}" ToggleMode="True" StyleClasses="OpenLeft" />
</BoxContainer>

<!-- Buffer info -->
<PanelContainer VerticalExpand="True" MinSize="0 150">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1E1B" />
</PanelContainer.PanelOverride>

<ScrollContainer HorizontalExpand="True" MinSize="0 150">
<!-- Buffer reagent list -->
<BoxContainer Name="BufferInfo" Orientation="Vertical" Margin="4" HorizontalExpand="True">
<Label Text="{Loc 'chem-master-window-buffer-empty-text'}" />
</BoxContainer>
</ScrollContainer>
</PanelContainer>
</BoxContainer>
</controls:FancyWindow>
Loading
Loading