Пример #1
0
        private void ConnectToServer(Server server)
        {
            if (server == null)
            {
                return;
            }

            if (server.State != Server.StateEnum.Succeeded)
            {
                return;
            }

            launcher = LauncherFactory.CreateLauncher(server.SourceEngine);
            launcher.JoiningServer = true;
            launcher.ServerSourceEngine = server.SourceEngine;
            launcher.ServerAddress = server.Address;
            launcher.ServerGameFolderName = server.GameFolder;
            launcher.ServerMapName = server.Map;
            launcher.Interface = (ILauncher)this;

            try
            {
                launcher.Verify();
            }
            catch (Launcher.AbortLaunchException)
            {
                return;
            }
            catch (ApplicationException ex)
            {
                Common.Message(this, null, ex);
                return;
            }
            catch (Exception ex)
            {
                Common.Message(this, null, ex, MessageWindow.Flags.Error);
                return;
            }

            canOpenServer = false;
            MinimiseToTray();

            // launch the game
            try
            {
                launcher.Run();
            }
            catch (Exception ex)
            {
                RestoreFromTray();
                FileOperationList.Execute();
                canOpenServer = true;
                Common.Message(this, "Error launching game.", ex, MessageWindow.Flags.Error);
                return;
            }

            SystemTrayIcon.Text = "Looking for game process...";

            // enable the tray context menu
            TrayContextMenuEnable(true);
        }
Пример #2
0
        private void uiPlayButton_Click(object sender, RoutedEventArgs e)
        {
            Demo demo = uiDemoListView.GetSelectedDemo();

            if (demo == null)
            {
                // shouldn't happen since the button should be disabled, but anyway...
                return;
            }

            // verify paths etc.
            launcher           = LauncherFactory.CreateLauncher(demo);
            launcher.Owner     = this;
            launcher.UseHlae   = UseHlae(demo);
            launcher.Interface = (ILauncher)this;

            try
            {
                launcher.Verify();
            }
            catch (Launcher.AbortLaunchException)
            {
                return;
            }
            catch (ApplicationException ex)
            {
                Common.Message(this, null, ex);
                return;
            }
            catch (Exception ex)
            {
                Common.Message(this, null, ex, MessageWindow.Flags.Error);
                return;
            }

            // make sure source and destination filenames don't match (dickhead insurance)
            if (String.Equals(demo.FileFullPath, launcher.GameFullPath + "\\" + Config.LaunchDemoFileName, StringComparison.CurrentCultureIgnoreCase))
            {
                Common.Message(this, "Source and destination filenames are the same. Rename or move the source file and try again.");
                return;
            }

            // add the demo file path to the file operation manager
            FileOperationList.Add(new FileDeleteOperation(launcher.GameFullPath + "\\" + Config.LaunchDemoFileName));

            // stop the user from being able to open a new demo now
            canOpenDemo = false;

            // write the demo
            ProgressWindow writeDemoProgressWindow = new ProgressWindow()
            {
                Owner = this
            };

            writeDemoProgressWindow.Thread          = demo.Write((IProgressWindow)writeDemoProgressWindow);
            writeDemoProgressWindow.ThreadParameter = launcher.GameFullPath + "\\" + Config.LaunchDemoFileName;
            if (writeDemoProgressWindow.ShowDialog() == false)
            {
                // user aborted writing
                FileOperationList.Execute();
                canOpenDemo = true;
                return;
            }

            // go to tray
            MinimiseToTray();

            // launch the game
            try
            {
                launcher.Run();
            }
            catch (Exception ex)
            {
                RestoreFromTray();
                FileOperationList.Execute();
                canOpenDemo = true;
                Common.Message(this, "Error launching game.", ex, MessageWindow.Flags.Error);
                return;
            }

            SystemTrayIcon.Text = "Looking for " + (launcher.UseHlae ? "HLAE" : "game") + " process...";

            // enable the tray context menu
            TrayContextMenuEnable(true);
        }
Пример #3
0
        private void uiPlayButton_Click(object sender, RoutedEventArgs e)
        {
            Demo demo = uiDemoListView.GetSelectedDemo();

            if (demo == null)
            {
                // shouldn't happen since the button should be disabled, but anyway...
                return;
            }

            // verify paths etc.
            launcher = LauncherFactory.CreateLauncher(demo);
            launcher.Owner = this;
            launcher.UseHlae = UseHlae(demo);
            launcher.Interface = (ILauncher)this;

            try
            {
                launcher.Verify();
            }
            catch (Launcher.AbortLaunchException)
            {
                return;
            }
            catch (ApplicationException ex)
            {
                Common.Message(this, null, ex);
                return;
            }
            catch (Exception ex)
            {
                Common.Message(this, null, ex, MessageWindow.Flags.Error);
                return;
            }

            // make sure source and destination filenames don't match (dickhead insurance)
            if (String.Equals(demo.FileFullPath, launcher.GameFullPath + "\\" + Config.LaunchDemoFileName, StringComparison.CurrentCultureIgnoreCase))
            {
                Common.Message(this, "Source and destination filenames are the same. Rename or move the source file and try again.");
                return;
            }

            // add the demo file path to the file operation manager
            FileOperationList.Add(new FileDeleteOperation(launcher.GameFullPath + "\\" + Config.LaunchDemoFileName));

            // stop the user from being able to open a new demo now
            canOpenDemo = false;

            // write the demo
            ProgressWindow writeDemoProgressWindow = new ProgressWindow() { Owner = this };
            writeDemoProgressWindow.Thread = demo.Write((IProgressWindow)writeDemoProgressWindow);
            writeDemoProgressWindow.ThreadParameter = launcher.GameFullPath + "\\" + Config.LaunchDemoFileName;
            if (writeDemoProgressWindow.ShowDialog() == false)
            {
                // user aborted writing
                FileOperationList.Execute();
                canOpenDemo = true;
                return;
            }

            // go to tray
            MinimiseToTray();

            // launch the game
            try
            {
                launcher.Run();
            }
            catch (Exception ex)
            {
                RestoreFromTray();
                FileOperationList.Execute();
                canOpenDemo = true;
                Common.Message(this, "Error launching game.", ex, MessageWindow.Flags.Error);
                return;
            }

            SystemTrayIcon.Text = "Looking for " + (launcher.UseHlae ? "HLAE" : "game") + " process...";

            // enable the tray context menu
            TrayContextMenuEnable(true);
        }