Ejemplo n.º 1
0
        public override void DoSettingsWindowContents(Rect rect)
        {
            bool threaded = settings.packMultiThreading;

            if (this.settings.enabledRaces == null)
            {
                this.settings.enabledRaces = new Dictionary <string, bool>();
            }
            if (!(settings.enableAirdrops))
            {
                AvaliDefs.AeroWeaveResearch.requiredResearchBuilding  = AvaliDefs.AvaliResearchBench;
                AvaliDefs.AvaliAdvancedGuns.requiredResearchBuilding  = AvaliDefs.AvaliResearchBench;
                AvaliDefs.AvaliAdvancedMelee.requiredResearchBuilding = AvaliDefs.AvaliResearchBench;
                AvaliDefs.AvaliAeroTungsten.requiredResearchBuilding  = AvaliDefs.AvaliResearchBench;
            }
            else
            {
                AvaliDefs.AeroWeaveResearch.requiredResearchBuilding  = AvaliDefs.AvaliNexus;
                AvaliDefs.AvaliAdvancedGuns.requiredResearchBuilding  = AvaliDefs.AvaliNexus;
                AvaliDefs.AvaliAdvancedMelee.requiredResearchBuilding = AvaliDefs.AvaliNexus;
                AvaliDefs.AvaliAeroTungsten.requiredResearchBuilding  = AvaliDefs.AvaliNexus;
            }
            Rect             TopHalf          = rect.TopHalf();
            Rect             TopLeft          = TopHalf.LeftHalf();
            Rect             TopRight         = TopHalf.RightHalf();
            Rect             BottomHalf       = rect.BottomHalf();
            Rect             BottomLeft       = BottomHalf.LeftHalf();
            Rect             BottomRight      = BottomHalf.RightHalf();
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.Begin(TopLeft);
            listing_Standard.Label("PackLabel".Translate());
            listing_Standard.GapLine(10);
            listing_Standard.CheckboxLabeled("PackLossCheck".Translate(), ref settings.packLossEnabled, "PackLossDesc".Translate());
            listing_Standard.CheckboxLabeled("MultithreadingCheck".Translate(), ref settings.packMultiThreading, "MultiThreadingDesc".Translate());
            listing_Standard.CheckboxLabeled("PacksCheck".Translate(), ref settings.packsEnabled, "PacksDesc".Translate());
            listing_Standard.CheckboxLabeled("Enable other avali", ref settings.checkOtherRaces, "Pull any other potential 'avali' races from other mods, and factor them into the pack system. ");

            /* try
             * {
             *   ShowRaces();
             *   foreach (ThingDef race in RimvaliPotentialPackRaces.potentialRaces)
             *   {
             *       bool checkOn = this.settings.enabledRaces.TryGetValue(race.defName);
             *       listing_Standard.CheckboxLabeled(race.label, ref checkOn);
             *       this.settings.enabledRaces.SetOrAdd(race.defName, checkOn);
             *   }
             * }
             * catch
             * {
             *   listing_Standard.GapLine(10);
             *   listing_Standard.Label("RimVali '".Colorize(Color.red) + RimValiUtility.build.Colorize(Color.red) + "' was unable to show this item! We're sorry for any inconvience. :(".Colorize(Color.red));
             *   listing_Standard.CheckboxLabeled("Enable debug mode".Colorize(Color.red), ref settings.enableDebugMode, "It appears RimVali encountered an error. You can use debug mode to return logs with more information on what RimVali was doing. [WIP]".Colorize(Color.red));
             * }*/
            LogDebugOn();
            listing_Standard.Gap(10);
            if ((settings.maxPackSize < 20 & settings.maxPackSize > 10) | settings.maxPackSize < 3)
            {
                settingsAreStable = 1;
            }
            else if (settings.maxPackSize >= 20)
            {
                settingsAreStable = 2;
            }
            else
            {
                settingsAreStable = 0;
            }
            Rect packRacesRect = rect;

            packRacesRect.Set(packRacesRect.x, packRacesRect.y, BottomLeft.width - 20, packRacesRect.height + (RimvaliPotentialPackRaces.potentialRaces.Count() * 17));
            listing_Standard.Label("MaxPackSize".Translate() + settings.maxPackSize.ToString(), -1, "RimVali was made to play this way.".Colorize(Color.green));
            settings.maxPackSize = (int)listing_Standard.Slider(settings.maxPackSize, 2, 50);
            listing_Standard.End();
            listing_Standard.Begin(TopRight);
            listing_Standard.Label("GameplayLabel".Translate());
            listing_Standard.GapLine(10);
            listing_Standard.CheckboxLabeled("CanHaveEggs".Translate(), ref settings.avaliLayEggs, "EggsDesc".Translate());
            listing_Standard.CheckboxLabeled("ShowText".Translate(), ref settings.textEnabled);
            listing_Standard.CheckboxLabeled("AirdropsText".Translate(), ref settings.enableAirdrops);
            listing_Standard.End();
            listing_Standard.Begin(BottomRight);
            listing_Standard.Label("DebugLabel".Translate());
            listing_Standard.GapLine(10);
            if (this.settings.enableDebugMode)
            {
                listing_Standard.GapLine(10);
                listing_Standard.Label("Debug settings");
                listing_Standard.GapLine(10);
                listing_Standard.Label("RVBuild".Translate() + RimValiUtility.build);
                listing_Standard.CheckboxLabeled("Enable map component", ref settings.mapCompOn);
            }

            if (settingsAreStable == 0)
            {
                resetSettings = listing_Standard.ButtonText("StableSettings".Translate());
            }
            else if (settingsAreStable == 1)
            {
                resetSettings = listing_Standard.ButtonText("PotentialIssuesSettings".Translate());
            }
            else
            {
                resetSettings = listing_Standard.ButtonText("UnstableSettings".Translate());
            }
            if (resetSettings)
            {
                settings.maxPackSize     = 5;
                settings.packLossEnabled = true;
                settings.packsEnabled    = true;
                settings.textEnabled     = true;
                settings.checkOtherRaces = true;
                settings.allowAllRaces   = false;
                settings.enableDebugMode = false;
                settings.avaliLayEggs    = false;
            }
            bool debugButton = listing_Standard.ButtonText("ToggleDebug".Translate());

            if (debugButton)
            {
                settings.enableDebugMode = !settings.enableDebugMode;
                debugButton = !debugButton;
            }
            if (!threaded == settings.packMultiThreading)
            {
                settings.Write();
                GenCommandLine.Restart();
            }
            listing_Standard.End();
            listing_Standard.BeginScrollView(BottomLeft, ref vector, ref packRacesRect);
            listing_Standard.Gap(50);
            listing_Standard.Label("RacesInPacks".Translate());
            listing_Standard.GapLine(10);

            try
            {
                ShowRaces();
                foreach (ThingDef race in RimvaliPotentialPackRaces.potentialRaces)
                {
                    bool checkOn = this.settings.enabledRaces.TryGetValue(race.defName);
                    listing_Standard.CheckboxLabeled(race.label, ref checkOn);
                    this.settings.enabledRaces.SetOrAdd(race.defName, checkOn);
                }
            }
            catch
            {
                listing_Standard.GapLine(10);
                listing_Standard.Label("RimVali '".Colorize(Color.red) + RimValiUtility.build.Colorize(Color.red) + "' was unable to show this item! We're sorry for any inconvience. :(".Colorize(Color.red));
                listing_Standard.CheckboxLabeled("Enable debug mode".Colorize(Color.red), ref settings.enableDebugMode, "It appears RimVali encountered an error. You can use debug mode to return logs with more information on what RimVali was doing. [WIP]".Colorize(Color.red));
            }
            listing_Standard.Gap(50);
            listing_Standard.EndScrollView(ref BottomLeft);
            base.DoSettingsWindowContents(rect);
        }
