Exemple #1
0
    public override void Initialize()
    {
        //Tabs
        this.Tabs      = new OpTab[1];
        this.Tabs[0]   = new OpTab("Config");
        this.cycleRect = new OpRect(new Vector2(50f, 325f), new Vector2(500f, 250f), 0.3f);
        //Labels
        Vector2 rectPos = new Vector2(this.cycleRect.GetPos().x - 10f, this.cycleRect.GetPos().y - 5f);

        this.hunterCycles             = new OpLabel(rectPos + new Vector2(23f, this.cycleRect.size.y - 25f), new Vector2(0f, 0f), "HUNTER CYCLES", FLabelAlignment.Left, true);
        this.startCycles              = new OpLabel(new Vector2(rectPos.x + (this.cycleRect.size.x / 2 - 80f), rectPos.y + this.cycleRect.size.y - 180f), new Vector2(0f, 0f), "Starting Cycles", FLabelAlignment.Center, false);
        this.pebblesCycles            = new OpLabel(new Vector2(rectPos.x + (this.cycleRect.size.x / 2 + 80f), rectPos.y + this.cycleRect.size.y - 180f), new Vector2(0f, 0f), "Pebbles Cycles", FLabelAlignment.Center, false);
        this.hunterToggle             = new OpCheckBox(rectPos + new Vector2(this.cycleRect.size.x - 25f, this.cycleRect.size.y - 30f), "hunterToggle", true);
        this.hunterToggle.description = "Toggle custom Hunter cycles";
        this.Tabs[0].AddItems(this.cycleRect, this.hunterCycles, this.startCycles, this.pebblesCycles, this.hunterToggle);
        //Textboxes
        this.startBox   = new OpTextBox(startCycles.GetPos() + new Vector2(-30f, -25f), 80f, "startCycle", "19", OpTextBox.Accept.Int);
        this.pebblesBox = new OpTextBox(pebblesCycles.GetPos() + new Vector2(-30f, -25f), 80f, "pebblesCycle", "5", OpTextBox.Accept.Int);
        this.Tabs[0].AddItems(this.startBox, this.pebblesBox);
        //Presets
        Vector2 presetPos = new Vector2(rectPos.x + 55f, rectPos.y + 90f);

        this.presetDescription         = new OpLabel(rectPos + new Vector2(this.cycleRect.size.x / 2, this.cycleRect.size.y - 74f), new Vector2(0f, 0f), "Choose a preset below or type in the desired cycle count.", FLabelAlignment.Center, false);
        this.presetDefault             = new OpSimpleButton(presetPos + new Vector2(30f, 30f), new Vector2(80f, 30f), "default", "DEFAULT");
        this.presetDefault.description = "Reset cycle numbers to their defaults";
        this.presetEasy             = new OpSimpleButton(presetPos + new Vector2(120f, 30f), new Vector2(80f, 30f), "easy", "EASY");
        this.presetEasy.description = "Start with more cycles, and recieve more from Five Pebbles";
        this.presetHard             = new OpSimpleButton(presetPos + new Vector2(210f, 30f), new Vector2(80f, 30f), "hard", "HARD");
        this.presetHard.description = "Start with less cycles, and recieve less from Five Pebbles";
        this.presetCure             = new OpSimpleButton(presetPos + new Vector2(300f, 30f), new Vector2(80f, 30f), "cure", "CURE");
        this.presetCure.description = "Start with the default number of cycles, but visiting Five Pebbles will essentially cure Hunter's illness";
        //Credits
        this.Tabs[0].AddItems(this.presetDescription, this.presetDefault, this.presetEasy, this.presetHard, this.presetCure);

        //Cycle Length
        this.lengthRect = new OpRect(new Vector2(50f, 30f), new Vector2(500f, 270f), 0.3f);
        Vector2 rect2Pos = new Vector2(this.lengthRect.GetPos().x - 10f, this.lengthRect.GetPos().y - 5f);

        this.cycleLength = new OpLabel(rect2Pos + new Vector2(23f, this.lengthRect.size.y - 25f), new Vector2(0f, 0f), "CYCLE LENGTH", FLabelAlignment.Left, true);

        this.minCycleSlider             = new OpSlider(rect2Pos + new Vector2(50f, this.lengthRect.size.y - 170f), "minLength", new IntVector2(2, 60), 7f, false, 12);
        this.minCycleSlider.colorEdge   = new Color(0f, 1f, 0f);
        this.maxCycleSlider             = new OpSlider(rect2Pos + new Vector2(50f, this.lengthRect.size.y - 210f), "maxLength", new IntVector2(2, 60), 7f, false, 26);
        this.maxCycleSlider.colorEdge   = new Color(1f, 0f, 0f);
        this.fixedCycleSlider           = new OpSlider(rect2Pos + new Vector2(50f, this.lengthRect.size.y - 185f), "fixedLength", new IntVector2(2, 61), 7f, false, 20);
        this.fixedCycleSlider.colorEdge = new Color(0.1f, 0.1f, 1f);

        this.rangeButton              = new OpSimpleButton(rect2Pos + new Vector2(50f, this.lengthRect.size.y - 115f), new Vector2(70f, 30f), "range", "RANGE");
        this.fixedButton              = new OpSimpleButton(rect2Pos + new Vector2(130f, this.lengthRect.size.y - 115f), new Vector2(70f, 30f), "fixed", "FIXED");
        this.timeLabel                = new OpLabel(rect2Pos + new Vector2(this.lengthRect.size.x / 2, this.lengthRect.size.y - 245f), new Vector2(0f, 0f), "X MINUTES", FLabelAlignment.Center, true);
        this.lengthToggle             = new OpCheckBox(rect2Pos + new Vector2(this.lengthRect.size.x - 25f, this.lengthRect.size.y - 30f), "lengthToggle", true);
        this.lengthToggle.description = "Toggle custom cycle length";
        this.lengthDescription        = new OpLabel(rect2Pos + new Vector2(50f, this.lengthRect.size.y - 70f), new Vector2(0f, 0f), "Adjust the possible length a cycle can be or set a fixed length.", FLabelAlignment.Left, false);
        this.fixedLength              = new OpCheckBox(new Vector2(0f, -1000f), "fixedCycle", false);

        this.Tabs[0].AddItems(this.lengthRect, this.cycleLength, this.fixedLength, this.minCycleSlider, this.maxCycleSlider, this.timeLabel, this.rangeButton, this.lengthToggle, this.fixedButton, this.fixedCycleSlider, this.lengthDescription);
    }
        public void ToggleItemsTab(OpTab[] TabList, int tabNum)
        {
            OpRect toggleContainer         = new OpRect(new Vector2(65f, 185f), new Vector2(200f, 302f));
            OpRect descContainer           = new OpRect(new Vector2(263f, 185f), new Vector2(277f, 302f));
            OpRect specialOptionsContainer = new OpRect(new Vector2(65f, 37f), new Vector2(475f, 150f));

            TabList[tabNum].AddItems(toggleContainer);
            TabList[tabNum].AddItems(descContainer);
            TabList[tabNum].AddItems(specialOptionsContainer);
        }
        public void BigTextTab(OpTab[] TabList, int tabNum, string txt, FLabelAlignment alignment = FLabelAlignment.Left)
        {
            OpRect  TextBoxContainer = new OpRect(new Vector2(65f, 37f), new Vector2(475f, 450f));
            OpLabel TextBoxID        = new OpLabel(new Vector2(90f, 60f), new Vector2(424f, 402f), txt, alignment, false)
            {
                autoWrap = true
            };

            TabList[tabNum].AddItems(TextBoxContainer);
            TabList[tabNum].AddItems(TextBoxID);
        }
