Exemplo n.º 1
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:81/honline/changelog.data");
                }
                catch
                {
                    ChangelogContent.Text = "You are offline. No changelog available.";
                }
            }

            LoadSettings();
            SaveSettings();

            try
            {
                settingsJson = JObject.Parse(File.ReadAllText("dewrito.json"));

                if (settingsJson["gameFiles"] == null || settingsJson["updateServiceUrl"] == null)
                {
                    SetStatus("Failed to read Dewrito updater configuration.", Color.FromRgb(255, 0, 0));
                    SetStatusLabels("Error", true);

                    return;
                }
            }
            catch
            {
                SetStatus("Failed to read Dewrito updater configuration.", Color.FromRgb(255, 0, 0));
                btnAction.Content = "PLAY";

                var MainWindow =
                    new MsgBox2(
                        "Could not connect to update servers. You can still play, but game files can not be updated or verified against the latest versions.");
                isPlayEnabled       = true;
                btnAction.IsEnabled = true;

                MainWindow.Show();
                MainWindow.Focus();
                return;
            }

            // CreateHashJson();
            validateThread = new Thread(BackgroundThread);
            validateThread.Start();
        }
Exemplo n.º 2
0
        private void btnAction_Click(object sender, RoutedEventArgs e)
        {
            if (isPlayEnabled)
            {
                var sInfo = new ProcessStartInfo(BasePath + "/eldorado.exe");
                sInfo.Arguments = "-launcher";
                try
                {
                    Process.Start(sInfo);
                }
                catch
                {
                    //MessageBox.Show("Game executable not found.");
                    var MainWindow = new MsgBox2("Game executable not found.");

                    MainWindow.Show();
                    MainWindow.Focus();
                }
            }
            else if (btnAction.Content == "UPDATE")
            {
                foreach (var file in filesToDownload)
                {
                    SetStatus("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
                    {
                        SetStatus("Download for file \"" + file + "\" failed.", Color.FromRgb(255, 0, 0));
                        SetStatus("Error: " + dialog.Error.Message, Color.FromRgb(255, 0, 0), false);
                        if (dialog.Error.InnerException != null)
                        {
                            SetStatus("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 MainWindow = new MsgBox("Update complete! Please restart the launcher.");

                    MainWindow.Show();
                    MainWindow.Focus();
                }

                btnAction.Content = "PLAY GAME";
                isPlayEnabled     = true;
                //imgAction.Source = new BitmapImage(new Uri(@"/Resourves/playEnabled.png", UriKind.Relative));
                SetStatus("Update successful. You have the latest version! (" + latestUpdateVersion + ")",
                          Color.FromRgb(0, 255, 0));
            }
        }
Exemplo n.º 3
0
        private void BackgroundThread()
        {
            if (!CompareHashesWithJson())
            {
                return;
            }

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

            if (!ProcessUpdateData())
            {
                SetStatus("Failed to retrieve update information.", Color.FromRgb(255, 0, 0));
                SetStatusLabels("Error", true);
                return;
            }

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


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

                    isPlayEnabled = true;

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

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

            SetStatus("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

                /*
                 *  Storyboard fadeStat = (Storyboard)TryFindResource("fadeStat");
                 *  fadeStat.Stop();	// Start
                 *  Storyboard fadeServer = (Storyboard)TryFindResource("fadeServer");
                 *  fadeServer.Stop();	// Start
                 */
                btnAction.IsEnabled = true;
            }));
            if (silentStart)
            {
                //MessageBox.Show("Sorry, you need to update before the game can be started silently.", "ElDewrito Launcher");
                var MainWindow = new MsgBox2("Sorry, you need to update before the game can be started silently.");

                MainWindow.Show();
                MainWindow.Focus();
            }
        }