private void addFilesToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog OFD = new OpenFileDialog(); OFD.Multiselect = true; if (OFD.ShowDialog() != DialogResult.OK) { return; } menuStrip1.Enabled = buttonX1.Enabled = buttonX2.Enabled = listView1.Enabled = false; List <ListViewItem> xItems = new List <ListViewItem>(); progressBarX1.Value = 0; progressBarX1.Maximum = OFD.FileNames.Length; textBoxX1.Text = "Status: Reading files..."; textBoxX1.Refresh(); foreach (string x in OFD.FileNames) { GameGPD z = null; try { z = new GameGPD(x, ProfileTools.GPDNameToID(Path.GetFileName(x))); ListViewItem u = new ListViewItem(z.GetStringByID((long)GPDIDs.ThisTitle)); if (u.SubItems[0].Text == null || u.SubItems[0].Text == "") { z.Close(); continue; } u.SubItems.Add(z.TitleID.ToString("X2")); u.SubItems.Add(x); z.Close(); xItems.Add(u); } catch { if (z != null) { z.Close(); } } progressBarX1.Value++; Application.DoEvents(); } listView1.Items.AddRange(xItems.ToArray()); textBoxX1.Text = "Status: Idle..."; menuStrip1.Enabled = buttonX1.Enabled = buttonX2.Enabled = listView1.Enabled = true; }
private void addFilesToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog OFD = new OpenFileDialog(); OFD.Multiselect = true; if (OFD.ShowDialog() != DialogResult.OK) return; menuStrip1.Enabled = buttonX1.Enabled = buttonX2.Enabled = listView1.Enabled = false; List<ListViewItem> xItems = new List<ListViewItem>(); progressBarX1.Value = 0; progressBarX1.Maximum = OFD.FileNames.Length; textBoxX1.Text = "Status: Reading files..."; textBoxX1.Refresh(); foreach (string x in OFD.FileNames) { GameGPD z = null; try { z = new GameGPD(x, ProfileTools.GPDNameToID(Path.GetFileName(x))); ListViewItem u = new ListViewItem(z.GetStringByID((long)GPDIDs.ThisTitle)); if (u.SubItems[0].Text == null || u.SubItems[0].Text == "") { z.Close(); continue; } u.SubItems.Add(z.TitleID.ToString("X2")); u.SubItems.Add(x); z.Close(); xItems.Add(u); } catch { if (z != null) z.Close(); } progressBarX1.Value++; Application.DoEvents(); } listView1.Items.AddRange(xItems.ToArray()); textBoxX1.Text = "Status: Idle..."; menuStrip1.Enabled = buttonX1.Enabled = buttonX2.Enabled = listView1.Enabled = true; }
/// <summary> /// Adds a game via the GPD /// </summary> /// <param name="xTitle"></param> /// <returns></returns> public bool AddGameViaGPD(GameGPD xTitle) { if (!ParseCheck()) return false; if (xTitle.TitleID == 0 || xTitle.TitleID == 0xFFFE07D1 || // Dash xTitle.TitleID == 0xFFFE07DE) // Avatar? return (xActive = false); foreach (TitlePlayedEntry x in xTitlesPlayed) { if (xTitle.TitleID != x.TitleID) continue; xActive = false; throw GPDExcepts.HasID; } try { string xName = xTitle.GetStringByID((long)GPDIDs.ThisTitle); if (xName == null) { xActive = false; throw GPDExcepts.NameError; } if (!xTitle.xErase()) return (xActive = false); int xsize = 0x28 + ((xName.Length + 1) * 2); int xPosition = AllocateData(xsize); if (xPosition == -1) return (xActive = false); XDBFEntry xEnt = new XDBFEntry(NameSpace.Title, xTitle.TitleID, xPosition, xsize, this); xIO.Position = xPosition + HeaderSize; xIO.Write(xTitle.TitleID); xIO.Write((uint)xTitle.xAchievements.Count); xIO.Write(xTitle.xCalcUT()); xIO.Write(xTitle.xCalcGSP()); xIO.Write(xTitle.xCalcGST()); xIO.Write(new byte[0x14]); xIO.Write(xName, StringForm.Unicode); xIO.Write((short)0); xIO.Flush(); TitlePlayedEntry z = new TitlePlayedEntry(xEnt); if (!z.LoadDetails()) return (xActive = false); xTitlesPlayed.Add(z); Setting x = xGetSetting(GPDIDs.GCardTitlesPlayed, SettingType.UInt32); if (x == null) xAddSetting((long)GPDIDs.GCardTitlesPlayed, xTitlesPlayed.Count, true, SyncType.Locale); else { uint xdata = (uint)x.Data; xdata++; x.Data = xdata; x.xUpdate(SyncType.Locale); } UpdateSync(NameSpace.Title, xTitle.TitleID, SyncType.Server); return (UpdateHeader() & !(xActive = false)); } catch { return (xActive = false); } }
private void listBox3_SelectedIndexChanged(object sender, EventArgs e) { if (listBox3.SelectedIndex < 0) return; tabControl1.Enabled = false; buttonX12.Enabled = true; TitlePlayedEntry x = xprof.UserGPD.TitlesPlayed[listBox3.SelectedIndex]; try { dateTimePicker3.Value = dateTimePicker4.Value = x.LastLoadedDT; } catch { dateTimePicker3.Value = dateTimePicker4.Value = DateTime.Now; } textBoxX14.Text = "Unlocked " + x.EarnedCount.ToString() + " of " + x.PossibleCount.ToString(); textBoxX14.Text += Environment.NewLine + "Total of " + x.EarnedWorth.ToString() + " of " + x.PossibleWorth.ToString(); string path = x.TitleID.ToString("X").ToUpper() + ".gpd"; FileEntry xent = xPackage.GetFile(path); if (xent == null) { Log("Error: could not find GPD"); killachievetab(); tabControl1.Enabled = true; return; } string xOut = VariousFunctions.GetTempFileLocale(); if (!xent.Extract(xOut)) { Log("Extraction error"); killachievetab(); tabControl1.Enabled = true; return; } GameGPD xload = new GameGPD(xOut, x.TitleID); if (!xload.IsValid) { Log("Error when parsing GPD"); xload.Close(); try { VariousFunctions.DeleteFile(xOut); } catch { } xload = null; killachievetab(); tabControl1.Enabled = true; return; } listBox2.Items.Clear(); for (int i = 0; i < xload.Achievements.Length; i++) listBox2.Items.Add(xload.Achievements[i].Title); Image xTitleIMGS = xload.GetImageByID(0x8000); if (xTitleIMGS != null) pictureBox4.Image = xTitleIMGS; else pictureBox4.Image = PublicResources.NoImage; string xTitleStrings = xload.GetStringByID(0x8000); if (xTitleStrings != null) textBoxX4.Text = xTitleStrings; else textBoxX4.Text = "Unknown"; xLoadedGPD = xload; xLoadedEntry = xent; if (listBox2.Items.Count > 0) listBox2.SelectedIndex = 0; listBox2_SelectedIndexChanged(null, null); buttonX11.Enabled = buttonX3.Enabled = buttonX10.Enabled = tabControl1.Enabled = buttonX6.Enabled = tabControlPanel10.Enabled = true; Log("GPD Loaded"); }
private void listBox3_SelectedIndexChanged(object sender, EventArgs e) { if (listBox3.SelectedIndex < 0) { return; } tabControl1.Enabled = false; buttonX12.Enabled = true; TitlePlayedEntry x = xprof.UserGPD.TitlesPlayed[listBox3.SelectedIndex]; try { dateTimePicker3.Value = dateTimePicker4.Value = x.LastLoadedDT; } catch { dateTimePicker3.Value = dateTimePicker4.Value = DateTime.Now; } textBoxX14.Text = "Unlocked " + x.EarnedCount.ToString() + " of " + x.PossibleCount.ToString(); textBoxX14.Text += Environment.NewLine + "Total of " + x.EarnedWorth.ToString() + " of " + x.PossibleWorth.ToString(); string path = x.TitleID.ToString("X").ToUpper() + ".gpd"; FileEntry xent = xPackage.GetFile(path); if (xent == null) { Log("Error: could not find GPD"); killachievetab(); tabControl1.Enabled = true; return; } string xOut = VariousFunctions.GetTempFileLocale(); if (!xent.Extract(xOut)) { Log("Extraction error"); killachievetab(); tabControl1.Enabled = true; return; } GameGPD xload = new GameGPD(xOut, x.TitleID); if (!xload.IsValid) { Log("Error when parsing GPD"); xload.Close(); try { VariousFunctions.DeleteFile(xOut); } catch { } xload = null; killachievetab(); tabControl1.Enabled = true; return; } listBox2.Items.Clear(); for (int i = 0; i < xload.Achievements.Length; i++) { listBox2.Items.Add(xload.Achievements[i].Title); } Image xTitleIMGS = xload.GetImageByID(0x8000); if (xTitleIMGS != null) { pictureBox4.Image = xTitleIMGS; } else { pictureBox4.Image = PublicResources.NoImage; } string xTitleStrings = xload.GetStringByID(0x8000); if (xTitleStrings != null) { textBoxX4.Text = xTitleStrings; } else { textBoxX4.Text = "Unknown"; } xLoadedGPD = xload; xLoadedEntry = xent; if (listBox2.Items.Count > 0) { listBox2.SelectedIndex = 0; } listBox2_SelectedIndexChanged(null, null); buttonX11.Enabled = buttonX3.Enabled = buttonX10.Enabled = tabControl1.Enabled = buttonX6.Enabled = tabControlPanel10.Enabled = true; Log("GPD Loaded"); }
void set(GameGPD xin) { xgame = xin; for (int i = 0; i < xin.Achievements.Length; i++) listBox2.Items.Add(xin.Achievements[i].Title); if (listBox2.Items.Count > 0) listBox2.SelectedIndex = 0; Image xTitleIMGS = xin.GetImageByID(0x8000); if (xTitleIMGS != null) pictureBox4.Image = xTitleIMGS; else pictureBox4.Image = PublicResources.NoImage; string xTitleStrings = xin.GetStringByID(0x8000); if (xTitleStrings != null) textBoxX4.Text = xTitleStrings; else textBoxX4.Text = "Unknown"; for (int i = 0; i < xin.SyncRecords.Length; i++) listBox1.Items.Add(i); for (int i = 0; i < xin.IndexRecords.Length; i++) listBox3.Items.Add(i); foreach (Setting x in xin.UserSettings) { ListViewItem y = new ListViewItem(x.ID.ToString("X")); y.SubItems.Add(((GPDIDs)x.ID).ToString()); listView2.Items.Add(y); } foreach (ImageEntry x in xin.Images) listBox4.Items.Add(x.ID); if (listBox4.Items.Count > 0) listBox4.SelectedIndex = 0; if (listView2.Items.Count > 0) listView2.Items[0].Selected = true; //Setting x1 = xin.GetSettingByType(GPDIDs.GCardPictureKey); //Setting x2 = xin.GetSettingByType(GPDIDs.GCardPersonalPicture); //x1.Data = x2.Data; //x1.Update(true); }
void set(GameGPD xin) { xgame = xin; for (int i = 0; i < xin.Achievements.Length; i++) { listBox2.Items.Add(xin.Achievements[i].Title); } if (listBox2.Items.Count > 0) { listBox2.SelectedIndex = 0; } Image xTitleIMGS = xin.GetImageByID(0x8000); if (xTitleIMGS != null) { pictureBox4.Image = xTitleIMGS; } else { pictureBox4.Image = PublicResources.NoImage; } string xTitleStrings = xin.GetStringByID(0x8000); if (xTitleStrings != null) { textBoxX4.Text = xTitleStrings; } else { textBoxX4.Text = "Unknown"; } for (int i = 0; i < xin.SyncRecords.Length; i++) { listBox1.Items.Add(i); } for (int i = 0; i < xin.IndexRecords.Length; i++) { listBox3.Items.Add(i); } foreach (Setting x in xin.UserSettings) { ListViewItem y = new ListViewItem(x.ID.ToString("X")); y.SubItems.Add(((GPDIDs)x.ID).ToString()); listView2.Items.Add(y); } foreach (ImageEntry x in xin.Images) { listBox4.Items.Add(x.ID); } if (listBox4.Items.Count > 0) { listBox4.SelectedIndex = 0; } if (listView2.Items.Count > 0) { listView2.Items[0].Selected = true; } //Setting x1 = xin.GetSettingByType(GPDIDs.GCardPictureKey); //Setting x2 = xin.GetSettingByType(GPDIDs.GCardPersonalPicture); //x1.Data = x2.Data; //x1.Update(true); }