Esempio n. 1
0
		private void Action_OnClick(object sender, RoutedEventArgs e)
		{
			var startInfo = new ProcessStartInfo
			{
				FileName = "eldorado.exe",
				Arguments = "-launcher"
			};

			if (BtnAction.Content.Equals("Play Game"))
			{
				try
				{
					Process.Start(startInfo);
				}
				catch
				{
					Dispatcher.Invoke(() =>
					{
						AppendDebugLine("Cannot locate eldorado.exe. Are you running in the right location?",
				Color.FromRgb(255, 0, 0));
						if (Cfg.LauncherConfigFile.ContainsKey("Launcher.AutoDebug") && Cfg.LauncherConfigFile["Launcher.AutoDebug"] == "0")
						{
							FlyoutHandler(FlyoutDebug);
						}
					});
				}

				if (Cfg.LauncherConfigFile["Launcher.Random"] == "1")
				{
					RandomArmor();
				}
				if (Cfg.LauncherConfigFile["Launcher.Close"] == "1")
				{
					Application.Current.Shutdown();
				}
			}
			else if (BtnAction.Content.Equals("Update"))
			{
				foreach (var file in _filesToDownload)
				{
					AppendDebugLine("Downloading file \"" + file + "\"...", Color.FromRgb(255, 255, 0));
					var url = "http://eldewrito.anvilonline.net/" + _eldoritoLatestVersion + "/" + file;
					var destPath = Path.Combine(BasePath, file);
					var dialog = new FileDownloadDialog(this, url, destPath);
					//var result = dialog.ShowDialog();
					//Update(destPath, url, file);

					AppendDebugLine("Download for file \"" + file + "\" failed.", Color.FromRgb(255, 0, 0));
					AppendDebugLine("Error: " + dialog.Error.Message, Color.FromRgb(255, 0, 0));
					Dispatcher.Invoke(() =>
					{
						BtnAction.Content = "Error";
						BtnSkip.Content = "Ignore";
						if (Cfg.LauncherConfigFile.ContainsKey("Launcher.AutoDebug") && Cfg.LauncherConfigFile["Launcher.AutoDebug"] == "0")
						{
							FlyoutHandler(FlyoutDebug);
						}
					});

					if (dialog.Error.InnerException != null)
						AppendDebugLine("Error: " + dialog.Error.InnerException.Message, Color.FromRgb(255, 0, 0));
					return;
				}

				if (_filesToDownload.Contains("DewritoUpdater.exe"))
				{
					var restartWindow = new MsgBoxRestart("Update complete! Please restart the launcher.");

					restartWindow.Show();
					restartWindow.Focus();
				}
				BtnAction.Content = "Play Game";
				BtnSkip.Visibility = Visibility.Hidden;
				AppendDebugLine("Update successful. You have the latest version! (" + _latestUpdateVersion + ")",
				  Color.FromRgb(0, 255, 0));
				LblVersion.Content = "Your Version: " + _eldoritoLatestVersion + "    Latest Version: " + _eldoritoLatestVersion;
			}
		}
        private void btnAction_Click(object sender, RoutedEventArgs e)
        {
            if (isPlayEnabled)
            {
                var sInfo = new ProcessStartInfo(BasePath + "/eldorado.exe");
                sInfo.Arguments = "-launcher";

                if (configFile["Video.Window"] == "1")
                {
                    sInfo.Arguments += " -window";
                }
                if (configFile["Video.FullScreen"] == "1")
                {
                    sInfo.Arguments += " -fullscreen";
                }
                if (configFile["Video.VSync"] == "1")
                {
                    sInfo.Arguments += " -no_vsync";
                }
                if (configFile["Video.FPSCounter"] == "1")
                {
                    sInfo.Arguments += " -show_fps";
                }

                sInfo.Arguments += " -width " + configFile["Video.Width"];
                sInfo.Arguments += " -height " + configFile["Video.Height"];

                if (!Directory.Exists("bink_disabled") || !Directory.Exists("bink"))
                {
                    AppendDebugLine(
                        "Your bink directory could not be found. Did you change the name manually or delete it?",
                        Color.FromRgb(255, 255, 0));
                }

                try
                {
                    Process.Start(sInfo);
                }
                catch
                {
                    //MessageBox.Show("Game executable not found.");
                    var AlertWindow = new MsgBoxOk("Game executable not found.");

                    AlertWindow.Show();
                    AlertWindow.Focus();
                }
            }
            else if (btnAction.Content.ToString() == "UPDATE")
            {
                foreach (var file in filesToDownload)
                {
                    AppendDebugLine("Downloading file \"" + file + "\"...", Color.FromRgb(255, 255, 0));
                    var url = latestUpdate["baseUrl"].ToString().Replace("\"", "") + file;
                    var destPath = Path.Combine(BasePath, file);
                    var dialog = new FileDownloadDialog(this, url, destPath);
                    var result = dialog.ShowDialog();
                    if (result.HasValue && result.Value)
                    {
                        // TOD: Refactor this. It's hacky
                    }
                    else
                    {
                        AppendDebugLine("Download for file \"" + file + "\" failed.", Color.FromRgb(255, 0, 0));
                        AppendDebugLine("Error: " + dialog.Error.Message, Color.FromRgb(255, 0, 0), false);
                        SetButtonText("Error", true);
                        if (dialog.Error.InnerException != null)
                            AppendDebugLine("Error: " + dialog.Error.InnerException.Message, Color.FromRgb(255, 0, 0),
                                false);
                        return;
                    }
                }

                if (filesToDownload.Contains("DewritoUpdater.exe"))
                {
                    //MessageBox.Show("Update complete! Please restart the launcher.", "ElDewrito Launcher");
                    //Application.Current.Shutdown();
                    var RestartWindow = new MsgBoxRestart("Update complete! Please restart the launcher.");

                    RestartWindow.Show();
                    RestartWindow.Focus();
                }

                btnAction.Content = "PLAY GAME";
                isPlayEnabled = true;
                GridSkip.Visibility = Visibility.Hidden;
                //imgAction.Source = new BitmapImage(new Uri(@"/Resourves/playEnabled.png", UriKind.Relative));
                AppendDebugLine("Update successful. You have the latest version! (" + latestUpdateVersion + ")",
                    Color.FromRgb(0, 255, 0));
            }
        }
        private void btnAction_Click(object sender, RoutedEventArgs e)
        {
            if (isPlayEnabled)
            {
                ProcessStartInfo sInfo = new ProcessStartInfo(BasePath + "/eldorado.exe");
                sInfo.Arguments = "-launcher";

                Process process = new Process();
                process.StartInfo = sInfo;

                if (!process.Start())
                {
                    SetVariable("Video.Window", "0", ref configFile);
                    SetVariable("Video.FullScreen", "1", ref configFile);
                    SetVariable("Video.VSync", "1", ref configFile);
                    SetVariable("Video.FPSCounter", "0", ref configFile);
                    SaveConfigFile("dewrito_prefs.cfg", configFile);

                    var AlertWindow = new MsgBoxOk("Your game crashed. Your launch settings have been reset please try again");

                    AlertWindow.Show();
                    AlertWindow.Focus();
                }

                if (configFile["Video.Window"] == "1")
                {
                    sInfo.Arguments += " -window";
                }
                if (configFile["Video.FullScreen"] == "1")
                {
                    sInfo.Arguments += " -fullscreen";
                }
                if (configFile["Video.VSync"] == "1")
                {
                    sInfo.Arguments += " -no_vsync";
                }
                if (configFile["Video.FPSCounter"] == "1")
                {
                    sInfo.Arguments += " -show_fps";
                }
            }
            else if (btnAction.Content.ToString() == "UPDATE")
            {
                foreach (var file in filesToDownload)
                {
                    AppendDebugLine("Downloading file \"" + file + "\"...", Color.FromRgb(255, 255, 0));
                    var url = latestUpdate["baseUrl"].ToString().Replace("\"", "") + file;
                    var destPath = Path.Combine(BasePath, file);
                    var dialog = new FileDownloadDialog(this, url, destPath);
                    var result = dialog.ShowDialog();
                    if (result.HasValue && result.Value)
                    {
                        // TOD: Refactor this. It's hacky
                    }
                    else
                    {
                        AppendDebugLine("Download for file \"" + file + "\" failed.", Color.FromRgb(255, 0, 0));
                        AppendDebugLine("Error: " + dialog.Error.Message, Color.FromRgb(255, 0, 0), false);
                        SetButtonText("Error", true);
                        if (dialog.Error.InnerException != null)
                            AppendDebugLine("Error: " + dialog.Error.InnerException.Message, Color.FromRgb(255, 0, 0),
                                false);
                        return;
                    }
                }

                if (filesToDownload.Contains("DewritoUpdater.exe"))
                {
                    //MessageBox.Show("Update complete! Please restart the launcher.", "ElDewrito Launcher");
                    //Application.Current.Shutdown();
                    var RestartWindow = new MsgBoxRestart("Update complete! Please restart the launcher.");

                    RestartWindow.Show();
                    RestartWindow.Focus();
                }

                btnAction.Content = "PLAY GAME";
                isPlayEnabled = true;
                GridSkip.Visibility = Visibility.Hidden;
                //imgAction.Source = new BitmapImage(new Uri(@"/Resourves/playEnabled.png", UriKind.Relative));
                AppendDebugLine("Update successful. You have the latest version! (" + latestUpdateVersion + ")",
                    Color.FromRgb(0, 255, 0));
            }
        }