/// <summary> /// 判断程序是否需要更新 /// </summary> /// <returns></returns> public static void CheckUpdate(bool Tips) { var builder = new LSBuilder(); var obj = builder.Get($"{Config["ApiHost"]}{Config["UpdateUrl"]}"); if (obj == null) { return; } var info = obj["tag"].GetValue(typeof(VersionInfo)) as VersionInfo; if (info != null && !info.Name.Equals(Version)) { //若当前版本低于最新版本时,触发更新 if (MessageBox.Show(Language.Default["NeedUpdateTips"], Language.Default["Tips"], MessageBoxButtons.OKCancel) != DialogResult.OK) { return; //提示更新 } StartUpdate(); //启动更新 } else if (Tips) { MessageBox.Show(Language.Default["NeedNotUpdateTips"]); //提示不需要更新 } Config.Save(); }
public void Do(params object[] args) { Album = args[0] as Album; Indexes = args[1] as int[]; Mode = (ClipMode)args[2]; Clipboarder = Clipboarder.Default; Clipboarder.Default = Clipboarder.CreateClipboarder(Album, Indexes, Mode); var arr = new string[Indexes.Length]; var dir = $"{Program.Config["RootPath"]}/temp/clipbord_image"; if (Directory.Exists(dir)) { Directory.Delete(dir, true); } Directory.CreateDirectory(dir); var builder = new LSBuilder(); for (var i = 0; i < Indexes.Length; i++) { var entity = Album[Indexes[i]]; var path = $"{dir}/{entity.Index}"; builder.WriteObject(entity, path + ".json"); arr[i] = path + ".png"; entity.Picture.Save(arr[i]); } var collection = new StringCollection(); collection.AddRange(arr); Clipboard.SetFileDropList(collection); }
public static void GetWeapons() { var professions = new List <Profession>(); var builder = new LSBuilder(); builder.ReadJson(Resources.profession).GetValue(ref professions); var gamePath = "D:\\地下城与勇士"; var regex = new Regex("\\d+"); foreach (var prof in professions) { foreach (var type in prof.Weapon) { var file = $"{gamePath}\\{NpkCoder.IMAGE_DIR}\\{Avatars.GetWeaponFile(prof.Name, type)}.NPK"; if (!File.Exists(file)) { continue; } var list = NpkCoder.LoadAll(file, Avatars.MatchWeapon); var path = $"d:\\avatar\\new_image\\{prof.Name}\\{type}"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } foreach (var img in list) { var image = img[prof.Frame]; var match = regex.Match(img.Name); ImageToJson(path, prof.Name, type, img.Name, match.Value, image); } } } }
private Result UploadBug(string message, string log) { var result = new Result() { Status = "error", Message = "提交失败!" }; try { var data = new Dictionary <string, object>() { { "projectId", Config["ProgramId"].Integer }, { "message", message }, { "log", log }, { "version", Config["Version"].Value } }; var builder = new LSBuilder(); var path = $"{Config["ApiHost"].Value}/{Config["FeedbackUrl"].Value}"; var resultObj = builder.Post(path, data); resultObj.GetValue(ref result); } catch (Exception e) { Console.Write(e.StackTrace); } return(result); }
public void ImageToJson(string path, string profession, string part, string name, string code, Sprite image) { var regex = new Regex("\\d+"); name = name.Replace(".img", ""); name = regex.Replace(name, code, 1); var pattern = name.Substring(name.IndexOf("_") + 1); pattern = regex.Replace(pattern, ""); var i = regex.Match(name).Index; name = name.Substring(i); var dressImage = new DressImage(); dressImage.hash = $"{profession}&{part}&{code}"; dressImage.name = $"{name}.png"; dressImage.width = image.Width; dressImage.height = image.Height; dressImage.x = image.X; dressImage.y = image.Y; dressImage.z = IndexOf(pattern); var builder = new LSBuilder(); image.Picture.Save($"{path}/{name}.png"); builder.WriteObject(dressImage, $"{path}/{name}.json"); }
public void Do(params object[] args) { Array = args[0] as Album[]; Mode = (ClipMode)args[1]; Clipboarder = Clipboarder.Default; Clipboarder.Default = Clipboarder.CreateClipboarder(Array, null, Mode); var builder = new LSBuilder(); var dir = $"{Program.Config["RootPath"]}/temp/clipbord_img"; if (Directory.Exists(dir)) { //删除文件夹内容 Directory.Delete(dir, true); } Directory.CreateDirectory(dir); var path_arr = new string[Array.Length]; for (var i = 0; i < Array.Length; i++) { path_arr[i] = $"{dir}/{Array[i].Name}"; Tools.SaveFile(path_arr[i], Array[i]); var json_path = path_arr[i].RemoveSuffix(".ogg"); json_path = json_path.RemoveSuffix(".img"); json_path = $"{json_path}.json"; var root = new LSObject { { "path", Array[i].Path } }; builder.Write(root, json_path); } var collection = new StringCollection(); collection.AddRange(path_arr); Clipboard.SetFileDropList(collection); }
public DressingService(IConfig Config) { this.Config = Config; replace_dic = new Dictionary <string, string>(); var builder = new LSBuilder(); var obj = builder.ReadJson(Resources.Weapon); weapon_info = new Dictionary <string, WeaponInfo>(); obj.GetValue(ref weapon_info); ProfessionList = new List <string>(); foreach (var entry in weapon_info) { var info = entry.Value; ProfessionList.Add(entry.Key); if (info.HasAt) { ProfessionList.Add(entry.Key + "_at"); } if (info.Alias != null) { foreach (var en in info.Alias) { replace_dic.Add(en.Key, en.Value); } } info.Name = entry.Key; info.Weapon.AddRange(info.Alias.Keys); } }
static UnitTest1() { Handler.Regisity(ImgVersion.Ver1, typeof(FirstHandler)); Handler.Regisity(ImgVersion.Ver2, typeof(SecondHandler)); Handler.Regisity(ImgVersion.Ver4, typeof(FourthHandler)); Handler.Regisity(ImgVersion.Ver5, typeof(FifthHandler)); Handler.Regisity(ImgVersion.Ver6, typeof(SixthHandler)); pairs = new Dictionary <string, int> { { "swordman", 176 }, { "swordman_at", 0 }, { "fighter", 116 }, { "fighter_at", 0 }, { "gunner", 18 }, { "gunner_at", 8 }, { "mage", 10 }, { "mage_at", 8 }, { "priest", 150 }, { "priest_at", 0 }, { "thief", 10 }, { "knight", 0 }, { "demoniclancer", 0 } }; var builder = new LSBuilder(); var obj = builder.ReadJson(Resources.queues); obj["Rules"].GetValue(ref sorts); var weapon = builder.ReadJson(Resources.weapon); weapon.GetValue(ref weapons); }
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); } }
private List <Profession> GetProfession() { var builder = new LSBuilder(); var obj = builder.Get("http://localhost:8080/api/dressing/profession/list"); var list = new List <Profession>(); obj.GetValue(ref list); return(list); }
private List <Profession> GetProfession() { var builder = new LSBuilder(); var obj = builder.Get($"{API_HOST}/profession/list"); var list = new List <Profession>(); obj.GetValue(ref list); return(list); }
private List <string> GetProfession() { LSBuilder builder = new LSBuilder(); var obj = builder.Get($"{API_HOST}/profession/list"); List <Profession> list = new List <Profession>(); obj.GetValue(ref list); return(list.ConvertAll(profesion => profesion.Name)); }
private List <string> GetAvatar(string profession, string part) { LSBuilder builder = new LSBuilder(); var obj = builder.Get($"{API_HOST}/avatar/list/{profession}/{part}"); List <Avatar> list = new List <Avatar>(); obj.GetValue(ref list); return(list.ConvertAll(avatar => avatar.Code)); }
public void Test13() { var path = @"D:\ES\ExtractorSharp\Resources\weapon.json"; var reader = new LSBuilder(); var root = reader.Read(path); var type = typeof(WeaponInfo[]); var list = root.GetValue(type); Assert.IsNotNull(list); }
static UnitTest3() { Handler.Regisity(ImgVersion.Other, typeof(OtherHandler)); Handler.Regisity(ImgVersion.Ver1, typeof(FirstHandler)); Handler.Regisity(ImgVersion.Ver2, typeof(SecondHandler)); Handler.Regisity(ImgVersion.Ver4, typeof(FourthHandler)); Handler.Regisity(ImgVersion.Ver5, typeof(FifthHandler)); Handler.Regisity(ImgVersion.Ver6, typeof(SixthHandler)); Dictionary = new Dictionary <string, WeaponInfo>(); var builder = new LSBuilder();; }
public VersionDialog(IConnector Connector) : base(Connector) { InitializeComponent(); button.Click += ButtonClose; var builder = new LSBuilder(); var root = builder.ReadJson(Resources.Version); var info = new VersionInfo(); root[root.Count - 1].GetValue(ref info); box.Text = info.ToString(); }
public void Do(params object[] args) { Target = args[0] as Album; Index = (int)args[1]; Clipboarder = Clipboarder.Default; var array = new ImageEntity[0]; if (Clipboarder != null) { Indexes = Clipboarder.Indexes; Source = Clipboarder.Album; array = new ImageEntity[Indexes.Length]; Source.Adjust(); for (var i = 0; i < array.Length; i++) { array[i] = Source[Indexes[i]].Clone(Target); } if (Clipboarder.Mode == ClipMode.Cut) { //如果是剪切,清空剪切板 Clipboarder.Default = null; Clipboard.Clear(); for (var i = 0; i < array.Length; i++) { Source.List.Remove(array[i]); } } Source.Adjust(); } else if (Clipboard.ContainsFileDropList()) { var collection = Clipboard.GetFileDropList(); array = new ImageEntity[collection.Count]; var builder = new LSBuilder(); for (var i = 0; i < collection.Count; i++) { if (!File.Exists(collection[i])) { continue; } var image = Image.FromFile(collection[i]) as Bitmap; var json = collection[i].Replace(".png", ".json"); if (File.Exists(json)) { var obj = builder.Read(json); array[i] = obj.GetValue(typeof(ImageEntity)) as ImageEntity; array[i].Parent = Target; array[i].Picture = image; } } } Target.List.InsertRange(Index, array); Target.Adjust(); }
private static List <string> GetAvatar(string profession, string part) { var url = $"{API_HOST}/avatar/list/{profession}/{part}.json"; var builder = new LSBuilder(); var obj = builder.Get(url); var list = new List <Avatar>(); obj.GetValue(ref list); Console.WriteLine("GET ... " + url); return(list.ConvertAll(avatar => avatar.Code)); }
private void SaveAs(object sender, EventArgs e) { var dialog = new SaveFileDialog(); dialog.Filter = "json文件|*.json"; if (dialog.ShowDialog() == DialogResult.OK) { var builder = new LSBuilder(); builder.Write(Root, dialog.FileName); } }
public void Refresh() { NetList.Clear(); try { var builder = new LSBuilder(); var obj = builder.Get(MARKET_URL); if (obj["status"].Value.Equals("success")) { NetList = obj["tag"].GetValue(typeof(List <Metadata>)) as List <Metadata>; } } catch (Exception e) { } }
/// <summary> /// 初始化字典 /// </summary> private void InitDictionary() { Dic = new Dictionary <string, string>(); var file = $"{Config["RootPath"]}/dictionary.txt"; if (File.Exists(file)) { var data = File.ReadAllText(file); var builder = new LSBuilder(); var obj = builder.ReadProperties(data); obj.GetValue(ref Dic); } }
public void Refresh() { NetList.Clear(); try { var builder = new LSBuilder(); var obj = builder.Get(Config["MarketUrl"].Value); if (obj["status"].Value.Equals("success")) { NetList = obj["tag"].GetValue(typeof(List <Metadata>)) as List <Metadata>; } } catch (Exception e) { throw new PluginExecption("PluginListDownloadError"); } }
/// <summary> /// 初始化排序规则 /// </summary> public void InitDictionary() { var builder = new LSBuilder(); var defaultObj = builder.ReadJson(Resources.Queue); InitSorter(defaultObj); if (Directory.Exists(RulePath)) { foreach (var json in Directory.GetFiles(RulePath)) { var obj = builder.Read(json); InitSorter(obj); } } }
private void LoadProp(object sender, EventArgs e) { var dialog = new OpenFileDialog(); if (dialog.ShowDialog() == DialogResult.OK) { var name = dialog.FileName; using (var reader = new StreamReader(dialog.FileName)) { var prop = reader.ReadToEnd(); var builder = new LSBuilder(); Root = builder.ReadProperties(prop); } ReFlush(); } }
public MainConnector() { SaveChanged += (o, e) => OnSaveChanged(); FileSupports.Add(new GifSupport()); var builder = new LSBuilder(); var recentConfigPath = $"{Config["RootPath"]}/conf/recent.json"; if (File.Exists(recentConfigPath)) { Recent = builder.Read(recentConfigPath).GetValue(typeof(List <string>)) as List <string>; } RecentChanged += (o, e) => { builder.WriteObject(Recent, recentConfigPath); }; }
public void Test11() { var reader = new LSBuilder(); var obj = new LSObject(); var child = new LSObject(); child.Name = "test"; child.Value = "HelloWorld'\n\t\b\r\f\\\u1111"; obj.Add(child); var path = @"E:\ES\ExtractorSharp\bin\Debug\conf\test.json"; reader.Write(obj, path); obj = reader.Read(path); Assert.AreEqual(obj["test"].Value, child.Value); }
static void Main(string[] args) { Sorts = new Dictionary <string, int>(); var builder = new LSBuilder(); var obj = builder.ReadJson(Resources.queues); obj["Rules"].GetValue(ref Sorts); var date = DateTime.Now; Console.WriteLine("Start..."); GetAvatars(); var time = DateTime.Now - date; Console.WriteLine($"Completed...{time.TotalSeconds}s"); Console.ReadKey(); }
static UnitTest2() { Handler.Regisity(Img_Version.Other, typeof(OtherHandler)); Handler.Regisity(Img_Version.Ver1, typeof(FirstHandler)); Handler.Regisity(Img_Version.Ver2, typeof(SecondHandler)); Handler.Regisity(Img_Version.Ver4, typeof(FourthHandler)); Handler.Regisity(Img_Version.Ver5, typeof(FifthHandler)); Handler.Regisity(Img_Version.Ver6, typeof(SixthHandler)); pairs = new Dictionary <string, int>() { { "swordman", 176 }, { "swordman_at", 0 }, { "fighter", 116 }, { "fighter_at", 0 }, { "gunner", 18 }, { "gunner_at", 8 }, { "mage", 10 }, { "mage_at", 8 }, { "priest", 150 }, { "priest_at", 0 }, { "thief", 10 }, { "knight", 0 }, { "demoniclancer", 0 }, { "gunblader", 0 } }; p2 = new Dictionary <string, string>() { { "swordman", "sm" }, { "swordman_at", "sg" }, { "fighter", "ft" }, { "fighter_at", "fm" }, { "gunner", "gn" }, { "gunner_at", "gg" }, { "mage", "mg" }, { "mage_at", "mm" }, { "priest", "pr" }, { "priest_at", "pg" }, { "thief", "th" }, { "knight", "kn" }, { "demoniclancer", "dl" }, { "gunblader", "gb" }, }; var builder = new LSBuilder(); var obj = builder.ReadJson(Resources.queues); obj["Rules"].GetValue(ref sorts); }
/// <summary> /// 获得临时贴图 /// </summary> /// <param name="profession"></param> /// <param name="part"></param> /// <param name="value"></param> /// <returns></returns> private TempImage[] GetTempImage(string part, string value) { var tempPath = $"temp/{ ProfessionList[Index]}/{part}/{value}.json"; var builder = new LSBuilder(); var dir = Path.GetDirectoryName(tempPath); if (File.Exists(tempPath)) { var obj = builder.Read(tempPath); var array = obj.GetValue(typeof(TempImage[])) as TempImage[]; var exist = true; for (var i = 0; i < array.Length; i++) { var p = dir + "/" + array[i].Name; if (!File.Exists(p)) { exist = false; break; } array[i].Image = Image.FromFile(p); } if (exist) { return(array); } } else { Directory.CreateDirectory(dir); } using (var client = new WebClient()) { var file = $"{API_URL}/image?profession={Profession}&part={part}&code={value}"; client.DownloadFile(file, tempPath); var o = builder.Read(tempPath); var arr = o.GetValue(typeof(TempImage[])) as TempImage[]; for (var i = 0; i < arr.Length; i++) { var path = $"{dir}/{arr[i].Name}"; var uri = $"{RESOUCES_URL}/{Profession}/{part}/{arr[i].Name}"; client.DownloadFile(uri, path); arr[i].Image = Image.FromFile(path); } return(arr); } }
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); } } } } } }