Beispiel #1
0
		public UOResource(byte[] raw, ShaderTypes type, bool _isLegacy) {
			DDSImage img = new DDSImage(raw);
			_ddsData.width = img.images[0].Width;
			_ddsData.height = img.images[0].Height;
			_ddsData.format = img.format;
			_ddsData.rawData = ImageToByte2(img.images[0]);

			switch (type) {
				case ShaderTypes.Sprite: stype = "Sprites/Default"; break;
				case ShaderTypes.Terrain: stype = "Diffuse"; break;
				default: stype = "Sprites/Default"; break;
			}
		}
        public Bitmap CreateBitmapForResource(int id)
        {
            if (bitmap_cache.ContainsKey(id)) return bitmap_cache[id];
            if (mcd == null) return null;

            //make new bitmap
            var chip = mcd.FindChip(id);
            if (chip == null) return null;
            var res = mcd.FindRes(chip.resourceID);
            if (res == null) return null;
            if (!(res is ActTextureResourceInfoObject))
            {
                //unsupported format
                return null;
            }
            string path_rel = ((ActTextureResourceInfoObject)res).properties.stFilePath;
            string path = Path.Combine(this.root_folder, path_rel);

            //create bitmap
            if (Path.GetExtension(path) == ".png")
            {
                try
                {
                    string ex_path = Path.GetDirectoryName(path);
                    string ex_file = Path.GetFileNameWithoutExtension(path);
                    var ret = CreateBitmapFromCv2File(Path.Combine(ex_path, ex_file + ".cv2"));
                    //ret = ret.Clone(new Rectangle(chip.src_x, chip.src_y, chip.width, chip.height), ret.PixelFormat);
                    ret = MakeBitmapRegion(ret, chip.src_x, chip.src_y, chip.width, chip.height);
                    ret.Tag = Path.GetFileName(path);
                    bitmap_cache.Add(id, ret);
                    return ret;
                }
                catch
                {
                    return null;
                }
            }
            else if (Path.GetExtension(path) == ".dds")
            {
                try
                {
                    DDSImage dds = new DDSImage(File.ReadAllBytes(path));
                    if (dds.images.Length != 1)
                    {
                        return null;
                    }
                    var ret = dds.images[0];
                    //if (chip.width > ret.Width) chip.width = (short) ret.Width;
                    //if (chip.height > ret.Height) chip.height = (short)ret.Height;
                    //ret = ret.Clone(new Rectangle(chip.src_x, chip.src_y, chip.width, chip.height), ret.PixelFormat);
                    ret = MakeBitmapRegion(ret, chip.src_x, chip.src_y, chip.width, chip.height);
                    ret.Tag = Path.GetFileName(path);
                    bitmap_cache.Add(id, ret);
                    return ret;
                }
                catch
                {
                    return null;
                }
            }
            return null;
        }
