/// <summary> /// Adds Basic Profile on top of OpTab /// </summary> /// <param name="tab"><see cref="OpTab"/> which will contain the profile</param> /// <param name="mod"><see cref="RainWorldMod"/> that has basic information of the mod</param> public static void AddBasicProfile(OpTab tab, RainWorldMod mod) { tab.AddItems(new OpLabel(new Vector2(100f, 550f), new Vector2(400f, 50f), mod.ModID, FLabelAlignment.Center, true)); tab.AddItems(new OpLabel(new Vector2(50f, 500f), new Vector2(100f, 20f), InternalTranslator.Translate("Version: <ModVersion>").Replace("<ModVersion>", mod.Version), FLabelAlignment.Left)); if (mod.author != RainWorldMod.authorNull) { tab.AddItems(new OpLabel(new Vector2(350f, 500f), new Vector2(200f, 20f), InternalTranslator.Translate("Author: <ModAuthor>").Replace("<ModAuthor>", mod.author), FLabelAlignment.Right) { autoWrap = true }); } /* * if (mod.coauthor != RainWorldMod.authorNull) * { * 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 != RainWorldMod.authorNull) * { * labelDesc = new OpLabel(new Vector2(80f, 350f), new Vector2(340f, 20f), mod.description, FLabelAlignment.Left); * Tabs[0].AddItem(labelDesc); * labelDesc.autoWrap = true; * } */ }
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)