Exemple #1
0
		private void ChangeBzonePathClick(object sender, RoutedEventArgs e)
		{
			string path = FindBzExeDialog.GetPath();

			if(path != null && path.Length != 0)
			{
				app.DirectoryPath = path;

				RefreshMapListClick(this, e);
			}

			e.Handled = true;
		}
Exemple #2
0
        public App()
        {
            // listen for our exit event to save any changed settings
            Exit += (s, args) => BZLauncher.Properties.Settings.Default.Save();

            // listen for newly installed maps
            MapInstaller.loadMapsSignal += LoadMaps;

            bool promptForPath = true;

            // if our Settings' BzonePath string does not exist, check the registry for a BZ install location
            if (BZLauncher.Properties.Settings.Default.BzonePath == null || BZLauncher.Properties.Settings.Default.BzonePath.Length == 0)
            {
                using (RegistryKey bzkey = Registry.LocalMachine.OpenSubKey(BZ_REG_KEY))
                {
                    if (bzkey != null)
                    {
                        string installLocation = bzkey.GetValue("InstallLocation") as string;

                        if (installLocation != null && installLocation.Length != 0)
                        {
                            DirectoryPath = installLocation;

                            promptForPath = false;
                        }
                    }
                }
            }
            // otherwise, it does exist, so use it
            else
            {
                if (BZLauncher.Properties.Settings.Default.BzonePath.LastIndexOf('.') >= BZLauncher.Properties.Settings.Default.BzonePath.Length - 5)
                {
                    BZLauncher.Properties.Settings.Default.BzonePath = BZLauncher.Properties.Settings.Default.BzonePath.Substring(0, BZLauncher.Properties.Settings.Default.BzonePath.LastIndexOfAny(new char[] { '/', '\\' }));
                }

                DirectoryPath = BZLauncher.Properties.Settings.Default.BzonePath;

                promptForPath = false;
            }

            // if we didn't have a BzonePath setting, and we couldn't find a path in the registry, ask the user for a path
            if (promptForPath)
            {
                string path = FindBzExeDialog.GetPath();

                if (path == null)
                {
                    MessageBox.Show("No path selected or found, exiting.");
                    Shutdown();
                }

                DirectoryPath = path;
            }

            maps = new List <Map>();

            bzoneProcess         = new Process();
            bzoneProcess.Exited += (s, args) =>
            {
                BZLauncher.Properties.Settings.Default.TimePlayed += bzoneProcess.ExitTime - bzoneProcess.StartTime;

                int totalTime = BZLauncher.Properties.Settings.Default.TimePlayed.Days * 24 + BZLauncher.Properties.Settings.Default.TimePlayed.Hours;

                MessageBox.Show("Time played: " + totalTime + " hours", "Time Played", MessageBoxButton.OK);
            };
        }