public TextPlusMinusInputWidget(string label, float labelWidth, List <string> items)
        {
            this.label      = label;
            this.labelWidth = labelWidth;
            this.items      = items;

            args = new PlusMinusArgs <string>()
            {
                getDisplayName = s => s,
                onRemove       = s => this.items.Remove(s),
                beingUsed      = () => this.items,
                addArgs        = new FloatOptionsArgs <string>()
                {
                    skipListCustomOnly = true,
                    onCustomOption     = () => Find.WindowStack.Add(new Dialog_Name(
                                                                        "Tag",
                                                                        delegate(string s)
                    {
                        this.items.Add(s);
                    },
                                                                        delegate(string s)
                    {
                        return(s.Trim().Length > 0 && !this.items.Contains(s));
                    })),
                },
                removeArgs = new FloatOptionsArgs <string>()
                {
                    getDisplayName = (s) => s,
                    items          = this.items,
                    onSelect       = (s) => this.items.Remove(s),
                },
            };
        }
        public DefPlusMinusInputWidget(string label, float labelWidth, List <D> items)
        {
            this.label      = label;
            this.labelWidth = labelWidth;
            this.items      = items;

            args = new PlusMinusArgs <D>()
            {
                getDisplayName = def => Util.GetLabel(def),
                allItems       = DefDatabase <D> .AllDefs,
                onAdd          = def => Util.AddTo(this.items, def),
                onRemove       = def => Util.RemoveFrom(this.items, def),
                beingUsed      = () => this.items
            };
        }
