Make HandsGui work on Clyde.
This commit is contained in:
@@ -34,11 +34,14 @@ namespace Content.Client.UserInterface
|
|||||||
private StyleBoxTexture handBox;
|
private StyleBoxTexture handBox;
|
||||||
private StyleBoxTexture inactiveHandBox;
|
private StyleBoxTexture inactiveHandBox;
|
||||||
|
|
||||||
private UiHandInfo LeftHand;
|
private IEntity LeftHand;
|
||||||
private UiHandInfo RightHand;
|
private IEntity RightHand;
|
||||||
private UIBox2i handL;
|
private UIBox2i handL;
|
||||||
private UIBox2i handR;
|
private UIBox2i handR;
|
||||||
|
|
||||||
|
private SpriteView LeftSpriteView;
|
||||||
|
private SpriteView RightSpriteView;
|
||||||
|
|
||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -59,8 +62,17 @@ namespace Content.Client.UserInterface
|
|||||||
|
|
||||||
handL = new UIBox2i(0, 0, BOX_SIZE, BOX_SIZE);
|
handL = new UIBox2i(0, 0, BOX_SIZE, BOX_SIZE);
|
||||||
handR = handL.Translated(new Vector2i(BOX_SIZE + BOX_SPACING, 0));
|
handR = handL.Translated(new Vector2i(BOX_SIZE + BOX_SPACING, 0));
|
||||||
SS14.Shared.Log.Logger.Debug($"{handL}, {handR}");
|
|
||||||
MouseFilter = MouseFilterMode.Stop;
|
MouseFilter = MouseFilterMode.Stop;
|
||||||
|
|
||||||
|
LeftSpriteView = new SpriteView();
|
||||||
|
AddChild(LeftSpriteView);
|
||||||
|
LeftSpriteView.Size = handL.Size;
|
||||||
|
LeftSpriteView.Position = handL.TopLeft;
|
||||||
|
|
||||||
|
RightSpriteView = new SpriteView();
|
||||||
|
AddChild(RightSpriteView);
|
||||||
|
RightSpriteView.Size = handR.Size;
|
||||||
|
RightSpriteView.Position = handR.TopLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Vector2 CalculateMinimumSize()
|
protected override Vector2 CalculateMinimumSize()
|
||||||
@@ -77,26 +89,6 @@ namespace Content.Client.UserInterface
|
|||||||
|
|
||||||
handle.DrawStyleBox(handBox, leftActive ? handL : handR);
|
handle.DrawStyleBox(handBox, leftActive ? handL : handR);
|
||||||
handle.DrawStyleBox(inactiveHandBox, leftActive ? handR : handL);
|
handle.DrawStyleBox(inactiveHandBox, leftActive ? handR : handL);
|
||||||
|
|
||||||
/*
|
|
||||||
if (LeftHand.Entity != null && LeftHand.HeldSprite != null)
|
|
||||||
{
|
|
||||||
var bounds = LeftHand.HeldSprite.Size;
|
|
||||||
handle.DrawTextureRect(LeftHand.HeldSprite,
|
|
||||||
UIBox2i.FromDimensions(handL.Left + (int)(handL.Width / 2f - bounds.X / 2f),
|
|
||||||
handL.Top + (int)(handL.Height / 2f - bounds.Y / 2f),
|
|
||||||
(int)bounds.X, (int)bounds.Y), tile: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RightHand.Entity != null && RightHand.HeldSprite != null)
|
|
||||||
{
|
|
||||||
var bounds = RightHand.HeldSprite.Size;
|
|
||||||
handle.DrawTextureRect(RightHand.HeldSprite,
|
|
||||||
UIBox2i.FromDimensions(handR.Left + (int)(handR.Width / 2f - bounds.Y / 2f),
|
|
||||||
handR.Top + (int)(handR.Height / 2f - bounds.Y / 2f),
|
|
||||||
(int)bounds.X, (int)bounds.Y), tile: false);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -130,51 +122,41 @@ namespace Content.Client.UserInterface
|
|||||||
|
|
||||||
UpdateDraw();
|
UpdateDraw();
|
||||||
|
|
||||||
if (!TryGetHands(out IHandsComponent hands))
|
if (!TryGetHands(out var hands))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var left = hands.GetEntity("left");
|
var left = hands.GetEntity("left");
|
||||||
var right = hands.GetEntity("right");
|
var right = hands.GetEntity("right");
|
||||||
|
|
||||||
// I'm naively gonna assume all items are 32x32.
|
|
||||||
//const float HalfSize = 16;
|
|
||||||
|
|
||||||
if (left != null)
|
if (left != null)
|
||||||
{
|
{
|
||||||
if (left != LeftHand.Entity)
|
if (left != LeftHand)
|
||||||
{
|
{
|
||||||
LeftHand.Entity = left;
|
LeftHand = left;
|
||||||
LeftHand.MirrorHandle?.Dispose();
|
if (LeftHand.TryGetComponent(out ISpriteComponent sprite))
|
||||||
LeftHand.MirrorHandle = GetSpriteMirror(left);
|
{
|
||||||
LeftHand.MirrorHandle.AttachToControl(this);
|
LeftSpriteView.Sprite = sprite;
|
||||||
LeftHand.MirrorHandle.Offset = new Vector2(handL.Left + (int) (handL.Width / 2f),
|
}
|
||||||
handL.Top + (int) (handL.Height / 2f));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LeftHand.Entity = null;
|
LeftHand = null;
|
||||||
LeftHand.MirrorHandle?.Dispose();
|
LeftSpriteView.Sprite = null;
|
||||||
LeftHand.MirrorHandle = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (right != null)
|
if (right != null)
|
||||||
{
|
{
|
||||||
if (right != RightHand.Entity)
|
RightHand = right;
|
||||||
|
if (RightHand.TryGetComponent(out ISpriteComponent sprite))
|
||||||
{
|
{
|
||||||
RightHand.Entity = right;
|
RightSpriteView.Sprite = sprite;
|
||||||
RightHand.MirrorHandle?.Dispose();
|
|
||||||
RightHand.MirrorHandle = GetSpriteMirror(right);
|
|
||||||
RightHand.MirrorHandle.AttachToControl(this);
|
|
||||||
RightHand.MirrorHandle.Offset = new Vector2(handR.Left + (int) (handR.Width / 2f),
|
|
||||||
handR.Top + (int) (handR.Height / 2f));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RightHand.Entity = null;
|
RightHand = null;
|
||||||
RightHand.MirrorHandle?.Dispose();
|
RightSpriteView.Sprite = null;
|
||||||
RightHand.MirrorHandle = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,11 +259,5 @@ namespace Content.Client.UserInterface
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct UiHandInfo
|
|
||||||
{
|
|
||||||
public IEntity Entity { get; set; }
|
|
||||||
public ISpriteProxy MirrorHandle { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
engine
2
engine
Submodule engine updated: b2bb711dbb...9fbaf144a6
Reference in New Issue
Block a user