/// <summary> /// Constructor - adds default options tab to tabstrip. /// </summary> /// <param name="tabStrip">Tab strip to add to</param> /// <param name="tabIndex">Index number of tab</param> internal DefaultsPanelBase(UITabstrip tabStrip, int tabIndex) : base(tabStrip, tabIndex) { // Initialise arrays. AvailablePopPacks = new PopDataPack[SubServiceNames.Length][]; AvailableFloorPacks = FloorData.instance.Packs; PopMenus = new UIDropDown[SubServiceNames.Length]; FloorMenus = new UIDropDown[SubServiceNames.Length]; // Add title. float currentY = PanelUtils.TitleLabel(panel, TitleKey); // Add header controls. currentY = PanelHeader(currentY); // Add menus. currentY = SetUpMenus(currentY); // Add buttons- add extra space. FooterButtons(currentY + Margin); // Set control values. UpdateControls(); }
/// <summary> /// Updates the population calculation pack selection to the selected pack. /// </summary> /// <param name="index">Index number (from menu) of selection pack</param> private void UpdatePopSelection(PopDataPack popPack) { // Update selected pack. currentPopPack = popPack; // Update description. popDescription.text = currentPopPack.description; // Check if we're using legacy or volumetric data. if (currentPopPack is VolumetricPopPack) { // Volumetric pack. Are we coming from a legacy setting? if (usingLegacy) { // Reset flag. usingLegacy = false; // Restore floor rendering. BuildingDetailsPanel.Panel.HideFloors = false; // Update override label text. floorOverrideLabel.text = Translations.Translate("RPR_CAL_FOV"); // Set visibility. legacyPanel.Hide(); volumetricPanel.Show(); } // Update panel with new calculations. LevelData thisLevel = CurrentLevelData; volumetricPanel.UpdatePopText(thisLevel); volumetricPanel.CalculateVolumetric(currentBuilding, thisLevel, currentFloorOverride ?? currentFloorPack, currentSchoolPack, currentMult); // Set visibility. if (currentFloorOverride == null) { floorOverrideLabel.Hide(); } else { floorOverrideLabel.Show(); } floorPanel.Show(); } else { // Using legacy calcs = set flag. usingLegacy = true; // Set visibility. volumetricPanel.Hide(); floorPanel.Hide(); legacyPanel.Show(); // Set override label and show. floorOverrideLabel.text = Translations.Translate("RPR_CAL_FLG"); floorOverrideLabel.Show(); // Cancel any floor rendering. BuildingDetailsPanel.Panel.HideFloors = true; } }
/// <summary> /// Called whenever the currently selected building is changed to update the panel display. /// </summary> /// <param name="building">Newly selected building</param> internal void SelectionChanged(BuildingInfo building) { // Set current building. currentBuilding = building; // Safety first! if (currentBuilding != null) { string buildingName = building.name; // Get available calculation packs for this building. popPacks = PopData.instance.GetPacks(building); floorPacks = FloorData.instance.Packs; // Get current and default packs for this item. currentPopPack = (PopDataPack)PopData.instance.ActivePack(building); currentFloorPack = (FloorDataPack)FloorData.instance.ActivePack(building); PopDataPack defaultPopPack = (PopDataPack)PopData.instance.CurrentDefaultPack(building); FloorDataPack defaultFloorPack = (FloorDataPack)FloorData.instance.CurrentDefaultPack(building); // Update multiplier before we do any other calcs. multCheck.isChecked = Multipliers.instance.HasOverride(buildingName); currentMult = Multipliers.instance.ActiveMultiplier(building); // Build pop pack menu. popMenu.items = new string[popPacks.Length]; for (int i = 0; i < popMenu.items.Length; ++i) { popMenu.items[i] = popPacks[i].displayName; // Check for default name match, if (popPacks[i].name.Equals(defaultPopPack.name)) { popMenu.items[i] += Translations.Translate("RPR_PCK_DEF"); } // Set menu selection to current pack if it matches. if (popPacks[i].name.Equals(currentPopPack.name)) { popMenu.selectedIndex = i; } } // Set population pack to current pack. UpdatePopSelection(currentPopPack); // Build floor pack menu. floorMenu.items = new string[floorPacks.Length]; for (int i = 0; i < floorPacks.Length; ++i) { floorMenu.items[i] = floorPacks[i].displayName; // Check for default name match, if (floorPacks[i].name.Equals(defaultFloorPack.name)) { floorMenu.items[i] += Translations.Translate("RPR_PCK_DEF"); } // Set menu selection to current pack if it matches. if (floorPacks[i].name.Equals(currentFloorPack.name)) { floorMenu.selectedIndex = i; // Force pack selection update. UpdateFloorSelection(i); } } // Update legacy panel for private building AIs (volumetric panel is updated by menu selection change above). if (building.GetAI() is PrivateBuildingAI) { legacyPanel.SelectionChanged(building); } // Is this a school building (need to do school building after pop and floor packs are updated)? if (building.GetAI() is SchoolAI) { // Yes - school building. Set current pack. currentSchoolPack = (SchoolDataPack)SchoolData.instance.ActivePack(building); // Are we using custom school settings? if (ModSettings.enableSchoolProperties) { // Yes - extend panel height and show school panel. volumetricPanel.relativePosition = new Vector2(0f, SchoolCalcY); applyButton.relativePosition = new Vector2(ApplyX, SchoolSaveY); // Get available school packs for this building. schoolPacks = SchoolData.instance.GetPacks(building); // Get current and default packs for this item. currentSchoolPack = (SchoolDataPack)SchoolData.instance.ActivePack(building); SchoolDataPack defaultSchoolPack = (SchoolDataPack)SchoolData.instance.CurrentDefaultPack(building); // Build school pack menu. schoolMenu.items = new string[schoolPacks.Length]; for (int i = 0; i < schoolMenu.items.Length; ++i) { schoolMenu.items[i] = schoolPacks[i].displayName; // Check for default name match, if (schoolPacks[i].name.Equals(defaultSchoolPack.name)) { schoolMenu.items[i] += Translations.Translate("RPR_PCK_DEF"); } // Set menu selection to current pack if it matches. if (schoolPacks[i].name.Equals(currentSchoolPack.name)) { schoolMenu.selectedIndex = i; // Force pack selection update. UpdateSchoolSelection(i); } } // Set multiplier value. multSlider.value = currentMult; schoolPanel.Show(); } else { // It's a school, but we're not using custom school settings, so use the non-school layout. volumetricPanel.relativePosition = new Vector2(0f, BaseCalcY); applyButton.relativePosition = new Vector2(ApplyX, BaseSaveY); schoolPanel.Hide(); } } else { // Not a school building - use non-school layout. currentSchoolPack = null; volumetricPanel.relativePosition = new Vector2(0f, BaseCalcY); applyButton.relativePosition = new Vector2(ApplyX, BaseSaveY); schoolPanel.Hide(); } } }