Пример #1
0
        /// <summary>
        /// Selectes the current game mode.
        /// </summary>
        /// <param name="p_strRequestedGameMode">The id of the game mode we want to select.</param>
        /// <param name="p_booChangeDefaultGameMode">Whether the users ahs requested a change to the default game mode.</param>
        /// <returns>The <see cref="IGameModeFactory"/> that can build the game mode selected by the user.</returns>
        public IGameModeFactory SelectGameMode(string p_strRequestedGameMode, bool p_booChangeDefaultGameMode)
        {
            Trace.Write("Determining Game Mode: ");

            string strSelectedGame = EnvironmentInfo.Settings.RememberGameMode ? EnvironmentInfo.Settings.RememberedGameMode : null;

            if (!String.IsNullOrEmpty(p_strRequestedGameMode))
            {
                Trace.Write("(Requested Mode: " + p_strRequestedGameMode + ") ");
                strSelectedGame = p_strRequestedGameMode;
            }

            if (p_booChangeDefaultGameMode || String.IsNullOrEmpty(strSelectedGame))
            {
                Trace.Write("(From Selection Form) ");
                List <IGameModeDescriptor> lstGameModeInfos = new List <IGameModeDescriptor>();
                foreach (IGameModeDescriptor gmdGameMode in InstalledGameModes.RegisteredGameModes)
                {
                    lstGameModeInfos.Add(gmdGameMode);
                }
                GameModeSelectionForm msfSelector = new GameModeSelectionForm(lstGameModeInfos, EnvironmentInfo.Settings);
                msfSelector.ShowDialog();
                if ((msfSelector.DialogResult == DialogResult.OK) && !(RescanRequested = msfSelector.RescanRequested))
                {
                    strSelectedGame = msfSelector.SelectedGameModeId;
                }
                else
                {
                    return(null);
                }
            }
            Trace.WriteLine(strSelectedGame);
            if (!InstalledGameModes.IsRegistered(strSelectedGame))
            {
                StringBuilder stbError = new StringBuilder();
                if (!SupportedGameModes.IsRegistered(strSelectedGame))
                {
                    stbError.AppendFormat("Unrecognized Game Mode: {0}", strSelectedGame);
                }
                else
                {
                    stbError.AppendFormat("{0} is not set up to work with {1}", EnvironmentInfo.Settings.ModManagerName, SupportedGameModes.GetGameMode(strSelectedGame).GameModeDescriptor.Name).AppendLine();
                    stbError.AppendFormat("If {0} is installed, rescan for installed games from the Change Game toolbar item.", SupportedGameModes.GetGameMode(strSelectedGame).GameModeDescriptor.Name).AppendLine();
                }
                Trace.TraceError(stbError.ToString());
                MessageBox.Show(stbError.ToString(), "Unrecognized Game Mode", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            return(InstalledGameModes.GetGameMode(strSelectedGame));
        }
Пример #2
0
		/// <summary>
		/// Selectes the current game mode.
		/// </summary>
		/// <param name="p_strRequestedGameMode">The id of the game mode we want to select.</param>
		/// <param name="p_booChangeDefaultGameMode">Whether the users ahs requested a change to the default game mode.</param>
		/// <returns>The <see cref="IGameModeFactory"/> that can build the game mode selected by the user.</returns>
		public IGameModeFactory SelectGameMode(string p_strRequestedGameMode, bool p_booChangeDefaultGameMode)
		{
			Trace.Write("Determining Game Mode: ");

			string strSelectedGame = EnvironmentInfo.Settings.RememberGameMode ? EnvironmentInfo.Settings.RememberedGameMode : null;
			if (!String.IsNullOrEmpty(p_strRequestedGameMode))
			{
				Trace.Write("(Requested Mode: " + p_strRequestedGameMode + ") ");
				strSelectedGame = p_strRequestedGameMode;
			}

			if (p_booChangeDefaultGameMode || String.IsNullOrEmpty(strSelectedGame))
			{
				Trace.Write("(From Selection Form) ");
				List<IGameModeDescriptor> lstGameModeInfos = new List<IGameModeDescriptor>();
				foreach (IGameModeDescriptor gmdGameMode in InstalledGameModes.RegisteredGameModes)
					lstGameModeInfos.Add(gmdGameMode);
				GameModeSelectionForm msfSelector = new GameModeSelectionForm(lstGameModeInfos, EnvironmentInfo.Settings);
				msfSelector.ShowDialog();
				if ((msfSelector.DialogResult == DialogResult.OK) && !(RescanRequested = msfSelector.RescanRequested))
					strSelectedGame = msfSelector.SelectedGameModeId;
				else
					return null;
			}
			Trace.WriteLine(strSelectedGame);
			if (!InstalledGameModes.IsRegistered(strSelectedGame))
			{
				StringBuilder stbError = new StringBuilder();
				if (!SupportedGameModes.IsRegistered(strSelectedGame))
					stbError.AppendFormat("Unrecognized Game Mode: {0}", strSelectedGame);
				else
				{
					stbError.AppendFormat("{0} is not set up to work with {1}", EnvironmentInfo.Settings.ModManagerName, SupportedGameModes.GetGameMode(strSelectedGame).GameModeDescriptor.Name).AppendLine();
					stbError.AppendFormat("If {0} is installed, rescan for installed games from the Change Game toolbar item.", SupportedGameModes.GetGameMode(strSelectedGame).GameModeDescriptor.Name).AppendLine();
				}
				Trace.TraceError(stbError.ToString());
				MessageBox.Show(stbError.ToString(), "Unrecognized Game Mode", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return null;
			}

			return InstalledGameModes.GetGameMode(strSelectedGame);
		}