Exemple #4
0
        public override void Initialize()
        {
            // hopefully all of the 'magic numbers' can be forgiven
            songKeyBindings = new KeyCode[4];

            base.Initialize();
            Tabs    = new OpTab[1];
            Tabs[0] = new OpTab("FMTTM");

            // metadata start
            string modName = FMTTMMod.Instance.Info.Metadata.Name;
            string modVrsn = FMTTMMod.Instance.Info.Metadata.Version.ToString();
            string modAuth = FMTTMMod.Instance.Info.Metadata.GUID.Split('.')[0];

            Tabs[0].AddItems(new UIelement[]
            {
                new OpLabel(new Vector2(50, 550), new Vector2(150, 40), modName, FLabelAlignment.Left, true),
                new OpLabel(new Vector2(228, 552), new Vector2(100, 30), $"by {modAuth}", FLabelAlignment.Left),
                new OpLabel(new Vector2(58, 535), new Vector2(100, 15), $"v{modVrsn}", FLabelAlignment.Left),
                new OpLabel(new Vector2(40, 500), new Vector2(250, 15), "Configure song hotkey for each player below!", FLabelAlignment.Left)
            });
            // metadata end

            // player control config start
            Vector2 rectSize = new Vector2(245, 59);

            int[,] controlConfigBoxCoords = new int[, ]
            {
                { 50, 400 }, { 305, 400 },
                { 50, 330 }, { 305, 330 }
            };

            for (int i = 0; i < controlConfigBoxCoords.GetLength(0); i++)
            {
                // rect's position coords (bottom-left corner)
                Vector2 bl = new Vector2(controlConfigBoxCoords[i, 0], controlConfigBoxCoords[i, 1]);

                OpRect  rect  = new OpRect(bl, rectSize);
                OpLabel label = new OpLabel(
                    new Vector2(bl.x + 5, bl.y + 20),
                    new Vector2(100, 15), $"Player {i + 1}");

                string      keyCodeString = (i == 0) ? KeyCode.C.ToString() : KeyCode.None.ToString();
                OpKeyBinder keyBinder     = new OpKeyBinder(
                    new Vector2(bl.x + 98, bl.y + 7),
                    new Vector2(140, 45), modID: FMTTMMod.Instance.Info.Metadata.GUID, $"player{i + 1}_key",
                    keyCodeString, false, OpKeyBinder.BindController.AnyController);

                Tabs[0].AddItems(new UIelement[] { rect, label, keyBinder });
            }
            // player control config end
        }
        public void AddHeader(OpTab[] TabList, int tabNum, string headerTxt)
        {
            OpLabel headerID         = new OpLabel(new Vector2(62.5f, 530f), new Vector2(475f, 50f), "Primitive Armory".ToUpper(), FLabelAlignment.Center, true);
            OpLabel headerDescID     = new OpLabel(new Vector2(62.5f, 520f), new Vector2(475f, 25f), headerTxt, FLabelAlignment.Center, false);
            OpLabel versionID        = new OpLabel(new Vector2(62.5f, 525f), new Vector2(225f, 40f), "Version: " + Main.instance.Version, FLabelAlignment.Left, false);
            OpLabel authorID         = new OpLabel(new Vector2(312.5f, 525f), new Vector2(225f, 40f), "Author: " + Main.instance.author, FLabelAlignment.Right, false);
            OpRect  optionsContainer = new OpRect(new Vector2(40f, 12f), new Vector2(525f, 500f));
            OpRect  headerContainer  = new OpRect(new Vector2(40f, 512f), new Vector2(525f, 65f));

            TabList[tabNum].AddItems(headerID);
            TabList[tabNum].AddItems(headerDescID);
            TabList[tabNum].AddItems(versionID);
            TabList[tabNum].AddItems(authorID);
            TabList[tabNum].AddItems(optionsContainer);
            TabList[tabNum].AddItems(headerContainer);
        }
Exemple #6
0
    public override void Initialize()
    {
        //Tabs
        this.Tabs    = new OpTab[1];
        this.Tabs[0] = new OpTab("Config");
        //Rect
        OpLabel title  = new OpLabel(240f, 475f, "SCAVSOUT!", true);
        OpLabel author = new OpLabel(167f, 455f, "Created by: LeeMoriya | Idea by: ThreeFingerG", false);
        OpRect  rect   = new OpRect(new UnityEngine.Vector2(140f, 302f), new UnityEngine.Vector2(310f, 140f), 0.3f);

        //Checkboxes
        this.shelterAccess = new OpCheckBox(new UnityEngine.Vector2(160f, 400f), "shelter", true);
        OpLabel shelter = new OpLabel(190f, 402f, "Scavengers are not allowed in shelters", false);

        this.itemPickup = new OpCheckBox(new UnityEngine.Vector2(160f, 360f), "pickup", true);
        OpLabel pickup = new OpLabel(190f, 362f, "Scavengers cannot pick up items in shelters", false);

        this.fleeShelter = new OpCheckBox(new UnityEngine.Vector2(160f, 320f), "flee", true);
        OpLabel flee = new OpLabel(190f, 322f, "Scavengers flee shelters if injured", false);

        this.Tabs[0].AddItems(title, author, rect, this.shelterAccess, this.itemPickup, this.fleeShelter, shelter, pickup, flee);
    }
