Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Separate microwave recipes into multiple machines (electric range, as…
Browse files Browse the repository at this point in the history
…sembler, medical assembler) (new-frontiers-14#1935)

* Oven, first pass

* Fix oven range

* Fix the oven range

* EntityHeater: passive power draw

* Add placeholder assembler

* Microwave recipe types (machine restrictions)

* Add canHeat/canIrradiate to Microwave

* Port EE#783 (Thank you, Mnemotechnician)

* Revert machine type changes to meal recipes

* Unneeded dependencies, show search bar

* Remove yet more microwave recipe machine types

* Multiple devices per recipe

* Food recipe guidebook: cleanup, style consistency

* Frontier comment cleanup

* Assembler UI proof of concept

* Assembler UI rework, fix recipes, mediwave layer

* Add machines to kitchen shuttles/POIs

* NFSD POI microwave

* Resolve GuideFoodSource merge conflicts

* Assembler sounds

* techs, "food-o-mat", minor fixes

* Update mccargo.yml

* Move this

* Syndicate Oven Baseline

* Donk co. range sprite

* Syndicate Range

* Update cove.yml

* Update dungeon_items_kitchen.yml

* Add syndicate texture

---------

Co-authored-by: Dvir <[email protected]>
Co-authored-by: Dvir <[email protected]>
  • Loading branch information
3 people authored Oct 12, 2024
1 parent 05da717 commit 2479231
Show file tree
Hide file tree
Showing 94 changed files with 2,163 additions and 1,106 deletions.
21 changes: 21 additions & 0 deletions Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,24 @@ public sealed class MicrowaveBoundUserInterface : BoundUserInterface
[ViewVariables]
private readonly Dictionary<int, ReagentQuantity> _reagents = new();

// Frontier: UI parameters
private readonly string _menuTitle;
private readonly string _leftFlavorText;

public MicrowaveBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
// Frontier: switch UI params based on key
if ((MicrowaveUiKey)uiKey == MicrowaveUiKey.ElectricRangeKey)
{
_menuTitle = "microwave-menu-range-title";
_leftFlavorText = "microwave-menu-range-footer-flavor-left";
}
else
{
_menuTitle = "microwave-menu-title";
_leftFlavorText = "microwave-menu-footer-flavor-left";
}
// End Frontier
}

protected override void Open()
Expand Down Expand Up @@ -60,6 +76,11 @@ protected override void Open()
("time", Loc.GetString("microwave-menu-instant-button")));
}
};

// Frontier: UI customization
_menu.Title = Loc.GetString(_menuTitle);
_menu.LeftFooter.Text = Loc.GetString(_leftFlavorText);
// End Frontier
}

protected override void UpdateState(BoundUserInterfaceState state)
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Kitchen/UI/MicrowaveMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<BoxContainer Orientation="Vertical">
<PanelContainer StyleClasses="LowDivider" />
<BoxContainer Orientation="Horizontal" Margin="10 2 5 0" VerticalAlignment="Bottom">
<Label Text="{Loc 'microwave-menu-footer-flavor-left'}" StyleClasses="WindowFooterText" />
<Label Text="{Loc 'microwave-menu-footer-flavor-left'}" StyleClasses="WindowFooterText" Name="LeftFooter" Access="Public"/> <!-- Frontier: add Name, Access -->
<Label Text="{Loc 'microwave-menu-footer-flavor-right'}" StyleClasses="WindowFooterText"
HorizontalAlignment="Right" HorizontalExpand="True" Margin="0 0 5 0" />
<TextureRect StyleClasses="NTLogoDark" Stretch="KeepAspectCentered" VerticalAlignment="Center" HorizontalAlignment="Right" SetSize="19 19"/>
Expand Down
5 changes: 2 additions & 3 deletions Content.Client/_EE/Guidebook/Controls/GuideFoodSource.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
Margin="2 0 0 0"/> <!-- Frontier: Label<RichTextLabel -->
</BoxContainer>
<BoxContainer Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center"> <!-- Frontier: remove HorizontalExpand -->
<TextureRect HorizontalAlignment="Center"
Name="ProcessingTexture"
Access="Public"/>
<BoxContainer Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalExpand="True" Name="ProcessingTextures"> <!-- Frontier: support for multiple machines -->
</BoxContainer>
<RichTextLabel Name="ProcessingLabel"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Expand Down
58 changes: 53 additions & 5 deletions Content.Client/_EE/Guidebook/Controls/GuideFoodSource.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Client.UserInterface.ControlExtensions;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Content.Shared.Kitchen; // Frontier
using Content.Shared.Nutrition.Components;
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
Expand Down Expand Up @@ -63,11 +64,13 @@ private void GenerateControl(FoodButcheringData entry)
SetSource(ent);
ProcessingLabel.Text = Loc.GetString("guidebook-food-processing-butchering");

