The Wait Is Over. (#49)
* Move submodule to Godot * Update submodule AGAIN. * Update project files. * Remove WearableAnimatedSprite from prototypes. * Remove content repo resource copier. * Update submodule. * Fix resource handling. * Content.Client compiles by commenting out hands GUI. * Update submodule. * Fix prototype textures and update submodule. * Update Submodule. * Update submodule SOME MORE! * Random WiP shit I guess * Make omnisharp not choke on buildchecker. * Update submodule. * Highly WiP broken HandsGui code. * Ok maybe let's not insult omnisharp. * Fix annoying Omnisharp warning. * Update submodule. * Update submodule. * Hey I forgot to push this but it didn't conflict! * Fix hands GUI on godot. * Update submodule. * Obligatory submodule update. * Work on exports. * Work on exports. * Update submodule. * Update submodule. * Fix dumb case mismatch between content and engine * work pls. * This maybe. * Now! * Update submodule. * update submodule. * Some WiP work on exporting aaah. * OK READY FOR THE BUILDS SERVER. * Probably should've made those commits in a different order. * DO THE THING * update submodule. * Updates for effects system. * Update submodule. * Make file/line numbers show up on Windows Godot. * Set submodule to master.
This commit is contained in:
committed by
GitHub
parent
128728bfcb
commit
6704245a41
@@ -1,11 +1,13 @@
|
||||
using Content.Client.Interfaces.GameObjects;
|
||||
using SS14.Client.GameObjects;
|
||||
using SS14.Client.Graphics;
|
||||
using SS14.Client.Graphics.Input;
|
||||
using SS14.Client.Graphics.Sprites;
|
||||
using SS14.Client.Graphics.Drawing;
|
||||
using SS14.Client.Input;
|
||||
using SS14.Client.Interfaces.Player;
|
||||
using SS14.Client.Interfaces.Resource;
|
||||
using SS14.Client.Interfaces.ResourceManagement;
|
||||
using SS14.Client.Interfaces.UserInterface;
|
||||
using SS14.Client.ResourceManagement;
|
||||
using SS14.Client.UserInterface;
|
||||
using SS14.Client.UserInterface.Controls;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.IoC;
|
||||
@@ -13,47 +15,53 @@ using SS14.Shared.Maths;
|
||||
|
||||
namespace Content.Client.UserInterface
|
||||
{
|
||||
public class HandsGui : Control
|
||||
public class HandsGui : HBoxContainer
|
||||
{
|
||||
private readonly Color _inactiveColor = new Color(90, 90, 90);
|
||||
private static readonly Color _inactiveColor = new Color(90, 90, 90);
|
||||
private const int BOX_SPACING = 1;
|
||||
// The boxes are square so that's both width and height.
|
||||
private const int BOX_SIZE = 50;
|
||||
|
||||
private readonly IPlayerManager _playerManager = IoCManager.Resolve<IPlayerManager>();
|
||||
private readonly IUserInterfaceManager _userInterfaceManager = IoCManager.Resolve<IUserInterfaceManager>();
|
||||
private readonly Sprite handSlot;
|
||||
private readonly int spacing = 1;
|
||||
private StyleBoxTexture handBox;
|
||||
private StyleBoxTexture inactiveHandBox;
|
||||
|
||||
private UiHandInfo LeftHand;
|
||||
private UiHandInfo RightHand;
|
||||
private Box2i handL;
|
||||
private Box2i handR;
|
||||
|
||||
public HandsGui()
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
var _resMgr = IoCManager.Resolve<IResourceCache>();
|
||||
handSlot = _resMgr.GetSprite("hand");
|
||||
// OnCalcRect() calculates position so this needs to be ran
|
||||
// as it doesn't automatically get called by the UI manager.
|
||||
DoLayout();
|
||||
var handsBoxTexture = _resMgr.GetResource<TextureResource>("Textures/UserInterface/handsbox.png");
|
||||
handBox = new StyleBoxTexture()
|
||||
{
|
||||
Texture = handsBoxTexture,
|
||||
};
|
||||
handBox.SetMargin(StyleBox.Margin.All, 6);
|
||||
inactiveHandBox = new StyleBoxTexture(handBox)
|
||||
{
|
||||
Modulate = _inactiveColor,
|
||||
};
|
||||
SetMarginsPreset(LayoutPreset.CenterBottom);
|
||||
SetAnchorPreset(LayoutPreset.CenterBottom);
|
||||
|
||||
handL = new Box2i(0, 0, BOX_SIZE, BOX_SIZE);
|
||||
handR = handL.Translated(new Vector2i(BOX_SIZE + BOX_SPACING, 0));
|
||||
SS14.Shared.Log.Logger.Debug($"{handL}, {handR}");
|
||||
MouseFilter = MouseFilterMode.Stop;
|
||||
}
|
||||
|
||||
protected override void OnCalcRect()
|
||||
protected override Vector2 CalculateMinimumSize()
|
||||
{
|
||||
// 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);
|
||||
return new Vector2(BOX_SIZE * 2 + 1, BOX_SIZE);
|
||||
}
|
||||
|
||||
protected override void DrawContents()
|
||||
protected override void Draw(DrawingHandle handle)
|
||||
{
|
||||
if (_playerManager?.LocalPlayer == null)
|
||||
{
|
||||
@@ -68,37 +76,31 @@ namespace Content.Client.UserInterface
|
||||
|
||||
var leftActive = hands.ActiveIndex == "left";
|
||||
|
||||
handSlot.Color = Color.White;
|
||||
handSlot.SetTransformToRect(leftActive ? handL : handR);
|
||||
handSlot.Draw();
|
||||
|
||||
handSlot.Color = _inactiveColor;
|
||||
handSlot.SetTransformToRect(leftActive ? handR : handL);
|
||||
handSlot.Draw();
|
||||
handle.DrawStyleBox(handBox, leftActive ? handL : handR);
|
||||
handle.DrawStyleBox(inactiveHandBox, leftActive ? handR : handL);
|
||||
|
||||
if (LeftHand.Entity != null && LeftHand.HeldSprite != null)
|
||||
{
|
||||
var bounds = LeftHand.HeldSprite.LocalBounds;
|
||||
LeftHand.HeldSprite.SetTransformToRect(
|
||||
Box2i.FromDimensions(handL.Left + (int)(handL.Width / 2f - bounds.Width / 2f),
|
||||
handL.Top + (int)(handL.Height / 2f - bounds.Height / 2f),
|
||||
(int)bounds.Width, (int)bounds.Height));
|
||||
LeftHand.HeldSprite.Draw();
|
||||
var bounds = LeftHand.HeldSprite.Size;
|
||||
handle.DrawTextureRect(LeftHand.HeldSprite,
|
||||
Box2i.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.LocalBounds;
|
||||
RightHand.HeldSprite.SetTransformToRect(
|
||||
Box2i.FromDimensions(handR.Left + (int)(handR.Width / 2f - bounds.Width / 2f),
|
||||
handR.Top + (int)(handR.Height / 2f - bounds.Height / 2f),
|
||||
(int)bounds.Width, (int)bounds.Height));
|
||||
RightHand.HeldSprite.Draw();
|
||||
var bounds = RightHand.HeldSprite.Size;
|
||||
handle.DrawTextureRect(RightHand.HeldSprite,
|
||||
Box2i.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);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateHandIcons()
|
||||
{
|
||||
UpdateDraw();
|
||||
if (_playerManager?.LocalPlayer.ControlledEntity == null)
|
||||
{
|
||||
return;
|
||||
@@ -152,39 +154,43 @@ namespace Content.Client.UserInterface
|
||||
hands.SendChangeHand(index);
|
||||
}
|
||||
|
||||
public override bool MouseDown(MouseButtonEventArgs e)
|
||||
protected override bool HasPoint(Vector2 point)
|
||||
{
|
||||
if (e.Button != Mouse.Button.Right)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (handL.Contains(e.X, e.Y))
|
||||
{
|
||||
SendSwitchHandTo("left");
|
||||
return true;
|
||||
}
|
||||
if (handR.Contains(e.X, e.Y))
|
||||
{
|
||||
SendSwitchHandTo("right");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return handL.Contains((Vector2i)point) || handR.Contains((Vector2i)point);
|
||||
}
|
||||
|
||||
private static Sprite GetIconSprite(IEntity entity)
|
||||
protected override void MouseDown(GUIMouseButtonEventArgs args)
|
||||
{
|
||||
Sprite icon = null;
|
||||
if (entity.TryGetComponent<IconComponent>(out var component))
|
||||
base.MouseDown(args);
|
||||
|
||||
if (args.Button != Mouse.Button.Right)
|
||||
{
|
||||
icon = component.Icon;
|
||||
return;
|
||||
}
|
||||
return icon ?? IoCManager.Resolve<IResourceCache>().DefaultSprite();
|
||||
|
||||
if (handL.Contains((Vector2i)args.RelativePosition))
|
||||
{
|
||||
SendSwitchHandTo("left");
|
||||
}
|
||||
if (handR.Contains((Vector2i)args.RelativePosition))
|
||||
{
|
||||
SendSwitchHandTo("right");
|
||||
}
|
||||
}
|
||||
|
||||
private static Texture GetIconSprite(IEntity entity)
|
||||
{
|
||||
if (entity.TryGetComponent<IconComponent>(out var component) && component.Icon != null)
|
||||
{
|
||||
return component.Icon;
|
||||
}
|
||||
return IoCManager.Resolve<IResourceCache>().GetFallback<TextureResource>();
|
||||
}
|
||||
|
||||
private struct UiHandInfo
|
||||
{
|
||||
public IEntity Entity { get; set; }
|
||||
public Sprite HeldSprite { get; set; }
|
||||
public Texture HeldSprite { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user