diff --git a/GCVerify/Data/GameTDB.cs b/GCVerify/Data/GameTDB.cs index 5e58538..fe8017c 100644 --- a/GCVerify/Data/GameTDB.cs +++ b/GCVerify/Data/GameTDB.cs @@ -19,68 +19,40 @@ static class GameTDB static Dictionary titles; static string _dataPath; - public static async Task Open(string dataPath) + static GameTDB() { - _dataPath = dataPath; - - await Task.Run(() => + StringReader r = new StringReader(Properties.Resources.titles); + string line; + titles = new Dictionary(); + string[] spl; + while ((line = r.ReadLine()) != null) { - var dbPath = Path.Combine(dataPath, "wiitdb.zip"); - if (!File.Exists(dbPath)) - Update(dataPath); - - var titlePath = Path.Combine(dataPath, "titles.txt"); - if (File.Exists(titlePath)) - { - var list = File.ReadAllLines(titlePath); - titles = new Dictionary(list.Length); - string[] spl; - foreach(var item in list) - { - spl = item.Split('='); - titles.Add(spl[0].Trim(), spl[1].Trim()); - } - } - - using (var arc = new ZipArchive(File.OpenRead(dbPath), ZipArchiveMode.Read)) - { - var entries = arc.Entries; - if (entries.Count > 0) - { - foreach (var entry in entries) - { - if (entry.Name.Contains(".xml")) - { - doc = XDocument.Load(entry.Open()); - return; - } - } - } - } - }); + spl = line.Split('='); + titles.Add(spl[0].Trim(), spl[1].Trim()); + } } public static void Update(string dataPath) { - var filePath = Path.Combine(dataPath, "wiitdb.zip"); - var req = HttpWebRequest.Create(string.Format("http://www.gametdb.com/wiitdb.zip?LANG={0}&FALLBACK=true&GAMECUBE=true&WIIWARE=true", "EN")); - var resp = req.GetResponse(); + //var filePath = Path.Combine(dataPath, "wiitdb.zip"); + //var req = HttpWebRequest.Create(string.Format("http://www.gametdb.com/wiitdb.zip?LANG={0}&FALLBACK=true&GAMECUBE=true&WIIWARE=true", "EN")); + //var resp = req.GetResponse(); Stream strm = null; - if (resp != null) - { - strm = resp.GetResponseStream(); - if (strm != null) - { - var f = File.Create(filePath); - strm.CopyTo(f); - f.Close(); - strm.Close(); - } - } + //if (resp != null) + //{ + // strm = resp.GetResponseStream(); + // if (strm != null) + // { + // var f = File.Create(filePath); + // strm.CopyTo(f); + // f.Close(); + // strm.Close(); + // } + //} - filePath = Path.Combine(dataPath, "titles.txt"); - req = HttpWebRequest.Create(string.Format("http://www.gametdb.com/titles.txt?LANG={0}", "EN")); - resp = req.GetResponse(); + var filePath = Path.Combine(dataPath, "titles.txt"); + var req = HttpWebRequest.Create(string.Format("http://www.gametdb.com/titles.txt?LANG={0}", "EN")); + var resp = req.GetResponse(); if (resp != null) { strm = resp.GetResponseStream(); diff --git a/GCVerify/Data/Redump.cs b/GCVerify/Data/Redump.cs index e647af7..ee5f73b 100644 --- a/GCVerify/Data/Redump.cs +++ b/GCVerify/Data/Redump.cs @@ -16,33 +16,23 @@ static class Redump const string redumpUri = "http://redump.org/datfile/gc/"; static XDocument doc; - public static async Task Open(string dataPath) + static Redump() { - await Task.Run(() => + using (var arc = new ZipArchive(new MemoryStream(Properties.Resources.redump), ZipArchiveMode.Read)) { - var path = Path.Combine(dataPath, "redump.zip"); - if (!File.Exists(path)) - Update(dataPath); - - if (File.Exists(path)) + var entries = arc.Entries; + if (entries.Count > 0) { - using (var arc = new ZipArchive(File.OpenRead(path), ZipArchiveMode.Read)) + foreach (var entry in entries) { - var entries = arc.Entries; - if (entries.Count > 0) + if (entry.Name.Contains(".dat")) { - foreach (var entry in entries) - { - if (entry.Name.Contains(".dat")) - { - doc = XDocument.Load(entry.Open()); - break; - } - } + doc = XDocument.Load(entry.Open()); + break; } } } - }); + } } public static void Update(string dataPath) diff --git a/GCVerify/GCVerify.csproj b/GCVerify/GCVerify.csproj index 58e86f9..5a0719b 100644 --- a/GCVerify/GCVerify.csproj +++ b/GCVerify/GCVerify.csproj @@ -104,6 +104,11 @@ + + True + True + Resources.resx + ScanPage.xaml @@ -151,6 +156,7 @@ Settings.Designer.cs + @@ -175,6 +181,15 @@ false + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + +