Exemplo n.º 1
0
        /// <summary>
        /// Load events. Calls the file selection dialog.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void main_Load(object sender, EventArgs e)
        {
            FrmSelect frm = new FrmSelect();

            frm.ShowDialog();
            PaletteLoader.LoadPalettes(main.basepath + "\\data\\pals.dat");
            PicPalette.Image = ArtLoader.Palette(PaletteLoader.Palettes[0]).image;
            PopulateTextureTree();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles selection of an art file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TreeArt_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode node = TreeArt.SelectedNode;

            BtnRepack4Bit.Enabled = false;
            if (node.Parent != null)
            {
                string partext = node.Parent.Text.ToUpper();
                switch (partext)
                {
                case "TEXTURES":
                case "WALL TEXTURES":
                case "FLOOR TEXTURES":
                {        //loading a texture
                    int index;
                    if (node.Tag == null)
                    {
                        return;
                    }
                    if (int.TryParse(node.Tag.ToString(), out index))
                    {
                        CurrentImage = tex.LoadImageAt(index);
                    }
                    break;
                }

                case "GRAPHIC RESOURCES":
                {
                    int index;
                    if (node.Tag == null)
                    {
                        return;
                    }
                    if (int.TryParse(node.Tag.ToString(), out index))
                    {
                        if (grfile[index] == null)
                        {        //Load the gr file and populate the tree.
                            grfile[index] = new GRLoader(main.basepath + "\\data\\" + node.Text);
                            for (int i = 0; i <= grfile[index].ImageCache.GetUpperBound(0); i++)
                            {
                                TreeNode img = node.Nodes.Add(i.ToString());
                                img.Tag = i;
                            }
                        }
                    }
                    break;
                }

                case "BITMAP RESOURCES":
                {
                    int index;
                    if (node.Tag == null)
                    {
                        return;
                    }
                    if (int.TryParse(node.Tag.ToString(), out index))
                    {
                        if (bytfile[index] == null)
                        {
                            bytfile[index] = new BytLoader();
                        }
                        CurrentImage = bytfile[index].LoadImageAt(index);
                    }
                    break;
                }

                case "BYT.ARK":
                {
                    int index;
                    if (node.Tag == null)
                    {
                        return;
                    }
                    if (int.TryParse(node.Tag.ToString(), out index))
                    {
                        if (bytfile[0] == null)
                        {
                            bytfile[0] = new BytLoader();
                        }
                        CurrentImage = bytfile[0].LoadImageAt(index);
                    }
                    break;
                }

                default:
                    if (partext.ToUpper().Contains(".GR"))
                    {
                        int parentindex;
                        if (node.Parent.Tag == null)
                        {
                            return;
                        }
                        if (int.TryParse(node.Parent.Tag.ToString(), out parentindex))
                        {
                            int index;
                            if (node.Tag == null)
                            {
                                return;
                            }
                            if (int.TryParse(node.Tag.ToString(), out index))
                            {
                                //load the gr file
                                CurrentImage = grfile[parentindex].LoadImageAt(index);
                                switch (CurrentImage.ImageType)
                                {
                                case BitmapUW.ImageTypes.FourBitRunLength:
                                case BitmapUW.ImageTypes.FourBitUncompress:
                                    BtnRepack4Bit.Enabled = true;
                                    break;
                                }
                            }
                        }
                    }
                    break;
                }
            }
            if (CurrentImage != null)
            {
                ImgOut.Image         = CurrentImage.image;
                PicPalette.Image     = ArtLoader.Palette(CurrentImage.ImagePalette, CurrentImage.PaletteRef).image;
                ImgOut.Width         = CurrentImage.image.Width * (int)NumZoom.Value;
                ImgOut.Height        = CurrentImage.image.Height * (int)NumZoom.Value;
                LblImageDetails.Text = CurrentImage.image.Height + "x" + CurrentImage.image.Width + "\n" + CurrentImage.ImageType.ToString();
            }
        }