public FactionGroupValueViewModel(SSFactionGroup factionGroup) { FactionGroup = factionGroup; SSDisplayName = new MonitoredValueViewModel(FactionGroup?.DisplayName); DisplayNameWithArticle = new MonitoredValueViewModel(FactionGroup?.DisplayNameWithArticle); ShipNamePrefix = new MonitoredValueViewModel(FactionGroup?.ShipNamePrefix); Color = new MonitoredColorViewModel(FactionGroup?.Color); BaseUIColor = new MonitoredColorViewModel(FactionGroup?.BaseUIColor) { ReplacementSource = FactionGroup?.Color }; DarkUIColor = new MonitoredColorViewModel(FactionGroup?.DarkUIColor) { ReplacementSource = FactionGroup?.Color, ReplacementSourceTransformation = delegate(JsonArray a) { JsonArray result = new JsonArray(); List <int> number = (from JsonToken j in a.Values select Convert.ToInt32(((JsonValue)j).Content)).ToList(); result.Values.Add(new JsonValue(number[0] * 0.4)); result.Values.Add(new JsonValue(number[1] * 0.4)); result.Values.Add(new JsonValue(number[2] * 0.4)); JsonValue alpha = new JsonValue(175); result.Values.Add(alpha); return(result); } }; SecondaryUIColor = new MonitoredColorViewModel(FactionGroup?.SecondaryUIColor) { ReplacementSource = FactionGroup?.Color }; SecondarySegments = new MonitoredValueViewModel(FactionGroup?.SecondarySegments); FleetCircleViewModel = new FactionGroupFleetCircleViewModel(Color, SecondaryUIColor, SecondarySegments); }
public void ApplyModificationFromJson(string text) { List <GroupModification> ModificationList = JsonConvert.DeserializeObject <List <GroupModification> >(text, setting); foreach (GroupModification gm in ModificationList) { SSFactionGroup match = Factions.Find(f => f.RelativeUrl.Equals(gm.GroupUrl)); if (match != null) { if (gm.Modification.RessourceType == typeof(PortraitsRessources)) { if (PortraitsRessource.FindBinaryFromDirectory(gm.Modification.GetContentAsValue().ToString()) == null) { continue; } } else if (gm.Modification.RessourceType == typeof(ShipHullRessources)) { if (!ShipHullRessources.UsableShipHull.ContainsKey(gm.Modification.GetContentAsValue().ToString())) { continue; } } else if (gm.Modification.RessourceType == typeof(BPPackageRessources)) { if (!BPPackageRessources.AvailableBPPackages.Select(x => x.Value.BluePrintTag).Contains(gm.Modification.GetContentAsValue().ToString())) { continue; } } else if (gm.Modification.RessourceType != null) { throw new ArgumentException("faction modification refer to unknown ressource"); } MonitoredField pointed; match.PathedContent.TryGetValue(gm.FieldPath, out pointed); if (pointed == null) { continue; } switch (gm.Modification) { case MonitoredArrayModification mam: ((MonitoredArray)pointed).Modify(mam); break; case MonitoredArrayValueModification mavm: ((MonitoredArrayValue)pointed).Modify(mavm); break; case MonitoredValueModification mvm: ((MonitoredValue)pointed).Modify(mvm); break; } } } }
public FactionGroupTokenViewModel(SSFactionGroup group) : base(group) { Group = group; binding.Add(Group.Bind(x => x.IsModified, (sender, arg) => NotifyOfPropertyChange(nameof(StatusLetter)))); binding.Add(Group.Bind(x => x.MustOverwrite, (sender, arg) => NotifyOfPropertyChange(nameof(StatusLetter)))); binding.Add(this.SSDisplayName.Bind(x => x.Value, (sender, arg) => NotifyOfPropertyChange(nameof(TokenDisplayName)))); }
/// <summary>Extract faction group from the directory</summary> public List <SSFactionGroup> GetFaction() { Factions = (from KeyValuePair <string, ISSGroup> kv in Directory.GroupedFiles where kv.Value is SSFactionGroup select kv.Value).Select(g => { SSFactionGroup f = (SSFactionGroup)g; if (f.MonitoredContent == null) { f.ExtractMonitoredContent(); } return(g as SSFactionGroup); }).ToList(); return(Factions); }
public SSFactionGroupViewModel(SSFactionGroup factionGroupModel) { FactionGroupModel = factionGroupModel; FactionGroupModel.GroupChanged += FactionGroupModel_GroupChanged; }