private void PopulateTechFamilyList(bool SelectFirst = false) { int num = 0; foreach (TechFamily techFamily in this._game.AssetDatabase.MasterTechTree.TechFamilies) { TechFamily techf = techFamily; if (this._game.GameDatabase.GetPlayerTechInfos(this._game.LocalPlayer.ID).FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => this._game.AssetDatabase.MasterTechTree.Technologies.FirstOrDefault <Tech>((Func <Tech, bool>)(y => y.Id == x.TechFileID)).Family == techf.Id)) != null) { this._game.UI.AddItem(this.LeftContentList, "", num, "", "FamilyTechCard"); this._FamilyID.Add(num, techf); string itemGlobalId = this._game.UI.GetItemGlobalID(this.LeftContentList, "", num, ""); this._techFamilyPanels.Add(num, itemGlobalId); this._game.UI.SetPropertyString(this._game.UI.Path(itemGlobalId, this.SystemButton), "id", this.SystemButton + "|" + (object)num); this._game.UI.SetText(this._game.UI.Path(itemGlobalId, "techLabel"), techf.Name); this._game.UI.SetPropertyString(this._game.UI.Path(itemGlobalId, "icon"), "sprite", Path.GetFileNameWithoutExtension(techf.Icon)); ++num; } } if (!SelectFirst || !this._techFamilyPanels.Any <KeyValuePair <int, string> >()) { return; } this.SelectFamily(this._techFamilyPanels.First <KeyValuePair <int, string> >().Key); }
private void AutoSelect() { Random random = new Random(); TechFamily fam = this._FamilyID.Values.ToArray <TechFamily>()[random.Next(0, this._FamilyID.Values.Count)]; this.SetSyncedTechFamily(fam); this.SetChecked(this._FamilyID.FirstOrDefault <KeyValuePair <int, TechFamily> >((Func <KeyValuePair <int, TechFamily>, bool>)(x => x.Value == fam)).Key, this._TechPanels.Keys.ToArray <string>()[random.Next(0, this._TechPanels.Keys.Count)], false); }
protected void SetSyncedTechFamily(TechFamily family) { this._game.UI.ClearItems(this.RightContentList); this._TechToggles.Clear(); this._TechPanels.Clear(); foreach (Tech tech1 in this._game.AssetDatabase.MasterTechTree.Technologies.Where <Tech>((Func <Tech, bool>)(x => x.Family == family.Id))) { Tech tech = tech1; int techId = this._game.GameDatabase.GetTechID(tech.Id); this._game.UI.AddItem(this.RightContentList, "", techId, "", "TechCard_Toggle"); string itemGlobalId = this._game.UI.GetItemGlobalID(this.RightContentList, "", techId, ""); this._TechPanels.Add(tech.Id, itemGlobalId); this._game.UI.SetChecked(this.UI.Path(itemGlobalId, "techtoggle"), (!this._CheckedTechs.Any <KeyValuePair <string, bool> >((Func <KeyValuePair <string, bool>, bool>)(x => x.Key == tech.Id)) ? 0 : (this._CheckedTechs[tech.Id] ? 1 : 0)) != 0); this._game.UI.SetVisible(this.UI.Path(itemGlobalId, "contentSelected"), (!this._CheckedTechs.Any <KeyValuePair <string, bool> >((Func <KeyValuePair <string, bool>, bool>)(x => x.Key == tech.Id)) ? 0 : (this._CheckedTechs[tech.Id] ? 1 : 0)) != 0); this._game.UI.SetPropertyString(this.UI.Path(itemGlobalId, "techtoggle"), "id", "techtoggle|" + this._FamilyID.FirstOrDefault <KeyValuePair <int, TechFamily> >((Func <KeyValuePair <int, TechFamily>, bool>)(x => x.Value == family)).Key.ToString() + "|" + tech.Id); string globalId = this._game.UI.GetGlobalID(this.UI.Path(itemGlobalId, "techtoggle|" + this._FamilyID.FirstOrDefault <KeyValuePair <int, TechFamily> >((Func <KeyValuePair <int, TechFamily>, bool>)(x => x.Value == family)).Key.ToString() + "|" + tech.Id)); this._TechToggles.Add(tech.Id, globalId); this._game.UI.SetText(this._game.UI.Path(itemGlobalId, "techLabel"), this._game.AssetDatabase.MasterTechTree.Technologies.FirstOrDefault <Tech>((Func <Tech, bool>)(x => x.Id == tech.Id)).Name); this._game.UI.SetPropertyString(this._game.UI.Path(itemGlobalId, "icon"), "sprite", Path.GetFileNameWithoutExtension(this._game.AssetDatabase.MasterTechTree.Technologies.FirstOrDefault <Tech>((Func <Tech, bool>)(x => x.Id == tech.Id)).Icon)); } }
protected void SetSyncedTechFamily(TechFamily family) { this._game.UI.ClearItems(this.RightContentList); this._TechToggles.Clear(); this._TechPanels.Clear(); foreach (PlayerTechInfo playerTechInfo in this._game.GameDatabase.GetPlayerTechInfos(this._game.LocalPlayer.ID).Where <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => this._game.AssetDatabase.MasterTechTree.Technologies.FirstOrDefault <Tech>((Func <Tech, bool>)(j => j.Id == x.TechFileID)).Family == family.Id)).ToList <PlayerTechInfo>()) { PlayerTechInfo tech = playerTechInfo; if (this._game.AssetDatabase.MasterTechTree.Technologies.FirstOrDefault <Tech>((Func <Tech, bool>)(x => x.Id == tech.TechFileID)).Allows.Any <Allowable>((Func <Allowable, bool>)(x => (double)x.GetFactionProbabilityPercentage(this._game.LocalPlayer.Faction.Name.ToLower()) > 0.0))) { this._game.UI.AddItem(this.RightContentList, "", tech.TechID, "", "TechCard_Toggle"); string itemGlobalId = this._game.UI.GetItemGlobalID(this.RightContentList, "", tech.TechID, ""); this._TechPanels.Add(tech.TechFileID, itemGlobalId); this._game.UI.SetChecked(this.UI.Path(itemGlobalId, "techtoggle"), (!this._CheckedTechs.Any <KeyValuePair <string, bool> >((Func <KeyValuePair <string, bool>, bool>)(x => x.Key == tech.TechFileID)) ? 0 : (this._CheckedTechs[tech.TechFileID] ? 1 : 0)) != 0); this._game.UI.SetVisible(this.UI.Path(itemGlobalId, "contentSelected"), (!this._CheckedTechs.Any <KeyValuePair <string, bool> >((Func <KeyValuePair <string, bool>, bool>)(x => x.Key == tech.TechFileID)) ? 0 : (this._CheckedTechs[tech.TechFileID] ? 1 : 0)) != 0); this._game.UI.SetPropertyString(this.UI.Path(itemGlobalId, "techtoggle"), "id", "techtoggle|" + this._FamilyID.FirstOrDefault <KeyValuePair <int, TechFamily> >((Func <KeyValuePair <int, TechFamily>, bool>)(x => x.Value == family)).Key.ToString() + "|" + tech.TechFileID); string globalId = this._game.UI.GetGlobalID(this.UI.Path(itemGlobalId, "techtoggle|" + this._FamilyID.FirstOrDefault <KeyValuePair <int, TechFamily> >((Func <KeyValuePair <int, TechFamily>, bool>)(x => x.Value == family)).Key.ToString() + "|" + tech.TechFileID)); this._TechToggles.Add(tech.TechFileID, globalId); this._game.UI.SetText(this._game.UI.Path(itemGlobalId, "techLabel"), this._game.AssetDatabase.MasterTechTree.Technologies.FirstOrDefault <Tech>((Func <Tech, bool>)(x => x.Id == tech.TechFileID)).Name); this._game.UI.SetPropertyString(this._game.UI.Path(itemGlobalId, "icon"), "sprite", Path.GetFileNameWithoutExtension(this._game.AssetDatabase.MasterTechTree.Technologies.FirstOrDefault <Tech>((Func <Tech, bool>)(x => x.Id == tech.TechFileID)).Icon)); } } }
private void SyncLimitationGroup(LimitationTreatyType ltt) { this._app.UI.ClearItems("lstLimitationGroup"); switch (ltt) { case LimitationTreatyType.ShipClass: using (Dictionary <ShipClass, string> .Enumerator enumerator = TreatyEditDialog.ShipClassLimitationGroups.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <ShipClass, string> current = enumerator.Current; this._app.UI.AddItem("lstLimitationGroup", string.Empty, (int)current.Key, App.Localize(current.Value)); } break; } case LimitationTreatyType.Weapon: using (IEnumerator <LogicalWeapon> enumerator = this._app.AssetDatabase.Weapons.GetEnumerator()) { while (enumerator.MoveNext()) { LogicalWeapon current = enumerator.Current; this._app.UI.AddItem("lstLimitationGroup", string.Empty, current.UniqueWeaponID, current.WeaponName); } break; } case LimitationTreatyType.ResearchTree: int userItemId = 0; using (List <TechFamily> .Enumerator enumerator = this._app.AssetDatabase.MasterTechTree.TechFamilies.GetEnumerator()) { while (enumerator.MoveNext()) { TechFamily current = enumerator.Current; this._app.UI.AddItem("lstLimitationGroup", string.Empty, userItemId, current.Name); ++userItemId; } break; } case LimitationTreatyType.ResearchTech: using (List <Tech> .Enumerator enumerator = this._app.AssetDatabase.MasterTechTree.Technologies.GetEnumerator()) { while (enumerator.MoveNext()) { Tech current = enumerator.Current; int techId = this._app.GameDatabase.GetTechID(current.Id); PlayerTechInfo playerTechInfo1 = this._app.GameDatabase.GetPlayerTechInfo(this._editedTreaty.InitiatingPlayerId, techId); PlayerTechInfo playerTechInfo2 = this._app.GameDatabase.GetPlayerTechInfo(this._editedTreaty.ReceivingPlayerId, techId); if (playerTechInfo1 != null && playerTechInfo1.State != TechStates.Researched && (playerTechInfo1.State != TechStates.Researching && playerTechInfo2 != null) && (playerTechInfo2.State != TechStates.Researched && playerTechInfo2.State != TechStates.Researching)) { this._app.UI.AddItem("lstLimitationGroup", string.Empty, techId, current.Name); } } break; } case LimitationTreatyType.StationType: using (Dictionary <StationType, string> .Enumerator enumerator = TreatyEditDialog.StationTypeLimitationGroups.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <StationType, string> current = enumerator.Current; this._app.UI.AddItem("lstLimitationGroup", string.Empty, (int)current.Key, App.Localize(current.Value)); } break; } } }