private float DoWorkAreaPriorityRowElement(WorkGiverDef giverType, Rect inRect)
        {
            Rect rect1 = inRect.ContractedBy(cellSpacing);              //usedHeight considered in return
            Rect rect2 = new Rect(rect1.xMin, rect1.yMin, rect1.width * 0.35f, rect1.height);
            Rect rect3 = new Rect(rect2.xMax + rect1.width * 0.1f, rect2.yMin, rect1.width * 0.55f, rect1.height);

            AreaPriorityManager    aPM = map.GetComponent <AreaPriorityManager> ();
            WorkAreaPrioritization wAP = aPM.Prioritizations [giverType];

            Rect rect2a = new Rect(rect2.xMin + 2 * CellSpacing, rect2.yMin, rect2.width - 4 * CellSpacing, LineHeight);
            Rect rect2b = new Rect(rect2a.xMin + 4 * CellSpacing, rect2a.yMax, rect2.width / 2, LineHeight);
            Rect rect2c = new Rect(rect2b.xMin, rect2b.yMax, rect2b.width, LineHeight);

            Widgets.Label(rect2a, giverType.workType.gerundLabel.CapitalizeFirst() + ": "
                          + giverType.gerund.CapitalizeFirst());
            Widgets.CheckboxLabeled(rect2b, "Disable".Translate(), ref wAP.disabled);
            Widgets.Label(rect2c, "Remove".Translate());
            if (Widgets.CloseButtonFor(rect2c))
            {
                aPM.Prioritizations [giverType] = null;
            }

            WidgetRow rowA = new WidgetRow(rect3.xMin, rect3.yMin, UIDirection.RightThenUp, rect3.width, CellSpacing * 2f);
            WidgetRow rowB = new WidgetRow(rect3.xMin, rect3.yMin + LineHeight, UIDirection.RightThenUp, rect3.width, CellSpacing * 2f);
            WidgetRow rowC = new WidgetRow(rect3.xMin, rect3.yMin + 2 * LineHeight, UIDirection.RightThenUp, rect3.width, CellSpacing * 2f);

            if (rowA.ButtonText("HighPriority".Translate() + ": " + (wAP.highPriorityArea?.Label ?? "None")))
            {
                List <FloatMenuOption> highPriorityChoices = new List <FloatMenuOption>();
                foreach (Area area in map.areaManager.AllAreas.Except(wAP.Areas))
                {
                    highPriorityChoices.Add(new FloatMenuOption(area.Label, () => wAP.highPriorityArea = area));
                }
                if (wAP.highPriorityArea != null)
                {
                    highPriorityChoices.Add(new FloatMenuOption("None".Translate(), () => wAP.highPriorityArea = null));
                }
                Find.WindowStack.Add(new FloatMenu(highPriorityChoices));
            }
            float gapAdjust = (rect3.xMin + 0.7f * rect3.width) - rowA.FinalX;                  //Start invert box 70% across dialog

            if (gapAdjust > 0)
            {
                rowA.Gap(gapAdjust);
            }
            if (rowA.ButtonText(wAP.invertHighArea ? "Inverted".Translate() : "NotInverted".Translate()))
            {
                wAP.invertHighArea = !wAP.invertHighArea;
            }

            if (rowB.ButtonText("LowPriority".Translate() + ": " + (wAP.lowPriorityArea?.Label ?? "None")))
            {
                List <FloatMenuOption> lowPriorityChoices = new List <FloatMenuOption>();
                foreach (Area area in map.areaManager.AllAreas.Except(wAP.Areas))
                {
                    lowPriorityChoices.Add(new FloatMenuOption(area.Label, () => wAP.lowPriorityArea = area));
                }
                if (wAP.lowPriorityArea != null)
                {
                    lowPriorityChoices.Add(new FloatMenuOption("None".Translate(), () => wAP.lowPriorityArea = null));
                }
                Find.WindowStack.Add(new FloatMenu(lowPriorityChoices));
            }
            gapAdjust = (rect3.xMin + 0.7f * rect3.width) - rowB.FinalX;
            if (gapAdjust > 0)
            {
                rowB.Gap(gapAdjust);
            }
            if (rowB.ButtonText(wAP.invertLowArea ? "Inverted".Translate() : "NotInverted".Translate()))
            {
                wAP.invertLowArea = !wAP.invertLowArea;
            }

            if (rowC.ButtonText("AvoidPriority".Translate() + ": " + (wAP.avoidPriorityArea?.Label ?? "None")))
            {
                List <FloatMenuOption> avoidPriorityChoices = new List <FloatMenuOption>();
                foreach (Area area in map.areaManager.AllAreas.Except(wAP.Areas))
                {
                    avoidPriorityChoices.Add(new FloatMenuOption(area.Label, () => wAP.avoidPriorityArea = area));
                }
                if (wAP.avoidPriorityArea != null)
                {
                    avoidPriorityChoices.Add(new FloatMenuOption("None".Translate(), () => wAP.avoidPriorityArea = null));
                }
                Find.WindowStack.Add(new FloatMenu(avoidPriorityChoices));
            }
            gapAdjust = (rect3.xMin + 0.7f * rect3.width) - rowC.FinalX;
            if (gapAdjust > 0)
            {
                rowC.Gap(gapAdjust);
            }
            if (rowC.ButtonText(wAP.invertAvoidArea ? "Inverted".Translate() : "NotInverted".Translate()))
            {
                wAP.invertAvoidArea = !wAP.invertAvoidArea;
            }

            inRect.height = 3f * LineHeight + CellSpacing;
            Widgets.DrawBox(inRect, 1);

            return(RowHeight);
        }
Exemple #2
0
 public WorkGiver_Scanner_AreaPriorityWrapper(WorkGiver_Scanner workGiver, Map map)
 {
     this.wrappedGiver   = workGiver;
     this.prioritization = map.GetComponent <AreaPriorityManager>().Prioritizations[workGiver.def];
     this.def            = wrappedGiver.def;
 }