diff --git a/DebugPlatform/GraphList.cs b/DebugPlatform/GraphList.cs index 3493dbe..3059ca1 100644 --- a/DebugPlatform/GraphList.cs +++ b/DebugPlatform/GraphList.cs @@ -1,302 +1,302 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Grabacr07.KanColleWrapper; -using Grabacr07.KanColleWrapper.Models; -using Grabacr07.KanColleWrapper.Models.Raw; -using Fiddler; -using System.IO; -using Debug = System.Diagnostics.Debug; -//using System.Runtime.Serialization.Json; -using System.Windows; - - -namespace d_f_32.KanColleCacher -{ - class GraphList - { - - public static void DebugFunc() - { - GenerateList(); - } - - static List graphList = new List(); - - /// - /// 将解析完成的信息保存到本地 - /// - static void PrintToFile() - { - //string filepath = Settings.Current.CacheFolder + "\\GraphList.txt"; - string filepath = @"E:\Game\KanColleViewer ver.3.3\MyCache\GraphList.txt"; - StringBuilder content = new StringBuilder(); - - content.AppendFormat( - "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\r\n", - "SortNo", "ShipId", "ShipName", - "FileName", "FileVersion", - "TypeName", "TypeId" - ); - content.AppendFormat( - "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\r\n", - "序号", "ID", "名称", - "文件名", "文件版本", "文件序号", - "类型", "类型序号", "类型ID" - ); - try - { - graphList.Sort((x, y) => - { - if (x.ship_sortno == y.ship_sortno) - { - if (x.ship_id == y.ship_id) - return 0; - - return x.ship_id < y.ship_id ? -1 : 1; - } - - return x.ship_sortno < y.ship_sortno ? -1 : 1; - }); - } - catch (Exception ex) - { - Debug.WriteLine("Cachr> GraphList.PrintToFile() 排序时发生异常(graphList.Sort)"); - Debug.WriteLine(ex); - } - - - graphList.ForEach(x => - { - content.AppendFormat( - "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\r\n", - x.ship_sortno, x.ship_id, x.ship_name, - x.ship_filename, x.ship_version, - x.ship_type_name, x.ship_type_id - ); - }); - - try - { - File.WriteAllText(filepath, content.ToString()); - } - catch (Exception ex) - { - //Log.Exception(ex.Source, ex, "写入立绘列表文件时异常"); - } - } - - /// - /// 解析 api_start2 数据信息 - /// - static void ParseSession(Session oSession) - { - SvData svd; - if (!SvData.TryParse(oSession, out svd)) - { - //Log.Warning("GraphList.ParseSession()", "TryParse失败,无效的Session对象!"); - return; - } - - var mst_shipgraph = svd.Data.api_mst_shipgraph - .ToDictionary(x => x.api_id); - var mst_ship = svd.Data.api_mst_ship - .ToDictionary(x => x.api_id); - var mst_stype = svd.Data.api_mst_stype - .ToDictionary(x => x.api_id); - - graphList.Clear(); - - foreach (var _pair in mst_shipgraph) - { - var item = new ship_graph_item(); - var _loc1 = _pair.Value; - - item.ship_id = _loc1.api_id; - item.ship_filename = _loc1.api_filename; - item.ship_version = _loc1.api_version; - item.ship_graph_sortno = _loc1.api_sortno; - - if (mst_ship.ContainsKey(item.ship_id)) - { - var _loc2 = mst_ship[item.ship_id]; - - item.ship_sortno = _loc2.api_sortno; - item.ship_name = _loc2.api_name; - item.ship_type_id = _loc2.api_stype; - - if (mst_stype.ContainsKey(item.ship_type_id)) - { - var _loc3 = mst_stype[item.ship_type_id]; - item.ship_type_name = _loc3.api_name; - item.ship_type_sortno = _loc3.api_sortno; - } - - graphList.Add(item); - mst_ship.Remove(item.ship_id); - } - else - { -#if DEBUG - Debug.WriteLine(@"CACHR> shipgraph->ship匹配失败 -> {0} = {1} {2} {3} -", _loc1.ToString(), _loc1.api_id, _loc1.api_sortno, _loc1.api_filename); -#endif - } - } - -#if DEBUG - Debug.WriteLine("CACHR> graphList = {0}, mst_shipgraph = {1}", - graphList.Count.ToString(), - mst_shipgraph.Count.ToString() - ); -#endif - } - - /// - /// 开始生成 GraphList.txt 文件 - /// - static public void GenerateList() - { - //var path = Settings.Current.CacheFolder + "\\api_start2.session"; - var path = @"E:\Game\KanColleViewer ver.3.3\MyCache\api_start2.session"; - if (!File.Exists(path)) - { - MessageBox.Show("无法生成舰娘列表,因为没有保存 api_start2 通信数据。", "提督很忙!缓存工具"); - return; - } - - //kcsapi_start2 data; - Session oSession; - //try - //{ - //data = (kcsapi_start2)ReadSessionData(); - oSession = ReadSessionData(path) as Session; - //} - //catch (Exception ex) - //{ - // MessageBox.Show("未能生成舰娘列表。读取本地保存的 api_start2 通信数据时发生异常。", "提督很忙!缓存工具"); - // //Log.Exception(ex.Source, ex, "读取本地保存的 api_start2 通信数据时发生异常"); - // throw ex; - //} - try - { - ParseSession(oSession); - } - catch (Exception ex) - { - MessageBox.Show("未能生成舰娘列表。解析 api_start2 数据时发生异常。", "提督很忙!缓存工具"); - //Log.Exception(ex.Source, ex, "解析 api_start2 数据时发生异常。"); - return; - } - try - { - PrintToFile(); - - //string filepath = Settings.Current.CacheFolder + "\\GraphList.txt"; - string filepath = @"E:\Game\KanColleViewer ver.3.3\MyCache\GraphList.txt"; - var si = new System.Diagnostics.ProcessStartInfo() - { - FileName = filepath, - UseShellExecute = true, - }; - System.Diagnostics.Process.Start(si); - } - catch (Exception ex) - { - //Log.Exception(ex.Source, ex, "写入GraphList.txt时或启动进程时发生异常"); - return; - } - } - - /// - /// 保存 api_start2 通信数据到本地 - /// - static void SaveSessionData(Session session) - { - //var path = Settings.Current.CacheFolder + "\\api_start2.dat"; - - session.SaveSession(Settings.Current.CacheFolder + "\\api_start2.session", false); - - //var data = session.GetRequestBodyAsString(); - //data = data.StartsWith("svdata=") - // ? data.Substring(7) : data.Replace("svdata=", ""); - - //Debug.WriteLineIf(data.Length < 100, data); - - //File.WriteAllText(path, data); - } - - /// - /// 从本地读取 api_start2 通信数据 - /// - static object ReadSessionData(string path) - { - //var path = Settings.Current.CacheFolder + "\\api_start2.dat"; - //var bytes = Encoding.UTF8.GetBytes(File.ReadAllText(path)); - - //var serializer = new DataContractJsonSerializer(typeof(svdata)); - //using (var stream = new MemoryStream(bytes)) - //{ - // return serializer.ReadObject(stream) as svdata; - //} - - Session session = new Session(new byte[] { 0 }, new byte[] { 0 }); - if (!session.LoadRequestBodyFromFile(path)) - { - throw new ApplicationException("LoadRequestBodyFromFile Failed!! " + path); - } - if (!session.LoadResponseFromFile(path)) - { - throw new ApplicationException("LoadResponseFromFile Failed!! " + path); - } - return session; - } - - /// - /// Fiddler规则(通信完成后 - /// - static public void RulePrintGraphList(Session oSession) - { - if (oSession.PathAndQuery != "/kcsapi/api_start2") - return; - - //Debug.WriteLine("【START2】" + oSession.PathAndQuery); - - SaveSessionData(oSession); - - //移除规则 - RemoveRule(); - } - - static public void AppendRule() - { - FiddlerApplication.AfterSessionComplete += RulePrintGraphList; - //Debug.WriteLine("CACHR> RulePrintGraphList Appended"); - } - - static public void RemoveRule() - { - FiddlerApplication.AfterSessionComplete -= RulePrintGraphList; - //Debug.WriteLine("CACHR> RulePrintGraphList Removed"); - } - } - - - class ship_graph_item - { - public int ship_id = 0; - public int ship_sortno = 0; - public string ship_name = ""; - - public int ship_type_id = 0; - public int ship_type_sortno = 0; - public string ship_type_name = ""; - - public int ship_graph_sortno = 0; - public string ship_filename = ""; - public string ship_version = ""; - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Grabacr07.KanColleWrapper; +using Grabacr07.KanColleWrapper.Models; +using Grabacr07.KanColleWrapper.Models.Raw; +using Fiddler; +using System.IO; +using Debug = System.Diagnostics.Debug; +//using System.Runtime.Serialization.Json; +using System.Windows; + + +namespace d_f_32.KanColleCacher +{ + class GraphList + { + + public static void DebugFunc() + { + GenerateList(); + } + + static List graphList = new List(); + + /// + /// 将解析完成的信息保存到本地 + /// + static void PrintToFile() + { + //string filepath = Settings.Current.CacheFolder + "\\GraphList.txt"; + string filepath = @"E:\Game\KanColleViewer ver.3.3\MyCache\GraphList.txt"; + StringBuilder content = new StringBuilder(); + + content.AppendFormat( + "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\r\n", + "SortNo", "ShipId", "ShipName", + "FileName", "FileVersion", + "TypeName", "TypeId" + ); + content.AppendFormat( + "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\r\n", + "序号", "ID", "名称", + "文件名", "文件版本", "文件序号", + "类型", "类型序号", "类型ID" + ); + try + { + graphList.Sort((x, y) => + { + if (x.ship_sortno == y.ship_sortno) + { + if (x.ship_id == y.ship_id) + return 0; + + return x.ship_id < y.ship_id ? -1 : 1; + } + + return x.ship_sortno < y.ship_sortno ? -1 : 1; + }); + } + catch (Exception ex) + { + Debug.WriteLine("Cachr> GraphList.PrintToFile() 排序时发生异常(graphList.Sort)"); + Debug.WriteLine(ex); + } + + + graphList.ForEach(x => + { + content.AppendFormat( + "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\r\n", + x.ship_sortno, x.ship_id, x.ship_name, + x.ship_filename, x.ship_version, + x.ship_type_name, x.ship_type_id + ); + }); + + try + { + File.WriteAllText(filepath, content.ToString()); + } + catch (Exception ex) + { + //Log.Exception(ex.Source, ex, "写入立绘列表文件时异常"); + } + } + + /// + /// 解析 api_start2 数据信息 + /// + static void ParseSession(Session oSession) + { + SvData svd; + if (!SvData.TryParse(oSession, out svd)) + { + //Log.Warning("GraphList.ParseSession()", "TryParse失败,无效的Session对象!"); + return; + } + + var mst_shipgraph = svd.Data.api_mst_shipgraph + .ToDictionary(x => x.api_id); + var mst_ship = svd.Data.api_mst_ship + .ToDictionary(x => x.api_id); + var mst_stype = svd.Data.api_mst_stype + .ToDictionary(x => x.api_id); + + graphList.Clear(); + + foreach (var _pair in mst_shipgraph) + { + var item = new ship_graph_item(); + var _loc1 = _pair.Value; + + item.ship_id = _loc1.api_id; + item.ship_filename = _loc1.api_filename; + item.ship_version = _loc1.api_version; + item.ship_graph_sortno = _loc1.api_sortno; + + if (mst_ship.ContainsKey(item.ship_id)) + { + var _loc2 = mst_ship[item.ship_id]; + + item.ship_sortno = _loc2.api_sortno; + item.ship_name = _loc2.api_name; + item.ship_type_id = _loc2.api_stype; + + if (mst_stype.ContainsKey(item.ship_type_id)) + { + var _loc3 = mst_stype[item.ship_type_id]; + item.ship_type_name = _loc3.api_name; + item.ship_type_sortno = _loc3.api_sortno; + } + + graphList.Add(item); + mst_ship.Remove(item.ship_id); + } + else + { +#if DEBUG + Debug.WriteLine(@"CACHR> shipgraph->ship匹配失败 +> {0} = {1} {2} {3} +", _loc1.ToString(), _loc1.api_id, _loc1.api_sortno, _loc1.api_filename); +#endif + } + } + +#if DEBUG + Debug.WriteLine("CACHR> graphList = {0}, mst_shipgraph = {1}", + graphList.Count.ToString(), + mst_shipgraph.Count.ToString() + ); +#endif + } + + /// + /// 开始生成 GraphList.txt 文件 + /// + static public void GenerateList() + { + //var path = Settings.Current.CacheFolder + "\\api_start2.session"; + var path = @"E:\Game\KanColleViewer ver.3.3\MyCache\api_start2.session"; + if (!File.Exists(path)) + { + MessageBox.Show("无法生成舰娘列表,因为没有保存 api_start2 通信数据。", "提督很忙!缓存工具"); + return; + } + + //kcsapi_start2 data; + Session oSession; + //try + //{ + //data = (kcsapi_start2)ReadSessionData(); + oSession = ReadSessionData(path) as Session; + //} + //catch (Exception ex) + //{ + // MessageBox.Show("未能生成舰娘列表。读取本地保存的 api_start2 通信数据时发生异常。", "提督很忙!缓存工具"); + // //Log.Exception(ex.Source, ex, "读取本地保存的 api_start2 通信数据时发生异常"); + // throw ex; + //} + try + { + ParseSession(oSession); + } + catch (Exception ex) + { + MessageBox.Show("未能生成舰娘列表。解析 api_start2 数据时发生异常。", "提督很忙!缓存工具"); + //Log.Exception(ex.Source, ex, "解析 api_start2 数据时发生异常。"); + return; + } + try + { + PrintToFile(); + + //string filepath = Settings.Current.CacheFolder + "\\GraphList.txt"; + string filepath = @"E:\Game\KanColleViewer ver.3.3\MyCache\GraphList.txt"; + var si = new System.Diagnostics.ProcessStartInfo() + { + FileName = filepath, + UseShellExecute = true, + }; + System.Diagnostics.Process.Start(si); + } + catch (Exception ex) + { + //Log.Exception(ex.Source, ex, "写入GraphList.txt时或启动进程时发生异常"); + return; + } + } + + /// + /// 保存 api_start2 通信数据到本地 + /// + static void SaveSessionData(Session session) + { + //var path = Settings.Current.CacheFolder + "\\api_start2.dat"; + + session.SaveSession(Settings.Current.CacheFolder + "\\api_start2.session", false); + + //var data = session.GetRequestBodyAsString(); + //data = data.StartsWith("svdata=") + // ? data.Substring(7) : data.Replace("svdata=", ""); + + //Debug.WriteLineIf(data.Length < 100, data); + + //File.WriteAllText(path, data); + } + + /// + /// 从本地读取 api_start2 通信数据 + /// + static object ReadSessionData(string path) + { + //var path = Settings.Current.CacheFolder + "\\api_start2.dat"; + //var bytes = Encoding.UTF8.GetBytes(File.ReadAllText(path)); + + //var serializer = new DataContractJsonSerializer(typeof(svdata)); + //using (var stream = new MemoryStream(bytes)) + //{ + // return serializer.ReadObject(stream) as svdata; + //} + + Session session = new Session(new byte[] { 0 }, new byte[] { 0 }); + if (!session.LoadRequestBodyFromFile(path)) + { + throw new ApplicationException("LoadRequestBodyFromFile Failed!! " + path); + } + if (!session.LoadResponseFromFile(path)) + { + throw new ApplicationException("LoadResponseFromFile Failed!! " + path); + } + return session; + } + + /// + /// Fiddler规则(通信完成后 + /// + static public void RulePrintGraphList(Session oSession) + { + if (oSession.PathAndQuery != "/kcsapi/api_start2") + return; + + //Debug.WriteLine("【START2】" + oSession.PathAndQuery); + + SaveSessionData(oSession); + + //移除规则 + RemoveRule(); + } + + static public void AppendRule() + { + FiddlerApplication.AfterSessionComplete += RulePrintGraphList; + //Debug.WriteLine("CACHR> RulePrintGraphList Appended"); + } + + static public void RemoveRule() + { + FiddlerApplication.AfterSessionComplete -= RulePrintGraphList; + //Debug.WriteLine("CACHR> RulePrintGraphList Removed"); + } + } + + + class ship_graph_item + { + public int ship_id = 0; + public int ship_sortno = 0; + public string ship_name = ""; + + public int ship_type_id = 0; + public int ship_type_sortno = 0; + public string ship_type_name = ""; + + public int ship_graph_sortno = 0; + public string ship_filename = ""; + public string ship_version = ""; + } +} diff --git a/DebugPlatform/Program.cs b/DebugPlatform/Program.cs index 39b8a89..c8b078e 100644 --- a/DebugPlatform/Program.cs +++ b/DebugPlatform/Program.cs @@ -1,313 +1,313 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Data; -using System.Windows; -//using System.Text.RegularExpressions; - -using System.Xml; -using System.Xml.Linq; -using System.IO; - -using d_f_32.KanColleCacher; -using d_f_32.KanColleCacher.Configuration; - -namespace DebugPlatform -{ - class Program - { - - static void Main(string[] args) - { - Console.WriteLine("-----------------------------------------"); - GraphList.DebugFunc(); - Console.ReadLine(); - } - static void Main_old(string[] args) - { - Console.WriteLine("-----------------------------------------"); - Console.WriteLine("KanColleCacher_1.3_Updater Copyright d.f.32 - 2015 \n"); - Console.WriteLine("本程序是KCV缓存插件 KanColleCacher 的更新补丁程序。"); - Console.WriteLine("插件从1.3更新到2.0时废弃了原有的设置文件与部分数据文件的储存方式,这将造成设置的丢失以及部分缓存文件需要重新下载。"); - Console.WriteLine("本程序则是用来解决这一问题的。"); - Console.WriteLine(); - Console.WriteLine(@"在程序运行前,请核实以下描述: -* 你在使用名为【舰队很忙!KanColleViewer】的游戏程序 -* 你安装使用了插件 KanColleCacher 一段时间,插件为你缓存了大量的游戏文件 -* 你需要将插件 KanColleCacher 从1.3更新到2.0,且不希望再次这些下载缓存文件 -* 你知道本程序只是补丁,并不包含插件主体的dll文件,且也不会为你拷贝移动插件主体 -* 你已经在运行前将本程序放置在了【舰队很忙!KanColleViewer】的程序目录下,或其目录的Plugins子目录下 - -若以上描述核实无误,请按回车键以开始执行补丁..."); - Console.ReadLine(); - - List setFiles = new List(); - List cacheFolders = new List(); - string dir = Directory.GetCurrentDirectory(); - - Console.WriteLine("-----------------------------------------"); - Console.WriteLine("检索设置文件..."); - - var path = dir + @"\Plugins\KanColleCacher.xml"; - if (File.Exists(path)) setFiles.Add(path); - - path = dir + @"\KanColleCacher.xml"; - if (File.Exists(path)) setFiles.Add(path); - - path = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), - "grabacr.net", - "KanColleViewer", - "KanColleCacher.xml" - ); - if (File.Exists(path)) setFiles.Add(path); - - if (setFiles.Count == 0) - { - Console.WriteLine("没有找到任何设置文件!更新无法继续进行。"); - Console.WriteLine("请按下回车键以退出程序..."); - Console.ReadLine(); - return; - } - - Console.WriteLine("找到设置文件共 {0} 个",setFiles.Count); - - foreach (var fpath in setFiles) - { - Console.WriteLine("处理设置文件...\n\t" + fpath); - try - { - string cachefolder; - ProcessSettingFile(fpath, out cachefolder); - if (String.IsNullOrEmpty(cachefolder) || !Directory.Exists(cachefolder)) - { - Console.WriteLine("无效的缓存文件夹!\n\t" + cachefolder); - } - cacheFolders.Add(cachefolder); - } - catch (Exception ex) - { - Console.WriteLine("处理设置文件时发生异常。可能是文件损坏。"); - Console.WriteLine(ex.Message); - } - } - - Console.WriteLine("设置文件处理结束。找到缓存文件夹 {0} 个", cacheFolders.Count); - Console.WriteLine(); - Console.WriteLine("-----------------------------------------"); - - if (cacheFolders.Count == 0) - { - Console.WriteLine("没有找到任何缓存文件夹的设置!更新无法继续进行。"); - Console.WriteLine("请手动输入缓存文件夹地址或按回车键结束程序:"); - string input; - while (!String.IsNullOrWhiteSpace(input = Console.ReadLine())) - { - if (Directory.Exists(input)) - { - cacheFolders.Add(input); - break; - } - Console.WriteLine("无效地址"); - } - if (cacheFolders.Count==0) return; - } - - Console.WriteLine(); - - foreach (var folder in cacheFolders) - { - Console.WriteLine("处理缓存文件夹...\n\t" + folder); - ProcessCacheFolder(folder); - } - - Console.WriteLine("缓存文件处理结束\n"); - Console.WriteLine("-----------------------------------------"); - Console.WriteLine("是否移除废弃的文件? [Y] 删除 [N] 不删除"); - - string ipt = Console.ReadLine().ToLower(); - while (!ipt.StartsWith("y") && !ipt.StartsWith("n")) - { - ipt = Console.ReadLine().ToLower(); - } - - if (ipt.StartsWith("y")) - { - foreach (var f in setFiles) - { - try { - File.Delete(f); - Console.WriteLine("删除 " + f); - } - catch { } - } - foreach (var p in cacheFolders) - { - try { - File.Delete(p + "\\Last-Modified.xml"); - Console.WriteLine("删除 " + p + "\\Last-Modified.xml"); - } - catch { } - } - } - - Console.WriteLine("按任意键退出程序"); - Console.ReadKey(); - } - - static void ProcessSettingFile(string filepath, out string cachefolder) - { - var doc = XDocument.Load(filepath); - var parser = new ConfigParser(); - var section = parser["Settings"] = new Section(); - parser.SerializeObject(new Settings(), "Settings"); - - foreach (var elm in doc.Root.Elements()) - { - var name = elm.Name.ToString(); - var val = elm.Value; - - if (!String.IsNullOrEmpty(val)) - { - section[name] = val; - } - } - - section["SaveApiStart2"] = section["PrintGraphList"]; - section["PrintGraphList"] = null; - - parser.SaveIniFile(filepath.Substring(0, filepath.Length - 3) + "ini"); - cachefolder = section["CacheFolder"]; - } - - static void ProcessCacheFolder(string cachefolder) - { - var xmlf = cachefolder + "//Last-Modified.xml"; - - if (!File.Exists(xmlf)) - { - Console.WriteLine("没有找到Last-Modified.xml。"); - return; - } - XDocument doc; - try - { - doc = XDocument.Load(xmlf); - } - catch (Exception) - { - Console.WriteLine("Last-Modified.xml文件损坏。"); - return; - } - - int count = 0; - foreach (var elm in doc.Root.Elements()) - { - count++; - try - { - var path = elm.Element("Path").Value; - var time = elm.Element("Time").Value; - - path = (cachefolder + "\\" + path).Replace('/', '\\'); - if (!File.Exists(path)) - { - Console.WriteLine("无效地址:" + path); - continue; - } - - var fi = new FileInfo(path); - fi.LastWriteTime =GMTHelper.GMT2Local(time); - } - catch(Exception ex) - { - Console.WriteLine("第 {0} 个元素损坏。" + ex.Message, count); - } - } - Console.WriteLine("Last-Modified.xml 处理结束,共处理 {0} 个文件", count); - } - } - - - - - - - - class ModifiedRecord - { - static string filepath; - static XDocument fileXML; - static IEnumerable recordList; - - const string _RootName = "Last-Modified"; - const string _ItemElm = "Record"; - const string _ElmPath = "Path"; - const string _ElmTime = "Time"; - const string _ElmVersion = "Version"; - - #region 加载与保存 - - /// - /// 从Last-Modified.xml加载记录 - /// - static public void Load() - { - //filepath = Settings.Current.CacheFolder + "\\Last-Modified.xml"; - filepath = @"B:\GitHub\KanColleCacher\DebugPlatform\Last-Modified - 副本.xml"; - try - { - if (File.Exists(filepath)) - fileXML = XDocument.Load(filepath); - } - catch (Exception ex) - { - //Log.Exception(ex.InnerException, ex, "加载Last-Modified.xml时发生异常"); - throw ex; - } - - if (fileXML == null) - { - fileXML = new XDocument(); - fileXML.Add(new XElement(_RootName)); - } - - recordList = fileXML.Descendants(_ItemElm); - //recordList 和 fileXML是同步的 - } - - /// - /// 保存到Last-Modified.xml - /// - static public void Save() - { - filepath = @"B:\GitHub\KanColleCacher\DebugPlatform\Last-Modified.xml"; - - - - try - { - var elms = fileXML.Descendants(_ItemElm) - .OrderBy(elm => - { return elm.Element(_ElmPath).Value; } - ).ToArray(); - - fileXML.Root.Elements().Remove(); - fileXML.Root.Add(elms); - } - catch - { - //Log.Exception(ex.InnerException, ex, "保存Last-Modified.xml时发生异常"); - } - - fileXML.Save(filepath); - } - - } - #endregion - - - -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows; +//using System.Text.RegularExpressions; + +using System.Xml; +using System.Xml.Linq; +using System.IO; + +using d_f_32.KanColleCacher; +using d_f_32.KanColleCacher.Configuration; + +namespace DebugPlatform +{ + class Program + { + + static void Main(string[] args) + { + Console.WriteLine("-----------------------------------------"); + GraphList.DebugFunc(); + Console.ReadLine(); + } + static void Main_old(string[] args) + { + Console.WriteLine("-----------------------------------------"); + Console.WriteLine("KanColleCacher_1.3_Updater Copyright d.f.32 - 2015 \n"); + Console.WriteLine("本程序是KCV缓存插件 KanColleCacher 的更新补丁程序。"); + Console.WriteLine("插件从1.3更新到2.0时废弃了原有的设置文件与部分数据文件的储存方式,这将造成设置的丢失以及部分缓存文件需要重新下载。"); + Console.WriteLine("本程序则是用来解决这一问题的。"); + Console.WriteLine(); + Console.WriteLine(@"在程序运行前,请核实以下描述: +* 你在使用名为【舰队很忙!KanColleViewer】的游戏程序 +* 你安装使用了插件 KanColleCacher 一段时间,插件为你缓存了大量的游戏文件 +* 你需要将插件 KanColleCacher 从1.3更新到2.0,且不希望再次这些下载缓存文件 +* 你知道本程序只是补丁,并不包含插件主体的dll文件,且也不会为你拷贝移动插件主体 +* 你已经在运行前将本程序放置在了【舰队很忙!KanColleViewer】的程序目录下,或其目录的Plugins子目录下 + +若以上描述核实无误,请按回车键以开始执行补丁..."); + Console.ReadLine(); + + List setFiles = new List(); + List cacheFolders = new List(); + string dir = Directory.GetCurrentDirectory(); + + Console.WriteLine("-----------------------------------------"); + Console.WriteLine("检索设置文件..."); + + var path = dir + @"\Plugins\KanColleCacher.xml"; + if (File.Exists(path)) setFiles.Add(path); + + path = dir + @"\KanColleCacher.xml"; + if (File.Exists(path)) setFiles.Add(path); + + path = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + "grabacr.net", + "KanColleViewer", + "KanColleCacher.xml" + ); + if (File.Exists(path)) setFiles.Add(path); + + if (setFiles.Count == 0) + { + Console.WriteLine("没有找到任何设置文件!更新无法继续进行。"); + Console.WriteLine("请按下回车键以退出程序..."); + Console.ReadLine(); + return; + } + + Console.WriteLine("找到设置文件共 {0} 个",setFiles.Count); + + foreach (var fpath in setFiles) + { + Console.WriteLine("处理设置文件...\n\t" + fpath); + try + { + string cachefolder; + ProcessSettingFile(fpath, out cachefolder); + if (String.IsNullOrEmpty(cachefolder) || !Directory.Exists(cachefolder)) + { + Console.WriteLine("无效的缓存文件夹!\n\t" + cachefolder); + } + cacheFolders.Add(cachefolder); + } + catch (Exception ex) + { + Console.WriteLine("处理设置文件时发生异常。可能是文件损坏。"); + Console.WriteLine(ex.Message); + } + } + + Console.WriteLine("设置文件处理结束。找到缓存文件夹 {0} 个", cacheFolders.Count); + Console.WriteLine(); + Console.WriteLine("-----------------------------------------"); + + if (cacheFolders.Count == 0) + { + Console.WriteLine("没有找到任何缓存文件夹的设置!更新无法继续进行。"); + Console.WriteLine("请手动输入缓存文件夹地址或按回车键结束程序:"); + string input; + while (!String.IsNullOrWhiteSpace(input = Console.ReadLine())) + { + if (Directory.Exists(input)) + { + cacheFolders.Add(input); + break; + } + Console.WriteLine("无效地址"); + } + if (cacheFolders.Count==0) return; + } + + Console.WriteLine(); + + foreach (var folder in cacheFolders) + { + Console.WriteLine("处理缓存文件夹...\n\t" + folder); + ProcessCacheFolder(folder); + } + + Console.WriteLine("缓存文件处理结束\n"); + Console.WriteLine("-----------------------------------------"); + Console.WriteLine("是否移除废弃的文件? [Y] 删除 [N] 不删除"); + + string ipt = Console.ReadLine().ToLower(); + while (!ipt.StartsWith("y") && !ipt.StartsWith("n")) + { + ipt = Console.ReadLine().ToLower(); + } + + if (ipt.StartsWith("y")) + { + foreach (var f in setFiles) + { + try { + File.Delete(f); + Console.WriteLine("删除 " + f); + } + catch { } + } + foreach (var p in cacheFolders) + { + try { + File.Delete(p + "\\Last-Modified.xml"); + Console.WriteLine("删除 " + p + "\\Last-Modified.xml"); + } + catch { } + } + } + + Console.WriteLine("按任意键退出程序"); + Console.ReadKey(); + } + + static void ProcessSettingFile(string filepath, out string cachefolder) + { + var doc = XDocument.Load(filepath); + var parser = new ConfigParser(); + var section = parser["Settings"] = new Section(); + parser.SerializeObject(new Settings(), "Settings"); + + foreach (var elm in doc.Root.Elements()) + { + var name = elm.Name.ToString(); + var val = elm.Value; + + if (!String.IsNullOrEmpty(val)) + { + section[name] = val; + } + } + + section["SaveApiStart2"] = section["PrintGraphList"]; + section["PrintGraphList"] = null; + + parser.SaveIniFile(filepath.Substring(0, filepath.Length - 3) + "ini"); + cachefolder = section["CacheFolder"]; + } + + static void ProcessCacheFolder(string cachefolder) + { + var xmlf = cachefolder + "//Last-Modified.xml"; + + if (!File.Exists(xmlf)) + { + Console.WriteLine("没有找到Last-Modified.xml。"); + return; + } + XDocument doc; + try + { + doc = XDocument.Load(xmlf); + } + catch (Exception) + { + Console.WriteLine("Last-Modified.xml文件损坏。"); + return; + } + + int count = 0; + foreach (var elm in doc.Root.Elements()) + { + count++; + try + { + var path = elm.Element("Path").Value; + var time = elm.Element("Time").Value; + + path = (cachefolder + "\\" + path).Replace('/', '\\'); + if (!File.Exists(path)) + { + Console.WriteLine("无效地址:" + path); + continue; + } + + var fi = new FileInfo(path); + fi.LastWriteTime =GMTHelper.GMT2Local(time); + } + catch(Exception ex) + { + Console.WriteLine("第 {0} 个元素损坏。" + ex.Message, count); + } + } + Console.WriteLine("Last-Modified.xml 处理结束,共处理 {0} 个文件", count); + } + } + + + + + + + + class ModifiedRecord + { + static string filepath; + static XDocument fileXML; + static IEnumerable recordList; + + const string _RootName = "Last-Modified"; + const string _ItemElm = "Record"; + const string _ElmPath = "Path"; + const string _ElmTime = "Time"; + const string _ElmVersion = "Version"; + + #region 加载与保存 + + /// + /// 从Last-Modified.xml加载记录 + /// + static public void Load() + { + //filepath = Settings.Current.CacheFolder + "\\Last-Modified.xml"; + filepath = @"B:\GitHub\KanColleCacher\DebugPlatform\Last-Modified - 副本.xml"; + try + { + if (File.Exists(filepath)) + fileXML = XDocument.Load(filepath); + } + catch (Exception ex) + { + //Log.Exception(ex.InnerException, ex, "加载Last-Modified.xml时发生异常"); + throw ex; + } + + if (fileXML == null) + { + fileXML = new XDocument(); + fileXML.Add(new XElement(_RootName)); + } + + recordList = fileXML.Descendants(_ItemElm); + //recordList 和 fileXML是同步的 + } + + /// + /// 保存到Last-Modified.xml + /// + static public void Save() + { + filepath = @"B:\GitHub\KanColleCacher\DebugPlatform\Last-Modified.xml"; + + + + try + { + var elms = fileXML.Descendants(_ItemElm) + .OrderBy(elm => + { return elm.Element(_ElmPath).Value; } + ).ToArray(); + + fileXML.Root.Elements().Remove(); + fileXML.Root.Add(elms); + } + catch + { + //Log.Exception(ex.InnerException, ex, "保存Last-Modified.xml时发生异常"); + } + + fileXML.Save(filepath); + } + + } + #endregion + + + +} diff --git a/KanColleCacher/CacheCore.cs b/KanColleCacher/CacheCore.cs index 6c64051..a7b064a 100644 --- a/KanColleCacher/CacheCore.cs +++ b/KanColleCacher/CacheCore.cs @@ -1,315 +1,315 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Windows; -using System.Windows.Controls; -using Debug = System.Diagnostics.Debug; - - -namespace d_f_32.KanColleCacher -{ - - enum filetype - { - not_file, - unknown_file, - - game_entry, //kcs\mainD2.swf - //kcs\Core.swf - - entry_large, //kcs\scenes\TitleMain.swf - //kcs\resources\swf\commonAsset.swf - //kcs\resources\swf\font.swf - //kcs\resources\swf\icons.swf - - port_main, //kcs\PortMain.swf - //kcs\resources\swf\sound_se.swf - - scenes, //kcs\scenes\ - - resources, //kcs\resources\bgm_p\ - //kcs\resources\swf\sound_bgm.swf - //kcs\resources\swf\sound_b_bgm_*.swf - //kcs\resources\swf\map\ - //kcs\resources\swf\ships\ - - image, //kcs\resources\images - sound, //kcs\sound - - world_name, //kcs\resources\images\world - title_call, //kcs\sound\titlecall - } - - - class CacheCore - { - #region 初始化与析构 - Settings set; - string myCacheFolder; - - public CacheCore() - { - set = Settings.Current; - //VersionChecker.Load(); - myCacheFolder = set.CacheFolder; - } - - - #endregion - - /// - /// 对于一个新的客户端请求,根据url,决定下一步要对请求怎样处理 - /// - /// 请求的url - /// 本地文件地址 or 记录的修改日期 - /// 下一步我们该做什么?忽略请求;返回缓存文件;验证缓存文件 - public Direction GotNewRequest(string url, out string result) - { - result = ""; - string filepath = ""; - - Uri uri; - try { uri = new Uri(url); } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex); - return Direction.Discharge_Response; - //url无效,忽略请求(不进行任何操作) - } - - if (!uri.IsFilePath()) - { - return Direction.Discharge_Response; - //url非文件,忽略请求 - } - - //识别文件类型 - filetype type = _RecognizeFileType(uri); - if (type == filetype.unknown_file || - type == filetype.not_file || - type == filetype.game_entry) - { - return Direction.Discharge_Response; - //无效的文件,忽略请求 - } - - //检查Title Call与World Name的特殊地址 - if (set.HackTitleEnabled) - { - if (type == filetype.title_call) - { - filepath = uri.AbsolutePath.Replace('/', '\\'); - filepath = filepath.Remove(filepath.LastIndexOf('\\')) + ".mp3"; - filepath = myCacheFolder + filepath; - result = filepath; - - if (File.Exists(filepath)) - return Direction.Return_LocalFile; - } - else if (type == filetype.world_name) - { - filepath = myCacheFolder + @"\kcs\resources\image\world.png"; - result = filepath; - - if (File.Exists(filepath)) - return Direction.Return_LocalFile; - } - } - - //检查一般文件地址 - if ((type == filetype.resources && set.CacheResourceFiles > 0) || - (type == filetype.entry_large && set.CacheEntryFiles > 0) || - (type == filetype.port_main && set.CachePortFiles > 0) || - (type == filetype.scenes && set.CacheSceneFiles > 0) || - (type == filetype.sound && set.CacheSoundFiles > 0) || - ((type == filetype.title_call || - type == filetype.world_name || - type == filetype.image) && set.CacheResourceFiles > 0)) - { - filepath = myCacheFolder + uri.AbsolutePath.Replace('/', '\\'); - - //检查Hack文件地址 - if (set.HackEnabled) - { - var fnext = uri.Segments.Last().Split('.'); - string hfilepath = filepath.Replace(uri.Segments.Last(), fnext[0] + ".hack." + fnext.Last()); - - if (File.Exists(hfilepath)) - { - result = hfilepath; - return Direction.Return_LocalFile; - //存在hack文件,则返回本地文件 - } - - } - - //检查缓存文件 - if (File.Exists(filepath)) - { - //存在本地缓存文件 -> 检查文件的最后修改时间 - //(验证所有文件 或 只验证非资源文件) - if (set.CheckFiles > 1 || (set.CheckFiles > 0 && type != filetype.resources)) - { - //只有swf文件需要验证时间 - if (filepath.EndsWith(".swf")) - { - //文件存在且需要验证时间 - //-> 请求服务器验证修改时间(记录读取和保存的位置) - result = filepath; - _RecordTask(url, filepath); - return Direction.Verify_LocalFile; - } - - ////检查文件时间 - //int i = VersionChecker.GetFileLastTime(uri, out result); - - //if (i == 1) - //{ - // //存在这个文件的修改时间记录 - // //-> 请求服务器验证修改时间(记录读取和保存的位置) - // _RecordTask(url, filepath); - // return Direction.Verify_LocalFile; - //} - //else if (i == 0) - //{ - // //没有关于这个文件最后修改时间的记录 - // //-> 当做这个文件不存在 - // //-> 下载文件(记录保存地址) - // _RecordTask(url, filepath); - // return Direction.Discharge_Response; - //} - //else - //{ - // //文件类型不需要验证时间(只有swf验证) - //} - } - //文件不需验证 - //->返回本地缓存文件 - result = filepath; - return Direction.Return_LocalFile; - - } - else - { - //缓存文件不存在 - //-> 下载文件 (记录保存地址) - _RecordTask(url, filepath); - return Direction.Discharge_Response; - } - } - - //文件类型对应的缓存设置没有开启 - //-> 当做文件不存在 - return Direction.Discharge_Response; - } - - filetype _RecognizeFileType(Uri uri) - { - if (!uri.IsFilePath()) - return filetype.not_file; - - var seg = uri.Segments; - - if (seg[1] != "kcs/") - { - return filetype.not_file; - } - else - { - - if (seg[2] == "resources/") - { - if (seg[3] == "swf/") - { - if (seg[4] == "commonAssets.swf" || - seg[4] == "font.swf" || - seg[4] == "icons.swf") - { - return filetype.entry_large; - } - - else if (seg[4] == ("sound_se.swf")) - { - return filetype.port_main; - } - } - else if (seg[3] == "image/") - { - if (seg[4] == "world/") - { - return filetype.world_name; - } - - return filetype.image; - } - return filetype.resources; - } - else if (seg[2] == "scenes/") - { - if (seg[3] == "TitleMain.swf") - { - return filetype.entry_large; - } - - return filetype.scenes; - } - else if (seg[2] == "sound/") - { - if (seg[3] == "titlecall/") - { - return filetype.title_call; - } - - return filetype.sound; - } - else - { - if (seg[2] == "Core.swf" || - seg[2] == "mainD2.swf") - { - return filetype.game_entry; - // kcs/mainD2.swf; kcs/Core.swf; - } - else if (seg[2] == "PortMain.swf") - { - return filetype.port_main; - // kcs/PortMain.swf; - - } - } - - //Debug.WriteLine("CACHR> _RecogniseFileType检查到无法识别的文件"); - //Debug.WriteLine(" "+uri.AbsolutePath); - return filetype.unknown_file; - } - - } - - public void RecordNewModifiedTime(string url, string time) - { - Uri uri; - try { uri = new Uri(url); } - catch { return; } - - //VersionChecker.Add(uri, time); - } - - public bool AllowedToSave(filetype type) - { - return (type == filetype.resources && set.CacheResourceFiles > 1) || - (type == filetype.entry_large && set.CacheEntryFiles > 1) || - (type == filetype.port_main && set.CachePortFiles > 1) || - (type == filetype.scenes && set.CacheSceneFiles > 1) || - (type == filetype.sound && set.CacheSoundFiles > 1) || - (type == filetype.title_call || - type == filetype.world_name || - type == filetype.image) && set.CacheResourceFiles > 1; - } - - void _RecordTask(string url, string filepath) - { - TaskRecord.Add(url, filepath); - } - } +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Windows; +using System.Windows.Controls; +using Debug = System.Diagnostics.Debug; + + +namespace d_f_32.KanColleCacher +{ + + enum filetype + { + not_file, + unknown_file, + + game_entry, //kcs\mainD2.swf + //kcs\Core.swf + + entry_large, //kcs\scenes\TitleMain.swf + //kcs\resources\swf\commonAsset.swf + //kcs\resources\swf\font.swf + //kcs\resources\swf\icons.swf + + port_main, //kcs\PortMain.swf + //kcs\resources\swf\sound_se.swf + + scenes, //kcs\scenes\ + + resources, //kcs\resources\bgm_p\ + //kcs\resources\swf\sound_bgm.swf + //kcs\resources\swf\sound_b_bgm_*.swf + //kcs\resources\swf\map\ + //kcs\resources\swf\ships\ + + image, //kcs\resources\images + sound, //kcs\sound + + world_name, //kcs\resources\images\world + title_call, //kcs\sound\titlecall + } + + + class CacheCore + { + #region 初始化与析构 + Settings set; + string myCacheFolder; + + public CacheCore() + { + set = Settings.Current; + //VersionChecker.Load(); + myCacheFolder = set.CacheFolder; + } + + + #endregion + + /// + /// 对于一个新的客户端请求,根据url,决定下一步要对请求怎样处理 + /// + /// 请求的url + /// 本地文件地址 or 记录的修改日期 + /// 下一步我们该做什么?忽略请求;返回缓存文件;验证缓存文件 + public Direction GotNewRequest(string url, out string result) + { + result = ""; + string filepath = ""; + + Uri uri; + try { uri = new Uri(url); } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex); + return Direction.Discharge_Response; + //url无效,忽略请求(不进行任何操作) + } + + if (!uri.IsFilePath()) + { + return Direction.Discharge_Response; + //url非文件,忽略请求 + } + + //识别文件类型 + filetype type = _RecognizeFileType(uri); + if (type == filetype.unknown_file || + type == filetype.not_file || + type == filetype.game_entry) + { + return Direction.Discharge_Response; + //无效的文件,忽略请求 + } + + //检查Title Call与World Name的特殊地址 + if (set.HackTitleEnabled) + { + if (type == filetype.title_call) + { + filepath = uri.AbsolutePath.Replace('/', '\\'); + filepath = filepath.Remove(filepath.LastIndexOf('\\')) + ".mp3"; + filepath = myCacheFolder + filepath; + result = filepath; + + if (File.Exists(filepath)) + return Direction.Return_LocalFile; + } + else if (type == filetype.world_name) + { + filepath = myCacheFolder + @"\kcs\resources\image\world.png"; + result = filepath; + + if (File.Exists(filepath)) + return Direction.Return_LocalFile; + } + } + + //检查一般文件地址 + if ((type == filetype.resources && set.CacheResourceFiles > 0) || + (type == filetype.entry_large && set.CacheEntryFiles > 0) || + (type == filetype.port_main && set.CachePortFiles > 0) || + (type == filetype.scenes && set.CacheSceneFiles > 0) || + (type == filetype.sound && set.CacheSoundFiles > 0) || + ((type == filetype.title_call || + type == filetype.world_name || + type == filetype.image) && set.CacheResourceFiles > 0)) + { + filepath = myCacheFolder + uri.AbsolutePath.Replace('/', '\\'); + + //检查Hack文件地址 + if (set.HackEnabled) + { + var fnext = uri.Segments.Last().Split('.'); + string hfilepath = filepath.Replace(uri.Segments.Last(), fnext[0] + ".hack." + fnext.Last()); + + if (File.Exists(hfilepath)) + { + result = hfilepath; + return Direction.Return_LocalFile; + //存在hack文件,则返回本地文件 + } + + } + + //检查缓存文件 + if (File.Exists(filepath)) + { + //存在本地缓存文件 -> 检查文件的最后修改时间 + //(验证所有文件 或 只验证非资源文件) + if (set.CheckFiles > 1 || (set.CheckFiles > 0 && type != filetype.resources)) + { + //只有swf文件需要验证时间 + if (filepath.EndsWith(".swf")) + { + //文件存在且需要验证时间 + //-> 请求服务器验证修改时间(记录读取和保存的位置) + result = filepath; + _RecordTask(url, filepath); + return Direction.Verify_LocalFile; + } + + ////检查文件时间 + //int i = VersionChecker.GetFileLastTime(uri, out result); + + //if (i == 1) + //{ + // //存在这个文件的修改时间记录 + // //-> 请求服务器验证修改时间(记录读取和保存的位置) + // _RecordTask(url, filepath); + // return Direction.Verify_LocalFile; + //} + //else if (i == 0) + //{ + // //没有关于这个文件最后修改时间的记录 + // //-> 当做这个文件不存在 + // //-> 下载文件(记录保存地址) + // _RecordTask(url, filepath); + // return Direction.Discharge_Response; + //} + //else + //{ + // //文件类型不需要验证时间(只有swf验证) + //} + } + //文件不需验证 + //->返回本地缓存文件 + result = filepath; + return Direction.Return_LocalFile; + + } + else + { + //缓存文件不存在 + //-> 下载文件 (记录保存地址) + _RecordTask(url, filepath); + return Direction.Discharge_Response; + } + } + + //文件类型对应的缓存设置没有开启 + //-> 当做文件不存在 + return Direction.Discharge_Response; + } + + filetype _RecognizeFileType(Uri uri) + { + if (!uri.IsFilePath()) + return filetype.not_file; + + var seg = uri.Segments; + + if (seg[1] != "kcs/") + { + return filetype.not_file; + } + else + { + + if (seg[2] == "resources/") + { + if (seg[3] == "swf/") + { + if (seg[4] == "commonAssets.swf" || + seg[4] == "font.swf" || + seg[4] == "icons.swf") + { + return filetype.entry_large; + } + + else if (seg[4] == ("sound_se.swf")) + { + return filetype.port_main; + } + } + else if (seg[3] == "image/") + { + if (seg[4] == "world/") + { + return filetype.world_name; + } + + return filetype.image; + } + return filetype.resources; + } + else if (seg[2] == "scenes/") + { + if (seg[3] == "TitleMain.swf") + { + return filetype.entry_large; + } + + return filetype.scenes; + } + else if (seg[2] == "sound/") + { + if (seg[3] == "titlecall/") + { + return filetype.title_call; + } + + return filetype.sound; + } + else + { + if (seg[2] == "Core.swf" || + seg[2] == "mainD2.swf") + { + return filetype.game_entry; + // kcs/mainD2.swf; kcs/Core.swf; + } + else if (seg[2] == "PortMain.swf") + { + return filetype.port_main; + // kcs/PortMain.swf; + + } + } + + //Debug.WriteLine("CACHR> _RecogniseFileType检查到无法识别的文件"); + //Debug.WriteLine(" "+uri.AbsolutePath); + return filetype.unknown_file; + } + + } + + public void RecordNewModifiedTime(string url, string time) + { + Uri uri; + try { uri = new Uri(url); } + catch { return; } + + //VersionChecker.Add(uri, time); + } + + public bool AllowedToSave(filetype type) + { + return (type == filetype.resources && set.CacheResourceFiles > 1) || + (type == filetype.entry_large && set.CacheEntryFiles > 1) || + (type == filetype.port_main && set.CachePortFiles > 1) || + (type == filetype.scenes && set.CacheSceneFiles > 1) || + (type == filetype.sound && set.CacheSoundFiles > 1) || + (type == filetype.title_call || + type == filetype.world_name || + type == filetype.image) && set.CacheResourceFiles > 1; + } + + void _RecordTask(string url, string filepath) + { + TaskRecord.Add(url, filepath); + } + } } \ No newline at end of file diff --git a/KanColleCacher/CacherToolView.xaml b/KanColleCacher/CacherToolView.xaml index 0a070bf..0d54863 100644 --- a/KanColleCacher/CacherToolView.xaml +++ b/KanColleCacher/CacherToolView.xaml @@ -133,13 +133,13 @@ - + - + - + @@ -166,7 +166,7 @@ @@ -174,7 +174,7 @@ - + - @@ -220,22 +220,22 @@ - - - - - @@ -244,14 +244,14 @@ - @@ -261,11 +261,11 @@ - - @@ -274,16 +274,16 @@ - - + - + @@ -291,14 +291,14 @@ - - + @@ -306,14 +306,14 @@ - - + @@ -321,23 +321,27 @@ -