Ejemplo n.º 3
0
        public ApparelPropertiesWidget(ApparelProperties apparelProperties)
        {
            this.apparelProperties = apparelProperties;

            this.inputWidgets = new List <IInputWidget>()
            {
                // this.useWornGraphicMask == s.useWornGraphicMask &&
                //    this.canBeGeneratedToSatisfyWarmth == s.canBeGeneratedToSatisfyWarmth &&
                //    this.gender == s.gender &&
                new FloatInputWidget <ApparelProperties>(this.apparelProperties, "Wear Per Day", s => s.wearPerDay, (s, v) => s.wearPerDay = v),
                new BoolInputWidget <ApparelProperties>(this.apparelProperties, "Care If Worn By Corpse", s => s.careIfWornByCorpse, (s, v) => s.careIfWornByCorpse            = v),
                new BoolInputWidget <ApparelProperties>(this.apparelProperties, "Hat Rendered Front OfFace", s => s.hatRenderedFrontOfFace, (s, v) => s.hatRenderedFrontOfFace = v),
                new BoolInputWidget <ApparelProperties>(this.apparelProperties, "Use Deflect Metal Effect", s => s.useDeflectMetalEffect, (s, v) => s.useDeflectMetalEffect    = v),
                new BoolInputWidget <ApparelProperties>(this.apparelProperties, "Use Worn Graphic Mask", s => s.useWornGraphicMask, (s, b) => s.useWornGraphicMask             = b),
                new BoolInputWidget <ApparelProperties>(this.apparelProperties, "Can Be Generated for Warmth", s => s.canBeGeneratedToSatisfyWarmth, (s, b) => s.canBeGeneratedToSatisfyWarmth = b),
                new EnumInputWidget <ApparelProperties, Gender>(this.apparelProperties, "Gender", 100f, s => s.gender, (s, v) => s.gender = v),
                new TextPlusMinusInputWidget("Tags", 100f, () => this.apparelProperties.tags)
            };

            this.bodyPartGroupArgs = new WindowUtil.PlusMinusArgs <BodyPartGroupDef>()
            {
                allItems       = DefDatabase <BodyPartGroupDef> .AllDefs,
                beingUsed      = () => this.apparelProperties?.bodyPartGroups,
                onAdd          = v => this.apparelProperties.bodyPartGroups.Add(v),
                onRemove       = v => this.apparelProperties.bodyPartGroups.Remove(v),
                getDisplayName = v => Util.GetLabel(v),
            };

            this.apparelLayerArgs = new WindowUtil.PlusMinusArgs <ApparelLayerDef>()
            {
                allItems       = DefDatabase <ApparelLayerDef> .AllDefs,
                beingUsed      = () => this.apparelProperties?.layers,
                onAdd          = v => this.apparelProperties.layers.Add(v),
                onRemove       = v => this.apparelProperties.layers.Remove(v),
                getDisplayName = v => Util.GetLabel(v),
            };
        }
        public ABuildableDefWidget(D def, DefType type) : base(def, type)
        {
            if (base.Def.statBases == null)
            {
                base.Def.statBases = new List <StatModifier>();
            }

            this.inputWidgets = new List <IInputWidget>()
            {
                new EnumInputWidget <D, Traversability>(base.Def, "Passability", 200, d => d.passability, (d, v) => d.passability = v),
                new IntInputWidget <D>(base.Def, "Path Cost", d => d.pathCost, (d, v) => d.pathCost = v),
                new BoolInputWidget <D>(base.Def, "Path Cost Ignore Repeat", d => d.pathCostIgnoreRepeat, (d, v) => d.pathCostIgnoreRepeat = v),
                new FloatInputWidget <D>(base.Def, "Fertility", d => d.fertility, (d, v) => d.fertility = v),
                new IntInputWidget <D>(base.Def, "Cost Stuff Count", d => d.costStuffCount, (d, v) => d.costStuffCount = v),
                new IntInputWidget <D>(base.Def, "Placing Draggable Dimensions", d => d.placingDraggableDimensions, (d, v) => d.placingDraggableDimensions = v),
                new BoolInputWidget <D>(base.Def, "Clear Building Area", d => d.clearBuildingArea, (d, v) => d.clearBuildingArea = v),
                new FloatInputWidget <D>(base.Def, "Resources Fraction When Deconstructed", d => d.resourcesFractionWhenDeconstructed, (d, v) => d.resourcesFractionWhenDeconstructed = v),
                new IntInputWidget <D>(base.Def, "Construction Skill Prerequisite", d => d.constructionSkillPrerequisite, (d, v) => d.constructionSkillPrerequisite = v),
                new EnumInputWidget <D, TechLevel>(base.Def, "Min Tech Level To Build", 200, d => d.minTechLevelToBuild, (d, v) => d.minTechLevelToBuild            = v),
                new EnumInputWidget <D, TechLevel>(base.Def, "Max Tech Level To Build", 200, d => d.maxTechLevelToBuild, (d, v) => d.maxTechLevelToBuild            = v),
                new EnumInputWidget <D, AltitudeLayer>(base.Def, "Altitude Layer", 200, d => d.altitudeLayer, (d, v) => d.altitudeLayer = v),
                new BoolInputWidget <D>(base.Def, "Menu Hidden", d => d.menuHidden, (d, v) => d.menuHidden = v),
                new FloatInputWidget <D>(base.Def, "Special Display Radius", d => d.specialDisplayRadius, (d, v) => d.specialDisplayRadius = v),

                new DefInputWidget <D, TerrainAffordanceDef>(base.Def, "Terrain Affordance Needed", 200, d => d.terrainAffordanceNeeded, (d, v) => d.terrainAffordanceNeeded = v, true),
                new DefInputWidget <D, EffecterDef>(base.Def, "Repair Effect", 200, d => d.repairEffect, (d, v) => d.repairEffect          = v, true),
                new DefInputWidget <D, EffecterDef>(base.Def, "Construct Effect", 200, d => d.constructEffect, (d, v) => d.constructEffect = v, true),
                new DefInputWidget <D, DesignationCategoryDef>(base.Def, "Designation Category", 200, d => d.designationCategory, (d, v) => d.designationCategory  = v, true),
                new DefInputWidget <D, DesignatorDropdownGroupDef>(base.Def, "Designator Dropdown", 200, d => d.designatorDropdown, (d, v) => d.designatorDropdown = v, true),
                new DefInputWidget <D, KeyBindingDef>(base.Def, "Key Binding", 200, d => d.designationHotKey, (d, v) => d.designationHotKey = v, true),
                new DefInputWidget <D, ThingDef>(base.Def, "Blueprint", 200, d => d.blueprintDef, (d, v) => d.blueprintDef = v, true),
                new DefInputWidget <D, ThingDef>(base.Def, "Install Blueprint", 200, d => d.installBlueprintDef, (d, v) => d.installBlueprintDef = v, true),
                new DefInputWidget <D, ThingDef>(base.Def, "Frame", 200, d => d.frameDef, (d, v) => d.frameDef = v, true),

                new EnumInputWidget <D, Direction>(base.Def, "Default Placing Rotation", 200,
                                                   d =>
                {
                    switch (d.defaultPlacingRot.AsAngle)
                    {
                    case 0f:
                        return(Direction.North);

                    case 90f:
                        return(Direction.East);

                    case 180f:
                        return(Direction.South);

                    default:
                        return(Direction.West);
                    }
                },
                                                   (d, v) =>
                {
                    switch (v)
                    {
                    case Direction.North:
                        d.defaultPlacingRot = Rot4.North;
                        break;

                    case Direction.East:
                        d.defaultPlacingRot = Rot4.East;
                        break;

                    case Direction.South:
                        d.defaultPlacingRot = Rot4.South;
                        break;

                    default:
                        d.defaultPlacingRot = Rot4.West;
                        break;
                    }
                }),
            };

            this.statBasesPlusMinus = new WindowUtil.PlusMinusArgs <StatDef>()
            {
                allItems       = DefDatabase <StatDef> .AllDefs,
                getDisplayName = d => Util.GetLabel(d),
                beingUsed      = () =>
                {
                    List <StatDef> l = new List <StatDef>(base.Def.statBases.Count);
                    base.Def.statBases.ForEach(v => l.Add(v.stat));
                    return(l);
                },
                onAdd = v =>
                {
                    StatModifier sm = new StatModifier()
                    {
                        stat = v, value = 0
                    };
                    base.Def.statBases.Add(sm);
                    this.statBases.Add(this.CreateFloatInput(sm));
                },
                onRemove = v =>
                {
                    base.Def.statBases.RemoveAll(sm => sm.stat == v);
                    this.statBases.RemoveAll(w => w.Parent.stat == v);
                },
            };
        }
        public TraitDegreeDataWidget(TraitDegreeData data)
        {
            if (data.disallowedMentalStates == null)
            {
                data.disallowedMentalStates = new List <MentalStateDef>();
            }
            if (data.disallowedInspirations == null)
            {
                data.disallowedInspirations = new List <InspirationDef>();
            }
            if (data.theOnlyAllowedMentalBreaks == null)
            {
                data.theOnlyAllowedMentalBreaks = new List <MentalBreakDef>();
            }

            this.data         = data;
            this.inputWidgets = new List <IInputWidget>()
            {
                //new IntInputWidget<TraitDegreeData>(this.data, "Degree", d => d.degree, (d, v) => d.degree = v),
                new FloatInputWidget <TraitDegreeData>(this.data, "Commonality", d => d.commonality, (d, v) => d.commonality = v),
                new FloatInputWidget <TraitDegreeData>(this.data, "Social Fight Chance Factor", d => d.socialFightChanceFactor, (d, v) => d.socialFightChanceFactor = v),
                new FloatInputWidget <TraitDegreeData>(this.data, "Market Value Factor Offset", d => d.marketValueFactorOffset, (d, v) => d.marketValueFactorOffset = v),
                new FloatInputWidget <TraitDegreeData>(this.data, "Random Disease Mtb Days", d => d.randomDiseaseMtbDays, (d, v) => d.randomDiseaseMtbDays          = v),
                new DefInputWidget <TraitDegreeData, ThinkTreeDef>(this.data, "Think Tree", 200, d => d.thinkTree, (d, v) => d.thinkTree = v, true),
                new DefInputWidget <TraitDegreeData, MentalStateDef>(this.data, "Random Mental State", 200, d => d.randomMentalState, (d, v) => d.randomMentalState = v, true),
                new DefPlusMinusInputWidget <InspirationDef>("Disallowed Inspirations", 200, this.data.disallowedInspirations),
                new DefPlusMinusInputWidget <MentalStateDef>("Disallowed Mental States", 200, this.data.disallowedMentalStates),
                new DefPlusMinusInputWidget <MentalBreakDef>("The Only Allowed Mental Breaks", 200, this.data.theOnlyAllowedMentalBreaks),
            };

            this.skillGainsArgs = new WindowUtil.PlusMinusArgs <SkillDef>()
            {
                getDisplayName = v => v.label,
                allItems       = DefDatabase <SkillDef> .AllDefs,
                beingUsed      = () =>
                {
                    List <SkillDef> l = new List <SkillDef>();
                    if (this.data.skillGains != null)
                    {
                        foreach (var kv in this.data.skillGains)
                        {
                            l.Add(kv.Key);
                        }
                    }
                    return(l);
                },
                onAdd = def =>
                {
                    this.data.skillGains.Add(def, 0);
                    this.skillGains.Add(this.CreateSkillGainInput(def));
                },
                onRemove = def =>
                {
                    this.skillGains.RemoveAll(v => v.Parent == def);
                    this.data.skillGains.Remove(def);
                }
            };

            this.statOffsetsArgs = new WindowUtil.PlusMinusArgs <StatDef>()
            {
                getDisplayName = v => v.label,
                allItems       = DefDatabase <StatDef> .AllDefs,
                beingUsed      = () =>
                {
                    List <StatDef> l = new List <StatDef>();
                    if (this.data.statOffsets != null)
                    {
                        foreach (var v in this.data.statOffsets)
                        {
                            l.Add(v.stat);
                        }
                    }
                    return(l);
                },
                onAdd = def =>
                {
                    StatModifier sm = new StatModifier()
                    {
                        stat = def, value = 0
                    };
                    this.data.statOffsets = Util.AddTo(this.data.statOffsets, sm);
                    this.statOffsets      = Util.AddTo(this.statOffsets, this.CreateStatModifierInput(sm));
                },
                onRemove = def =>
                {
                    this.statOffsets?.RemoveAll(v => v.Parent.stat == def);
                    this.data.statOffsets?.RemoveAll(v => v.stat == def);
                }
            };

            this.statFactorsArgs = new WindowUtil.PlusMinusArgs <StatDef>()
            {
                getDisplayName = v => v.label,
                allItems       = DefDatabase <StatDef> .AllDefs,
                beingUsed      = () =>
                {
                    List <StatDef> l = new List <StatDef>();
                    if (this.data.statFactors != null)
                    {
                        foreach (var v in this.data.statFactors)
                        {
                            l.Add(v.stat);
                        }
                    }
                    return(l);
                },
                onAdd = def =>
                {
                    StatModifier sm = new StatModifier()
                    {
                        stat = def, value = 0
                    };
                    this.data.statFactors = Util.AddTo(this.data.statFactors, sm);
                    this.statFactors      = Util.AddTo(this.statFactors, this.CreateStatModifierInput(sm));
                },
                onRemove = def =>
                {
                    this.statFactors?.RemoveAll(v => v.Parent.stat == def);
                    this.data.statFactors?.RemoveAll(v => v.stat == def);
                }
            };

            this.ResetBuffers();
        }
        public StuffPropertiesWidget(StuffProperties sp)
        {
            this.stuffProperties = sp;

            this.inputWidgets = new List <IInputWidget>()
            {
                new FloatInputWidget <StuffProperties>(this.stuffProperties, "Commonality", d => d.commonality, (d, v) => d.commonality = v),
                new ColorWidget <StuffProperties>(this.stuffProperties, "Color", d => d.color, (d, v) => d.color = v),
                new BoolInputWidget <StuffProperties>(this.stuffProperties, "Allow Color Generators", d => d.allowColorGenerators, (d, v) => d.allowColorGenerators          = v),
                new DefInputWidget <StuffProperties, EffecterDef>(this.stuffProperties, "Construct Effect", 200, d => d.constructEffect, (d, v) => d.constructEffect         = v, true),
                new DefInputWidget <StuffProperties, StuffAppearanceDef>(this.stuffProperties, "Appearance", 200, d => d.appearance, (d, v) => d.appearance                  = v, true),
                new DefInputWidget <StuffProperties, SoundDef>(this.stuffProperties, "Sound Impact", 200, d => d.soundImpactStuff, (d, v) => d.soundImpactStuff              = v, true),
                new DefInputWidget <StuffProperties, SoundDef>(this.stuffProperties, "Sound Melee Hit Sharp", 200, d => d.soundMeleeHitSharp, (d, v) => d.soundMeleeHitSharp = v, true),
                new DefInputWidget <StuffProperties, SoundDef>(this.stuffProperties, "Sound Melee Hit Blunt", 200, d => d.soundMeleeHitBlunt, (d, v) => d.soundMeleeHitBlunt = v, true),
            };

            this.statOffsetsArgs = new WindowUtil.PlusMinusArgs <StatDef>()
            {
                getDisplayName = v => v.label,
                allItems       = DefDatabase <StatDef> .AllDefs,
                beingUsed      = () =>
                {
                    List <StatDef> l = new List <StatDef>();
                    if (this.stuffProperties.statOffsets != null)
                    {
                        foreach (var v in this.stuffProperties.statOffsets)
                        {
                            l.Add(v.stat);
                        }
                    }
                    return(l);
                },
                onAdd = def =>
                {
                    StatModifier sm = new StatModifier()
                    {
                        stat = def, value = 0
                    };
                    this.stuffProperties.statOffsets = Util.AddTo(this.stuffProperties.statOffsets, sm);
                    this.statOffsets = Util.AddTo(this.statOffsets, this.CreateStatModifierInput(sm));
                },
                onRemove = def =>
                {
                    this.statOffsets?.RemoveAll(v => v.Parent.stat == def);
                    this.stuffProperties.statOffsets?.RemoveAll(v => v.stat == def);
                }
            };

            this.statFactorsArgs = new WindowUtil.PlusMinusArgs <StatDef>()
            {
                getDisplayName = v => v.label,
                allItems       = DefDatabase <StatDef> .AllDefs,
                beingUsed      = () =>
                {
                    List <StatDef> l = new List <StatDef>();
                    if (this.stuffProperties.statFactors != null)
                    {
                        foreach (var v in this.stuffProperties.statFactors)
                        {
                            l.Add(v.stat);
                        }
                    }
                    return(l);
                },
                onAdd = def =>
                {
                    StatModifier sm = new StatModifier()
                    {
                        stat = def, value = 0
                    };
                    this.stuffProperties.statFactors = Util.AddTo(this.stuffProperties.statFactors, sm);
                    this.statFactors = Util.AddTo(this.statFactors, this.CreateStatModifierInput(sm));
                },
                onRemove = def =>
                {
                    this.statFactors?.RemoveAll(v => v.Parent.stat == def);
                    this.stuffProperties.statFactors?.RemoveAll(v => v.stat == def);
                }
            };

            this.ResetBuffers();
        }