public override void SaveToAutoCat(AutoCat autoCat) { AutoCatTags ac = autoCat as AutoCatTags; if (ac == null) { return; } ac.Prefix = txtPrefix.Text; ac.MaxTags = (int)numMaxTags.Value; ac.IncludedTags = new HashSet <string>(); foreach (ListViewItem i in lstIncluded.CheckedItems) { ac.IncludedTags.Add(i.Tag as string); } ac.List_MinScore = (int)list_numMinScore.Value; ac.List_OwnedOnly = list_chkOwnedOnly.Checked; ac.List_TagsPerGame = (int)list_numTagsPerGame.Value; ac.List_WeightFactor = (float)list_numWeightFactor.Value; ac.List_ExcludeGenres = list_chkExcludeGenres.Checked; }
public static AutoCatTags LoadFromXmlElement(XmlElement xElement) { string name = XmlUtil.GetStringFromNode(xElement[Serialization.Constants.Name], TypeIdString); AutoCatTags result = new AutoCatTags(name) { Filter = XmlUtil.GetStringFromNode(xElement[Serialization.Constants.Filter], null) }; if (XmlUtil.TryGetStringFromNode(xElement[Serialization.Constants.Prefix], out string prefix)) { result.Prefix = prefix; } if (XmlUtil.TryGetIntFromNode(xElement[XmlName_MaxTags], out int maxTags)) { result.MaxTags = maxTags; } if (XmlUtil.TryGetBoolFromNode(xElement[XmlName_ListOwnedOnly], out bool listOwnedOnly)) { result.List_OwnedOnly = listOwnedOnly; } if (XmlUtil.TryGetFloatFromNode(xElement[XmlName_ListWeightFactor], out float listWeightFactor)) { result.List_WeightFactor = listWeightFactor; } if (XmlUtil.TryGetIntFromNode(xElement[XmlName_ListMinScore], out int listMinScore)) { result.List_MinScore = listMinScore; } if (XmlUtil.TryGetIntFromNode(xElement[XmlName_ListTagsPerGame], out int listTagsPerGame)) { result.List_TagsPerGame = listTagsPerGame; } if (XmlUtil.TryGetBoolFromNode(xElement[XmlName_ListScoreSort], out bool listScoreSort)) { result.List_ScoreSort = listScoreSort; } if (XmlUtil.TryGetBoolFromNode(xElement[XmlName_ListExcludeGenres], out bool listExcludeGenres)) { result.List_ExcludeGenres = listExcludeGenres; } List <string> tagList = XmlUtil.GetStringsFromNodeList(xElement.SelectNodes(XmlName_TagList + "/" + XmlName_Tag)); result.IncludedTags = tagList == null ? new HashSet <string>() : new HashSet <string>(tagList); return(result); }
public static AutoCat LoadACFromXmlElement(XmlElement xElement) { string type = xElement.Name; switch (type) { 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)); case AutoCatVrSupport.TypeIdString: return(AutoCatVrSupport.LoadFromXmlElement(xElement)); case AutoCatLanguage.TypeIdString: return(AutoCatLanguage.LoadFromXmlElement(xElement)); case AutoCatCurator.TypeIdString: return(LoadFromXmlElement(xElement, typeof(AutoCatCurator))); case AutoCatPlatform.TypeIdString: return(LoadFromXmlElement(xElement, typeof(AutoCatPlatform))); case AutoCatHoursPlayed.TypeIdString: return(AutoCatHoursPlayed.LoadFromXmlElement(xElement)); default: return(null); } }
public static void GenerateDefaultAutoCatSet(List <AutoCat> list) { if (list == null) { list = new List <AutoCat>(); } //By Genre list.Add(new AutoCatGenre(GlobalStrings.Profile_DefaultAutoCatName_Genre, null, "(" + GlobalStrings.Name_Genre + ") ")); //By Year list.Add(new AutoCatYear(GlobalStrings.Profile_DefaultAutoCatName_Year, null, "(" + GlobalStrings.Name_Year + ") ")); //By Score AutoCatUserScore ac = new AutoCatUserScore(GlobalStrings.Profile_DefaultAutoCatName_UserScore, null, "(" + GlobalStrings.Name_Score + ") "); ac.GenerateSteamRules(ac.Rules); list.Add(ac); //By Tags AutoCatTags act = new AutoCatTags(GlobalStrings.Profile_DefaultAutoCatName_Tags, null, "(" + GlobalStrings.Name_Tags + ") "); foreach (KeyValuePair <string, float> tag in Database.CalculateSortedTagList(null, 1, 20, 0, false, false)) { act.IncludedTags.Add(tag.Key); } list.Add(act); //By Flags AutoCatFlags acf = new AutoCatFlags(GlobalStrings.Profile_DefaultAutoCatName_Flags, null, "(" + GlobalStrings.Name_Flags + ") "); foreach (string flag in Database.AllFlags) { acf.IncludedFlags.Add(flag); } list.Add(acf); //By HLTB AutoCatHltb ach = new AutoCatHltb(GlobalStrings.Profile_DefaultAutoCatName_Hltb, null, "(HLTB) ", false); ach.Rules.Add(new HowLongToBeatRule(" 0-5", 0, 5, TimeType.Extras)); ach.Rules.Add(new HowLongToBeatRule(" 5-10", 5, 10, TimeType.Extras)); ach.Rules.Add(new HowLongToBeatRule("10-20", 10, 20, TimeType.Extras)); ach.Rules.Add(new HowLongToBeatRule("20-50", 20, 50, TimeType.Extras)); ach.Rules.Add(new HowLongToBeatRule("50+", 20, 0, TimeType.Extras)); list.Add(ach); //By Platform AutoCatPlatform acPlatform = new AutoCatPlatform(GlobalStrings.Profile_DefaultAutoCatName_Platform, null, "(" + GlobalStrings.AutoCat_Name_Platform + ") ", true, true, true, true); list.Add(acPlatform); }
protected AutoCatTags(AutoCatTags other) : base(other) { Filter = other.Filter; Prefix = other.Prefix; IncludedTags = new HashSet <string>(other.IncludedTags); MaxTags = other.MaxTags; List_OwnedOnly = other.List_OwnedOnly; List_WeightFactor = other.List_WeightFactor; List_MinScore = other.List_MinScore; List_TagsPerGame = other.List_TagsPerGame; List_ScoreSort = other.List_ScoreSort; List_ExcludeGenres = other.List_ExcludeGenres; Selected = other.Selected; }
public override void LoadFromAutoCat(AutoCat autoCat) { AutoCatTags ac = autoCat as AutoCatTags; if (ac == null) { return; } txtPrefix.Text = ac.Prefix ?? string.Empty; numMaxTags.Value = ac.MaxTags; list_numMinScore.Value = ac.List_MinScore; list_numTagsPerGame.Value = ac.List_TagsPerGame; list_chkOwnedOnly.Checked = ac.List_OwnedOnly; list_numWeightFactor.Value = (decimal)ac.List_WeightFactor; list_chkExcludeGenres.Checked = ac.List_ExcludeGenres; FillTagsList(ac.IncludedTags); loaded = true; }