public GameMultiplayerControl(Control Control, GameScreen GameScreen, int MapIndex, int SaveGameIndex, MultiplayerMatchStartInformation MP)
            : base(Control, GameScreen, MapIndex, SaveGameIndex, true)
        {
            this.UserName = MP.UserName;
            this.Password = MP.Password;
            this.MatchId = MP.MatchId;
            this.GameState = 0;
            this.MultiplayerMatch = true;
            this.MultiplayerFraction = MP.MultiplayerFraction;

            // timer checking if a newer game state is available
            NewGameStateAvailableTimer = new System.Windows.Forms.Timer();
            NewGameStateAvailableTimer.Interval = 1000;
            NewGameStateAvailableTimer.Tick += UpdateGameState;
            NewGameStateAvailableTimer.Start();

            // show multiplayer tab (gui) and update it's content
            GameScreen.TabItem_Multiplayer.Visibility = Visibility.Visible;
            GameScreen.Button_Restart.IsEnabled = false; // disable restart map button for multiplayer matches
            GameScreen.Label_Multiplayer_MatchID.Content = R.String("MatchID") + ": " + MatchId.ToString();
            GameScreen.Label_Multiplayer_MatchVersion.Content = R.String("MatchVersion") + ": " + GameState.ToString();

            // background worker
            BackgroundWorkerDownloadLatestGameState.DoWork += BackgroundWorkerDownloadLatestGameStateWork;
            BackgroundWorkerDownloadLatestGameState.RunWorkerCompleted += BackgroundWorkerDownloadLatestGameState_RunWorkerCompleted;
        }
        public MultiplayerControl(Control Control, MultiplayerScreen MultiplayerScreen, string UserName, SecureString Password)
        {
            this.MultiplayerScreen = MultiplayerScreen;
            this.Control = Control;

            this.UserName = UserName;
            this.Password = Password;

            Data.SaveMultiplayerUserName(UserName);

            RefreshServerList();

            // background worker
            BackgroundWorkerWaitForPlayer2.DoWork += BackgroundWorkerWaitForPlayer2_DoWork;
            BackgroundWorkerWaitForPlayer2.RunWorkerCompleted += BackgroundWorkerWaitForPlayer2_RunWorkerCompleted;
        }
Exemple #3
0
        public MenuControl(Control MainControl, MenuScreen MenuScreen)
        {
            this.MenuScreen = MenuScreen;
            this.Control = MainControl;

            MenuScreen.TextBox_MultiplayerLoginUserName.Text = Data.GetMultiplayerUserName();

            // savegames
            string[] AvailableSaveGames = Data.GetAvailableSavegames();
            for (int i = 0; i < AvailableSaveGames.Length; i++)
            {
                string PathRemoved = AvailableSaveGames[i].Replace(Data.DataPath, "").Replace(Data.SaveGamesPath, "").Replace(Data.DefaultFileExtension, "").Replace("\\", "");
                long Ticks = Convert.ToInt64(PathRemoved);
                string TimeString = Time.ConvertTicksToString(Ticks);
                MenuScreen.ComboBox_Local_SavegameSelection.Items.Add(TimeString);

            }

            if (AvailableSaveGames.Length == 0)
            {
                MenuScreen.Button_Local_ContinueSavegame.IsEnabled = false;
                MenuScreen.ComboBox_Local_SavegameSelection.IsEnabled = false;
            }

            // sound
            Sound.PlaySound(Sound.SoundName.MenuBackground);

            // updates
            Thread CheckForUpdatesThread = new Thread(new ThreadStart(CheckForUpdates));
            CheckForUpdatesThread.IsBackground = true; // closes the thread if the window is closing
            CheckForUpdatesThread.Priority = ThreadPriority.Lowest;
            CheckForUpdatesThread.Start();

            // background workers
            BackgroundWorkerNewAccount.DoWork += BackgroundWorkerNewAccountWork;
            BackgroundWorkerLogin.DoWork += BackgroundWorkerLoginWork;
        }