예제 #1
0
 private void chr_13_renderer_DragDrop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
         foreach (string filePath in files)
         {
             if (filePath.ToLower().EndsWith(".dds"))
             {
                 DDS dds = new DDS(new FileData(filePath));
                 if (sender == chr_13_renderer)
                 {
                     chr_13 = ReplaceTexture(dds.toNUT_Texture(), 416, 416, chr_13);
                     if (chr_13_loc != null)
                     {
                         chr_13.Save(chr_13_loc);
                     }
                 }
                 if (sender == chr_00_renderer)
                 {
                     chr_00 = ReplaceTexture(dds.toNUT_Texture(), 128, 128, chr_00);
                     if (chr_00_loc != null)
                     {
                         chr_00.Save(chr_00_loc);
                     }
                 }
                 if (sender == chr_11_renderer)
                 {
                     chr_11 = ReplaceTexture(dds.toNUT_Texture(), 384, 384, chr_13);
                     if (chr_11_loc != null)
                     {
                         chr_11.Save(chr_11_loc);
                     }
                 }
             }
             if (filePath.ToLower().EndsWith(".png"))
             {
                 if (sender == stock_90_renderer)
                 {
                     stock_90 = ReplaceTexture(NUTEditor.fromPNG(filePath, 0), 64, 64, chr_13);
                     if (stock_90_loc != null)
                     {
                         stock_90.Save(stock_90_loc);
                     }
                 }
             }
         }
         ((GLControl)sender).Invalidate();
     }
 }
예제 #2
0
        private void importBack(string filename)
        {
            if (dontModify)
            {
                return;
            }

            NUT.NUD_Texture tex = textureFromFile[filename];

            try
            {
                DDS             dds  = new DDS(new FileData(filename));
                NUT.NUD_Texture ntex = dds.toNUT_Texture();

                tex.height  = ntex.height;
                tex.width   = ntex.width;
                tex.type    = ntex.type;
                tex.mipmaps = ntex.mipmaps;
                tex.utype   = ntex.utype;

                GL.DeleteTexture(selected.draw[tex.id]);
                selected.draw.Remove(tex.id);
                selected.draw.Add(tex.id, NUT.loadImage(tex));

                FillForm();
                listBox1.SelectedItem = selected;
                listBox2.SelectedItem = tex;
                RenderTexture();
            }
            catch
            {
                Console.WriteLine("Could not be open for editing");
            }
        }
예제 #3
0
        private void replaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var ofd = new OpenFileDialog())
            {
                ofd.Filter = "Direct Draw Surface (.dds)|*.dds|" +
                             "All files(*.*)|*.*";

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    if (ofd.FileName.EndsWith(".dds") && selected != null)
                    {
                        NUT.NUD_Texture tex = (NUT.NUD_Texture)(listBox2.SelectedItem);

                        DDS             dds  = new DDS(new FileData(ofd.FileName));
                        NUT.NUD_Texture ntex = dds.toNUT_Texture();

                        tex.height  = ntex.height;
                        tex.width   = ntex.width;
                        tex.type    = ntex.type;
                        tex.mipmaps = ntex.mipmaps;
                        tex.utype   = ntex.utype;

                        GL.DeleteTexture(selected.draw[tex.id]);
                        selected.draw.Remove(tex.id);
                        selected.draw.Add(tex.id, NUT.loadImage(tex));

                        FillForm();
                        listBox1.SelectedItem = selected;
                    }
                }
            }
        }
예제 #4
0
        private void importBack(string filename)
        {
            if (dontModify)
            {
                return;
            }

            NUT_Texture tex = textureFromFile[filename];

            try
            {
                DDS         dds  = new DDS(new FileData(filename));
                NUT_Texture ntex = dds.toNUT_Texture();

                tex.Height  = ntex.Height;
                tex.Width   = ntex.Width;
                tex.type    = ntex.type;
                tex.mipmaps = ntex.mipmaps;
                tex.utype   = ntex.utype;

                GL.DeleteTexture(NUT.draw[tex.HASHID]);
                NUT.draw.Remove(tex.HASHID);
                NUT.draw.Add(tex.HASHID, NUT.loadImage(tex));

                FillForm();
                textureList.SelectedItem = tex;
                glControl1.Invalidate();
                //RenderTexture();
            }
            catch
            {
                Console.WriteLine("Could not be open for editing");
            }
        }
