/// <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> /// Adds a sub-service field group to the panel. /// </summary> /// <param name="panel">UI panel instance</param> /// <param name="subService">Subservice reference number</param> /// <param name="isExtract">Set this to true (and label to null) to add extractor/processor labels (default false, which is plain level labels)</param> /// <param name="label">Text label base for each row; null (default) to use level numbers or extractor/prcessor</param> protected void AddSubService(UIPanel panel, bool _, int subService, bool isExtract = false, string label = null) { // Add a row for each level within this subservice. for (int i = 0; i < powerFields[subService].Length; ++i) { // Row label. RowLabel(panel, currentY, label ?? (isExtract ? Translations.Translate(i == 0 ? "RPR_CAT_EXT" : "RPR_CAT_PRO") : Translations.Translate("RPR_OPT_LVL") + " " + (i + 1).ToString())); // Textfields. powerFields[subService][i] = AddTextField(panel, ColumnWidth, PowerX, currentY, powerLabel); waterFields[subService][i] = AddTextField(panel, ColumnWidth, WaterX, currentY, waterLabel); garbageFields[subService][i] = AddTextField(panel, ColumnWidth, GarbageX, currentY, garbageLabel); sewageFields[subService][i] = AddTextField(panel, ColumnWidth, SewageX, currentY, sewageLabel); pollutionFields[subService][i] = AddTextField(panel, ColumnWidth, PollutionX, currentY, pollutionLabel); noiseFields[subService][i] = AddTextField(panel, ColumnWidth, NoiseX, currentY, noiseLabel); mailFields[subService][i] = AddTextField(panel, ColumnWidth, MailX, currentY, mailLabel); incomeFields[subService][i] = AddTextField(panel, WideColumnWidth, IncomeX, currentY, wealthLabel); // Increment Y position. currentY += RowHeight; } // Add an extra bit of space at the end. currentY += Margin; }
/// <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; }; }
/// <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 a sub-service field group to the panel. /// </summary> /// <param name="panel">UI panel instance</param> /// <param name="subService">Subservice reference number</param> /// <param name="isExtract">Set this to true (and label to null) to add extractor/processor labels (default false, which is plain level labels)</param> /// <param name="label">Text label base for each row; null (default) to use level numbers or extractor/prcessor</param> protected void AddSubService(UIPanel panel, int subService, bool isExtract = false, string label = null) { // Add a row for each level within this subservice. for (int i = 0; i < areaFields[subService].Length; ++i) { // Row label. RowLabel(panel, currentY, label ?? (isExtract ? Translations.Translate(i == 0 ? "RPR_CAT_EXT" : "RPR_CAT_PRO") : Translations.Translate("RPR_OPT_LVL") + " " + (i + 1).ToString())); // Textfields. areaFields[subService][i] = AddTextField(panel, Column1Width, Column1, currentY, areaLabel); floorFields[subService][i] = AddTextField(panel, ColumnWidth, Column2, currentY, floorLabel); powerFields[subService][i] = AddTextField(panel, ColumnWidth, Column4, currentY, powerLabel); waterFields[subService][i] = AddTextField(panel, ColumnWidth, Column5, currentY, waterLabel); sewageFields[subService][i] = AddTextField(panel, ColumnWidth, Column6, currentY, sewageLabel); garbageFields[subService][i] = AddTextField(panel, ColumnWidth, Column7, currentY, garbageLabel); incomeFields[subService][i] = AddTextField(panel, Column8Width, Column8, currentY, wealthLabel); productionFields[subService][i] = AddTextField(panel, ColumnWidth, Column9, currentY, productionLabel); // Bonus levels. if (notResidential) { extraFloorFields[subService][i] = AddTextField(panel, ColumnWidth, Column3, currentY, extraFloorLabel); } // Increment Y position. currentY += RowHeight; } // Add an extra bit of space at the end. currentY += Margin; }
/// <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; } }
/// <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> /// Adds panel footer controls (pack name textfield and buttons). /// </summary> /// <param name="yPos">Reference Y position</param> protected void PanelFooter(float yPos) { // Additional space before name textfield. float currentY = yPos + RowHeight; // Pack name textfield. PackNameField = UIControls.BigTextField(panel, 140f, currentY); PackNameField.isEnabled = false; UILabel packNameLabel = UIControls.AddLabel(PackNameField, -100f, (PackNameField.height - 18f) / 2, Translations.Translate("RPR_OPT_EDT_NAM")); // Space for buttons. currentY += 50f; // 'Add new' button. UIButton addNewButton = UIControls.AddButton(panel, 20f, currentY, Translations.Translate("RPR_OPT_NEW")); addNewButton.eventClicked += AddPack; // Save pack button. saveButton = UIControls.AddButton(panel, 250f, currentY, Translations.Translate("RPR_OPT_SAA")); saveButton.eventClicked += Save; // Delete pack button. deleteButton = UIControls.AddButton(panel, 480f, currentY, Translations.Translate("RPR_OPT_DEL")); deleteButton.eventClicked += DeletePack; }
/// <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); }
/// <summary> /// Render and show a preview of a building. /// </summary> /// <param name="building">The building to render</param> public void Show(BuildingInfo building) { // Update current selection to the new building. currentSelection = building; // Generate render if there's a selection with a mesh. if (currentSelection != null && currentSelection.m_mesh != null) { // Set default values. previewRender.CameraRotation = 210f; previewRender.Zoom = 4f; // Set mesh and material for render. previewRender.SetTarget(currentSelection); // Set background. previewSprite.texture = previewRender.Texture; noPreviewSprite.isVisible = false; // Render at next update. RenderPreview(); } else { // No valid current selection with a mesh; reset background. previewSprite.texture = null; noPreviewSprite.isVisible = true; } // Hide any empty building names. if (building == null) { buildingName.isVisible = false; buildingLevel.isVisible = false; buildingSize.isVisible = false; } else { // Set and show building name. buildingName.isVisible = true; buildingName.text = UIBuildingDetails.GetDisplayName(currentSelection.name); UIUtils.TruncateLabel(buildingName, width - 45); buildingName.autoHeight = true; // Set and show building level. buildingLevel.isVisible = true; buildingLevel.text = Translations.Translate("RPR_OPT_LVL") + " " + Mathf.Min((int)currentSelection.GetClassLevel() + 1, MaxLevelOf(currentSelection.GetSubService())); UIUtils.TruncateLabel(buildingLevel, width - 45); buildingLevel.autoHeight = true; // Set and show building size. buildingSize.isVisible = true; buildingSize.text = currentSelection.GetWidth() + "x" + currentSelection.GetLength(); UIUtils.TruncateLabel(buildingSize, width - 45); buildingSize.autoHeight = true; } }
/// <summary> /// Adds a settings check to the current row. /// </summary> /// <param name="xPos">Check relative x-position</param> /// <param name="translationKey">Tooltip translation key</param> /// <returns></returns> private UISprite AddSettingsCheck(float xPos, string translationKey) { UISprite newSprite = AddUIComponent <UISprite>(); newSprite.size = new Vector2(20, 20); newSprite.relativePosition = new Vector3(xPos, 5f); newSprite.tooltip = Translations.Translate(translationKey); return(newSprite); }
/// <summary> /// 'Add new pack' button event handler. /// </summary> /// <param name="control">Calling component (unused)</param> /// <param name="mouseEvent">Mouse event (unused)</param> protected override void AddPack(UIComponent control, UIMouseEventParameter mouseEvent) { // Default new pack name. string basePackName = Translations.Translate("RPR_OPT_NPK"); string newPackName = basePackName; // Integer suffix for when the above name already exists (starts with 2). int packNum = 2; // Current service. ItemClass.Service currentService = services[serviceDropDown.selectedIndex]; // Starting with our default new pack name, check to see if we already have a pack with this name for the currently selected service. while (PopData.instance.calcPacks.Find(pack => ((PopDataPack)pack).service == currentService && pack.name.Equals(newPackName)) != null) { // We already have a match for this name; append the current integer suffix to the base name and try again, incementing the integer suffix for the next attempt (if required). newPackName = "New pack " + packNum++; } // We now have a unique name; set the textfield. PackNameField.text = newPackName; // Add new pack with basic values (deails will be populated later). VolumetricPopPack newPack = new VolumetricPopPack { version = (int)DataVersion.customOne, service = services[serviceDropDown.selectedIndex], levels = new LevelData[maxLevels[serviceDropDown.selectedIndex]] }; // Update pack with information from the panel. UpdatePack(newPack); // Add our new pack to our list of packs and update defaults panel menus. PopData.instance.AddCalculationPack(newPack); CalculationsPanel.Instance.UpdateDefaultMenus(); // Update pack menu. packDropDown.items = PackList(currentService); // Set pack selection by iterating through each pack in the menu and looking for a match. for (int i = 0; i < packDropDown.items.Length; ++i) { if (packDropDown.items[i].Equals(newPack.displayName)) { // Got a match; apply selected index and stop looping. packDropDown.selectedIndex = i; break; } } // Save configuration file. ConfigUtils.SaveSettings(); }
/// <summary> /// Adds footer buttons to the panel. /// </summary> /// <param name="yPos">Relative Y position for buttons</param> protected virtual void FooterButtons(float yPos) { // Reset button. UIButton resetButton = UIControls.AddButton(panel, Margin, yPos, Translations.Translate("RPR_OPT_RTD"), 150f); resetButton.eventClicked += ResetDefaults; // Revert button. UIButton revertToSaveButton = UIControls.AddButton(panel, (Margin * 2) + 150f, yPos, Translations.Translate("RPR_OPT_RTS"), 150f); revertToSaveButton.eventClicked += ResetSaved; }
/// <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 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> /// Adds a title label across the top of the specified UIComponent. /// </summary> /// <param name="parent">Parent component</param> /// <param name="titleKey">Title translation key</param> /// <returns>Y position below title</returns> internal static float TitleLabel(UIComponent parent, string titleKey) { // Margin. const float Margin = 5f; // Add title. UILabel titleLabel = UIControls.AddLabel(parent, 0f, Margin, Translations.Translate(titleKey), parent.width, 1.5f); titleLabel.textAlignment = UIHorizontalAlignment.Center; titleLabel.font = Resources.FindObjectsOfTypeAll <UIFont>().FirstOrDefault((UIFont f) => f.name == "OpenSans-Semibold"); UIControls.OptionsSpacer(parent, Margin, titleLabel.height + (Margin * 2f), parent.width - (Margin * 2f)); return(Margin + titleLabel.height + Margin + 5f + Margin); }
/// <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> /// Adds control buttons to the bottom of the panel. /// </summary> /// <param name="panel">UI panel instance</param> protected void AddButtons(UIPanel panel) { // Add extra space. currentY += Margin; // Reset button. UIButton resetButton = UIControls.AddButton(panel, Margin, currentY, Translations.Translate("RPR_OPT_RTD"), 150f); resetButton.eventClicked += (component, clickEvent) => ResetToDefaults(); UIButton revertToSaveButton = UIControls.AddButton(panel, (Margin * 2) + 150f, currentY, Translations.Translate("RPR_OPT_RTS"), 150f); revertToSaveButton.eventClicked += (component, clickEvent) => { XMLUtilsWG.ReadFromXML(); PopulateFields(); }; UIButton saveButton = UIControls.AddButton(panel, (Margin * 3) + 300f, currentY, Translations.Translate("RPR_OPT_SAA"), 150f); saveButton.eventClicked += (component, clickEvent) => ApplyFields(); }
/// <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 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); }
/// <summary> /// Adds a textfield with a label to the left. /// </summary> /// <param name="yPos">Relative y-position of textfield</param> /// <param name="key">Translation key for label</param> /// <returns></returns> private UILabelledTextfield AddLabelledTextfield(float yPos, string key) { // Create textfield. UILabelledTextfield newField = new UILabelledTextfield { textField = UIControls.AddTextField(this, MarginPadding + LabelWidth + MarginPadding, yPos, width: this.width - (MarginPadding * 3) - LabelWidth) }; newField.textField.clipChildren = false; // Label. newField.label = newField.textField.AddUIComponent <UILabel>(); newField.label.anchor = UIAnchorStyle.Right | UIAnchorStyle.CenterVertical; newField.label.relativePosition = new Vector2(-MarginPadding * 2f, newField.textField.height / 2); newField.label.textAlignment = UIHorizontalAlignment.Right; newField.label.textScale = 0.7f; newField.label.text = Translations.Translate(key); return(newField); }
/// <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>(); }
/// <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 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). powerLabel = Translations.Translate("RPR_OPT_POW"); waterLabel = Translations.Translate("RPR_OPT_WAT"); garbageLabel = Translations.Translate("RPR_OPT_GAR"); sewageLabel = Translations.Translate("RPR_OPT_SEW"); pollutionLabel = Translations.Translate("RPR_OPT_POL"); noiseLabel = Translations.Translate("RPR_OPT_NOI"); mailLabel = Translations.Translate("RPR_OPT_MAI"); wealthLabel = Translations.Translate("RPR_OPT_WEA"); // Headings. ColumnIcon(panel, PowerX, ColumnWidth, powerLabel, "ToolbarIconElectricity"); ColumnIcon(panel, WaterX, ColumnWidth, waterLabel, "ToolbarIconWaterAndSewage"); ColumnIcon(panel, GarbageX, ColumnWidth, garbageLabel, "InfoIconGarbage"); ColumnIcon(panel, SewageX, ColumnWidth, sewageLabel, "IconPolicyFilterIndustrialWaste"); ColumnIcon(panel, PollutionX, ColumnWidth, pollutionLabel, "InfoIconPollution"); ColumnIcon(panel, NoiseX, ColumnWidth, noiseLabel, "InfoIconNoisePollution"); ColumnIcon(panel, MailX, ColumnWidth, mailLabel, "InfoIconPost"); ColumnIcon(panel, IncomeX, WideColumnWidth, wealthLabel, "ToolbarIconMoney"); }
/// <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); }
/// <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); }
/// <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); }
/// <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; }); }
/// <summary> /// Constructor - initializes inbuilt default calculation packs and performs other setup tasks. /// </summary> public SchoolData() { // Vanilla elementary. SchoolDataPack newPack = new SchoolDataPack { name = "vanelem", displayName = Translations.Translate("RPR_PCK_SVE_NAM"), description = Translations.Translate("RPR_PCK_SVE_DES"), version = (int)DataVersion.one, level = ItemClass.Level.Level1, baseWorkers = new int[] { 1, 2, 1, 0 }, perWorker = new int[] { 20, 50, 300, 0 }, baseCost = 1000, costPer = 30, baseMaint = 100, maintPer = 3 }; calcPacks.Add(newPack); // Vanilla community school. newPack = new SchoolDataPack { name = "vancom", displayName = Translations.Translate("RPR_PCK_SVC_NAM"), description = Translations.Translate("RPR_PCK_SVC_DES"), version = (int)DataVersion.one, level = ItemClass.Level.Level1, baseWorkers = new int[] { 2, 2, 1, 1 }, perWorker = new int[] { 25, 25, 50, 0 }, baseCost = 2000, costPer = 40, baseMaint = 250, maintPer = 5 }; calcPacks.Add(newPack); // Vanilla high school. newPack = new SchoolDataPack { name = "vanhigh", displayName = Translations.Translate("RPR_PCK_SVH_NAM"), description = Translations.Translate("RPR_PCK_SVH_DES"), version = (int)DataVersion.one, level = ItemClass.Level.Level2, baseWorkers = new int[] { 9, 11, 5, 1 }, perWorker = new int[] { 100, 20, 100, 250 }, baseCost = 4000, costPer = 20, baseMaint = 500, maintPer = 3 }; calcPacks.Add(newPack); // Vanilla art school. newPack = new SchoolDataPack { name = "vanart", displayName = Translations.Translate("RPR_PCK_SVA_NAM"), description = Translations.Translate("RPR_PCK_SVA_DES"), version = (int)DataVersion.one, level = ItemClass.Level.Level2, baseWorkers = new int[] { 10, 20, 5, 1 }, perWorker = new int[] { 80, 20, 80, 200 }, baseCost = 6000, costPer = 30, baseMaint = 500, maintPer = 5 }; calcPacks.Add(newPack); }
/// <summary> /// Adds a slider. /// </summary> /// <param name="parent">Parent component</param> /// <param name="xPos">Relative X position</param> /// <param name="yPos">Relative Y position</param> /// <param name="width">Slider width</param> /// <param name="tooltipKey">Tooltip translation key</param> /// <param name="isPercent">True if this slider should display percentage values, false to display absolute values</param> /// <returns>New slider</returns> protected UISlider AddSlider(UIComponent parent, float xPos, float yPos, float width, string tooltipKey, bool isPercent = true) { // Layout constants. const float SliderPanelHeight = 20f; const float SliderHeight = 6f; const float ValueLabelWidth = 45f; const float OffsetX = (SliderPanelHeight - SliderHeight) / 2f; // Mutiplier slider panel. UIPanel sliderPanel = parent.AddUIComponent <UIPanel>(); sliderPanel.autoSize = false; sliderPanel.autoLayout = false; sliderPanel.size = new Vector2(width, SliderPanelHeight); sliderPanel.relativePosition = new Vector2(xPos, yPos); // Mutiplier slider value label. UILabel valueLabel = sliderPanel.AddUIComponent <UILabel>(); valueLabel.name = "ValueLabel"; valueLabel.verticalAlignment = UIVerticalAlignment.Middle; valueLabel.textAlignment = UIHorizontalAlignment.Center; valueLabel.textScale = 0.7f; valueLabel.autoSize = false; valueLabel.color = new Color32(91, 97, 106, 255); valueLabel.size = new Vector2(ValueLabelWidth, 15f); valueLabel.relativePosition = new Vector2(sliderPanel.width - ValueLabelWidth - Margin, (SliderPanelHeight - valueLabel.height) / 2f); // Mutiplier slider control. UISlider newSlider = sliderPanel.AddUIComponent <UISlider>(); newSlider.size = new Vector2(sliderPanel.width - ValueLabelWidth - (Margin * 3), SliderHeight); newSlider.relativePosition = new Vector2(0f, OffsetX); // Mutiplier slider track. UISlicedSprite sliderSprite = newSlider.AddUIComponent <UISlicedSprite>(); sliderSprite.autoSize = false; sliderSprite.size = new Vector2(newSlider.width, newSlider.height); sliderSprite.relativePosition = new Vector2(0f, 0f); sliderSprite.atlas = TextureUtils.InGameAtlas; sliderSprite.spriteName = "ScrollbarTrack"; // Mutiplier slider thumb. UISlicedSprite sliderThumb = newSlider.AddUIComponent <UISlicedSprite>(); sliderThumb.atlas = TextureUtils.InGameAtlas; sliderThumb.spriteName = "ScrollbarThumb"; sliderThumb.height = 20f; sliderThumb.width = 10f; sliderThumb.relativePosition = new Vector2(0f, -OffsetX); newSlider.thumbObject = sliderThumb; // Tooltip. newSlider.tooltipBox = TooltipUtils.TooltipBox; newSlider.tooltip = Translations.Translate(tooltipKey); // Mutiplier slider value range. newSlider.stepSize = 1f; newSlider.minValue = 1f; newSlider.maxValue = 100f; // Event handler to update text. if (isPercent) { newSlider.eventValueChanged += PercentSliderText; } else { newSlider.eventValueChanged += AbsSliderText; } return(newSlider); }