private void RestartMsgBox_YesClicked(XNAMessageBox messageBox)
 {
     WindowManager.RestartGame();
 }
 private void MessageBox_YesClicked(XNAMessageBox messageBox)
 {
     BtnGameCompatibilityFix_LeftClick(messageBox, EventArgs.Empty);
 }
 private void ExitDownloadCancelConfirmation_YesClicked(XNAMessageBox messageBox)
 {
     componentsPanel.CancelAllDownloads();
     Disable();
 }
        private void SaveDownloadCancelConfirmation_YesClicked(XNAMessageBox messageBox)
        {
            componentsPanel.CancelAllDownloads();

            SaveSettings();
        }
 protected override void AddNotice(string message, Color color)
 {
     XNAMessageBox.Show(WindowManager, "Message", message);
 }
Beispiel #6
0
 private void ClearStatisticsConfirmation_YesClicked(XNAMessageBox messageBox)
 {
     ClearAllStatistics();
 }
Beispiel #7
0
 private void MsgBox_OKClicked(XNAMessageBox messageBox)
 {
     innerPanel.Hide();
 }
Beispiel #8
0
 private void CCMsgBox_YesClicked(XNAMessageBox messageBox)
 {
     optionsWindow.Open();
     optionsWindow.SwitchToCustomComponentsPanel();
 }
 private void ForceUpdateMsgBox_YesClicked(XNAMessageBox obj)
 {
     CUpdater.ClearVersionInfo();
     OnForceUpdate?.Invoke(this, EventArgs.Empty);
 }
Beispiel #10
0
 private void FirstRunMessageBox_YesClicked(XNAMessageBox messageBox)
 {
     optionsWindow.Open();
 }
Beispiel #11
0
 private void ExitDownloadCancelConfirmation_YesClicked(XNAMessageBox messageBox)
 {
     componentsPanel.CancelAllDownloads();
     WindowManager.SoundPlayer.SetVolume(Convert.ToSingle(UserINISettings.Instance.ClientVolume));
     Disable();
 }
Beispiel #12
0
        protected void LoadGame()
        {
            File.Delete(ProgramConstants.GamePath + "spawn.ini");

            File.Copy(ProgramConstants.GamePath + ProgramConstants.SAVED_GAME_SPAWN_INI, ProgramConstants.GamePath + "spawn.ini");

            IniFile spawnIni = new IniFile(ProgramConstants.GamePath + "spawn.ini");

            int    sgIndex    = (ddSavedGame.Items.Count - 1) - ddSavedGame.SelectedIndex;
            string sgFileName = string.Format("SVGM_{0}.NET", sgIndex.ToString("D3"));

            spawnIni.SetStringValue("Settings", "SaveGameName", sgFileName);
            spawnIni.SetBooleanValue("Settings", "LoadSaveGame", true);

            PlayerInfo localPlayer = Players.Find(p => p.Name == ProgramConstants.PLAYERNAME);

            if (localPlayer == null)
            {
                return;
            }

            spawnIni.SetIntValue("Settings", "Port", localPlayer.Port);

            for (int i = 1; i < Players.Count; i++)
            {
                string otherName = spawnIni.GetStringValue("Other" + i, "Name", string.Empty);

                if (string.IsNullOrEmpty(otherName))
                {
                    continue;
                }

                PlayerInfo otherPlayer = Players.Find(p => p.Name == otherName);

                if (otherPlayer == null)
                {
                    continue;
                }

                spawnIni.SetStringValue("Other" + i, "Ip", otherPlayer.IPAddress);
                spawnIni.SetIntValue("Other" + i, "Port", otherPlayer.Port);
            }

            WriteSpawnIniAdditions(spawnIni);
            spawnIni.WriteIniFile();

            File.Delete(ProgramConstants.GamePath + "spawnmap.ini");
            StreamWriter sw = new StreamWriter(ProgramConstants.GamePath + "spawnmap.ini");

            sw.WriteLine("[Map]");
            sw.WriteLine("Size=0,0,50,50");
            sw.WriteLine("LocalSize=0,0,50,50");
            sw.WriteLine();
            sw.Close();

            gameLoadTime = DateTime.Now;

            string saveFilePath = ProgramConstants.GamePath + MultiplayerSaveGameManager.SAVED_GAMES_MP_DIRECTORY + "/" + sgFileName;
            string metaFilePath = Path.ChangeExtension(saveFilePath, GameSessionManager.SavedGameMetaExtension);
            var    meta         = GameSessionInfo.ParseFromFile(metaFilePath);

            if (meta == null)
            {
                XNAMessageBox.Show(WindowManager, "Failed to load saved multiplayer game", "Failed to load saved game: saved game meta could not be parsed!");
                return;
            }

            var gameSessionInfo = new GameSessionManager(new GameSessionInfo(GameSessionType.MULTIPLAYER, meta.UniqueId), WindowManager.AddCallback);

            gameSessionInfo.StartSession();
            GameProcessLogic.GameProcessExited += SharedUILogic_GameProcessExited;
            GameProcessLogic.StartGameProcess(gameSessionInfo);

            UpdateDiscordPresence(true);
        }
Beispiel #13
0
 private void UpdateMessageBox_NoClicked(XNAMessageBox messageBox)
 {
     updateDenied = true;
 }