ProcessingTexture.Texture = entry.Type switch
var processingTexture = new TextureRect(); // Frontier
processingTexture.Texture = entry.Type switch
{
ButcheringType.Knife => GetRsiTexture("/Textures/Objects/Weapons/Melee/kitchen_knife.rsi", "icon"),
_ => GetRsiTexture("/Textures/Structures/meat_spike.rsi", "spike")
};
ProcessingTextures.AddChild(processingTexture); // Frontier
}

private void GenerateControl(FoodSlicingData entry)
Expand All @@ -80,7 +83,9 @@ private void GenerateControl(FoodSlicingData entry)

SetSource(ent);
ProcessingLabel.Text = Loc.GetString("guidebook-food-processing-slicing");
ProcessingTexture.Texture = GetRsiTexture("/Textures/Objects/Misc/utensils.rsi", "plastic_knife");
var processingTexture = new TextureRect(); // Frontier
processingTexture.Texture = GetRsiTexture("/Textures/Objects/Misc/utensils.rsi", "plastic_knife");
ProcessingTextures.AddChild(processingTexture); // Frontier
}

private void GenerateControl(FoodRecipeData entry)
Expand All @@ -101,8 +106,49 @@ private void GenerateControl(FoodRecipeData entry)
var combinedIngredients = string.Join("\n", combinedLiquids.Union(combinedSolids));
SourceLabel.Text = Loc.GetString("guidebook-food-processing-recipe", ("ingredients", combinedIngredients)); // Frontier: SetMessage<Text

ProcessingTexture.Texture = GetRsiTexture("/Textures/Structures/Machines/microwave.rsi", "mw");
ProcessingLabel.Text = Loc.GetString("guidebook-food-processing-cooking", ("time", recipe.CookTime));
// Frontier: multiple machine types
var recipeType = (MicrowaveRecipeType)recipe.RecipeType;
TextureRect processingTexture;
List<string> processingTypes = new();
if (recipeType.HasFlag(MicrowaveRecipeType.Microwave))
{
processingTexture = new TextureRect();
if (recipe.SecretRecipe)
processingTexture.Texture = GetRsiTexture("/Textures/Structures/Machines/microwave_syndie.rsi", "mw");
else
processingTexture.Texture = GetRsiTexture("/Textures/Structures/Machines/microwave.rsi", "mw");
ProcessingTextures.AddChild(processingTexture);
processingTypes.Add(Loc.GetString("guidebook-food-processing-type-microwave"));
}
if (recipeType.HasFlag(MicrowaveRecipeType.Oven))
{
processingTexture = new TextureRect();
if (recipe.SecretRecipe)
processingTexture.Texture = GetRsiTexture("/Textures/_NF/Structures/Machines/oven_syndie.rsi", "composite_off");
else
processingTexture.Texture = GetRsiTexture("/Textures/_NF/Structures/Machines/oven.rsi", "composite_off");
ProcessingTextures.AddChild(processingTexture);
processingTypes.Add(Loc.GetString("guidebook-food-processing-type-oven"));
}
if (recipeType.HasFlag(MicrowaveRecipeType.Assembler))
{
processingTexture = new TextureRect();
processingTexture.Texture = GetRsiTexture("/Textures/_NF/Structures/Machines/assembler.rsi", "assembler");
ProcessingTextures.AddChild(processingTexture);
processingTypes.Add(Loc.GetString("guidebook-food-processing-type-assembler"));
}
if (recipeType.HasFlag(MicrowaveRecipeType.MedicalAssembler))
{
processingTexture = new TextureRect();
processingTexture.Texture = GetRsiTexture("/Textures/_NF/Structures/Machines/medical_assembler.rsi", "mediwave-base");
ProcessingTextures.AddChild(processingTexture);
processingTypes.Add(Loc.GetString("guidebook-food-processing-type-medical-assembler"));
}
if (processingTypes.Count <= 0)
processingTypes.Add(Loc.GetString("guidebook-food-processing-type-generic"));
var processingTypeString = string.Join('/', processingTypes);
// End Frontier
ProcessingLabel.Text = Loc.GetString("guidebook-food-processing-cooking", ("processingTypes", processingTypeString), ("time", recipe.CookTime));
}