Exemple #7
0
        public void Initialize() //UI
        {
            if (vanillaMenu != null)
            {
                vanillaMenu.ShutDownProcess();
                vanillaMenu = null;
            }



            if (!redUnlocked)
            {
                this.scene = new InteractiveMenuScene(this, this.pages[0], (MenuScene.SceneID)(bgList[Mathf.FloorToInt(UnityEngine.Random.value * (bgList.Length))]));
            }
            else
            {
                this.scene = new InteractiveMenuScene(this, this.pages[0], (MenuScene.SceneID)(bgListRed[Mathf.FloorToInt(UnityEngine.Random.value * (bgListRed.Length))]));
            }
            Debug.Log(string.Concat("Chosen Background : " + this.scene.sceneID.ToString()));
            this.pages[0].subObjects.Add(this.scene);

            this.fadeSprite.RemoveFromContainer();
            this.pages[0].Container.AddChild(this.fadeSprite); //reset fadeSprite



            this.darkSprite = new FSprite("pixel", true)
            {
                color   = new Color(0f, 0f, 0f),
                anchorX = 0f,
                anchorY = 0f,
                scaleX  = 1368f,
                scaleY  = 770f,
                x       = -1f,
                y       = -1f,
                alpha   = 0.6f
            };
            this.pages[0].Container.AddChild(this.darkSprite);


            modListBound = new OpRect(new Vector2(205f, 225f) - UIelement._offset, new Vector2(280f, 510f), 0.3f);
            //modCanvasBound = new OpRect(new Vector2(553f, 105f), new Vector2(630f, 630f), 0.4f);
            modCanvasBound = new OpRect(new Vector2(533f, 105f) - UIelement._offset, new Vector2(630f, 630f), 0.4f);
            //Base: new Vector2(468f, 120f);
            menuTab.AddItems(modListBound, modCanvasBound);
            this.pages[0].subObjects.Add(modListBound.rect);
            this.pages[0].subObjects.Add(modCanvasBound.rect);



            this.backButton = new SimpleButton(this, this.pages[0], "BACK", "CANCEL", new Vector2(450f, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.backButton);
            this.saveButton = new SimpleButton(this, this.pages[0], "APPLY", "APPLY", new Vector2(600f, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.saveButton);
            base.MutualHorizontalButtonBind(saveButton, backButton);
            this.resetButton = new HoldButton(this, this.pages[0], "RESET CONFIG", "RESET CONFIG", new Vector2(300f, 90f), 30f);
            this.pages[0].subObjects.Add(this.resetButton);

            //Dark Box for ModList & Canvas
            //modlist x200 y400 w240 h600
            //canvas  x568 y120 w600 h600

            this.resetButton.nextSelectable[2] = this.backButton;
            this.backButton.nextSelectable[0]  = this.resetButton;
            this.backButton.nextSelectable[2]  = this.saveButton;
            this.saveButton.nextSelectable[0]  = this.backButton;



            modButtons = new SelectOneButton[OptionScript.loadedModsDictionary.Count]; //<==MenuLabel
            int i = 0; selectedModIndex = 0;
            Dictionary <int, string> dictionary  = new Dictionary <int, string>(modButtons.Length);
            Dictionary <int, bool>   dictionary0 = new Dictionary <int, bool>(modButtons.Length);

            foreach (string id in OptionScript.loadedModsDictionary.Keys)
            {
                modButtons[i] = new SelectOneButton(this, this.pages[0], id, "ModSelect", new Vector2(220f, 700f - 30f * i), new Vector2(250f, 24f), modButtons, i);

                this.pages[0].subObjects.Add(modButtons[i]);

                dictionary.Add(i, id);
                Debug.Log(string.Concat("Mod(" + i + ") : " + id));
                OptionInterface itf = OptionScript.loadedInterfaceDict[id];
                try
                {
                    itf.Initialize();
                }
                catch (Exception ex)
                {
                    itf = new UnconfiguableOI(itf.mod, new Exception(string.Concat("OIinitializeError: ", id, " had a problem in Initialize().",
                                                                                   Environment.NewLine, ex
                                                                                   )));
                    OptionScript.loadedInterfaceDict.Remove(id);
                    OptionScript.loadedInterfaceDict.Add(id, itf);
                    itf.Initialize();
                }


                if (itf.Tabs == null || itf.Tabs.Length < 1)
                {
                    itf = new UnconfiguableOI(itf.mod, new Exception(string.Concat("TabIsNull: ", id, " OI has No OpTabs! ",
                                                                                   Environment.NewLine, "Did you put base.Initialize() after your code?",
                                                                                   Environment.NewLine, "Leaving OI.Initialize() completely blank will prevent the mod from using LoadData/SaveData."
                                                                                   )));
                    OptionScript.loadedInterfaceDict.Remove(id);
                    OptionScript.loadedInterfaceDict.Add(id, itf);
                    itf.Initialize();
                }
                else if (itf.Tabs.Length > 20)
                {
                    itf = new UnconfiguableOI(itf.mod, new Exception("Too Many Tabs! D: Maximum tab number is 20.\nAlso what are you going to do with all those settings?"));
                    OptionScript.loadedInterfaceDict.Remove(id);
                    OptionScript.loadedInterfaceDict.Add(id, itf);
                    itf.Initialize();
                }

                try
                {
                    itf.LoadConfig();
                    itf.ShowConfig();
                }
                catch (Exception ex)
                {
                    itf = new UnconfiguableOI(itf.mod, new Exception(string.Concat("OILoad/ShowConfigError: ", id, " had a problem in Load/ShowConfig()\nAre you editing LoadConfig()/ShowConfig()? That could cause serious error.",
                                                                                   Environment.NewLine, ex
                                                                                   )));
                    OptionScript.loadedInterfaceDict.Remove(id);
                    OptionScript.loadedInterfaceDict.Add(id, itf);
                    itf.Initialize();

                    itf.LoadConfig();
                    itf.ShowConfig();
                }

                dictionary0.Add(i, itf.Configuable());


                for (int t = 0; t < itf.Tabs.Length; t++)
                {
                    OptionScript.tabs.Add(string.Concat(i.ToString("D3") + "_" + t.ToString("D2")), itf.Tabs[t]);
                    foreach (UIelement element in itf.Tabs[t].items)
                    {
                        foreach (MenuObject obj in element.subObjects)
                        {
                            this.pages[0].subObjects.Add(obj);
                        }
                        this.pages[0].Container.AddChild(element.myContainer);
                    }
                    itf.Tabs[t].Hide();
                }

                i++;
            }
            modList           = dictionary;
            modConfiguability = dictionary0;


            this.resetButton.nextSelectable[1] = this.modButtons[this.modButtons.Length - 1];
            this.backButton.nextSelectable[1]  = this.modButtons[this.modButtons.Length - 1];
            this.saveButton.nextSelectable[1]  = this.modButtons[this.modButtons.Length - 1];
            this.modButtons[this.modButtons.Length - 1].nextSelectable[3] = this.saveButton;
            if (this.modButtons.Length > 1)
            {
                for (int m = 0; m < this.modButtons.Length - 1; m++)
                {
                    this.modButtons[m].nextSelectable[3]     = this.modButtons[m + 1];
                    this.modButtons[m + 1].nextSelectable[1] = this.modButtons[m];
                }
            }



            //Load Tab
            selectedTabIndex = 0;
            currentInterface = OptionScript.loadedInterfaceDict[modList[0]];
            currentTab       = OptionScript.tabs[string.Concat(selectedModIndex.ToString("D3") + "_" + selectedTabIndex.ToString("D2"))];

            currentTab.Show();
            if (currentInterface.Configuable())
            {
                saveButton.buttonBehav.greyedOut  = false;
                resetButton.buttonBehav.greyedOut = false;
            }
            else
            {
                saveButton.buttonBehav.greyedOut  = true;
                resetButton.buttonBehav.greyedOut = true;
            }


            tabCtrler = new ConfigTabController(new Vector2(493f, 120f) - UIelement._offset, new Vector2(40f, 600f), menuTab, this);
            menuTab.AddItems(tabCtrler);
            foreach (MenuObject obj in tabCtrler.subObjects)
            {
                this.pages[0].subObjects.Add(obj);
            }

            this.selectedObject = this.backButton;


            OptionScript.configChanged = false;
        }
Exemple #8
0
        public override void Initialize()
        {
            Tabs    = new OpTab[1];
            Tabs[0] = new OpTab();

            if (this.reason == Reason.NoMod)
            {
                TutoInit();
                return;
            }

            //Futile.atlasManager.LogAllElementNames();

            labelID      = new OpLabel(new Vector2(100f, 500f), new Vector2(400f, 50f), mod.ModID, FLabelAlignment.Center, true);
            labelVersion = new OpLabel(new Vector2(100f, 450f), new Vector2(100f, 20f), string.Concat("Version: ", mod.Version), FLabelAlignment.Left);
            Tabs[0].AddItems(labelID, labelVersion);
            if (mod.author != "NULL")
            {
                labelAuthor = new OpLabel(new Vector2(350f, 450f), new Vector2(200f, 20f), string.Concat("Author: ", mod.author), FLabelAlignment.Right);
                Tabs[0].AddItems(labelAuthor);
                labelAuthor.autoWrap = true;
            }

            /*
             * if (mod.coauthor != "NULL")
             * {
             *  labelCoauthor = new OpLabel(new Vector2(100f, 420f), new Vector2(300f, 20f), string.Concat("Coautor: ", mod.coauthor));
             *  Tabs[0].AddItem(labelCoauthor);
             *  labelCoauthor.autoWrap = true;
             * }
             * if(mod.description != "NULL")
             * {
             *  labelDesc = new OpLabel(new Vector2(80f, 350f), new Vector2(340f, 20f), mod.description, FLabelAlignment.Left);
             *  Tabs[0].AddItem(labelDesc);
             *  labelDesc.autoWrap = true;
             * }*/


            switch (this.reason)
            {
            case Reason.NoInterface:
                labelSluggo0 = new OpLabel(new Vector2(100f, 200f), new Vector2(400f, 20f), "This Partiality Mod/Patch cannot be configured.");
                Tabs[0].AddItems(labelSluggo0);

                break;

            case Reason.InitError:
                blue = new OpRect(new Vector2(40f, 40f), new Vector2(520f, 340f))
                {
                    alpha = 0.7f
                };
                if (OptionScript.init)
                {
                    for (int j = 0; j < 9; j++)
                    {
                        blue.rect.sprites[j].color = new Color(0.121568627f, 0.40392156862f, 0.69411764705f, 1f);
                    }
                }
                Color white = Menu.Menu.MenuRGB(Menu.Menu.MenuColors.White);
                oof = new OpLabel(new Vector2(100f, 320f), new Vector2(30f, 40f), ":(", FLabelAlignment.Left, true)
                {
                    color = white
                };
                labelSluggo0 = new OpLabel(new Vector2(100f, 320f), new Vector2(400f, 20f), "There was an issue initializing OptionInterface.")
                {
                    color = white
                };
                labelSluggo1 = new OpLabel(new Vector2(100f, 80f), new Vector2(400f, 240f), exception, FLabelAlignment.Left)
                {
                    autoWrap = true,
                    color    = white
                };
                labelSluggo1.OnChange();

                Tabs[0].AddItems(blue, oof, labelSluggo0, labelSluggo1);

                break;
            }
        }
Exemple #9
0
#pragma warning restore IDE0060
#pragma warning restore CA1822

        public override void Initialize()
        {
            if (this.reason == Reason.TooManyMod)
            {
                ListMods();
                return;
            }

            Tabs    = new OpTab[1];
            Tabs[0] = new OpTab();

            if (this.reason == Reason.NoMod)
            {
                TutoInit();
                return;
            }

            GeneratedOI.AddBasicProfile(Tabs[0], rwMod);

            switch (this.reason)
            {
            case Reason.NoInterface:
                if (rwMod.description != RainWorldMod.authorNull)
                {
                    Tabs[0].AddItems(new OpLabelLong(new Vector2(50f, 200f), new Vector2(500f, 250f), rwMod.description, alignment: FLabelAlignment.Center));
                    labelSluggo0 = new OpLabel(new Vector2(100f, 150f), new Vector2(400f, 20f),
                                               InternalTranslator.Translate(rwMod.type == RainWorldMod.Type.PartialityMod ? "This Partiality Mod has no Option Interface." : "This BepInEx Plugin has no Option Interface."));
                }
                else
                {
                    labelSluggo0 = new OpLabel(new Vector2(100f, 350f), new Vector2(400f, 20f),
                                               InternalTranslator.Translate(rwMod.type == RainWorldMod.Type.PartialityMod ? "This Partiality Mod has no Option Interface." : "This BepInEx Plugin has no Option Interface."));
                }

                Tabs[0].AddItems(labelSluggo0);

                break;

            case Reason.InitError:
                blue = new OpRect(new Vector2(30f, 20f), new Vector2(540f, 420f))
                {
                    alpha = 0.7f, colorFill = new Color(0.121568627f, 0.40392156862f, 0.69411764705f, 1f)
                };

                Color white = Menu.Menu.MenuRGB(Menu.Menu.MenuColors.White);
                oof = new OpLabel(new Vector2(100f, 380f), new Vector2(30f, 40f), ":(", FLabelAlignment.Left, true)
                {
                    color = white
                };
                labelSluggo0 = new OpLabel(new Vector2(150f, 390f), new Vector2(300f, 20f), InternalTranslator.Translate("There was an issue initializing OptionInterface."))
                {
                    color = white
                };
                labelSluggo1 = new OpLabelLong(new Vector2(50f, 40f), new Vector2(500f, 320f), exception)
                {
                    color = white, allowOverflow = false
                };
                labelVersion = new OpLabel(new Vector2(50f, 480f), new Vector2(100f, 20f), string.Concat(Environment.NewLine, "Config Machine ", MenuTab.GetCMVersion()), FLabelAlignment.Left);

                Tabs[0].AddItems(blue, oof, labelSluggo0, labelSluggo1, labelVersion);

                break;
            }
        }
        private void CreateRegionPackList(OpTab tab, Dictionary <string, RegionPack> packs, Dictionary <string, byte[]> thumbnails, bool raindb)
        {
            //How Many Options
            int numberOfOptions = packs.Count;

            if (numberOfOptions < 1)
            {
                OpLabel label2 = new OpLabel(new Vector2(100f, 450), new Vector2(400f, 20f), "No regions available.", FLabelAlignment.Center, false);
                if (raindb && CustomWorldMod.OfflineMode)
                {
                    label2.text = "Browsing RainDB is not available in offline mode";
                }
                tab.AddItems(label2);
                return;
            }

            int spacing = 25;

            // SIZES AND POSITIONS OF ALL ELEMENTS //
            Vector2     rectSize           = new Vector2(475, 175);
            Vector2     thumbSize          = new Vector2(225, 156);
            Vector2     buttonDownloadSize = new Vector2(80, 30);
            Vector2     labelSize          = new Vector2(rectSize.x - thumbSize.x - 1.5f * spacing, 25);
            Vector2     descripSize        = new Vector2(rectSize.x - thumbSize.x - 1.5f * spacing, rectSize.y - labelSize.y - buttonDownloadSize.y);
            OpScrollBox mainScroll         = new OpScrollBox(new Vector2(25, 25), new Vector2(550, 500), (int)(spacing + ((rectSize.y + spacing) * numberOfOptions)));
            Vector2     rectPos            = new Vector2(spacing, mainScroll.contentSize - rectSize.y - spacing);

            // ---------------------------------- //

            tab.AddItems(mainScroll);

            for (int i = 0; i < numberOfOptions; i++)
            {
                RegionPack pack      = packs.ElementAt(i).Value;
                bool       activated = pack.activated;
                bool       update    = false;
                try
                {
                    update = raindb && !activated && pack.checksum != null && pack.checksum != string.Empty && !pack.checksum.Equals(CustomWorldMod.installedPacks[pack.name].checksum);
                }
                catch { CustomWorldMod.Log("Error checking the checksum for updates"); }
                Color colorEdge    = activated ? Color.white : new Color((108f / 255f), 0.001f, 0.001f);
                Color colorInverse = Color.white;

                /*
                 * if (raindb)
                 * {
                 *  colorEdge = Color.white;
                 *  try
                 *  {
                 *      // Online checksum is different from local, needs to be updated.
                 *      if (!activated && pack.checksum != null && pack.checksum != string.Empty)
                 *      {
                 *          update = !pack.checksum.Equals(CustomWorldMod.installedPacks[pack.name].checksum);
                 *      }
                 *  }
                 *  catch { CustomWorldMod.Log("Error checking the checksum for updates"); }
                 * }
                 */

                // RECTANGLE
                OpRect rectOption = new OpRect(rectPos, rectSize, 0.2f)
                {
                    doesBump = activated && !pack.packUrl.Equals(string.Empty)
                };
                mainScroll.AddItems(rectOption);
                // ---------------------------------- //


                // REGION NAME LABEL
                string nameText = pack.name;
                if (!pack.author.Equals(string.Empty))
                {
                    nameText += " [by " + pack.author.ToUpper() + "]";
                }
                OpLabel labelRegionName = new OpLabel(rectPos + new Vector2(thumbSize.x + spacing, 140), labelSize, "", FLabelAlignment.Left)
                {
                    description = nameText
                };

                // Add load order number if local pack
                if (!raindb)
                {
                    nameText = (i + 1).ToString() + "] " + nameText;
                }
                // Trim in case of overflow
                CRExtras.TrimString(ref nameText, labelSize.x, "...");
                labelRegionName.text = nameText;
                mainScroll.AddItems(labelRegionName);
                // ---------------------------------- //


                // DESCRIPTION LABEL
                OpLabelLong labelDesc = new OpLabelLong(rectPos + new Vector2(spacing + thumbSize.x, (rectSize.y - descripSize.y - labelSize.y - 0.5f * spacing)), descripSize, "", true, FLabelAlignment.Left)
                {
                    text = pack.description,
                    verticalAlignment = OpLabel.LabelVAlignment.Top,
                    allowOverflow     = false
                };
                mainScroll.AddItems(labelDesc);
                // ---------------------------------- //

                if (thumbnails.TryGetValue(pack.name, out byte[] fileData) && fileData.Length > 0)
Exemple #11
0
    public override void Initialize()
    {
        regionList = RegionFinder.Generate().ToArray();

        //Tabs
        this.Tabs    = new OpTab[1];
        this.Tabs[0] = new OpTab("Weather");

        //Weather Type
        this.logo             = new OpImage(new Vector2(270f, 540f), "logo");
        this.logo2            = new OpImage(new Vector2(270f, 540f), "logo2");
        this.weatherType      = new OpRadioButtonGroup("Type", 0);
        this.weatherTypeLabel = new OpLabel(new Vector2(30f, 570f), new Vector2(400f, 40f), "Weather Type", FLabelAlignment.Left, true);
        this.rainWeather      = new OpRadioButton(new Vector2(0f, 800f));
        this.rainButton       = new OpSimpleButton(new Vector2(30f, 540f), new Vector2(70f, 25f), "rainButton", "Rain");
        this.snowWeather      = new OpRadioButton(new Vector2(0f, 800f));
        this.snowButton       = new OpSimpleButton(new Vector2(130f, 540f), new Vector2(70f, 25f), "snowButton", "Snow");
        this.weatherType.SetButtons(new OpRadioButton[] { rainWeather, snowWeather });
        //this.weatherType.valueInt = 1;
        this.versionNumber     = new OpLabel(new Vector2(10f, -5f), new Vector2(0f, 0f), "Version: " + Downpour.mod.Version, FLabelAlignment.Left, false);
        this.snowWarning       = new OpLabel(305f, 525f, "Snow is experimental, use at your own risk!", false);
        this.snowWarning.color = new Color(0.85f, 0f, 0f);
        this.Tabs[0].AddItems(rainButton, rainWeather, snowWeather, snowButton, weatherType, weatherTypeLabel, versionNumber, snowWarning);

        //Weather Sliders
        this.rainIntensity                = new OpLabel(new Vector2(topAnchor.x, topAnchor.y), new Vector2(400f, 40f), "Rain Settings", FLabelAlignment.Left, true);
        this.intensitySliderLabel         = new OpLabel(new Vector2(topAnchor.x + 40f, topAnchor.y - 83f), new Vector2(400f, 40f), "Weather Progression", FLabelAlignment.Left, false);
        this.weatherIntensity             = new OpSlider(new Vector2(topAnchor.x + 25, topAnchor.y - 60f), "weatherIntensity", new IntVector2(0, 3), 50f, false, 0);
        this.rainSettingsDescription      = new OpLabel(new Vector2(topAnchor.x, topAnchor.y - 20f), new Vector2(400f, 40f), "Enable or disable rain specific settings:", FLabelAlignment.Left, false);
        this.directionSliderLabel         = new OpLabel(new Vector2(topAnchor.x + 47f, topAnchor.y - 143f), new Vector2(400f, 40f), "Weather Direction", FLabelAlignment.Left, false);
        this.weatherDirection             = new OpSlider(new Vector2(topAnchor.x + 25, topAnchor.y - 120f), "weatherDirection", new IntVector2(0, 3), 50f, false, 0);
        this.rainChanceLabel              = new OpLabel(new Vector2(topAnchor.x + 47f, topAnchor.y - 203f), new Vector2(400f, 40f), "Weather Chance", FLabelAlignment.Left, false);
        this.rainChanceSlider             = new OpSlider(new Vector2(topAnchor.x + 25, topAnchor.y - 180f), "weatherChance", new IntVector2(0, 100), 1.5f, false, 100);
        this.weatherIntensity.description = "Configure whether the intensity of the chosen weather increases as the cycle progresses or fix it to a certain intensity.";
        this.weatherDirection.description = "Configure whether rain should fall towards a random or chosen direction.";
        this.rainChanceSlider.description = "Configure whether the chosen weather will occur during a cycle.";
        this.topRect = new OpRect(new Vector2(15f, 250f), new Vector2(570f, 270f), 0.1f);
        this.Tabs[0].AddItems(rainIntensity, weatherIntensity, intensitySliderLabel, directionSliderLabel, weatherDirection, topRect, logo, logo2, rainChanceSlider, rainChanceLabel);

        //Checkboxes
        this.lightningCheck             = new OpCheckBox(new Vector2(checkAnchor.x, checkAnchor.y - 30f), "Lightning", false);
        this.lightningLabel             = new OpLabel(new Vector2(checkAnchor.x + 30f, checkAnchor.y - 36f), new Vector2(400f, 40f), "Lightning", FLabelAlignment.Left, false);
        this.paletteCheck               = new OpCheckBox(new Vector2(checkAnchor.x, checkAnchor.y + 10), "Palette", true);
        this.paletteLabel               = new OpLabel(new Vector2(checkAnchor.x + 30f, checkAnchor.y + 4f), new Vector2(400f, 40f), "Palette changes", FLabelAlignment.Left, false);
        this.muteCheck                  = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y + 10), "Mute", false);
        this.muteLabel                  = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y + 4f), new Vector2(400f, 40f), "Mute interiors", FLabelAlignment.Left, false);
        this.waterCheck                 = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y - 30f), "Water", false);
        this.waterLabel                 = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y - 36f), new Vector2(400f, 40f), "Water ripples", FLabelAlignment.Left, false);
        this.strikeCheck                = new OpCheckBox(new Vector2(checkAnchor.x, checkAnchor.y - 70f), "Strike", true);
        this.strikeLabel                = new OpLabel(new Vector2(checkAnchor.x + 30f, checkAnchor.y - 76f), new Vector2(400f, 40f), "Lightning Strikes", FLabelAlignment.Left, false);
        this.strikeDamage               = new OpSliderSubtle(new Vector2(checkAnchor.x + 10f, checkAnchor.y - 105f), "Damage", new IntVector2(0, 2), 110, false, 1);
        this.damageLabel                = new OpLabel(new Vector2(checkAnchor.x + 10f, checkAnchor.y - 123f), new Vector2(), "Damage Type: ", FLabelAlignment.Left, false);
        this.bgOn                       = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y - 70f), "Background", true);
        this.bgLabel                    = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y - 76f), new Vector2(400f, 40f), "Background", FLabelAlignment.Left, false);
        this.decalCheck                 = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y - 30f), "Decals", true);
        this.decalLabel                 = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y - 36f), new Vector2(400f, 40f), "Surface decals", FLabelAlignment.Left, false);
        this.dustCheck                  = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y - 70f), "Dust", true);
        this.dustLabel                  = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y - 76f), new Vector2(400f, 40f), "Snow dust", FLabelAlignment.Left, false);
        this.blizzardCheck              = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y - 110f), "Blizzard", true);
        this.blizzardLabel              = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y - 116f), new Vector2(400f, 40f), "Blizzard", FLabelAlignment.Left, false);
        this.effectCheck                = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y + 10), "Effect", true);
        this.effectLabel                = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y + 4f), new Vector2(400f, 40f), "Effect Colors", FLabelAlignment.Left, false);
        this.dustCheck.description      = "Puffs of snow appear when landing on the ground.";
        this.decalCheck.description     = "Adds snowy decals to surfaces.";
        this.lightningCheck.description = "Lightning will appear at higher weather intensities.";
        this.paletteCheck.description   = "The region will become darker with higher rain intensity.";
        this.muteCheck.description      = "Mute the sound effect added to interiors when its raining outside.";
        this.waterCheck.description     = "Rain drops can interact with water surfaces and cause ripples, may impact performance.";
        this.bgOn.description           = "Enable or disable collision with background elements, may impact performance.";
        this.strikeDamage.description   = "Adjust the damage type of Lightning Strikes";
        this.strikeCheck.description    = "When weather intensity is high enough, lightning strikes can occur.";
        this.effectCheck.description    = "Whitens things like plants and signs so they better match the snowy palette, can ruin some custom props";
        this.blizzardCheck.description  = "Replaces the end-of-cycle rain with a roaring blizzard and affects normal gameplay";
        this.Tabs[0].AddItems(lightningLabel, lightningCheck, strikeCheck, strikeLabel, strikeDamage, damageLabel, rainSettingsDescription, paletteCheck, muteCheck, waterCheck, bgOn, paletteLabel, muteLabel, waterLabel, bgLabel, dustCheck, dustLabel, decalCheck, decalLabel, effectCheck, effectLabel, blizzardCheck, blizzardLabel);

        //Particle Limit
        this.rainOption = new OpLabel(new Vector2(topAnchor.x + 366f, topAnchor.y - 223f), new Vector2(400f, 40f), "Particle Limit", FLabelAlignment.Left, false);
        this.rainSlider = new OpSlider(new Vector2(topAnchor.x + 275f, topAnchor.y - 200f), "rainAmount", new IntVector2(10, 80), 3.3f, false, 50);
        this.Tabs[0].AddItems(rainSlider, rainOption);

        //Regions
        if (regionList != null)
        {
            this.regionLabelList   = new OpLabel[regionList.Length];
            this.regionChecks      = new OpCheckBox[regionList.Length];
            this.regionLabel       = new OpLabel(new Vector2(30f, 200f), new Vector2(400f, 40f), "Region Settings", FLabelAlignment.Left, true);
            this.regionDescription = new OpLabel(new Vector2(30f, 175f), new Vector2(400f, 40f), "Enable and Disable weather on a per-region basis.", FLabelAlignment.Left, false);
            this.Tabs[0].AddItems(regionLabel, regionDescription);
            for (int i = 0; i < regionList.Length; i++)
            {
                if (i < 10)
                {
                    regionChecks[i]    = new OpCheckBox(new Vector2(30f + (55f * i), 150f), regionList[i], true);
                    regionLabelList[i] = new OpLabel(new Vector2(60f + (55f * i), 142f), new Vector2(400f, 40f), regionList[i], FLabelAlignment.Left, false);
                }
                else if (i >= 10 && i < 20)
                {
                    regionChecks[i]    = new OpCheckBox(new Vector2(-520f + (55f * i), 105f), regionList[i], true);
                    regionLabelList[i] = new OpLabel(new Vector2(-490f + (55f * i), 97f), new Vector2(400f, 40f), regionList[i], FLabelAlignment.Left, false);
                }
                else if (i >= 20 && i < 30)
                {
                    regionChecks[i]    = new OpCheckBox(new Vector2(-1070f + (55f * i), 60f), regionList[i], true);
                    regionLabelList[i] = new OpLabel(new Vector2(-1040f + (55f * i), 52f), new Vector2(400f, 40f), regionList[i], FLabelAlignment.Left, false);
                }
                else if (i >= 30)
                {
                    regionChecks[i]    = new OpCheckBox(new Vector2(-1650f + (55f * i), 15f), regionList[i], true);
                    regionLabelList[i] = new OpLabel(new Vector2(-1620f + (55f * i), 7f), new Vector2(400f, 40f), regionList[i], FLabelAlignment.Left, false);
                }
                this.Tabs[0].AddItems(regionLabelList[i], regionChecks[i]);
                if (regionList[i] == "SS")
                {
                    regionChecks[i].valueBool = false;
                }
            }
        }
        Downpour.configLoaded = true;
    }
