HUD Themes (#3774)
* HUD Themes * Prototypes * field * oops * ugh * Fixes * Update Content.Client/UserInterface/GameHud.cs Co-authored-by: ike709 <sparebytes@protonmail.com>
@@ -1,16 +1,22 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Client.UserInterface;
|
using Content.Client.UserInterface;
|
||||||
using Content.Client.Utility;
|
using Content.Client.Utility;
|
||||||
|
using Content.Shared;
|
||||||
|
using Content.Shared.Prototypes.HUD;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Client.ResourceManagement;
|
using Robust.Client.ResourceManagement;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
|
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.Components.HUD.Inventory
|
namespace Content.Client.GameObjects.Components.HUD.Inventory
|
||||||
@@ -20,7 +26,10 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
|
|||||||
public class HumanInventoryInterfaceController : InventoryInterfaceController
|
public class HumanInventoryInterfaceController : InventoryInterfaceController
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
||||||
|
[Dependency] private readonly IGameHud _gameHud = default!;
|
||||||
[Dependency] private readonly IItemSlotManager _itemSlotManager = default!;
|
[Dependency] private readonly IItemSlotManager _itemSlotManager = default!;
|
||||||
|
[Dependency] private readonly INetConfigurationManager _configManager = default!;
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
|
||||||
private readonly Dictionary<Slots, List<ItemSlotButton>> _inventoryButtons
|
private readonly Dictionary<Slots, List<ItemSlotButton>> _inventoryButtons
|
||||||
= new();
|
= new();
|
||||||
@@ -51,8 +60,9 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
_configManager.OnValueChanged(CCVars.HudTheme, UpdateHudTheme, invokeImmediately: true);
|
||||||
|
|
||||||
_window = new HumanInventoryWindow(_resourceCache);
|
_window = new HumanInventoryWindow(_gameHud);
|
||||||
_window.OnClose += () => GameHud.InventoryButtonDown = false;
|
_window.OnClose += () => GameHud.InventoryButtonDown = false;
|
||||||
foreach (var (slot, button) in _window.Buttons)
|
foreach (var (slot, button) in _window.Buttons)
|
||||||
{
|
{
|
||||||
@@ -64,9 +74,9 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
|
|||||||
|
|
||||||
void AddButton(out ItemSlotButton variable, Slots slot, string textureName)
|
void AddButton(out ItemSlotButton variable, Slots slot, string textureName)
|
||||||
{
|
{
|
||||||
var texture = _resourceCache.GetTexture($"/Textures/Interface/Inventory/{textureName}.png");
|
var texture = _gameHud.GetHudTexture($"{textureName}.png");
|
||||||
var storageTexture = _resourceCache.GetTexture("/Textures/Interface/Inventory/back.png");
|
var storageTexture = _gameHud.GetHudTexture("back.png");
|
||||||
variable = new ItemSlotButton(texture, storageTexture)
|
variable = new ItemSlotButton(texture, storageTexture, textureName)
|
||||||
{
|
{
|
||||||
OnPressed = (e) => AddToInventory(e, slot),
|
OnPressed = (e) => AddToInventory(e, slot),
|
||||||
OnStoragePressed = (e) => OpenStorage(e, slot),
|
OnStoragePressed = (e) => OpenStorage(e, slot),
|
||||||
@@ -247,6 +257,23 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateHudTheme(int idx)
|
||||||
|
{
|
||||||
|
if (!_gameHud.ValidateHudTheme(idx))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (_, list) in _inventoryButtons)
|
||||||
|
{
|
||||||
|
foreach (var button in list)
|
||||||
|
{
|
||||||
|
button.Button.Texture = _gameHud.GetHudTexture($"{button.TextureName}.png");
|
||||||
|
button.StorageButton.TextureNormal = _gameHud.GetHudTexture("back.png");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class HumanInventoryWindow : SS14Window
|
private class HumanInventoryWindow : SS14Window
|
||||||
{
|
{
|
||||||
private const int ButtonSize = 64;
|
private const int ButtonSize = 64;
|
||||||
@@ -254,8 +281,9 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
|
|||||||
private const int RightSeparation = 2;
|
private const int RightSeparation = 2;
|
||||||
|
|
||||||
public IReadOnlyDictionary<Slots, ItemSlotButton> Buttons { get; }
|
public IReadOnlyDictionary<Slots, ItemSlotButton> Buttons { get; }
|
||||||
|
[Dependency] private readonly IGameHud _gameHud = default!;
|
||||||
|
|
||||||
public HumanInventoryWindow(IResourceCache resourceCache)
|
public HumanInventoryWindow(IGameHud gameHud)
|
||||||
{
|
{
|
||||||
Title = Loc.GetString("Your Inventory");
|
Title = Loc.GetString("Your Inventory");
|
||||||
Resizable = false;
|
Resizable = false;
|
||||||
@@ -271,9 +299,9 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
|
|||||||
|
|
||||||
void AddButton(Slots slot, string textureName, Vector2 position)
|
void AddButton(Slots slot, string textureName, Vector2 position)
|
||||||
{
|
{
|
||||||
var texture = resourceCache.GetTexture($"/Textures/Interface/Inventory/{textureName}.png");
|
var texture = gameHud.GetHudTexture($"{textureName}.png");
|
||||||
var storageTexture = resourceCache.GetTexture("/Textures/Interface/Inventory/back.png");
|
var storageTexture = gameHud.GetHudTexture("back.png");
|
||||||
var button = new ItemSlotButton(texture, storageTexture);
|
var button = new ItemSlotButton(texture, storageTexture, textureName);
|
||||||
|
|
||||||
LayoutContainer.SetPosition(button, position);
|
LayoutContainer.SetPosition(button, position);
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,24 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
using Content.Client.UserInterface.Stylesheets;
|
using Content.Client.UserInterface.Stylesheets;
|
||||||
using Content.Client.Utility;
|
using Content.Client.Utility;
|
||||||
|
using Content.Shared;
|
||||||
using Content.Shared.GameObjects.Components.Mobs;
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
|
using Content.Shared.Prototypes.HUD;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.Input;
|
using Robust.Client.Input;
|
||||||
using Robust.Client.ResourceManagement;
|
using Robust.Client.ResourceManagement;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
using Robust.Shared.Input.Binding;
|
using Robust.Shared.Input.Binding;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using static Robust.Client.Input.Keyboard.Key;
|
using static Robust.Client.Input.Keyboard.Key;
|
||||||
using Control = Robust.Client.UserInterface.Control;
|
using Control = Robust.Client.UserInterface.Control;
|
||||||
@@ -74,6 +80,10 @@ namespace Content.Client.UserInterface
|
|||||||
|
|
||||||
void AddTopNotification(TopNotification notification);
|
void AddTopNotification(TopNotification notification);
|
||||||
|
|
||||||
|
Texture GetHudTexture(string path);
|
||||||
|
|
||||||
|
bool ValidateHudTheme(int idx);
|
||||||
|
|
||||||
// Init logic.
|
// Init logic.
|
||||||
void Initialize();
|
void Initialize();
|
||||||
}
|
}
|
||||||
@@ -95,7 +105,9 @@ namespace Content.Client.UserInterface
|
|||||||
private VBoxContainer _topNotificationContainer = default!;
|
private VBoxContainer _topNotificationContainer = default!;
|
||||||
|
|
||||||
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
[Dependency] private readonly IInputManager _inputManager = default!;
|
[Dependency] private readonly IInputManager _inputManager = default!;
|
||||||
|
[Dependency] private readonly INetConfigurationManager _configManager = default!;
|
||||||
|
|
||||||
public Control HandsContainer { get; private set; } = default!;
|
public Control HandsContainer { get; private set; } = default!;
|
||||||
public Control SuspicionContainer { get; private set; } = default!;
|
public Control SuspicionContainer { get; private set; } = default!;
|
||||||
@@ -121,6 +133,38 @@ namespace Content.Client.UserInterface
|
|||||||
_topNotificationContainer.AddChild(notification);
|
_topNotificationContainer.AddChild(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ValidateHudTheme(int idx)
|
||||||
|
{
|
||||||
|
if (!_prototypeManager.TryIndex(idx.ToString(), out HudThemePrototype? _))
|
||||||
|
{
|
||||||
|
Logger.ErrorS("hud", "invalid HUD theme id {0}, using different theme",
|
||||||
|
idx);
|
||||||
|
var proto = _prototypeManager.EnumeratePrototypes<HudThemePrototype>().FirstOrDefault();
|
||||||
|
if (proto == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("No valid HUD prototypes!");
|
||||||
|
}
|
||||||
|
var id = int.Parse(proto.ID);
|
||||||
|
_configManager.SetCVar(CCVars.HudTheme, id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Texture GetHudTexture(string path)
|
||||||
|
{
|
||||||
|
var id = _configManager.GetCVar<int>("hud.theme");
|
||||||
|
var dir = string.Empty;
|
||||||
|
if (!_prototypeManager.TryIndex(id.ToString(), out HudThemePrototype? proto))
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
dir = proto.Path;
|
||||||
|
|
||||||
|
var resourcePath = (new ResourcePath("/Textures/Interface/Inventory") / dir) / path;
|
||||||
|
return _resourceCache.GetTexture(resourcePath);
|
||||||
|
}
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
RootControl = new LC { Name = "AAAAAAAAAAAAAAAAAAAAAA"};
|
RootControl = new LC { Name = "AAAAAAAAAAAAAAAAAAAAAA"};
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace Content.Client.UserInterface
|
|||||||
private bool _activeHand;
|
private bool _activeHand;
|
||||||
private bool _highlighted;
|
private bool _highlighted;
|
||||||
|
|
||||||
public HandButton(Texture texture, Texture storageTexture, Texture blockedTexture, HandLocation location) : base(texture, storageTexture)
|
public HandButton(Texture texture, Texture storageTexture, string textureName, Texture blockedTexture, HandLocation location) : base(texture, storageTexture, textureName)
|
||||||
{
|
{
|
||||||
Location = location;
|
Location = location;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Client.GameObjects.Components.Items;
|
using Content.Client.GameObjects.Components.Items;
|
||||||
using Content.Client.Utility;
|
using Content.Client.Utility;
|
||||||
|
using Content.Shared;
|
||||||
using Content.Shared.GameObjects.Components.Items;
|
using Content.Shared.GameObjects.Components.Items;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
@@ -10,6 +11,7 @@ using Robust.Client.Player;
|
|||||||
using Robust.Client.ResourceManagement;
|
using Robust.Client.ResourceManagement;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
@@ -21,10 +23,12 @@ namespace Content.Client.UserInterface
|
|||||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
||||||
[Dependency] private readonly IItemSlotManager _itemSlotManager = default!;
|
[Dependency] private readonly IItemSlotManager _itemSlotManager = default!;
|
||||||
|
[Dependency] private readonly IGameHud _gameHud = default!;
|
||||||
|
[Dependency] private readonly INetConfigurationManager _configManager = default!;
|
||||||
|
|
||||||
private readonly Texture _leftHandTexture;
|
private Texture _leftHandTexture;
|
||||||
private readonly Texture _middleHandTexture;
|
private Texture _middleHandTexture;
|
||||||
private readonly Texture _rightHandTexture;
|
private Texture _rightHandTexture;
|
||||||
|
|
||||||
private readonly ItemStatusPanel _topPanel;
|
private readonly ItemStatusPanel _topPanel;
|
||||||
|
|
||||||
@@ -36,6 +40,8 @@ namespace Content.Client.UserInterface
|
|||||||
{
|
{
|
||||||
IoCManager.InjectDependencies(this);
|
IoCManager.InjectDependencies(this);
|
||||||
|
|
||||||
|
_configManager.OnValueChanged(CCVars.HudTheme, UpdateHudTheme, invokeImmediately: true);
|
||||||
|
|
||||||
AddChild(_guiContainer = new HBoxContainer
|
AddChild(_guiContainer = new HBoxContainer
|
||||||
{
|
{
|
||||||
SeparationOverride = 0,
|
SeparationOverride = 0,
|
||||||
@@ -52,9 +58,21 @@ namespace Content.Client.UserInterface
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_leftHandTexture = _resourceCache.GetTexture("/Textures/Interface/Inventory/hand_l.png");
|
_leftHandTexture = _gameHud.GetHudTexture("hand_l.png");
|
||||||
_middleHandTexture = _resourceCache.GetTexture("/Textures/Interface/Inventory/hand_l.png");
|
_middleHandTexture = _gameHud.GetHudTexture("hand_l.png");
|
||||||
_rightHandTexture = _resourceCache.GetTexture("/Textures/Interface/Inventory/hand_r.png");
|
_rightHandTexture = _gameHud.GetHudTexture("hand_r.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateHudTheme(int idx)
|
||||||
|
{
|
||||||
|
if (!_gameHud.ValidateHudTheme(idx))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_leftHandTexture = _gameHud.GetHudTexture("hand_l.png");
|
||||||
|
_middleHandTexture = _gameHud.GetHudTexture("hand_l.png");
|
||||||
|
_rightHandTexture = _gameHud.GetHudTexture("hand_r.png");
|
||||||
|
UpdateHandIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Texture HandTexture(HandLocation location)
|
private Texture HandTexture(HandLocation location)
|
||||||
@@ -82,10 +100,15 @@ namespace Content.Client.UserInterface
|
|||||||
/// </param>
|
/// </param>
|
||||||
private void AddHand(Hand hand, HandLocation buttonLocation)
|
private void AddHand(Hand hand, HandLocation buttonLocation)
|
||||||
{
|
{
|
||||||
|
var textureName = "hand_l.png";
|
||||||
|
if(buttonLocation == HandLocation.Right)
|
||||||
|
{
|
||||||
|
textureName = "hand_r.png";
|
||||||
|
}
|
||||||
var buttonTexture = HandTexture(buttonLocation);
|
var buttonTexture = HandTexture(buttonLocation);
|
||||||
var storageTexture = _resourceCache.GetTexture("/Textures/Interface/Inventory/back.png");
|
var storageTexture = _gameHud.GetHudTexture("back.png");
|
||||||
var blockedTexture = _resourceCache.GetTexture("/Textures/Interface/Inventory/blocked.png");
|
var blockedTexture = _resourceCache.GetTexture("/Textures/Interface/Inventory/blocked.png");
|
||||||
var button = new HandButton(buttonTexture, storageTexture, blockedTexture, buttonLocation);
|
var button = new HandButton(buttonTexture, storageTexture, textureName, blockedTexture, buttonLocation);
|
||||||
var slot = hand.Name;
|
var slot = hand.Name;
|
||||||
|
|
||||||
button.OnPressed += args => HandKeyBindDown(args, slot);
|
button.OnPressed += args => HandKeyBindDown(args, slot);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Content.Client.UserInterface
|
|||||||
public TextureRect Button { get; }
|
public TextureRect Button { get; }
|
||||||
public SpriteView SpriteView { get; }
|
public SpriteView SpriteView { get; }
|
||||||
public SpriteView HoverSpriteView { get; }
|
public SpriteView HoverSpriteView { get; }
|
||||||
public BaseButton StorageButton { get; }
|
public TextureButton StorageButton { get; }
|
||||||
public CooldownGraphic CooldownDisplay { get; }
|
public CooldownGraphic CooldownDisplay { get; }
|
||||||
|
|
||||||
public Action<GUIBoundKeyEventArgs>? OnPressed { get; set; }
|
public Action<GUIBoundKeyEventArgs>? OnPressed { get; set; }
|
||||||
@@ -27,10 +27,14 @@ namespace Content.Client.UserInterface
|
|||||||
|
|
||||||
private readonly PanelContainer _highlightRect;
|
private readonly PanelContainer _highlightRect;
|
||||||
|
|
||||||
public ItemSlotButton(Texture texture, Texture storageTexture)
|
public string TextureName { get; set; }
|
||||||
|
|
||||||
|
public ItemSlotButton(Texture texture, Texture storageTexture, string textureName)
|
||||||
{
|
{
|
||||||
MinSize = (64, 64);
|
MinSize = (64, 64);
|
||||||
|
|
||||||
|
TextureName = textureName;
|
||||||
|
|
||||||
AddChild(Button = new TextureRect
|
AddChild(Button = new TextureRect
|
||||||
{
|
{
|
||||||
Texture = texture,
|
Texture = texture,
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
using Robust.Client.Graphics;
|
using System;
|
||||||
|
using Content.Client.GameObjects.Components.HUD.Inventory;
|
||||||
|
using Content.Shared;
|
||||||
|
using Content.Shared.Prototypes.HUD;
|
||||||
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.ResourceManagement;
|
using Robust.Client.ResourceManagement;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
@@ -7,6 +11,7 @@ using Robust.Shared.Configuration;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Client.UserInterface
|
namespace Content.Client.UserInterface
|
||||||
{
|
{
|
||||||
@@ -26,16 +31,19 @@ namespace Content.Client.UserInterface
|
|||||||
};
|
};
|
||||||
|
|
||||||
private readonly IConfigurationManager _cfg;
|
private readonly IConfigurationManager _cfg;
|
||||||
|
private readonly IPrototypeManager _prototypeManager;
|
||||||
|
|
||||||
private readonly Button ApplyButton;
|
private readonly Button ApplyButton;
|
||||||
private readonly CheckBox VSyncCheckBox;
|
private readonly CheckBox VSyncCheckBox;
|
||||||
private readonly CheckBox FullscreenCheckBox;
|
private readonly CheckBox FullscreenCheckBox;
|
||||||
private readonly OptionButton LightingPresetOption;
|
private readonly OptionButton LightingPresetOption;
|
||||||
private readonly OptionButton _uiScaleOption;
|
private readonly OptionButton _uiScaleOption;
|
||||||
|
private readonly OptionButton _hudThemeOption;
|
||||||
|
|
||||||
public GraphicsControl(IConfigurationManager cfg)
|
public GraphicsControl(IConfigurationManager cfg, IPrototypeManager proMan)
|
||||||
{
|
{
|
||||||
_cfg = cfg;
|
_cfg = cfg;
|
||||||
|
_prototypeManager = proMan;
|
||||||
var vBox = new VBoxContainer();
|
var vBox = new VBoxContainer();
|
||||||
|
|
||||||
var contents = new VBoxContainer
|
var contents = new VBoxContainer
|
||||||
@@ -75,10 +83,9 @@ namespace Content.Client.UserInterface
|
|||||||
HorizontalAlignment = HAlignment.Right
|
HorizontalAlignment = HAlignment.Right
|
||||||
};
|
};
|
||||||
|
|
||||||
var resourceCache = IoCManager.Resolve<IResourceCache>();
|
|
||||||
|
|
||||||
_uiScaleOption = new OptionButton();
|
_uiScaleOption = new OptionButton();
|
||||||
_uiScaleOption.AddItem(Loc.GetString("ui-options-scale-auto", ("scale", UserInterfaceManager.DefaultUIScale)));
|
_uiScaleOption.AddItem(Loc.GetString("ui-options-scale-auto",
|
||||||
|
("scale", UserInterfaceManager.DefaultUIScale)));
|
||||||
_uiScaleOption.AddItem(Loc.GetString("ui-options-scale-75"));
|
_uiScaleOption.AddItem(Loc.GetString("ui-options-scale-75"));
|
||||||
_uiScaleOption.AddItem(Loc.GetString("ui-options-scale-100"));
|
_uiScaleOption.AddItem(Loc.GetString("ui-options-scale-100"));
|
||||||
_uiScaleOption.AddItem(Loc.GetString("ui-options-scale-125"));
|
_uiScaleOption.AddItem(Loc.GetString("ui-options-scale-125"));
|
||||||
@@ -97,6 +104,23 @@ namespace Content.Client.UserInterface
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_hudThemeOption = new OptionButton();
|
||||||
|
foreach (var gear in _prototypeManager.EnumeratePrototypes<HudThemePrototype>())
|
||||||
|
{
|
||||||
|
_hudThemeOption.AddItem(Loc.GetString(gear.Name));
|
||||||
|
}
|
||||||
|
_hudThemeOption.OnItemSelected += OnHudThemeChanged;
|
||||||
|
|
||||||
|
contents.AddChild(new HBoxContainer
|
||||||
|
{
|
||||||
|
Children =
|
||||||
|
{
|
||||||
|
new Label {Text = Loc.GetString("ui-options-hud-theme")},
|
||||||
|
new Control {MinSize = (4, 0)},
|
||||||
|
_hudThemeOption
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
contents.AddChild(new Placeholder()
|
contents.AddChild(new Placeholder()
|
||||||
{
|
{
|
||||||
VerticalExpand = true,
|
VerticalExpand = true,
|
||||||
@@ -120,6 +144,7 @@ namespace Content.Client.UserInterface
|
|||||||
FullscreenCheckBox.Pressed = ConfigIsFullscreen;
|
FullscreenCheckBox.Pressed = ConfigIsFullscreen;
|
||||||
LightingPresetOption.SelectId(GetConfigLightingQuality());
|
LightingPresetOption.SelectId(GetConfigLightingQuality());
|
||||||
_uiScaleOption.SelectId(GetConfigUIScalePreset(ConfigUIScale));
|
_uiScaleOption.SelectId(GetConfigUIScalePreset(ConfigUIScale));
|
||||||
|
_hudThemeOption.SelectId(_cfg.GetCVar(CCVars.HudTheme));
|
||||||
|
|
||||||
AddChild(vBox);
|
AddChild(vBox);
|
||||||
}
|
}
|
||||||
@@ -130,10 +155,21 @@ namespace Content.Client.UserInterface
|
|||||||
UpdateApplyButton();
|
UpdateApplyButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnHudThemeChanged(OptionButton.ItemSelectedEventArgs args)
|
||||||
|
{
|
||||||
|
_hudThemeOption.SelectId(args.Id);
|
||||||
|
UpdateApplyButton();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
|
private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
|
||||||
{
|
{
|
||||||
_cfg.SetCVar(CVars.DisplayVSync, VSyncCheckBox.Pressed);
|
_cfg.SetCVar(CVars.DisplayVSync, VSyncCheckBox.Pressed);
|
||||||
SetConfigLightingQuality(LightingPresetOption.SelectedId);
|
SetConfigLightingQuality(LightingPresetOption.SelectedId);
|
||||||
|
if (_hudThemeOption.SelectedId != _cfg.GetCVar(CCVars.HudTheme)) // Don't unnecessarily redraw the HUD
|
||||||
|
{
|
||||||
|
_cfg.SetCVar(CCVars.HudTheme, _hudThemeOption.SelectedId);
|
||||||
|
}
|
||||||
|
|
||||||
_cfg.SetCVar(CVars.DisplayWindowMode,
|
_cfg.SetCVar(CVars.DisplayWindowMode,
|
||||||
(int) (FullscreenCheckBox.Pressed ? WindowMode.Fullscreen : WindowMode.Windowed));
|
(int) (FullscreenCheckBox.Pressed ? WindowMode.Fullscreen : WindowMode.Windowed));
|
||||||
_cfg.SetCVar(CVars.DisplayUIScale, UIScaleOptions[_uiScaleOption.SelectedId]);
|
_cfg.SetCVar(CVars.DisplayUIScale, UIScaleOptions[_uiScaleOption.SelectedId]);
|
||||||
@@ -157,8 +193,10 @@ namespace Content.Client.UserInterface
|
|||||||
var isVSyncSame = VSyncCheckBox.Pressed == _cfg.GetCVar(CVars.DisplayVSync);
|
var isVSyncSame = VSyncCheckBox.Pressed == _cfg.GetCVar(CVars.DisplayVSync);
|
||||||
var isFullscreenSame = FullscreenCheckBox.Pressed == ConfigIsFullscreen;
|
var isFullscreenSame = FullscreenCheckBox.Pressed == ConfigIsFullscreen;
|
||||||
var isLightingQualitySame = LightingPresetOption.SelectedId == GetConfigLightingQuality();
|
var isLightingQualitySame = LightingPresetOption.SelectedId == GetConfigLightingQuality();
|
||||||
|
var isHudThemeSame = _hudThemeOption.SelectedId == _cfg.GetCVar(CCVars.HudTheme);
|
||||||
var isUIScaleSame = MathHelper.CloseTo(UIScaleOptions[_uiScaleOption.SelectedId], ConfigUIScale);
|
var isUIScaleSame = MathHelper.CloseTo(UIScaleOptions[_uiScaleOption.SelectedId], ConfigUIScale);
|
||||||
ApplyButton.Disabled = isVSyncSame && isFullscreenSame && isLightingQualitySame && isUIScaleSame;
|
ApplyButton.Disabled = isVSyncSame && isFullscreenSame && isLightingQualitySame && isHudThemeSame &&
|
||||||
|
isUIScaleSame;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ConfigIsFullscreen =>
|
private bool ConfigIsFullscreen =>
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ using Robust.Shared.Configuration;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Client.UserInterface
|
namespace Content.Client.UserInterface
|
||||||
{
|
{
|
||||||
public sealed partial class OptionsMenu : SS14Window
|
public sealed partial class OptionsMenu : SS14Window
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IConfigurationManager _configManager = default!;
|
[Dependency] private readonly IConfigurationManager _configManager = default!;
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
[Dependency] private readonly IClydeAudio _clydeAudio = default!;
|
[Dependency] private readonly IClydeAudio _clydeAudio = default!;
|
||||||
|
|
||||||
public OptionsMenu()
|
public OptionsMenu()
|
||||||
@@ -28,7 +30,7 @@ namespace Content.Client.UserInterface
|
|||||||
{
|
{
|
||||||
Children =
|
Children =
|
||||||
{
|
{
|
||||||
(graphicsControl = new GraphicsControl(_configManager)),
|
(graphicsControl = new GraphicsControl(_configManager, _prototypeManager)),
|
||||||
(rebindControl = new KeyRebindControl()),
|
(rebindControl = new KeyRebindControl()),
|
||||||
(audioControl = new AudioControl(_configManager, _clydeAudio)),
|
(audioControl = new AudioControl(_configManager, _clydeAudio)),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,6 +190,13 @@ namespace Content.Shared
|
|||||||
public static readonly CVarDef<bool> LobbyMusicEnabled =
|
public static readonly CVarDef<bool> LobbyMusicEnabled =
|
||||||
CVarDef.Create("ambience.lobbymusicenabled", true, CVar.ARCHIVE | CVar.CLIENTONLY);
|
CVarDef.Create("ambience.lobbymusicenabled", true, CVar.ARCHIVE | CVar.CLIENTONLY);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HUD
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static readonly CVarDef<int> HudTheme =
|
||||||
|
CVarDef.Create("hud.theme", 0, CVar.ARCHIVE | CVar.CLIENTONLY);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AI
|
* AI
|
||||||
*/
|
*/
|
||||||
|
|||||||
18
Content.Shared/Prototypes/HUD/HudThemePrototype.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
|
||||||
|
namespace Content.Shared.Prototypes.HUD
|
||||||
|
{
|
||||||
|
[Prototype("hudTheme")]
|
||||||
|
public class HudThemePrototype : IPrototype
|
||||||
|
{
|
||||||
|
[field: DataField("name", required: true)]
|
||||||
|
public string Name { get; } = string.Empty;
|
||||||
|
|
||||||
|
[field: DataField("id", required: true)]
|
||||||
|
public string ID { get; } = string.Empty;
|
||||||
|
|
||||||
|
[field: DataField("path", required: true)]
|
||||||
|
public string Path { get; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,10 @@ ui-options-scale-125 = 125%
|
|||||||
ui-options-scale-150 = 150%
|
ui-options-scale-150 = 150%
|
||||||
ui-options-scale-175 = 175%
|
ui-options-scale-175 = 175%
|
||||||
ui-options-scale-200 = 200%
|
ui-options-scale-200 = 200%
|
||||||
|
ui-options-hud-theme = HUD Theme:
|
||||||
|
ui-options-hud-theme-default = Default
|
||||||
|
ui-options-hud-theme-modernized = Modernized
|
||||||
|
ui-options-hud-theme-classic = Classic
|
||||||
ui-options-placeholder-viewport = Viewport settings
|
ui-options-placeholder-viewport = Viewport settings
|
||||||
|
|
||||||
## Controls menu
|
## Controls menu
|
||||||
|
|||||||
14
Resources/Prototypes/hud.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
- type: hudTheme
|
||||||
|
id: 0
|
||||||
|
name: ui-options-hud-theme-default
|
||||||
|
path: Default
|
||||||
|
|
||||||
|
- type: hudTheme
|
||||||
|
id: 1
|
||||||
|
name: ui-options-hud-theme-modernized
|
||||||
|
path: Modernized
|
||||||
|
|
||||||
|
- type: hudTheme
|
||||||
|
id: 2
|
||||||
|
name: ui-options-hud-theme-classic
|
||||||
|
path: Classic
|
||||||
|
Before Width: | Height: | Size: 941 B After Width: | Height: | Size: 941 B |
|
Before Width: | Height: | Size: 587 B After Width: | Height: | Size: 587 B |
|
Before Width: | Height: | Size: 768 B After Width: | Height: | Size: 768 B |
|
Before Width: | Height: | Size: 597 B After Width: | Height: | Size: 597 B |
|
Before Width: | Height: | Size: 882 B After Width: | Height: | Size: 882 B |
|
Before Width: | Height: | Size: 732 B After Width: | Height: | Size: 732 B |
|
Before Width: | Height: | Size: 679 B After Width: | Height: | Size: 679 B |
|
Before Width: | Height: | Size: 719 B After Width: | Height: | Size: 719 B |
|
Before Width: | Height: | Size: 660 B After Width: | Height: | Size: 660 B |
|
Before Width: | Height: | Size: 549 B After Width: | Height: | Size: 549 B |
|
Before Width: | Height: | Size: 476 B After Width: | Height: | Size: 476 B |
|
Before Width: | Height: | Size: 582 B After Width: | Height: | Size: 582 B |
BIN
Resources/Textures/Interface/Inventory/Classic/neck.png
Normal file
|
After Width: | Height: | Size: 846 B |
|
Before Width: | Height: | Size: 649 B After Width: | Height: | Size: 649 B |
|
Before Width: | Height: | Size: 628 B After Width: | Height: | Size: 628 B |
|
Before Width: | Height: | Size: 850 B After Width: | Height: | Size: 850 B |
|
Before Width: | Height: | Size: 947 B After Width: | Height: | Size: 947 B |
|
Before Width: | Height: | Size: 726 B After Width: | Height: | Size: 726 B |
|
Before Width: | Height: | Size: 791 B After Width: | Height: | Size: 791 B |
|
Before Width: | Height: | Size: 540 B After Width: | Height: | Size: 540 B |
|
Before Width: | Height: | Size: 676 B After Width: | Height: | Size: 676 B |
|
Before Width: | Height: | Size: 505 B After Width: | Height: | Size: 505 B |
|
Before Width: | Height: | Size: 489 B After Width: | Height: | Size: 489 B |
|
Before Width: | Height: | Size: 737 B After Width: | Height: | Size: 737 B |
|
Before Width: | Height: | Size: 642 B After Width: | Height: | Size: 642 B |
|
Before Width: | Height: | Size: 600 B After Width: | Height: | Size: 600 B |
|
Before Width: | Height: | Size: 628 B After Width: | Height: | Size: 628 B |
|
Before Width: | Height: | Size: 570 B After Width: | Height: | Size: 570 B |
|
Before Width: | Height: | Size: 463 B After Width: | Height: | Size: 463 B |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 442 B |
|
Before Width: | Height: | Size: 685 B After Width: | Height: | Size: 685 B |
|
Before Width: | Height: | Size: 492 B After Width: | Height: | Size: 492 B |
|
Before Width: | Height: | Size: 573 B After Width: | Height: | Size: 573 B |
|
Before Width: | Height: | Size: 491 B After Width: | Height: | Size: 491 B |
|
Before Width: | Height: | Size: 566 B After Width: | Height: | Size: 566 B |
|
Before Width: | Height: | Size: 530 B After Width: | Height: | Size: 530 B |
|
Before Width: | Height: | Size: 732 B After Width: | Height: | Size: 732 B |
|
Before Width: | Height: | Size: 869 B After Width: | Height: | Size: 869 B |
|
Before Width: | Height: | Size: 654 B After Width: | Height: | Size: 654 B |
|
Before Width: | Height: | Size: 425 B After Width: | Height: | Size: 425 B |
|
Before Width: | Height: | Size: 395 B After Width: | Height: | Size: 395 B |
|
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 231 B |
|
Before Width: | Height: | Size: 419 B After Width: | Height: | Size: 419 B |
|
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 321 B |
|
Before Width: | Height: | Size: 441 B After Width: | Height: | Size: 441 B |
|
Before Width: | Height: | Size: 368 B After Width: | Height: | Size: 368 B |
|
Before Width: | Height: | Size: 418 B After Width: | Height: | Size: 418 B |
|
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 474 B After Width: | Height: | Size: 474 B |
|
Before Width: | Height: | Size: 355 B After Width: | Height: | Size: 355 B |
|
Before Width: | Height: | Size: 364 B After Width: | Height: | Size: 364 B |
|
Before Width: | Height: | Size: 485 B After Width: | Height: | Size: 485 B |
|
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 399 B |
|
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 426 B |
|
Before Width: | Height: | Size: 370 B After Width: | Height: | Size: 370 B |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 339 B After Width: | Height: | Size: 339 B |
|
Before Width: | Height: | Size: 375 B After Width: | Height: | Size: 375 B |
|
Before Width: | Height: | Size: 480 B After Width: | Height: | Size: 480 B |
|
Before Width: | Height: | Size: 374 B After Width: | Height: | Size: 374 B |
|
Before Width: | Height: | Size: 700 B |
|
Before Width: | Height: | Size: 454 B |
|
Before Width: | Height: | Size: 594 B |
|
Before Width: | Height: | Size: 342 B |
|
Before Width: | Height: | Size: 398 B |
|
Before Width: | Height: | Size: 727 B |
|
Before Width: | Height: | Size: 557 B |
|
Before Width: | Height: | Size: 485 B |
|
Before Width: | Height: | Size: 568 B |
|
Before Width: | Height: | Size: 486 B |
|
Before Width: | Height: | Size: 335 B |
|
Before Width: | Height: | Size: 261 B |
|
Before Width: | Height: | Size: 387 B |
|
Before Width: | Height: | Size: 620 B |
|
Before Width: | Height: | Size: 340 B |
|
Before Width: | Height: | Size: 541 B |
|
Before Width: | Height: | Size: 416 B |
|
Before Width: | Height: | Size: 617 B |
|
Before Width: | Height: | Size: 881 B |
|
Before Width: | Height: | Size: 506 B |