Beispiel #14
0
 private void UpdateMessageBox_YesClicked(XNAMessageBox messageBox)
 {
     UpdateCheck?.Invoke(this, EventArgs.Empty);
 }
Beispiel #15
0
        private void GameBroadcastChannel_CTCPReceived(object sender, ChannelCTCPEventArgs e)
        {
            var channel = (Channel)sender;

            var channelUser = channel.Users.Find(u => u.IRCUser.Name == e.UserName);

            if (channelUser == null)
            {
                return;
            }

            if (localGame != null &&
                channel.ChannelName == localGame.GameBroadcastChannel &&
                !updateDenied &&
                channelUser.IsAdmin &&
                !isInGameRoom &&
                e.Message.StartsWith("UPDATE ") &&
                e.Message.Length > 7)
            {
                string version = e.Message.Substring(7);
                if (version != ProgramConstants.GAME_VERSION)
                {
                    var updateMessageBox = XNAMessageBox.ShowYesNoDialog(WindowManager, "Update available",
                                                                         "An update is available. Do you want to perform the update now?");
                    updateMessageBox.NoClickedAction  = UpdateMessageBox_NoClicked;
                    updateMessageBox.YesClickedAction = UpdateMessageBox_YesClicked;
                }
            }

            if (!e.Message.StartsWith("GAME "))
            {
                return;
            }

            string msg = e.Message.Substring(5); // Cut out GAME part

            string[] splitMessage = msg.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            if (splitMessage.Length < 11 || splitMessage.Length > 12) // Support for optional isRA2Mode param
            {
                Logger.Log("Ignoring CTCP game message because of an invalid amount of parameters.");
                return;
            }

            try
            {
                string revision = splitMessage[0];
                if (revision != ProgramConstants.CNCNET_PROTOCOL_REVISION)
                {
                    return;
                }
                string   gameVersion         = splitMessage[1];
                int      maxPlayers          = Conversions.IntFromString(splitMessage[2], 0);
                string   gameRoomChannelName = splitMessage[3];
                string   gameRoomDisplayName = splitMessage[4];
                bool     locked           = Conversions.BooleanFromString(splitMessage[5].Substring(0, 1), true);
                bool     isCustomPassword = Conversions.BooleanFromString(splitMessage[5].Substring(1, 1), false);
                bool     isClosed         = Conversions.BooleanFromString(splitMessage[5].Substring(2, 1), true);
                bool     isLoadedGame     = Conversions.BooleanFromString(splitMessage[5].Substring(3, 1), false);
                bool     isLadder         = Conversions.BooleanFromString(splitMessage[5].Substring(4, 1), false);
                string[] players          = splitMessage[6].Split(new char[1] {
                    ','
                }, StringSplitOptions.RemoveEmptyEntries);
                List <string> playerNames   = players.ToList();
                string        mapName       = splitMessage[7];
                string        gameMode      = splitMessage[8];
                string        tunnelAddress = splitMessage[9];
                string        loadedGameId  = splitMessage[10];
                bool          isRA2Mode     = 11 < splitMessage.Length ? Conversions.BooleanFromString(splitMessage[11], false) : false;

                CnCNetGame cncnetGame = gameCollection.GameList.Find(g => g.GameBroadcastChannel == channel.ChannelName);

                CnCNetTunnel tunnel = tunnelHandler.Tunnels.Find(t => t.Address == tunnelAddress);

                if (tunnel == null)
                {
                    return;
                }

                if (cncnetGame == null)
                {
                    return;
                }

                HostedCnCNetGame game = new HostedCnCNetGame(gameRoomChannelName, revision, gameVersion, maxPlayers,
                                                             gameRoomDisplayName, isCustomPassword, true, players,
                                                             e.UserName, mapName, gameMode);
                game.IsLoadedGame    = isLoadedGame;
                game.MatchID         = loadedGameId;
                game.LastRefreshTime = DateTime.Now;
                game.IsLadder        = isLadder;
                game.Game            = cncnetGame;
                game.Locked          = locked || (game.IsLoadedGame && !game.Players.Contains(ProgramConstants.PLAYERNAME));
                game.Incompatible    = cncnetGame == localGame && game.GameVersion != ProgramConstants.GAME_VERSION;
                game.TunnelServer    = tunnel;

                if (isClosed)
                {
                    int index = lbGameList.HostedGames.FindIndex(hg => hg.HostName == e.UserName);

                    if (index > -1)
                    {
                        lbGameList.RemoveGame(index);
                    }

                    return;
                }

                // Seek for the game in the internal game list based on the name of its host;
                // if found, then refresh that game's information, otherwise add as new game
                int gameIndex = lbGameList.HostedGames.FindIndex(hg => hg.HostName == e.UserName);

                if (gameIndex > -1)
                {
                    lbGameList.HostedGames[gameIndex] = game;
                    lbGameList.SortAndRefreshHostedGames();
                }
                else
                {
                    if (UserINISettings.Instance.PlaySoundOnGameHosted &&
                        cncnetGame.InternalName == localGameID.ToLower() &&
                        !ProgramConstants.IsInGame && !game.Locked)
                    {
                        SoundPlayer.Play(sndGameCreated);
                    }

                    lbGameList.AddGame(game);
                }
            }
            catch (Exception ex)
            {
                Logger.Log("Game parsing error:" + ex.Message);
            }
        }