public static void OnPlayerClicked(Players.Player player, PlayerClickedData boxedData) { if (boxedData.ClickType == PlayerClickedData.EClickType.Right) { if (boxedData.HitType == PlayerClickedData.EHitType.Block) { string itemname = ItemTypes.IndexLookup.GetName(boxedData.GetVoxelHit().TypeHit); if (itemname.Contains("Geo Dasher")) { NetworkUI.NetworkMenu menu = new NetworkUI.NetworkMenu(); menu.LocalStorage.SetAs("header", "Geo Dasher"); menu.Width = 600; menu.Height = 400; List <ValueTuple <NetworkUI.IItem, int> > items = new List <ValueTuple <IItem, int> > { ValueTuple.Create <NetworkUI.IItem, int>(new NetworkUI.Items.InputField("teleporterID"), 200), (new NetworkUI.Items.ButtonCallback("PG.RotNC.Teleporter.SetKey", new NetworkUI.LabelData("Set Teleporter Key", UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), 200), (new NetworkUI.Items.DropDown("Availability", "PG.RotNC.Teleporter.Availability", new List <string>() { "public", "private", "spawn" }), 200) }; menu.Items.Add(new NetworkUI.Items.HorizontalRow(items)); menu.LocalStorage.SetAs("PG.RotNC.Teleporter.SetKey", 0); menu.LocalStorage.SetAs("PG.RotNC.Teleporter.Availability", 0); menu.Items.Add(new NetworkUI.Items.Line(UnityEngine.Color.black)); items = new List <ValueTuple <IItem, int> > { ValueTuple.Create <NetworkUI.IItem, int>(new NetworkUI.Items.InputField("gototeleporter"), 200), (new NetworkUI.Items.ButtonCallback("PG.RotNC.Teleporter.GoToKey", new NetworkUI.LabelData("Go To Key", UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), 200) }; menu.Items.Add(new NetworkUI.Items.HorizontalRow(items)); menu.LocalStorage.SetAs("PG.RotNC.Teleporter.GoToKey", 0); menu.Items.Add(new NetworkUI.Items.Line(UnityEngine.Color.black)); foreach (var colony in player.Colonies) { if (TeleporterManager.GetKey(colony.ColonyID, out string output)) { items = new List <ValueTuple <IItem, int> > { ValueTuple.Create <NetworkUI.IItem, int>(new NetworkUI.Items.Label(colony.Name), 200), ValueTuple.Create <NetworkUI.IItem, int>(new NetworkUI.Items.Label(output), 200) }; menu.Items.Add(new NetworkUI.Items.HorizontalRow(items)); } } if (itemname.Contains("x-")) { Vector3Int pos = boxedData.GetVoxelHit().BlockHit.Add(-1, 0, 0); menu.LocalStorage.SetAs("location", NewColonyAPI.Helpers.Utilities.Vector3IntToNode(pos)); } if (itemname.Contains("x+")) { Vector3Int pos = boxedData.GetVoxelHit().BlockHit.Add(1, 0, 0); menu.LocalStorage.SetAs("location", NewColonyAPI.Helpers.Utilities.Vector3IntToNode(pos)); } if (itemname.Contains("z-")) { Vector3Int pos = boxedData.GetVoxelHit().BlockHit.Add(0, 0, -1); menu.LocalStorage.SetAs("location", NewColonyAPI.Helpers.Utilities.Vector3IntToNode(pos)); } if (itemname.Contains("z+")) { Vector3Int pos = boxedData.GetVoxelHit().BlockHit.Add(0, 0, 1); menu.LocalStorage.SetAs("location", NewColonyAPI.Helpers.Utilities.Vector3IntToNode(pos)); } NetworkUI.NetworkMenuManager.SendServerPopup(player, menu); return; } }
public static NetworkUI.NetworkMenu BaseMenu() { NetworkUI.NetworkMenu ret = new NetworkUI.NetworkMenu(); ret.Width = 1000; ret.Height = 500; int total = menus.Count; int counter = 0; int menubuttonwidth = 0; if (total >= 5) { menubuttonwidth = 193; } else if (total == 4) { menubuttonwidth = 243; } else if (total == 3) { menubuttonwidth = 326; } else if (total == 2) { menubuttonwidth = 493; } else { menubuttonwidth = 990; } List <(NetworkUI.IItem, int)> topbuttons = new List <(NetworkUI.IItem, int)>(); foreach (var item in menus) { topbuttons.Add((new NetworkUI.Items.ButtonCallback(item.Value, new NetworkUI.LabelData(item.Key, UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), menubuttonwidth)); ret.LocalStorage.SetAs(item.Value, 0); total--; counter++; if (counter == 5) { counter = 0; ret.Items.Add(new NetworkUI.Items.HorizontalRow(topbuttons)); topbuttons = new List <(NetworkUI.IItem, int)>(); if (total >= 5) { menubuttonwidth = 193; } else if (total == 4) { menubuttonwidth = 243; } else if (total == 3) { menubuttonwidth = 326; } else if (total == 2) { menubuttonwidth = 493; } else { menubuttonwidth = 990; } } } ret.Items.Add(new NetworkUI.Items.HorizontalRow(topbuttons)); ret.Items.Add(new NetworkUI.Items.Line(UnityEngine.Color.black)); return(ret); }