forked from SpaceStation14-Shenanigans/Monolith
Merge branch 'master' into 2020-04-28-tool-component
This commit is contained in:
@@ -144,7 +144,10 @@ namespace Content.Client
|
||||
"Mop",
|
||||
"Bucket",
|
||||
"Puddle",
|
||||
"CanSpill"
|
||||
"CanSpill",
|
||||
"RandomPottedPlant",
|
||||
"CommunicationsConsole",
|
||||
"BarSign",
|
||||
};
|
||||
|
||||
foreach (var ignoreName in registerIgnore)
|
||||
|
||||
@@ -81,6 +81,9 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
|
||||
base.Startup();
|
||||
|
||||
SnapGrid.OnPositionChanged += SnapGridOnPositionChanged;
|
||||
// ensures lastposition initial value is populated on spawn. Just calling
|
||||
// the hook here would cause a dirty event to fire needlessly
|
||||
_lastPosition = (Owner.Transform.GridID, SnapGrid.Position);
|
||||
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner,null, SnapGrid.Offset, Mode));
|
||||
if (Mode == IconSmoothingMode.Corners)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
|
||||
public MicrowaveBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner,uiKey)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
@@ -39,9 +39,9 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
_menu.StartButton.OnPressed += args => SendMessage(new SharedMicrowaveComponent.MicrowaveStartCookMessage());
|
||||
_menu.EjectButton.OnPressed += args => SendMessage(new SharedMicrowaveComponent.MicrowaveEjectMessage());
|
||||
_menu.IngredientsList.OnItemSelected += args =>
|
||||
{
|
||||
{
|
||||
SendMessage(new SharedMicrowaveComponent.MicrowaveEjectSolidIndexedMessage(_solids[args.ItemIndex]));
|
||||
|
||||
|
||||
};
|
||||
|
||||
_menu.IngredientsListReagents.OnItemSelected += args =>
|
||||
@@ -49,7 +49,7 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
SendMessage(
|
||||
new SharedMicrowaveComponent.MicrowaveVaporizeReagentIndexedMessage(_reagents[args.ItemIndex]));
|
||||
};
|
||||
|
||||
|
||||
_menu.OnCookTimeSelected += args =>
|
||||
{
|
||||
var actualButton = args.Button as Button;
|
||||
@@ -80,6 +80,7 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
return;
|
||||
}
|
||||
|
||||
_menu.ToggleBusyDisableOverlayPanel(cstate.IsMicrowaveBusy);
|
||||
RefreshContentsDisplay(cstate.ReagentsReagents, cstate.ContainedSolids);
|
||||
|
||||
}
|
||||
@@ -101,9 +102,12 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
_menu.IngredientsList.Clear();
|
||||
foreach (var entityID in solids)
|
||||
{
|
||||
var entity = _entityManager.GetEntity(entityID);
|
||||
if (!_entityManager.TryGetEntity(entityID, out var entity))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out IconComponent icon))
|
||||
if (!entity.Deleted && entity.TryGetComponent(out IconComponent icon))
|
||||
{
|
||||
var solidItem = _menu.IngredientsList.AddItem(entity.Name, icon.Icon.Default);
|
||||
|
||||
|
||||
@@ -26,6 +26,11 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
public ButtonGroup CookTimeButtonGroup { get; }
|
||||
private VBoxContainer CookTimeButtonVbox { get; }
|
||||
|
||||
private VBoxContainer ButtonGridContainer { get; }
|
||||
|
||||
private PanelContainer DisableCookingPanelOverlay { get;}
|
||||
|
||||
|
||||
public ItemList IngredientsList { get;}
|
||||
|
||||
public ItemList IngredientsListReagents { get; }
|
||||
@@ -35,6 +40,16 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
{
|
||||
Owner = owner;
|
||||
Title = Loc.GetString("Microwave");
|
||||
DisableCookingPanelOverlay = new PanelContainer
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Stop,
|
||||
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.Black.WithAlpha(0.60f)},
|
||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
||||
SizeFlagsVertical = SizeFlags.Fill,
|
||||
|
||||
};
|
||||
|
||||
|
||||
var hSplit = new HBoxContainer
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
||||
@@ -58,14 +73,14 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
SizeFlagsStretchRatio = 2,
|
||||
CustomMinimumSize = (100,128)
|
||||
};
|
||||
|
||||
|
||||
hSplit.AddChild(IngredientsListReagents);
|
||||
//Padding between the lists.
|
||||
hSplit.AddChild(new Control
|
||||
{
|
||||
CustomMinimumSize = (0,5),
|
||||
});
|
||||
|
||||
|
||||
hSplit.AddChild(IngredientsList);
|
||||
|
||||
var vSplit = new VBoxContainer
|
||||
@@ -76,7 +91,7 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
|
||||
hSplit.AddChild(vSplit);
|
||||
|
||||
var buttonGridContainer = new VBoxContainer
|
||||
ButtonGridContainer = new VBoxContainer
|
||||
{
|
||||
Align = BoxContainer.AlignMode.Center,
|
||||
SizeFlagsStretchRatio = 3
|
||||
@@ -96,10 +111,10 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
TextAlign = Label.AlignMode.Center,
|
||||
};
|
||||
|
||||
buttonGridContainer.AddChild(StartButton);
|
||||
buttonGridContainer.AddChild(EjectButton);
|
||||
vSplit.AddChild(buttonGridContainer);
|
||||
|
||||
ButtonGridContainer.AddChild(StartButton);
|
||||
ButtonGridContainer.AddChild(EjectButton);
|
||||
vSplit.AddChild(ButtonGridContainer);
|
||||
|
||||
//Padding
|
||||
vSplit.AddChild(new Control
|
||||
{
|
||||
@@ -114,6 +129,7 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
Align = BoxContainer.AlignMode.Center,
|
||||
};
|
||||
|
||||
|
||||
var index = 0;
|
||||
for (var i = 0; i <= 12; i++)
|
||||
{
|
||||
@@ -134,7 +150,8 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
|
||||
var cookTimeOneSecondButton = (Button)CookTimeButtonVbox.GetChild(0);
|
||||
cookTimeOneSecondButton.Pressed = true;
|
||||
|
||||
|
||||
|
||||
_cookTimeInfoLabel = new Label
|
||||
{
|
||||
Text = Loc.GetString($"COOK TIME: {VisualCookTime}"),
|
||||
@@ -158,7 +175,7 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
|
||||
Children =
|
||||
{
|
||||
|
||||
|
||||
new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat(){BackgroundColor = Color.Gray.WithAlpha(0.2f)},
|
||||
@@ -199,8 +216,15 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
||||
|
||||
vSplit.AddChild(TimerFacePlate);
|
||||
Contents.AddChild(hSplit);
|
||||
Contents.AddChild(DisableCookingPanelOverlay);
|
||||
|
||||
}
|
||||
|
||||
public void ToggleBusyDisableOverlayPanel(bool shouldDisable)
|
||||
{
|
||||
DisableCookingPanelOverlay.Visible = shouldDisable;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.GameObjects.Components.Storage;
|
||||
using Content.Client.Interfaces.GameObjects;
|
||||
using Robust.Client.Graphics.Drawing;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
@@ -103,9 +104,11 @@ namespace Content.Client.GameObjects.Components.Storage
|
||||
private Control VSplitContainer;
|
||||
private VBoxContainer EntityList;
|
||||
private Label Information;
|
||||
private Button AddItemButton;
|
||||
public ClientStorageComponent StorageEntity;
|
||||
|
||||
private StyleBoxFlat _HoveredBox = new StyleBoxFlat {BackgroundColor = Color.Black.WithAlpha(0.35f)};
|
||||
private StyleBoxFlat _unHoveredBox = new StyleBoxFlat {BackgroundColor = Color.Black.WithAlpha(0.0f)};
|
||||
|
||||
protected override Vector2? CustomSize => (180, 320);
|
||||
|
||||
public StorageWindow()
|
||||
@@ -113,7 +116,37 @@ namespace Content.Client.GameObjects.Components.Storage
|
||||
Title = "Storage Item";
|
||||
RectClipContent = true;
|
||||
|
||||
VSplitContainer = new VBoxContainer();
|
||||
var containerButton = new ContainerButton
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
||||
SizeFlagsVertical = SizeFlags.Fill,
|
||||
MouseFilter = MouseFilterMode.Pass,
|
||||
};
|
||||
|
||||
var innerContainerButton = new PanelContainer
|
||||
{
|
||||
PanelOverride = _unHoveredBox,
|
||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
||||
SizeFlagsVertical = SizeFlags.Fill,
|
||||
};
|
||||
|
||||
|
||||
containerButton.AddChild(innerContainerButton);
|
||||
containerButton.OnPressed += args =>
|
||||
{
|
||||
var controlledEntity = IoCManager.Resolve<IPlayerManager>().LocalPlayer.ControlledEntity;
|
||||
|
||||
if (controlledEntity.TryGetComponent(out IHandsComponent hands))
|
||||
{
|
||||
StorageEntity.SendNetworkMessage(new InsertEntityMessage());
|
||||
}
|
||||
};
|
||||
|
||||
VSplitContainer = new VBoxContainer()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
};
|
||||
containerButton.AddChild(VSplitContainer);
|
||||
Information = new Label
|
||||
{
|
||||
Text = "Items: 0 Volume: 0/0 Stuff",
|
||||
@@ -126,7 +159,7 @@ namespace Content.Client.GameObjects.Components.Storage
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
HScrollEnabled = true,
|
||||
VScrollEnabled = true
|
||||
VScrollEnabled = true,
|
||||
};
|
||||
EntityList = new VBoxContainer
|
||||
{
|
||||
@@ -135,16 +168,17 @@ namespace Content.Client.GameObjects.Components.Storage
|
||||
listScrollContainer.AddChild(EntityList);
|
||||
VSplitContainer.AddChild(listScrollContainer);
|
||||
|
||||
AddItemButton = new Button
|
||||
{
|
||||
Text = "Add Item",
|
||||
ToggleMode = false,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand
|
||||
};
|
||||
AddItemButton.OnPressed += OnAddItemButtonPressed;
|
||||
VSplitContainer.AddChild(AddItemButton);
|
||||
Contents.AddChild(containerButton);
|
||||
|
||||
Contents.AddChild(VSplitContainer);
|
||||
listScrollContainer.OnMouseEntered += args =>
|
||||
{
|
||||
innerContainerButton.PanelOverride = _HoveredBox;
|
||||
};
|
||||
|
||||
listScrollContainer.OnMouseExited += args =>
|
||||
{
|
||||
innerContainerButton.PanelOverride = _unHoveredBox;
|
||||
};
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
@@ -168,7 +202,8 @@ namespace Content.Client.GameObjects.Components.Storage
|
||||
|
||||
var button = new EntityButton()
|
||||
{
|
||||
EntityuID = entityuid.Key
|
||||
EntityuID = entityuid.Key,
|
||||
MouseFilter = MouseFilterMode.Stop,
|
||||
};
|
||||
button.ActualButton.OnToggled += OnItemButtonToggled;
|
||||
//Name and Size labels set
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Shared.BodySystem;
|
||||
using Robust.Client.GameObjects.Components.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Content.Client.BodySystem
|
||||
{
|
||||
public class BodyScannerBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[ViewVariables]
|
||||
private BodyScannerDisplay _display;
|
||||
|
||||
[ViewVariables]
|
||||
private BodyScannerTemplateData _template;
|
||||
|
||||
[ViewVariables]
|
||||
private Dictionary<string, BodyScannerBodyPartData> _parts;
|
||||
|
||||
public BodyScannerBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_display = new BodyScannerDisplay(this);
|
||||
_display.OnClose += Close;
|
||||
_display.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
if (!(state is BodyScannerInterfaceState scannerState))
|
||||
return;
|
||||
|
||||
_template = scannerState.Template;
|
||||
_parts = scannerState.Parts;
|
||||
|
||||
_display.UpdateDisplay(_template, _parts);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
using Content.Client.BodySystem;
|
||||
using Content.Shared.BodySystem;
|
||||
using Robust.Client.Graphics.Drawing;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using static Robust.Client.UserInterface.Controls.ItemList;
|
||||
|
||||
namespace Content.Client.UserInterface
|
||||
{
|
||||
public sealed class BodyScannerDisplay : SS14Window
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly ILocalizationManager _loc;
|
||||
#pragma warning restore 649
|
||||
|
||||
public BodyScannerBoundUserInterface Owner { get; private set; }
|
||||
protected override Vector2? CustomSize => (800, 600);
|
||||
private ItemList BodyPartList { get; }
|
||||
private Label BodyPartLabel { get; }
|
||||
private Label BodyPartHealth { get; }
|
||||
private ItemList MechanismList { get; }
|
||||
private RichTextLabel MechanismInfoLabel { get; }
|
||||
|
||||
|
||||
private BodyScannerTemplateData _template;
|
||||
private Dictionary<string, BodyScannerBodyPartData> _parts;
|
||||
private List<string> _slots;
|
||||
private BodyScannerBodyPartData _currentBodyPart;
|
||||
|
||||
|
||||
public BodyScannerDisplay(BodyScannerBoundUserInterface owner)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
Owner = owner;
|
||||
Title = _loc.GetString("Body Scanner");
|
||||
|
||||
var hSplit = new HBoxContainer();
|
||||
Contents.AddChild(hSplit);
|
||||
|
||||
//Left half
|
||||
var scrollBox = new ScrollContainer
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
};
|
||||
hSplit.AddChild(scrollBox);
|
||||
BodyPartList = new ItemList { };
|
||||
scrollBox.AddChild(BodyPartList);
|
||||
BodyPartList.OnItemSelected += BodyPartOnItemSelected;
|
||||
|
||||
//Right half
|
||||
var vSplit = new VBoxContainer
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
};
|
||||
hSplit.AddChild(vSplit);
|
||||
|
||||
//Top half of the right half
|
||||
var limbBox = new VBoxContainer
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand
|
||||
};
|
||||
vSplit.AddChild(limbBox);
|
||||
BodyPartLabel = new Label();
|
||||
limbBox.AddChild(BodyPartLabel);
|
||||
var limbHealthHBox = new HBoxContainer();
|
||||
limbBox.AddChild(limbHealthHBox);
|
||||
var healthLabel = new Label
|
||||
{
|
||||
Text = "Health: "
|
||||
};
|
||||
limbHealthHBox.AddChild(healthLabel);
|
||||
BodyPartHealth = new Label();
|
||||
limbHealthHBox.AddChild(BodyPartHealth);
|
||||
var limbScroll = new ScrollContainer
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand
|
||||
};
|
||||
limbBox.AddChild(limbScroll);
|
||||
MechanismList = new ItemList();
|
||||
limbScroll.AddChild(MechanismList);
|
||||
MechanismList.OnItemSelected += MechanismOnItemSelected;
|
||||
|
||||
//Bottom half of the right half
|
||||
MechanismInfoLabel = new RichTextLabel
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand
|
||||
};
|
||||
vSplit.AddChild(MechanismInfoLabel);
|
||||
}
|
||||
|
||||
|
||||
public void UpdateDisplay(BodyScannerTemplateData template, Dictionary<string, BodyScannerBodyPartData> parts)
|
||||
{
|
||||
_template = template;
|
||||
_parts = parts;
|
||||
_slots = new List<string>();
|
||||
foreach (var (key, value) in _parts)
|
||||
{
|
||||
_slots.Add(key); //We have to do this since ItemLists only return the index of what item is selected and dictionaries don't allow you to explicitly grab things by index.
|
||||
//So we put the contents of the dictionary into a list so that we can grab the list by index. I don't know either.
|
||||
BodyPartList.AddItem(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(key));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void BodyPartOnItemSelected(ItemListSelectedEventArgs args)
|
||||
{
|
||||
if(_parts.TryGetValue(_slots[args.ItemIndex], out _currentBodyPart)) {
|
||||
UpdateBodyPartBox(_currentBodyPart, _slots[args.ItemIndex]);
|
||||
}
|
||||
}
|
||||
private void UpdateBodyPartBox(BodyScannerBodyPartData part, string slotName)
|
||||
{
|
||||
BodyPartLabel.Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(slotName) + ": " + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(part.Name);
|
||||
BodyPartHealth.Text = part.CurrentDurability + "/" + part.MaxDurability;
|
||||
|
||||
MechanismList.Clear();
|
||||
foreach (var mechanism in part.Mechanisms) {
|
||||
MechanismList.AddItem(mechanism.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void MechanismOnItemSelected(ItemListSelectedEventArgs args)
|
||||
{
|
||||
UpdateMechanismBox(_currentBodyPart.Mechanisms[args.ItemIndex]);
|
||||
}
|
||||
private void UpdateMechanismBox(BodyScannerMechanismData mechanism)
|
||||
{
|
||||
//TODO: Make UI look less shit and clean up whatever the fuck this is lmao
|
||||
if (mechanism != null)
|
||||
{
|
||||
string message = "";
|
||||
message += mechanism.Name;
|
||||
message += "\nHealth: ";
|
||||
message += mechanism.CurrentDurability;
|
||||
message += "/";
|
||||
message += mechanism.MaxDurability;
|
||||
message += "\n";
|
||||
message += mechanism.Description;
|
||||
MechanismInfoLabel.SetMessage(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
MechanismInfoLabel.SetMessage("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.GameObjects.Components.Storage;
|
||||
using Content.Client.Interfaces.GameObjects;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Players;
|
||||
using Content.Shared.BodySystem;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Content.Client.BodySystem
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class ClientSurgeryToolComponent : SharedSurgeryToolComponent
|
||||
{
|
||||
private SurgeryToolWindow Window;
|
||||
public override void HandleNetworkMessage(ComponentMessage message, INetChannel channel, ICommonSession session = null)
|
||||
{
|
||||
base.HandleNetworkMessage(message, channel, session);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case OpenSurgeryUIMessage msg:
|
||||
HandleOpenSurgeryUIMessage();
|
||||
break;
|
||||
case CloseSurgeryUIMessage msg:
|
||||
HandleCloseSurgeryUIMessage();
|
||||
break;
|
||||
case UpdateSurgeryUIMessage msg:
|
||||
HandleUpdateSurgeryUIMessage(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public override void OnAdd()
|
||||
{
|
||||
base.OnAdd();
|
||||
Window = new SurgeryToolWindow() { SurgeryToolEntity = this };
|
||||
}
|
||||
|
||||
public override void OnRemove()
|
||||
{
|
||||
Window.Dispose();
|
||||
base.OnRemove();
|
||||
}
|
||||
|
||||
private void HandleOpenSurgeryUIMessage()
|
||||
{
|
||||
Window.Open();
|
||||
}
|
||||
private void HandleCloseSurgeryUIMessage()
|
||||
{
|
||||
Window.Close();
|
||||
}
|
||||
private void HandleUpdateSurgeryUIMessage(UpdateSurgeryUIMessage surgeryUIState)
|
||||
{
|
||||
Window.BuildDisplay(surgeryUIState.Targets);
|
||||
}
|
||||
private class SurgeryToolWindow : SS14Window
|
||||
{
|
||||
private Control _VSplitContainer;
|
||||
private VBoxContainer _bodyPartList;
|
||||
public ClientSurgeryToolComponent SurgeryToolEntity;
|
||||
|
||||
protected override Vector2? CustomSize => (300, 400);
|
||||
|
||||
public SurgeryToolWindow()
|
||||
{
|
||||
Title = "Select surgery target...";
|
||||
RectClipContent = true;
|
||||
|
||||
_VSplitContainer = new VBoxContainer();
|
||||
var listScrollContainer = new ScrollContainer
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
HScrollEnabled = true,
|
||||
VScrollEnabled = true
|
||||
};
|
||||
_bodyPartList = new VBoxContainer
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand
|
||||
};
|
||||
listScrollContainer.AddChild(_bodyPartList);
|
||||
_VSplitContainer.AddChild(listScrollContainer);
|
||||
Contents.AddChild(_VSplitContainer);
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
SurgeryToolEntity.SendNetworkMessage(new CloseSurgeryUIMessage());
|
||||
base.Close();
|
||||
}
|
||||
|
||||
public void BuildDisplay(Dictionary<string, string> targets)
|
||||
{
|
||||
_bodyPartList.DisposeAllChildren();
|
||||
foreach (var(slotName, partname) in targets)
|
||||
{
|
||||
var button = new BodyPartButton(slotName);
|
||||
button.ActualButton.OnToggled += OnButtonPressed;
|
||||
button.LimbName.Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(slotName + " - " + partname);
|
||||
|
||||
//button.SpriteView.Sprite = sprite;
|
||||
|
||||
_bodyPartList.AddChild(button);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnButtonPressed(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
var parent = (BodyPartButton) args.Button.Parent;
|
||||
SurgeryToolEntity.SendNetworkMessage(new SelectSurgeryUIMessage(parent.LimbSlotName));
|
||||
}
|
||||
}
|
||||
|
||||
private class BodyPartButton : PanelContainer
|
||||
{
|
||||
public Button ActualButton { get; }
|
||||
public SpriteView SpriteView { get; }
|
||||
public Control EntityControl { get; }
|
||||
public Label LimbName { get; }
|
||||
public string LimbSlotName { get; }
|
||||
|
||||
public BodyPartButton(string slotName)
|
||||
{
|
||||
LimbSlotName = slotName;
|
||||
ActualButton = new Button
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
ToggleMode = true,
|
||||
MouseFilter = MouseFilterMode.Stop
|
||||
};
|
||||
AddChild(ActualButton);
|
||||
|
||||
var hBoxContainer = new HBoxContainer();
|
||||
SpriteView = new SpriteView
|
||||
{
|
||||
CustomMinimumSize = new Vector2(32.0f, 32.0f)
|
||||
};
|
||||
LimbName = new Label
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.ShrinkCenter,
|
||||
Text = "N/A",
|
||||
};
|
||||
hBoxContainer.AddChild(SpriteView);
|
||||
hBoxContainer.AddChild(LimbName);
|
||||
|
||||
EntityControl = new Control
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand
|
||||
};
|
||||
hBoxContainer.AddChild(EntityControl);
|
||||
AddChild(hBoxContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user