/// <summary>
        /// Adds header controls to the panel.
        /// </summary>
        /// <param name="yPos">Relative Y position for buttons</param>
        /// <returns>Relative Y coordinate below the finished setup</returns>
        protected override float PanelHeader(float yPos)
        {
            // Y position reference.
            float currentY = yPos + Margin;

            // Add 'Use legacy by default' header.

            // Label.
            UILabel legacyLabel = UIControls.AddLabel(panel, Margin, currentY, Translations.Translate(LegacyCheckLabel), panel.width - Margin, textScale: 0.9f);

            currentY += legacyLabel.height + 5f;

            // Use legacy by default for this save check.
            UICheckBox legacyThisSaveCheck = UIControls.LabelledCheckBox(panel, Margin * 2, currentY, Translations.Translate("RPR_DEF_LTS"));

            legacyThisSaveCheck.label.wordWrap     = true;
            legacyThisSaveCheck.label.autoSize     = false;
            legacyThisSaveCheck.label.width        = 710f;
            legacyThisSaveCheck.label.autoHeight   = true;
            legacyThisSaveCheck.isChecked          = ThisLegacyCategory;
            legacyThisSaveCheck.eventCheckChanged += (control, isChecked) =>
            {
                ThisLegacyCategory = isChecked;
                UpdateControls();
                SettingsUtils.SaveSettings();
            };

            // Use legacy by default for new saves check.
            currentY += 20f;
            UICheckBox legacyNewSaveCheck = UIControls.LabelledCheckBox(panel, Margin * 2, currentY, Translations.Translate("RPR_DEF_LAS"));

            legacyNewSaveCheck.label.wordWrap     = true;
            legacyNewSaveCheck.label.autoSize     = false;
            legacyNewSaveCheck.label.width        = 710f;
            legacyNewSaveCheck.label.autoHeight   = true;
            legacyNewSaveCheck.isChecked          = NewLegacyCategory;
            legacyNewSaveCheck.eventCheckChanged += (control, isChecked) =>
            {
                NewLegacyCategory = isChecked;
                UpdateControls();
                SettingsUtils.SaveSettings();
            };

            // Spacer bar.
            currentY += 25f;
            UIControls.OptionsSpacer(panel, Margin, currentY, panel.width - (Margin * 2f));

            return(currentY + 10f);
        }
        /// <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);
        }
예제 #3
0
        /// <summary>
        /// Create the 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>
        public void Setup()
        {
            // Generic setup.
            isVisible               = true;
            canFocus                = true;
            isInteractive           = true;
            backgroundSprite        = "UnlockingPanel";
            autoLayout              = false;
            autoLayoutDirection     = LayoutDirection.Vertical;
            autoLayoutPadding.top   = 5;
            autoLayoutPadding.right = 5;
            builtinKeyNavigation    = true;
            clipChildren            = true;

            // Panel title.
            UILabel title = this.AddUIComponent <UILabel>();

            title.relativePosition = new Vector3(0, TitleY);
            title.textAlignment    = UIHorizontalAlignment.Center;
            title.text             = Translations.Translate("RPR_CUS_TITLE");
            title.textScale        = 1.2f;
            title.autoSize         = false;
            title.width            = this.width;
            title.height           = 30;

            // Checkboxes.
            popCheck   = UIControls.LabelledCheckBox(this, 20f, PopCheckY, Translations.Translate("RPR_EDT_POP"), textScale: 1.0f);
            floorCheck = UIControls.LabelledCheckBox(this, 20f, FloorCheckY, Translations.Translate("RPR_EDT_FLR"), textScale: 1.0f);

            // Text fields.
            homeJobsCount    = AddLabelledTextfield(HomeJobY, "RPR_LBL_HOM");
            firstFloorField  = AddLabelledTextfield(FirstFloorY, "RPR_LBL_OFF");
            floorHeightField = AddLabelledTextfield(FloorHeightY, "RPR_LBL_OFH");
            homeJobLabel     = homeJobsCount.label;

            // Save button.
            saveButton         = UIControls.AddButton(this, MarginPadding, SaveY, Translations.Translate("RPR_CUS_ADD"));
            saveButton.tooltip = Translations.Translate("RPR_CUS_ADD_TIP");
            saveButton.Disable();

            // Delete button.
            deleteButton         = UIControls.AddButton(this, MarginPadding, DeleteY, Translations.Translate("RPR_CUS_DEL"));
            deleteButton.tooltip = Translations.Translate("RPR_CUS_DEL_TIP");
            deleteButton.Disable();

            // Message label (initially hidden).
            messageLabel = this.AddUIComponent <UILabel>();
            messageLabel.relativePosition = new Vector3(MarginPadding, MessageY);
            messageLabel.textAlignment    = UIHorizontalAlignment.Left;
            messageLabel.autoSize         = false;
            messageLabel.autoHeight       = true;
            messageLabel.wordWrap         = true;
            messageLabel.width            = this.width - (MarginPadding * 2);
            messageLabel.isVisible        = false;
            messageLabel.text             = "No message to display";

            // Checkbox event handlers.
            popCheck.eventCheckChanged += (component, isChecked) =>
            {
                // If this is now selected and floorCheck is also selected, deselect floorCheck.
                if (isChecked && floorCheck.isChecked)
                {
                    floorCheck.isChecked = false;
                }
            };
            floorCheck.eventCheckChanged += (component, isChecked) =>
            {
                // If this is now selected and popCheck is also selected, deselect popCheck.
                if (isChecked && popCheck.isChecked)
                {
                    popCheck.isChecked = false;
                }
            };

            // Save button event handler.
            saveButton.eventClick += (component, clickEvent) => SaveAndApply();

            // Delete button event handler.
            deleteButton.eventClick += (component, clickEvent) => DeleteOverride();
        }