Improves the HUD (#3655)

* All good except the combat doll

* Makes the HUD inventory less terrible

* Cleanup, nuke the Combat Mode button

* Harm icon

* Switch the icon

* Basic goon hud

* Toggleable

* Nuke the popup, properly centers it

* Fix clicking the button

* Nuke some old code

* missed a comment

* Remove defaults

* Localization

* Nuke some old yaml

* New sprites

Co-authored-by: ike709 <sparebytes@protonmail.com>
This commit is contained in:
ike709
2021-03-26 10:23:12 -05:00
committed by GitHub
parent ec7eab2989
commit 1d052d0410
45 changed files with 245 additions and 248 deletions

View File

@@ -27,11 +27,22 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
private ItemSlotButton _hudButtonPocket1 = default!;
private ItemSlotButton _hudButtonPocket2 = default!;
private ItemSlotButton _hudButtonShoes = default!;
private ItemSlotButton _hudButtonJumpsuit = default!;
private ItemSlotButton _hudButtonGloves = default!;
private ItemSlotButton _hudButtonNeck = default!;
private ItemSlotButton _hudButtonHead = default!;
private ItemSlotButton _hudButtonBelt = default!;
private ItemSlotButton _hudButtonBack = default!;
private ItemSlotButton _hudButtonOClothing = default!;
private ItemSlotButton _hudButtonId = default!;
private Control _rightQuickButtonsContainer = default!;
private Control _leftQuickButtonsContainer = default!;
private ItemSlotButton _hudButtonMask = default!;
private ItemSlotButton _hudButtonEyes = default!;
private ItemSlotButton _hudButtonEars = default!;
private Control _topQuickButtonsContainer = default!;
private Control _bottomLeftQuickButtonsContainer = default!;
private Control _bottomRightQuickButtonsContainer = default!;
public HumanInventoryInterfaceController(ClientInventoryComponent owner) : base(owner)
{
@@ -66,28 +77,55 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
AddButton(out _hudButtonPocket1, Slots.POCKET1, "pocket");
AddButton(out _hudButtonPocket2, Slots.POCKET2, "pocket");
AddButton(out _hudButtonBack, Slots.BACKPACK, "back");
AddButton(out _hudButtonBelt, Slots.BELT, "belt");
AddButton(out _hudButtonId, Slots.IDCARD, "id");
_leftQuickButtonsContainer = new HBoxContainer
AddButton(out _hudButtonBack, Slots.BACKPACK, "back");
AddButton(out _hudButtonBelt, Slots.BELT, "belt");
AddButton(out _hudButtonShoes, Slots.SHOES, "shoes");
AddButton(out _hudButtonJumpsuit, Slots.INNERCLOTHING, "uniform");
AddButton(out _hudButtonOClothing, Slots.OUTERCLOTHING, "suit");
AddButton(out _hudButtonGloves, Slots.GLOVES, "gloves");
AddButton(out _hudButtonNeck, Slots.NECK, "neck");
AddButton(out _hudButtonMask, Slots.MASK, "mask");
AddButton(out _hudButtonEyes, Slots.EYES, "glasses");
AddButton(out _hudButtonEars, Slots.EARS, "ears");
AddButton(out _hudButtonHead, Slots.HEAD, "head");
_topQuickButtonsContainer = new HBoxContainer
{
Children =
{
_hudButtonId,
_hudButtonBack,
_hudButtonBelt,
_hudButtonShoes,
_hudButtonJumpsuit,
_hudButtonOClothing,
_hudButtonGloves,
_hudButtonNeck,
_hudButtonMask,
_hudButtonEyes,
_hudButtonEars,
_hudButtonHead
},
SeparationOverride = 5
};
_rightQuickButtonsContainer = new HBoxContainer
_bottomRightQuickButtonsContainer = new HBoxContainer
{
Children =
{
_hudButtonPocket1,
_hudButtonPocket2,
// keeps this "balanced" with the left, so the hands will appear perfectly in the center
new Control{MinSize = (64, 64)}
_hudButtonId,
},
SeparationOverride = 5
};
_bottomLeftQuickButtonsContainer = new HBoxContainer
{
Children =
{
_hudButtonBelt,
_hudButtonBack
},
SeparationOverride = 5
};
@@ -172,8 +210,9 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
{
base.PlayerAttached();
GameHud.RightInventoryQuickButtonContainer.AddChild(_rightQuickButtonsContainer);
GameHud.LeftInventoryQuickButtonContainer.AddChild(_leftQuickButtonsContainer);
GameHud.BottomLeftInventoryQuickButtonContainer.AddChild(_bottomLeftQuickButtonsContainer);
GameHud.BottomRightInventoryQuickButtonContainer.AddChild(_bottomRightQuickButtonsContainer);
GameHud.TopInventoryQuickButtonContainer.AddChild(_topQuickButtonsContainer);
// Update all the buttons to make sure they check out.
@@ -195,8 +234,9 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
{
base.PlayerDetached();
GameHud.RightInventoryQuickButtonContainer.RemoveChild(_rightQuickButtonsContainer);
GameHud.LeftInventoryQuickButtonContainer.RemoveChild(_leftQuickButtonsContainer);
GameHud.BottomRightInventoryQuickButtonContainer.RemoveChild(_bottomRightQuickButtonsContainer);
GameHud.BottomLeftInventoryQuickButtonContainer.RemoveChild(_bottomLeftQuickButtonsContainer);
GameHud.TopInventoryQuickButtonContainer.RemoveChild(_topQuickButtonsContainer);
foreach (var (slot, list) in _inventoryButtons)
{

View File

@@ -30,23 +30,11 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
public virtual void PlayerAttached()
{
GameHud.InventoryButtonVisible = true;
GameHud.InventoryButtonToggled = b =>
{
if (b)
{
Window?.Open();
}
else
{
Window?.Close();
}
};
}
public virtual void PlayerDetached()
{
GameHud.InventoryButtonVisible = false;
Window?.Close();
}
public virtual void Dispose()

View File

@@ -58,7 +58,6 @@ namespace Content.Client.GameObjects.Components.Mobs
return;
}
_gameHud.CombatModeActive = IsInCombatMode;
_gameHud.TargetingZone = ActiveZone;
}
}

View File

@@ -34,45 +34,7 @@ namespace Content.Client.GameObjects.EntitySystems
private void HandleOpenInventoryMenu()
{
if (_playerManager.LocalPlayer?.ControlledEntity == null
|| !_playerManager.LocalPlayer.ControlledEntity.TryGetComponent(out ClientInventoryComponent? clientInventory))
{
return;
}
var menu = clientInventory.InterfaceController.Window;
if (menu == null) return;
if (menu.IsOpen)
{
if (menu.IsAtFront())
{
_setOpenValue(menu, false);
}
else
{
menu.MoveToFront();
}
}
else
{
_setOpenValue(menu, true);
}
}
private void _setOpenValue(SS14Window menu, bool value)
{
if (value)
{
_gameHud.InventoryButtonDown = true;
menu.OpenCentered();
}
else
{
_gameHud.InventoryButtonDown = false;
menu.Close();
}
_gameHud.InventoryButtonDown = !_gameHud.InventoryButtonDown;
}
}
}

