Update submodule, fix HandsGui.

HandsGui now works with the new system. The port was sloppy though so
somebody might want to come and refactor this so that it doesn't force
its own position and size.
This commit is contained in:
Pieter-Jan Briers
2017-11-09 18:04:37 +01:00
committed by PJB3005
parent ba152fc61d
commit 68f4fd995e
3 changed files with 21 additions and 20 deletions

View File

@@ -38,13 +38,14 @@ namespace Content.Client.GameObjects
ActiveIndex = cast.ActiveIndex; ActiveIndex = cast.ActiveIndex;
var uiMgr = (UserInterfaceManager)IoCManager.Resolve<IUserInterfaceManager>(); // Tell UI to update.
var uiMgr = IoCManager.Resolve<IUserInterfaceManager>();
if (uiMgr.GetSingleComponentByGuiComponentType(GuiComponentType.HandsUi) == null) if (!uiMgr.TryGetSingleComponent<HandsGui>(out var component))
{ {
uiMgr.AddComponent(new HandsGui()); component = new HandsGui();
uiMgr.AddComponent(component);
} }
uiMgr.ComponentUpdate(GuiComponentType.HandsUi, this); component.UpdateHandIcons();
} }
public void SendChangeHand(string index) public void SendChangeHand(string index)

View File

@@ -6,15 +6,14 @@ using SS14.Client.Graphics.Sprites;
using SS14.Client.Interfaces.Player; using SS14.Client.Interfaces.Player;
using SS14.Client.Interfaces.Resource; using SS14.Client.Interfaces.Resource;
using SS14.Client.Interfaces.UserInterface; using SS14.Client.Interfaces.UserInterface;
using SS14.Client.UserInterface.Components; using SS14.Client.UserInterface.Controls;
using SS14.Shared;
using SS14.Shared.Interfaces.GameObjects; using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.IoC; using SS14.Shared.IoC;
using SS14.Shared.Maths; using SS14.Shared.Maths;
namespace Content.Client.UserInterface namespace Content.Client.UserInterface
{ {
public class HandsGui : GuiComponent public class HandsGui : Control
{ {
private readonly Color _inactiveColor = new Color(90, 90, 90); private readonly Color _inactiveColor = new Color(90, 90, 90);
@@ -31,29 +30,30 @@ namespace Content.Client.UserInterface
public HandsGui() public HandsGui()
{ {
var _resMgr = IoCManager.Resolve<IResourceCache>(); var _resMgr = IoCManager.Resolve<IResourceCache>();
ComponentClass = GuiComponentType.HandsUi;
handSlot = _resMgr.GetSprite("hand"); handSlot = _resMgr.GetSprite("hand");
ZDepth = 5; // OnCalcRect() calculates position so this needs to be ran
// as it doesn't automatically get called by the UI manager.
DoLayout();
} }
public override void ComponentUpdate(params object[] args) protected override void OnCalcRect()
{
base.ComponentUpdate(args);
UpdateHandIcons();
}
public override void Update(float frameTime)
{ {
// Individual size of the hand slot sprite.
var slotBounds = handSlot.LocalBounds; var slotBounds = handSlot.LocalBounds;
var width = (int)((slotBounds.Width * 2) + spacing); var width = (int)((slotBounds.Width * 2) + spacing);
var height = (int)slotBounds.Height; var height = (int)slotBounds.Height;
// Force size because refactoring is HARD.
Size = new Vector2i(width, height);
ClientArea = Box2i.FromDimensions(0, 0, Width, Height);
// Hell force position too what could go wrong!
Position = new Vector2i((int)(CluwneLib.Window.Viewport.Width - width) / 2, (int)CluwneLib.Window.Viewport.Height - height - 10); Position = new Vector2i((int)(CluwneLib.Window.Viewport.Width - width) / 2, (int)CluwneLib.Window.Viewport.Height - height - 10);
handL = Box2i.FromDimensions(Position.X, Position.Y, (int)slotBounds.Width, (int)slotBounds.Height); handL = Box2i.FromDimensions(Position.X, Position.Y, (int)slotBounds.Width, (int)slotBounds.Height);
handR = Box2i.FromDimensions(Position.X + (int)slotBounds.Width + spacing, Position.Y, (int)slotBounds.Width, (int)slotBounds.Height); handR = Box2i.FromDimensions(Position.X + (int)slotBounds.Width + spacing, Position.Y, (int)slotBounds.Width, (int)slotBounds.Height);
ClientArea = Box2i.FromDimensions(Position.X, Position.Y, width, (int)slotBounds.Height);
} }
public override void Render() protected override void DrawContents()
{ {
if (_playerManager?.ControlledEntity == null) if (_playerManager?.ControlledEntity == null)
{ {

2
engine

Submodule engine updated: debdbf8fda...59b2df97d8