예제 #5
0
        private void importBack(string filename)
        {
            if (dontModify)
            {
                return;
            }

            NutTexture tex = textureFromFile[filename];

            try
            {
                DDS        dds  = new DDS(new FileData(filename));
                NutTexture ntex = dds.toNUT_Texture();

                tex.Height   = ntex.Height;
                tex.Width    = ntex.Width;
                tex.type     = ntex.type;
                tex.surfaces = ntex.surfaces;
                tex.utype    = ntex.utype;

                GL.DeleteTexture(NUT.glTexByHashId[tex.HASHID]);
                NUT.glTexByHashId.Remove(tex.HASHID);
                NUT.glTexByHashId.Add(tex.HASHID, NUT.CreateGlTexture(tex));

                FillForm();
                textureListBox.SelectedItem = tex;
                glControl1.Invalidate();
            }
            catch
            {
                Console.WriteLine("Could not be open for editing");
            }
        }
예제 #6
0
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (selected != null)
            {
                using (var ofd = new OpenFileDialog())
                {
                    ofd.Filter = "Supported Formats|*.dds;*.png|" +
                                 "Direct Draw Surface (.dds)|*.dds|" +
                                 "Portable Networks Graphic (.png)|*.png|" +
                                 "All files(*.*)|*.*";

                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        int  texId;
                        bool isTex = int.TryParse(Path.GetFileNameWithoutExtension(ofd.FileName), NumberStyles.HexNumber,
                                                  new CultureInfo("en-US"), out texId);

                        if (isTex)
                        {
                            foreach (NUT.NUD_Texture te in selected.textures)
                            {
                                if (texId == te.id)
                                {
                                    isTex = false;
                                }
                            }
                        }

                        NUT.NUD_Texture tex = null;

                        if (ofd.FileName.EndsWith(".dds") && selected != null)
                        {
                            DDS dds = new DDS(new FileData(ofd.FileName));
                            tex = dds.toNUT_Texture();
                        }
                        if (ofd.FileName.EndsWith(".png") && selected != null)
                        {
                            tex = fromPNG(ofd.FileName, 1);
                        }

                        if (tex != null)
                        {
                            if (isTex)
                            {
                                tex.id = texId;
                            }
                            else
                            {
                                tex.id = 0x40FFFF00 | (selected.textures.Count);
                            }
                            selected.textures.Add(tex);
                            selected.draw.Add(tex.id, NUT.loadImage(tex));
                            FillForm();
                            listBox1.SelectedItem = selected;
                        }
                    }
                }
            }
        }
예제 #7
0
        private void replaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var ofd = new OpenFileDialog())
            {
                NUT_Texture tex = (NUT_Texture)(textureList.SelectedItem);

                if (tex.type == PixelInternalFormat.Rgba)
                {
                    ofd.Filter = "Portable Networks Graphic (.png)|*.png|" +
                                 "All files(*.*)|*.*";
                }
                else
                {
                    ofd.Filter = "Direct Draw Surface (.dds)|*.dds|" +
                                 "All files(*.*)|*.*";
                }

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    Edited = true;
                    NUT_Texture ntex = null;
                    if (ofd.FileName.EndsWith(".dds") && NUT != null)
                    {
                        DDS dds = new DDS(new FileData(ofd.FileName));
                        ntex = dds.toNUT_Texture();
                    }

                    if (ofd.FileName.EndsWith(".png") && NUT != null)
                    {
                        ntex = fromPNG(ofd.FileName, 1);
                    }

                    tex.Height  = ntex.Height;
                    tex.Width   = ntex.Width;
                    tex.type    = ntex.type;
                    tex.mipmaps = ntex.mipmaps;
                    tex.utype   = ntex.utype;

                    if (ntex == null)
                    {
                        return;
                    }

                    GL.DeleteTexture(NUT.draw[tex.HASHID]);
                    NUT.draw.Remove(tex.HASHID);
                    NUT.draw.Add(tex.HASHID, NUT.loadImage(tex));

                    FillForm();
                }
            }
        }