Exemple #12
0
    public override void Initialize()
    {
        //Create a copy of the creature color dictionary that will be modified by the config screen
        this.configColors = new Dictionary <string, Color>(BloodMod.creatureColors);
        this.Tabs         = new OpTab[1];
        int num  = 0;
        int num2 = 0;
        int num3 = 0;
        int num4 = 0;

        this.Tabs[0]                  = new OpTab("Options");
        this.creatureLabel            = new OpLabel(new Vector2(490f, 375f), new Vector2(0f, 0f), "None Selected", FLabelAlignment.Center, true);
        this.colorPicker              = new OpColorPicker(new Vector2(250f, 250f), "bloodColor");
        this.previewOld               = new OpImage(new Vector2(250f, 150f), "Futile_White");
        this.previewOld.sprite.scaleX = 10f;
        this.previewOld.sprite.scaleY = 4f;
        this.oldLabel                 = new OpLabel(new Vector2(250f, 220f), new Vector2(0f, 0f), "Default", FLabelAlignment.Left, true);
        this.previewNew               = new OpImage(new Vector2(420f, 150f), "Futile_White");
        this.previewNew.sprite.scaleX = 10f;
        this.previewNew.sprite.scaleY = 4f;
        this.newLabel                 = new OpLabel(new Vector2(420f, 220f), new Vector2(0f, 0f), "Modified", FLabelAlignment.Left, true);
        this.resetButton              = new OpSimpleButton(new Vector2(425f, 305f), new Vector2(150f, 45f), "reset", "Reset to Default");
        this.resetButton.description  = "Reset this creature's blood color to the mod's default.";
        this.modName                  = new OpLabel(new Vector2(400f, 552f), new Vector2(0f, 0f), "BLOOD MOD", FLabelAlignment.Center, true);
        this.modCredit                = new OpLabel(new Vector2(400f, 532f), new Vector2(0f, 0f), "Created by LeeMoriya", FLabelAlignment.Center, false);
        this.modVersion               = new OpLabel(new Vector2(400f, 518f), new Vector2(0f, 0f), "Version: 1.01", FLabelAlignment.Center, false);
        this.rect                        = new OpRect(new Vector2(230f, 130f), new Vector2(370f, 360f), 0f);
        this.guide                       = new OpLabel(new Vector2(405f, 462f), new Vector2(0f, 0f), "Select creatures on the left and adjust their blood color using", FLabelAlignment.Center, false);
        this.guide2                      = new OpLabel(new Vector2(405f, 442f), new Vector2(0f, 0f), "the color picker below. Finalize changes by clicking 'Apply'", FLabelAlignment.Center, false);
        this.bloodPreview                = new OpCheckBox(new Vector2(30f, 2f), "_prev", false);
        this.bloodPreviewLabel           = new OpLabel(new Vector2(66f, 5f), new Vector2(0f, 0f), "Preview all blood colors", FLabelAlignment.Left, false);
        this.selectedSprite              = new OpImage(new Vector2(0f, 0f), "Futile_White");
        this.selectedSprite.sprite.scale = 17f;
        this.selectedSprite.sprite.alpha = 0.05f;
        this.selectedSprite.description  = "?";
        this.selectedSprite.sprite.SetAnchor(new Vector2(0.5f, 0.5f));
        this.realisticPreset             = new OpSimpleButton(new Vector2(265f, 85f), new Vector2(130f, 31f), "real", "Realistic Preset");
        this.vibrantPreset               = new OpSimpleButton(new Vector2(435f, 85f), new Vector2(130f, 31f), "vibrant", "Vibrant Preset");
        this.realisticPreset.description = "Blood colors will be more realistic.";
        this.vibrantPreset.description   = "Blood colors will more closely match the creature's color.";
        this.bloodlust             = new OpCheckBox(new Vector2(265f, 45f), "gore", false);
        this.bloodlust.description = "Blood effects are increased dramatically";
        this.bloodlustLabel        = new OpLabel(new Vector2(295f, 48f), new Vector2(), "Bloodlust Mode", FLabelAlignment.Left, false);
        this.compat             = new OpCheckBox(new Vector2(265f, 12f), "wash", false);
        this.compat.description = "Rainfall from the mod Downpour will wash away blood.";
        this.compatLabel        = new OpLabel(new Vector2(295f, 15f), new Vector2(), "Downpour Compatibility", FLabelAlignment.Left, false);
        this.preset             = new OpCheckBox(new Vector2(), "preset", false);
        foreach (PartialityMod mod in PartialityManager.Instance.modManager.loadedMods)
        {
            if (mod.ModID == "Downpour")
            {
                this.Tabs[0].AddItems(this.compat, this.compatLabel);
            }
        }
        this.Tabs[0].AddItems(this.selectedSprite, this.colorPicker, this.creatureLabel, this.previewOld, this.previewNew, this.oldLabel, this.newLabel, this.resetButton, this.bloodPreviewLabel, this.modName, this.modCredit, this.rect, this.guide, this.guide2, this.modVersion, this.bloodPreview, this.realisticPreset, this.vibrantPreset, this.bloodlust, this.bloodlustLabel, this.preset);
        //Create individual buttons/sprites/color pickers for each creature
        foreach (KeyValuePair <string, Color> creature in this.configColors)
        {
            if (creature.Key != "Overseer")
            {
                if (num < 11)
                {
                    OpColorPicker  picker = new OpColorPicker(new Vector2(250f, 270f), creature.Key, OpColorPicker.ColorToHex(BloodMod.defaultColors[creature.Key]));
                    OpSimpleButton button = new OpSimpleButton(new Vector2(21f, 548f) + (buttonOffset * num), new Vector2(40f, 40f), creature.Key + "but", "");
                    OpImage        sprite = new OpImage(new Vector2(21f, 548f) + (buttonOffset * num) + spriteOffset, BloodColor.GetCreatureSprite(creature.Key));
                    sprite.color = BloodColor.GetCreatureSpriteColor(creature.Key);
                    sprite.sprite.SetAnchor(new Vector2(0.5f, 0.5f));
                    sprite.description = creature.Key;
                    button.description = creature.Key;
                    this.Tabs[0].AddItems(button, sprite, picker);
                    num++;
                }
                else if (num2 < 11)
                {
                    OpColorPicker  picker = new OpColorPicker(new Vector2(250f, 270f), creature.Key, OpColorPicker.ColorToHex(BloodMod.defaultColors[creature.Key]));
                    OpSimpleButton button = new OpSimpleButton(new Vector2(21f, 548f) + (buttonOffset * num2) + buttonOffset2, new Vector2(40f, 40f), creature.Key + "but", "");
                    OpImage        sprite = new OpImage(new Vector2(21f, 548f) + (buttonOffset * num2) + buttonOffset2 + spriteOffset, BloodColor.GetCreatureSprite(creature.Key));
                    sprite.color = BloodColor.GetCreatureSpriteColor(creature.Key);
                    sprite.sprite.SetAnchor(new Vector2(0.5f, 0.5f));
                    sprite.description = creature.Key;
                    button.description = creature.Key;
                    this.Tabs[0].AddItems(button, sprite, picker);
                    num2++;
                }
                else if (num3 < 11)
                {
                    OpColorPicker  picker = new OpColorPicker(new Vector2(250f, 270f), creature.Key, OpColorPicker.ColorToHex(BloodMod.defaultColors[creature.Key]));
                    OpSimpleButton button = new OpSimpleButton(new Vector2(21f, 548f) + (buttonOffset * num3) + (buttonOffset2 * 2), new Vector2(40f, 40f), creature.Key + "but", "");
                    OpImage        sprite = new OpImage(new Vector2(21f, 548f) + (buttonOffset * num3) + (buttonOffset2 * 2) + spriteOffset, BloodColor.GetCreatureSprite(creature.Key));
                    sprite.color = BloodColor.GetCreatureSpriteColor(creature.Key);
                    sprite.sprite.SetAnchor(new Vector2(0.5f, 0.5f));
                    sprite.description = creature.Key;
                    button.description = creature.Key;
                    this.Tabs[0].AddItems(button, sprite, picker);
                    num3++;
                }
                else
                {
                    OpColorPicker  picker = new OpColorPicker(new Vector2(250f, 270f), creature.Key, OpColorPicker.ColorToHex(BloodMod.defaultColors[creature.Key]));
                    OpSimpleButton button = new OpSimpleButton(new Vector2(21f, 548f) + (buttonOffset * num4) + (buttonOffset2 * 3), new Vector2(40f, 40f), creature.Key + "but", "");
                    OpImage        sprite = new OpImage(new Vector2(21f, 548f) + (buttonOffset * num4) + (buttonOffset2 * 3) + spriteOffset, BloodColor.GetCreatureSprite(creature.Key));
                    sprite.color = BloodColor.GetCreatureSpriteColor(creature.Key);
                    sprite.sprite.SetAnchor(new Vector2(0.5f, 0.5f));
                    sprite.description = creature.Key;
                    button.description = creature.Key;
                    this.Tabs[0].AddItems(button, sprite, picker);
                    num4++;
                }
            }
            this.selected = "Slugcat";
        }
    }
