public override void DoWindowContents(Rect canvas) { // fix weird zooming bug Text.Font = GameFont.Small; // SET UP RECTS // top buttons Rect selectRect = new Rect(0f, 0f, canvas.width * .2f, _topAreaHeight); Rect newRect = new Rect(selectRect.xMax + _margin, 0f, canvas.width * .2f, _topAreaHeight); Rect copyRect = new Rect(newRect.xMax + _margin, 0f, canvas.width * .2f, _topAreaHeight); Rect deleteRect = new Rect(copyRect.xMax + _margin, 0f, canvas.width * .2f, _topAreaHeight); // main areas Rect nameRect = new Rect( 0f, _topAreaHeight + _margin * 2, (canvas.width - _margin) / 2f, 24f); Rect slotListRect = new Rect( 0f, nameRect.yMax + _margin, (canvas.width - _margin) / 2f, canvas.height - _topAreaHeight - nameRect.height - _barHeight * 2 - _margin * 5); Rect weightBarRect = new Rect(slotListRect.xMin, slotListRect.yMax + _margin, slotListRect.width, _barHeight); Rect bulkBarRect = new Rect(weightBarRect.xMin, weightBarRect.yMax + _margin, weightBarRect.width, _barHeight); Rect sourceButtonRect = new Rect( slotListRect.xMax + _margin, _topAreaHeight + _margin * 2, (canvas.width - _margin) / 2f, 24f); Rect selectionRect = new Rect( slotListRect.xMax + _margin, sourceButtonRect.yMax + _margin, (canvas.width - _margin) / 2f, canvas.height - 24f - _topAreaHeight - _margin * 3); LoadoutManager.SortLoadouts(); List <Loadout> loadouts = LoadoutManager.Loadouts.Where(l => !l.defaultLoadout).ToList(); // DRAW CONTENTS // buttons // select loadout if (Widgets.ButtonText(selectRect, "CE_SelectLoadout".Translate())) { List <FloatMenuOption> options = new List <FloatMenuOption>(); if (loadouts.Count == 0) { options.Add(new FloatMenuOption("CE_NoLoadouts".Translate(), null)); } else { for (int i = 0; i < loadouts.Count; i++) { int local_i = i; options.Add(new FloatMenuOption(loadouts[i].LabelCap, delegate { CurrentLoadout = loadouts[local_i]; })); } } Find.WindowStack.Add(new FloatMenu(options)); } // create loadout if (Widgets.ButtonText(newRect, "CE_NewLoadout".Translate())) { Loadout loadout = new Loadout(); loadout.AddBasicSlots(); LoadoutManager.AddLoadout(loadout); CurrentLoadout = loadout; } // copy loadout if (CurrentLoadout != null && Widgets.ButtonText(copyRect, "CE_CopyLoadout".Translate())) { CurrentLoadout = CurrentLoadout.Copy(); LoadoutManager.AddLoadout(CurrentLoadout); } // delete loadout if (loadouts.Any(l => l.canBeDeleted) && Widgets.ButtonText(deleteRect, "CE_DeleteLoadout".Translate())) { List <FloatMenuOption> options = new List <FloatMenuOption>(); for (int i = 0; i < loadouts.Count; i++) { int local_i = i; // don't allow deleting the default loadout if (!loadouts[i].canBeDeleted) { continue; } options.Add(new FloatMenuOption(loadouts[i].LabelCap, delegate { if (CurrentLoadout == loadouts[local_i]) { CurrentLoadout = LoadoutManager.DefaultLoadout; } LoadoutManager.RemoveLoadout(loadouts[local_i]); })); } Find.WindowStack.Add(new FloatMenu(options)); } // draw notification if no loadout selected if (CurrentLoadout == null) { Text.Anchor = TextAnchor.MiddleCenter; GUI.color = Color.grey; Widgets.Label(canvas, "CE_NoLoadoutSelected".Translate()); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; // and stop further drawing return; } // name DrawNameField(nameRect); // source selection DrawSourceSelection(sourceButtonRect); // selection area DrawSlotSelection(selectionRect); // current slots DrawSlotList(slotListRect); // bars if (CurrentLoadout != null) { Utility_Loadouts.DrawBar(weightBarRect, CurrentLoadout.Weight, Utility_Loadouts.medianWeightCapacity, "CE_Weight".Translate(), CurrentLoadout.GetWeightTip()); Utility_Loadouts.DrawBar(bulkBarRect, CurrentLoadout.Bulk, Utility_Loadouts.medianBulkCapacity, "CE_Bulk".Translate(), CurrentLoadout.GetBulkTip()); } // done! }