Beispiel #3
0
        private void dgvSongs_SelectionChanged(object sender, EventArgs e)
        {
            if (dgvSongs.SelectedRows.Count > 0)
            {
                string taggedPreviewPath = Path.Combine(tbWorkingFolderPath.Text, "previews", dgvSongs.SelectedRows[0].Cells["colPath"].Value.ToString().Replace("dlc\\", "").Replace("_p.psarc", "") + "_tagged.png");
                string cleanPreviewPath = taggedPreviewPath.Replace("_tagged", "_clean");

                if (File.Exists(taggedPreviewPath))
                {
                    using (FileStream fs = new FileStream(taggedPreviewPath, FileMode.Open))
                    {
                        pictureBoxPreview.Image = Image.FromStream(fs);
                    }
                }
                else if (File.Exists(cleanPreviewPath))
                {
                    using (FileStream fs = new FileStream(cleanPreviewPath, FileMode.Open))
                    {
                        pictureBoxPreview.Image = Image.FromStream(fs);
                    }
                }
                else
                {
                    if (stopWatch.Elapsed.Seconds < 1)
                    {
                        try
                        {
                            if (DirOK())
                            {
                                ThreadPool.QueueUserWorkItem(delegate
                                  {
                                      string songPath = Path.Combine(tbRSPath.Text, dgvSongs.SelectedRows[0].Cells["colPath"].Value.ToString());

                                      songExtractedPath = Path.Combine(tbWorkingFolderPath.Text, Path.GetFileName(songPath.Replace(".psarc", "_Pc")));
                                      manifestsFolderPath = Path.Combine(songExtractedPath, "manifests");
                                      albumArtFolderPath = Path.Combine(songExtractedPath, "gfxassets", "album_art");
                                      toolkitVersionFilePath = Path.Combine(songExtractedPath, "toolkit.version");
                                      cleanPreviewPath = Path.Combine(tbWorkingFolderPath.Text, "previews", Path.GetFileName(songPath.Replace("_p.psarc", "")) + "_clean.png");

                                      try
                                      {
                                          if (Directory.Exists(songExtractedPath))
                                          {
                                              ClearDirectory(songExtractedPath);
                                              Directory.Delete(songExtractedPath, true);
                                          }
                                          Packer.Unpack(songPath, tbWorkingFolderPath.Text);
                                      }
                                      catch (IOException ex)
                                      {
                                          MessageBox.Show(ex.Message.ToString(), "Extracting error");
                                      }

                                      if (File.Exists(toolkitVersionFilePath))
                                      {
                                          albumMidArtPath = Directory.EnumerateFiles(albumArtFolderPath, "*128.dds").ToList()[0];
                                          albumBigArtPath = Directory.EnumerateFiles(albumArtFolderPath, "*256.dds").ToList()[0];

                                          albumArtDDS = new DDSImage(File.ReadAllBytes(albumBigArtPath));
                                          bigAlbumArt = albumArtDDS.images[0];

                                          midAlbumArt = ResizeImage(bigAlbumArt, 128, 128);

                                          if (File.Exists(cleanPreviewPath))
                                              File.Delete(cleanPreviewPath);
                                          if (!Directory.Exists(Path.Combine(tbWorkingFolderPath.Text, "previews")))
                                              Directory.CreateDirectory(Path.Combine(tbWorkingFolderPath.Text, "previews"));

                                          var imgToSave = midAlbumArt;
                                          imgToSave.Save(cleanPreviewPath, ImageFormat.Png);

                                          pictureBoxPreview.Image = midAlbumArt;

                                          if (checkDeleteExtractedOnDone.Checked)
                                          {
                                              if (Directory.Exists(songExtractedPath))
                                              {
                                                  ClearDirectory(songExtractedPath);
                                                  Directory.Delete(songExtractedPath, true);
                                              }
                                          }
                                      }
                                      else
                                      {
                                          if (Directory.Exists(songExtractedPath))
                                          {
                                              ClearDirectory(songExtractedPath);
                                              Directory.Delete(songExtractedPath, true);
                                          }
                                      }
                                  });
                            }
                        }
                        catch (IOException ex)
                        {
                            MessageBox.Show("Error: \n\n" + ex.Message.ToString(), "IO Error");
                        }
                        catch (ArgumentException)
                        {
                            MessageBox.Show("Make sure that you have all required files in the app folder: \n" +
                                            "-nvdxt.exe \n" +
                                            "-Newtonsoft.Json.dll \n" +
                                            "-RocksmithTookitLib.dll \n" +
                                            "-X360.dll \n" +
                                            "-zlib.net.dll \n" +
                                            "-MiscUtil.dll \n" +
                                            "-tags/" + tagsFolder + "/Background.png \n" +
                                            "-tags/" + tagsFolder + "/Lead.png \n" +
                                            "-tags/" + tagsFolder + "/Lead Bonus.png \n" +
                                            "-tags/" + tagsFolder + "/Rhythm.png \n" +
                                            "-tags/" + tagsFolder + "/Rhythm Bonus.png \n" +
                                            "-tags/" + tagsFolder + "/Custom.png \n" +
                                            "-tags/" + tagsFolder + "/Vocal.png");

                        }
                    }
                }
            }
        }