View File

@@ -25,13 +25,7 @@ namespace Content.Client.GameObjects.EntitySystems
{
base.Initialize();
_gameHud.OnCombatModeChanged = OnCombatModeChanged;
_gameHud.OnTargetingZoneChanged = OnTargetingZoneChanged;
CommandBinds.Builder
.Bind(ContentKeyFunctions.ToggleCombatMode,
InputCmdHandler.FromDelegate(CombatModeToggled))
.Register<CombatModeSystem>();
}
public override void Shutdown()
@@ -40,15 +34,6 @@ namespace Content.Client.GameObjects.EntitySystems
base.Shutdown();
}
private void CombatModeToggled(ICommonSession? session)
{
if (_gameTiming.IsFirstTimePredicted)
{
EntityManager.RaisePredictiveEvent(
new CombatModeSystemMessages.SetCombatModeActiveMessage(!IsInCombatMode()));
}
}
public bool IsInCombatMode()
{
var entity = _playerManager.LocalPlayer?.ControlledEntity;
@@ -64,10 +49,5 @@ namespace Content.Client.GameObjects.EntitySystems
{
EntityManager.RaisePredictiveEvent(new CombatModeSystemMessages.SetTargetZoneMessage(obj));
}
private void OnCombatModeChanged(bool obj)
{
EntityManager.RaisePredictiveEvent(new CombatModeSystemMessages.SetCombatModeActiveMessage(obj));
}
}
}