private static void DrawAutoWorkPrioritiesToggle(ExtendedOutfit outfit, ref Vector2 pos, Rect canvas)
        {
            var rect = new Rect(pos.x, pos.y, canvas.width, 30f);

            Verse.Widgets.CheckboxLabeled(rect, ResourceBank.Strings.AutoWorkPriorities, ref outfit.AutoWorkPriorities);
            TooltipHandler.TipRegion(rect, ResourceBank.Strings.AutoWorkPrioritiesTooltip);
            pos.y += rect.height;
        }
コード例 #2
0
        static void ConfigureOutfitNudist(ExtendedOutfit outfit, Dictionary <StatDef, float> priorities)
        {
            var forbid = new[] {
                BodyPartGroupDefOf.Legs,
                BodyPartGroupDefOf.Torso
            };

            ConfigureOutfitFiltered(outfit, priorities, d => d.apparel?.bodyPartGroups.All(g => !forbid.Contains(g)) ?? false);
        }
        private static void DrawTaintedToggle(ExtendedOutfit selectedOutfit, ref Vector2 cur, Rect canvas)
        {
            var rect = new Rect(cur.x, cur.y, canvas.width, 30f);

            Verse.Widgets.CheckboxLabeled(rect, ResourceBank.Strings.PenalizeTaintedApparel,
                                          ref selectedOutfit.PenalizeTaintedApparel);
            TooltipHandler.TipRegion(rect, ResourceBank.Strings.PenalizeTaintedApparelTooltip);
            cur.y += rect.height;
        }
コード例 #4
0
        static void ConfigureOutfitFiltered(ExtendedOutfit outfit, Dictionary <StatDef, float> priorities, Func <ThingDef, bool> filter)
        {
            outfit.filter.SetDisallowAll(null, null);
            outfit.filter.SetAllow(SpecialThingFilterDefOf.AllowDeadmansApparel, false);

            foreach (ThingDef current in DefDatabase <ThingDef> .AllDefs.Where(filter))
            {
                outfit.filter.SetAllow(current, true);
            }

            ConfigureOutfit(outfit, priorities);
        }
コード例 #5
0
        static Outfit ReplaceKnownVanillaOutfits(Outfit outfit)
        {
            var newOutfit = new ExtendedOutfit(outfit);

            switch (newOutfit.label)
            {
            default:
                newOutfit.AddRange(new List <StatPriority>
                {
                    new StatPriority(StatDefOf.MoveSpeed, Priority.Desired),
                    new StatPriority(StatDefOf.WorkSpeedGlobal, Priority.Wanted),
                    new StatPriority(StatDefOf.ArmorRating_Blunt, Priority.Desired),
                    new StatPriority(StatDefOf.ArmorRating_Sharp, Priority.Desired),
                });
                break;

            case "Worker":
                newOutfit.AddRange(new List <StatPriority>
                {
                    new StatPriority(StatDefOf.MoveSpeed, Priority.Neutral),
                    new StatPriority(StatDefOf.WorkSpeedGlobal, Priority.Desired),
                });
                break;

            case "Soldier":
                newOutfit.AddRange(new List <StatPriority>
                {
                    new StatPriority(StatDefOf.ShootingAccuracyPawn, Priority.Wanted),
                    new StatPriority(StatDefOf.AccuracyShort, Priority.Desired),
                    new StatPriority(StatDefOf.AccuracyMedium, Priority.Desired),
                    new StatPriority(StatDefOf.AccuracyLong, Priority.Desired),
                    new StatPriority(StatDefOf.MoveSpeed, Priority.Desired),
                    new StatPriority(StatDefOf.ArmorRating_Blunt, Priority.Neutral),
                    new StatPriority(StatDefOf.ArmorRating_Sharp, Priority.Desired),
                    new StatPriority(StatDefOf.MeleeDodgeChance, Priority.Neutral),
                    new StatPriority(StatDefOf.AimingDelayFactor, Priority.Unwanted),
                    new StatPriority(StatDefOf.RangedWeapon_Cooldown, Priority.Unwanted),
                    new StatPriority(StatDefOf.PainShockThreshold, Priority.Wanted),
                });
                break;

            case "Nudist":
                newOutfit.AddRange(new List <StatPriority>
                {
                    new StatPriority(StatDefOf.MoveSpeed, Priority.Desired),
                    new StatPriority(StatDefOf.WorkSpeedGlobal, Priority.Wanted),
                });
                break;
            }

            return(newOutfit);
        }
