using System; using System.Globalization; using System.Collections.Generic; using Newtonsoft.Json; using Oxide.Core.Libraries.Covalence; using Oxide.Core.Plugins; using Oxide.Core; using Oxide.Game.Rust.Cui; using UnityEngine; /*1.1.9 * NRE fix */ namespace Oxide.Plugins { [Info("Ammo HUD", "beee", "1.1.9")] [Description("Allows players to show an Ammo HUD.")] public class AmmoHUD : RustPlugin { public static AmmoHUD _plugin; private static PluginConfig _config; [PluginReference] private Plugin ImageLibrary; public PlayersData pData; public const string PREFIX_SHORT = "ahud."; public const string PREFIX_LONG = "ammohud."; public const string PERM_ADMIN = PREFIX_LONG + "admin"; public const string PERM_USE = PREFIX_LONG + "use"; private class PluginConfig { [JsonProperty("Position Settings")] public PositionConfigSettings PositionSettings { get; set; } #region PositionConfigSettings internal class PositionConfigSettings { [JsonProperty("Default State (true = on, false = off)")] public bool DefaultState { get; set; } [JsonProperty( "Position (Top, TopLeft, TopRight, Left, Right, Bottom, BottomLeft, BottomRight)" )] public string Position { get; set; } [JsonProperty("Custom Position")] public CustomPositionConfigSettings CustomPositionSettings { get; set; } #region CustomPositionConfigSettings internal class CustomPositionConfigSettings { [JsonProperty("Enabled")] public bool Enabled { get; set; } [JsonProperty("Custom Position")] public PositionPreset CustomPosition { get; set; } } #endregion } #endregion } protected override void LoadDefaultConfig() { _config = new PluginConfig { PositionSettings = new PluginConfig.PositionConfigSettings() { DefaultState = true, Position = "Right", CustomPositionSettings = new PluginConfig.PositionConfigSettings.CustomPositionConfigSettings() { Enabled = false, CustomPosition = new PositionPreset() { Position = PositionEnum.Right, ParentPosition = new PositionParams() { Enabled = true, AnchorMin = "1 0.5", AnchorMax = "1 0.5", OffsetMin = "-155 -32", OffsetMax = "-15 33" }, WeaponAmmoFontSize = 36, WeaponAmmoTextAlignment = TextAnchor.LowerRight, WeaponAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0", AnchorMax = "0.79 0.70", OffsetMin = "0 0", OffsetMax = "0 0" }, TotalAmmoFontSize = 22, TotalAmmoTextAlignment = TextAnchor.LowerRight, TotalAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0.55", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0" }, IconPosition = new PositionParams() { Enabled = true, AnchorMin = "0.83 0.15", AnchorMax = "1 0.51", OffsetMin = "0 0", OffsetMax = "0 0" } } } } }; } protected override void LoadConfig() { base.LoadConfig(); _config = Config.ReadObject(); if ( _config == null || _config.PositionSettings == null || _config.PositionSettings.CustomPositionSettings == null || _config.PositionSettings.CustomPositionSettings.CustomPosition == null ) { LoadDefaultConfig(); SaveConfig(); } LoadColors(); } protected override void SaveConfig() { Config.WriteObject(_config); } void OnServerInitialized() { if (!ImageLibrary) { PrintError("The plugin is not installed on the server [ImageLibrary]"); } else { ImageLibrary.Call("AddImage", "https://i.imgur.com/DvgPtiW.png", "genericammo"); } RegisterMessages(); //permission.RegisterPermission(PERM_ADMIN, this); permission.RegisterPermission(PERM_USE, this); } void Loaded() { _plugin = this; LoadDefaultPresets(); pData = PlayersData.Load(); } void Unload() { SaveData(); foreach (var player in BasePlayer.activePlayerList) { CuiHelper.DestroyUi(player, Layer + "." + uisuffix); } _plugin = null; _config = null; } void RegisterMessages() => lang.RegisterMessages(messages, this); #region Data private void OnServerSave() => SaveData(); private bool wiped { get; set; } private void OnNewSave(string filename) => wiped = true; private void SaveData() { if (pData != null) pData.Save(); } public class PlayersData { public Dictionary Players = new Dictionary(); public static PlayersData Load() { var data = Interface.Oxide.DataFileSystem.ReadObject(nameof(AmmoHUD)); if (data == null || _plugin.wiped) { _plugin.PrintWarning("No player data found! Creating a new data file"); data = new PlayersData(); data.Save(); } return data; } public void Save() { Interface.Oxide.DataFileSystem.WriteObject(nameof(AmmoHUD), this); } public bool ToggleHUDActive(ulong playerid) { PlayerInfo playerInfo; if (!Players.TryGetValue(playerid, out playerInfo)) { Players.Add( playerid, playerInfo = new PlayerInfo() { HUDActive = false, Position = "Default" } ); } else { playerInfo.HUDActive = !playerInfo.HUDActive; } return playerInfo.HUDActive; } public bool IsActive(ulong playerid) { PlayerInfo playerInfo; if (!Players.TryGetValue(playerid, out playerInfo)) { return true; } else { return playerInfo.HUDActive; } } public void SetWeaponActive(ulong playerid, bool active) { PlayerInfo playerInfo; if (!Players.TryGetValue(playerid, out playerInfo)) { Players.Add( playerid, playerInfo = new PlayerInfo() { HUDActive = _config.PositionSettings.DefaultState, WeaponActive = active, Position = "Default" } ); } else { playerInfo.WeaponActive = active; } } public bool IsWeaponActive(ulong playerid) { PlayerInfo playerInfo; if (!Players.TryGetValue(playerid, out playerInfo)) { return false; } else { return playerInfo.WeaponActive; } } public PositionPreset GetPosition(ulong playerid) { PlayerInfo playerInfo; if (Players.TryGetValue(playerid, out playerInfo)) { var position = _plugin.GetPreset(playerInfo.Position); if (position != null) return position; } return _plugin.GetConfigPosition(); } public void SetPosition(ulong playerid, string position) { PlayerInfo playerInfo; if (!Players.TryGetValue(playerid, out playerInfo)) { Players.Add( playerid, playerInfo = new PlayerInfo() { HUDActive = true, Position = position } ); } else { playerInfo.Position = position; } } } public class PlayerInfo { public bool HUDActive = true; public string Position = "Default"; [JsonIgnore] public bool WeaponActive = false; } #endregion #region Commands [ChatCommand("ammohud")] void AmmoHUDChatCMD(BasePlayer player, string command, string[] args) { if (player == null || !permission.UserHasPermission(player.UserIDString, PERM_USE)) return; if (args.Length == 0) { BroadcastCommands(player); return; } string argument = args[0].ToLower().Trim(); if (argument == "toggle") { bool isActive = pData.ToggleHUDActive(player.userID); UpdateUI(player, player.GetHeldEntity() as BaseProjectile); if (isActive) Reply(player, lang.GetMessage("toggle_enabled", this, player.UserIDString)); else Reply(player, lang.GetMessage("toggle_disabled", this, player.UserIDString)); } else if (argument.ToLower() == "default") { pData.SetPosition(player.userID, argument); UpdateUI(player, player.GetHeldEntity() as BaseProjectile); Reply(player, string.Format(lang.GetMessage("positionsetto", this, player.UserIDString), "Default")); } else { var preset = GetPreset(argument); if (preset != null) { pData.SetPosition(player.userID, argument); UpdateUI(player, player.GetHeldEntity() as BaseProjectile); Reply(player, string.Format(lang.GetMessage("positionsetto", this, player.UserIDString), preset.Position.ToString())); } } } public void BroadcastCommands(BasePlayer player) { string msg = string.Format(lang.GetMessage("commands", this, player.UserIDString), fontColor1); SendReply(player, msg); } #endregion #region Hooks void OnActiveItemChanged(BasePlayer player, Item oldItem, Item newItem) { if (player == null || !permission.UserHasPermission(player.UserIDString, PERM_USE)) return; if (newItem == null || newItem.info.shortname.Contains("snowballgun")) { UpdateUI(player, null); return; } bool statechanged = false; if (newItem != null && newItem.GetHeldEntity() is BaseProjectile) { if (!pData.IsWeaponActive(player.userID)) { statechanged = true; pData.SetWeaponActive(player.userID, true); } } else { if (pData.IsWeaponActive(player.userID)) { statechanged = true; pData.SetWeaponActive(player.userID, false); } } if (statechanged || oldItem != newItem) UpdateUI(player, newItem.GetHeldEntity() as BaseProjectile); } void OnWeaponFired( BaseProjectile projectile, BasePlayer player, ItemModProjectile mod, ProtoBuf.ProjectileShoot projectiles ) { if (player == null || !permission.UserHasPermission(player.UserIDString, PERM_USE)) return; if (projectile != null && !projectile.ShortPrefabName.Contains("snowballgun")) UpdateUI(player, projectile, UpdateEnum.WeaponAmmo); } void OnRocketLaunched(BasePlayer player, BaseEntity entity) { if (player == null || !permission.UserHasPermission(player.UserIDString, PERM_USE)) return; var projectile = player.GetHeldEntity() as BaseProjectile; if (projectile != null) { UpdateUI(player, projectile, UpdateEnum.WeaponAmmo); } } object OnMagazineReload(BaseProjectile weapon, int desiredAmount, BasePlayer player) { if (player == null || !permission.UserHasPermission(player.UserIDString, PERM_USE)) return null; _plugin.timer.Once( 0.2f, () => { UpdateUI(player, weapon, UpdateEnum.All); } ); return null; } void OnItemAddedToContainer(ItemContainer container, Item item) { if(container == null || item == null || item.info == null) return; var player = container?.playerOwner as BasePlayer; if (player == null || player.UserIDString == null || !permission.UserHasPermission(player.UserIDString, PERM_USE)) return; if (item.info.shortname.Contains("ammo")) { var projectile = player.GetHeldEntity() as BaseProjectile; if (projectile != null) { UpdateUI(player, projectile, UpdateEnum.AvailableAmmo); } } } void OnItemRemovedFromContainer(ItemContainer container, Item item) { var player = container?.playerOwner as BasePlayer; if (player == null || !permission.UserHasPermission(player.UserIDString, PERM_USE)) return; if (item.info.shortname.Contains("ammo")) { var projectile = player.GetHeldEntity() as BaseProjectile; if (projectile != null) { UpdateUI(player, projectile, UpdateEnum.AvailableAmmo); } } } #endregion #region UI string defaultAmmoColor, redAmmoColor, orangeAmmoColor = ""; string defaultIconColor, blueIconColor, redIconColor, greyIconColor, greenIconColor = ""; public void LoadColors() { defaultAmmoColor = GetColorFromHex("#ffffff", 80); redAmmoColor = GetColorFromHex("#ff3737", 80); orangeAmmoColor = GetColorFromHex("#ffa749", 80); defaultIconColor = GetColorFromHex("#ba9a51", 50); blueIconColor = GetColorFromHex("#3564c3", 50); redIconColor = GetColorFromHex("#d43224", 50); greyIconColor = GetColorFromHex("#1e1e1e", 50); greenIconColor = GetColorFromHex("#57a14f", 50); } private enum UpdateEnum { All, WeaponAmmo, AvailableAmmo, AllAmmo, Icon } public string Layer = "Under"; public string uisuffix = "wui"; private void UpdateUI( BasePlayer player, BaseProjectile item, UpdateEnum uiToUpdate = UpdateEnum.All ) { if (player == null) return; if ( item == null || !pData.IsActive(player.userID) || !pData.IsWeaponActive(player.userID) ) { CuiHelper.DestroyUi(player, Layer + "." + uisuffix); return; } PositionPreset position = pData.GetPosition(player.userID); if (!position.ParentPosition.Enabled) { CuiHelper.DestroyUi(player, Layer + "." + uisuffix); return; } if (uiToUpdate == UpdateEnum.All) CuiHelper.DestroyUi(player, Layer + "." + uisuffix); var cont = new CuiElementContainer(); if (uiToUpdate == UpdateEnum.All) { cont.Add( new CuiPanel { CursorEnabled = false, RectTransform = { AnchorMin = position.ParentPosition.AnchorMin, AnchorMax = position.ParentPosition.AnchorMax, OffsetMin = position.ParentPosition.OffsetMin, OffsetMax = position.ParentPosition.OffsetMax }, Image = { Color = "0 0 0 0" } }, Layer, Layer + "." + uisuffix ); } if ( ( uiToUpdate == UpdateEnum.All || uiToUpdate == UpdateEnum.AvailableAmmo || uiToUpdate == UpdateEnum.AllAmmo ) && position.TotalAmmoPosition.Enabled ) { if (uiToUpdate == UpdateEnum.AvailableAmmo || uiToUpdate == UpdateEnum.AllAmmo) CuiHelper.DestroyUi(player, "." + uisuffix + "totammo"); cont.Add( new CuiElement { Parent = Layer + "." + uisuffix, Name = "." + uisuffix + "totammo", Components = { new CuiTextComponent() { Color = GetColorFromHex("#ffffff", 50), Text = string.Format("{0:n0}", item.GetAvailableAmmo()), FontSize = position.TotalAmmoFontSize, Align = position.TotalAmmoTextAlignment, Font = "robotocondensed-bold.ttf" }, new CuiRectTransformComponent { AnchorMin = position.TotalAmmoPosition.AnchorMin, AnchorMax = position.TotalAmmoPosition.AnchorMax, OffsetMin = position.TotalAmmoPosition.OffsetMin, OffsetMax = position.TotalAmmoPosition.OffsetMax } } } ); } if ( ( uiToUpdate == UpdateEnum.All || uiToUpdate == UpdateEnum.WeaponAmmo || uiToUpdate == UpdateEnum.AllAmmo ) && position.WeaponAmmoPosition.Enabled ) { if (uiToUpdate == UpdateEnum.WeaponAmmo || uiToUpdate == UpdateEnum.AllAmmo) CuiHelper.DestroyUi(player, "." + uisuffix + "currammo"); string ammoColor = defaultAmmoColor; bool dangerzone = false; int currAmmo = item.primaryMagazine.contents; int magCapacity = item.primaryMagazine.capacity; float ammoRatio = (float)currAmmo / (float)magCapacity; if (ammoRatio < 0.6f) ammoColor = orangeAmmoColor; if (ammoRatio < 0.3f) ammoColor = redAmmoColor; cont.Add( new CuiElement { Parent = Layer + "." + uisuffix, Name = "." + uisuffix + "currammo", Components = { new CuiTextComponent() { Color = ammoColor, Text = $"{currAmmo}", FontSize = position.WeaponAmmoFontSize, Align = position.WeaponAmmoTextAlignment, Font = "robotocondensed-bold.ttf" }, new CuiRectTransformComponent { AnchorMin = position.WeaponAmmoPosition.AnchorMin, AnchorMax = position.WeaponAmmoPosition.AnchorMax, OffsetMin = position.WeaponAmmoPosition.OffsetMin, OffsetMax = position.WeaponAmmoPosition.OffsetMax } } } ); } if ( (uiToUpdate == UpdateEnum.All || uiToUpdate == UpdateEnum.Icon) && position.IconPosition.Enabled ) { if (uiToUpdate == UpdateEnum.Icon) CuiHelper.DestroyUi(player, "." + uisuffix + "icon"); var ammoItemDefinition = item.primaryMagazine.ammoType; string iconColor = defaultIconColor; if ( ammoItemDefinition.shortname.Contains("incen") || ammoItemDefinition.shortname.Contains("fire") ) { iconColor = redIconColor; } else if (ammoItemDefinition.shortname.Contains("explo")) { iconColor = greyIconColor; } else if (ammoItemDefinition.shortname.Contains("hv")) { iconColor = blueIconColor; } else if (ammoItemDefinition.shortname.Contains("slug")) { iconColor = greenIconColor; } cont.Add( new CuiElement { Parent = Layer + "." + uisuffix, Name = "." + uisuffix + "icon", Components = { new CuiRawImageComponent { Color = iconColor, Png = GetImg("genericammo") }, new CuiRectTransformComponent { AnchorMin = position.IconPosition.AnchorMin, AnchorMax = position.IconPosition.AnchorMax, OffsetMin = position.IconPosition.OffsetMin, OffsetMax = position.IconPosition.OffsetMax } } } ); } CuiHelper.AddUi(player, cont); } #endregion #region Helpers private string GetColorFromHex(string hex, double alpha) { if (string.IsNullOrEmpty(hex)) hex = "#FFFFFF"; var str = hex.Trim('#'); if (str.Length != 6) throw new Exception(hex); var r = byte.Parse(str.Substring(0, 2), NumberStyles.HexNumber); var g = byte.Parse(str.Substring(2, 2), NumberStyles.HexNumber); var b = byte.Parse(str.Substring(4, 2), NumberStyles.HexNumber); return $"{(double)r / 255} {(double)g / 255} {(double)b / 255} {alpha / 100}"; } private string GetImg(string name) { return (string)ImageLibrary?.Call("GetImage", name) ?? ""; } public void Reply(BasePlayer player, string msg) { BroadcastToPlayer(player, msg); } static string fontColor1 = ""; static string fontColor2 = ""; private void BroadcastToAll(string msg) => PrintToChat(fontColor1 + "[AmmoHUD]" + " " + fontColor2 + msg + ""); private void BroadcastToPlayer(BasePlayer player, string msg) => SendReply( player, fontColor1 + "[AmmoHUD]" + " " + fontColor2 + msg + "" ); #endregion #region Lang Dictionary messages = new Dictionary() { {"commands", "{0}Ammo HUD Available Commands:\n" + "/ammohud toggle\t\tToggles on/off\n" + "/ammohud [position]\t\tRepositions on screen\n\n" + "{0}Available Positions:\nDefault, Top, Bottom, Right, Left,\n" + "BottomRight, BottomLeft, TopRight, TopLeft"}, {"toggle_enabled", "HUD enabled."}, {"toggle_disabled", "HUD disabled."}, {"positionsetto", "HUD position set to {0}."} }; #endregion #region PositionPresets public PositionPreset GetConfigPosition() { if (_config.PositionSettings.CustomPositionSettings.Enabled) { return _config.PositionSettings.CustomPositionSettings.CustomPosition; } else { return GetPreset(_config.PositionSettings.Position); } } public PositionPreset GetPreset(string position) { return PositionPresets.Find(s => s.Position.ToString().ToLower() == position.ToLower()); } public void LoadDefaultPresets() { PositionPresets = new List() { new PositionPreset() { Position = PositionEnum.Right, ParentPosition = new PositionParams() { Enabled = true, AnchorMin = "1 0.5", AnchorMax = "1 0.5", OffsetMin = "-155 -32", OffsetMax = "-15 33" }, WeaponAmmoFontSize = 36, WeaponAmmoTextAlignment = TextAnchor.LowerRight, WeaponAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0", AnchorMax = "0.79 0.70", OffsetMin = "0 0", OffsetMax = "0 0" }, TotalAmmoFontSize = 22, TotalAmmoTextAlignment = TextAnchor.LowerRight, TotalAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0.55", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0" }, IconPosition = new PositionParams() { Enabled = true, AnchorMin = "0.83 0.15", AnchorMax = "1 0.51", OffsetMin = "0 0", OffsetMax = "0 0" } }, new PositionPreset() { Position = PositionEnum.BottomRight, ParentPosition = new PositionParams() { Enabled = true, AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-355 25", OffsetMax = "-215 90" }, WeaponAmmoFontSize = 36, WeaponAmmoTextAlignment = TextAnchor.LowerRight, WeaponAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0", AnchorMax = "0.79 0.70", OffsetMin = "0 0", OffsetMax = "0 0" }, TotalAmmoFontSize = 22, TotalAmmoTextAlignment = TextAnchor.LowerRight, TotalAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0.55", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0" }, IconPosition = new PositionParams() { Enabled = true, AnchorMin = "0.83 0.15", AnchorMax = "1 0.51", OffsetMin = "0 0", OffsetMax = "0 0" } }, new PositionPreset() { Position = PositionEnum.Bottom, ParentPosition = new PositionParams() { Enabled = true, AnchorMin = "0.5 0", AnchorMax = "0.5 0", OffsetMin = "-120 80", OffsetMax = "20 145" }, WeaponAmmoFontSize = 36, WeaponAmmoTextAlignment = TextAnchor.LowerRight, WeaponAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0", AnchorMax = "0.79 0.70", OffsetMin = "0 0", OffsetMax = "0 0" }, TotalAmmoFontSize = 22, TotalAmmoTextAlignment = TextAnchor.LowerRight, TotalAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0.55", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0" }, IconPosition = new PositionParams() { Enabled = true, AnchorMin = "0.83 0.15", AnchorMax = "1 0.51", OffsetMin = "0 0", OffsetMax = "0 0" } }, new PositionPreset() { Position = PositionEnum.BottomLeft, ParentPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "15 60", OffsetMax = "155 125" }, WeaponAmmoFontSize = 36, WeaponAmmoTextAlignment = TextAnchor.LowerLeft, WeaponAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0.21 0", AnchorMax = "1 0.70", OffsetMin = "0 0", OffsetMax = "0 0" }, TotalAmmoFontSize = 22, TotalAmmoTextAlignment = TextAnchor.LowerLeft, TotalAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0.55", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0" }, IconPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0.15", AnchorMax = "0.17 0.51", OffsetMin = "0 0", OffsetMax = "0 0" } }, new PositionPreset() { Position = PositionEnum.Left, ParentPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0.5", AnchorMax = "0 0.5", OffsetMin = "15 -32", OffsetMax = "155 33" }, WeaponAmmoFontSize = 36, WeaponAmmoTextAlignment = TextAnchor.LowerLeft, WeaponAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0.21 0", AnchorMax = "1 0.70", OffsetMin = "0 0", OffsetMax = "0 0" }, TotalAmmoFontSize = 22, TotalAmmoTextAlignment = TextAnchor.LowerLeft, TotalAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0.55", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0" }, IconPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0.15", AnchorMax = "0.17 0.51", OffsetMin = "0 0", OffsetMax = "0 0" } }, new PositionPreset() { Position = PositionEnum.TopLeft, ParentPosition = new PositionParams() { Enabled = true, AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = "15 -95", OffsetMax = "155 -30" }, WeaponAmmoFontSize = 36, WeaponAmmoTextAlignment = TextAnchor.LowerLeft, WeaponAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0.21 0", AnchorMax = "1 0.70", OffsetMin = "0 0", OffsetMax = "0 0" }, TotalAmmoFontSize = 22, TotalAmmoTextAlignment = TextAnchor.LowerLeft, TotalAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0.55", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0" }, IconPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0.15", AnchorMax = "0.17 0.51", OffsetMin = "0 0", OffsetMax = "0 0" } }, new PositionPreset() { Position = PositionEnum.Top, ParentPosition = new PositionParams() { Enabled = true, AnchorMin = "0.5 1", AnchorMax = "0.5 1", OffsetMin = "-110 -95", OffsetMax = "30 -30" }, WeaponAmmoFontSize = 36, WeaponAmmoTextAlignment = TextAnchor.LowerRight, WeaponAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0", AnchorMax = "0.79 0.70", OffsetMin = "0 0", OffsetMax = "0 0" }, TotalAmmoFontSize = 22, TotalAmmoTextAlignment = TextAnchor.LowerRight, TotalAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0.55", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0" }, IconPosition = new PositionParams() { Enabled = true, AnchorMin = "0.83 0.15", AnchorMax = "1 0.51", OffsetMin = "0 0", OffsetMax = "0 0" } }, new PositionPreset() { Position = PositionEnum.TopRight, ParentPosition = new PositionParams() { Enabled = true, AnchorMin = "1 1", AnchorMax = "1 1", OffsetMin = "-155 -95", OffsetMax = "-15 -30" }, WeaponAmmoFontSize = 36, WeaponAmmoTextAlignment = TextAnchor.LowerRight, WeaponAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0", AnchorMax = "0.79 0.70", OffsetMin = "0 0", OffsetMax = "0 0" }, TotalAmmoFontSize = 22, TotalAmmoTextAlignment = TextAnchor.LowerRight, TotalAmmoPosition = new PositionParams() { Enabled = true, AnchorMin = "0 0.55", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0" }, IconPosition = new PositionParams() { Enabled = true, AnchorMin = "0.83 0.15", AnchorMax = "1 0.51", OffsetMin = "0 0", OffsetMax = "0 0" } } }; } public List PositionPresets; public class PositionPreset { [JsonIgnore] public PositionEnum Position { get; set; } public PositionParams ParentPosition { get; set; } public PositionParams WeaponAmmoPosition { get; set; } public int WeaponAmmoFontSize { get; set; } public TextAnchor WeaponAmmoTextAlignment { get; set; } public PositionParams TotalAmmoPosition { get; set; } public int TotalAmmoFontSize { get; set; } public TextAnchor TotalAmmoTextAlignment { get; set; } public PositionParams IconPosition { get; set; } } public class PositionParams { public bool Enabled { get; set; } public string AnchorMin { get; set; } public string AnchorMax { get; set; } public string OffsetMin { get; set; } public string OffsetMax { get; set; } } public enum PositionEnum { Top, TopLeft, TopRight, Left, Right, Bottom, BottomLeft, BottomRight } #endregion } }