/// <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 GeneralOptionsPanel(UITabstrip tabStrip, int tabIndex) { // Add tab and helper. UIPanel panel = PanelUtils.AddTab(tabStrip, Translations.Translate("BOB_OPT_GEN"), tabIndex); 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; // Hotkey control. panel.gameObject.AddComponent <OptionsKeymapping>(); // Default grouping behaviour. string[] groupItems = new string[] { Translations.Translate("BOB_PER_LST"), Translations.Translate("BOB_PER_SIN"), Translations.Translate("BOB_PER_GRP") }; UIDropDown groupDropDown = UIControls.AddPlainDropDown(panel, Translations.Translate("BOB_PER_IND"), groupItems, ModSettings.indDefault, 350f); groupDropDown.eventSelectedIndexChanged += (control, index) => ModSettings.indDefault = index; // Rember last position. UICheckBox rememberPosCheck = UIControls.AddPlainCheckBox(panel, Translations.Translate("BOB_OPT_POS")); rememberPosCheck.isChecked = ModSettings.rememberPosition; rememberPosCheck.eventCheckChanged += (control, isChecked) => ModSettings.rememberPosition = isChecked; }
/// <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 RuiningOptionsPanel(UITabstrip tabStrip, int tabIndex) { // Add tab and helper. UIPanel panel = PanelUtils.AddTab(tabStrip, Translations.Translate("BOB_OPT_RUI"), tabIndex); UIHelper helper = new UIHelper(panel); panel.autoLayout = true; UIHelperBase ruinGroup = helper.AddGroup(Translations.Translate("BOB_OPT_RGL")); // Checkboxes. ruinGroup.AddCheckbox(Translations.Translate("BOB_OPT_RRT"), ModSettings.StopTreeRuining, (value) => ModSettings.StopTreeRuining = value); ruinGroup.AddCheckbox(Translations.Translate("BOB_OPT_RRP"), ModSettings.StopPropRuining, (value) => ModSettings.StopPropRuining = value); }
/// <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 VisualOptionsPanel(UITabstrip tabStrip, int tabIndex) { // Add tab and helper. UIPanel panel = PanelUtils.AddTab(tabStrip, Translations.Translate("BOB_OPT_VIS"), tabIndex); UIHelper helper = new UIHelper(panel); panel.autoLayout = true; // Ruining. UIHelperBase ruinGroup = helper.AddGroup(Translations.Translate("BOB_OPT_RUI") + " - " + Translations.Translate("BOB_OPT_RGL")); ruinGroup.AddCheckbox(Translations.Translate("BOB_OPT_RRT"), ModSettings.StopTreeRuining, (value) => ModSettings.StopTreeRuining = value); ruinGroup.AddCheckbox(Translations.Translate("BOB_OPT_RRP"), ModSettings.StopPropRuining, (value) => ModSettings.StopPropRuining = value); // Electrical wire thickness. UIHelperBase wiresGroup = helper.AddGroup(Translations.Translate("BOB_OPT_WIR")); wiresGroup.AddCheckbox(Translations.Translate("BOB_OPT_WTH"), ModSettings.ThinnerWires, (value) => ModSettings.ThinnerWires = value); }
/// <summary> /// Adds configurations panel tab to tabstrip. /// </summary> /// <param name="tabStrip">Tab strip to add to</param> /// <param name="tabIndex">Index number of tab</param> internal ConfigurationsPanel(UITabstrip tabStrip, int tabIndex) { // Set reference. instance = this; // Determine if we're in-game or not; use status of replacer managers to determine. inGame = BuildingReplacement.Instance != null && NetworkReplacement.Instance != null; // Add tab and helper. UIPanel panel = PanelUtils.AddTab(tabStrip, Translations.Translate("BOB_OPT_CFG"), tabIndex); UIHelper helper = new UIHelper(panel); panel.autoLayout = false; // Config list panel. UIPanel configListPanel = panel.AddUIComponent <UIPanel>(); configListPanel.width = ListWidth; configListPanel.height = ListHeight; configListPanel.relativePosition = new Vector2(Margin, ListY); // Config selection list. configList = UIFastList.Create <UIConfigRow>(configListPanel); configList.backgroundSprite = "UnlockingPanel"; configList.width = configListPanel.width; configList.height = configListPanel.height; configList.canSelect = true; configList.rowHeight = RowHeight; configList.autoHideScrollbar = true; configList.relativePosition = Vector2.zero; configList.rowsData = new FastList <object>(); // File name textfield. UILabel fileTextLabel = UIControls.AddLabel(panel, ControlPanelX, ListY, "New configuration name:"); fileNameField = UIControls.AddTextField(panel, ControlPanelX, ListY + fileTextLabel.height); fileNameField.eventTextChanged += (control, text) => UpdateButtonStates(); // Buttons. activeCopyButton = UIControls.AddButton(panel, ControlPanelX, ListY + 70f, Translations.Translate("BOB_CFG_SAC"), 300f, scale: 0.8f); activeCopyButton.eventClicked += NewCurrent; selectedCopyButton = UIControls.AddButton(panel, ControlPanelX, ListY + 105f, Translations.Translate("BOB_CFG_SSC"), 300f, scale: 0.8f); selectedCopyButton.eventClicked += CopySelected; newCleanButton = UIControls.AddButton(panel, ControlPanelX, ListY + 140f, Translations.Translate("BOB_CFG_SEC"), 300f, scale: 0.8f); newCleanButton.eventClicked += NewClean; deleteButton = UIControls.AddButton(panel, ControlPanelX, ListY + 210f, Translations.Translate("BOB_CFG_DEL"), 300f, scale: 0.8f); deleteButton.eventClicked += Delete; // Ingame buttons - 'use custom' check and apply and nuke buttons. if (inGame) { // Use custom check box. customCheck = UIControls.LabelledCheckBox(panel, Margin, ToolBarY, Translations.Translate("BOB_CFG_UCS")); customCheck.eventCheckChanged += (control, isChecked) => { // If we've got a valid selection, set the current config name to this. if (isChecked && !string.IsNullOrEmpty(selectedConfig)) { ConfigurationUtils.CurrentSavedConfigName = selectedConfig; } }; // Apply button. UIButton applyButton = UIControls.AddButton(panel, Margin, FooterY, Translations.Translate("BOB_CFG_LAA"), 400f, scale: 0.8f); applyButton.eventClicked += Apply; // Use global configuration button. UIButton globalButton = UIControls.AddButton(panel, Margin, FooterY + 50f, Translations.Translate("BOB_CFG_LGL"), 400f, scale: 0.8f); globalButton.eventClicked += UseGlobal; // Clean up config button. UIButton cleanUpButton = UIControls.AddButton(panel, Margin + 50f, FooterY + 150f, Translations.Translate("BOB_CFG_CLE"), 300f); cleanUpButton.tooltip = Translations.Translate("BOB_CFG_CLE_TIP"); cleanUpButton.eventClicked += (control, clickEvent) => ConfigurationUtils.Cleanup(); // Nuke all settings button. UIButton nukeButton = UIControls.AddButton(panel, Margin + 50f, FooterY + 200f, Translations.Translate("BOB_NUKE"), 300f); nukeButton.eventClicked += (control, clickEvent) => { // Revert all-building and building settings. ReplacementUtils.NukeSettings(); // Save clean configuration. //ConfigurationUtils.SaveConfig(ConfigurationUtils.CurrentSavedConfigName, true); }; } // Populate selection list and set initial button states. RefreshList(); // Select current pack if we've got one. if (customCheck != null && customCheck.isChecked) { // Try to select current config name. selectedConfig = configList.FindItem(ConfigurationUtils.CurrentSavedConfigName); // Did we find it? if (selectedConfig == null) { // Not found; uncheck the use custom check. customCheck.isChecked = false; } } // Set initial button states. UpdateButtonStates(); }