private void Main_Shown(object sender, EventArgs e) { if (!(File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Reditec\\RDR Explorer\\KnownFilenames.txt"))) { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("appdTXT"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("nfTXT"), MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } statusProgress.ProgressBar.Value = 0; if (!(settingsIni.KeyExists("FirstLaunch"))) { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("thks") + Environment.NewLine + RDR_Explorer.Properties.Resources.ResourceManager.GetString("wip") + Environment.NewLine + RDR_Explorer.Properties.Resources.ResourceManager.GetString("gtaf") + Environment.NewLine + RDR_Explorer.Properties.Resources.ResourceManager.GetString("rptbg"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("welc"), MessageBoxButtons.OK, MessageBoxIcon.Information); settingsIni.Write("FirstLaunch", "true"); } if (!(settingsIni.KeyExists("GamePath"))) { CheckExeFile(); //settingsIni.Write("FirstLaunch", "true"); } else { if (Directory.Exists(settingsIni.Read("GamePath"))) { if (Directory.GetFiles(settingsIni.Read("GamePath"), "default.xex", SearchOption.TopDirectoryOnly).Length > 0) { gameEXE = settingsIni.Read("GamePath") + "\\default.xex"; RageLib.Common.KeyStore.gameEXE = gameEXE; RageLib.Common.KeyUtil.MYgameExe = gameEXE; KeyUtil keyUtil = new KeyUtilRDR(); if (File.Exists("xextool.exe")) { key = keyUtil.FindKey(gameEXE, "RDR"); RPFLib.Common.DataUtil.setKey(key); if (!(key == null)) { settingsIni.Write("GamePath", settingsIni.Read("GamePath")); } else { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("UnsuppXEX") + Environment.NewLine + RDR_Explorer.Properties.Resources.ResourceManager.GetString("adminFIX"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("UnsuppEX"), MessageBoxButtons.OK, MessageBoxIcon.Error); CheckExeFile(); } } else { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("xextDEL"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("xextNF")); Application.Exit(); } } else { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("sfNF") + Environment.NewLine + RDR_Explorer.Properties.Resources.ResourceManager.GetString("xexSPEC"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("sfNFtitle"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("xexNF") + Environment.NewLine + RDR_Explorer.Properties.Resources.ResourceManager.GetString("xexSPEC"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("xexNFtitle"), MessageBoxButtons.OK, MessageBoxIcon.Error); CheckExeFile(); } } if (settingsIni.Read("GamePath") != "") { statusProgress.ProgressBar.Value = 100; statusLabel.Text = RDR_Explorer.Properties.Resources.ResourceManager.GetString("keyF"); gameDir = settingsIni.Read("GamePath"); DirectoryInfo root = new DirectoryInfo(gameDir); PrepareList(); if (Directory.Exists(gameDir)) { try { DirectoryInfo[] directories = root.GetDirectories(); if (directories.Length > 0) { foreach (DirectoryInfo directory in directories) { treeView1.Nodes[0].Nodes.Add(directory.Name, directory.Name, 0, 0); } } } catch (Exception ex) { MessageBox.Show(ex.Message, RDR_Explorer.Properties.Resources.ResourceManager.GetString("err"), MessageBoxButtons.OK, MessageBoxIcon.Error); } treeView1.Nodes[0].Expand(); } } else { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("adminREQ"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("accDEN"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CheckExeFile() { do { openFolder.Description = RDR_Explorer.Properties.Resources.ResourceManager.GetString("selDir") + " " + "default.xex."; DialogResult dr = openFolder.ShowDialog(); if (dr == DialogResult.OK) { if(Directory.Exists(openFolder.SelectedPath.ToString())) { if (Directory.GetFiles(openFolder.SelectedPath.ToString(), "default.xex", SearchOption.TopDirectoryOnly).Length > 0) { gameEXE = openFolder.SelectedPath + "\\default.xex"; RageLib.Common.KeyStore.gameEXE = gameEXE; RageLib.Common.KeyUtil.MYgameExe = gameEXE; KeyUtil keyUtil = new KeyUtilRDR(); if(File.Exists("xextool.exe")) { byte[] key = keyUtil.FindKey(gameEXE, "RDR"); RPFLib.Common.DataUtil.setKey(key); if (!(key == null)) { settingsIni.Write("GamePath", openFolder.SelectedPath); } else { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("UnsuppXEX") + Environment.NewLine + RDR_Explorer.Properties.Resources.ResourceManager.GetString("adminFIX"), Environment.NewLine + RDR_Explorer.Properties.Resources.ResourceManager.GetString("UnsuppEX"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("xextDEL"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("xextNF"), MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } else { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("xexNF") + Environment.NewLine + RDR_Explorer.Properties.Resources.ResourceManager.GetString("xexSPEC"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("xexNFtitle"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("sfNF") + Environment.NewLine + RDR_Explorer.Properties.Resources.ResourceManager.GetString("xexSPEC"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("sfNFtitle"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { openFolder.SelectedPath = ""; break; } } while (!(settingsIni.KeyExists("GamePath"))); if (openFolder.SelectedPath == "") { Application.Exit(); return; } }