Ejemplo n.º 1
0
        /// <summary>
        /// Adds education options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal LegacyPanel(UITabstrip parentTabStrip, int tabIndex)
        {
            // Add tab and helper.
            UIPanel panel = PanelUtils.AddTextTab(parentTabStrip, Translations.Translate("RPR_OPT_LEG"), tabIndex, out UIButton tabButton, 100f);

            // Button size and text scale.
            tabButton.textScale = 0.7f;

            // Add tabstrip.
            UITabstrip childTabStrip = panel.AddUIComponent <UITabstrip>();

            childTabStrip.relativePosition = new Vector3(0, 0);
            childTabStrip.size             = new Vector2(744f, 725f);

            // Tab container (the panels underneath each tab).
            UITabContainer tabContainer = panel.AddUIComponent <UITabContainer>();

            tabContainer.relativePosition = new Vector3(0, 30f);
            tabContainer.size             = new Vector3(744f, 720);
            childTabStrip.tabPages        = tabContainer;

            // Add child tabs.
            new LegacyResidentialPanel(childTabStrip, 0);
            new LegacyIndustrialPanel(childTabStrip, 1);
            new LegacyCommercialPanel(childTabStrip, 2);
            new LegacyOfficePanel(childTabStrip, 3);

            // Change tab size and text scale (to differentiate from 'main' tabstrip).
            foreach (UIButton button in childTabStrip.components)
            {
                button.textScale = 0.8f;
                button.width     = 100f;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds commercial options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        public OffConsumptionPanel(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab.
            UIPanel panel = PanelUtils.AddIconTab(tabStrip, Translations.Translate("RPR_OPT_CON"), tabIndex, tabIconNames, tabAtlasNames);

            // Initialise textfield arrays (first dimension, sub-services).
            SubServiceArrays(NumSubServices);

            // Initialise textfield arrays (second dimension, levels).
            for (int i = 0; i < NumSubServices; i++)
            {
                // Number of levels is either 3 (for the first category, generic offices), or 1 for the remainder.
                int levels = i == 0 ? NumLevels : 1;

                LevelArrays(i, levels);
            }

            // Headings.
            AddHeadings(panel);

            // Create residential per-person area textfields and labels.
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Office]), "ZoningOffice", "Thumbnails");
            AddSubService(panel, true, Office);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[HighTech]), "IconPolicyHightech", "Ingame");
            AddSubService(panel, false, HighTech, label: Translations.Translate(subServiceLables[HighTech]));

            // Populate initial values.
            PopulateFields();

            // Add command buttons.
            AddButtons(panel);
        }
        /// <summary>
        /// Updates the given calculation pack with data from the panel.
        /// </summary>
        /// <param name="pack">Pack to update</param>
        protected override void UpdatePack(DataPack pack)
        {
            if (pack is VolumetricPopPack popPack)
            {
                // Basic pack attributes.
                pack.name        = PackNameField.text;
                pack.displayName = PackNameField.text;

                // Iterate through each level, parsing input fields.
                for (int i = 0; i < maxLevels[serviceDropDown.selectedIndex]; ++i)
                {
                    // Textfields.
                    PanelUtils.ParseFloat(ref popPack.levels[i].emptyArea, emptyAreaFields[i].text);
                    PanelUtils.ParseInt(ref popPack.levels[i].emptyPercent, emptyPercentFields[i].text);

                    // Look at fixed population checkbox state to work out if we're doing fixed population or area per.
                    if (fixedPopChecks[i].isChecked)
                    {
                        // Using fixed pop: negate the 'area per' number to denote fixed population.
                        int pop = 0;
                        PanelUtils.ParseInt(ref pop, fixedPopFields[i].text);
                        popPack.levels[i].areaPer = 0 - pop;
                    }
                    else
                    {
                        // Area per unit.
                        PanelUtils.ParseFloat(ref popPack.levels[i].areaPer, areaPerFields[i].text);
                    }

                    // Checkboxes.
                    popPack.levels[i].multiFloorUnits = multiFloorChecks[i].isChecked;
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds column headings.
        /// </summary>
        /// <param name="panel">UI panel instance</param>
        protected void AddHeadings(UIPanel panel)
        {
            // Set string references (we'll reference these multiple times with the textfields, so this saves calling translate each time).
            areaLabel       = Translations.Translate(notResidential ? "RPR_OPT_APW" : "RPR_OPT_APH");
            floorLabel      = Translations.Translate("RPR_OPT_FLR");
            extraFloorLabel = Translations.Translate("RPR_CAL_FLR_M");
            powerLabel      = Translations.Translate("RPR_OPT_POW");
            waterLabel      = Translations.Translate("RPR_OPT_WAT");
            sewageLabel     = Translations.Translate("RPR_OPT_SEW");
            garbageLabel    = Translations.Translate("RPR_OPT_GAR");
            wealthLabel     = Translations.Translate("RPR_OPT_WEA");
            productionLabel = Translations.Translate("RPR_OPT_PRO");

            // Headings.
            PanelUtils.ColumnLabel(panel, Column1, TitleHeight, Column1Width + Margin, areaLabel, areaLabel, 1.0f);
            PanelUtils.ColumnLabel(panel, Column2, TitleHeight, ColumnWidth + Margin, floorLabel, floorLabel, 1.0f);
            ColumnIcon(panel, Column4, ColumnWidth, powerLabel, "ToolbarIconElectricity");
            ColumnIcon(panel, Column5, ColumnWidth, waterLabel, "ToolbarIconWaterAndSewage");
            ColumnIcon(panel, Column6, ColumnWidth, sewageLabel, "ToolbarIconWaterAndSewageDisabled");
            ColumnIcon(panel, Column7, ColumnWidth, garbageLabel, "InfoIconGarbage");
            ColumnIcon(panel, Column8, Column8Width, wealthLabel, "ToolbarIconMoney");
            ColumnIcon(panel, Column9, ColumnWidth, productionLabel, "IconPolicyAutomatedSorting");

            // Bonus floors.
            if (notResidential)
            {
                PanelUtils.ColumnLabel(panel, Column3, TitleHeight, ColumnWidth + Margin, extraFloorLabel, extraFloorLabel, 0.8f);
            }
        }
        /// <summary>
        /// Adds crime options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal CrimePanel(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab and helper.
            UIPanel  panel  = PanelUtils.AddTextTab(tabStrip, Translations.Translate("RPR_OPT_CRI"), tabIndex, out UIButton _);
            UIHelper helper = new UIHelper(panel);

            panel.autoLayout = true;

            // Add slider component.
            UISlider newSlider = UIControls.AddSlider(panel, Translations.Translate("RPR_OPT_CML"), 1f, 200f, 1f, ModSettings.crimeMultiplier);

            newSlider.tooltipBox = TooltipUtils.TooltipBox;
            newSlider.tooltip    = Translations.Translate("RPR_OPT_CML_TIP");

            // Value label.
            UIPanel sliderPanel = (UIPanel)newSlider.parent;
            UILabel valueLabel  = sliderPanel.AddUIComponent <UILabel>();

            valueLabel.name             = "ValueLabel";
            valueLabel.relativePosition = UIControls.PositionRightOf(newSlider, 8f, 1f);

            // Set initial text.
            PercentSliderText(newSlider, newSlider.value);

            // Slider change event.
            newSlider.eventValueChanged += (control, value) =>
            {
                // Update value label.
                PercentSliderText(control, value);

                // Update setting.
                ModSettings.crimeMultiplier = value;
            };
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds education options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal CalculationsPanel(UITabstrip parentTabStrip, int tabIndex)
        {
            // Instance reference.
            Instance = this;

            // Add tab and helper.
            UIPanel panel = PanelUtils.AddTextTab(parentTabStrip, Translations.Translate("RPR_PCK_NAM"), tabIndex, out UIButton _);

            panel.autoLayout = false;

            // Add tabstrip.
            UITabstrip childTabStrip = panel.AddUIComponent <UITabstrip>();

            childTabStrip.relativePosition = new Vector3(0, 0);
            childTabStrip.size             = new Vector2(744f, 725f);

            // Tab container (the panels underneath each tab).
            UITabContainer tabContainer = panel.AddUIComponent <UITabContainer>();

            tabContainer.relativePosition = new Vector3(0, 30f);
            tabContainer.size             = new Vector3(744f, 720);
            childTabStrip.tabPages        = tabContainer;

            // Add child tabs.
            int tab = 0;

            resTab = new ResidentialTab(childTabStrip, tab++);
            comTab = new CommercialTab(childTabStrip, tab++);
            offTab = new OfficeTab(childTabStrip, tab++);
            indTab = new IndustrialTab(childTabStrip, tab++);
            schTab = new SchoolTab(childTabStrip, tab++);
            new PopulationPanel(childTabStrip, tab++);
            new FloorPanel(childTabStrip, tab++);
            new LegacyPanel(childTabStrip, tab);
        }
        /// <summary>
        /// Constructor - adds editing options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal PackPanelBase(UITabstrip tabStrip, int tabIndex)
        {
            // Layout constants.
            const float TabWidth = 50f;

            // Add tab and helper.
            panel = PanelUtils.AddIconTab(tabStrip, Translations.Translate(TabTooltipKey), tabIndex, new string[] { TabSprite }, new string[] { "ingame" }, TabWidth);
        }
Ejemplo n.º 8
0
        /// <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 CalculationsPanelBase(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab and helper.
            panel = PanelUtils.AddIconTab(tabStrip, TabName, tabIndex, TabIconNames, TabAtlasNames, TabWidth);

            // Set instance.
            instance = this;
        }
Ejemplo n.º 9
0
        /// <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 GoodsPanelBase(UITabstrip tabStrip, int tabIndex) : base(tabStrip, tabIndex)
        {
            // Add title.
            float currentY = PanelUtils.TitleLabel(panel, TitleKey);

            // Add menus.
            currentY = SetUpMenus(panel, currentY);

            // Add buttons- add extra space.
            FooterButtons(currentY + Margin);
        }
        /// <summary>
        /// Adds editing options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal FloorPanel(UITabstrip tabStrip, int tabIndex) : base(tabStrip, tabIndex)
        {
            // Add title.
            float currentY = PanelUtils.TitleLabel(panel, TabTooltipKey);

            // Initialise arrays
            floorHeightField = new UITextField();
            firstMinField = new UITextField();
            firstExtraField = new UITextField();
            firstEmptyCheck = new UICheckBox();

            // Pack selection dropdown.
            packDropDown = UIControls.AddPlainDropDown(panel, Translations.Translate("RPR_OPT_CPK"), new string[0], -1);
            packDropDown.parent.relativePosition = new Vector3(20f, currentY);
            packDropDown.eventSelectedIndexChanged += PackChanged;

            // Headings.
            currentY += 140f;
            PanelUtils.ColumnLabel(panel, FloorHeightX, currentY, ColumnWidth, Translations.Translate("RPR_CAL_VOL_FLH"), Translations.Translate("RPR_CAL_VOL_FLH_TIP"), 1.0f);
            PanelUtils.ColumnLabel(panel, FirstMinX, currentY, ColumnWidth, Translations.Translate("RPR_CAL_VOL_FMN"), Translations.Translate("RPR_CAL_VOL_FMN_TIP"), 1.0f);
            PanelUtils.ColumnLabel(panel, FirstMaxX, currentY, ColumnWidth, Translations.Translate("RPR_CAL_VOL_FMX"), Translations.Translate("RPR_CAL_VOL_FMX_TIP"), 1.0f);
            PanelUtils.ColumnLabel(panel, FirstEmptyX, currentY, ColumnWidth, Translations.Translate("RPR_CAL_VOL_IGF"), Translations.Translate("RPR_CAL_VOL_IGF_TIP"), 1.0f);

            // Add level textfields.
            currentY += RowHeight;
            floorHeightField = UIControls.AddTextField(panel, FloorHeightX + Margin, currentY, width: TextFieldWidth, tooltip: Translations.Translate("RPR_CAL_VOL_FLH_TIP"));
            floorHeightField.eventTextChanged += (control, value) => PanelUtils.FloatTextFilter((UITextField)control, value);
            floorHeightField.tooltipBox = TooltipUtils.TooltipBox;

            firstMinField = UIControls.AddTextField(panel, FirstMinX + Margin, currentY, width: TextFieldWidth, tooltip: Translations.Translate("RPR_CAL_VOL_FMN_TIP"));
            firstMinField.eventTextChanged += (control, value) => PanelUtils.FloatTextFilter((UITextField)control, value);
            firstMinField.tooltipBox = TooltipUtils.TooltipBox;

            firstExtraField = UIControls.AddTextField(panel, FirstMaxX + Margin, currentY, width: TextFieldWidth, tooltip: Translations.Translate("RPR_CAL_VOL_FMX_TIP"));
            firstExtraField.eventTextChanged += (control, value) => PanelUtils.FloatTextFilter((UITextField)control, value);
            firstExtraField.tooltipBox = TooltipUtils.TooltipBox;

            firstEmptyCheck = UIControls.AddCheckBox(panel, FirstEmptyX + (ColumnWidth / 2), currentY, tooltip: Translations.Translate("RPR_CAL_VOL_IGF_TIP"));
            firstEmptyCheck.tooltipBox = TooltipUtils.TooltipBox;

            // Move to next row.
            currentY += RowHeight;

            // Add footer controls.
            PanelFooter(currentY);

            // Populate pack menu and set onitial pack selection.
            packDropDown.items = PackList();
            packDropDown.selectedIndex = 0;
        }
        /// <summary>
        /// Adds an input text field at the specified coordinates.
        /// </summary>
        /// <param name="textField">Textfield object</param>
        /// <param name="panel">panel to add to</param>
        /// <param name="posX">Relative X postion</param>
        /// <param name="posY">Relative Y position</param>
        /// <param name="tooltip">Tooltip, if any</param>
        protected UITextField AddTextField(UIPanel panel, float width, float posX, float posY, string tooltip = null)
        {
            UITextField textField = UIControls.SmallTextField(panel, posX, posY, width);

            textField.eventTextChanged += (control, value) => PanelUtils.IntTextFilter((UITextField)control, value);

            // Add tooltip.
            if (tooltip != null)
            {
                textField.tooltip = tooltip;
            }

            return(textField);
        }
 /// <summary>
 /// Updates the DataStore for a given SubService with information from text fields.
 /// </summary>
 /// <param name="dataArray">DataStore data array for the SubService</param>
 /// <param name="subService">SubService reference number</param>
 protected void ApplySubService(int[][] dataArray, int subService)
 {
     // Iterate though each level, populating each row as we go.
     for (int i = 0; i < powerFields[subService].Length; ++i)
     {
         PanelUtils.ParseInt(ref dataArray[i][DataStore.POWER], powerFields[subService][i].text);
         PanelUtils.ParseInt(ref dataArray[i][DataStore.WATER], waterFields[subService][i].text);
         PanelUtils.ParseInt(ref dataArray[i][DataStore.GARBAGE], garbageFields[subService][i].text);
         PanelUtils.ParseInt(ref dataArray[i][DataStore.SEWAGE], sewageFields[subService][i].text);
         PanelUtils.ParseInt(ref dataArray[i][DataStore.GROUND_POLLUTION], pollutionFields[subService][i].text);
         PanelUtils.ParseInt(ref dataArray[i][DataStore.NOISE_POLLUTION], noiseFields[subService][i].text);
         PanelUtils.ParseInt(ref dataArray[i][DataStore.MAIL], mailFields[subService][i].text);
         PanelUtils.ParseInt(ref dataArray[i][DataStore.INCOME], incomeFields[subService][i].text);
     }
 }
        /// <summary>
        /// Adds residential options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        public LegacyResidentialPanel(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab.
            UIPanel panel = PanelUtils.AddTextTab(tabStrip, Translations.Translate("RPR_CAT_RES"), tabIndex, out UIButton _);

            // Set residential flag.
            notResidential = false;

            // Initialise textfield array.
            SetupArrays(NumSubServices);

            for (int i = 0; i < NumSubServices; ++i)
            {
                areaFields[i]       = new UITextField[NumLevels];
                floorFields[i]      = new UITextField[NumLevels];
                powerFields[i]      = new UITextField[NumLevels];
                waterFields[i]      = new UITextField[NumLevels];
                sewageFields[i]     = new UITextField[NumLevels];
                garbageFields[i]    = new UITextField[NumLevels];
                incomeFields[i]     = new UITextField[NumLevels];
                productionFields[i] = new UITextField[NumLevels];
            }

            // Headings.
            AddHeadings(panel);

            // Move currentY up, so we can fit everything.
            currentY -= 30f;

            // Create residential per-person area textfields and labels.
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate("RPR_CAT_RLO"), "ZoningResidentialLow", "Thumbnails");
            AddSubService(panel, LowRes);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate("RPR_CAT_RHI"), "ZoningResidentialHigh", "Thumbnails");
            AddSubService(panel, HighRes);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate("RPR_CAT_ERL"), "IconPolicySelfsufficient", "Ingame");
            AddSubService(panel, LowEcoRes);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate("RPR_CAT_ERH"), "IconPolicySelfsufficient", "Ingame");
            AddSubService(panel, HighEcoRes);

            // Populate initial values.
            PopulateFields();

            // Add command buttons.
            AddButtons(panel);
        }
        /// <summary>
        /// Updates the given calculation pack with data from the panel.
        /// </summary>
        /// <param name="pack">Pack to update</param>
        protected override void UpdatePack(DataPack pack)
        {
            if (pack is FloorDataPack floorPack)
            {
                // Basic pack attributes.
                floorPack.name = PackNameField.text;
                floorPack.displayName = PackNameField.text;
                floorPack.version = (int)DataVersion.customOne;

                // Textfields.
                PanelUtils.ParseFloat(ref floorPack.floorHeight, floorHeightField.text);
                PanelUtils.ParseFloat(ref floorPack.firstFloorMin, firstMinField.text);
                PanelUtils.ParseFloat(ref floorPack.firstFloorExtra, firstExtraField.text);

                // Checkboxes.
                floorPack.firstFloorEmpty = firstEmptyCheck.isChecked;
            }
        }
        /// <summary>
        /// Adds commercial options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        public LegacyCommercialPanel(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab.
            UIPanel panel = PanelUtils.AddTextTab(tabStrip, Translations.Translate("RPR_CAT_COM"), tabIndex, out UIButton _);

            // Initialise textfield array.
            SetupArrays(NumSubServices);

            for (int i = 0; i < NumSubServices; i++)
            {
                int levels = i < 2 ? NumLevels : 1;

                areaFields[i]       = new UITextField[levels];
                floorFields[i]      = new UITextField[levels];
                extraFloorFields[i] = new UITextField[levels];
                powerFields[i]      = new UITextField[levels];
                waterFields[i]      = new UITextField[levels];
                sewageFields[i]     = new UITextField[levels];
                garbageFields[i]    = new UITextField[levels];
                incomeFields[i]     = new UITextField[levels];
                productionFields[i] = new UITextField[NumLevels];
            }

            // Headings.
            AddHeadings(panel);

            // Create residential per-person area textfields and labels.
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[LowCom]), "ZoningCommercialLow", "Thumbnails");
            AddSubService(panel, LowCom);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[HighCom]), "ZoningCommercialHigh", "Thumbnails");
            AddSubService(panel, HighCom);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[EcoCom]), "IconPolicyOrganic", "Ingame");
            AddSubService(panel, EcoCom, label: Translations.Translate("RPR_CAT_ECO"));
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Leisure]), "IconPolicyLeisure", "Ingame");
            AddSubService(panel, Leisure, label: Translations.Translate(subServiceLables[Leisure]));
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Tourist]), "IconPolicyTourist", "Ingame");
            AddSubService(panel, Tourist, label: Translations.Translate(subServiceLables[Tourist]));

            // Populate initial values.
            PopulateFields();

            // Add command buttons.
            AddButtons(panel);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Adds industrial options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        public LegacyIndustrialPanel(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab.
            UIPanel panel = PanelUtils.AddTextTab(tabStrip, Translations.Translate("RPR_CAT_IND"), tabIndex, out UIButton _);

            // Initialise textfield array.
            SetupArrays(NumSubServices);

            for (int i = 0; i < NumSubServices; i++)
            {
                int levels = i == 0 ? NumLevels : 2;

                areaFields[i]       = new UITextField[levels];
                floorFields[i]      = new UITextField[levels];
                extraFloorFields[i] = new UITextField[levels];
                powerFields[i]      = new UITextField[levels];
                waterFields[i]      = new UITextField[levels];
                sewageFields[i]     = new UITextField[levels];
                garbageFields[i]    = new UITextField[levels];
                incomeFields[i]     = new UITextField[levels];
                productionFields[i] = new UITextField[NumLevels];
            }

            // Headings.
            AddHeadings(panel);

            // Create residential per-person area textfields and labels.
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Generic]), "ZoningIndustrial", "Thumbnails");
            AddSubService(panel, Generic);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Farming]), "IconPolicyFarming", "Ingame");
            AddSubService(panel, Farming, true);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Forestry]), "IconPolicyForest", "Ingame");
            AddSubService(panel, Forestry, true);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Oil]), "IconPolicyOil", "Ingame");
            AddSubService(panel, Oil, true);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Ore]), "IconPolicyOre", "Ingame");
            AddSubService(panel, Ore, true);

            // Populate initial values.
            PopulateFields();

            // Add command buttons.
            AddButtons(panel);
        }
        /// <summary>
        /// Adds mod options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal ModOptionsPanel(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab and helper.
            UIPanel  panel  = PanelUtils.AddTextTab(tabStrip, Translations.Translate("RPR_OPT_MOD"), tabIndex, out UIButton _);
            UIHelper helper = new UIHelper(panel);

            panel.autoLayout = true;

            // Language dropdown.
            UIDropDown languageDrop = UIControls.AddPlainDropDown(panel, Translations.Translate("TRN_CHOICE"), Translations.LanguageList, Translations.Index);

            languageDrop.eventSelectedIndexChanged += (control, index) =>
            {
                Translations.Index = index;
                SettingsUtils.SaveSettings();
            };

            // Hotkey control.
            panel.gameObject.AddComponent <OptionsKeymapping>();
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Sets up the defaults dropdown menus.
        /// </summary>
        /// <param name="panel">Panel reference</param>
        /// <param name="yPos">Relative Y position for buttons</param>
        /// <returns>Relative Y coordinate below the finished setup</returns>
        private float SetUpMenus(UIPanel panel, float yPos)
        {
            // Starting y position.
            float currentY = yPos + Margin;

            for (int i = 0; i < SubServiceNames.Length; ++i)
            {
                // Row icon and label.
                PanelUtils.RowHeaderIcon(panel, ref currentY, SubServiceNames[i], IconNames[i], AtlasNames[i]);

                // Add any additional controls.
                currentY = SubServiceControls(currentY, i);

                // Next row.
                currentY += RowHeight + Margin;
            }

            // Return finishing Y position.
            return(currentY);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Adds options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal CalculationsTabBase(UITabstrip parentTabStrip, int tabIndex)
        {
            // Add tab and helper.
            UIPanel panel = PanelUtils.AddIconTab(parentTabStrip, Tooltip, tabIndex, IconNames, AtlasNames, TabWidth);

            // Add tabstrip.
            UITabstrip childTabStrip = panel.AddUIComponent <UITabstrip>();

            childTabStrip.relativePosition = new Vector3(0, 0);
            childTabStrip.size             = new Vector2(744f, 725f);

            // Tab container (the panels underneath each tab).
            UITabContainer tabContainer = panel.AddUIComponent <UITabContainer>();

            tabContainer.relativePosition = new Vector3(0, 30f);
            tabContainer.size             = new Vector3(744f, 720);
            childTabStrip.tabPages        = tabContainer;

            // Add child tabs.
            AddTabs(childTabStrip);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Updates the DataStore for a given SubService with information from text fields.
        /// </summary>
        /// <param name="dataArray">DataStore data array for the SubService</param>
        /// <param name="subService">SubService reference number</param>
        protected void ApplySubService(int[][] dataArray, int subService)
        {
            // Iterate though each level, populating each row as we go.
            for (int i = 0; i < areaFields[subService].Length; ++i)
            {
                PanelUtils.ParseInt(ref dataArray[i][DataStore.PEOPLE], areaFields[subService][i].text);
                PanelUtils.ParseInt(ref dataArray[i][DataStore.LEVEL_HEIGHT], floorFields[subService][i].text);
                PanelUtils.ParseInt(ref dataArray[i][DataStore.POWER], powerFields[subService][i].text);
                PanelUtils.ParseInt(ref dataArray[i][DataStore.WATER], waterFields[subService][i].text);
                PanelUtils.ParseInt(ref dataArray[i][DataStore.SEWAGE], sewageFields[subService][i].text);
                PanelUtils.ParseInt(ref dataArray[i][DataStore.GARBAGE], garbageFields[subService][i].text);
                PanelUtils.ParseInt(ref dataArray[i][DataStore.INCOME], incomeFields[subService][i].text);
                PanelUtils.ParseInt(ref dataArray[i][DataStore.PRODUCTION], productionFields[subService][i].text);

                // Extra floor field, if applicable.
                if (!(this is LegacyResidentialPanel))
                {
                    PanelUtils.ParseInt(ref dataArray[i][DataStore.DENSIFICATION], extraFloorFields[subService][i].text);
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Sets up the defaults dropdown menus.
        /// </summary>
        /// <param name="yPos">Relative Y position for buttons</param>
        /// <returns>Relative Y coordinate below the finished setup</returns>
        private float SetUpMenus(float yPos)
        {
            // Layout constants.
            const float LeftColumn = 200f;
            const float MenuWidth  = 300f;

            // Starting y position.
            float currentY = yPos + Margin;

            for (int i = 0; i < SubServiceNames.Length; ++i)
            {
                // Row icon and label.
                PanelUtils.RowHeaderIcon(panel, ref currentY, SubServiceNames[i], IconNames[i], AtlasNames[i]);

                // Pop pack dropdown.
                PopMenus[i] = UIControls.AddLabelledDropDown(panel, LeftColumn, currentY, Translations.Translate("RPR_CAL_DEN"), MenuWidth, height: 20f, itemVertPadding: 6, accomodateLabel: false);

                // Save current index in object user data.
                PopMenus[i].objectUserData = i;

                // Event handler.
                PopMenus[i].eventSelectedIndexChanged += PopMenuChanged;

                // Floor pack on next row.
                currentY += RowHeight;

                // Floor pack dropdown.
                FloorMenus[i] = UIControls.AddLabelledDropDown(panel, LeftColumn, currentY, Translations.Translate("RPR_CAL_BFL"), MenuWidth, height: 20f, itemVertPadding: 6, accomodateLabel: false);

                // Add any additional controls.
                currentY = RowAdditions(currentY, i);


                // Next row.
                currentY += RowHeight + Margin;
            }

            // Return finishing Y position.
            return(currentY);
        }
        /// <summary>
        /// Adds residential options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        public ResConsumptionPanel(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab.
            UIPanel panel = PanelUtils.AddIconTab(tabStrip, Translations.Translate("RPR_OPT_CON"), tabIndex, tabIconNames, tabAtlasNames);

            // Set residential flag.
            notResidential = false;

            // Initialise textfield arrays (first dimension, sub-services).
            SubServiceArrays(NumSubServices);

            // Initialise textfield arrays (second dimension, levels - five each).
            for (int i = 0; i < NumSubServices; ++i)
            {
                LevelArrays(i, NumLevels);
            }

            // Headings.
            AddHeadings(panel);

            // Move currentY up, so we can fit everything.
            currentY -= 30f;

            // Create residential per-person area textfields and labels.
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate("RPR_CAT_RLO"), "ZoningResidentialLow", "Thumbnails");
            AddSubService(panel, true, LowRes);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate("RPR_CAT_RHI"), "ZoningResidentialHigh", "Thumbnails");
            AddSubService(panel, true, HighRes);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate("RPR_CAT_ERL"), "IconPolicySelfsufficient", "Ingame");
            AddSubService(panel, true, LowEcoRes);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate("RPR_CAT_ERH"), "IconPolicySelfsufficient", "Ingame");
            AddSubService(panel, true, HighEcoRes);

            // Populate initial values.
            PopulateFields();

            // Add command buttons.
            AddButtons(panel);
        }
        /// <summary>
        /// Adds industrial options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        public IndConsumptionPanel(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab.
            UIPanel panel = PanelUtils.AddIconTab(tabStrip, Translations.Translate("RPR_OPT_CON"), tabIndex, tabIconNames, tabAtlasNames);

            // Initialise textfield arrays (first dimension, sub-services).
            SubServiceArrays(NumSubServices);

            // Initialise textfield arrays (second dimension, levels).
            for (int i = 0; i < NumSubServices; i++)
            {
                // Number of levels is either 3 (for the first category, generic industry), or 2 for the remainder.
                int levels = i == 0 ? NumLevels : 2;

                LevelArrays(i, levels);
            }

            // Headings.
            AddHeadings(panel);

            // Create residential per-person area textfields and labels.
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Generic]), "ZoningIndustrial", "Thumbnails");
            AddSubService(panel, true, Generic);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Farming]), "IconPolicyFarming", "Ingame");
            AddSubService(panel, false, Farming, true);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Forestry]), "IconPolicyForest", "Ingame");
            AddSubService(panel, false, Forestry, true);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Oil]), "IconPolicyOil", "Ingame");
            AddSubService(panel, false, Oil, true);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Ore]), "IconPolicyOre", "Ingame");
            AddSubService(panel, false, Ore, true);

            // Populate initial values.
            PopulateFields();

            // Add command buttons.
            AddButtons(panel);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Adds commercial options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        public LegacyOfficePanel(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab.
            UIPanel panel = PanelUtils.AddTextTab(tabStrip, Translations.Translate("RPR_CAT_OFF"), tabIndex, out UIButton _);

            // Initialise textfield array.
            SetupArrays(NumSubServices);

            for (int i = 0; i < NumSubServices; i++)
            {
                int levels = i == 0 ? NumLevels : 1;

                areaFields[i]       = new UITextField[levels];
                floorFields[i]      = new UITextField[levels];
                extraFloorFields[i] = new UITextField[levels];
                powerFields[i]      = new UITextField[levels];
                waterFields[i]      = new UITextField[levels];
                sewageFields[i]     = new UITextField[levels];
                garbageFields[i]    = new UITextField[levels];
                incomeFields[i]     = new UITextField[levels];
                productionFields[i] = new UITextField[NumLevels];
            }

            // Headings.
            AddHeadings(panel);

            // Create residential per-person area textfields and labels.
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Office]), "ZoningOffice", "Thumbnails");
            AddSubService(panel, Office);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[HighTech]), "IconPolicyHightech", "Ingame");
            AddSubService(panel, HighTech, label: Translations.Translate(subServiceLables[HighTech]));

            // Populate initial values.
            PopulateFields();

            // Add command buttons.
            AddButtons(panel);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Adds commercial options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        public ComConsumptionPanel(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab.
            UIPanel panel = PanelUtils.AddIconTab(tabStrip, Translations.Translate("RPR_OPT_CON"), tabIndex, tabIconNames, tabAtlasNames);

            // Initialise textfield arrays (first dimension, sub-services).
            SubServiceArrays(NumSubServices);

            // Initialise textfield arrays (second dimension, levels).
            for (int i = 0; i < NumSubServices; i++)
            {
                // Number of levels is either 3 (for the first two categories, low and high com), or 1 for the remainder.
                int levels = i < 2 ? NumLevels : 1;

                LevelArrays(i, levels);
            }

            // Headings.
            AddHeadings(panel);

            // Create residential per-person area textfields and labels.
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[LowCom]), "ZoningCommercialLow", "Thumbnails");
            AddSubService(panel, true, LowCom);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[HighCom]), "ZoningCommercialHigh", "Thumbnails");
            AddSubService(panel, true, HighCom);
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[EcoCom]), "IconPolicyOrganic", "Ingame");
            AddSubService(panel, false, EcoCom, label: Translations.Translate("RPR_CAT_ECO"));
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Leisure]), "IconPolicyLeisure", "Ingame");
            AddSubService(panel, false, Leisure, label: Translations.Translate(subServiceLables[Leisure]));
            PanelUtils.RowHeaderIcon(panel, ref currentY, Translations.Translate(subServiceLables[Tourist]), "IconPolicyTourist", "Ingame");
            AddSubService(panel, false, Tourist, label: Translations.Translate(subServiceLables[Tourist]));

            // Populate initial values.
            PopulateFields();

            // Add command buttons.
            AddButtons(panel);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Adds school options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal EducationPanel(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab and helper.
            UIPanel  panel  = PanelUtils.AddTextTab(tabStrip, Translations.Translate("RPR_OPT_SCH"), tabIndex, out UIButton _);
            UIHelper helper = new UIHelper(panel);

            panel.autoLayout = true;

            // Enable realistic schools checkbox.
            UICheckBox schoolCapacityCheck = UIControls.AddPlainCheckBox(panel, Translations.Translate("RPR_OPT_SEN"));

            schoolCapacityCheck.isChecked          = ModSettings.enableSchoolPop;
            schoolCapacityCheck.eventCheckChanged += (control, isChecked) => ModSettings.enableSchoolPop = isChecked;

            // Enable realistic schools checkbox.
            UICheckBox schoolPropertyCheck = UIControls.AddPlainCheckBox(panel, Translations.Translate("RPR_OPT_SEJ"));

            schoolPropertyCheck.isChecked          = ModSettings.enableSchoolProperties;
            schoolPropertyCheck.eventCheckChanged += (control, isChecked) => ModSettings.enableSchoolProperties = isChecked;

            // School default multiplier.  Simple integer.
            UISlider schoolMult = UIControls.AddSliderWithValue(panel, Translations.Translate("RPR_OPT_SDM"), 1f, 5f, 0.5f, ModSettings.DefaultSchoolMult, (value) => { ModSettings.DefaultSchoolMult = value; });
        }
