private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode Parent = e.Node.Parent; if (Parent == null) { return; } switch (Parent.Text) { case "Characters": TA.Text = $"Training as {e.Node.Text}"; Character = e.Node.Text; var Levels = CharDictionary[e.Node.Text].Levels; Level.Nodes.Clear(); foreach (string Lev in Levels) { Level.Nodes.Add(new TreeNode(Lev)); } Chars.Collapse(); Level.Expand(); break; case "Training Level": TL.Text = $"Training Level: {e.Node.Text}"; TrainingLevel = e.Node.Text; CharImage.Load($"./Assets/Characters/{string.Join("_", $"{Character} {TrainingLevel}".Split(null)).ToLower()}.png"); break; } }
private byte[] fontIdent; // unique font identifier #endregion Fields #region Constructors public BmfFile(Stream fileStream) { using (fileStream) { fontIdent = new byte[4]; fileStream.Read(fontIdent, 0, fontIdent.Length); byte numChar = (byte)fileStream.ReadByte(); fontHeight = (byte)fileStream.ReadByte(); fontAscent = (byte)fileStream.ReadByte(); fontDescent = (byte)fileStream.ReadByte(); // read in data CharHeader[] charHeaders = new CharHeader[(uint)numChar]; CharImage[] charImages = new CharImage[(uint)numChar]; for (uint x = 0; x < (uint)numChar; x++) { charHeaders[x].charValue = (byte)fileStream.ReadByte(); charHeaders[x].fullWidth = (byte)fileStream.ReadByte(); charHeaders[x].rectX0 = (byte)fileStream.ReadByte(); charHeaders[x].rectY0 = (byte)fileStream.ReadByte(); charHeaders[x].rectX1 = (byte)fileStream.ReadByte(); charHeaders[x].rectY1 = (byte)fileStream.ReadByte(); } for (uint x = 0; x < (uint)numChar; x++) { charImages[x].charWidth = (byte)fileStream.ReadByte(); charImages[x].charHeight = (byte)fileStream.ReadByte(); charImages[x].charData = new byte[((uint)charImages[x].charWidth) * ((uint)charImages[x].charHeight)]; for (uint y = 0; y < charImages[x].charData.Length; y++) { charImages[x].charData[y] = (byte)fileStream.ReadByte(); } } //re-roll data characters = new Dictionary<byte, BmfCharacter>(); for (uint x = 0; x < (uint)numChar; x++) { characters.Add(charHeaders[x].charValue, new BmfCharacter( charHeaders[x].fullWidth, charHeaders[x].rectX0, charHeaders[x].rectY0, charHeaders[x].rectX1, charHeaders[x].rectY1, charImages[x].charWidth, charImages[x].charHeight, charImages[x].charData)); } } }