Beispiel #4
0
        private void btnShowPreview_Click(object sender, EventArgs e)
        {
            try
            {
                if (DirOK())
                {
                    bgWorker = new BackgroundWorker();
                    bgWorker.DoWork += delegate
                    {
                        Bitmap backgroundLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Background.png"));
                        Bitmap customTagLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Custom.png"));
                        Bitmap vocalLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Vocal.png"));
                        Bitmap leadLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Lead.png"));
                        Bitmap rhythmLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Rhythm.png"));
                        Bitmap bassLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Bass.png"));
                        Bitmap leadBonusLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Lead Bonus.png"));
                        Bitmap rhythmBonusLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Rhythm Bonus.png"));
                        Bitmap bassBonusLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Bass Bonus.png"));

                        string songPath = Path.Combine(tbRSPath.Text, dgvSongs.SelectedRows[0].Cells["colPath"].Value.ToString());

                        songExtractedPath = Path.Combine(tbWorkingFolderPath.Text, Path.GetFileName(songPath.Replace(".psarc", "_Pc")));
                        manifestsFolderPath = Path.Combine(songExtractedPath, "manifests");
                        albumArtFolderPath = Path.Combine(songExtractedPath, "gfxassets", "album_art");
                        toolkitVersionFilePath = Path.Combine(songExtractedPath, "toolkit.version");

                        Packer.Unpack(songPath, tbWorkingFolderPath.Text);

                        if (File.Exists(toolkitVersionFilePath))
                        {
                            albumBigArtPath = Directory.EnumerateFiles(albumArtFolderPath, "*256.dds").ToList()[0];

                            albumArtDDS = new DDSImage(File.ReadAllBytes(albumBigArtPath));
                            midAlbumArt = ResizeImage(albumArtDDS.images[0], 128, 128);

                            lead = false;
                            rhythm = false;
                            bass = false;
                            vocals = false;
                            bonusLead = false;
                            bonusRhythm = false;
                            bonusBass = false;

                            var arrangements = Directory.EnumerateFiles(manifestsFolderPath, "*.json", SearchOption.AllDirectories);

                            foreach (string arrangement in arrangements)
                            {
                                if (arrangement.Contains("lead") && !arrangement.Contains("lead2"))
                                    lead = true;
                                if (arrangement.Contains("lead2"))
                                    bonusLead = true;
                                if (arrangement.Contains("rhythm") && !arrangement.Contains("rhythm2"))
                                    rhythm = true;
                                if (arrangement.Contains("rhythm2"))
                                    bonusRhythm = true;
                                if (arrangement.Contains("bass") && !arrangement.Contains("bass2"))
                                    bass = true;
                                if (arrangement.Contains("bass2"))
                                    bonusBass = true;
                                if (arrangement.Contains("vocals"))
                                    vocals = true;
                            }

                            using (Graphics gra = Graphics.FromImage(midAlbumArt))
                            {
                                gra.DrawImage(backgroundLayer, 0, 0.5f);
                                if (vocals)
                                    gra.DrawImage(vocalLayer, 0, 0.5f);
                                if (bass)
                                    gra.DrawImage(bassLayer, 0, 0.5f);
                                if (bonusBass)
                                    gra.DrawImage(bassBonusLayer, 0, 0.5f);
                                if (rhythm)
                                    gra.DrawImage(rhythmLayer, 0, 0.5f);
                                if (bonusRhythm)
                                    gra.DrawImage(rhythmBonusLayer, 0, 0.5f);
                                if (lead)
                                    gra.DrawImage(leadLayer, 0, 0.5f);
                                if (bonusLead)
                                    gra.DrawImage(leadBonusLayer, 0, 0.5f);
                                gra.DrawImage(customTagLayer, 0, 0.5f);
                            }

                            pictureBoxPreview.Image = midAlbumArt;
                        }
                        //Clear dirs
                        Directory.Delete(songExtractedPath, true);
                    };
                    bgWorker.RunWorkerAsync();
                }
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Make sure that you have all required files in the app folder: \n" +
                                "-nvdxt.exe \n" +
                                "-Newtonsoft.Json.dll \n" +
                                "-RocksmithTookitLib.dll \n" +
                                "-X360.dll \n" +
                                "-zlib.net.dll \n" +
                                "-MiscUtil.dll \n" +
                                "-tags/" + tagsFolder + "/Background.png \n" +
                                "-tags/" + tagsFolder + "/Lead.png \n" +
                                "-tags/" + tagsFolder + "/Lead Bonus.png \n" +
                                "-tags/" + tagsFolder + "/Rhythm.png \n" +
                                "-tags/" + tagsFolder + "/Rhythm Bonus.png \n" +
                                "-tags/" + tagsFolder + "/Custom.png \n" +
                                "-tags/" + tagsFolder + "/Vocal.png");
            }
        }
