/// <summary> /// Create the mod calcs panel; we no longer use Start() as that's not sufficiently reliable (race conditions), and is no longer needed, with the new create/destroy process. /// </summary> internal void Setup() { // Basic setup. clipChildren = true; // Title. title = this.AddUIComponent <UILabel>(); title.relativePosition = new Vector3(0, 0); title.textAlignment = UIHorizontalAlignment.Center; title.text = Translations.Translate("RPR_CAL_MOD"); title.textScale = 1.2f; title.autoSize = false; title.width = this.width; // Column titles. UILabel densityTitle = ColumnLabel(this, Translations.Translate("RPR_CAL_DEN"), Margin, ColumnLabelY); UILabel floorTitle = ColumnLabel(this, Translations.Translate("RPR_CAL_BFL"), RightColumnX, ColumnLabelY); // Volumetric calculations panel. volumetricPanel = this.AddUIComponent <UIVolumetricPanel>(); volumetricPanel.relativePosition = new Vector2(0f, BaseCalcY); volumetricPanel.height = this.height - title.height + 80f; volumetricPanel.width = this.width; volumetricPanel.Setup(); // Legacy calculations panel - copy volumetric calculations panel. legacyPanel = this.AddUIComponent <UILegacyCalcs>(); legacyPanel.relativePosition = volumetricPanel.relativePosition; legacyPanel.height = volumetricPanel.height; legacyPanel.width = volumetricPanel.width; legacyPanel.Setup(); legacyPanel.Hide(); // Floor dropdown panel - set size manually to avoid invisible overlap of calculations panel (preventing e.g. tooltips). floorPanel = this.AddUIComponent <UIPanel>(); floorPanel.relativePosition = new Vector2(RightColumnX, MenuY); floorPanel.autoSize = false; floorPanel.width = RightColumnX - this.width; floorPanel.height = BaseCalcY - MenuY; floorPanel.autoLayout = false; floorPanel.clipChildren = false; floorPanel.Show(); // Floor override label (for when floor dropdown menu is hidden). floorOverrideLabel = UIControls.AddLabel(this, RightColumnX, MenuY, Translations.Translate("RPR_CAL_FOV"), this.width - RightColumnX, 0.7f); floorOverrideLabel.Hide(); // Pack dropdowns. popMenu = UIControls.AddDropDown(this, Margin, MenuY, ComponentWidth); floorMenu = UIControls.AddDropDown(floorPanel, 0f, 0f, ComponentWidth); // School dropdown panel. schoolPanel = this.AddUIComponent <UIPanel>(); schoolPanel.relativePosition = new Vector2(Margin, Row2LabelY); schoolPanel.autoSize = false; schoolPanel.autoLayout = false; schoolPanel.clipChildren = false; schoolPanel.height = ApplyX - Row2LabelY; schoolPanel.width = this.width - (Margin * 2); // School panel title and dropdown menu. UILabel schoolTitle = ColumnLabel(schoolPanel, Translations.Translate("RPR_CAL_SCH_PRO"), 0, 0); schoolMenu = UIControls.AddDropDown(schoolPanel, 0f, LabelHeight, ComponentWidth); schoolPanel.Hide(); // Pack descriptions. popDescription = Description(this, Margin, DescriptionY); floorDescription = Description(floorPanel, 0f, DescriptionY - MenuY); schoolDescription = Description(schoolPanel, 0f, LabelHeight + DescriptionY - MenuY); // Apply button. applyButton = UIControls.AddButton(this, ApplyX, BaseSaveY, Translations.Translate("RPR_OPT_SAA"), ButtonWidth); applyButton.eventClicked += (control, clickEvent) => ApplySettings(); // Dropdown event handlers. popMenu.eventSelectedIndexChanged += (component, index) => UpdatePopSelection(index); floorMenu.eventSelectedIndexChanged += (component, index) => UpdateFloorSelection(index); schoolMenu.eventSelectedIndexChanged += (component, index) => UpdateSchoolSelection(index); // Add school multiplier slider (starts hidden). multSlider = AddSliderWithMultipler(schoolPanel, string.Empty, 1f, 5f, 0.5f, ModSettings.DefaultSchoolMult, (value) => UpdateMultiplier(value), ComponentWidth); multSlider.parent.relativePosition = new Vector2(RightColumnX, 10f); multSlider.parent.Hide(); // Muliplier checkbox. multCheck = UIControls.LabelledCheckBox(schoolPanel, RightColumnX, 18f, Translations.Translate("RPR_CAL_CAP_OVR")); // Multiplier default label. multDefaultLabel = UIControls.AddLabel(schoolPanel, RightColumnX + 21f, 40f, Translations.Translate("RPR_CAL_CAP_DEF") + " x" + ModSettings.DefaultSchoolMult, textScale: 0.8f); // Multplier checkbox event handler. multCheck.eventCheckChanged += (control, isChecked) => MultiplierCheckChanged(isChecked); }