Beispiel #1
0
        /// <summary>
        /// Get the best command associated with a string.
        /// </summary>
        /// <param name="parse">The complete command string, including Identifier.</param>
        /// <returns>The best command associated with parse.</returns>
        private static ACommand GetCommand(string parse)
        {
            parse = parse.TrimStart().ToLower();

            List <ACommand> list;

            if (!Static.dummyCommands.TryGetValue(parse[0], out list))
            {
                return(null);
            }

            ACommand bestMatch       = null;
            int      bestMatchLength = 0;

            foreach (ACommand cmd in list)
            {
                foreach (string idOrAlias in cmd.IdAndAliases())
                {
                    if (idOrAlias.Length > bestMatchLength && parse.StartsWith(idOrAlias))
                    {
                        bestMatchLength = idOrAlias.Length;
                        bestMatch       = cmd;
                    }
                }
            }

            if (bestMatch == null)
            {
                return(null);
            }
            return(bestMatch.Clone());
        }
Beispiel #2
0
        private void EditCommand(IMyTerminalBlock block)
        {
            Log.DebugLog("block != m_block", Logger.severity.FATAL, condition: block != m_block);

            if (m_currentCommand == null)
            {
                LogAndInfo("nothing selected");
                return;
            }

            if (!m_currentCommand.HasControls)
            {
                LogAndInfo("This command cannot be edited");
                return;
            }

            Log.DebugLog("editing: " + m_currentCommand.DisplayString);

            m_insertIndex    = m_commandList.IndexOf(m_currentCommand);
            m_replace        = true;
            m_currentCommand = m_currentCommand.Clone();
            m_listCommands   = false;
            ClearMessage();
        }