Example #1
0
        public void handleChatCommand(string messageText, ref bool sendToOthers)
        {
            try {
                if (messageText[0] != '/')
                {
                    return;
                }

                string[] cmd =
                    messageText.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

                log("Handling commands " + String.Join(" , ", cmd), "handleChatCommand");
                if (cmd[0].ToLower() != "/gc")
                {
                    return;
                }

                sendToOthers = false;
                int numCommands = cmd.Length - 1;
                log("numCommands " + numCommands, "handleChatCommand");
                if (numCommands > 0)
                {
                    switch (cmd[1].ToLower())
                    {
                    case "about":
                    case "help":
                        if (numCommands == 1)
                        {
                            Utility.showDialog("Help", s_HelpText, "Close");
                        }
                        else
                        {
                            switch (cmd[2].ToLower())
                            {
                            case "classes":
                                Utility.showDialog("Help - Classes", helpClassesText(), "Close");
                                break;

                            case "classifiers":
                                Utility.showDialog("Help - Classifiers", helpClassifiersText(), "Close");
                                break;

                            case "cps":
                                Utility.showDialog("Help - Control Points", helpCPsText(), "Close");
                                break;

                            case "licenses":
                                Utility.showDialog("Help - Licenses", s_HelpLicensesText, "Close");
                                break;
                            }
                        }
                        break;

                    case "cps":
                        if (numCommands == 1)
                        {
                            Utility.showDialog("Help - Control Points", helpCPsText(), "Close");
                        }
                        else if (numCommands == 2)
                        {
                            switch (cmd[2].ToLower())
                            {
                            case "show":
                                m_MailMan.addCPGPS();
                                break;

                            case "hide":
                                m_MailMan.removeCPGPS();
                                break;
                            }
                        }
                        break;

                    case "fleet":
                        if (numCommands == 1)
                        {
                            m_MailMan.requestFleet();
                        }
                        else
                        {
                            switch (cmd[2].ToLower())
                            {
                            case "disown":
                                // Disabled until the Mod API supports the ability to change owners of individual blocks

                                /*if (numCommands == 4) {
                                 *      m_MailMan.requestDisown(cmd[3], cmd[4]);
                                 * }*/
                                break;

                            case "stop":
                                if (numCommands == 4)
                                {
                                    m_MailMan.requestStopGrid(cmd[3], cmd[4]);
                                }
                                break;
                            }
                        }
                        break;

                    case "violations":
                        m_MailMan.requestViolations();
                        break;

                    case "admin":
                        // admin fleet listing
                        break;
                    }
                }
            } catch (Exception e) {
                log("Exception occured: " + e, "handleChatCommand", Logger.severity.ERROR);
            }
        }