예제 #8
0
        private void replaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (NUT == null || textureListBox.SelectedItem == null)
            {
                return;
            }
            using (var ofd = new OpenFileDialog())
            {
                NutTexture texture = (NutTexture)(textureListBox.SelectedItem);

                ofd.Filter = "Supported Formats|*.dds;*.png|" +
                             "DirectDraw Surface (.dds)|*.dds|" +
                             "Portable Network Graphics (.png)|*.png|" +
                             "All files(*.*)|*.*";

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    NutTexture newTexture = null;
                    string     extension  = Path.GetExtension(ofd.FileName).ToLowerInvariant();
                    if (extension == ".dds")
                    {
                        DDS dds = new DDS(new FileData(ofd.FileName));
                        newTexture = dds.toNUT_Texture();
                    }
                    else if (extension == ".png")
                    {
                        newTexture = fromPNG(ofd.FileName, 1);
                    }
                    else
                    {
                        return;
                    }

                    texture.Height   = newTexture.Height;
                    texture.Width    = newTexture.Width;
                    texture.type     = newTexture.type;
                    texture.surfaces = newTexture.surfaces;
                    texture.utype    = newTexture.utype;

                    Edited = true;

                    GL.DeleteTexture(NUT.glTexByHashId[texture.HASHID]);
                    NUT.glTexByHashId.Remove(texture.HASHID);
                    NUT.glTexByHashId.Add(texture.HASHID, NUT.CreateGlTexture(texture));

                    FillForm();
                }
            }
        }
예제 #9
0
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var ofd = new OpenFileDialog())
            {
                ofd.Filter = "Direct Draw Surface (.dds)|*.dds|" +
                             "All files(*.*)|*.*";

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    if (ofd.FileName.EndsWith(".dds") && selected != null)
                    {
                        DDS             dds = new DDS(new FileData(ofd.FileName));
                        NUT.NUD_Texture tex = dds.toNUT_Texture();
                        tex.id = 0x40FFFF00 | (selected.textures.Count);
                        selected.textures.Add(tex);
                        selected.draw.Add(tex.id, NUT.loadImage(tex));
                        FillForm();
                        listBox1.SelectedItem = selected;
                    }
                }
            }
        }
예제 #10
0
        private void importNutFromFolder(object sender, EventArgs e)
        {
            using (FolderSelectDialog f = new FolderSelectDialog())
            {
                if (f.ShowDialog() == DialogResult.OK)
                {
                    if (!Directory.Exists(f.SelectedPath))
                    {
                        Directory.CreateDirectory(f.SelectedPath);
                    }
                    NUT nut;
                    if (listBox1.SelectedItem == null)
                    {
                        nut = new NUT();
                    }
                    else
                    {
                        nut = selected;
                    }

                    foreach (var texPath in Directory.GetFiles(f.SelectedPath))
                    {
                        int  texId;
                        bool isTex = int.TryParse(Path.GetFileNameWithoutExtension(texPath), NumberStyles.HexNumber,
                                                  new CultureInfo("en-US"), out texId);
                        if (isTex)
                        {
                            NUT.NUD_Texture texture = null;
                            foreach (var tex in nut.textures)
                            {
                                if (tex.id == texId)
                                {
                                    texture = tex;
                                }
                            }

                            if (texture == null)
                            {
                                //new texture
                                DDS             dds = new DDS(new FileData(texPath));
                                NUT.NUD_Texture tex = dds.toNUT_Texture();
                                tex.id = 0x40FFFF00 | (nut.textures.Count);
                                nut.textures.Add(tex);
                                nut.draw.Add(tex.id, NUT.loadImage(tex));
                            }
                            else
                            {
                                //old texture
                                NUT.NUD_Texture tex = texture;

                                DDS             dds  = new DDS(new FileData(texPath));
                                NUT.NUD_Texture ntex = dds.toNUT_Texture();

                                tex.height  = ntex.height;
                                tex.width   = ntex.width;
                                tex.type    = ntex.type;
                                tex.mipmaps = ntex.mipmaps;
                                tex.utype   = ntex.utype;

                                GL.DeleteTexture(selected.draw[tex.id]);
                                selected.draw.Remove(tex.id);
                                selected.draw.Add(tex.id, NUT.loadImage(tex));
                            }
                        }
                    }
                    if (!Runtime.TextureContainers.Contains(nut))
                    {
                        Runtime.TextureContainers.Add(nut);
                    }
                    FillForm();
                }
            }
        }