Beispiel #5
0
        private void btnRemoveTags_Click(object sender, EventArgs e)
        {
            int counter = 0;

            try
            {
                if (DirOK())
                {
                    bgWorker = new BackgroundWorker();
                    bgWorker.DoWork += delegate
                    {
                        dgvSongs.InvokeIfRequired(delegate
                        {
                            songCount = dgvSongs.Rows.Cast<DataGridViewRow>().Where(row => (Convert.ToBoolean(row.Cells["colSelect"].Value) || row.Selected) && row.Cells["colTagged"].Value.ToString() == "Yes").ToList().Count();
                        });

                        statusStripMain.InvokeIfRequired(delegate
                        {
                            statusLblTagged.Text = "Tags removed on: 0/" + songCount;
                        });

                        foreach (DataGridViewRow song in dgvSongs.Rows)
                        {
                            if (((Convert.ToBoolean(song.Cells["colSelect"].Value)) || song.Selected) && song.Cells["colTagged"].Value.ToString() == "Yes")
                            {
                                string songPath = Path.Combine(tbRSPath.Text, song.Cells["colPath"].Value.ToString());

                                songExtractedPath = Path.Combine(tbWorkingFolderPath.Text, Path.GetFileName(songPath.Replace(".psarc", "_Pc")));
                                manifestsFolderPath = Path.Combine(songExtractedPath, "manifests");
                                albumArtFolderPath = Path.Combine(songExtractedPath, "gfxassets", "album_art");
                                toolkitVersionFilePath = Path.Combine(songExtractedPath, "toolkit.version");
                                taggedPreviewPath = Path.Combine(tbWorkingFolderPath.Text, "previews", Path.GetFileName(songPath.Replace("_p.psarc", "")) + "_tagged.png");

                                Packer.Unpack(songPath, tbWorkingFolderPath.Text);

                                if (File.Exists(toolkitVersionFilePath))
                                {
                                    albumSmallArtPath = Directory.EnumerateFiles(albumArtFolderPath, "*64.dds").ToList()[0];
                                    albumMidArtPath = Directory.EnumerateFiles(albumArtFolderPath, "*128.dds").ToList()[0];
                                    albumBigArtPath = Directory.EnumerateFiles(albumArtFolderPath, "*256.dds").ToList()[0];

                                    albumArtDDS = new DDSImage(File.ReadAllBytes(albumBigArtPath));
                                    bigAlbumArt = albumArtDDS.images[0];

                                    midAlbumArt = ResizeImage(bigAlbumArt, 128, 128);
                                    smallAlbumArt = ResizeImage(bigAlbumArt, 64, 64);

                                    //Delete existing album art
                                    if (File.Exists(albumMidArtPath))
                                        File.Delete(albumMidArtPath);

                                    if (File.Exists(albumSmallArtPath))
                                        File.Delete(albumSmallArtPath);

                                    //Save modified album art
                                    albumArtDDS.images[0] = midAlbumArt;
                                    albumArtDDS.images[0].Save("albumMidArt.png", ImageFormat.Png);

                                    ExternalApps.Png2Dds("albumMidArt.png", albumMidArtPath, 128, 128);

                                    if (!Directory.Exists(Path.Combine(tbWorkingFolderPath.Text, "previews")))
                                        Directory.CreateDirectory(Path.Combine(tbWorkingFolderPath.Text, "previews"));
                                    File.Copy("albumMidArt.png", taggedPreviewPath, true);
                                    File.Delete("albumMidArt.png");

                                    albumArtDDS.images[0] = smallAlbumArt;
                                    albumArtDDS.images[0].Save("albumSmallArt.png", ImageFormat.Png);

                                    ExternalApps.Png2Dds("albumSmallArt.png", albumSmallArtPath, 64, 64);

                                    File.Delete("albumSmallArt.png");

                                    //Delete existing song & repack it
                                    if (File.Exists(songPath))
                                        File.Delete(songPath);

                                    var songVar = SongCollection.FirstOrDefault(sng => sng == songPath);

                                    //Replace arrangement tags in file name, if they exist
                                    string[] split = songPath.Split('_');
                                    foreach (string part in split)
                                    {
                                        if (!part.Except("LlVvBbRr-").Any())
                                        {
                                            songPath = songPath.Replace(part, "-").Replace("_-", "").Replace("-_p.psarc", "_p.psarc");
                                        }
                                    }

                                    //Just in case that the changes don't go too well, remove "-" again
                                    if (songPath.EndsWith("-_p.psarc"))
                                        songPath = songPath.Replace("-_p.psarc", "_p.psarc");

                                    if (songPath.EndsWith("-_p.disabled.psarc"))
                                        songPath = songPath.Replace("-_p.disabled.psarc", "_p.disabled.psarc");

                                    Packer.Pack(songExtractedPath, songPath);
                                    File.SetCreationTime(songPath, DateTime.Now);

                                    counter += 1;
                                    statusLblTagged.Text = "Tags removed on: " + counter + "/" + songCount;
                                    songVar = songPath;

                                    string songAndFolderPath = new FileInfo(songPath).Directory.FullName.Replace(tbRSPath.Text + @"\", "").Replace(tbRSPath.Text, "");
                                    string fileName = Path.GetFileName(songPath);
                                    songPath = Path.Combine(songAndFolderPath, fileName);

                                    song.Cells["colTagged"].Value = "No";
                                    song.Cells["colPath"].Value = songPath;

                                    //Delete extracted folders if needed
                                    if (checkDeleteExtractedOnDone.Checked)
                                        Directory.Delete(songExtractedPath, true);
                                }
                                else
                                    songCount -= 1;
                            }
                        }
                        if (counter > 0 && songCount > 0)
                        {
                            MessageBox.Show("Removing tags finished!", "Done");
                            statusLblTagged.Text = "Removing tags finished!";
                        }
                    };
                    bgWorker.RunWorkerAsync();
                }
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Make sure that you have all required files in the app folder: \n" +
                                "-nvdxt.exe \n" +
                                "-Newtonsoft.Json.dll \n" +
                                "-RocksmithTookitLib.dll \n" +
                                "-X360.dll \n" +
                                "-zlib.net.dll \n" +
                                "-MiscUtil.dll \n" +
                                "-tags/" + tagsFolder + "/Background.png \n" +
                                "-tags/" + tagsFolder + "/Lead.png \n" +
                                "-tags/" + tagsFolder + "/Lead Bonus.png \n" +
                                "-tags/" + tagsFolder + "/Rhythm.png \n" +
                                "-tags/" + tagsFolder + "/Rhythm Bonus.png \n" +
                                "-tags/" + tagsFolder + "/Custom.png \n" +
                                "-tags/" + tagsFolder + "/Vocal.png");
            }
            catch (IOException ex)
            {
                MessageBox.Show("Error: \n\n" + ex.Message.ToString(), "IO Error");
            }
        }
