Beispiel #1
0
        public static void InjectCustomUI()
        {
            Rect editButtonRect = new Rect(620f, 0.0f, 50f, 30f);

            if (ModsConfig.IsActive("hahkethomemah.simplepersonalities"))
            {
                editButtonRect.x -= 130;
            }

            if (Widgets.ButtonText(editButtonRect, "RandomPlus.FilterButton".Translate(), true, false, true))
            {
                var page = new Page_RandomEditor();
                Find.WindowStack.Add(page);
            }

            Rect rerollLabelRect = new Rect(620f, 40f, 200f, 30f);

            if (ModsConfig.IdeologyActive)
            {
                rerollLabelRect.y += 40;
            }

            string labelText = "RandomPlus.RerollLabel".Translate() + RandomSettings.RandomRerollCounter() + "/" + RandomSettings.PawnFilter.RerollLimit;

            var tmpSave = GUI.color;

            if (RandomSettings.RandomRerollCounter() >= RandomSettings.PawnFilter.RerollLimit)
            {
                GUI.color = Color.red;
            }
            Widgets.Label(rerollLabelRect, labelText);
            GUI.color = tmpSave;
        }
Beispiel #2
0
        static bool Prefix()
        {
            if (rerolling)
            {
                return(false);
            }

            rerolling = true;
            RandomSettings.ResetRerollCounter();
            return(true);
        }
Beispiel #3
0
        public override void DoWindowContents(Rect inRect)
        {
            this.DrawPageTitle(inRect);
            Rect mainRect = base.GetMainRect(inRect, 30f, false);

            panelSkills.Draw();
            panelTraits.Draw();

            var randomRerollLimitLabelRect = new Rect(320 + 20, 156 + 40 + 20, 320, 20);

            Widgets.Label(randomRerollLimitLabelRect, "Random Reroll Limit: ");
            var randomRerollLimitRect = new Rect(320 + 20, 156 + 40 + 20 + 20 + 4, 60, 30);

            foreach (var option in RandomSettings.RANDOM_REROLL_LIMIT_OPTIONS)
            {
                bool isSelected = Widgets.RadioButtonLabeled(randomRerollLimitRect, option.ToString(), RandomSettings.RandomRerollLimit() == option);
                if (isSelected)
                {
                    RandomSettings.SetRandomRerollLimit(option);
                }
                randomRerollLimitRect    = new Rect(randomRerollLimitRect);
                randomRerollLimitRect.x += 60 + 20;
            }

            var ageLabelRect = randomRerollLimitLabelRect.OffsetBy(0, 68);

            ageLabelRect.height = 26;
            string labelText = string.Format("Age: {0}-{1}", RandomSettings.PawnFilter.AgeRange.min, RandomSettings.PawnFilter.AgeRange.max);

            Widgets.Label(ageLabelRect, labelText);

            var ageRangeRect = ageLabelRect.OffsetBy(0, 18);

            ageRangeRect.width  = 310;
            ageRangeRect.height = 18;
            Widgets.IntRange(ageRangeRect, 20, ref RandomSettings.PawnFilter.AgeRange,
                             PawnFilter.MinAgeDefault, PawnFilter.MaxAgeDefault, "", 2);

            var healthRect = ageRangeRect.OffsetBy(0, 34);

            healthRect.width  = 320;
            healthRect.height = 20;
            Widgets.CheckboxLabeled(healthRect, "No Health Conditions", ref RandomSettings.PawnFilter.NoHealthConditions);

            var dumbLaborRect = healthRect.OffsetBy(0, 24);

            Widgets.CheckboxLabeled(dumbLaborRect, "No Dumb Labor", ref RandomSettings.PawnFilter.NoDumbLabor);
        }
        public static void DrawEditButton()
        {
            Rect editButtonRect = new Rect(620f, 0.0f, 50f, 30f);

            if (Widgets.ButtonText(editButtonRect, "Edit", true, false, true))
            {
                var page = new Page_RandomEditor();
                Find.WindowStack.Add(page);
            }

            Rect   rerollLabelRect = new Rect(620f, 40f, 200f, 30f);
            string labelText       = "Rerolls: " + RandomSettings.RandomRerollCounter() + "/" + RandomSettings.RandomRerollLimit();

            var tmpSave = GUI.color;

            if (RandomSettings.RandomRerollCounter() >= RandomSettings.RandomRerollLimit())
            {
                GUI.color = Color.red;
            }
            Widgets.Label(rerollLabelRect, labelText);
            GUI.color = tmpSave;
        }