예제 #11
0
        private void importNutFromFolder(object sender, EventArgs e)
        {
            using (FolderSelectDialog f = new FolderSelectDialog())
            {
                if (f.ShowDialog() == DialogResult.OK)
                {
                    Edited = true;
                    if (!Directory.Exists(f.SelectedPath))
                    {
                        Directory.CreateDirectory(f.SelectedPath);
                    }
                    NUT nut;
                    nut = NUT;

                    foreach (var texPath in Directory.GetFiles(f.SelectedPath))
                    {
                        if (!(texPath.ToLower().EndsWith(".dds") || texPath.ToLower().EndsWith(".png")))
                        {
                            return;
                        }
                        int  texId;
                        bool isTex = int.TryParse(Path.GetFileNameWithoutExtension(texPath), NumberStyles.HexNumber,
                                                  new CultureInfo("en-US"), out texId);

                        NUT_Texture texture = null;
                        foreach (NUT_Texture tex in nut.Nodes)
                        {
                            if (tex.HASHID == texId)
                            {
                                texture = tex;
                            }
                        }

                        if (texture == null)
                        {
                            //new texture
                            NUT_Texture tex = null;
                            if (texPath.ToLower().EndsWith(".png"))
                            {
                                tex = fromPNG(texPath, 1);
                            }
                            if (texPath.ToLower().EndsWith(".dds"))
                            {
                                DDS dds = new DDS(new FileData(texPath));
                                tex = dds.toNUT_Texture();
                            }
                            if (isTex)
                            {
                                tex.HASHID = texId;
                            }
                            else
                            {
                                tex.HASHID = nut.Nodes.Count;
                            }
                            nut.Nodes.Add(tex);
                            nut.draw.Add(tex.HASHID, NUT.loadImage(tex));
                            FillForm();
                        }
                        else
                        {
                            //old texture
                            NUT_Texture tex = texture;

                            NUT_Texture ntex = null;
                            if (texPath.ToLower().EndsWith(".png"))
                            {
                                ntex = fromPNG(texPath, 1);
                            }
                            if (texPath.ToLower().EndsWith(".dds"))
                            {
                                DDS dds = new DDS(new FileData(texPath));
                                ntex = dds.toNUT_Texture();
                            }

                            tex.Height  = ntex.Height;
                            tex.Width   = ntex.Width;
                            tex.type    = ntex.type;
                            tex.mipmaps = ntex.mipmaps;
                            tex.utype   = ntex.utype;

                            GL.DeleteTexture(NUT.draw[tex.HASHID]);
                            NUT.draw.Remove(tex.HASHID);
                            NUT.draw.Add(tex.HASHID, NUT.loadImage(tex));
                            FillForm();
                        }
                    }
                    if (!Runtime.TextureContainers.Contains(nut))
                    {
                        Runtime.TextureContainers.Add(nut);
                    }
                }
            }
            FillForm();
        }
