protected void DrawSelectedEquipmentList() { if (destSelection >= PrepareCarefully.Instance.Equipment.Count) { destSelection = PrepareCarefully.Instance.Equipment.Count - 1; } GUI.color = ColorBoxBackground; GUI.DrawTexture(RectDestBox, BaseContent.WhiteTex); GUI.color = ColorBoxOutline; Widgets.DrawBox(RectDestBox, 1); try { GUI.color = Color.white; GUI.BeginGroup(RectDestContent); Rect scrollRect = new Rect(0, 0, RectDestContent.width, RectDestContent.height); Rect viewRect = new Rect(scrollRect.x, scrollRect.y, scrollRect.width - 16, destScrollViewHeight); Widgets.BeginScrollView(scrollRect, ref destScrollPosition, viewRect); Rect rectEntry = RectDestEntry; Rect rectText = RectDestEntry; rectText.x += 65; rectText.width = 320; Rect rectCost = RectDestEntry; rectCost.x += 352; rectCost.y += 7; rectCost.height -= 14; rectCost.width = 60; Rect rectItem = RectDestItem; Rect rectEntryButton = RectDestEntry; rectEntryButton.width = 320; bool alternateBackground = false; float top = destScrollPosition.y - rectEntry.height; float bottom = destScrollPosition.y + RectDestBox.height; int index = -1; foreach (SelectedEquipment customPawn in PrepareCarefully.Instance.Equipment) { index++; ThingDef def = customPawn.def; EquipmentDatabaseEntry entry = PrepareCarefully.Instance.EquipmentEntries[customPawn.EquipmentKey]; if (entry == null) { string thing = def != null ? def.defName : "null"; string stuff = customPawn.stuffDef != null ? customPawn.stuffDef.defName : "null"; Log.Warning(string.Format("Could not draw unrecognized resource/equipment. Invalid item was removed. This may have been caused by an invalid thing/stuff combination. (thing = {0}, stuff={1})", thing, stuff)); PrepareCarefully.Instance.RemoveEquipment(customPawn); continue; } SelectedEquipment loadoutRecord = PrepareCarefully.Instance.Find(entry); if (alternateBackground) { GUI.color = ColorEntryBackground; alternateBackground = false; } else { GUI.color = ColorBoxBackground; alternateBackground = true; } if (destSelection == index) { GUI.color = ColorSelectedEntry; } GUI.DrawTexture(rectEntry, BaseContent.WhiteTex); GUI.color = ColorText; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rectText, entry.LabelNoCount); DrawEquipmentIcon(rectItem, entry); Rect fieldRect = rectCost; Widgets.DrawAtlas(fieldRect, Textures.TextureFieldAtlas); equipmentDragSlider.OnGUI(fieldRect, loadoutRecord.count, (int value) => { var record = loadoutRecord; record.count = value; }); bool dragging = DragSlider.IsDragging(); Rect buttonRect = new Rect(fieldRect.x - 17, fieldRect.y + 6, 16, 16); if (!dragging && buttonRect.Contains(Event.current.mousePosition)) { GUI.color = ButtonHighlightColor; } else { GUI.color = ButtonColor; } GUI.DrawTexture(buttonRect, Textures.TextureButtonPrevious); if (Widgets.ButtonInvisible(buttonRect, false)) { SoundDefOf.TickHigh.PlayOneShotOnCamera(); int amount = Event.current.shift ? 10 : 1; loadoutRecord.count -= amount; if (loadoutRecord.count < 0) { loadoutRecord.count = 0; } } buttonRect = new Rect(fieldRect.x + fieldRect.width + 1, fieldRect.y + 6, 16, 16); if (!dragging && buttonRect.Contains(Event.current.mousePosition)) { GUI.color = ButtonHighlightColor; } else { GUI.color = ButtonColor; } GUI.DrawTexture(buttonRect, Textures.TextureButtonNext); if (Widgets.ButtonInvisible(buttonRect, false)) { SoundDefOf.TickHigh.PlayOneShotOnCamera(); int amount = Event.current.shift ? 10 : 1; loadoutRecord.count += amount; } if (rectEntry.y > top && rectEntry.y < bottom) { if (Event.current.type == EventType.MouseDown && rectEntryButton.Contains(Event.current.mousePosition)) { if (Event.current.clickCount == 1) { if (Event.current.button == 1) { if (destSelection != index) { destSelection = index; } List <FloatMenuOption> list = new List <FloatMenuOption>(); ThingDef thingDef = customPawn.def; ThingDef stuffDef = customPawn.stuffDef; list.Add(new FloatMenuOption("ThingInfo".Translate(), delegate { Find.WindowStack.Add(new Dialog_InfoCard(thingDef, stuffDef)); }, MenuOptionPriority.Default, null, null, 0, null, null)); Find.WindowStack.Add(new FloatMenu(list, null, false)); } else { destSelection = index; SoundDefOf.TickHigh.PlayOneShotOnCamera(); } } else if (Event.current.clickCount == 2) { if (customPawn.count > 0) { SoundDefOf.TickHigh.PlayOneShotOnCamera(); int amount = Event.current.shift ? 10 : 1; loadoutRecord.count -= amount; if (loadoutRecord.count < 0) { loadoutRecord.count = 0; } } else { SoundDefOf.TickLow.PlayOneShotOnCamera(); PrepareCarefully.Instance.RemoveEquipment(PrepareCarefully.Instance.EquipmentEntries[customPawn.EquipmentKey]); } } } } rectEntry.y += rectEntry.height; rectText.y += rectEntry.height; rectCost.y += rectEntry.height; rectItem.y += rectEntry.height; rectEntryButton.y += rectEntry.height; } if (Event.current.type == EventType.Layout) { destScrollViewHeight = rectEntry.y; } } catch (Exception e) { FatalError("Could not draw selected resources", e); } finally { Widgets.EndScrollView(); GUI.EndGroup(); } if (newDestScrollPosition >= 0) { destScrollPosition.y = newDestScrollPosition; newDestScrollPosition = -1; } GUI.color = Color.white; if (destSelection != -1) { if (Widgets.ButtonText(RectDestButton, "EdB.RemoveButton".Translate(), true, false, true)) { var customPawn = PrepareCarefully.Instance.Equipment[destSelection]; SoundDefOf.TickLow.PlayOneShotOnCamera(); PrepareCarefully.Instance.RemoveEquipment(PrepareCarefully.Instance.EquipmentEntries[customPawn.EquipmentKey]); } } }