コード例 #6
0
 static void ConfigureOutfitSoldier(ExtendedOutfit outfit, Dictionary <StatDef, float> priorities)
 {
     ConfigureOutfitTagged(outfit, priorities, "Soldier");
 }
コード例 #7
0
 static void ConfigureOutfitTagged(ExtendedOutfit outfit, Dictionary <StatDef, float> priorities, string tag)
 {
     ConfigureOutfitFiltered(outfit, priorities, d => d.apparel?.defaultOutfitTags?.Contains(tag) ?? false);
 }
コード例 #8
0
 static void ConfigureOutfit(ExtendedOutfit outfit, Dictionary <StatDef, float> priorities)
 {
     outfit.AddRange(priorities.Select(i => new StatPriority(i.Key, i.Value, i.Value)));
 }
        private static void DrawApparelStats(ExtendedOutfit selectedOutfit, Vector2 cur, Rect canvas)
        {
            // header
            var statsHeaderRect = new Rect(cur.x, cur.y, canvas.width, 30f);

            cur.y      += 30f;
            Text.Anchor = TextAnchor.LowerLeft;
            Text.Font   = GameFont.Small;
            Verse.Widgets.Label(statsHeaderRect, ResourceBank.Strings.PreferedStats);
            Text.Anchor = TextAnchor.UpperLeft;

            // add button
            var addStatRect = new Rect(statsHeaderRect.xMax - 16f, statsHeaderRect.yMin + MarginVertical, 16f, 16f);

            if (Verse.Widgets.ButtonImage(addStatRect, ResourceBank.Textures.AddButton))
            {
                var options = new List <FloatMenuOption>();
                foreach (var def in selectedOutfit.UnassignedStats.OrderBy(i => i.label)
                         .ThenBy(i => i.category.displayOrder))
                {
                    var option = new FloatMenuOption(def.LabelCap, delegate { selectedOutfit.AddStatPriority(def); });
                    options.Add(option);
                }
                Find.WindowStack.Add(new FloatMenu(options));
            }
            TooltipHandler.TipRegion(addStatRect, ResourceBank.Strings.StatPriorityAdd);

            // line
            GUI.color = Color.grey;
            Verse.Widgets.DrawLineHorizontal(cur.x, cur.y, canvas.width);
            GUI.color = Color.white;

            // some padding
            cur.y += MarginVertical;
            var stats = selectedOutfit.StatPriorities.ToList();

            // main content in scrolling view
            var contentRect = new Rect(cur.x, cur.y, canvas.width, canvas.height - cur.y);
            var viewRect    = new Rect(contentRect)
            {
                height = 30f * stats.Count
            };

            if (viewRect.height > contentRect.height)
            {
                viewRect.width -= 20f;
            }
            Verse.Widgets.BeginScrollView(contentRect, ref _scrollPosition, viewRect);
            GUI.BeginGroup(viewRect);
            cur = Vector2.zero;

            // none label
            if (stats.Count > 0)
            {
                // legend kind of thingy.
                var legendRect = new Rect(cur.x + (viewRect.width - 24) / 2, cur.y, (viewRect.width - 24) / 2, 20f);
                Text.Font   = GameFont.Tiny;
                GUI.color   = Color.grey;
                Text.Anchor = TextAnchor.LowerLeft;
                Verse.Widgets.Label(legendRect,
                                    "-" + DefaultWorkTypePriorities.MaxStatWeight.ToString("N1", CultureInfo.InvariantCulture));
                Text.Anchor = TextAnchor.LowerRight;
                Verse.Widgets.Label(legendRect,
                                    DefaultWorkTypePriorities.MaxStatWeight.ToString("N1", CultureInfo.InvariantCulture));
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
                GUI.color   = Color.white;
                cur.y      += 15f;

                // statPriority weight sliders
                foreach (var stat in stats)
                {
                    DrawStatRow(selectedOutfit, stat, ref cur, viewRect.width);
                }
            }
            else
            {
                var noneLabel = new Rect(cur.x, cur.y, viewRect.width, 30f);
                GUI.color   = Color.grey;
                Text.Anchor = TextAnchor.MiddleCenter;
                Verse.Widgets.Label(noneLabel, ResourceBank.Strings.None);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
                cur.y      += 30f;
            }
            GUI.EndGroup();
            Verse.Widgets.EndScrollView();
        }
        private static void DrawStatRow(ExtendedOutfit selectedOutfit, StatPriority statPriority, ref Vector2 cur,
                                        float width)
        {
            // set up rects
            var labelRect  = new Rect(cur.x, cur.y, (width - 24) / 2f, 30f);
            var sliderRect = new Rect(labelRect.xMax + 4f, cur.y + 5f, labelRect.width, 25f);
            var buttonRect = new Rect(sliderRect.xMax + 4f, cur.y + 3f, 16f, 16f);

            // draw label
            Text.Font = Text.CalcHeight(statPriority.Stat.LabelCap, labelRect.width) > labelRect.height
                ? GameFont.Tiny
                : GameFont.Small;
            GUI.color = AssignmentColor(statPriority);
            Verse.Widgets.Label(labelRect, statPriority.Stat.LabelCap);
            Text.Font = GameFont.Small;

            // draw button
            // if manually added, delete the priority
            var buttonTooltip = string.Empty;

            if (statPriority.IsManual)
            {
                buttonTooltip = ResourceBank.Strings.StatPriorityDelete(statPriority.Stat.LabelCap);
                if (Verse.Widgets.ButtonImage(buttonRect, ResourceBank.Textures.DeleteButton))
                {
                    selectedOutfit.RemoveStatPriority(statPriority.Stat);
                }
            }
            // if overridden auto assignment, reset to auto
            else if (statPriority.IsOverride)
            {
                buttonTooltip = ResourceBank.Strings.StatPriorityReset(statPriority.Stat.LabelCap);
                if (Verse.Widgets.ButtonImage(buttonRect, ResourceBank.Textures.ResetButton))
                {
                    statPriority.Weight = statPriority.Default;
                }
            }

            // draw line behind slider
            GUI.color = new Color(.3f, .3f, .3f);
            for (var y = (int)cur.y; y < cur.y + 30; y += 5)
            {
                Verse.Widgets.DrawLineVertical((sliderRect.xMin + sliderRect.xMax) / 2f, y, 3f);
            }

            // draw slider
            GUI.color = AssignmentColor(statPriority);
            var weight = GUI.HorizontalSlider(sliderRect, statPriority.Weight, -DefaultWorkTypePriorities.MaxStatWeight,
                                              DefaultWorkTypePriorities.MaxStatWeight);

            if (Mathf.Abs(weight - statPriority.Weight) > 1e-4)
            {
                statPriority.Weight = weight;
            }
            GUI.color = Color.white;
            // tooltips
            TooltipHandler.TipRegion(labelRect, statPriority.Stat.LabelCap + "\n\n" + statPriority.Stat.description);
            if (!string.IsNullOrEmpty(buttonTooltip))
            {
                TooltipHandler.TipRegion(buttonRect, buttonTooltip);
            }
            TooltipHandler.TipRegion(sliderRect, statPriority.Weight.ToStringByStyle(ToStringStyle.FloatTwo));

            // advance row
            cur.y += 30f;
        }