Exemplo n.º 1
0
        void loaddatabase() {
            if (!System.IO.File.Exists(gamedatabase_path)) {
                System.IO.File.Create(gamedatabase_path).Close();
                return;
            }
            System.IO.StreamReader sr = new System.IO.StreamReader(gamedatabase_path);
            gamedatabase.Clear();
            if (sr.BaseStream.Length == 0) goto exsub;

            wud tmp = new wud();
            string treg = sr.ReadLine();
            int databaseversion=100;

            if (Microsoft.VisualBasic.Strings.Left(treg, "Uwizard game database version".Length) == "Uwizard game database version") {
                databaseversion = int.Parse(treg[30].ToString() + treg[32].ToString() + treg[34].ToString());
                treg = sr.ReadLine();
            }

            if (databaseversion>myversion)
                msgbox(uwiz_langtext[149]); // "This game database was generated by a newer version of Uwizard. It may be incompatible."//*/ // Remove this REALLY stupid piece of code.

            bool isfirst = true;

            try {
                while (!sr.EndOfStream) {
                    if (isfirst) {
                        tmp.id = treg;
                        isfirst = false;
                    } else
                        tmp.id = sr.ReadLine();
                    tmp.name = sr.ReadLine();
                    treg = sr.ReadLine();
                    switch (treg) {
                        case "EUR": tmp.reg = wud.regcode.EUR; break;
                        case "JPN": tmp.reg = wud.regcode.JPN; break;
                        case "AUS": tmp.reg = wud.regcode.AUS; break;
                        default: tmp.reg = wud.regcode.USA; break;
                    }
                    tmp.keyhash = sr.ReadLine();
                    tmp.key = sr.ReadLine();
                    if (sr.ReadLine() == "Ziffs Live On Cliffs:") {
                        tmp.desc = "";
                        treg = sr.ReadLine();
                        while (treg != "Zuffs Live On Bluffs:") {
                            tmp.desc = tmp.desc + treg + "\r\n";
                            treg = sr.ReadLine();
                        }
                    }
                    sr.ReadLine();
                    gamedatabase.Add(tmp);
                }
            } catch (Exception ex) {}
exsub:      sr.Close();
            sr.Dispose();
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e) {
            //MessageBox.Show("You must time-travel into the future to use this feature!");
            if (System.IO.Directory.Exists("uwiz_newverfiles")) System.IO.Directory.Delete("uwiz_newverfiles", true);
            System.IO.Directory.CreateDirectory("uwiz_newverfiles");
            //System.IO.File.SetAttributes("uwiz_newverfiles", System.IO.FileAttributes.Hidden);

            gzip.decompress(Uwizard.Properties.Resources.unzip, "uwiz_newverfiles/unzip.exe");

            System.Diagnostics.Process unzip = new System.Diagnostics.Process();
            unzip.StartInfo.FileName = System.IO.Path.GetFullPath("uwiz_newverfiles/unzip.exe");
            unzip.StartInfo.WorkingDirectory =  System.IO.Path.GetFullPath("uwiz_newverfiles");
            unzip.StartInfo.CreateNoWindow = true;
            unzip.StartInfo.UseShellExecute = false;

            try {
                netw.DownloadFile("http://www.gametdb.com/wiiutdb.zip", "uwiz_newverfiles/wiiutdb.zip", "", "", true, 100, true);
                //System.IO.File.Copy("wiiutdb.zip", "uwiz_newverfiles/wiiutdb.zip");

                unzip.StartInfo.Arguments = "\"" + System.IO.Path.GetFullPath("uwiz_newverfiles/wiiutdb.zip") + "\"";
                unzip.Start();
                unzip.WaitForExit();

                string wiiutdb = System.IO.File.ReadAllText("uwiz_newverfiles/wiiutdb.xml");
                string tstr;

                #if DEBUG_BUILD
                    string dbdata = "";
                #endif

                wud twud = new wud();
                int lindex = wiiutdb.IndexOf("<game");
                int tint;

                int numadded = 0;
                int numalted = 0;

                while (lindex != -1) {
                    twud.key="";
                    twud.keyhash="";
                    twud.desc="";

                    wiiutdb = wiiutdb.Substring(lindex+5, wiiutdb.Length-lindex-5);
                    tint = wiiutdb.IndexOf("</game>");
                    tstr = wiiutdb.Substring(0, tint);
                    lindex = wiiutdb.IndexOf("<id>");
                    if (lindex == -1) goto nexitem;

                    twud.id = tstr.Substring(lindex+4, 6);

                    lindex = tstr.IndexOf("<type>");
                    if (lindex == -1) goto nexitem;
                    tint = tstr.IndexOf("</type>");
                    if (tint == -1) goto nexitem;

                    if (tstr.Substring(lindex + 6, tint - lindex - 6) != "WiiU") goto nexitem;

                    lindex = tstr.IndexOf("<title>");
                    if (lindex == -1) goto nexitem;
                    tint = tstr.IndexOf("</title>");
                    if (tint == -1) goto nexitem;
                    twud.name = tstr.Substring(lindex + 7, tint - lindex - 7);

                    switch (twud.id[3]) {
                        case 'J': twud.reg = wud.regcode.JPN; break;
                        case 'P': twud.reg = wud.regcode.EUR; break;
                        case 'A': twud.reg = wud.regcode.AUS; break;
                        default: twud.reg = wud.regcode.USA; break;
                    }

                    lindex = tstr.IndexOf("<synopsis>");
                    tint = tstr.IndexOf("</synopsis>");
                    if (lindex != -1 && tint != -1) {
                        twud.desc = tstr.Substring(lindex + 10, tint - lindex - 10) + "\r\n";
                    }

                    for (tint = 0; tint < gamedatabase.Count; tint++) {
                        if (gamedatabase[tint].id == twud.id) {
                            twud.key = gamedatabase[tint].key;
                            twud.keyhash = gamedatabase[tint].keyhash;
                            if (gamedatabase[tint].name != twud.name || gamedatabase[tint].desc != twud.desc) {
                                numalted++;
                                #if DEBUG_BUILD
                                    dbdata += "alted: " + twud.id + '\n';
                                #endif
                            }
                            gamedatabase[tint] = twud;
                            #if DEBUG_BUILD
                                dbdata += "added: " + twud.id + '\n';
                            #endif
                            goto nexitem;
                        }
                    }

                    gamedatabase.Add(twud);
                    numadded++;

nexitem:            lindex = wiiutdb.IndexOf("<game");
                }

                savedatabase();

                if (numadded == 0 && numalted == 0)
                    msgbox(uwiz_langtext[27]); // "The game list is up to date."
                else {
                    string umsg="";
                    if (numadded != 1 && numalted != 1)
                        umsg = uwiz_langtext[28];
                    if (numadded == 1 && numalted != 1)
                        umsg = uwiz_langtext[29];
                    if (numadded != 1 && numalted == 1)
                        umsg = uwiz_langtext[30];
                    if (numadded == 1 && numalted == 1)
                        umsg = uwiz_langtext[31];

                    /*if (numadded > 0) {
                        umsg = numadded + " game";
                        if (numadded != 1) umsg += 's';
                        umsg += " added ";
                        if (numalted > 0) umsg += "and ";
                    }
                    if (numalted > 0) {
                        umsg += numalted + " game";
                        if (numalted != 1) umsg += 's';
                        umsg += " updated ";
                    }
                    umsg += "from gametdb.com";//*/
                    #if DEBUG_BUILD
                        writedebuglog(dbdata);
                        msgbox(string.Format(umsg + dblst, numadded, numalted));
                    #else
                        msgbox(string.Format(umsg, numadded, numalted));
                    #endif
                    }
            } catch (Exception ex) {
                #if DEBUG_BUILD
                    writedebuglog("Exception in wiiutdb try block:\r\n\r\n" + ex.Message);
                    msgbox("Error downloading wiiutdb.xml information from gametdb.com." + dblst);
                #endif
            }
            //System.IO.File.Copy("C:\\W98\\uwiz_ver.txt", "uwiz_newverfiles/uwiz_ver.txt");
            try {
            netw.DownloadFile("http://wiiubrew.net/wp-content/uploads/2015/04/uwiz_ver.txt", "uwiz_newverfiles/uwiz_ver.txt", "", "", true, 100, true);
            } catch (Exception ex) {
                #if DEBUG_BUILD
                    writedebuglog("Error in uwiz_ver download try block:\r\n\r\n" + ex.Message);
                    msgbox("Error downloading version information from wiiubrew.net. Update process canceled." + dblst);
                #else
                    msgbox(uwiz_langtext[32]); // "Error downloading version information from wiiubrew.net. Update process canceled."
#endif
                    goto exsub;
            }

            string nver = System.IO.File.ReadAllText("uwiz_newverfiles/uwiz_ver.txt");
            System.IO.File.Delete("uwiz_newverfiles/uwiz_ver.txt");
            int nveri = 0;
            if (!int.TryParse(nver, out nveri)) {
                MessageBox.Show(uwiz_langtext[33], uwiz_langtext[34]);
                goto exsub;
            }
            if (nveri > myversion) {
                if (MessageBox.Show(string.Format(uwiz_langtext[35], getVerText(myversion), getVerText(nveri)), "Uwizard", MessageBoxButtons.YesNo) == DialogResult.No) goto exsub; // "There is a new version of Uwizard available. Do you want to update from " + getVerText(myversion) + " to " + getVerText(nveri) + " ?"

                //System.IO.File.Copy("C:\\W98\\uwiz.zip", "uwiz_newverfiles/newuwiz.zip");
                netw.DownloadFile("http://wiiubrew.net/?smd_process_download=1&download_id=299", "uwiz_newverfiles/uwizzip_info");
                netw.DownloadFile("http://wiiubrew.net/wp-content/uploads/2015/04/Uwizard.zip", "uwiz_newverfiles/uwiz.zip", "", "", true, 100, true);

                gzip.decompress(Uwizard.Properties.Resources.Updater, "uwiz_newverfiles/Updater.exe");
                System.IO.File.WriteAllText("uwiz_newverfiles/uwiz_lver.txt", myversion.ToString());
                System.IO.Directory.CreateDirectory("uwiz_newverfiles/extracted");

                unzip.StartInfo.Arguments = "\"" + System.IO.Path.GetFullPath("uwiz_newverfiles/uwiz.zip") + "\" -d \"" + System.IO.Path.GetFullPath("uwiz_newverfiles/extracted") + "\"";
                unzip.Start();

                System.IO.StreamWriter sw = new System.IO.StreamWriter("uwiz_newverfiles/Updater.dat");
                sw.WriteLine("100"); // Updater File Version
                sw.WriteLine("2000"); // Process Delay (Milsecs)
                //sw.WriteLine("http://wiiubrew.net/?smd_process_download=1&download_id=299"); // New File Location
                //sw.WriteLine("C:\\W98\\uwiz.exe"); // New File Location
                sw.WriteLine(System.IO.Path.GetFullPath("uwiz_newverfiles/extracted/Uwizard.exe")); // New File Location
                sw.WriteLine(Environment.GetCommandLineArgs()[0]); // Old File Location
                sw.WriteLine("NotFromInternet");
                sw.WriteLine("Uwizard Updater"); // Updater Title
                sw.Close();
                sw.Dispose();

                //wud[] old_gdb = gamedatabase.ToArray();
                List<wud> new_gdb = new List<wud>();

                new_gdb.AddRange(gamedatabase.ToArray());

                unzip.WaitForExit();

                System.IO.File.Copy(System.IO.Path.GetFullPath("uwiz_newverfiles/extracted/gamedatabase.txt"), "gamedatabase.txt", true);
                if (System.IO.File.Exists("uwiz_newverfiles/extracted/README.txt")) System.IO.File.Copy("uwiz_newverfiles/extracted/README.txt", "README.txt", true);

                loaddatabase();

                int c, c2;
                wud tmp;
                for (c = 0; c < gamedatabase.Count; c++) {
                    for (c2 = 0; c2 < new_gdb.Count; c2++) {
                        if (gamedatabase[c].id == new_gdb[c2].id) {
                            wud wtmp = gamedatabase[c];
                            wtmp.key = new_gdb[c2].key;
                            new_gdb[c2] = wtmp;
                            break;
                        }
                    }
                    if (c2 == new_gdb.Count) new_gdb.Add(gamedatabase[c]);
                }

                gamedatabase.Clear();
                gamedatabase.AddRange(new_gdb);
                savedatabase();
                gamedatabase.Clear();
                new_gdb.Clear();

                System.Diagnostics.Process np = new System.Diagnostics.Process();
                np.StartInfo.FileName = System.IO.Path.GetFullPath("uwiz_newverfiles/Updater.exe");
                np.StartInfo.WorkingDirectory = System.IO.Path.GetFullPath("uwiz_newverfiles");
                np.Start();

                this.Close();
                return;
            } else {
                msgbox(uwiz_langtext[36]); // "Uwizard is up to date!"
            }
exsub:      System.IO.Directory.Delete("uwiz_newverfiles", true);
            unzip.Dispose();
        }