Beispiel #5
0
        public override void DoWindowContents(Rect inRect)
        {
            this.DrawPageTitle(inRect);
            Rect mainRect = base.GetMainRect(inRect, 30f, false);

            panelSkills.Draw();
            panelTraits.Draw();

            var randomRerollLimitLabelRect = new Rect(320 + 20, 156 + 40 + 20, 320, 20);

            Widgets.Label(randomRerollLimitLabelRect, "Random Reroll Limit: ");
            var randomRerollLimitRect = new Rect(320 + 20, 156 + 40 + 20 + 20 + 4, 55, 30);

            foreach (var option in RandomSettings.RANDOM_REROLL_LIMIT_OPTIONS)
            {
                bool isSelected = Widgets.RadioButtonLabeled(randomRerollLimitRect, option.ToString(), RandomSettings.RandomRerollLimit() == option);
                if (isSelected)
                {
                    RandomSettings.SetRandomRerollLimit(option);
                }
                randomRerollLimitRect        = new Rect(randomRerollLimitRect);
                randomRerollLimitRect.x     += randomRerollLimitRect.width + 20;
                randomRerollLimitRect.width += 6;
            }

            var ageLabelRect = randomRerollLimitLabelRect.OffsetBy(0, 68);

            ageLabelRect.height = 26;
            string labelText = string.Format("Age: {0}-{1}", RandomSettings.PawnFilter.AgeRange.min, RandomSettings.PawnFilter.AgeRange.max);

            Widgets.Label(ageLabelRect, labelText);

            var ageRangeRect = ageLabelRect.OffsetBy(0, 18);

            ageRangeRect.width  = 310;
            ageRangeRect.height = 18;
            Widgets.IntRange(ageRangeRect, 20, ref RandomSettings.PawnFilter.AgeRange,
                             PawnFilter.MinAgeDefault, PawnFilter.MaxAgeDefault, "", 2);

            var healthRect = ageRangeRect.OffsetBy(0, 34);

            healthRect.width  = 315;
            healthRect.height = 20;
            Widgets.CheckboxLabeled(healthRect, "No Health Conditions", ref RandomSettings.PawnFilter.NoHealthConditions);

            var incapableRect = healthRect.OffsetBy(0, 24);

            Widgets.CheckboxLabeled(incapableRect, "No Incapabilities", ref RandomSettings.PawnFilter.NoIncapabilities);

            var dumbLaborRect = incapableRect.OffsetBy(0, 24);

            Widgets.CheckboxLabeled(dumbLaborRect, "No Dumb Labor Incapability", ref RandomSettings.PawnFilter.NoDumbLabor);

            var genderLabelRect = dumbLaborRect.OffsetBy(0, 30);

            genderLabelRect.width = 87;
            Widgets.Label(genderLabelRect, "Gender:");

            var genderAnyRect = genderLabelRect.OffsetBy(70, 1);

            genderAnyRect.width = 60;
            bool genderIsSelected = Widgets.RadioButtonLabeled(
                genderAnyRect, "Any", RandomSettings.PawnFilter.gender == Gender.None);

            if (genderIsSelected)
            {
                RandomSettings.SetGenderFilter(Gender.None);
            }

            var genderMaleRect = genderAnyRect.OffsetBy(genderAnyRect.width + 20, 0);

            genderMaleRect.width = 65;
            genderIsSelected     = Widgets.RadioButtonLabeled(
                genderMaleRect, "Male", RandomSettings.PawnFilter.gender == Gender.Male);
            if (genderIsSelected)
            {
                RandomSettings.SetGenderFilter(Gender.Male);
            }

            var genderFemaleRect = genderMaleRect.OffsetBy(genderMaleRect.width + 20, 0);

            genderFemaleRect.width = 80;
            genderIsSelected       = Widgets.RadioButtonLabeled(
                genderFemaleRect, "Female", RandomSettings.PawnFilter.gender == Gender.Female);
            if (genderIsSelected)
            {
                RandomSettings.SetGenderFilter(Gender.Female);
            }
        }
Beispiel #6
0
 static void Prefix()
 {
     RandomSettings.ResetRerollCounter();
 }
Beispiel #7
0
        protected override void DrawPanelContent()
        {
            base.DrawPanelContent();

            if (Page_RandomEditor.MOD_WELL_MET)
            {
                Widgets.Label(disabledLabelRect, "RandomPlus.PanelTraits.Disabled".Translate());
                return;
            }

            float cursor = 0;

            GUI.color = Color.white;
            GUI.BeginGroup(RectScrollFrame);
            try
            {
                if (!RandomSettings.PawnFilter.Traits.Any())
                {
                    GUI.color = Style.ColorText;
                    Widgets.Label(RectScrollView.InsetBy(6, 0, 0, 0), "RandomPlus.PanelTraits.NoTraits".Translate());
                }
                GUI.color = Color.white;

                scrollView.Begin(RectScrollView);

                int index = 0;
                foreach (TraitContainer traitContainer in RandomSettings.PawnFilter.Traits)
                {
                    if (index >= fields.Count)
                    {
                        fields.Add(new Field());
                    }
                    Field field = fields[index];

                    GUI.color = Style.ColorPanelBackgroundItem;
                    Rect traitRect = new Rect(0, cursor, SizeTrait.x - (scrollView.ScrollbarsVisible ? 16 : 0), SizeTrait.y);
                    GUI.DrawTexture(traitRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;

                    Rect fieldRect = new Rect(SizeFieldPadding.x, cursor + SizeFieldPadding.y, SizeField.x, SizeField.y);
                    if (scrollView.ScrollbarsVisible)
                    {
                        fieldRect.width = fieldRect.width - 16;
                    }
                    field.Rect = fieldRect;
                    Rect fieldClickRect = fieldRect;
                    fieldClickRect.width = fieldClickRect.width - 36;
                    field.ClickRect      = fieldClickRect;

                    if (traitContainer != null)
                    {
                        field.Label = $"{traitContainer.trait.LabelCap}{LabelForTraitFilter(index)} {RandomSettings.GetTraitRollChanceText(traitContainer.trait.def)}";
                        field.Tip   = traitContainer.trait.CurrentData.description;
                    }
                    else
                    {
                        field.Label = null;
                    }
                    Trait localTrait = traitContainer.trait;
                    int   localIndex = index;
                    field.ClickAction = () =>
                    {
                        Trait originalTrait = localTrait;
                        Trait selectedTrait = originalTrait;
                        ComputeDisallowedTraits(originalTrait);
                        Dialog_Options <Trait> dialog = new Dialog_Options <Trait>(ProviderTraits.Traits)
                        {
                            NameFunc = (Trait t) =>
                            {
                                return(t.LabelCap);
                            },
                            DescriptionFunc = (Trait t) =>
                            {
                                return(t.CurrentData.description);
                            },
                            SelectedFunc = (Trait t) =>
                            {
                                if ((selectedTrait == null || t == null) && selectedTrait != t)
                                {
                                    return(false);
                                }
                                return(selectedTrait.def == t.def && selectedTrait.Label == t.Label);
                            },
                            SelectAction = (Trait t) =>
                            {
                                selectedTrait = t;
                            },
                            EnabledFunc = (Trait t) =>
                            {
                                // filter out conflicting traits
                                return(!(disallowedTraitDefs.Contains(t.def) || disallowedTraitLabels.Contains(t.Label)));
                            },
                            CloseAction = () =>
                            {
                                RandomSettings.PawnFilter.TraitUpdated(localIndex, selectedTrait);
                            },
                            NoneSelectedFunc = () =>
                            {
                                return(selectedTrait == null);
                            },
                            SelectNoneAction = () =>
                            {
                                selectedTrait = null;
                            }
                        };
                        Find.WindowStack.Add(dialog);
                    };
                    //field.PreviousAction = () =>
                    //{
                    //    SelectPreviousTrait(index);
                    //};
                    //field.NextAction = () =>
                    //{
                    //    SelectNextTrait(index);
                    //};
                    field.Draw();

                    // Remove trait button.
                    Rect deleteRect = new Rect(field.Rect.xMax - 32, field.Rect.y + field.Rect.HalfHeight() - 6, 12, 12);
                    if (deleteRect.Contains(Event.current.mousePosition))
                    {
                        GUI.color = Style.ColorButtonHighlight;
                    }
                    else
                    {
                        GUI.color = Style.ColorButton;
                    }
                    GUI.DrawTexture(deleteRect, Textures.TextureButtonDelete);
                    if (Widgets.ButtonInvisible(deleteRect, false))
                    {
                        SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                        traitsToRemove.Add(traitContainer.trait);
                    }

                    //cycling required/ optional / exluded trait filter button
                    Rect traitFilterTypeRect = new Rect(field.Rect.xMax + 12, field.Rect.y + field.Rect.HalfHeight() - 6, 12, 12);
                    GUI.color = traitFilterTypeRect.Contains(Event.current.mousePosition) ?
                                Style.ColorButtonHighlight : Style.ColorButton;
                    GUI.DrawTexture(traitFilterTypeRect, Textures.TextureButtonReset);
                    if (Widgets.ButtonInvisible(traitFilterTypeRect, false))
                    {
                        SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                        CycleTraitFilter(index);
                    }

                    index++;

                    cursor += SizeTrait.y + SizeTraitMargin.y;
                }
                cursor -= SizeTraitMargin.y;
            }
            finally
            {
                scrollView.End(cursor);

                GUI.color = Color.white;
                drawTraitPool();
                GUI.EndGroup();
            }

            // Add trait button.
            Rect addRect = new Rect(PanelRect.width - 24, 12, 16, 16);

            Style.SetGUIColorForButton(addRect);
            int  traitCount       = RandomSettings.PawnFilter.Traits.Count();
            bool addButtonEnabled = (traitCount < ProviderTraits.Traits.Count());

            if (!addButtonEnabled)
            {
                GUI.color = Style.ColorButtonDisabled;
            }
            GUI.DrawTexture(addRect, Textures.TextureButtonAdd);
            if (addButtonEnabled && Widgets.ButtonInvisible(addRect, false))
            {
                ComputeDisallowedTraits(null);
                SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                Trait selectedTrait           = null;
                Dialog_Options <Trait> dialog = new Dialog_Options <Trait>(ProviderTraits.Traits)
                {
                    ConfirmButtonLabel = "RandomPlus.PanelTraits.AddDialog.AddButton".Translate(),
                    NameFunc           = (Trait t) => {
                        return($"{t.LabelCap} {RandomSettings.GetTraitRollChanceText(t.def)}");
                    },
                    DescriptionFunc = (Trait t) => {
                        return(t.CurrentData.description);
                    },
                    SelectedFunc = (Trait t) => {
                        return(selectedTrait == t);
                    },
                    SelectAction = (Trait t) => {
                        selectedTrait = t;
                    },
                    EnabledFunc = (Trait t) => {
                        return(!(disallowedTraitDefs.Contains(t.def) || disallowedTraitLabels.Contains(t.Label)));
                    },
                    CloseAction = () => {
                        if (selectedTrait != null)
                        {
                            RandomSettings.PawnFilter.AddTrait(selectedTrait);
                        }
                    }
                };
                Find.WindowStack.Add(dialog);
            }

            if (traitsToRemove.Count > 0)
            {
                foreach (var trait in traitsToRemove)
                {
                    RandomSettings.PawnFilter.TraitRemoved(trait);
                }
                traitsToRemove.Clear();
            }
        }
Beispiel #8
0
 static void Postfix()
 {
     RandomSettings.Init();
     RandomSettings.ResetRerollCounter();
 }