Exemple #13
0
        public void Initialize() //UI
        {
            if (vanillaMenu != null)
            {
                vanillaMenu.ShutDownProcess();
                vanillaMenu = null;
            }

            instance = this;
            mute     = true;

#pragma warning disable CS0162 // 접근할 수 없는 코드가 있습니다.
            if (!OptionMod.testing)
            {
                if (!redUnlocked)
                {
                    this.scene = new InteractiveMenuScene(this, this.pages[0], (MenuScene.SceneID)(bgList[Mathf.FloorToInt(UnityEngine.Random.value * (bgList.Length))]));
                }
                else
                {
                    this.scene = new InteractiveMenuScene(this, this.pages[0], (MenuScene.SceneID)(bgListRed[Mathf.FloorToInt(UnityEngine.Random.value * (bgListRed.Length))]));
                }
                Debug.Log(string.Concat("Chosen Background : " + this.scene.sceneID.ToString()));
                this.pages[0].subObjects.Add(this.scene);
            }
            else
            {
                this.scene = new SlideShowMenuScene(this, this.pages[0], MenuScene.SceneID.Intro_4_Walking);
                this.pages[0].subObjects.Add(this.scene);
            }
#pragma warning restore CS0162

            this.fadeSprite.RemoveFromContainer();
            this.pages[0].Container.AddChild(this.fadeSprite); //reset fadeSprite

            this.darkSprite = new FSprite("pixel", true)
            {
                color   = new Color(0f, 0f, 0f),
                anchorX = 0f,
                anchorY = 0f,
                scaleX  = 1368f,
                scaleY  = 770f,
                x       = -1f,
                y       = -1f,
                alpha   = 0.6f
            };
            this.pages[0].Container.AddChild(this.darkSprite);

            modListBound = new OpRect(new Vector2(193f, 240f) - UIelement._offset, new Vector2(280f, 495f), 0.3f);
            //modCanvasBound = new OpRect(new Vector2(553f, 105f), new Vector2(630f, 630f), 0.4f);
            modCanvasBound = new OpRect(new Vector2(543f, 105f) - UIelement._offset, new Vector2(630f, 630f), 0.4f);
            //Base: new Vector2(468f, 120f);
            menuTab.AddItems(modListBound, modCanvasBound);
            this.pages[0].subObjects.Add(modListBound.rect);
            this.pages[0].subObjects.Add(modCanvasBound.rect);

            this.backButton = new SimpleButton(this, this.pages[0], InternalTranslator.Translate("BACK"), "CANCEL", new Vector2(450f, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.backButton);
            this.saveButton = new SimpleButton(this, this.pages[0], InternalTranslator.Translate("APPLY"), "APPLY", new Vector2(600f, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.saveButton);
            base.MutualHorizontalButtonBind(saveButton, backButton);
            this.resetButton = new HoldButton(this, this.pages[0], InternalTranslator.Translate("RESET CONFIG"), "RESET CONFIG", new Vector2(300f, 110f), 30f);
            this.pages[0].subObjects.Add(this.resetButton);
            this.alertLabel = new MenuLabel(this, this.pages[0], "", new Vector2(383f, 735f), new Vector2(600f, 30f), false);
            this.pages[0].subObjects.Add(this.alertLabel);
            this.alertLabelFade = 0f; this.lastAlertLabelFade = 0f; this.alertLabelSin = 0f;

            //Dark Box for ModList & Canvas
            //modlist x200 y400 w240 h600
            //canvas  x568 y120 w600 h600

            this.resetButton.nextSelectable[2] = this.backButton;
            this.backButton.nextSelectable[0]  = this.resetButton;
            this.backButton.nextSelectable[2]  = this.saveButton;
            this.saveButton.nextSelectable[0]  = this.backButton;

            menuTab.lblInfoButton           = new OpLabel(new Vector2(233f, 215f) - UIelement._offset, new Vector2(200f, 20f), "Config Machine " + MenuTab.GetCMVersion());
            menuTab.lblInfoButton.bumpBehav = new BumpBehaviour(menuTab.lblInfoButton);
            menuTab.AddItems(menuTab.lblInfoButton);
            this.pages[0].subObjects.Add(menuTab.lblInfoButton.label);

            List <OptionInterface> itfs = new List <OptionInterface>();

            // Initialize
            OptionScript.loadedInterfaceDict.Remove(InternalTranslator.Translate("Mod List")); // Remove old Mod List
            List <UnconfiguableOI> replacedOIs = new List <UnconfiguableOI>();
            foreach (string id in OptionScript.loadedInterfaceDict.Keys)
            {
                OptionInterface itf = OptionScript.loadedInterfaceDict[id];
                Debug.Log(string.Concat("OptionInterface Initializing: " + id));

#pragma warning disable CS0612
                try { itf.Initialize(); }
                catch (Exception ex)
                { itf = new UnconfiguableOI(itf.mod, new GeneralInitializeException(ex)); goto replaced; }

                if (itf.Tabs == null || itf.Tabs.Length < 1)
                {
                    itf = new UnconfiguableOI(itf.mod, new NoTabException(id)); goto replaced;
                }
                else if (itf.Tabs.Length > 20)
                {
                    itf = new UnconfiguableOI(itf.mod, new TooManyTabsException()); goto replaced;
                }

                try { itf.LoadConfig(); itf.ShowConfig(); }
                catch (Exception ex)
                {
                    itf = new UnconfiguableOI(itf.mod, new LoadDataException(string.Concat("OILoad/ShowConfigError: ", id, " had a problem in Load/ShowConfig()\nAre you editing LoadConfig()/ShowConfig()? That could cause serious error.",
                                                                                           Environment.NewLine, ex
                                                                                           )));
                    goto replaced;
                }
#pragma warning restore CS0612

                itfs.Add(itf);
                continue;

replaced:
                itf.Initialize();
                itfs.Add(itf);
                replacedOIs.Add(itf as UnconfiguableOI);
            }
            foreach (UnconfiguableOI itf in replacedOIs)
            {
                OptionScript.loadedInterfaceDict.Remove(itf.rwMod.ModID);
                OptionScript.loadedInterfaceDict.Add(itf.rwMod.ModID, itf);
            }

            // Remove Excess
            int                 priority    = (int)OptionInterface.Priority.NoInterface;
            UnconfiguableOI     listItf     = null;
            List <RainWorldMod> listIgnored = new List <RainWorldMod>();
            while (itfs.Count > 16 && priority < (int)OptionInterface.Priority.Inconfiguable) // 1
            {
                Debug.Log(string.Concat("Mod Count: ", itfs.Count, "! Discarding priority ", priority));

                /* if (priority == -2)
                 * {
                 *  List<OptionInterface> temp2 = new List<OptionInterface>();
                 *  foreach (OptionInterface oi in itfs) { if (oi.GetPriority() > -2) { temp2.Add(oi); } }
                 *  itfs = temp2; priority++; continue;
                 * } */
                if (priority == (int)OptionInterface.Priority.NoInterface)
                {
                    PartialityMod blankMod = new PartialityMod
                    {
                        ModID   = InternalTranslator.Translate("Mod List"),
                        Version = "XXXX",
                        author  = RainWorldMod.authorNull
                    };
                    listItf = new UnconfiguableOI(blankMod, UnconfiguableOI.Reason.TooManyMod);
                }
                List <OptionInterface> temp = new List <OptionInterface>();
                foreach (OptionInterface oi in itfs)
                {
                    if (oi.GetPriority() > priority)
                    {
                        temp.Add(oi);
                    }
                    else
                    {
                        listIgnored.Add(oi.rwMod);
                    }
                }
                itfs = temp;
                priority++;
            }

            // Sorting
            {
                List <OptionInterface>[] sortTemp = new List <OptionInterface> [(int)OptionInterface.Priority.Error + 2];
                for (int p = 0; p < sortTemp.Length; p++)
                {
                    sortTemp[p] = new List <OptionInterface>();
                }
                foreach (OptionInterface oi in itfs)
                {
                    sortTemp[oi.GetPriority() + 1].Add(oi);
                }
                int cmCount = 0;
                for (int p = 0; p < sortTemp.Length; p++)
                {
                    cmCount += sortTemp[p].Count; sortTemp[p].Sort(CompareOIModID);
                }

                itfs = new List <OptionInterface>();
                if (priority > (int)OptionInterface.Priority.NoInterface)
                {
                    OptionScript.loadedInterfaceDict.Add(InternalTranslator.Translate("Mod List"), listItf);
                    listItf.SetIgnoredModList(listIgnored);
                    if (cmCount > 15)
                    {
                        listItf.SetConfiguableModList(sortTemp);
                    }
                    else
                    {
                        listItf.SetConfiguableModList(null);
                    }
                    listItf.Initialize();
                    itfs.Add(listItf);
                }
                for (int p = sortTemp.Length - 1; p >= 0; p--)
                {
                    for (int i = 0; i < sortTemp[p].Count; i++)
                    {
                        itfs.Add(sortTemp[p][i]);
                    }
                }
            }

            // Add Buttons
            modButtons = new SelectOneButton[Math.Min(16, itfs.Count)];
            Dictionary <int, string> dictionary = new Dictionary <int, string>(itfs.Count);
            selectedModIndex = 0;
            for (int i = 0; i < itfs.Count; i++)
            {
                OptionInterface itf = itfs[i];
#pragma warning disable CS0162
                if (OptionMod.testing)
                {
                    Debug.Log(string.Concat("Mod(" + i + ") : " + itf.rwMod.ModID));
                }
#pragma warning restore CS0162
                for (int t = 0; t < itf.Tabs.Length; t++)
                {
                    OptionScript.tabs.Add(string.Concat(i.ToString("D3") + "_" + t.ToString("D2")), itf.Tabs[t]);
                    foreach (UIelement element in itf.Tabs[t].items)
                    {
                        foreach (MenuObject obj in element.subObjects)
                        {
                            this.pages[0].subObjects.Add(obj);
                        }
                        this.pages[0].Container.AddChild(element.myContainer);
                    }
                    itf.Tabs[t].Hide();
                }
                dictionary.Add(i, itf.rwMod.ModID);

                if (i > 15)
                {
                    continue;
                }
                modButtons[i] = new SelectOneButton(this, this.pages[0], itf.rwMod.ModID, "ModSelect", new Vector2(208f, 700f - 30f * i), new Vector2(250f, 24f), modButtons, i);
                this.pages[0].subObjects.Add(modButtons[i]);
            }
            modList    = dictionary;
            scrollMode = false;
            if (itfs.Count > 16)
            {
                scrollMode = true;
                scrollTop  = 1;
                modButtons[1].menuLabel.text  = InternalTranslator.Translate("Scroll Up");
                modButtons[1].signalText      = "ScrollUp";
                modButtons[15].menuLabel.text = InternalTranslator.Translate("Scroll Down");
                modButtons[15].signalText     = "ScrollDown";
                ScrollButtons();
            }

            if (this.modButtons.Length > 1)
            {
                for (int m = 0; m < this.modButtons.Length - 1; m++)
                {
                    this.modButtons[m].nextSelectable[3]     = this.modButtons[m + 1];
                    this.modButtons[m + 1].nextSelectable[1] = this.modButtons[m];
                }
                if (listItf != null)
                {
                    this.modButtons[0].menuLabel.text = listItf.rwMod.ModID;
                }
            }
            this.resetButton.nextSelectable[1] = this.modButtons[this.modButtons.Length - 1];
            this.backButton.nextSelectable[1]  = this.modButtons[this.modButtons.Length - 1];
            this.saveButton.nextSelectable[1]  = this.modButtons[this.modButtons.Length - 1];
            this.modButtons[this.modButtons.Length - 1].nextSelectable[3] = this.saveButton;

            //Load Tab
            selectedTabIndex = 0;
            currentInterface = OptionScript.loadedInterfaceDict[modList[0]];
            currentTab       = OptionScript.tabs[string.Concat(selectedModIndex.ToString("D3") + "_" + selectedTabIndex.ToString("D2"))];

            currentTab.Show();
            if (currentInterface.Configuable())
            {
                saveButton.buttonBehav.greyedOut  = false;
                resetButton.buttonBehav.greyedOut = false;
            }
            else
            {
                saveButton.buttonBehav.greyedOut  = true;
                resetButton.buttonBehav.greyedOut = true;
            }

            tabCtrler = new ConfigTabController(new Vector2(503f, 120f) - UIelement._offset, new Vector2(40f, 600f), menuTab, this);
            menuTab.AddItems(tabCtrler);
            foreach (MenuObject obj in tabCtrler.subObjects)
            {
                this.pages[0].subObjects.Add(obj);
            }

            this.selectedObject = this.backButton;

            OptionScript.configChanged = false;

            mute = false;
        }
Exemple #14
0
        public override void Initialize()
        {
            base.Initialize();

            Tabs = new OpTab[] { new OpTab("Config") };

            const string desc =
                "Mod behavior\n" +
                "\n+ When bit by a lizard, instead of randomly killing the player, the player takes damage." +
                "\n+ Too much damage equals death." +
                "\n+ Some time after being released, or after the start of a cycle, damage is reset.";
            const string vanillaDesc =
                "Vanilla behavior\n" +
                "\n+ When not killed by a bite, slugcat is only grabbed, so you can still escape with your life if your captor drops you before reaching a den." +
                "\n+ The creature will drop you if it is stunned." +
                "\n+ After a moment, it will paralyze slugcat, so hit it with a rock or spear quickly!";

            var labelAuthor  = new OpLabel(20, 600 - 30, "by Dual", true);
            var labelVersion = new OpLabel(20, 600 - 30 - 40, "github.com/Dual-Iron/");
            var labelNote    = new OpLabel(200, 600 - 30 - 20, "Testing the waters with this mod. It's been pleasant so far.");

            var size            = new Vector2(300 - 20, 150);
            var pos             = new Vector2(10, 200 - size.y / 2);
            var rectDescription = new OpRect(pos, size)
            {
                description = "Mod mechanics"
            };
            var labelDescription = new OpLabelLong(pos + new Vector2(10, 0), rectDescription.size - Vector2.one * 20, desc, true, FLabelAlignment.Left);

            pos.x = 310;
            var rectVanillaDescription = new OpRect(pos, size)
            {
                description = "Tips on creatures grabbing slugcat"
            };
            var labelVanillaDescription = new OpLabelLong(pos + new Vector2(10, 0), rectDescription.size - Vector2.one * 20, vanillaDesc, true, FLabelAlignment.Left);

            var top           = 200;
            var labelDmgMul   = new OpLabel(20, 600 - top, "Lizard damage multiplier");
            var labelDecimal  = new OpLabel(326, 600 - top + 2, "x 0.1");
            var draggerDmgMul = new OpDragger(new Vector2(300, 600 - top), "D1", 10)
            {
                description = "Makes you take more/less damage per lizard bite. By default (x1.0), a 1/n chance for lizards to kill makes them kill in n bites.",
                min         = 0,
                max         = 50,
                colorEdge   = Color.clear,
                colorText   = new Color(122, 216, 255)
            };

            var labelDmgRegen   = new OpLabel(20, 600 - top - 30, "Lizard damage reset cooldown");
            var labelSeconds    = new OpLabel(326, 600 - top - 30 + 2, "seconds");
            var draggerDmgRegen = new OpDragger(new Vector2(300, 600 - top - 30), "D2", -1)
            {
                description = "The time it takes to reset damage after being released from a grab. Value -1 means damage is only reset at the start of a cycle.",
                min         = -1,
                max         = 60,
                colorEdge   = Color.clear,
                colorText   = new Color(122, 216, 255)
            };

            Tabs[0].AddItems(
                rectVanillaDescription,
                labelVanillaDescription,
                rectDescription,
                labelDescription,
                labelAuthor,
                labelVersion,
                labelNote,
                labelDmgMul,
                labelDecimal,
                draggerDmgMul,
                labelDmgRegen,
                labelSeconds,
                draggerDmgRegen
                );
        }