Ejemplo n.º 1
0
        public void SendHelpRequest(string topic, int page, Client RequestingClient)
        {
            HelpTopic chosentopic = null;

            if (topic != null)
            {
                chosentopic = Topics.Find(tp => tp.Name.ToLowerInvariant() == topic.ToLowerInvariant());
                if (chosentopic == null)
                {
                    return;
                }
                if (chosentopic.Pages.Count() == 0)
                {
                    return;
                }
                if (page >= chosentopic.Pages.Count())
                {
                    page = chosentopic.Pages.Count() - 1;
                }
            }

            if (RequestingClient != null)
            {
                var chatMsg = ChatMessage.Create(
                    "Help System",
                    (topic != null ? chosentopic.Pages[page] : DefaultHelpstring),
                    (ChatMessageType)ChatMessageType.MessageBox,
                    null);

                GameMain.Server.SendChatMessage(chatMsg, RequestingClient);
            }
            else
            {
                if (topic != null)
                {
                    DebugConsole.ExecuteCommand("messagebox " + chosentopic.Pages[page]);
                }
                else
                {
                    DebugConsole.ExecuteCommand("messagebox " + DefaultHelpstring);
                }
            }
        }
Ejemplo n.º 2
0
        public void Load()
        {
            XDocument doc = null;

            if (File.Exists(SavePath))
            {
                doc = XMLExtensions.TryLoadXml(SavePath);
            }
            else
            {
                SaveDefault();
                //doc = ToolBox.TryLoadXml(SavePath);
            }
            if (doc != null)
            {
                XElement NilModHelpTopicsdoc       = doc.Root.Element("HelpTopics");
                XElement NilModDefaultHelpTopicdoc = doc.Root.Element("DefaultHelpTopic");
                Topics = new List <HelpTopic>();

                DefaultHelpstring = NilModDefaultHelpTopicdoc.Element("Line").GetAttributeString("Text", "1").Trim();
                //DefaultHelpstring = ToolBox.GetAttributeString(NilModDefaultHelpTopicdoc, "Text", "1").Trim();

                //Load the help topics
                if (NilModHelpTopicsdoc?.Elements().Count() > 0)
                {
                    foreach (XElement subElementTopic in NilModHelpTopicsdoc.Elements())
                    {
                        HelpTopic newtopic = new HelpTopic();
                        newtopic.Name  = subElementTopic.GetAttributeString("Name", "1").Trim();
                        newtopic.Pages = new List <string>();
                        foreach (XElement SubElementPage in subElementTopic.Elements())
                        {
                            newtopic.Pages.Add(SubElementPage.GetAttributeString("Text", ""));
                        }
                        Topics.Add(newtopic);
                    }
                }
            }
        }