public override void SpawnWindow(SegmentEntity targetEntity) { FreightCartStation station = targetEntity as FreightCartStation; //Catch for when the window is called on an inappropriate machine if (station == null) { //GenericMachinePanelScript.instance.Hide(); UIManager.RemoveUIRules("Machine"); return; } if (!SetFreightItems && !ItemSearchWindow && !SetNetworkID && !SetName && !SetInventoryName && !string.IsNullOrEmpty(station.NetworkID)) { this.manager.SetTitle("Freight Cart Station"); this.manager.AddButton("stationname", "Set Name", 15, 0); this.manager.AddBigLabel("namelabel", string.IsNullOrEmpty(station.StationName) ? "UNNAMED" : station.StationName, Color.white, 165, 0); this.manager.AddButton("namenetwork", "Change Network", 15, 55); this.manager.AddBigLabel("networkid", station.NetworkID, Color.white, 165, 55); this.manager.AddButton("namestorage", "Name Storage", 15, 110); this.manager.AddBigLabel("storagename", station.ConnectedInventory != null ? station.ConnectedInventory.Name : "Connect Mass Storage", Color.white, 165, 110); this.manager.AddButton("setfreight", "Set Freight Goods", 100, 165); this.manager.AddBigLabel("assignedcarts", "Assigned Carts: " + station.AssignedCarts.ToString(), Color.white, 15, 215); this.manager.AddButton("decreasecarts", "Remove Cart", 25, 260); this.manager.AddButton("increasecarts", "Add Cart", 175, 260); this.manager.AddButton("toggleload", "Toggle Load", 25, 315); this.manager.AddButton("toggleoffer", "Toggle Offers", 25, 370); this.manager.AddButton("togglecarttier", "Toggle Tier", 100, 425); this.manager.AddBigLabel("loadstatus", "Wait for " + (station.mbWaitForFullLoad ? "Full" : "Any"), Color.white, 165, 315); this.manager.AddBigLabel("offerlabel", (station.OfferAll ? "Offer All" : "Use Offer List"), Color.white, 165, 370); this.manager.AddBigLabel("carttier", "Cart Tier: " + station.CartTierLabel(), Color.white, 25, 480); } else if (SetFreightItems && !ItemSearchWindow && !SetNetworkID && !SetName && !SetInventoryName && !string.IsNullOrEmpty(station.NetworkID)) { this.manager.SetTitle("Freight Cart Station - Register Freight"); this.manager.AddButton("freightdone", "Done", 100, 0); int count = 0; if (station.massStorageCrate != null) { count = FreightCartManager.instance.GetFreightEntries(station.NetworkID, station.massStorageCrate).Count; this.manager.AddTabButton("switchlowstock", "Edit Requests", !this.ChooseLowStock, 25, 50); this.manager.AddTabButton("switchhighstock", "Edit Offers", this.ChooseLowStock, 175, 50); int spacing = 175; int offset = 50 + 50; for (int n = 0; n < count + 1; n++) { int suffix = n; if (n == count) { suffix = -1; } this.manager.AddIcon("registry" + suffix, "empty", Color.white, 0, offset + (spacing * n)); this.manager.AddBigLabel("registrytitle" + suffix, "Add New Freight", Color.white, 60, offset + (spacing * n)); if (suffix != -1) { this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "lowstocktitle" + n, "Request if below", this.ChooseLowStock == true ? Color.white : Color.gray, false, 0, offset + (spacing * n + 40)); this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "highstocktitle" + n, "Offer if above", this.ChooseLowStock == false ? Color.white : Color.gray, false, 150, offset + (spacing * n + 40)); this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "lowstock" + n, "Request if below", this.ChooseLowStock == true ? Color.white : Color.gray, false, 0, offset + (spacing * n + 60)); this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "highstock" + n, "Offer if above", this.ChooseLowStock == false ? Color.white : Color.gray, false, 150, offset + (spacing * n + 60)); this.manager.AddButton("decreasestock" + n, "Decrease Stock", 25, offset + (spacing * n + 100)); this.manager.AddButton("increasestock" + n, "Increase Stock", 175, offset + (spacing * n + 100)); } } } else if (station.AttachedInterface != null) { this.manager.AddBigLabel("interfacetext", "Servicing freight for:", Color.white, 0, 225); this.manager.AddBigLabel("interfacename", station.AttachedInterface.ToString(), Color.cyan, 0, 275); } else if (station.HopperInterface != null) { this.manager.AddIcon("hopitemoffer", "empty", Color.white, 0, 50); this.manager.AddBigLabel("registrytitle0", "Item to Offer", Color.white, 60, 50); this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "highstock", "Offer if above", Color.white, false, 150, 90); this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "highstocktitle", "Offer if above", Color.white, false, 50, 90); this.manager.AddButton("hopofferdown", "Decrease Stock", 25, 150); this.manager.AddButton("hopofferup", "Increase Stock", 175, 150); this.manager.AddIcon("hopitemrequest", "empty", Color.white, 0, 225); this.manager.AddBigLabel("registrytitle1", "Request Item", Color.white, 60, 225); this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "lowstock", "Request if below", Color.white, false, 150, 265); this.manager.AddLabel(GenericMachineManager.LabelType.OneLineHalfWidth, "lowstocktitle", "Request if below", Color.white, false, 50, 265); this.manager.AddButton("hoprequestdown", "Decrease Stock", 25, 325); this.manager.AddButton("hoprequestup", "Increase Stock", 175, 325); } } else if (ItemSearchWindow) { this.manager.SetTitle("Freight Cart Station - Item Search"); this.manager.AddButton("searchcancel", "Cancel", 100, 0); this.manager.AddBigLabel("searchtitle", "Enter Item Search Term", Color.white, 50, 40); this.manager.AddBigLabel("searchtext", "_", Color.cyan, 50, 65); if (this.SearchResults != null) { int count = this.SearchResults.Count; int spacing = 60; //Spacing between each registry line int yoffset = 100; //Offset below button row int labeloffset = 60; //x offset for label from icon for (int n = 0; n < count; n++) { this.manager.AddIcon("itemicon" + n, "empty", Color.white, 0, yoffset + (spacing * n)); this.manager.AddBigLabel("iteminfo" + n, "Inventory Item", Color.white, labeloffset, yoffset + (spacing * n)); } } } else if (SetNetworkID || string.IsNullOrEmpty(station.NetworkID) || SetName || SetInventoryName) { if (SetName) { this.manager.SetTitle("Freight Cart Station - Set Name"); this.manager.AddBigLabel("networktitle", "Enter Station Name", Color.white, 50, 40); } else if (SetInventoryName) { this.manager.SetTitle("Set Mass Storage Name"); this.manager.AddBigLabel("networktitle", "Enter Storage Name", Color.white, 50, 40); } else { this.manager.SetTitle("Freight Cart Station - Set Network"); this.manager.AddBigLabel("networktitle", "Enter Network ID", Color.white, 50, 40); } UIManager.mbEditingTextField = true; UIManager.AddUIRules("TextEntry", UIRules.RestrictMovement | UIRules.RestrictLooking | UIRules.RestrictBuilding | UIRules.RestrictInteracting | UIRules.SetUIUpdateRate); GenericMachinePanelScript.instance.Scroll_Bar.GetComponent <UIScrollBar>().scrollValue = 0.0f; this.manager.AddButton("networkidcancel", "Cancel", 100, 0); this.manager.AddBigLabel("networkentry", "_", Color.cyan, 50, 65); } dirty = true; networkredraw = false; }
public override void UpdateMachine(SegmentEntity targetEntity) { FreightCartStation station = targetEntity as FreightCartStation; //Catch for when the window is called on an inappropriate machine if (station == null) { GenericMachinePanelScript.instance.Hide(); UIManager.RemoveUIRules("Machine"); return; } GenericMachinePanelScript.instance.Scroll_Bar.GetComponent <UIScrollBar>().scrollValue -= Input.GetAxis("Mouse ScrollWheel"); if (networkredraw) { this.manager.RedrawWindow(); } if (!dirty) { return; } if (!SetFreightItems && !ItemSearchWindow && !SetNetworkID && !SetName && !SetInventoryName && !string.IsNullOrEmpty(station.NetworkID)) { this.manager.UpdateLabel("assignedcarts", "Assigned Carts: " + station.AssignedCarts.ToString(), Color.white); this.manager.UpdateLabel("loadstatus", "Wait for " + (station.mbWaitForFullLoad ? "Full" : "Any"), Color.white); this.manager.UpdateLabel("offerlabel", (station.OfferAll ? "Offer All" : "Use Offer List"), Color.white); this.manager.UpdateLabel("carttier", "Cart Tier: " + station.CartTierLabel(), Color.white); } else if (SetFreightItems && !ItemSearchWindow && !SetNetworkID && !SetName && !SetInventoryName && station.NetworkID != null) { if (station.massStorageCrate != null) { List <FreightRegistry> registries = new List <FreightRegistry>(); registries = FreightCartManager.instance.GetFreightEntries(station.NetworkID, station.massStorageCrate); for (int index = 0; index < registries.Count; index++) { ItemBase item = registries[index].FreightItem; int lowstock = registries[index].LowStock; int highstock = registries[index].HighStock; string itemname = ItemManager.GetItemName(item); string iconname = ItemManager.GetItemIcon(item); this.manager.UpdateIcon("registry" + index, iconname, Color.white); this.manager.UpdateLabel("registrytitle" + index, itemname, Color.white); this.manager.UpdateLabel("lowstock" + index, registries[index].LowStock.ToString(), this.ChooseLowStock == true ? Color.white : Color.gray); this.manager.UpdateLabel("highstock" + index, registries[index].HighStock.ToString(), this.ChooseLowStock == false ? Color.white : Color.gray); this.manager.UpdateLabel("lowstocktitle" + index, "Request if below", this.ChooseLowStock == true ? Color.white : Color.gray); this.manager.UpdateLabel("highstocktitle" + index, "Offer if above", this.ChooseLowStock == false ? Color.white : Color.gray); } } else if (station.HopperInterface != null) { ItemBase item = station.HopperInterface.OfferItem; string itemname; string iconname; if (item != null) { itemname = ItemManager.GetItemName(item); iconname = ItemManager.GetItemIcon(item); this.manager.UpdateIcon("hopitemoffer", iconname, Color.white); this.manager.UpdateLabel("registrytitle0", itemname, Color.white); } this.manager.UpdateLabel("highstock", station.HopperInterface.OfferLimit.ToString(), Color.white); item = station.HopperInterface.RequestItem; if (item != null) { itemname = ItemManager.GetItemName(item); iconname = ItemManager.GetItemIcon(item); this.manager.UpdateIcon("hopitemrequest", iconname, Color.white); this.manager.UpdateLabel("registrytitle1", itemname, Color.white); } this.manager.UpdateLabel("lowstock", station.HopperInterface.RequestLimit.ToString(), Color.white); } else { this.manager.UpdateLabel("registrytitle-1", "Connect to Freight provider", Color.red); return; } } else if (ItemSearchWindow) { if (this.SearchResults == null) { this.Counter++; foreach (char c in Input.inputString) { if (c == "\b"[0]) //Backspace { if (this.EntryString.Length != 0) { this.EntryString = this.EntryString.Substring(0, this.EntryString.Length - 1); } } else if (c == "\n"[0] || c == "\r"[0]) //Enter or Return { this.SearchResults = new List <ItemBase>(); for (int n = 0; n < ItemEntry.mEntries.Length; n++) { if (ItemEntry.mEntries[n] == null) { continue; } if (ItemEntry.mEntries[n].Name.ToLower().Contains(this.EntryString.ToLower())) { this.SearchResults.Add(ItemManager.SpawnItem(ItemEntry.mEntries[n].ItemID)); } } for (int n = 0; n < TerrainData.mEntries.Length; n++) { bool foundvalue = false; TerrainDataEntry entry = TerrainData.mEntries[n]; if (entry == null) { continue; } if (entry.Name.ToLower().Contains(this.EntryString.ToLower())) { int count = entry.Values.Count; for (int m = 0; m < count; m++) { if (entry.Values[m].Name.ToLower().Contains(this.EntryString.ToLower())) { if (string.IsNullOrEmpty(entry.PickReplacement)) { this.SearchResults.Add(ItemManager.SpawnCubeStack(entry.CubeType, entry.Values[m].Value, 1)); foundvalue = true; } } } if (!foundvalue && string.IsNullOrEmpty(entry.PickReplacement)) { this.SearchResults.Add(ItemManager.SpawnCubeStack(entry.CubeType, entry.DefaultValue, 1)); } } if ((this.EntryString.ToLower().Contains("component") || this.EntryString.ToLower().Contains("placement") || this.EntryString.ToLower().Contains("multi")) && entry.CubeType == 600) { int count = entry.Values.Count; for (int m = 0; m < count; m++) { this.SearchResults.Add(ItemManager.SpawnCubeStack(600, entry.Values[m].Value, 1)); } } } if (this.SearchResults.Count == 0) { this.SearchResults = null; } UIManager.mbEditingTextField = false; UIManager.RemoveUIRules("TextEntry"); this.manager.RedrawWindow(); return; } else { this.EntryString += c; } } this.manager.UpdateLabel("searchtext", this.EntryString + (this.Counter % 20 > 10 ? "_" : ""), Color.cyan); dirty = true; return; } else { this.manager.UpdateLabel("searchtitle", "Searching for:", Color.white); this.manager.UpdateLabel("searchtext", this.EntryString, Color.cyan); int count = this.SearchResults.Count; for (int n = 0; n < count; n++) { ItemBase item = this.SearchResults[n]; string itemname = ItemManager.GetItemName(item); string iconname = ItemManager.GetItemIcon(item); this.manager.UpdateIcon("itemicon" + n, iconname, Color.white); this.manager.UpdateLabel("iteminfo" + n, itemname, Color.white); } } } else if (SetNetworkID || string.IsNullOrEmpty(station.NetworkID) || SetName || SetInventoryName) { this.Counter++; foreach (char c in Input.inputString) { if (c == "\b"[0]) //Backspace { if (this.EntryString.Length != 0) { this.EntryString = this.EntryString.Substring(0, this.EntryString.Length - 1); } } else if (c == "\n"[0] || c == "\r"[0]) //Enter or Return { if (SetName) { FreightCartWindow.SetStationName(station, this.EntryString); this.SetName = false; } else if (SetInventoryName) { FreightCartWindow.NameInventory(station, this.EntryString); this.SetInventoryName = false; } else { FreightCartWindow.SetNetwork(station, this.EntryString); this.SetNetworkID = false; } this.EntryString = ""; UIManager.mbEditingTextField = false; UIManager.RemoveUIRules("TextEntry"); return; } else { this.EntryString += c; } } this.manager.UpdateLabel("networkentry", this.EntryString + (this.Counter % 20 > 10 ? "_" : ""), Color.cyan); dirty = true; return; } dirty = false; }