Beispiel #6
0
        private void btnProcessSelected_Click(object sender, EventArgs e)
        {
            string pathExtension = "_";
            int counter = 0;

            try
            {
                Bitmap backgroundLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Background.png"));
                Bitmap customTagLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Custom.png"));
                Bitmap vocalLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Vocal.png"));
                Bitmap leadLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Lead.png"));
                Bitmap rhythmLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Rhythm.png"));
                Bitmap bassLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Bass.png"));
                Bitmap leadBonusLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Lead Bonus.png"));
                Bitmap rhythmBonusLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Rhythm Bonus.png"));
                Bitmap bassBonusLayer = new Bitmap(Path.Combine("tags", tagsFolder, "Bass Bonus.png"));

                if (DirOK())
                {
                    bgWorker = new BackgroundWorker();
                    bgWorker.DoWork += delegate
                    {
                        bool overwriteTags = checkOverwriteTagsOnTaggedSongs.Checked;
                        dgvSongs.InvokeIfRequired(delegate
                        {
                            songCount = dgvSongs.Rows.Cast<DataGridViewRow>().Where(row => ((Convert.ToBoolean(row.Cells["colSelect"].Value)) || row.Selected)).ToList().Count();
                        });

                        statusStripMain.InvokeIfRequired(delegate
                        {
                            statusLblTagged.Text = "Tagged: 0/" + songCount;
                        });

                        foreach (DataGridViewRow song in dgvSongs.Rows)
                        {
                            bool songTagged = song.Cells["colTagged"].Value.ToString() == "Yes" ? true : false;
                            if ((Convert.ToBoolean(song.Cells["colSelect"].Value) || song.Selected))
                            {
                                if (!songTagged || (songTagged && overwriteTags))
                                {
                                    pathExtension = "_";

                                    string songPath = Path.Combine(tbRSPath.Text, song.Cells["colPath"].Value.ToString());

                                    songExtractedPath = Path.Combine(tbWorkingFolderPath.Text, Path.GetFileName(songPath.Replace(".psarc", "_Pc")));
                                    manifestsFolderPath = Path.Combine(songExtractedPath, "manifests");
                                    albumArtFolderPath = Path.Combine(songExtractedPath, "gfxassets", "album_art");
                                    toolkitVersionFilePath = Path.Combine(songExtractedPath, "toolkit.version");
                                    taggedPreviewPath = Path.Combine(tbWorkingFolderPath.Text, "previews", Path.GetFileName(songPath.Replace("_p.psarc", "")) + "_tagged.png");
                                    cleanPreviewPath = Path.Combine(tbWorkingFolderPath.Text, "previews", Path.GetFileName(songPath.Replace("_p.psarc", "")) + "_clean.png");

                                    Packer.Unpack(songPath, tbWorkingFolderPath.Text);

                                    if (File.Exists(toolkitVersionFilePath))
                                    {
                                        albumSmallArtPath = Directory.EnumerateFiles(albumArtFolderPath, "*64.dds").ToList()[0];
                                        albumMidArtPath = Directory.EnumerateFiles(albumArtFolderPath, "*128.dds").ToList()[0];
                                        albumBigArtPath = Directory.EnumerateFiles(albumArtFolderPath, "*256.dds").ToList()[0];

                                        albumArtDDS = new DDSImage(File.ReadAllBytes(albumBigArtPath));
                                        bigAlbumArt = albumArtDDS.images[0];

                                        midAlbumArt = ResizeImage(bigAlbumArt, 128, 128);
                                        smallAlbumArt = ResizeImage(bigAlbumArt, 64, 64);

                                        if (!Directory.Exists(Path.Combine(tbWorkingFolderPath.Text, "previews")))
                                            Directory.CreateDirectory(Path.Combine(tbWorkingFolderPath.Text, "previews"));

                                        midAlbumArt.Save("albumMidArt.png", ImageFormat.Png);
                                        File.Copy("albumMidArt.png", cleanPreviewPath, true);
                                        File.Delete("albumMidArt.png");

                                        //Check which arrangements it contains
                                        lead = false;
                                        rhythm = false;
                                        bass = false;
                                        vocals = false;
                                        bonusLead = false;
                                        bonusRhythm = false;
                                        bonusBass = false;
                                        DD = false;

                                        var arrangements = Directory.EnumerateFiles(manifestsFolderPath, "*.json", SearchOption.AllDirectories);

                                        foreach (string arrangement in arrangements)
                                        {
                                            // arrangement.Substring(arrangement.LastIndexOf("_") + 1, arrangement.Length - arrangement.LastIndexOf(".") + 1);
                                            if (arrangement.Contains("lead") && !arrangement.Contains("lead2"))
                                            {
                                                lead = true;
                                                pathExtension += "L";
                                                if (!DD)
                                                    DD = HasDD(arrangement);
                                            }
                                            if (arrangement.Contains("lead2"))
                                            {
                                                bonusLead = true;
                                                pathExtension += "l";
                                                if (!DD)
                                                    DD = HasDD(arrangement);
                                            }
                                            if (arrangement.Contains("rhythm") && !arrangement.Contains("rhythm2"))
                                            {
                                                rhythm = true;
                                                pathExtension += "R";
                                                if (!DD)
                                                    DD = HasDD(arrangement);
                                            }
                                            if (arrangement.Contains("rhythm2"))
                                            {
                                                bonusRhythm = true;
                                                pathExtension = "r";
                                                if (!DD)
                                                    DD = HasDD(arrangement);
                                            }
                                            if (arrangement.Contains("bass") && !arrangement.Contains("bass2"))
                                            {
                                                bass = true;
                                                pathExtension += "B";
                                                if (!DD)
                                                    DD = HasDD(arrangement);
                                            }
                                            if (arrangement.Contains("bass2"))
                                            {
                                                bonusBass = true;
                                                pathExtension += "b";
                                                if (!DD)
                                                    DD = HasDD(arrangement);
                                            }
                                            if (arrangement.Contains("vocals"))
                                            {
                                                vocals = true;
                                                pathExtension += "V";
                                            }
                                        }

                                        //Add layers to big album art
                                        using (Graphics gra = Graphics.FromImage(midAlbumArt))
                                        {
                                            gra.DrawImage(backgroundLayer, 0, 0.5f);
                                            if (vocals)
                                                gra.DrawImage(vocalLayer, 0, 0.5f);
                                            if (bass)
                                                gra.DrawImage(bassLayer, 0, 0.5f);
                                            if (bonusBass)
                                                gra.DrawImage(bassBonusLayer, 0, 0.5f);
                                            if (rhythm)
                                                gra.DrawImage(rhythmLayer, 0, 0.5f);
                                            if (bonusRhythm)
                                                gra.DrawImage(rhythmBonusLayer, 0, 0.5f);
                                            if (lead)
                                                gra.DrawImage(leadLayer, 0, 0.5f);
                                            if (bonusLead)
                                                gra.DrawImage(leadBonusLayer, 0, 0.5f);
                                            gra.DrawImage(customTagLayer, 0, 0.5f);
                                        }

                                        //Draw layers to small album art
                                        using (Graphics gra = Graphics.FromImage(smallAlbumArt))
                                        {
                                            gra.DrawImage(new Bitmap(backgroundLayer, backgroundLayer.Width / 2, backgroundLayer.Height / 2), 0, 1.0f);
                                            if (vocals)
                                                gra.DrawImage(new Bitmap(vocalLayer, vocalLayer.Width / 2, vocalLayer.Height / 2), 0, 1.0f);
                                            if (bass)
                                                gra.DrawImage(new Bitmap(bassLayer, vocalLayer.Width / 2, vocalLayer.Height / 2), 0, 1.0f);
                                            if (bonusBass)
                                                gra.DrawImage(new Bitmap(bassBonusLayer, vocalLayer.Width / 2, vocalLayer.Height / 2), 0, 1.0f);
                                            if (rhythm)
                                                gra.DrawImage(new Bitmap(rhythmLayer, vocalLayer.Width / 2, vocalLayer.Height / 2), 0, 1.0f);
                                            if (bonusRhythm)
                                                gra.DrawImage(new Bitmap(rhythmLayer, vocalLayer.Width / 2, vocalLayer.Height / 2), 0, 1.0f);
                                            if (lead)
                                                gra.DrawImage(new Bitmap(leadLayer, vocalLayer.Width / 2, vocalLayer.Height / 2), 0, 1.0f);
                                            if (bonusLead)
                                                gra.DrawImage(new Bitmap(leadBonusLayer, vocalLayer.Width / 2, vocalLayer.Height / 2), 0, 1.0f);
                                            gra.DrawImage(new Bitmap(customTagLayer, customTagLayer.Width / 2, customTagLayer.Height / 2), 0, 1.0f);
                                        }

                                        //Delete existing album art
                                        if (File.Exists(albumMidArtPath))
                                            File.Delete(albumMidArtPath);

                                        if (File.Exists(albumSmallArtPath))
                                            File.Delete(albumSmallArtPath);

                                        //Save modified album art
                                        midAlbumArt.Save("albumMidArt.png", ImageFormat.Png);

                                        ExternalApps.Png2Dds("albumMidArt.png", albumMidArtPath, 128, 128);
                                        File.Copy("albumMidArt.png", taggedPreviewPath, true);

                                        File.Delete("albumMidArt.png");

                                        smallAlbumArt.Save("albumSmallArt.png", ImageFormat.Png);

                                        ExternalApps.Png2Dds("albumSmallArt.png", albumSmallArtPath, 64, 64);

                                        File.Delete("albumSmallArt.png");

                                        // Delete existing song & repack it
                                        if (File.Exists(songPath))
                                            File.Delete(songPath);

                                        var songVar = SongCollection.FirstOrDefault(sng => sng == songPath);

                                        //Add file name tags if the checkbox is checked
                                        if (checkAddTagsToFileName.Checked)
                                            songPath = songPath.Replace("_p.", pathExtension + "_p.");

                                        Packer.Pack(songExtractedPath, songPath);
                                        File.SetCreationTime(songPath, new DateTime(1990, 1, 1));

                                        counter += 1;
                                        statusLblTagged.Text = "Tagged: " + counter + "/" + songCount;

                                        songVar = songPath;

                                        string songAndFolderPath = new FileInfo(songPath).Directory.FullName.Replace(tbRSPath.Text + @"\", "").Replace(tbRSPath.Text, "");
                                        string fileName = Path.GetFileName(songPath);

                                        songPath = Path.Combine(songAndFolderPath, fileName);

                                        song.Cells["colTagged"].Value = "Yes";
                                        song.Cells["colPath"].Value = songPath;

                                        //Delete extracted folders if needed
                                        if (checkDeleteExtractedOnDone.Checked)
                                            Directory.Delete(songExtractedPath, true);
                                    }
                                    else
                                    {
                                        Directory.Delete(songExtractedPath, true);
                                        songCount -= 1;
                                    }
                                }
                            }
                        }
                        if (counter > 0 && songCount > 0)
                        {
                            MessageBox.Show("Tagging finished!", "Done");
                            statusLblTagged.Text = "Tagging finished!";
                        }
                    };
                    bgWorker.RunWorkerAsync();
                }
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Make sure that you have all required files in the app folder: \n" +
                                "-nvdxt.exe \n" +
                                "-Newtonsoft.Json.dll \n" +
                                "-RocksmithTookitLib.dll \n" +
                                "-X360.dll \n" +
                                "-zlib.net.dll \n" +
                                "-MiscUtil.dll \n" +
                                "-tags/" + tagsFolder + "/Background.png \n" +
                                "-tags/" + tagsFolder + "/Lead.png \n" +
                                "-tags/" + tagsFolder + "/Lead Bonus.png \n" +
                                "-tags/" + tagsFolder + "/Rhythm.png \n" +
                                "-tags/" + tagsFolder + "/Rhythm Bonus.png \n" +
                                "-tags/" + tagsFolder + "/Custom.png \n" +
                                "-tags/" + tagsFolder + "/Vocal.png");
            }
            catch (IOException ex)
            {
                MessageBox.Show("Error: \n\n" + ex.Message.ToString(), "IO Error");
            }
        }
