Ejemplo n.º 1
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (_library == null)
     {
         return;
     }
     _library.Save();
 }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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)) + "\\");
                }
            }
        }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
        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();
            }
        }
Ejemplo n.º 7
0
        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)) + "\\");
                    }
                }
            }
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
        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();
        }
Ejemplo n.º 11
0
        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);
        }