예제 #1
0
        public void MainTabRedux(int tab)
        {
            // MOD DESCRIPTION
            OpLabel labelID = new OpLabel(new Vector2(50, 560), new Vector2(500, 40f), mod.ModID.ToUpper(), FLabelAlignment.Center, true);

            Tabs[tab].AddItems(labelID);
            OpLabel labelDsc = new OpLabel(new Vector2(100f, 545), new Vector2(400f, 20f), "Support for custom regions.", FLabelAlignment.Center, false);

            Tabs[tab].AddItems(labelDsc);

            // VERSION AND AUTHOR
            OpLabel labelVersion = new OpLabel(new Vector2(50, 530), new Vector2(200f, 20f), "Version: pre-release" /*+ mod.Version*/, FLabelAlignment.Left, false);

            Tabs[tab].AddItems(labelVersion);
            OpLabel labelAuthor = new OpLabel(new Vector2(430, 560), new Vector2(60, 20f), "by Garrakx", FLabelAlignment.Right, false);

            Tabs[tab].AddItems(labelAuthor);

            Tabs[tab].AddItems(new OpSimpleButton(new Vector2(525, 550), new Vector2(60, 30), "reloadRegions", "Reload"));

            OpLabelLong errorLabel = new OpLabelLong(new Vector2(25, 1), new Vector2(500, 15), "", true, FLabelAlignment.Center)
            {
                text = "Any changes made (load order, activating/deactivating) will corrupt the save"
            };

            Tabs[tab].AddItems(errorLabel);
            CreateRegionPackList(Tabs[tab], CustomWorldMod.installedPacks, CustomWorldMod.downloadedThumbnails, false);
        }
예제 #2
0
        private void InitChangeLog()
        {
            List <UIelement> newElems = new List <UIelement>();

            this.lblTitle = new OpLabel(new Vector2(200f, 560f), new Vector2(200f, 30f), InternalTranslator.Translate("Config Machine ChangeLog"), bigText: true);
            this.lblVer   = new OpLabel(new Vector2(50f, 540f), new Vector2(200f, 20f), GetCMVersion(), FLabelAlignment.Left);
            this.lblTrans = new OpLabel(new Vector2(350f, 540f), new Vector2(200f, 20f), GetTranslator(), FLabelAlignment.Right);
            this.AddItems(this.lblTitle, this.lblVer, this.lblTrans);
            newElems.Add(this.lblTitle); newElems.Add(this.lblVer); newElems.Add(this.lblTrans);

            if (rawLog == null)
            {
                ReadTXT();
            }
            int len = Math.Min(rawLog.Length - 1, 16);

            this.box = new OpScrollBox(new Vector2(20f, 10f), new Vector2(560f, 520f), len * 560f, true, true, false)
            {
                redrawFlags = OpScrollBox.RedrawEvents.OnHover, doesBackBump = false
            };
            this.AddItems(this.box); this.box.Lock(true);
            newElems.Add(this.box);
            this.vers = new string[len];
            for (int i = 0; i < len; i++)
            {
                string[] split = Regex.Split(rawLog[i + 1], "#!#");
                this.vers[i] = split[0];
                OpLabel     ver = new OpLabel(new Vector2(130f + i * 560f, 470f), new Vector2(300f, 30f), split[0], bigText: true);
                OpLabelLong log = new OpLabelLong(new Vector2(20f + i * 560f, 20f), new Vector2(520f, 420f), "placeholder")
                {
                    allowOverflow = false
                };
                log.text = split[2].Trim();
                if (!string.IsNullOrEmpty(split[1]))
                {
                    ver.description = ConvertDate(split[1].Trim()); ver.bumpBehav = new BumpBehaviour(ver);
                }
                this.box.AddItems(ver, log);
                newElems.Add(ver); newElems.Add(log);
            }

            sbRight = new ScrollButton(new Vector2(460f, 470f), true);
            sbLeft  = new ScrollButton(new Vector2(90f, 470f), false);
            this.AddItems(sbRight, sbLeft); sbLeft.Hide(); curVer = 0;
            newElems.Add(sbRight); newElems.Add(sbLeft);

            foreach (UIelement element in newElems)
            {
                foreach (MenuObject obj in element.subObjects)
                {
                    OptionScript.configMenu.pages[0].subObjects.Add(obj);
                }
                OptionScript.configMenu.pages[0].Container.AddChild(element.myContainer);
            }

            _initLog = true;
        }
예제 #3
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;
            }
        }
예제 #4
0
        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)
예제 #5
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
                );
        }