Ejemplo n.º 2
0
        public override void DoSettingsWindowContents(Rect rect)
        {
            Window window   = Find.WindowStack.currentlyDrawnWindow;
            bool   threaded = settings.packMultiThreading;

            if (settings.enabledRaces == null)
            {
                settings.enabledRaces = new Dictionary <string, bool>();
            }


            Rect             TopHalf          = rect.TopHalf();
            Rect             TopLeft          = TopHalf.LeftHalf();
            Rect             TopRight         = TopHalf.RightHalf();
            Rect             BottomHalf       = rect.BottomHalf();
            Rect             BottomLeft       = BottomHalf.LeftHalf();
            Rect             BottomRight      = BottomHalf.RightHalf();
            Listing_Standard listing_Standard = new Listing_Standard();

            //Main page
            if (0 == windowToShow)
            {
                listing_Standard.Begin(rect);
                bool packSettings     = listing_Standard.ButtonText("PackLabel".Translate());
                bool gameplaySettings = listing_Standard.ButtonText("GameplayLabel".Translate());
                bool debug            = listing_Standard.ButtonText("DebugLabel".Translate());
                if (packSettings)
                {
                    windowToShow = 1;
                }
                if (gameplaySettings)
                {
                    windowToShow = 2;
                }
                if (debug)
                {
                    windowToShow = 3;
                }
            }
            //Pack settings
            if (windowToShow == 1)
            {
                listing_Standard.Begin(TopLeft);
                Backbutton(listing_Standard);
                listing_Standard.CheckboxLabeled("PackLossCheck".Translate(), ref settings.packLossEnabled, "PackLossDesc".Translate());
                bool threading = listing_Standard.ButtonText("MultithreadingCheck".Translate() + " " + ((Func <string>) delegate { if (settings.packMultiThreading)
                                                                                                                                   {
                                                                                                                                       return("Y");
                                                                                                                                   }
                                                                                                                                   else
                                                                                                                                   {
                                                                                                                                       return("N");
                                                                                                                                   }; })());
                if (threading)
                {
                    windowToShow = 4;
                }
                listing_Standard.CheckboxLabeled("MultithreadingCheck".Translate(), ref settings.packMultiThreading, "MultiThreadingDesc".Translate());
                listing_Standard.CheckboxLabeled("PacksCheck".Translate(), ref settings.packsEnabled, "PacksDesc".Translate());
                listing_Standard.Label("MaxPackSize".Translate(settings.maxPackSize.Named("COUNT")), -1, "PacksNum".Translate());
                settings.maxPackSize = (int)listing_Standard.Slider(settings.maxPackSize, 2, 50);
                listing_Standard.Label("PackOpinionReq".Translate(settings.packOpReq.Named("COUNT")));
                settings.packOpReq = (int)listing_Standard.Slider(settings.packOpReq, 0, 100);
            }
            //Gameplay settings
            if (windowToShow == 2)
            {
                listing_Standard.Begin(rect);
                Backbutton(listing_Standard);
                listing_Standard.CheckboxLabeled("CanHaveEggs".Translate(), ref settings.avaliLayEggs, "EggsDesc".Translate());

                listing_Standard.CheckboxLabeled("ShowText".Translate(), ref settings.textEnabled, "ShowTextLabel".Translate());
                listing_Standard.CheckboxLabeled("AirdropsText".Translate(), ref settings.enableAirdrops, "AirdropsLabel".Translate());
                listing_Standard.Label("AvaliForDropReq".Translate(settings.avaliRequiredForDrop.Named("COUNT")));
                settings.avaliRequiredForDrop = (int)listing_Standard.Slider(settings.avaliRequiredForDrop, 0, 100);
                listing_Standard.Label("HPScaler".Translate(settings.healthScale.Named("SCALE")));
                settings.healthScale = (float)listing_Standard.Slider(settings.healthScale, 1f, 2.5f);

                listing_Standard.Label("PackLossStageOneSetting".Translate(settings.stageOneDaysPackloss.Named("TIME")));
                settings.stageOneDaysPackloss = (int)listing_Standard.Slider(settings.stageOneDaysPackloss, 1, 100);
                if (settings.stageOneDaysPackloss > settings.stageTwoDaysPackloss)
                {
                    settings.stageTwoDaysPackloss = settings.stageOneDaysPackloss;
                }
                listing_Standard.Label("PackLossStageTwoSetting".Translate(settings.stageTwoDaysPackloss.Named("TIME")));
                settings.stageTwoDaysPackloss = (int)listing_Standard.Slider(settings.stageTwoDaysPackloss, settings.stageOneDaysPackloss, settings.stageThreeDaysPackloss);
                listing_Standard.Label("PackLossStageThreeSetting".Translate(settings.stageThreeDaysPackloss.Named("TIME")));
                if (settings.stageTwoDaysPackloss > settings.stageThreeDaysPackloss)
                {
                    settings.stageThreeDaysPackloss = settings.stageTwoDaysPackloss;
                }
                settings.stageThreeDaysPackloss = (int)listing_Standard.Slider(settings.stageThreeDaysPackloss, settings.stageTwoDaysPackloss, 100);
                listing_Standard.Label("ChanceToHackTech".Translate(settings.hackChance.Named("CHANCE")));
                settings.hackChance = (int)listing_Standard.Slider(settings.hackChance, 0, 100);
            }

            //Debug
            if (windowToShow == 3)
            {
                listing_Standard.Begin(TopLeft);
                Modulefinder.startup();
                listing_Standard.Label("Debug settings");
                listing_Standard.GapLine(10);
                listing_Standard.CheckboxLabeled("ToggleDebug".Translate(), ref settings.enableDebugMode);
                listing_Standard.Label("RVBuild".Translate(RimValiUtility.build.Named("BUILD")));
                listing_Standard.CheckboxLabeled("Enable map component", ref settings.mapCompOn);
                listing_Standard.Label(RimValiUtility.modulesFound);
                Backbutton(listing_Standard);
            }
            //Multithreading reboot warn
            if (windowToShow == 4)
            {
                listing_Standard.Begin(rect);
                listing_Standard.Label("MultiThreadWarnLabel".Translate());
                listing_Standard.Label("MultiThreadWarnDesc".Translate());
                bool ready  = listing_Standard.ButtonText("MultiThreadYes".Translate(), null);
                bool goBack = listing_Standard.ButtonText("MultiThreadNo".Translate());
                if (ready)
                {
                    void UpdateBool(ref bool val)
                    {
                        val = !val;
                    }

                    UpdateBool(ref settings.packMultiThreading);
                    settings.Write();
                    GenCommandLine.Restart();
                }
                if (goBack)
                {
                    windowToShow = 1;
                }
            }
            listing_Standard.End();

            /*
             * else if (settingsAreStable == 1)
             * {
             *    resetSettings = listing_Standard.ButtonText("PotentialIssuesSettings".Translate());
             * }
             * else
             * {
             *    resetSettings = listing_Standard.ButtonText("UnstableSettings".Translate());
             * }
             * if (resetSettings)
             * {
             *    settings.maxPackSize = 5;
             *    settings.packLossEnabled = true;
             *    settings.packsEnabled = true;
             *    settings.textEnabled = true;
             *    settings.checkOtherRaces = true;
             *    settings.allowAllRaces = false;
             *    settings.enableDebugMode = false;
             *    settings.avaliLayEggs = false;
             * }
             *
             * listing_Standard.End();*/
            base.DoSettingsWindowContents(rect);
        }