// SpaceDorf added LabelLength private void DrawWeaponsPayloadRow(ref float y, float width, KeyValuePair <ShipWeaponSlot, WeaponSystemShipBomb> currentWeapon, float LabelLength) { Rect rectslotName = new Rect(10f, y, LabelLength, 30f); Widgets.Label(rectslotName, currentWeapon.Key.SlotName); Rect rectslotIcon = new Rect(rectslotName.xMax + 5f, y, 30f, 30f); if (currentWeapon.Value == null) { Widgets.DrawWindowBackground(rectslotIcon); } else { Widgets.DrawWindowBackground(rectslotIcon); Texture2D tex = currentWeapon.Value.def.uiIcon; GUI.DrawTexture(rectslotIcon, currentWeapon.Value.def.uiIcon); } if (Mouse.IsOver(rectslotIcon)) { GUI.color = ITab_ShipCargo.HighlightColor; GUI.DrawTexture(rectslotIcon, TexUI.HighlightTex); } GUI.color = Color.white; if (Widgets.ButtonInvisible(rectslotIcon)) { List <FloatMenuOption> opts = new List <FloatMenuOption>(); if (currentWeapon.Value == null) { List <Thing> list = DropShipUtility.availableWeaponsForSlot(this.ship.Map, currentWeapon.Key); list.OrderBy(x => x.Position.DistanceToSquared(this.ship.Position)); for (int i = 0; i < list.Count; i++) { Thing weapon = list[i]; Action action = new Action(delegate { ship.TryModifyWeaponSystem(currentWeapon.Key, weapon, true); }); FloatMenuOption newOption = new FloatMenuOption("Install".Translate() + weapon.Label, action); opts.Add(newOption); } } else { Action action = new Action(delegate { ship.TryModifyWeaponSystem(currentWeapon.Key, currentWeapon.Value, false); }); FloatMenuOption newOption = new FloatMenuOption("Uninstall".Translate() + currentWeapon.Value.Label, action); opts.Add(newOption); } if (opts.Count < 1) { opts.Add(new FloatMenuOption("None", null)); } Find.WindowStack.Add(new FloatMenu(opts)); } Rect rect3 = new Rect(rectslotIcon.xMax + 10f, y, width - rectslotName.width - rectslotIcon.width - 10f, 30f); if (currentWeapon.Value == null) { Widgets.Label(rect3, "NoneInstalled".Translate()); } else if (ship.weaponsToInstall.Any(x => x.Key == currentWeapon.Key)) { Widgets.Label(rect3, "InstallingShipWeapon".Translate(new object[] { currentWeapon.Value.LabelCap })); } else { Widgets.Label(rect3, currentWeapon.Value.def.LabelCap); } y += 35f; }
private void DrawWeaponsTurretRow(ref float y, float width, KeyValuePair <ShipWeaponSlot, Building_ShipTurret> currentWeapon) { Rect rectslotName = new Rect(10f, y, 100f, 30f); Widgets.Label(rectslotName, currentWeapon.Key.SlotName); Rect rectslotIcon = new Rect(rectslotName.xMax + 5f, y, 30f, 30f); if (currentWeapon.Value == null) { Widgets.DrawWindowBackground(rectslotIcon); } else { Texture2D tex = ContentFinder <Texture2D> .Get(currentWeapon.Value.def.building.turretTopGraphicPath); GUI.DrawTexture(rectslotIcon, tex); Widgets.DrawWindowBackground(rectslotIcon); } if (Mouse.IsOver(rectslotIcon)) { GUI.color = ITab_ShipCargo.HighlightColor; GUI.DrawTexture(rectslotIcon, TexUI.HighlightTex); } GUI.color = Color.white; if (Widgets.ButtonInvisible(rectslotIcon)) { List <FloatMenuOption> opts = new List <FloatMenuOption>(); if (currentWeapon.Value == null) { List <Thing> list = DropShipUtility.availableWeaponsForSlot(this.ship.Map, currentWeapon.Key); // Log.Message("List of potentials " + list.Count.ToString()); list.OrderBy(x => x.Position.DistanceToSquared(this.ship.Position)); for (int i = 0; i < list.Count; i++) { Thing weapon = list[i]; Action action = new Action(delegate { ship.TryModifyWeaponSystem(currentWeapon.Key, weapon, true); }); FloatMenuOption newOption = new FloatMenuOption("Install".Translate() + weapon.Label, action); opts.Add(newOption); } } else { Action action = new Action(delegate { ship.TryModifyWeaponSystem(currentWeapon.Key, currentWeapon.Value, false); }); FloatMenuOption newOption = new FloatMenuOption("Uninstall".Translate() + currentWeapon.Value.Label, action); opts.Add(newOption); } if (opts.Count < 1) { opts.Add(new FloatMenuOption("None", null)); } Find.WindowStack.Add(new FloatMenu(opts)); } Rect rect3 = new Rect(rectslotIcon.xMax + 10f, y, width - rectslotName.width - rectslotIcon.width - 10f, 30f); if (currentWeapon.Value == null && !ship.weaponsToInstall.Any(x => x.Key == currentWeapon.Key)) { Widgets.Label(rect3, "NoneInstalled".Translate()); } else { ShipWeaponSlot installingSlot = ship.weaponsToInstall.FirstOrDefault(x => x.Key == currentWeapon.Key).Key; if (installingSlot != null) { Widgets.Label(rect3, "InstallingShipWeapon".Translate(new object[] { ship.weaponsToInstall[installingSlot].LabelCap })); } else { Widgets.Label(rect3, currentWeapon.Value.def.LabelCap); } } y += 35f; }