private void GenerateControl(FoodReactionData entry)
Expand All @@ -118,7 +164,9 @@ private void GenerateControl(FoodReactionData entry)
.Where(it => it.Length > 0);

SourceLabel.Text = Loc.GetString("guidebook-food-processing-recipe", ("ingredients", string.Join("\n", combinedReagents))); // Frontier: SetMessage<Text
ProcessingTexture.TexturePath = "/Textures/Interface/Misc/beakerlarge.png";
var processingTexture = new TextureRect(); // Frontier
processingTexture.TexturePath = "/Textures/Interface/Misc/beakerlarge.png";
ProcessingTextures.AddChild(processingTexture); // Frontier
ProcessingLabel.Text = Loc.GetString("guidebook-food-processing-reaction");
}

Expand Down
125 changes: 125 additions & 0 deletions Content.Client/_NF/Kitchen/UI/AssemblerBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
using Content.Shared._NF.Kitchen.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Kitchen.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;

namespace Content.Client._NF.Kitchen.UI
{
[UsedImplicitly]
public sealed class AssemblerBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private AssemblerMenu? _menu;

[ViewVariables]
private readonly Dictionary<int, EntityUid> _solids = new();

[ViewVariables]
private readonly Dictionary<int, ReagentQuantity> _reagents = new();

private readonly string _menuTitle;
private readonly string _leftFlavorText;

public AssemblerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
if ((MicrowaveUiKey)uiKey == MicrowaveUiKey.MedicalAssemblerKey)
{
_menuTitle = "assembler-menu-medical-title";
_leftFlavorText = "assembler-menu-medical-footer-flavor-left";
}
else
{
_menuTitle = "assembler-menu-title";
_leftFlavorText = "assembler-menu-footer-flavor-left";
}
}

protected override void Open()
{
base.Open();
_menu = this.CreateWindow<AssemblerMenu>();
_menu.StartButton.OnPressed += _ => SendPredictedMessage(new AssemblerStartCookMessage());
_menu.EjectButton.OnPressed += _ => SendPredictedMessage(new MicrowaveEjectMessage());
_menu.IngredientsList.OnItemSelected += args =>
{
SendPredictedMessage(new MicrowaveEjectSolidIndexedMessage(EntMan.GetNetEntity(_solids[args.ItemIndex])));
};

_menu.Title = Loc.GetString(_menuTitle);
_menu.LeftFooter.Text = Loc.GetString(_leftFlavorText);
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not MicrowaveUpdateUserInterfaceState cState || _menu == null)
{
return;
}

_menu.IsBusy = cState.IsMicrowaveBusy;
_menu.CurrentCooktimeEnd = cState.CurrentCookTimeEnd;

_menu.ToggleBusyDisableOverlayPanel(cState.IsMicrowaveBusy || cState.ContainedSolids.Length == 0);
// TODO move this to a component state and ensure the net ids.
RefreshContentsDisplay(EntMan.GetEntityArray(cState.ContainedSolids));

//Set the cook time info label
var cookTime = cState.CurrentCookTime.ToString();

_menu.CookTimeInfoLabel.Text = Loc.GetString("assembler-bound-user-interface-insert-ingredients");
_menu.StartButton.Disabled = cState.IsMicrowaveBusy || cState.ContainedSolids.Length == 0;
_menu.EjectButton.Disabled = cState.IsMicrowaveBusy || cState.ContainedSolids.Length == 0;

//Set the "micowave light" ui color to indicate if the microwave is busy or not
if (cState.IsMicrowaveBusy && cState.ContainedSolids.Length > 0)
{
_menu.IngredientsPanel.PanelOverride = new StyleBoxFlat { BackgroundColor = Color.FromHex("#947300") };
}
else
{
_menu.IngredientsPanel.PanelOverride = new StyleBoxFlat { BackgroundColor = Color.FromHex("#1B1B1E") };
}
}