예제 #12
0
        private void importNutFromFolder(object sender, EventArgs e)
        {
            using (FolderSelectDialog f = new FolderSelectDialog())
            {
                if (f.ShowDialog() == DialogResult.OK)
                {
                    Edited = true;
                    if (!Directory.Exists(f.SelectedPath))
                    {
                        Directory.CreateDirectory(f.SelectedPath);
                    }
                    NUT nut;
                    nut = NUT;

                    foreach (var texPath in Directory.GetFiles(f.SelectedPath))
                    {
                        string extension = Path.GetExtension(texPath).ToLowerInvariant();
                        if (!(extension == ".dds" || extension == ".png"))
                        {
                            continue;
                        }
                        int  texId;
                        bool isTex = int.TryParse(Path.GetFileNameWithoutExtension(texPath), NumberStyles.HexNumber,
                                                  new CultureInfo("en-US"), out texId);

                        NutTexture texture = null;
                        if (isTex)
                        {
                            foreach (NutTexture tex in nut.Nodes)
                            {
                                if (tex.HASHID == texId)
                                {
                                    texture = tex;
                                }
                            }
                        }

                        if (texture == null)
                        {
                            //new texture
                            NutTexture tex = null;
                            if (extension == ".dds")
                            {
                                DDS dds = new DDS(new FileData(texPath));
                                tex = dds.toNUT_Texture();
                            }
                            else if (extension == ".png")
                            {
                                tex = fromPNG(texPath, 1);
                            }

                            if (isTex)
                            {
                                tex.HASHID = texId;
                            }
                            else
                            {
                                tex.HASHID = nut.Nodes.Count;
                            }
                            nut.Nodes.Add(tex);
                            NUT.glTexByHashId.Add(tex.HASHID, NUT.CreateGlTexture(tex));
                            FillForm();
                        }
                        else
                        {
                            //existing texture
                            NutTexture tex = texture;

                            NutTexture ntex = null;
                            if (extension == ".dds")
                            {
                                DDS dds = new DDS(new FileData(texPath));
                                ntex = dds.toNUT_Texture();
                            }
                            else if (extension == ".png")
                            {
                                ntex = fromPNG(texPath, 1);
                            }

                            tex.Height   = ntex.Height;
                            tex.Width    = ntex.Width;
                            tex.type     = ntex.type;
                            tex.surfaces = ntex.surfaces;
                            tex.utype    = ntex.utype;

                            GL.DeleteTexture(NUT.glTexByHashId[tex.HASHID]);
                            NUT.glTexByHashId.Remove(tex.HASHID);
                            NUT.glTexByHashId.Add(tex.HASHID, NUT.CreateGlTexture(tex));
                            FillForm();
                        }
                    }
                    if (!Runtime.TextureContainers.Contains(nut))
                    {
                        Runtime.TextureContainers.Add(nut);
                    }
                }
            }
            FillForm();
        }
예제 #13
0
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (NUT == null)
            {
                return;
            }
            using (var ofd = new OpenFileDialog())
            {
                ofd.Filter = "Supported Formats|*.dds;*.png|" +
                             "DirectDraw Surface (.dds)|*.dds|" +
                             "Portable Network Graphics (.png)|*.png|" +
                             "All files(*.*)|*.*";

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    int  texId;
                    bool isTex = int.TryParse(Path.GetFileNameWithoutExtension(ofd.FileName), NumberStyles.HexNumber,
                                              new CultureInfo("en-US"), out texId);

                    if (isTex)
                    {
                        foreach (NutTexture te in NUT.Nodes)
                        {
                            if (texId == te.HASHID)
                            {
                                isTex = false;
                            }
                        }
                    }

                    NutTexture tex       = null;
                    string     extension = Path.GetExtension(ofd.FileName).ToLowerInvariant();
                    if (extension == ".dds")
                    {
                        DDS dds = new DDS(new FileData(ofd.FileName));
                        tex = dds.toNUT_Texture();
                    }
                    else if (extension == ".png")
                    {
                        tex = fromPNG(ofd.FileName, 1);
                    }
                    else
                    {
                        return;
                    }

                    Edited = true;

                    if (isTex)
                    {
                        tex.HASHID = texId;
                    }
                    else
                    {
                        tex.HASHID = 0x40FFFF00 | (NUT.Nodes.Count);
                    }

                    if (NUT.glTexByHashId.ContainsKey(tex.HASHID))
                    {
                        NUT.glTexByHashId.Remove(tex.HASHID);
                    }

                    NUT.Nodes.Add(tex);
                    NUT.glTexByHashId.Add(tex.HASHID, NUT.CreateGlTexture(tex));
                    FillForm();
                }
            }
        }