コード例 #1
0
        public void TestMethod3()
        {
            var dir = @"D:\avatar_new\image";

            foreach (var prof in pairs.Keys)
            {
                foreach (var part in part_array)
                {
                    var file = $@"{dir}\{prof}\{part}";

                    var path = $"d:/avatar_ex/image/{prof}/{part}";
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    var list = Npks.Load(file);

                    foreach (var img in list)
                    {
                        var tables = img.Tables;
                        var match  = Regex.Match(img.Name, "\\d+");
                        if (match.Success)
                        {
                            var code = int.Parse(match.Value);
                            for (var i = 0; i < tables.Count; i++)
                            {
                                img.TableIndex = i;
                                var image = img[pairs[prof]];
                                ImageToJson(path, prof, part, img.Name, Npks.CompleteCode(code + i), image);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
 public void Test()
 {
     foreach (string f in Directory.GetFiles(@"D:\地下城与勇士\ImagePacks2"))
     {
         Npks.Load(f);
     }
 }
コード例 #3
0
        public void Do(params object[] args)
        {
            Index       = (int)args[0];
            Clipboarder = Clipboarder.Default;
            var array = new Album[0];

            if (Clipboarder != null)
            {
                array = Clipboarder.Albums;
                if (Clipboarder.Mode == ClipMode.Cut)
                {
                    Clipboarder.Clear();
                    Clipboard.Clear();
                    Connector.RemoveFile(array);
                }
                for (var i = 0; i < array.Length; i++)
                {
                    array[i] = array[i].Clone();
                }
            }
            else if (Clipboard.ContainsFileDropList())
            {
                var collection = Clipboard.GetFileDropList();
                var file_arr   = new string[collection.Count];
                collection.CopyTo(file_arr, 0);
                array = Npks.Load(file_arr).ToArray();
                var builder = new LSBuilder();
                for (var i = 0; i < array.Length; i++)
                {
                    var name = file_arr[i].RemoveSuffix(".img");
                    name  = name.RemoveSuffix(".ogg");
                    name += ".json";
                    if (File.Exists(name))
                    {
                        var root = builder.Read(name)["path"];
                        var path = root.Value?.ToString();
                        if (path != null)
                        {
                            array[i].Path = path;
                        }
                    }
                }
            }
            Indexes = new int[array.Length];
            if (array.Length > 0)
            {
                if (Connector.FileCount > 0)
                {
                    Connector.SelectedFileIndex = Connector.FileCount - 1;
                }
                Index = Index > Connector.List.Count ? Connector.List.Count : Index;
                Index = Index < 0 ? 0 : Index;
                for (var i = 0; i < array.Length; i++)
                {
                    Indexes[i] = Index + i;
                }
                Connector.List.InsertRange(Index, array);
            }
        }
コード例 #4
0
 protected override void OnDragDrop(DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         var args  = e.Data.GetData(DataFormats.FileDrop, false) as string[];
         var array = Npks.Load(args).ToArray();
         Connector.Do("addMerge", array);
     }
 }
コード例 #5
0
        private void AddOutside(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog();

            dialog.Filter      = $"{Language["ImageResources"]}| *.NPK; *.img";
            dialog.Multiselect = true;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var array = Npks.Load(dialog.FileNames).ToArray();
                Connector.Do("addMerge", array);
            }
        }
コード例 #6
0
ファイル: TestHandler.cs プロジェクト: DK2222/ExtractorSharp
        public void Test() {
            foreach(var f in Directory.GetFiles(@"D:\地下城与勇士\ImagePacks2")) {
                var list=Npks.Load(f);
                foreach (var e in list) {
                    if (e.Version == Img_Version.Ver5) {
                        var handler = e.Handler as FifthHandler;
                        foreach (var a in handler.List) {
                            var image = a.Pictrue;
                        }
                    }

                    GC.Collect();
                }
            }
        }
コード例 #7
0
        public void Test01()
        {
            var prof_list = GetProfession();

            foreach (var prof in prof_list)
            {
                var dir = $"{SAVE_DIR}/image/{prof}";
                if (Directory.Exists(dir))
                {
                    Directory.Delete(dir, true);
                }
                Directory.CreateDirectory(dir);
                foreach (var part in part_array)
                {
                    var file    = $"{GAME_DIR}/ImagePacks2/sprite_character_{prof}{(prof.EndsWith("_at") ? "" : "_")}equipment_avatar_{part}.NPK";
                    var avatars = GetAvatar(prof, part);
                    var list    = Npks.Load(file);
                    var arr     = new List <Album>();
                    list = list.Where(item => {
                        var name = item.Name;
                        if (name.Contains("(tn)") || name.Contains("_mask"))
                        {
                            return(false);
                        }
                        var regex = new Regex("\\d+");
                        var match = regex.Match(name);
                        if (match.Success)
                        {
                            var codeStr = match.Value;
                            var code    = int.Parse(codeStr);
                            var rs      = false;
                            for (var i = 0; i < item.Tables.Count; i++)
                            {
                                rs = rs || !avatars.Contains((code + i).ToString());
                            }
                            return(rs);
                        }
                        return(false);
                    }).ToList();
                    var target = $"{dir}/{part}/";
                    if (!Directory.Exists(target))
                    {
                        Directory.CreateDirectory(target);
                    }
                    Npks.SaveToDirectory($"{dir}/{part}/", list);
                }
            }
        }
コード例 #8
0
ファイル: UnitTest1.cs プロジェクト: DK2222/ExtractorSharp
        public void TestSaveImg()
        {
            var list = Npks.Load(@"D:\地下城与勇士\ImagePacks2\sprite_character_swordman_equipment_avatar_coat.NPK");

            Assert.IsTrue(list.Count > 0);
            var img = list[0];

            Assert.IsNotNull(img);
            var target = @"d:\test\v6\01.img";

            img.Save(target);
            Assert.IsTrue(File.Exists(target));
            list = Npks.Load(target);
            Assert.IsTrue(list.Count > 0);
            img = list[0];
            Assert.IsNotNull(img);
        }
コード例 #9
0
ファイル: UnitTest1.cs プロジェクト: DK2222/ExtractorSharp
        public void TestSaveImage()
        {
            var list = Npks.Load(@"D:\test\v6\01.img");

            Assert.IsTrue(list.Count > 0);
            var img = list[0];

            Assert.IsNotNull(img);
            var dir = @"D:\test\v6\image\";

            if (Directory.Exists(dir))
            {
                Directory.Delete(dir, true);
                Directory.CreateDirectory(dir);
            }
            img.List.ForEach(e => e.Picture.Save(dir + e.Index + ".png"));
            Assert.IsTrue(Directory.GetFiles(dir, "*.png").Length == img.Count);
        }
コード例 #10
0
ファイル: UnitTest1.cs プロジェクト: DK2222/ExtractorSharp
        public void GetWeapon()
        {
            var dir = "d:/avatar/new";

            foreach (var prof in pairs.Keys)
            {
                foreach (var typed in Directory.GetDirectories($"{dir}/{prof.Replace("_at", "")}/weapon"))
                {
                    var type = typed.GetSuffix();
                    var file = $"{GAME_PATH}/sprite_character_{prof}{(prof.EndsWith("_at") ? "" : "_")}equipment_weapon_{GetType(prof, type)}.npk";
                    var list = Npks.Load(file);
                    var ps   = $"{dir}/{prof}/weapon/{type}";
                    if (!Directory.Exists(ps))
                    {
                        continue;
                    }
                    var images = Directory.GetFiles(ps);

                    var path = $"d:/avatar/new_image/{prof}/weapon/{type}";
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    for (var i = 0; i < images.Length; i++)
                    {
                        var regex = new Regex("\\d+");
                        var match = regex.Match(images[i]);
                        if (match.Success)
                        {
                            var code = match.Value;
                            var arr  = list.Where(item => Npks.MatchCode(item.Name, code)).ToList();
                            var rs   = FindImg(arr, int.Parse(code), type);
                            if (rs.Count() > 0)
                            {
                                var img     = rs.ElementAt(0);
                                var builder = new LSBuilder();
                                var image   = img[pairs[prof]];
                                ImageToJson(path, prof, type, img.Name, match.Value, image);
                            }
                        }
                    }
                }
            }
        }
コード例 #11
0
        public void TestMethod1()
        {
            var dir = @"D:\avatar_ex\icon";

            foreach (var prof in pairs.Keys)
            {
                foreach (var part in part_array)
                {
                    var file = $"{GAME_PATH}/sprite_character_{prof}{(prof.EndsWith("_at") ? "" : "_")}equipment_avatar_{part}.NPK";
                    var list = Npks.Load(file);
                    var ps   = $"{dir}/{prof}/{part}";
                    if (!Directory.Exists(ps))
                    {
                        continue;
                    }
                    var images = Directory.GetFiles(ps);

                    var path = $"d:/avatar_ex/image/{prof}/{part}";
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    for (var i = 0; i < images.Length; i++)
                    {
                        var regex = new Regex("\\d+");
                        var match = regex.Match(images[i]);
                        if (match.Success)
                        {
                            var code    = match.Value;
                            var arr     = Npks.FindByCode(list, code);
                            var rs      = FindImg(arr, int.Parse(code), part.Equals("skin") ? "body" : part);
                            var builder = new LSBuilder();
                            foreach (var img in rs)
                            {
                                var image = img[pairs[prof]];
                                ImageToJson(path, prof, part, img.Name, match.Value, image);
                            }
                        }
                    }
                }
            }
        }
コード例 #12
0
ファイル: UnitTest1.cs プロジェクト: DK2222/ExtractorSharp
        public void GetImage(string source, string target, string prof)
        {
            foreach (var part in part_array)
            {
                var file = $"{GAME_PATH}/sprite_character_{prof}{(prof.EndsWith("_at") ? "" : "_")}equipment_avatar_{part}.NPK";
                var list = Npks.Load(file);
                var ps   = $"{source}/icon/{prof}/{part}";
                if (!Directory.Exists(ps))
                {
                    continue;
                }
                var images = Directory.GetFiles(ps);

                var path = $"{target}/image/{prof}/{part}";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                for (var i = 0; i < images.Length; i++)
                {
                    var regex = new Regex("\\d+");
                    var match = regex.Match(images[i].GetSuffix());
                    if (match.Success)
                    {
                        var code = match.Value;
                        var arr  = list.Where(item => Npks.MatchCode(item.Name, code)).ToList();
                        var rs   = FindImg(arr, int.Parse(code), part.Equals("skin") ? "body" : part);
                        foreach (var img in rs)
                        {
                            var builder = new LSBuilder();
                            var image   = img[pairs[prof]];
                            ImageToJson(path, prof, part, img.Name, match.Value, image);
                        }
                    }
                }
            }
        }
コード例 #13
0
            public void AddFile(bool clear, params string[] args)
            {
                if (clear)
                {
                    SavePath = string.Empty;
                    IsSave   = true;
                }
                if (SavePath.Length == 0)
                {
                    SavePath = args.Find(item => item.ToLower().EndsWith(".npk")) ?? string.Empty;
                }
                if (args.Length < 1)
                {
                    return;
                }
                var list = new List <Album>();

                for (var i = 0; i < args.Length; i++)
                {
                    var index  = args[i].LastIndexOf(".") + 1;
                    var suffix = args[i].Substring(index);
                    var arr    = new List <Album>();
                    if (FileConverters.ContainsKey(suffix))
                    {
                        arr = FileConverters[suffix].Load(args[i]);
                    }
                    else
                    {
                        arr = Npks.Load(args[i]);
                    }
                    list.AddRange(arr);
                }
                if (args.Length > 0)
                {
                    MainForm.Controller.Do("addImg", list.ToArray(), clear);
                }
            }
コード例 #14
0
        public void Test01()
        {
            var prof_list = GetProfession();

            foreach (var prof in prof_list)
            {
                var dir = $"{SAVE_DIR}/image/{prof}";
                if (Directory.Exists(dir))
                {
                    Directory.Delete(dir, true);
                }
                Directory.CreateDirectory(dir);
                foreach (var part in part_array)
                {
                    var file    = $"{GAME_DIR}/ImagePacks2/sprite_character_{prof}{(prof.EndsWith("_at") ? "" : "_")}equipment_avatar_{part}.NPK";
                    var avatars = GetAvatar(prof, part);
                    var list    = Npks.Load(file);
                    list = list.Where(item => {
                        var name = item.Name;
                        if (name.Contains("(tn)") || name.Contains("_mask"))
                        {
                            return(false);
                        }
                        var regex = new Regex("\\d+");
                        var match = regex.Match(name);
                        if (match.Success)
                        {
                            var code = match.Value;
                            return(!avatars.Contains(code));
                        }
                        return(false);
                    }).ToList();
                    Npks.Save($"{dir}/{part}.NPK", list);
                }
            }
        }