private void RefreshContentsDisplay(EntityUid[] containedSolids)
{
_reagents.Clear();

if (_menu == null) return;

_solids.Clear();
_menu.IngredientsList.Clear();
foreach (var entity in containedSolids)
{
if (EntMan.Deleted(entity))
{
return;
}

// TODO just use sprite view

Texture? texture;
if (EntMan.TryGetComponent<IconComponent>(entity, out var iconComponent))
{
texture = EntMan.System<SpriteSystem>().GetIcon(iconComponent);
}
else if (EntMan.TryGetComponent<SpriteComponent>(entity, out var spriteComponent))
{
texture = spriteComponent.Icon?.Default;
}
else
{
continue;
}

var solidItem = _menu.IngredientsList.AddItem(EntMan.GetComponent<MetaDataComponent>(entity).EntityName, texture);
var solidIndex = _menu.IngredientsList.IndexOf(solidItem);
_solids.Add(solidIndex, entity);
}
}
}
}
95 changes: 95 additions & 0 deletions Content.Client/_NF/Kitchen/UI/AssemblerMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<controls:FancyWindow
xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:style="clr-namespace:Content.Client.Stylesheets"
Title="{Loc 'assembler-menu-title'}"
MinWidth="512"
MinSize="512 256">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal" >
<PanelContainer
Name="IngredientsPanel"
Access="Public"
MinSize="300 128"
Margin="5 5">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>
<ItemList
Name="IngredientsList"
Access="Public"
Margin="5 5"
VerticalExpand="True"
HorizontalExpand="True"
StyleClasses="transparentBackgroundItemList"
SelectMode="Button"
SizeFlagsStretchRatio="3"
ItemSeparation="5"
MinSize="100 128">
<!-- Ingredients are added here by code -->
</ItemList>
</PanelContainer>
<BoxContainer
Orientation="Vertical"
MinWidth="170"
Margin="10 10"
VerticalExpand="True"
HorizontalExpand="True">
<PanelContainer
VerticalExpand="True"
HorizontalExpand="True">
<PanelContainer
VerticalExpand="True"
ModulateSelfOverride="#FF0000"
MinSize="100 256">
<BoxContainer Orientation="Vertical">
<Label
Name="CookTimeInfoLabel"
Access="Public"
Align="Center"
Modulate="#FFFFFF"
VAlign="Center" />
<BoxContainer Orientation="Vertical">
<BoxContainer
Orientation="Vertical"
Align="Center"
SizeFlagsStretchRatio="3">
<Control MinSize="0 15" />
<Button
Name="StartButton"
Access="Public"
Text="{Loc 'assembler-menu-start-button'}"
StyleClasses="ButtonColorGreen"
TextAlign="Center" />
<Button
Name="EjectButton"
Access="Public"
Text="{Loc 'microwave-menu-eject-all-text'}"
ToolTip="{Loc 'microwave-menu-eject-all-tooltip'}"
StyleClasses="ButtonColorRed"
TextAlign="Center" />
</BoxContainer>
</BoxContainer>
</BoxContainer>
</PanelContainer>
</PanelContainer>
</BoxContainer>
</BoxContainer>
<!-- Footer -->
<BoxContainer Orientation="Vertical">
<PanelContainer StyleClasses="LowDivider" />
<BoxContainer Orientation="Horizontal" Margin="10 2 5 0" VerticalAlignment="Bottom">
<Label Text="{Loc 'assembler-menu-footer-flavor-left'}" StyleClasses="WindowFooterText" Name="LeftFooter" Access="Public"/>
<Label Text="{Loc 'assembler-menu-footer-flavor-right'}" StyleClasses="WindowFooterText"
HorizontalAlignment="Right" HorizontalExpand="True" Margin="0 0 5 0" />
<TextureRect StyleClasses="NTLogoDark" Stretch="KeepAspectCentered" VerticalAlignment="Center" HorizontalAlignment="Right" SetSize="19 19"/>
</BoxContainer>
</BoxContainer>
</BoxContainer>
<PanelContainer Name="DisableCookingPanelOverlay" MouseFilter="Stop">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E66" />
</PanelContainer.PanelOverride>
</PanelContainer>
</controls:FancyWindow>
Loading

0 comments on commit 2479231

Please sign in to comment.