Esempio n. 1
0
        private void ReplaceCharacterImage(string image)
        {
            Tools.CurrentFolder = Path.GetDirectoryName(image);
            console             = isPS3 ? "ps3" : (isWii ? "wii" : "xbox");
            var xfile  = ImageFolder + "character_" + (cboCharacter.SelectedIndex + 1) + ".png_" + console;
            var file   = ImageFolder + "character_" + (cboCharacter.SelectedIndex + 1) + ".png";
            var backup = xfile + ".bak";

            File.Copy(xfile, backup);

            Tools.isSaveFileCharacter = true;
            Tools.isSaveFileArt       = false;
            Tools.TextureSize         = isWii? 256 : 512;
            Tools.isVerticalTexture   = true;

            if (isWii)
            {
                Tools.ConvertImagetoWii(wimgt, image, xfile);
            }
            else
            {
                Tools.ConvertImagetoRB(image, xfile, false, isPS3);
            }


            if (File.Exists(xfile))
            {
                Tools.DeleteFile(file);
                if (isWii)
                {
                    Tools.ConvertWiiImage(xfile, image, file);
                }
                else
                {
                    Tools.ConvertRBImage(xfile, file);
                }
                picCharacter.Image = Tools.NemoLoadImage(file);
                Log("Replaced image for character '" + cboCharacter.Items[cboCharacter.SelectedIndex] + "' successfully");
                NeedsToSave(true);
                Log("Ready");
                Tools.DeleteFile(backup);
                return;
            }
            Log("Replacing image for character '" + cboCharacter.Items[cboCharacter.SelectedIndex] + "' failed");

            //set everything back
            File.Move(backup, xfile);
            Tools.DeleteFile(file);
            if (isWii)
            {
                Tools.ConvertImagetoWii(wimgt, image, xfile);
            }
            else
            {
                Tools.ConvertImagetoRB(image, xfile, false, isPS3);
            }
            ChangeImagePadding();
            picCharacter.Image = Tools.NemoLoadImage(file);
        }
Esempio n. 2
0
        /// <summary>
        /// Extracts images from Milo file and saves textures in "(miloDir)/ext_(milofilename)"
        /// as "texture(int)" starting from zero.
        /// </summary>
        /// <param name="inMilo">Milo file location</param>
        /// <param name="saveDDS">Save DDS?</param>
        /// <param name="saveTEX">Save TEX?</param>
        /// <param name="format">Format to output the images to</param>
        /// <param name="outTexCount">Number of textures in Milo file</param>
        public static void ExtractTextures(string inMilo, bool saveDDS, bool saveTEX, string format, out int outTexCount)
        {
            var texCount = 0;
            var Tools    = new NemoTools();
            var ext      = Path.GetExtension(inMilo);

            if (string.IsNullOrWhiteSpace(ext))
            {
                outTexCount = 0;
                return;
            }
            TexturesFolder = inMilo.Replace(ext, "_textures\\");
            BlocksFolder   = TexturesFolder + "blocks\\";
            FilesFolder    = TexturesFolder + "files\\";

            try
            {
                // Reads first four bytes to check its compression type.
                var br        = new BinaryReader(File.OpenRead(inMilo));
                var firstFour = br.ReadBytes(4);
                br.Close();

                string compressionType;
                if (firstFour.IsMilo(out compressionType))
                {
                    var count = 0;
                    ProcessMilo(inMilo, compressionType, true, saveTEX, ref texCount, false, ref count, false, ref count);
                }
            }
            catch (Exception)
            {}
            outTexCount = texCount;

            //clean up afterwards
            if (outTexCount < 1)
            {
                Tools.DeleteFolder(TexturesFolder, true);
            }
            else
            {
                Tools.DeleteFolder(BlocksFolder, true);
                Tools.DeleteFolder(FilesFolder, true);

                var ddsfiles = Directory.GetFiles(TexturesFolder, "*.dds");
                foreach (var dds in ddsfiles)
                {
                    if (!string.IsNullOrWhiteSpace(format))
                    {
                        Tools.ConvertRBImage(dds, dds, format);
                    }
                    if (!saveDDS)
                    {
                        Tools.DeleteFile(dds);
                    }
                }
            }
            outTexCount = texCount;
        }
Esempio n. 3
0
        private void lstFiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            var file = folder + lstFiles.SelectedItem;

            if (!File.Exists(file))
            {
                MessageBox.Show("Couldn't find that file!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            var fileSize = new FileInfo(file);
            var info     = "";

            if (extension == ".png_xbox")
            {
                var png = Application.StartupPath + "\\bin\\temp.png";
                Tools.DeleteFile(png);
                if (!Tools.ConvertRBImage(file, png))
                {
                    return;
                }

                var img = Tools.NemoLoadImage(png);
                picImage.Image = img;
                info           = "Dimensions: " + img.Height + "x" + img.Width;
            }

            if (extension == ".mogg")
            {
                var bytes = File.ReadAllBytes(file);

                info = "Encrypted? " + (bytes[0] == 0x0A ? "No" : "Yes (0x" + bytes[0].ToString("X2") + ")");
            }

            var size = "Size: ";

            if (fileSize.Length >= 1048576)
            {
                size = size + (Math.Round((double)fileSize.Length / 1048576, 2)) + " MB";
            }
            else
            {
                size = size + (Math.Round((double)fileSize.Length / 1024, 2)) + " KB";
            }

            lblInformation.Text = size + (string.IsNullOrEmpty(info) ? "" : "   |   " + info);

            if (starting)
            {
                return;
            }

            timer1.Enabled   = false;
            lblTimer.Visible = false;
        }
Esempio n. 4
0
        private void fromXbox(string image)
        {
            var pngfile = Path.GetDirectoryName(image) + "\\album.png";

            try
            {
                Log(Tools.ConvertRBImage(image, pngfile, "png", true) ? "Converted album art file to 'album.png' successfully" : "There was an error when converting the album art file");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something went wrong when trying to convert the album art file\nfrom the native Rock Band format\nSorry\n\nThe message says: " + ex.Message,
                                Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Log("There was an error when converting the album art file");
                Log("The error says: " + ex.Message);
            }
        }
Esempio n. 5
0
        private void FromPS3(string image)
        {
            if (!File.Exists(image))
            {
                return;
            }

            imgCounter++;
            Log("Converting file " + imgCounter + " of " + imagesPS3.Count());
            Log(" - " + Path.GetFileName(image));

            var success = false;

            // Save the image
            if (chkPS3BMP.Checked)
            {
                success = Tools.ConvertRBImage(image, image, "bmp");
            }
            if (chkPS3PNG.Checked)
            {
                success = Tools.ConvertRBImage(image, image, "png");
            }
            if (chkPS3JPG.Checked)
            {
                success = Tools.ConvertRBImage(image, image, "jpg");
            }

            if (success)
            {
                //if clean up box checked, delete originals
                if (chkCleanUpPS3.Checked)
                {
                    Tools.SendtoTrash(image);
                }
                Log("Converted from png_ps3 format successfully");
            }
            else
            {
                Log("Error converting from png_ps3 format");
            }
        }