void AddIconPacks(ScrollingPanel parent, ref int xpos, ref int ypos) { int rowCount = 0; int startX = xpos; SpellIconCollection iconCollection = DaggerfallUI.Instance.SpellIconCollection; // TODO: Add suggested icons (if any) // Add spell icon collections int packsAdded = 0; foreach (var kvp in iconCollection.SpellIconPacks) { string key = kvp.Key; SpellIconCollection.SpellIconPack pack = kvp.Value; if (pack.icons == null || pack.iconCount == 0) { continue; } AddHeaderLabel(parent, ref xpos, ref ypos, pack.displayName); rowCount = 0; for (int i = 0; i < pack.iconCount; i++) { AddIcon(iconCollection, pack, key, i, parent, ref rowCount, ref startX, ref xpos, ref ypos); } packsAdded++; } // Start from a new row if we added any icon packs if (packsAdded > 0) { ypos += iconSpacing; } // Add classic icons xpos = startX; AddHeaderLabel(parent, ref xpos, ref ypos, TextManager.Instance.GetText(textDatabase, "classicIcons")); rowCount = 0; for (int i = 0; i < iconCollection.SpellIconCount; i++) { AddIcon(iconCollection, null, null, i, parent, ref rowCount, ref startX, ref xpos, ref ypos); } // Assign total scroll steps in scrolling panel parent.ScrollSteps = ypos / iconSpacing + 1; scroller.DisplayUnits = parent.InteriorHeight / iconSpacing; scroller.TotalUnits = parent.ScrollSteps; }
void Start() { // Post start message PostMessage(startupMessage); // Load spell icon collection spellIconCollection = new SpellIconCollection(); // Set version text versionFont = new DaggerfallFontPlus(Resources.Load <Texture2D>("Kingthings-Petrock-Light-PixelFont"), 16, 16, 32); versionText = string.Format("{0} {1} {2}", VersionInfo.DaggerfallUnityProductName, VersionInfo.DaggerfallUnityStatus, VersionInfo.DaggerfallUnityVersion); versionTextWidth = versionFont.GetCharacterWidth(versionText, -1, versionTextScale); }
void AddIcon(SpellIconCollection iconCollection, SpellIconCollection.SpellIconPack pack, string key, int index, Panel parent, ref int rowCount, ref int startX, ref int xpos, ref int ypos) { // Get pack or classic texture Texture2D texture; if (pack == null) { texture = iconCollection.GetSpellIcon(index); } else { texture = pack.icons[index].texture; } // Add image panel Panel panel = new Panel(); panel.BackgroundTexture = texture; panel.Position = new Vector2(xpos, ypos); panel.Size = new Vector2(iconSize, iconSize); parent.Components.Add(panel); xpos += iconSpacing; if (++rowCount >= iconsPerRow) { xpos = startX; ypos += iconSpacing; rowCount = 0; } // Tag panel for selection, a null key will fallback to classic using index panel.Tag = new SpellIcon() { key = key, index = index, }; }