//Sends the interface of the category PreferredCategories[<category>] public static void SendSetWarningsUI(Players.Player player, int category = 0) { NetworkMenu menu = new NetworkMenu(); menu.Identifier = "WarningUI"; menu.Width = 400; menu.Height = 600; Label label = new Label("Category: "); DropDownNoLabel dropDown = new DropDownNoLabel("Khanx.Warning.categoryDropDown", PreferredCategories); //Default dropdown (ALWAYS INCLUDE OR GIVES ERROR) menu.LocalStorage.SetAs("Khanx.Warning.categoryDropDown", category); //Kenovis: NEEDS JTOKEN //JToken jToken = JToken.Parse("Khanx.Warning.ChangeCategory"); ButtonCallback buttonCallback = new ButtonCallback("Khanx.Warning.ChangeCategory", new LabelData("Change category", UnityEngine.Color.black)); List <(IItem, int)> horizontalRowItems = new List <(IItem, int)>(); horizontalRowItems.Add((label, 75)); horizontalRowItems.Add((dropDown, 125)); horizontalRowItems.Add((buttonCallback, 125)); HorizontalRow horizontalRow = new HorizontalRow(horizontalRowItems); menu.Items.Add(horizontalRow); menu.Items.Add(new EmptySpace(25)); //Show icon & amount per category IEnumerable <ItemTypes.ItemType> itemsInCategory = ItemTypes.NotableTypes.Where(type => type.HasCategory(PreferredCategories[category])); Dictionary <ushort, int> warning = warnings.GetValueOrDefault(player.ID, new Dictionary <ushort, int>()); foreach (ItemTypes.ItemType item in itemsInCategory) { ItemIcon icon = new ItemIcon(item.Name); InputField inputField = new InputField("Khanx.Warning." + item.Name + "Field", 50); //default value menu.LocalStorage.SetAs("Khanx.Warning." + item.Name + "Field", warning.GetValueOrDefault(item.ItemIndex, 0)); menu.Items.Add(new HorizontalSplit(icon, inputField)); } NetworkMenuManager.SendServerPopup(player, menu); }
/// <summary> /// Shows the UI /// </summary> /// <param name="player"></param> public static void CompassUI(Players.Player player) { NetworkMenu menu = new NetworkMenu(); menu.Identifier = "Compass"; menu.LocalStorage.SetAs("header", "Compass"); menu.Width = 450; menu.Height = 400; ButtonCallback CardinalButtonCallback = new ButtonCallback("Khanx.Compass.CardinalDirection", new LabelData("Cardinal direction", UnityEngine.Color.white), 200, 30, ButtonCallback.EOnClickActions.ClosePopup); List <string> colonies = new List <string>(); if (player.Colonies.Length > 0) { foreach (var col in player.Colonies) { colonies.Add(col.Name); } } else { colonies.Add("-"); } Label ColonyLabel = new Label(new LabelData("Colony:", UnityEngine.Color.white)); DropDownNoLabel ColonyDropDown = new DropDownNoLabel("Khanx.Compass.Colony", colonies); ColonyDropDown.Width = 300; //Default dropdown (ALWAYS INCLUDE OR GIVES ERROR) menu.LocalStorage.SetAs("Khanx.Compass.Colony", 0); HorizontalRow ColonySelector = new HorizontalRow(new List <(IItem, int)> { (ColonyLabel, 75), (ColonyDropDown, 325) }); ButtonCallback ColonyButtonCallback = new ButtonCallback("Khanx.Compass.ColonyDirection", new LabelData("Find colony", (player.Colonies.Length > 0) ? UnityEngine.Color.white : UnityEngine.Color.black), 200, 30, (player.Colonies.Length > 0) ? ButtonCallback.EOnClickActions.ClosePopup : ButtonCallback.EOnClickActions.None); CompassWaypoints compassWaypoints = CompassManager.Waypoints.GetValueOrDefault(player.ID, null); ButtonCallback PlayerDeathButtonCallback = new ButtonCallback("Khanx.Compass.PlayerDeath", new LabelData("Player Death", UnityEngine.Color.white), 200, 30, ButtonCallback.EOnClickActions.ClosePopup); if (compassWaypoints == null || compassWaypoints.playerDeath == Vector3Int.invalidPos) { PlayerDeathButtonCallback.Enabled = false; } ButtonCallback ColonistDeathButtonCallback = new ButtonCallback("Khanx.Compass.ColonistDeath", new LabelData("Colonist Death", UnityEngine.Color.white), 200, 30, ButtonCallback.EOnClickActions.ClosePopup);; if (compassWaypoints == null || compassWaypoints.colonistDeath == Vector3Int.invalidPos) { ColonistDeathButtonCallback.Enabled = false; } List <string> waypoints = new List <string>(); if (compassWaypoints != null && compassWaypoints.waypoints != null && compassWaypoints.waypoints.Count != 0) { foreach (var w in compassWaypoints.waypoints) { waypoints.Add(w.name); } } else { waypoints.Add("-"); } Label WaypointLabel = new Label(new LabelData("Waypoint:", UnityEngine.Color.white)); DropDownNoLabel WaypointDropDown = new DropDownNoLabel("Khanx.Compass.Waypoint", waypoints); WaypointDropDown.Width = 300; //Default dropdown (ALWAYS INCLUDE OR GIVES ERROR) menu.LocalStorage.SetAs("Khanx.Compass.Waypoint", 0); HorizontalRow WaypointSelector = new HorizontalRow(new List <(IItem, int)> { (WaypointLabel, 75), (WaypointDropDown, 325) }); ButtonCallback WaypointButtonCallback = new ButtonCallback("Khanx.Compass.WaypointDirection", new LabelData("Find waypoint", (compassWaypoints != null && compassWaypoints.waypoints != null && compassWaypoints.waypoints.Count != 0) ? UnityEngine.Color.white : UnityEngine.Color.black), 200, 30, (compassWaypoints != null && compassWaypoints.waypoints != null && compassWaypoints.waypoints.Count != 0) ? ButtonCallback.EOnClickActions.ClosePopup : ButtonCallback.EOnClickActions.None); ButtonCallback WayPointAdd = new ButtonCallback("Khanx.Compass.WaypointUIAdd", new LabelData("Add waypoint", UnityEngine.Color.white), 200, 30, ButtonCallback.EOnClickActions.ClosePopup); ButtonCallback WayPointRemove = new ButtonCallback("Khanx.Compass.WaypointRemove", new LabelData("Remove waypoint", (compassWaypoints != null && compassWaypoints.waypoints != null && compassWaypoints.waypoints.Count != 0) ? UnityEngine.Color.white : UnityEngine.Color.black), 200, 30, (compassWaypoints != null && compassWaypoints.waypoints != null && compassWaypoints.waypoints.Count != 0) ? ButtonCallback.EOnClickActions.ClosePopup : ButtonCallback.EOnClickActions.None); HorizontalRow WaypointManage = new HorizontalRow(new List <(IItem, int)> { (WayPointAdd, 200), (WayPointRemove, 200) }); menu.Items.Add(new HorizontalRow(new List <(IItem, int)> { (new EmptySpace(), 100), (CardinalButtonCallback, 200) })); menu.Items.Add(new HorizontalRow(new List <(IItem, int)> { (new EmptySpace(), 100), (PlayerDeathButtonCallback, 200) })); menu.Items.Add(new HorizontalRow(new List <(IItem, int)> { (new EmptySpace(), 100), (ColonistDeathButtonCallback, 200) })); menu.Items.Add(new EmptySpace(10)); menu.Items.Add(new Line(UnityEngine.Color.white, 1, 410, 0, 0)); menu.Items.Add(new EmptySpace(10)); menu.Items.Add(ColonySelector); menu.Items.Add(new HorizontalRow(new List <(IItem, int)> { (new EmptySpace(), 100), (ColonyButtonCallback, 200) })); menu.Items.Add(new EmptySpace(10)); menu.Items.Add(new Line(UnityEngine.Color.white, 1, 410, 0, 0)); menu.Items.Add(new EmptySpace(10)); menu.Items.Add(WaypointSelector); menu.Items.Add(new HorizontalRow(new List <(IItem, int)> { (new EmptySpace(), 100), (WaypointButtonCallback, 200) })); menu.Items.Add(WaypointManage); NetworkMenuManager.SendServerPopup(player, menu); }