Esempio n. 1
0
        /// <summary>
        /// Asks the user if they'd like to update their custom components.
        /// Handles an event raised by the updater when it has detected
        /// that the custom components are out of date.
        /// </summary>
        private void CUpdater_OnCustomComponentsOutdated()
        {
            if (innerPanel.UpdateQueryWindow.Visible)
            {
                return;
            }

            if (UpdateInProgress)
            {
                return;
            }

            if ((firstRunMessageBox != null && firstRunMessageBox.Visible) || optionsWindow.Enabled)
            {
                // If the custom components are out of date on the first run
                // or the options window is already open, don't show the dialog
                customComponentDialogQueued = true;
                return;
            }

            customComponentDialogQueued = false;

            XNAMessageBox ccMsgBox = XNAMessageBox.ShowYesNoDialog(WindowManager,
                                                                   "Custom Component Updates Available",
                                                                   "Updates for custom components are available. Do you want to open" + Environment.NewLine +
                                                                   "the Options menu where you can update the custom components?");

            ccMsgBox.YesClickedAction = CCMsgBox_YesClicked;
        }
        private void BtnDelete_LeftClick(object sender, EventArgs e)
        {
            var selectedItem = ddPresetSelect.Items[ddPresetSelect.SelectedIndex];
            var messageBox   = XNAMessageBox.ShowYesNoDialog(WindowManager, "Confirm Preset Delete", $"Are you sure you want to delete this preset?\n\n{selectedItem.Text}");

            messageBox.YesClickedAction = box =>
            {
                GameOptionPresets.Instance.DeletePreset(selectedItem.Text);
                ddPresetSelect.Items.Remove(selectedItem);
                ddPresetSelect.SelectedIndex = 0;
            };
        }
Esempio n. 3
0
        /// <summary>
        /// Checks whether the client is running for the first time.
        /// If it is, displays a dialog asking the user if they'd like
        /// to configure settings.
        /// </summary>
        private void CheckIfFirstRun()
        {
            if (UserINISettings.Instance.IsFirstRun)
            {
                UserINISettings.Instance.IsFirstRun.Value = false;
                UserINISettings.Instance.SaveSettings();

                firstRunMessageBox = XNAMessageBox.ShowYesNoDialog(WindowManager, "Initial Installation",
                                                                   string.Format("You have just installed {0}." + Environment.NewLine +
                                                                                 "It's highly recommended that you configure your settings before playing." +
                                                                                 Environment.NewLine + "Do you want to configure them now?", ClientConfiguration.Instance.LocalGame));
                firstRunMessageBox.YesClickedAction = FirstRunMessageBox_YesClicked;
                firstRunMessageBox.NoClickedAction  = FirstRunMessageBox_NoClicked;
            }

            optionsWindow.PostInit();
        }
        /// <summary>
        /// Asks the user whether they want to install the DTA/TI/TS compatibility fix.
        /// </summary>
        public void PostInit()
        {
            Load();

            if (!GameCompatFixInstalled && !GameCompatFixDeclined)
            {
                string defaultGame = ClientConfiguration.Instance.LocalGame;

                var messageBox = XNAMessageBox.ShowYesNoDialog(WindowManager, "New Compatibility Fix",
                                                               "A performance-enhancing compatibility fix for modern Windows versions" + Environment.NewLine +
                                                               "has been included in this version of " + defaultGame + ". Enabling it requires" + Environment.NewLine +
                                                               "administrative priveleges. Would you like to install the compatibility fix?" + Environment.NewLine + Environment.NewLine +
                                                               "You'll always be able to install or uninstall the compatibility fix later from the options menu.");
                messageBox.YesClickedAction = MessageBox_YesClicked;
                messageBox.NoClickedAction  = MessageBox_NoClicked;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Asks the user whether they want to install the DTA/TI/TS compatibility fix.
        /// </summary>
        public void PostInit()
        {
            Load();

            if (!GameCompatFixInstalled && !GameCompatFixDeclined)
            {
                string defaultGame = ClientConfiguration.Instance.LocalGame;

                var messageBox = XNAMessageBox.ShowYesNoDialog(WindowManager, "新版操作系统兼容性修复",
                                                               "此版本的 " + defaultGame + " 中包含了现代 Windows 版本的性能增强兼容性修复程序。" + Environment.NewLine +
                                                               "启用它需要管理员运行权限。" + Environment.NewLine +
                                                               "您希望安装兼容性修复程序吗" + Environment.NewLine + Environment.NewLine +
                                                               "您以后始终可以从选项菜单中安装或卸载兼容性修补程序。");
                messageBox.YesClickedAction = MessageBox_YesClicked;
                messageBox.NoClickedAction  = MessageBox_NoClicked;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Executed after the "Cheater" dialog has been resolved (iow. never displayed,
        /// or it was displayed and the user didn't care about cheating).
        /// </summary>
        private void PostCheaterWindow()
        {
            // Is this mission probably too hard for the user? If so, display a warning dialog.
            if (trbDifficultySelector.Value == 2 && missionToLaunch.WarnOnHardWithoutMediumPlayed && (int)missionToLaunch.Rank < (int)DifficultyRank.NORMAL)
            {
                var messageBox = XNAMessageBox.ShowYesNoDialog(WindowManager,
                                                               "Difficulty warning",
                                                               "This mission can be quite challenging. It's recommended to clear it on lower" + Environment.NewLine +
                                                               "difficulty levels first before attempting it on the hardest difficulty level." + Environment.NewLine + Environment.NewLine +
                                                               "Are you still feeling suicidal enough to attempt it on the hardest difficulty level?");
                messageBox.btnYes.Text      = "Yes";
                messageBox.btnNo.Text       = "I'll reconsider";
                messageBox.YesClickedAction = PostDifficultyWarning;
                return;
            }

            LaunchMission(missionToLaunch);
        }
Esempio n. 7
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);
            }
        }