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:
committed by
PJB3005
parent
ba152fc61d
commit
68f4fd995e
@@ -38,13 +38,14 @@ namespace Content.Client.GameObjects
|
||||
|
||||
ActiveIndex = cast.ActiveIndex;
|
||||
|
||||
var uiMgr = (UserInterfaceManager)IoCManager.Resolve<IUserInterfaceManager>();
|
||||
|
||||
if (uiMgr.GetSingleComponentByGuiComponentType(GuiComponentType.HandsUi) == null)
|
||||
// Tell UI to update.
|
||||
var uiMgr = IoCManager.Resolve<IUserInterfaceManager>();
|
||||
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)
|
||||
|
||||
@@ -6,15 +6,14 @@ using SS14.Client.Graphics.Sprites;
|
||||
using SS14.Client.Interfaces.Player;
|
||||
using SS14.Client.Interfaces.Resource;
|
||||
using SS14.Client.Interfaces.UserInterface;
|
||||
using SS14.Client.UserInterface.Components;
|
||||
using SS14.Shared;
|
||||
using SS14.Client.UserInterface.Controls;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.IoC;
|
||||
using SS14.Shared.Maths;
|
||||
|
||||
namespace Content.Client.UserInterface
|
||||
{
|
||||
public class HandsGui : GuiComponent
|
||||
public class HandsGui : Control
|
||||
{
|
||||
private readonly Color _inactiveColor = new Color(90, 90, 90);
|
||||
|
||||
@@ -31,29 +30,30 @@ namespace Content.Client.UserInterface
|
||||
public HandsGui()
|
||||
{
|
||||
var _resMgr = IoCManager.Resolve<IResourceCache>();
|
||||
ComponentClass = GuiComponentType.HandsUi;
|
||||
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)
|
||||
{
|
||||
base.ComponentUpdate(args);
|
||||
UpdateHandIcons();
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
protected override void OnCalcRect()
|
||||
{
|
||||
// Individual size of the hand slot sprite.
|
||||
var slotBounds = handSlot.LocalBounds;
|
||||
var width = (int)((slotBounds.Width * 2) + spacing);
|
||||
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);
|
||||
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);
|
||||
ClientArea = Box2i.FromDimensions(Position.X, Position.Y, width, (int)slotBounds.Height);
|
||||
}
|
||||
|
||||
public override void Render()
|
||||
protected override void DrawContents()
|
||||
{
|
||||
if (_playerManager?.ControlledEntity == null)
|
||||
{
|
||||
|
||||
2
engine
2
engine
Submodule engine updated: debdbf8fda...59b2df97d8
Reference in New Issue
Block a user