Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (silentStart)
            {
                WindowState = WindowState.Minimized;
            }
            using (var wc = new WebClient())
            {
                try
                {
                    ChangelogContent.Text = wc.DownloadString("http://167.114.156.21/update_server/changelog.data");
                }
                catch
                {
                    ChangelogContent.Text = "You are offline. No changelog available.";
                }
            }

            if (!Directory.Exists("mods/medals"))
                Directory.CreateDirectory("mods/medals");

            try
            {
                Initial(false);
            }
            catch
            {
                Initial(true);
            }

            try
            {
                settingsJson = JObject.Parse(File.ReadAllText("dewrito.json"));
                if (settingsJson["gameFiles"] == null || settingsJson["updateServiceUrl"] == null)
                {
                    lblVersion.Text = "Error";
                    AppendDebugLine("Error reading dewrito.json: gameFiles or updateServiceUrl is missing.",
                        Color.FromRgb(255, 0, 0));
                    SetButtonText("ERROR", true);

                    var AlertWindow = new MsgBoxOk("Could not read the dewrito.json updater configuration.");
                    AlertWindow.Show();
                    AlertWindow.Focus();
                    return;
                }
            }
            catch
            {
                AppendDebugLine("Failed to read dewrito.json updater configuration.", Color.FromRgb(255, 0, 0));
                SetButtonText("ERROR", true);

                var AlertWindow = new MsgBoxOk("Could not read the dewrito.json updater configuration.");
                AlertWindow.Show();
                AlertWindow.Focus();
                return;
            }

            var fade = (Storyboard)TryFindResource("fade");
            fade.Begin(); // Start animation

            // CreateHashJson();
            validateThread = new Thread(BackgroundThread);
            validateThread.Start();
        }
Ejemplo n.º 3
0
        private void BackgroundThread()
        {
            if (!CompareHashesWithJson())
            {
                return;
            }

            AppendDebugLine("Game files validated, contacting update server...", Color.FromRgb(255, 255, 255));

            if (!ProcessUpdateData())
            {
                var confirm = false;

                AppendDebugLine(
                    "Failed to retrieve update information from set update server: " + settingsJson["updateServiceUrl"],
                    Color.FromRgb(255, 0, 0));

                if (settingsJson["updateServiceUrl"].ToString() != "http://167.114.156.21/update_server/update.json" ||
                    settingsJson["updateServiceUrl"].ToString() !=
                    "http://167.114.156.21/update_server/update_publicbeta.json")
                {
                    AppendDebugLine("Set update server is not default server...", Color.FromRgb(255, 255, 255));
                    AppendDebugLine("Attempting to contact the default update server...", Color.FromRgb(255, 255, 255));

                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        var confirmWindow =
                            new MsgBoxConfirm(
                                "Failed to retrieve update information. Do you want to try updating from GitHub?");
                        var ConfirmWindow =
                            new MsgBoxConfirm(
                                "Failed to retrieve update information. Do you want to try updating from GitHub?");

                        if (ConfirmWindow.ShowDialog() == false)
                        {
                            if (ConfirmWindow.confirm)
                            {
                                settingsJson["updateServiceUrl"] = "https://raw.githubusercontent.com/Woovie/dorito-master-update-json/master/update.json";

                                if (!ProcessUpdateData())
                                {
                                    AppendDebugLine("Failed to connect to GitHub.",
                                        Color.FromRgb(255, 0, 0));
                                    btnAction.Content = "PLAY GAME";
                                    GridSkip.Visibility = Visibility.Hidden;
                                    isPlayEnabled = true;
                                    btnAction.IsEnabled = true;

                                    var MainWindow =
                                        new MsgBoxOk(
                                            "Failed to connect to GitHub, you can still play the game if your files are valid.");
                                    MainWindow.Show();
                                    MainWindow.Focus();
                                    var AlertWindow =
                                        new MsgBoxOk(
                                            "Failed to connect to GitHub, you can still play the game if your files are valid.");
                                    AlertWindow.Show();
                                    AlertWindow.Focus();
                                }
                                else
                                {
                                    confirm = true;
                                }
                            }
                            else
                            {
                                AppendDebugLine("GitHub connection manually canceled.", Color.FromRgb(255, 0, 0));
                                btnAction.Content = "PLAY GAME";
                                GridSkip.Visibility = Visibility.Hidden;
                                isPlayEnabled = true;
                                btnAction.IsEnabled = true;

                                var MainWindow =
                                    new MsgBoxOk(
                                        "GitHub connection manually canceled, you can still play the game if your files are valid.");
                                MainWindow.Show();
                                MainWindow.Focus();
                                var AlertWindow =
                                    new MsgBoxOk(
                                        "GitHub connection manually canceled, you can still play the game if your files are valid.");
                                AlertWindow.Show();
                                AlertWindow.Focus();
                            }
                        }
                    });
                }
                else
                {
                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        AppendDebugLine("Failed to retrieve update information from GitHub.",
                            Color.FromRgb(255, 0, 0));
                        btnAction.Content = "PLAY";
                        isPlayEnabled = true;
                        btnAction.IsEnabled = true;

                        var MainWindow =
                            new MsgBoxOk(
                                "Could not connect to GitHub, you can still play the game if your files are valid.");
                        MainWindow.Show();
                        MainWindow.Focus();
                        var AlertWindow =
                            new MsgBoxOk(
                                "Could not connect to GitHub, you can still play the game if your files are valid.");
                        AlertWindow.Show();
                        AlertWindow.Focus();
                    });
                }

                if (!confirm)
                {
                    return;
                }
            }

            if (filesToDownload.Count <= 0)
            {
                AppendDebugLine("You have the latest version! (" + latestUpdateVersion + ")", Color.FromRgb(0, 255, 0));

                btnAction.Dispatcher.Invoke(
                    new Action(
                        () =>
                        {
                            btnAction.Content = "PLAY GAME";
                            GridSkip.Visibility = Visibility.Hidden;
                            isPlayEnabled = true;

                            var fade = (Storyboard) TryFindResource("fade");
                            fade.Stop(); // Start animation
                            btnAction.IsEnabled = true;
                        }));

                if (silentStart)
                {
                    btnAction_Click(new object(), new RoutedEventArgs());
                }
                return;
            }

            AppendDebugLine("An update is available. (" + latestUpdateVersion + ")", Color.FromRgb(255, 255, 0));

            btnAction.Dispatcher.Invoke(
                new Action(
                    () =>
                    {
                        btnAction.Content = "UPDATE";

                        var fade = (Storyboard) TryFindResource("fade");
                        fade.Stop(); // Stop
                        btnAction.IsEnabled = true;
                        GridSkip.Visibility = Visibility.Visible;
                    }));
            if (silentStart)
            {
                //MessageBox.Show("Sorry, you need to update before the game can be started silently.", "ElDewrito Launcher");
                var AlertWindow = new MsgBoxOk("Sorry, you need to update before the game can be started silently.");

                AlertWindow.Show();
                AlertWindow.Focus();
            }
        }
Ejemplo n.º 4
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));
            }
        }