Exemple #1
0
        /// <summary>
        /// Generates the list of the modules stored in config file
        /// </summary>
        /// <returns>List of the modules</returns>
        public List <ExpansionSettingsBase> GetExpansionList()
        {
            List <ExpansionSettingsBase> expansions = new List <ExpansionSettingsBase>();

            // check if the settings exists in the XML
            if (m_xml_doc != null)
            {
                XmlElement root_node = m_xml_doc.DocumentElement;

                if (root_node != null && root_node.Name == RootElementName)
                {
                    XmlNodeList modules_node = root_node.SelectNodes('/' + RootElementName + '/' + TVCSettingsElementName + "[@Active = 'true']" + "/*");

                    for (int i = 0; i < modules_node.Count; i++)
                    {
                        // try to deserialize card
                        CardSettingsBase card_settings = new CardSettingsBase(SettingsBase.SettingsCategory.TVC, modules_node[i].Name);

                        DeserializeEntry(modules_node[i], card_settings);

                        if (card_settings.ExpansionIndex >= 0 && card_settings.SlotIndex >= 0)
                        {
                            if (card_settings.Active)
                            {
                                expansions.Add(card_settings);
                            }
                        }
                        else
                        {
                            // this is not a card it's an expansion
                            ExpansionSettingsBase settings_base = new ExpansionSettingsBase(SettingsBase.SettingsCategory.TVC, modules_node[i].Name);

                            DeserializeEntry(modules_node[i], settings_base);

                            if (settings_base.ExpansionIndex >= 0)
                            {
                                if (settings_base.Active)
                                {
                                    expansions.Add(settings_base);
                                }
                            }
                        }
                    }
                }
            }

            return(expansions);
        }
Exemple #2
0
        public void ModuleActivate(ExpansionSettingsBase in_module)
        {
            try
            {
                XmlNode     root      = m_xml_doc.DocumentElement;
                XmlNodeList node_list = root.SelectNodes('/' + in_module.ModuleName + "/*");

                if (in_module.ExpansionIndex < node_list.Count)
                {
                    node_list[in_module.ExpansionIndex].Attributes[ExpanstionActiveAttribute].Value = "true";
                }
            }
            catch
            {
                // error occured
            }
        }
Exemple #3
0
        public void ModuleAdd(ExpansionSettingsBase inout_module_info)
        {
            XmlNode     root_node      = m_xml_doc.DocumentElement;
            XmlNode     parent_node    = root_node.SelectSingleNode('/' + RootElementName + '/' + TVCSettingsElementName + "[@Active = 'true']");
            XmlNodeList expansion_node = parent_node.SelectNodes(inout_module_info.ModuleName);
            bool        create_new     = true;

            inout_module_info.ExpansionIndex = 0;
            ExpansionSettingsBase expansion_info = (ExpansionSettingsBase)Activator.CreateInstance(inout_module_info.GetType(), SettingsBase.SettingsCategory.TVC, inout_module_info.ModuleName);

            for (int i = 0; i < expansion_node.Count; i++)
            {
                DeserializeEntry(expansion_node[i], expansion_info);

                if (!expansion_info.Active)
                {
                    // if there is an inactive expansion, then activate it
                    inout_module_info.ExpansionIndex = expansion_info.ExpansionIndex;
                    create_new = false;

                    // update existing node
                    UpdateEntry(expansion_node[i], inout_module_info);

                    break;
                }
                else
                {
                    if (inout_module_info.ExpansionIndex <= expansion_info.ExpansionIndex)
                    {
                        inout_module_info.ExpansionIndex = expansion_info.ExpansionIndex + 1;
                    }
                }
            }

            if (create_new)
            {
                // create a new node
                SerializeEntry(parent_node, inout_module_info);
            }
        }
Exemple #4
0
        /// <summary>
        /// Module Deactivate
        /// </summary>
        /// <param name="in_module"></param>
        public void ModuleDeactivate(string in_expansion_name, int in_expansion_index)
        {
            try
            {
                XmlNode root_node   = m_xml_doc.DocumentElement;
                XmlNode parent_node = root_node.SelectSingleNode('/' + RootElementName + '/' + TVCSettingsElementName + "[@Active = 'true']");
                XmlNode module_node = parent_node.SelectSingleNode(in_expansion_name + "[@ExpansionIndex = '" + in_expansion_index.ToString() + "']");

                if (module_node != null)
                {
                    ExpansionSettingsBase settings = new ExpansionSettingsBase(SettingsBase.SettingsCategory.TVC, in_expansion_name);
                    DeserializeEntry(module_node, settings);

                    settings.Active = false;
                    UpdateEntry(module_node, settings);
                }
            }
            catch
            {
                // error occured
            }
        }
Exemple #5
0
 public ExpansionSettingsBase(ExpansionSettingsBase in_module_settings_base) : base(in_module_settings_base.Category, in_module_settings_base.ModuleName)
 {
     ExpansionIndex = in_module_settings_base.ExpansionIndex;
     Active         = in_module_settings_base.Active;
 }