Beispiel #7
0
        private unsafe void ReadStaticTexture(int index, out Texture2D texture, out Tileart tileart)
        {
            uint resource = 0xFFFFFFFF;
            string resPath = "ERROR";
            bool resize;

            int x;
            int y;
            int width;
            int height;

            using (FileStream fs = new FileStream(string.Format(FileManager.GetPath("EC/build/tileart/{0:d8}.bin"), index), FileMode.Open))
            using (BinaryReader r = new BinaryReader(fs))
                tileart = Tileart.readTileart(r);

            x = 0;
            y = 0;
            width = 44;
            height = 44;
            resize = false;

            //WorldArt Texture
            if (tileart.textures[0].texturePresent == -1)
            {
                resource = tileart.textures[0].texturesArray[0].textureIDX;
                resPath = string.Format(FileManager.GetPath("EC/build/worldart/{0:d8}.dds"), index);

                if (!File.Exists(resPath))
                {
                    resource = 0xFFFFFFFF;
                }
                else
                {
                    x = tileart.offsetEC.Xstart;
                    y = 0;
                    width = tileart.offsetEC.Width;
                    height = tileart.offsetEC.Height;

                    if (width == 0)
                    {
                        width = height = 64;
                    }
                    resize = true;
                }
            }
            //LegacyTexture
            if (resource == 0xFFFFFFFF && tileart.textures[1].texturePresent == 1)
            {
                //resource = tileart.textures[1].texturesArray[0].textureIDX;
                resource = 0;
                resPath = string.Format(FileManager.GetPath("EC/build/tileartlegacy/{0:d8}.dds"), index);
                if (!File.Exists(resPath))
                {
                    resource = 0xFFFFFFFF;
                }
                else
                {
                    x = tileart.offset2D.Xstart;
                    y = tileart.offset2D.Ystart;
                    width = tileart.offset2D.Width;
                    height = tileart.offset2D.Height;

                    if (width == 0)
                    {
                        width = height = 44;
                    }
                }
            }
            //EnhancedTexture
            //Is this really necessary?
            //Light Texture
            if (resource != 0xFFFFFFFF && tileart.textures[3].texturePresent == 1)
            {
                //TODO: light texture load
            }

            if (resource == 0xFFFFFFFF)
                throw new System.Exception("Missing IMAGE!");

            DDSImage img = new DDSImage(File.ReadAllBytes(resPath));

            //Metrics.ReportDataRead((int)filestream.Length);
            using (MemoryStream ms = new MemoryStream())
            {
                img.images[0].Save(ms, ImageFormat.Png);
                Texture2D temp;

                if (resize)//HERE WE SCALE THE IMAGE
                {
                    temp = Texture2D.FromStream(m_Graphics, ms, (int)(img.images[0].Width * 0.6875), (int)(img.images[0].Height * 0.6875), true);
                    x = (int)(x * 0.6875);
                    y = (int)(y * 0.6875);
                    width = (int)(width * 0.6875);
                    height = (int)(height * 0.6875);
                }
                else
                    temp = Texture2D.FromStream(m_Graphics, ms);

                if ((width + x) > temp.Width)
                    width = temp.Width - x;
                if ((height + y) > temp.Height)
                    height = temp.Height - y;

                uint[] texData = new uint[width * height];
                temp.GetData<uint>(
                    0,
                    new Rectangle(
                        x,
                        y,
                        width,
                        height),
                    texData,
                    0,
                    width * height);

                texture = new Texture2D(m_Graphics, width, height, false, SurfaceFormat.Color);
                texture.SetData(texData);

            }
            return;
        }
Beispiel #8
0
        /// <summary>
        /// Displays the contents of a FileRecord in the ImageBox (DDS Texture mode)
        /// </summary>
        /// <param name="selectedRecord">FileRecord to display</param>
        private void DisplayDDS(FileRecord selectedRecord)
        {
            byte[] buffer = selectedRecord.ReadData(ggpkPath);
            imageOutput.Visibility = System.Windows.Visibility.Visible;

            DDSImage dds = new DDSImage(buffer);

            using (MemoryStream ms = new MemoryStream())
            {
                dds.images[0].Save(ms, ImageFormat.Png);

                BitmapImage bmp = new BitmapImage();
                bmp.BeginInit();
                bmp.CacheOption = BitmapCacheOption.OnLoad;
                bmp.StreamSource = ms;
                bmp.EndInit();
                imageOutput.Source = bmp;
            }
        }
Beispiel #9
0
 private void LoadOverview()
 {
     try
     {
         overviewImage = new DDSImage(File.ReadAllBytes(ProjectMoretz.MainForm.overviewsPath + "\\" + mapName + "_radar.dds"));
     }
     catch (Exception e) { Console.WriteLine("Error loading overview: " + e.Message); }
 }