Esempio n. 1
0
        private void Set(string data)
        {
            StringBuilder sTemp = new StringBuilder();

            int nSpace = data.IndexOf(" ");

            if (nSpace > 0)
            {
                string sCmd   = data.Substring(0, nSpace);
                string sData  = data.Remove(0, nSpace + 1);
                int    nIndex = m_Parameters.IndexOfKey(sCmd);

                if (nIndex < 0)                   // not found
                {
                    AddLine("Unrecognized Parameter");
                }
                else
                {
                    GameCommand Cmd = (GameCommand)m_Parameters.GetByIndex(nIndex);
                    Cmd.Execute(sData);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Add a console parameter mapping
        /// </summary>
        /// <param name="sParam"></param>
        /// <param name="sHelp"></param>
        /// <param name="Func"></param>
        public static void AddParameter(string sParam, string sHelp, CommandFunction Func)
        {
            GameCommand Cmd = new GameCommand(sParam, sHelp, Func);

            m_Parameters.Add(sParam, Cmd);
        }
Esempio n. 3
0
        private void Help(string sData)
        {
            StringBuilder sTemp = new StringBuilder();

            if (sData == null)
            {
                AddLine("Valid Commands");
                foreach (string sCmds in m_Commands.Keys)
                {
                    sTemp.Append(sCmds);
                    sTemp.Append(" ");
                    if (sTemp.Length > 40)
                    {
                        AddLine(sTemp.ToString());
                        sTemp.Remove(0, sTemp.Length - 1);
                    }
                }
                if (sTemp.Length > 0)
                {
                    AddLine(sTemp.ToString());
                }
            }
            else
            {
                int nIndex = m_Commands.IndexOfKey(sData);

                if (nIndex < 0)                   // not found
                {
                    nIndex = m_Parameters.IndexOfKey(sData);

                    if (nIndex < 0)                       // not found
                    {
                        AddLine("Unrecognized Command");
                    }
                    else
                    {
                        GameCommand Cmd       = (GameCommand)m_Parameters.GetByIndex(nIndex);
                        string      sHelpText = sData + " - " + Cmd.Help;
                        AddLine(sHelpText);
                    }
                }
                else
                {
                    GameCommand Cmd       = (GameCommand)m_Commands.GetByIndex(nIndex);
                    string      sHelpText = sData + " - " + Cmd.Help;
                    AddLine(sHelpText);
                }
            }
            if (sData == "SET")
            {
                AddLine("Valid Parameters");
                foreach (string sCmds in m_Parameters.Keys)
                {
                    sTemp.Append(sCmds);
                    sTemp.Append(" ");
                    if (sTemp.Length > 40)
                    {
                        AddLine(sTemp.ToString());
                        sTemp.Remove(0, sTemp.Length - 1);
                    }
                }
                if (sTemp.Length > 0)
                {
                    AddLine(sTemp.ToString());
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Add a console command mapping
        /// </summary>
        /// <param name="sCmd"></param>
        /// <param name="sHelp"></param>
        /// <param name="Func"></param>
        public static void AddCommand(string sCmd, string sHelp, CommandFunction Func)
        {
            GameCommand Cmd = new GameCommand(sCmd, sHelp, Func);

            m_Commands.Add(sCmd, Cmd);
        }