private void OpenLibrary(string filename) { ClearInterface(); ImageList.Images.Clear(); PreviewListView.Items.Clear(); _indexList.Clear(); if (_library != null) { _library.Close(); } _library = new MLibraryV2(filename); PreviewListView.VirtualListSize = _library.Images.Count; // Show .Lib path in application title. this.Text = filename; PreviewListView.SelectedIndices.Clear(); if (PreviewListView.Items.Count > 0) { PreviewListView.Items[0].Selected = true; } UpdateFrameGridView(); }
private void copyToToolStripMenuItem_Click(object sender, EventArgs e) { if (PreviewListView.SelectedIndices.Count == 0) { return; } if (SaveLibraryDialog.ShowDialog() != DialogResult.OK) { return; } MLibraryV2 tempLibrary = new MLibraryV2(SaveLibraryDialog.FileName); List <int> copyList = new List <int>(); for (int i = 0; i < PreviewListView.SelectedIndices.Count; i++) { copyList.Add(PreviewListView.SelectedIndices[i]); } copyList.Sort(); for (int i = 0; i < copyList.Count; i++) { MLibraryV2.MImage image = _library.GetMImage(copyList[i]); tempLibrary.AddImage(image.Image, image.MaskImage, image.X, image.Y); } tempLibrary.Save(); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (OpenLibraryDialog.ShowDialog() != DialogResult.OK) { return; } ClearInterface(); ImageList.Images.Clear(); PreviewListView.Items.Clear(); _indexList.Clear(); if (_library != null) { _library.Close(); } _library = new MLibraryV2(OpenLibraryDialog.FileName); PreviewListView.VirtualListSize = _library.Images.Count; // Show .Lib path in application title. this.Text = OpenLibraryDialog.FileName.ToString(); PreviewListView.SelectedIndices.Clear(); if (PreviewListView.Items.Count > 0) { PreviewListView.Items[0].Selected = true; } }
private void convertToolStripMenuItem_Click(object sender, EventArgs e) { if (OpenWeMadeDialog.ShowDialog() != DialogResult.OK) { return; } toolStripProgressBar.Maximum = OpenWeMadeDialog.FileNames.Length; toolStripProgressBar.Value = 0; try { ParallelOptions options = new ParallelOptions { MaxDegreeOfParallelism = 1 }; Parallel.For(0, OpenWeMadeDialog.FileNames.Length, options, i => { if (Path.GetExtension(OpenWeMadeDialog.FileNames[i]).ToUpper() == ".WTL") { WTLLibrary WTLlib = new WTLLibrary(OpenWeMadeDialog.FileNames[i]); WTLlib.ToMLibrary(); } else if (Path.GetExtension(OpenWeMadeDialog.FileNames[i]).ToUpper() == ".LIB") { FileStream stream = new FileStream(OpenWeMadeDialog.FileNames[i], FileMode.Open, FileAccess.ReadWrite); BinaryReader reader = new BinaryReader(stream); int CurrentVersion = reader.ReadInt32(); stream.Close(); stream.Dispose(); reader.Dispose(); if (CurrentVersion == 1) { MLibrary v1Lib = new MLibrary(OpenWeMadeDialog.FileNames[i]); v1Lib.ToMLibrary(); } else { MLibraryV2 v2Lib = new MLibraryV2(OpenWeMadeDialog.FileNames[i]); v2Lib.ToMLibrary(); } } else { WeMadeLibrary WILlib = new WeMadeLibrary(OpenWeMadeDialog.FileNames[i]); WILlib.ToMLibrary(); } toolStripProgressBar.Value++; }); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } toolStripProgressBar.Value = 0; MessageBox.Show(string.Format("Successfully converted {0} {1}", (OpenWeMadeDialog.FileNames.Length).ToString(), (OpenWeMadeDialog.FileNames.Length > 1) ? "libraries" : "library")); }
public LMain() { InitializeComponent(); SendMessage(PreviewListView.Handle, 4149, 0, 5242946); //80 x 66 this.AllowDrop = true; this.DragEnter += new DragEventHandler(Form1_DragEnter); this.DragDrop += new DragEventHandler(Form1_DragDrop); if (Program.openFileWith.Length > 0 && File.Exists(Program.openFileWith)) { _library = new MLibraryV2(Program.openFileWith); PreviewListView.VirtualListSize = _library.Images.Count; // Show .Lib path in application title. FileInfo fileInfo = new FileInfo(Program.openFileWith); this.Text = fileInfo.FullName.ToString(); OpenLibraryDialog.FileName = fileInfo.Name; PreviewListView.SelectedIndices.Clear(); if (PreviewListView.Items.Count > 0) { PreviewListView.Items[0].Selected = true; } } }
private void countBlanksToolStripMenuItem_Click(object sender, EventArgs e) { OpenLibraryDialog.Multiselect = true; if (OpenLibraryDialog.ShowDialog() != DialogResult.OK) { OpenLibraryDialog.Multiselect = false; return; } OpenLibraryDialog.Multiselect = false; MLibraryV2.Load = false; int count = 0; for (int i = 0; i < OpenLibraryDialog.FileNames.Length; i++) { MLibraryV2 library = new MLibraryV2(OpenLibraryDialog.FileNames[i]); for (int x = 0; x < library.Count; x++) { if (library.Images[x].Length <= 8) { count++; } } library.Close(); } MLibraryV2.Load = true; MessageBox.Show(count.ToString()); }
private void Form1_DragDrop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (Path.GetExtension(files[0]).ToUpper() == ".WIL" || Path.GetExtension(files[0]).ToUpper() == ".WZL" || Path.GetExtension(files[0]).ToUpper() == ".MIZ") { try { ParallelOptions options = new ParallelOptions { MaxDegreeOfParallelism = 8 }; Parallel.For(0, files.Length, options, i => { if (Path.GetExtension(files[i]) == ".wtl") { WTLLibrary WTLlib = new WTLLibrary(files[i]); WTLlib.ToMLibrary(); } else { WeMadeLibrary WILlib = new WeMadeLibrary(files[i]); WILlib.ToMLibrary(); } toolStripProgressBar.Value++; }); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } toolStripProgressBar.Value = 0; MessageBox.Show( string.Format("Successfully converted {0} {1}", (OpenWeMadeDialog.FileNames.Length).ToString(), (OpenWeMadeDialog.FileNames.Length > 1) ? "libraries" : "library")); } else if (Path.GetExtension(files[0]).ToUpper() == ".LIB") { ClearInterface(); ImageList.Images.Clear(); PreviewListView.Items.Clear(); _indexList.Clear(); if (_library != null) _library.Close(); _library = new MLibraryV2(files[0]); PreviewListView.VirtualListSize = _library.Images.Count; PreviewListView.RedrawItems(0, PreviewListView.Items.Count - 1, true); // Show .Lib path in application title. this.Text = files[0].ToString(); } else { return; } }
public static void ProcessDir(string sourceDir, int recursionLvl, string outputDir) { if (recursionLvl <= HowDeepToScan) { // Process the list of files found in the directory. string[] fileEntries = Directory.GetFiles(sourceDir); foreach (string fileName in fileEntries) { if (Directory.Exists(outputDir) != true) Directory.CreateDirectory(outputDir); MLibraryv0 OldLibrary = new MLibraryv0(fileName); MLibraryV2 NewLibrary = new MLibraryV2(outputDir + Path.GetFileName(fileName)) { Images = new List<MLibraryV2.MImage>(), IndexList = new List<int>(), Count = OldLibrary.Images.Count }; ; for (int i = 0; i < OldLibrary.Images.Count; i++) NewLibrary.Images.Add(null); for (int j = 0; j < OldLibrary.Images.Count; j++) { MLibraryv0.MImage oldimage = OldLibrary.GetMImage(j); NewLibrary.Images[j] = new MLibraryV2.MImage(oldimage.FBytes, oldimage.Width, oldimage.Height) { X = oldimage.X, Y = oldimage.Y }; } NewLibrary.Save(); for (int i = 0; i < NewLibrary.Images.Count; i++) { if (NewLibrary.Images[i].Preview != null) NewLibrary.Images[i].Preview.Dispose(); if (NewLibrary.Images[i].Image != null) NewLibrary.Images[i].Image.Dispose(); if (NewLibrary.Images[i].MaskImage != null) NewLibrary.Images[i].MaskImage.Dispose(); } for (int i = 0; i < OldLibrary.Images.Count; i++) { if (OldLibrary.Images[i].Preview != null) OldLibrary.Images[i].Preview.Dispose(); if (OldLibrary.Images[i].Image != null) OldLibrary.Images[i].Image.Dispose(); } NewLibrary.Images.Clear(); NewLibrary.IndexList.Clear(); OldLibrary.Images.Clear(); OldLibrary.IndexList.Clear(); NewLibrary.Close(); OldLibrary.Close(); NewLibrary = null; OldLibrary = null; } // Recurse into subdirectories of this directory. string[] subdirEntries = Directory.GetDirectories(sourceDir); foreach (string subdir in subdirEntries) { // Do not iterate through re-parse points. if (Path.GetFileName(Path.GetFullPath(subdir).TrimEnd(Path.DirectorySeparatorChar)) == Path.GetFileName(Path.GetFullPath(outputDir).TrimEnd(Path.DirectorySeparatorChar))) continue; if ((File.GetAttributes(subdir) & FileAttributes.ReparsePoint) != FileAttributes.ReparsePoint) ProcessDir(subdir, recursionLvl + 1, outputDir + " \\" + Path.GetFileName(Path.GetFullPath(subdir).TrimEnd(Path.DirectorySeparatorChar)) + "\\"); } } }
public void ToMLibrary() { string fileName = Path.ChangeExtension(_fileName, ".Lib"); if (File.Exists(fileName)) { File.Delete(fileName); } MLibraryV2 library = new MLibraryV2(fileName) { Images = new List <MLibraryV2.MImage>(), IndexList = new List <int>(), Count = Images.Length }; //library.Save(); for (int i = 0; i < library.Count; i++) { library.Images.Add(null); } ParallelOptions options = new ParallelOptions { MaxDegreeOfParallelism = 8 }; try { Parallel.For(0, Images.Length, options, i => { WeMadeImage image = Images[i]; if (image.HasMask) { library.Images[i] = new MLibraryV2.MImage(image.Image, image.MaskImage) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow ? (byte)1 : (byte)0, MaskX = image.X, MaskY = image.Y } } ; else { library.Images[i] = new MLibraryV2.MImage(image.Image) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow ? (byte)1 : (byte)0 } }; }); } catch (System.Exception) { throw; } finally { library.Save(); } }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { if (SaveLibraryDialog.ShowDialog() != DialogResult.OK) { return; } if (_library != null) { _library.Close(); } _library = new MLibraryV2(SaveLibraryDialog.FileName); PreviewListView.VirtualListSize = 0; _library.Save(); }
private void autofillNpcFramesToolStripMenuItem_Click(object sender, EventArgs e) { if (FolderLibraryDialog.ShowDialog() != DialogResult.OK) { return; } var path = FolderLibraryDialog.SelectedPath; var files = Directory.GetFiles(path, "*.Lib"); if (MessageBox.Show($"Are you sure you want to populate {files.Count()} Libs with their matching FrameSet?", "Autofill Libs.", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } foreach (var file in files) { if (_library != null) { _library.Close(); } _library = new MLibraryV2(file); // Show .Lib path in application title. this.Text = file; var name = Path.GetFileNameWithoutExtension(file); if (!int.TryParse(name, out int imageNumber)) { continue; } _library.Frames = GetFrameSetByImage((Monster)imageNumber); _library.Save(); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (OpenLibraryDialog.ShowDialog() != DialogResult.OK) return; ClearInterface(); ImageList.Images.Clear(); PreviewListView.Items.Clear(); _indexList.Clear(); if (_library != null) _library.Close(); _library = new MLibraryV2(OpenLibraryDialog.FileName); PreviewListView.VirtualListSize = _library.Images.Count; // Show .Lib path in application title. this.Text = OpenLibraryDialog.FileName.ToString(); PreviewListView.SelectedIndices.Clear(); if (PreviewListView.Items.Count > 0) PreviewListView.Items[0].Selected = true; }
private void MergeButton_Click(object sender, EventArgs e) { if (_library == null) { return; } if (_library.FileName == null) { return; } string value = "1000"; int temp = 0; if (InputBox("Merge Blanks", "How Many Images Per Object:", ref value) == DialogResult.OK) { if (!int.TryParse(value, out temp)) { MessageBox.Show("Should be a numeric value"); return; } if (temp <= 0) { MessageBox.Show("Must be atleast 1"); return; } newImages = temp; } _library.AddBlanks(newImages); if (OpenMergeDialog.ShowDialog() != DialogResult.OK) { return; } toolStripProgressBar.Maximum = OpenMergeDialog.FileNames.Length; toolStripProgressBar.Value = 0; try { foreach (string file in OpenMergeDialog.FileNames) { if (Path.GetExtension(file).ToUpper() == ".ZL") { Mir3Library newLib = new Mir3Library(file); foreach (Mir3Library.Mir3Image image in newLib.Images) { _library.AddImage(image.Image, image.OffSetX, image.OffSetY); } } else if (Path.GetExtension(file).ToUpper() == ".WTL") { WTLLibrary WTLlib = new WTLLibrary(file); WTLlib.MergeToMLibrary(_library, newImages); } else if (Path.GetExtension(file).ToUpper() == ".LIB") { FileStream stream = new FileStream(file, FileMode.Open, FileAccess.ReadWrite); BinaryReader reader = new BinaryReader(stream); int CurrentVersion = reader.ReadInt32(); stream.Close(); stream.Dispose(); reader.Dispose(); if (CurrentVersion == 1) { MLibrary v1Lib = new MLibrary(file); v1Lib.MergeToMLibrary(_library, newImages); } else { MLibraryV2 v2Lib = new MLibraryV2(file); v2Lib.MergeToMLibrary(_library, newImages); } } else { WeMadeLibrary WILlib = new WeMadeLibrary(file); WILlib.MergeToMLibrary(_library, newImages); } toolStripProgressBar.Value++; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } toolStripProgressBar.Value = 0; MessageBox.Show(string.Format("Successfully merged {0} {1}", (OpenMergeDialog.FileNames.Length).ToString(), (OpenMergeDialog.FileNames.Length > 1) ? "libraries" : "library")); ImageList.Images.Clear(); _indexList.Clear(); PreviewListView.VirtualListSize = _library.Images.Count; _library.Save(_library.FileName); }
public static void ProcessDir(string sourceDir, int recursionLvl, string outputDir) { if (recursionLvl <= HowDeepToScan) { // Process the list of files found in the directory. string[] fileEntries = Directory.GetFiles(sourceDir); foreach (string fileName in fileEntries) { if (Directory.Exists(outputDir) != true) { Directory.CreateDirectory(outputDir); } MLibraryV0 OldLibrary = new MLibraryV0(fileName); MLibraryV2 NewLibrary = new MLibraryV2(outputDir + Path.GetFileName(fileName)) { Images = new List <MLibraryV2.MImage>(), IndexList = new List <int>(), Count = OldLibrary.Images.Count };; for (int i = 0; i < OldLibrary.Images.Count; i++) { NewLibrary.Images.Add(null); } for (int j = 0; j < OldLibrary.Images.Count; j++) { MLibraryV0.MImage oldimage = OldLibrary.GetMImage(j); NewLibrary.Images[j] = new MLibraryV2.MImage(oldimage.FBytes, oldimage.Width, oldimage.Height) { X = oldimage.X, Y = oldimage.Y }; } NewLibrary.Save(); for (int i = 0; i < NewLibrary.Images.Count; i++) { if (NewLibrary.Images[i].Preview != null) { NewLibrary.Images[i].Preview.Dispose(); } if (NewLibrary.Images[i].Image != null) { NewLibrary.Images[i].Image.Dispose(); } if (NewLibrary.Images[i].MaskImage != null) { NewLibrary.Images[i].MaskImage.Dispose(); } } for (int i = 0; i < OldLibrary.Images.Count; i++) { if (OldLibrary.Images[i].Preview != null) { OldLibrary.Images[i].Preview.Dispose(); } if (OldLibrary.Images[i].Image != null) { OldLibrary.Images[i].Image.Dispose(); } } NewLibrary.Images.Clear(); NewLibrary.IndexList.Clear(); OldLibrary.Images.Clear(); OldLibrary.IndexList.Clear(); NewLibrary.Close(); OldLibrary.Close(); NewLibrary = null; OldLibrary = null; } // Recurse into subdirectories of this directory. string[] subdirEntries = Directory.GetDirectories(sourceDir); foreach (string subdir in subdirEntries) { // Do not iterate through re-parse points. if (Path.GetFileName(Path.GetFullPath(subdir).TrimEnd(Path.DirectorySeparatorChar)) == Path.GetFileName(Path.GetFullPath(outputDir).TrimEnd(Path.DirectorySeparatorChar))) { continue; } if ((File.GetAttributes(subdir) & FileAttributes.ReparsePoint) != FileAttributes.ReparsePoint) { ProcessDir(subdir, recursionLvl + 1, outputDir + " \\" + Path.GetFileName(Path.GetFullPath(subdir).TrimEnd(Path.DirectorySeparatorChar)) + "\\"); } } } }
private void Form1_DragDrop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (Path.GetExtension(files[0]).ToUpper() == ".WIL" || Path.GetExtension(files[0]).ToUpper() == ".WZL" || Path.GetExtension(files[0]).ToUpper() == ".MIZ") { toolStripProgressBar.Maximum = files.Length; toolStripProgressBar.Value = 0; new Action(() => { try { ParallelOptions options = new ParallelOptions { MaxDegreeOfParallelism = 8 }; Parallel.For(0, files.Length, options, i => { if (Path.GetExtension(files[i]) == ".wtl") { WTLLibrary WTLlib = new WTLLibrary(files[i]); WTLlib.ToMLibrary(); } else { WeMadeLibrary WILlib = new WeMadeLibrary(files[i]); WILlib.ToMLibrary(); } Invoke(new Action(() => { toolStripProgressBar.Value++; })); }); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } Invoke(new Action(() => { toolStripProgressBar.Value = 0; })); MessageBox.Show( string.Format("Successfully converted {0} {1}", (files.Length).ToString(), (files.Length > 1) ? "libraries" : "library")); }).BeginInvoke(null, null); } else if (Path.GetExtension(files[0]).ToUpper() == ".LIB") { ClearInterface(); ImageList.Images.Clear(); PreviewListView.Items.Clear(); _indexList.Clear(); if (_library != null) { _library.Close(); } _library = new MLibraryV2(files[0]); PreviewListView.VirtualListSize = _library.Images.Count; PreviewListView.RedrawItems(0, PreviewListView.Items.Count - 1, true); // Show .Lib path in application title. this.Text = files[0].ToString(); } else { return; } }
public void ToMLibrary() { string fileName = Path.ChangeExtension(_fileName, ".Lib"); if (File.Exists(fileName)) File.Delete(fileName); MLibraryV2 library = new MLibraryV2(fileName) { Images = new List<MLibraryV2.MImage>(), IndexList = new List<int>(), Count = Images.Length }; //library.Save(); for (int i = 0; i < library.Count; i++) library.Images.Add(null); ParallelOptions options = new ParallelOptions { MaxDegreeOfParallelism = 8 }; try { Parallel.For(0, Images.Length, options, i => { WTLImage image = Images[i]; if (image.HasMask) library.Images[i] = new MLibraryV2.MImage(image.Image, image.MaskImage) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.Shadow, MaskX = image.MaskX, MaskY = image.MaskY }; else library.Images[i] = new MLibraryV2.MImage(image.Image) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.Shadow }; }); } catch (System.Exception) { throw; } finally { library.Save(); } // Operation finished. // System.Windows.Forms.MessageBox.Show("Converted " + fileName + " successfully.", // "Shanda Information", // System.Windows.Forms.MessageBoxButtons.OK, // System.Windows.Forms.MessageBoxIcon.Information, // System.Windows.Forms.MessageBoxDefaultButton.Button1); }
public void ToMLibrary() { string fileName = Path.ChangeExtension(_fileName, ".Lib"); if (File.Exists(fileName)) { File.Delete(fileName); } MLibraryV2 library = new MLibraryV2(fileName) { Images = new List <MLibraryV2.MImage>(), IndexList = new List <int>(), Count = Images.Length }; //library.Save(); for (int i = 0; i < library.Count; i++) { library.Images.Add(null); } ParallelOptions options = new ParallelOptions { MaxDegreeOfParallelism = 8 }; try { Parallel.For(0, Images.Length, options, i => { WeMadeImage image = Images[i]; if (image.HasMask) { library.Images[i] = new MLibraryV2.MImage(image.Image, image.MaskImage) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow ? (byte)1 : (byte)0, MaskX = image.X, MaskY = image.Y } } ; else { library.Images[i] = new MLibraryV2.MImage(image.Image) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow ? (byte)1 : (byte)0 } }; }); } catch (System.Exception) { throw; } finally { library.Save(); } // Operation finished. // System.Windows.Forms.MessageBox.Show("Converted " + fileName + " successfully.", // "Wemade Information", // System.Windows.Forms.MessageBoxButtons.OK, // System.Windows.Forms.MessageBoxIcon.Information, // System.Windows.Forms.MessageBoxDefaultButton.Button1); }
private void copyToToolStripMenuItem_Click(object sender, EventArgs e) { if (PreviewListView.SelectedIndices.Count == 0) return; if (SaveLibraryDialog.ShowDialog() != DialogResult.OK) return; MLibraryV2 tempLibrary = new MLibraryV2(SaveLibraryDialog.FileName); List<int> copyList = new List<int>(); for (int i = 0; i < PreviewListView.SelectedIndices.Count; i++) copyList.Add(PreviewListView.SelectedIndices[i]); copyList.Sort(); for (int i = 0; i < copyList.Count; i++) { MLibraryV2.MImage image = _library.GetMImage(copyList[i]); tempLibrary.AddImage(image.Image, image.X, image.Y); } tempLibrary.Save(); }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { if (SaveLibraryDialog.ShowDialog() != DialogResult.OK) return; if (_library != null) _library.Close(); _library = new MLibraryV2(SaveLibraryDialog.FileName); PreviewListView.VirtualListSize = 0; _library.Save(); }
private void countBlanksToolStripMenuItem_Click(object sender, EventArgs e) { OpenLibraryDialog.Multiselect = true; if (OpenLibraryDialog.ShowDialog() != DialogResult.OK) { OpenLibraryDialog.Multiselect = false; return; } OpenLibraryDialog.Multiselect = false; MLibraryV2.Load = false; int count = 0; for (int i = 0; i < OpenLibraryDialog.FileNames.Length; i++) { MLibraryV2 library = new MLibraryV2(OpenLibraryDialog.FileNames[i]); for (int x = 0; x < library.Count; x++) { if (library.Images[x].Length <= 8) count++; } library.Close(); } MLibraryV2.Load = true; MessageBox.Show(count.ToString()); }