コード例 #1
0
        private void CheckAndSave(IMyTerminalBlock block)
        {
            Log.DebugLog("block != m_block", Logger.severity.FATAL, condition: block != m_block);
            Log.DebugLog("m_currentCommand == null", Logger.severity.FATAL, condition: m_currentCommand == null);

            string msg;

            if (m_currentCommand.ValidateControls((IMyCubeBlock)m_block, out msg))
            {
                if (m_commandList.Contains(m_currentCommand))
                {
                    Log.DebugLog("edited command: " + m_currentCommand.DisplayString);
                }
                else
                {
                    if (m_insertIndex == -1)
                    {
                        Log.DebugLog("new command: " + m_currentCommand.DisplayString);
                        m_commandList.Add(m_currentCommand);
                    }
                    else
                    {
                        if (m_replace)
                        {
                            m_commandList.RemoveAt(m_insertIndex);
                            Log.DebugLog("replace at " + m_insertIndex + ": " + m_currentCommand.DisplayString);
                        }
                        else
                        {
                            Log.DebugLog("new command at " + m_insertIndex + ": " + m_currentCommand.DisplayString);
                        }
                        m_commandList.Insert(m_insertIndex, m_currentCommand);
                    }
                }
                m_currentCommand = null;
                m_listCommands   = true;
                ClearMessage();
            }
            else
            {
                Log.DebugLog("failed to save command: " + m_currentCommand.DisplayString + ", reason: " + msg);
                LogAndInfo(msg);
            }
        }