Exemplo n.º 3
0
        void openWUD(string wudpath, bool verbose) {
            this.Cursor = Cursors.WaitCursor;
            if (verbose) {
                duout.Text = "";
                duout.Visible = true;
            }
            Application.DoEvents();
            try {
                duout.Text = "Reading " + System.IO.Path.GetFileName(wudpath) + "\r\n";
                Application.DoEvents();
                System.IO.StreamReader sr = new System.IO.StreamReader(wudpath);
                currentwud_id = sr.ReadLine();
                sr.Close();
                sr.Dispose();
            } catch (Exception ex) {
                msgbox(uwiz_langtext[8] + "\r\n\r\n" + ex.Message); // "Invalid Wii U disc Image. Perhaps you forgot to unzip the file?\r\n\r\n" + ex.Message
                goto exsub;
            }
            currentwud = wudpath;

            string id = currentwud_id[6].ToString()+currentwud_id[7].ToString()+currentwud_id[8].ToString()+currentwud_id[9].ToString();
            /*string tmp = Microsoft.VisualBasic.Interaction.InputBox("Type the game Id. If you are not a dev, then please click cancel. This feature is only for debugging.","Uwizard", id, -1,-1);
            if (tmp != "") id = tmp;//*/

            wud game=new wud();
            bool isnew = false;

            duout.Text = duout.Text + "Searching game database...\r\n";
            Application.DoEvents();
            int c = -1;
            for (c = 0; c < gamedatabase.Count; c++) {
                if (gamedatabase[c].id[0] == id[0] && gamedatabase[c].id[1] == id[1] && gamedatabase[c].id[2] == id[2] && gamedatabase[c].id[3] == id[3]) {
                    game = gamedatabase[c];
                    goto foundit;
                }
            }

            isnew = true;
            game.id = System.IO.Path.GetFileNameWithoutExtension(currentwud);
            if (game.id.Length != 6) {
                game.id = id + "01";
            } else {
                if (game.id.Substring(0, 4) != id) {
                    game.id = id + "01";
                }
            }

            switch (id[3]) {
                case 'J': game.reg = wud.regcode.JPN; break;
                case 'P': game.reg = wud.regcode.EUR; break;
                case 'A': game.reg = wud.regcode.AUS; break;
                default: game.reg = wud.regcode.USA; break;
            }

            game.name = Microsoft.VisualBasic.Interaction.InputBox(uwiz_langtext[10], uwiz_langtext[11], System.IO.Path.GetFileNameWithoutExtension(currentwud), -1, -1); // "This game is not in the database. Please enter the name:", "Enter Game Name"
            if (game.name == "") goto exsub;

            c = gamedatabase.Count;
            gamedatabase.Add(game);
            savedatabase();

        foundit:
            gid.Text = game.id;
            gid.Tag = c;
            gname.Text = game.name;
            switch (game.reg) {
                case wud.regcode.EUR: gregion.Text = uwiz_langtext[12]; break; // "PAL: Europe"
                case wud.regcode.JPN: gregion.Text = uwiz_langtext[13]; break; // "NTSC: Japan"
                case wud.regcode.AUS: gregion.Text = uwiz_langtext[14]; break; // "PAL: Australia"
                default: gregion.Text = uwiz_langtext[15]; break; // "NTSC: North America"
            }
            gregion.Tag = game.reg;
            gtkey.Tag = game.keyhash;
            gtkey.Text = game.key;
            gdesc.Text = game.desc;

            SetReadOnly(gtkey, false);
            SetReadOnly(gname, false);
            button7.Enabled = true;
            button8.Enabled = true;

            string cvnam = "covers";
            if (!System.IO.Directory.Exists(cvnam)) System.IO.Directory.CreateDirectory(cvnam);
            cvnam = "covers/full";
            if (!System.IO.Directory.Exists(cvnam)) System.IO.Directory.CreateDirectory(cvnam);
            cvnam = "covers/front";
            if (!System.IO.Directory.Exists(cvnam)) System.IO.Directory.CreateDirectory(cvnam);
            cvnam = "covers/3d";
            if (!System.IO.Directory.Exists(cvnam)) System.IO.Directory.CreateDirectory(cvnam);
            cvnam = "covers/disc";
            if (!System.IO.Directory.Exists(cvnam)) System.IO.Directory.CreateDirectory(cvnam);
            cvnam = "covers/front/" + game.id + ".jpg";

            duout.Text = duout.Text + "Searching GameTDB for covers...\r\n";
            Application.DoEvents();
            if (gcover.Tag != null) {
                ((Bitmap)gcover.Tag).Dispose();
                gcover.Tag = null;
            }
            if (otherwudpic != null) {
                otherwudpic.Dispose();
                otherwudpic = null;
            }

            string rtext = "US";
            if (game.reg == wud.regcode.EUR) rtext = "EN";
            if (game.reg == wud.regcode.JPN) rtext = "JP";
            if (game.reg == wud.regcode.AUS) rtext = "AS";

            dcover(cvnam, gametdb_coverlinks, rtext, game.id);

            /*if (!System.IO.File.Exists(cvnam)) {
                System.Net.WebClient wc = new System.Net.WebClient();
                string rtext = "US";
                if (game.reg == wud.regcode.EUR) rtext = "EN";
                if (game.reg == wud.regcode.JPN) rtext = "JP";
                if (game.reg == wud.regcode.AUS) rtext = "AS";
                for (c=0; c < gametdb_coverlinks.Length; c++) {
                    try {
                        duout.Text = duout.Text + "Dowloading: " + gametdb_coverlinks[c] + rtext + "/" + game.id + ".jpg\r\n";
                        Application.DoEvents();
                        wc.DownloadFile(gametdb_coverlinks[c] + rtext + "/" + game.id + ".jpg", cvnam);
                        goto exfor;
                    } catch (System.Exception ex) {}
                    try {
                        duout.Text = duout.Text + "Dowloading: " + gametdb_coverlinks[c] + rtext + "/" + game.id + ".png\r\n";
                        Application.DoEvents();
                        wc.DownloadFile(gametdb_coverlinks[c] + rtext + "/" + game.id + ".png", cvnam);
                        goto exfor;
                    } catch (System.Exception ex) { }
                }
exfor:          wc.Dispose();
            }//*/

            if (System.IO.File.Exists(cvnam)) gcover.Tag = OpenBitmap(cvnam);

            cvnam = "covers/full/" + game.id + ".jpg";
            dcover(cvnam, gametdb_coverfulllinks, rtext, game.id);

            if (System.IO.File.Exists(cvnam)) otherwudpic = OpenBitmap(cvnam);

            cvnam = "covers/disc/" + game.id + ".jpg";
            dcover(cvnam, gametdb_coverdisclinks, rtext, game.id);

            cvnam = "covers/3d/" + game.id + ".jpg";
            dcover(cvnam, gametdb_cover3dlinks, rtext, game.id);

            /*if (!System.IO.File.Exists(cvnam)) {
                 System.Net.WebClient wc = new System.Net.WebClient();
                 string rtext = "US";
                 if (game.reg == wud.regcode.EUR) rtext = "EN";
                 if (game.reg == wud.regcode.JPN) rtext = "JP";
                 if (game.reg == wud.regcode.AUS) rtext = "AS";
                 for (c=0; c < gametdb_coverfulllinks.Length; c++) {
                     try {
                         duout.Text = duout.Text + "Dowloading: " + gametdb_coverlinks[c] + rtext + "/" + game.id + ".jpg\r\n";
                         Application.DoEvents();
                         wc.DownloadFile(gametdb_coverfulllinks[c] + rtext + "/" + game.id + ".jpg", cvnam);
                         goto exfor;
                     } catch (System.Exception ex) { }
                     try {
                         duout.Text = duout.Text + "Dowloading: " + gametdb_coverlinks[c] + rtext + "/" + game.id + ".png\r\n";
                         Application.DoEvents();
                         wc.DownloadFile(gametdb_coverfulllinks[c] + rtext + "/" + game.id + ".png", cvnam);
                         goto exfor;
                     } catch (System.Exception ex) { }
                 }
             exfor: wc.Dispose();
             }//*/


            if (isnew) button9_Click(button9, null);
            gamedatahaschanged(false);

            duout.Text = duout.Text + "Done!";
            Application.DoEvents();
exsub:      gcover.Refresh();
            duout.Visible = false;
            this.Cursor = Cursors.Default;
        }
Exemplo n.º 4
0
 private void button9_Click(object sender, EventArgs e) {
     wud tmp = new wud();
     tmp.id = gid.Text;
     tmp.name = gname.Text;
     tmp.key = gtkey.Text;
     tmp.keyhash = (string)gtkey.Tag;
     tmp.reg = (wud.regcode) gregion.Tag;
     tmp.desc = gdesc.Text;
     gamedatabase[(int) gid.Tag] = tmp;
     savedatabase();
     button9.Enabled = false;
 }