예제 #1
0
 public AutoCatHltb(AutoCatHltb other) : base(other)
 {
     Filter         = other.Filter;
     Prefix         = other.Prefix;
     IncludeUnknown = other.IncludeUnknown;
     UnknownText    = other.UnknownText;
     Rules          = other.Rules.ConvertAll(rule => new HltbRule(rule));
     Selected       = other.Selected;
 }
        public override void SaveToAutoCat(AutoCat ac)
        {
            AutoCatHltb acHltb = ac as AutoCatHltb;

            if (acHltb == null)
            {
                return;
            }

            acHltb.Prefix         = txtPrefix.Text;
            acHltb.IncludeUnknown = chkIncludeUnknown.Checked;
            acHltb.UnknownText    = txtUnknownText.Text;
            acHltb.Rules          = new List <HltbRule>(ruleList);
        }
예제 #3
0
        public static AutoCatHltb LoadFromXmlElement(XmlElement xElement)
        {
            string name           = XmlUtil.GetStringFromNode(xElement[XmlNameName], TypeIdString);
            string filter         = XmlUtil.GetStringFromNode(xElement[XmlNameFilter], null);
            string prefix         = XmlUtil.GetStringFromNode(xElement[XmlNamePrefix], string.Empty);
            bool   includeUnknown = XmlUtil.GetBoolFromNode(xElement[XmlNameIncludeUnknown], false);
            string unknownText    = XmlUtil.GetStringFromNode(xElement[XmlNameUnknownText], string.Empty);

            List <HltbRule> rules       = new List <HltbRule>();
            XmlNodeList     xmlNodeList = xElement.SelectNodes(XmlNameRule);

            if (xmlNodeList != null)
            {
                foreach (XmlNode node in xmlNodeList)
                {
                    string   ruleName = XmlUtil.GetStringFromNode(node[XmlNameRuleText], string.Empty);
                    float    ruleMin  = XmlUtil.GetFloatFromNode(node[XmlNameRuleMinHours], 0);
                    float    ruleMax  = XmlUtil.GetFloatFromNode(node[XmlNameRuleMaxHours], 0);
                    string   type     = XmlUtil.GetStringFromNode(node[XmlNameRuleTimeType], string.Empty);
                    TimeType ruleTimeType;
                    switch (type)
                    {
                    case "Extras":
                        ruleTimeType = TimeType.Extras;
                        break;

                    case "Completionist":
                        ruleTimeType = TimeType.Completionist;
                        break;

                    default:
                        ruleTimeType = TimeType.Main;
                        break;
                    }

                    rules.Add(new HltbRule(ruleName, ruleMin, ruleMax, ruleTimeType));
                }
            }

            AutoCatHltb result = new AutoCatHltb(name, filter, prefix, includeUnknown, unknownText)
            {
                Rules = rules
            };

            return(result);
        }
예제 #4
0
        /// <summary>
        /// </summary>
        /// <param name="xElement"></param>
        /// <returns></returns>
        public static AutoCat LoadAutoCatFromXmlElement(XmlElement xElement)
        {
            switch (xElement.Name)
            {
            case AutoCatGenre.TypeIdString:
                return(AutoCatGenre.LoadFromXmlElement(xElement));

            case AutoCatFlags.TypeIdString:
                return(AutoCatFlags.LoadFromXmlElement(xElement));

            case AutoCatTags.TypeIdString:
                return(AutoCatTags.LoadFromXmlElement(xElement));

            case AutoCatYear.TypeIdString:
                return(AutoCatYear.LoadFromXmlElement(xElement));

            case AutoCatUserScore.TypeIdString:
                return(AutoCatUserScore.LoadFromXmlElement(xElement));

            case AutoCatHltb.TypeIdString:
                return(AutoCatHltb.LoadFromXmlElement(xElement));

            case AutoCatManual.TypeIdString:
                return(AutoCatManual.LoadFromXmlElement(xElement));

            case AutoCatDevPub.TypeIdString:
                return(AutoCatDevPub.LoadFromXmlElement(xElement));

            case AutoCatGroup.TypeIdString:
                return(AutoCatGroup.LoadFromXmlElement(xElement));

            case AutoCatName.TypeIdString:
                return(AutoCatName.LoadFromXmlElement(xElement));

            default:
                return(null);
            }
        }
        public override void LoadFromAutoCat(AutoCat ac)
        {
            AutoCatHltb acHltb = ac as AutoCatHltb;

            if (acHltb == null)
            {
                return;
            }

            txtPrefix.Text            = acHltb.Prefix;
            chkIncludeUnknown.Checked = acHltb.IncludeUnknown;
            txtUnknownText.Text       = acHltb.UnknownText == null ? string.Empty : acHltb.UnknownText;
            acHltb.IncludeUnknown     = chkIncludeUnknown.Checked;
            acHltb.UnknownText        = txtUnknownText.Text;

            ruleList.Clear();
            foreach (HltbRule rule in acHltb.Rules)
            {
                ruleList.Add(new HltbRule(rule));
            }

            UpdateEnabledSettings();
        }