Ejemplo n.º 27
0
        /// <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>
        /// Adds editing options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal PopulationPanel(UITabstrip tabStrip, int tabIndex) : base(tabStrip, tabIndex)
        {
            // Add title.
            float currentY = PanelUtils.TitleLabel(panel, TabTooltipKey);

            // Initialise arrays
            emptyAreaFields    = new UITextField[5];
            emptyPercentFields = new UITextField[5];
            fixedPopChecks     = new UICheckBox[5];
            fixedPopFields     = new UITextField[5];
            areaPerFields      = new UITextField[5];
            multiFloorChecks   = new UICheckBox[5];
            rowLabels          = new UILabel[5];

            // Service selection dropdown.
            serviceDropDown = UIControls.AddPlainDropDown(panel, Translations.Translate("RPR_OPT_SVC"), serviceNames, -1);
            serviceDropDown.parent.relativePosition    = new Vector3(20f, currentY);
            serviceDropDown.eventSelectedIndexChanged += ServiceChanged;

            // Pack selection dropdown.
            packDropDown = UIControls.AddPlainDropDown(panel, Translations.Translate("RPR_OPT_CPK"), new string[0], -1);
            currentY    += 70f;
            packDropDown.parent.relativePosition    = new Vector3(20f, currentY);
            packDropDown.eventSelectedIndexChanged += PackChanged;

            // Label strings - cached to avoid calling Translations.Translate each time (for the tooltips, anwyay, including the others makes code more readable).
            string emptyArea       = Translations.Translate("RPR_CAL_VOL_EMP");
            string emptyAreaTip    = Translations.Translate("RPR_CAL_VOL_EMP_TIP");
            string emptyPercent    = Translations.Translate("RPR_CAL_VOL_EPC");
            string emptyPercentTip = Translations.Translate("RPR_CAL_VOL_EPC_TIP");
            string useFixedPop     = Translations.Translate("RPR_CAL_VOL_FXP");
            string useFixedPopTip  = Translations.Translate("RPR_CAL_VOL_FXP_TIP");
            string fixedPop        = Translations.Translate("RPR_CAL_VOL_UNI");
            string fixedPopTip     = Translations.Translate("RPR_CAL_VOL_UNI_TIP");
            string areaPer         = Translations.Translate("RPR_CAL_VOL_APU");
            string areaPerTip      = Translations.Translate("RPR_CAL_VOL_APU_TIP");
            string multiFloor      = Translations.Translate("RPR_CAL_VOL_MFU");
            string multiFloorTip   = Translations.Translate("RPR_CAL_VOL_MFU_TIP");

            // Headings.
            currentY += 140f;
            PanelUtils.ColumnLabel(panel, EmptyAreaX, currentY, ColumnWidth, emptyArea, emptyAreaTip, 1.0f);
            PanelUtils.ColumnLabel(panel, EmptyPercentX, currentY, ColumnWidth, emptyPercent, emptyPercentTip, 1.0f);
            PanelUtils.ColumnLabel(panel, PopCheckX, currentY, ColumnWidth, useFixedPop, useFixedPopTip, 1.0f);
            PanelUtils.ColumnLabel(panel, FixedPopX, currentY, ColumnWidth, fixedPop, fixedPopTip, 1.0f);
            PanelUtils.ColumnLabel(panel, AreaPerX, currentY, ColumnWidth, areaPer, areaPerTip, 1.0f);
            PanelUtils.ColumnLabel(panel, MultiFloorX, currentY, ColumnWidth, multiFloor, multiFloorTip, 1.0f);

            // Add level textfields.
            for (int i = 0; i < 5; ++i)
            {
                // Row label.
                rowLabels[i] = RowLabel(panel, currentY, Translations.Translate("RPR_OPT_LVL") + " " + (i + 1).ToString());

                emptyPercentFields[i] = UIControls.AddTextField(panel, EmptyPercentX + Margin, currentY, width: TextFieldWidth, tooltip: emptyPercentTip);
                emptyPercentFields[i].eventTextChanged += (control, value) => PanelUtils.IntTextFilter((UITextField)control, value);
                emptyPercentFields[i].tooltipBox        = TooltipUtils.TooltipBox;

                emptyAreaFields[i] = UIControls.AddTextField(panel, EmptyAreaX + Margin, currentY, width: TextFieldWidth, tooltip: emptyAreaTip);
                emptyAreaFields[i].eventTextChanged += (control, value) => PanelUtils.FloatTextFilter((UITextField)control, value);
                emptyAreaFields[i].tooltipBox        = TooltipUtils.TooltipBox;

                // Fixed pop checkboxes - ensure i is saved as objectUserData for use by event handler.  Starts unchecked by default.
                fixedPopChecks[i] = UIControls.AddCheckBox(panel, PopCheckX + (ColumnWidth / 2), currentY, tooltip: useFixedPopTip);
                fixedPopChecks[i].objectUserData     = i;
                fixedPopChecks[i].eventCheckChanged += FixedPopCheckChanged;
                fixedPopChecks[i].tooltipBox         = TooltipUtils.TooltipBox;

                // Fixed population fields start hidden by default.
                fixedPopFields[i] = UIControls.AddTextField(panel, FixedPopX + Margin, currentY, width: TextFieldWidth, tooltip: fixedPopTip);
                fixedPopFields[i].eventTextChanged += (control, value) => PanelUtils.IntTextFilter((UITextField)control, value);
                fixedPopFields[i].tooltipBox        = TooltipUtils.TooltipBox;
                fixedPopFields[i].Hide();

                areaPerFields[i] = UIControls.AddTextField(panel, AreaPerX + Margin, currentY, width: TextFieldWidth, tooltip: areaPerTip);
                areaPerFields[i].eventTextChanged += (control, value) => PanelUtils.FloatTextFilter((UITextField)control, value);
                areaPerFields[i].tooltipBox        = TooltipUtils.TooltipBox;

                multiFloorChecks[i]            = UIControls.AddCheckBox(panel, MultiFloorX + (ColumnWidth / 2), currentY, tooltip: multiFloorTip);
                multiFloorChecks[i].tooltipBox = TooltipUtils.TooltipBox;

                // Move to next row.
                currentY += RowHeight;
            }

            // Add footer controls.
            PanelFooter(currentY);

            // Set service menu to initial state (residential), which will also update textfield visibility via event handler.
            serviceDropDown.selectedIndex = 0;
        }