private void initGames() { foreach (var game in GameUtils.InstalledGames) { if (game.Name != "The Sims 3") { AddGame(game.DisplayName, game.Name, game.Directory); } } if (GameUtils.UnifiedExe == null) { expansionBox.Items.Add(Translator.GetText("NoGame"), "Empty"); expansionBox.CheckBoxes = false; } if (GameUtils.IsUsingSteam) { expansionBox.Items.Add(Translator.GetText("SteamMode"), "Steam"); expansionBox.CheckBoxes = false; } if (expansionBox.Items.Count == 0) { expansionBox.Items.Add(Translator.GetText("NoExpansions"), "Empty"); expansionBox.CheckBoxes = false; } }
public static bool TryRestorePermissions() { try { RestorePermissions(); } catch (SecurityException) { if (MessageBox.Show(Translator.GetText("NeedToFixRegistryPermissions"), "Any Game Starter 3", MessageBoxButtons.YesNo) == DialogResult.No) { return(false); } Process p = new Process() { StartInfo = new ProcessStartInfo(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "FixRegistryRights.exe")) { UseShellExecute = true, Verb = "runas" } }; try { p.Start(); p.WaitForExit(); AnyGameStarter.Program.RestorePermissions(); } catch { MessageBox.Show(Translator.GetText("NeedToFixRegistryPermissionsFail"), "", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } return(true); }
private void init(StarterProfile p) { InitializeComponent(); Translator.TranslateForm(this); InitLocales(); AnyGameStarter.Program.TryRestorePermissions(); GameUtils.RedetectGames(); initGames(); nameBox.Enabled = false; niceLanguageBox.Enabled = false; languageBox.Enabled = false; locationBox.Enabled = false; _dontChangeExecutable = true; foreach (string game in p.InstalledGames) { if (expansionBox.Items.ContainsKey(game)) { expansionBox.Items[game].Checked = expansionBox.CheckBoxes; } } nameBox.Text = p.Name; executableBox.Text = p.Executable; languageBox.Text = p.Locale; Text = Translator.GetText("EditProfileDialog"); AdvancedCheck.Checked = false; }
private static string AdjustMyDocuments(string p, out string old) { var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", true); string o = (string)key.GetValue("Personal", null, RegistryValueOptions.DoNotExpandEnvironmentNames); old = o; if (o.StartsWith("%USERPROFILE%")) { return(o); } if (o.StartsWith(Environment.GetEnvironmentVariable("userprofile"))) { string newval = o.Replace(Environment.GetEnvironmentVariable("userprofile"), "%USERPROFILE%"); //key.DeleteValue("Personal"); key.SetValue("Personal", newval, RegistryValueKind.ExpandString); return(newval); } var result = MessageBox.Show(Translator.GetText("DocumentPathModified"), "Any Game Starter 3", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); if (result == DialogResult.OK) { string newval = @"%USERPROFILE%\Documents"; key.SetValue("Personal", newval, RegistryValueKind.ExpandString); return(newval); } else { throw new ArgumentException(); } }
private void button1_Click(object sender, EventArgs e) { if (expansionBox.Enabled == true) { if (!File.Exists(executableBox.Text)) { MessageBox.Show(Translator.GetText("ExecutableNotFound")); DialogResult = System.Windows.Forms.DialogResult.None; AdvancedCheck.Checked = true; return; } var games = new List <string>(); foreach (ListViewItem item in expansionBox.CheckedItems) { games.Add(item.Name); } if (locationBox.Enabled == true) { target: try { var directory = new DirectoryInfo(locationBox.Text); if (directory.Exists) { var result = MessageBox.Show(Translator.GetText("DirectoryAlreadyExists"), "Any Game Starter 3", MessageBoxButtons.AbortRetryIgnore); if (result == System.Windows.Forms.DialogResult.Retry) { goto target; } if (result == System.Windows.Forms.DialogResult.Abort) { DialogResult = System.Windows.Forms.DialogResult.None; return; } } else { directory.Create(); } } catch (Exception ex) { MessageBox.Show(ex.Message); DialogResult = System.Windows.Forms.DialogResult.None; return; } } Profile = new StarterProfile(executableBox.Text, locationBox.Text, games, nameBox.Text, languageBox.Text); Profile.Save(); Hide(); } else { GameUtils.Locale = languageBox.Text; Hide(); } }
public AboutBox() { InitializeComponent(); Translator.TranslateForm(this); var version = Assembly.GetExecutingAssembly().GetName().Version; versionInfo.Text = Translator.GetText("Version", version.Major.ToString(), version.Minor.ToString()) + "/" + (GameUtils.BaseGame == null ? "N" : GameUtils.BaseGame.Sku.ToString()) + "." + System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag ; // +"." + GameUtils.Locale; }
private void button2_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = Translator.GetText("Sims3Exe") + " (TS3*.exe)|TS3*.exe"; ofd.FileName = Path.GetFileName(executableBox.Text); try { ofd.InitialDirectory = Path.GetDirectoryName(executableBox.Text); } catch { ofd.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); } if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { executableBox.Text = ofd.FileName; } ofd.Dispose(); }
static void Main(string[] args) { //Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); //Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); bool isNew; using (var mutex = new Mutex(true, "JonhaAnyGameStarter", out isNew)) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (args.Length == 0) { if (!isNew) { MessageBox.Show(Translator.GetText("AlreadyRunning")); return; } Application.Run(new MainForm()); } else if (args.Length == 1) { if (!isNew) { MessageBox.Show(Translator.GetText("AlreadyRunning")); return; } StartGame(args[0]); } else if (args.Length == 3 && args[0] == "-restore") { if (isNew) { RestoreAfterCrash(args[1], args[2]); } } else { MessageBox.Show("Usage: AnyGameStarter.exe ProfileName", "Any Game Starter 3", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public AddProfileDialog(StarterProfile source, bool copy) : this(source) { if (source == null) { nameBox.Text = Translator.GetText("DefaultProfile") + " - " + Translator.GetText("Copy"); foreach (ListViewItem i in expansionBox.Items) { i.Checked = true; } } else { nameBox.Text = source.Name + " - " + Translator.GetText("Copy"); } nameBox.Enabled = true; niceLanguageBox.Enabled = false; languageBox.Enabled = false; locationBox.Enabled = true; Text = Translator.GetText("CopyProfileDialog"); }
private void NameBox_Validating(object sender, CancelEventArgs e) { nameBox.Text = nameBox.Text.Trim(); OKButton.Enabled = !String.IsNullOrEmpty(nameBox.Text); if (nameBox.Text.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || nameBox.Text.IndexOfAny(Path.GetInvalidPathChars()) >= 0 || nameBox.Text.IndexOfAny(new Char[] { '<', '>' }) >= 0) { MessageBox.Show(Translator.GetText("NoSpecialChars") + "\n\":,*?<>/\\"); e.Cancel = true; return; } foreach (var profile in StarterProfile.Profiles) { if (profile.Name == nameBox.Text) { MessageBox.Show(Translator.GetText("ProfileAlreadyExists")); e.Cancel = true; return; } } }
private void openFolderItem_Click(object sender, EventArgs e) { DirectoryInfo directory; if (Profiles.SelectedItems[0].Group == Profiles.Groups[1]) { directory = new DirectoryInfo(new StarterProfile(Profiles.SelectedItems[0].Text).VirtualAppDataFolder); } else { directory = new DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Electronic Arts")); } Directory.CreateDirectory(directory.FullName); retry: var d2 = FindSimsRoot(directory, 0); if (d2 != null) { directory = d2; } else { var result = MessageBox.Show(Translator.GetText("FirstRunProfile"), "Any Game Starter 3", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (result == System.Windows.Forms.DialogResult.Retry) { goto retry; } if (result == System.Windows.Forms.DialogResult.Abort) { return; } } string path = directory.FullName; Process p = new Process() { StartInfo = new ProcessStartInfo(path) }; p.Start(); p.Dispose(); }
public AddProfileDialog(bool b) { InitializeComponent(); Translator.TranslateForm(this); InitLocales(); initGames(); nameBox.Text = "Default"; locationBox.Text = ""; executableBox.Text = GameUtils.UnifiedExe; languageBox.Text = GameUtils.Locale; nameBox.Enabled = false; locationBox.Enabled = false; executableBox.Enabled = false; expansionBox.Enabled = false; foreach (ListViewItem i in expansionBox.Items) { i.Checked = expansionBox.CheckBoxes; } Text = Translator.GetText("DefaultProfileDialog"); AdvancedCheck.Checked = false; }
public void Delete() { var folder = GetAnyGameFolder(); if (MessageBox.Show(Translator.GetText("DeleteProfileConfirm", Name), "Any Game Starter 3", MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button2) == DialogResult.Yes) File.Delete(Path.Combine(folder, Name + ".profile")); else return; if (!Directory.Exists(VirtualAppDataFolder)) return; if (MessageBox.Show(Translator.GetText("DeleteProfileFolder1") + "\n" + Translator.GetText("DeleteProfileFolder2") + "\n" + VirtualAppDataFolder, "Any Game Starter 3", MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button2) == DialogResult.Yes) try { Directory.Delete(VirtualAppDataFolder, true); } catch (Exception) { try { Directory.Delete(VirtualAppDataFolder, true); } catch (Exception) { } } }
public StartGameErrorDialog(StartGameResult startGameResult) { InitializeComponent(); Translator.TranslateForm(this); switch (startGameResult) { case StartGameResult.EarlyGameExit: mainInstruction.Text = Translator.GetText("EarlyGameExitMainInstruction"); subTitle.Text = Translator.GetText("EarlyGameExitSubtitle"); instruction.Text = Translator.GetText("EarlyGameExitInstruction1") + "\n\n" + Translator.GetText("EarlyGameExitInstruction2") + "\n\n" + Translator.GetText("EarlyGameExitInstruction3"); break; case StartGameResult.Failure: mainInstruction.Text = Translator.GetText("FailureMainInstruction"); subTitle.Text = Translator.GetText("FailureSubtitle"); instruction.Text = Translator.GetText("FailureInstruction1") + "\n\n" + Translator.GetText("FailureInstruction2") + "\n\n" + Translator.GetText("FailureInstruction3"); break; case StartGameResult.PermissionsNeeded: mainInstruction.Text = Translator.GetText("PermissionsNeededMainInstruction"); subTitle.Text = Translator.GetText("PermissionsNeededSubtitle"); instruction.Text = Translator.GetText("PermissionsNeededInstruction1") + "\n\n" + Translator.GetText("PermissionsNeededInstruction2") + "\n\n" + Translator.GetText("PermissionsNeededInstruction3"); break; case StartGameResult.ProfileNotFound: mainInstruction.Text = Translator.GetText("ProfileMissingMainInstruction"); subTitle.Text = Translator.GetText("ProfileMissingSubtitle"); instruction.Text = Translator.GetText("ProfileMissingInstruction1"); break; } }
/// <summary> /// Main initialization procedure /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainForm_Load(object sender, EventArgs e) { if (GameUtils.BaseGame == null) { if (MessageBox.Show(Translator.GetText("NoSimsFound"), "Any Game Starter 3", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { Close(); Application.Exit(); return; } } //Program.TryRestorePermissions(); Translator.TranslateForm(this); if (StarterProfile.IsFirstRun()) { new AboutBox().ShowDialog(); } DefaultProfileItem = new ListViewItem(Translator.GetText("DefaultProfile")); DefaultProfileItem.SubItems.Add("All"); DefaultProfileItem.ImageIndex = 0; Profiles.Groups.Add("default", Translator.GetText("DefaultProfileSection")); Profiles.Groups.Add("anygame", Translator.GetText("AdditionalProfileSection")); ReloadProfiles(); }
private string FormatMods(long p) { return(Translator.GetText("Mods", p.ToString())); }
public static StartGameResult StartGame(string profile, bool startLauncher, bool firstStart) { if (!TryRestorePermissions()) { return(StartGameResult.PermissionsNeeded); } GameUtils.RedetectGames(); StarterProfile e = null; try { e = new StarterProfile(profile); } catch (Exception) { } if (e == null) { return(StartGameResult.ProfileNotFound); } CreateSystemRestore(); try { foreach (var game in GameUtils.InstalledGames) { if (game != GameUtils.BaseGame && !e.InstalledGames.Contains(game.Name) && game.RegistryKey != null) { RemovePermissions(game.RegistryKey); } } } catch (SecurityException) { return(StartGameResult.PermissionsNeeded); } var oldlocale = GameUtils.Locale; try { GameUtils.Locale = e.Locale; } catch (SecurityException) { return(StartGameResult.PermissionsNeeded); } string fname = e.Executable; if (startLauncher) { var games = new List <Game>(); foreach (Game game in GameUtils.InstalledGames) { if (e.InstalledGames.Contains(game.Name)) { games.Add(game); } } fname = GameUtils.UnifiedLauncherExecutable; } string oldMyDocuments; string folder; try { folder = AdjustMyDocuments(e.VirtualAppDataFolder, out oldMyDocuments); } catch (ArgumentException) { GameUtils.Locale = oldlocale; foreach (var game in GameUtils.InstalledGames) { if (game.RegistryKey != null) { RestorePermissions(game.RegistryKey); } } RemoveSystemRestore(); return(StartGameResult.Success); } folder = folder.Replace("%USERPROFILE%", e.VirtualAppDataFolder); try { Directory.CreateDirectory(folder); Process p = new Process() { StartInfo = new ProcessStartInfo(fname) { UseShellExecute = false } }; p.StartInfo.EnvironmentVariables["userprofile"] = e.VirtualAppDataFolder; p.StartInfo.WorkingDirectory = Path.GetDirectoryName(fname); p.Start(); try { p.WaitForInputIdle(); if (p.MainWindowTitle == "" || startLauncher) { if (firstStart && !startLauncher) { p.Kill(); } else { p.WaitForExit(); } p.Close(); return(StartGameResult.Success); } else { p.WaitForExit(); p.Close(); return(StartGameResult.EarlyGameExit); } } catch (Exception) { p.Close(); return(StartGameResult.Success); } } catch (Exception ex) { MessageBox.Show(ex.Message, Translator.GetText("StartGameErrorDialog"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(StartGameResult.Failure); } finally { try { AdjustMyDocuments(oldMyDocuments); } finally { GameUtils.Locale = oldlocale; foreach (var game in GameUtils.InstalledGames) { if (game.RegistryKey != null) { RestorePermissions(game.RegistryKey); } } RemoveSystemRestore(); } } }
public static string T(string o) { return(Translator.GetText(o)); }