Example #1
0
        private void loadPalettes()
        {
            if (gameFolderPathTextBox.Text.Length > 0 && Directory.Exists(gameFolderPathTextBox.Text))
            {
                // populate the list box with the font .LBX files and the first several blocks.
                // all of the game fonts are stored here
                palettesListBox.Items.Clear();
                //palettesListBox.Items.Add("FONTS.LBX:000");
                palettesListBox.Items.Add("FONTS.LBX:001");
                palettesListBox.Items.Add("FONTS.LBX:002");
                palettesListBox.Items.Add("FONTS.LBX:003");
                palettesListBox.Items.Add("FONTS.LBX:004");
                palettesListBox.Items.Add("FONTS.LBX:005");

                palettesListBox.Items.Add("IFONTS.LBX:000");
                palettesListBox.Items.Add("IFONTS.LBX:001");
                palettesListBox.Items.Add("IFONTS.LBX:002");
                palettesListBox.Items.Add("IFONTS.LBX:003");
                palettesListBox.Items.Add("IFONTS.LBX:004");

                // a Palette[] holds the actual Palette objects
                palettes = new Palette[palettesListBox.Items.Count];
                LBXBlock block = new LBXBlock();

                // load those
                for (int i = 0; i < palettes.Length; ++i)
                {
                    // create new palette, then parse out the filename from the block index
                    palettes[i] = new Palette();
                    string listItem     = (string)palettesListBox.Items[i];
                    string fontFileName = listItem.Substring(0, listItem.IndexOf(":"));
                    int    blockIndex   = Int32.Parse(listItem.Substring(listItem.IndexOf(":") + 1, listItem.Length - listItem.IndexOf(":") - 1));

                    lbxReader.close();
                    lbxReader.open(gameFolderPathTextBox.Text + "\\" + fontFileName);
                    lbxReader.read(block, blockIndex);

                    palettes[i].load(block);
                }
                lbxReader.close();

                // set the second font as the current, which should also trigger the event to
                // update currentPaletteIndex and redraw the palette view image
                palettesListBox.SetSelected(2, true);
            }
        }
Example #2
0
        public void load(string filePath, int index)
        {
            LBXReader lbx   = new LBXReader(filePath);
            LBXBlock  block = new LBXBlock();

            lbx.read(block, index);
            load(block);
            lbx.close();
        }