public void ConfigureOptionsPanel(IStronglyTypedUIHelper uiHelper) { try { ConfigureGeneralGroup(uiHelper); ConfigureDisableDisastersGroup(uiHelper); ConfigureMaxIntensityGroup(uiHelper); ConfigureAutoEvacuateGroup(uiHelper); ConfigureProbabilityGroup(uiHelper); var debuggingGroup = uiHelper.AddGroup("Debugging"); debuggingGroup.AddCheckBox( "Enable logging", ModConfig.Instance.GetSetting <bool>(SettingKeys.EnableLogging), isChecked => { ModConfig.Instance.SaveSetting(SettingKeys.EnableLogging, isChecked); RagnarokLogger.Enabled = isChecked; }); } catch (Exception ex) { logger.LogException(ex); throw; } }
protected void ConfigureOptionsPanel(IStronglyTypedUIHelper uiHelper) { if (OptionsPanelManager != null) { OptionsPanelManager.ConfigureOptionsPanel(uiHelper); } }
private void AddMaxIntensitySlider(IStronglyTypedUIHelper group, string disasterName, string impactSettingKey) { var setting = ModConfig.Instance.GetSetting <byte>(impactSettingKey); var slider = group.AddSlider( disasterName, MinimumIntensityValue, MaximumIntensityValue, 1, setting, val => { ModConfig.Instance.SaveSetting(impactSettingKey, (byte)val); UpdateMaxIntensityLabel(impactSettingKey, disasterName, val); }); slider.width = (int)Math.Round(slider.width * 1.4); var label = slider.GetLabel(); label.width = (int)Math.Round(label.width * 1.4); if (maxIntensitySliders.ContainsKey(impactSettingKey)) { maxIntensitySliders[impactSettingKey] = slider; } else { maxIntensitySliders.Add(impactSettingKey, slider); } UpdateMaxIntensityLabel(impactSettingKey, disasterName, setting); }
public void ConfigureOptionsPanel(IStronglyTypedUIHelper uiHelper) { try { var appearance = uiHelper.AddGroup("Appearance"); appearance.AddDropDown( "Popup position", Positions.ToArray(), ModConfig.Instance.GetSetting <int>(SettingKeys.PopupPosition), PositionChanged); var behaviour = uiHelper.AddGroup("Behaviour"); behaviour.AddCheckBox("Enable achievements", ModConfig.Instance.GetSetting <bool>(SettingKeys.EnableAchievements), AchievementStatusChanged); var debugging = uiHelper.AddGroup("Debugging"); debugging.AddCheckBox("Enable logging", ModConfig.Instance.GetSetting <bool>(SettingKeys.EnableLogging), EnableLoggingChanged); logger.Info("OnSettingsUi"); } catch (Exception ex) { logger.LogException(ex); throw; } }
private void AddEnabledDisasterCheckbox(IStronglyTypedUIHelper uiGroup, string label, string settingKey) { uiGroup.AddCheckBox( label, ModConfig.Instance.GetSetting <bool>(settingKey), isChecked => SaveSetting(settingKey, isChecked)); }
private static void AddProbabilitySlider(IStronglyTypedUIHelper disasterGroup, string settingKey, DisasterInfo disasterInfo) { var probability = disasterInfo.m_finalRandomProbability; if (ModConfig.Instance.HasSetting(settingKey)) { probability = ModConfig.Instance.GetSetting <int>(settingKey); } var labelText = disasterInfo.name; var slider = disasterGroup.AddSlider( labelText, 0, 1000, 1, probability, newProbability => { disasterInfo.m_finalRandomProbability = (int)newProbability; ModConfig.Instance.SaveSetting(settingKey, (int)newProbability); }); slider.width = (int)Math.Round(slider.width * 1.5f); var label = slider.GetLabel(); label.width = (int)Math.Round(label.width * 1.5f); }
public void ConfigureOptionsPanel(IStronglyTypedUIHelper uiHelper) { try { var appearanceGroup = uiHelper.AddGroup("Appearance"); var behaviourGroup = uiHelper.AddGroup("Behaviour"); var debugGroup = uiHelper.AddGroup("Debugging"); appearanceGroup.AddCheckBox("Hide chirper", ModConfig.Instance.GetSetting <bool>(SettingKeys.HideChirper), ToggleChirper); appearanceGroup.AddCheckBox( "Make Chirper draggable (hold ctrl + left mouse button)", ModConfig.Instance.GetSetting <bool>(SettingKeys.Draggable), ToggleDraggable); appearanceGroup.AddSpace(10); appearanceGroup.AddButton("Reset Chirper position", ResetPosition); behaviourGroup.AddCheckBox( "Filter non-important messages", ModConfig.Instance.GetSetting <bool>(SettingKeys.FilterMessages), ToggleFilter); debugGroup.AddCheckBox("Enable logging", ModConfig.Instance.GetSetting <bool>(SettingKeys.EnableLogging), ToggleLogging); } catch (Exception ex) { logger.LogException(ex); } }
public static UILabel AddLabel(this IStronglyTypedUIHelper uiHelper, string text) { var label = uiHelper.Component.AddUIComponent <UILabel>(); label.text = text; return(label); }
private void AddDebugSettings(IStronglyTypedUIHelper uiHelper) { var group = uiHelper.AddGroup("Debugging"); group.AddCheckBox( "Enable logging", ModConfig.Instance.GetSetting <bool>(SettingKeys.EnableLogging), ToggleLogging); }
private void ConfigureAutoEvacuateGroup(IStronglyTypedUIHelper uiHelper) { var group = uiHelper.AddGroup("Auto evacuate"); foreach (var disaster in SettingKeys.DisasterSettingKeys) { AddAutoEvacuateBehaviourDropDown(group, disaster.Key, disaster.Value.AutoEvacuate); } }
private void AddAutoEvacuateBehaviourDropDown(IStronglyTypedUIHelper autoEvacuateGroup, string disasterName, string settingKey) { var dropDown = autoEvacuateGroup.AddDropDown( disasterName, AutoEvacuateValues, ModConfig.Instance.GetSetting <int>(settingKey), sel => SaveSetting(settingKey, sel)); dropDown.width = (int)Math.Round(dropDown.width * 1.4f); }
private void ConfigureMaxIntensityGroup(IStronglyTypedUIHelper uiHelper) { var group = uiHelper.AddGroup("Disable disasters over a given intensity"); group.AddLabel("Use the sliders to set the max intensity for a given disaster.\nSet to zero (0) to allow all intensities."); foreach (var disaster in SettingKeys.DisasterSettingKeys) { AddMaxIntensitySlider(group, disaster.Key, disaster.Value.MaxIntensity); } }
private void AddCheckBox(IStronglyTypedUIHelper group, string label, string settingKey, string localeId) { group.AddCheckBox( label, ModConfig.Get(settingKey), isChecked => { ModConfig.Save(settingKey, isChecked); filterService.UpdateFilters(); }) .WithTooltipLocaleId(localeId); }
public void ConfigureOptionsPanel(IStronglyTypedUIHelper uiHelper) { try { AddAppearanceSettings(uiHelper); AddBehaviourSettings(uiHelper); AddDebugSettings(uiHelper); } catch (Exception ex) { logger.LogException(ex); } }
private void ConfigureGeneralGroup(IStronglyTypedUIHelper uiHelper) { var generalGroup = uiHelper.AddGroup("General"); generalGroup.AddCheckBox( "Auto focus on disaster", ModConfig.Instance.GetSetting <bool>(SettingKeys.DisableAutofocusDisaster), OnAutoFocusDisasterChanged); generalGroup.AddCheckBox( "Pause on disaster start", ModConfig.Instance.GetSetting <bool>(SettingKeys.PauseOnDisasterStart), isChecked => SaveSetting(SettingKeys.PauseOnDisasterStart, isChecked)); }
public static UILabel AddLabel(this IStronglyTypedUIHelper uiHelper, string text) { var field = uiHelper.UiHelper.GetType().GetField("m_Root", BindingFlags.NonPublic | BindingFlags.Instance); if (field == null) { throw new InvalidOperationException("m_Root field not found on the UI helper."); } var root = (UIComponent)field.GetValue(uiHelper.UiHelper); var label = root.AddUIComponent <UILabel>(); label.text = text; return(label); }
private void AddAppearanceSettings(IStronglyTypedUIHelper uiHelper) { var group = uiHelper.AddGroup("Appearance"); group.AddCheckBox( "Hide Chirper", ModConfig.Instance.GetSetting <bool>(SettingKeys.HideChirper), ToggleChirper); group.AddCheckBox( "Make Chirper draggable (hold ctrl + left mouse button)", ModConfig.Instance.GetSetting <bool>(SettingKeys.Draggable), ToggleDraggable); group.AddSpace(); resetPositionButton = group.AddButton("Reset Chirper position", ResetPosition) .WithTooltip(ResetPositionButtonTooltip); resetPositionButton.isEnabled = false; }
private void ConfigureDisableDisastersGroup(IStronglyTypedUIHelper uiHelper) { var group = uiHelper.AddGroup("Disable disasters"); group.AddCheckBox( "Fires not caused by disasters", ModConfig.Instance.GetSetting <bool>(SettingKeys.DisableNonDisasterFires), OnDisableNonDisasterFiresChanged); group.AddSpace(10); foreach (var disableDisaster in SettingKeys.DisasterSettingKeys) { AddEnabledDisasterCheckbox(group, disableDisaster.Key, disableDisaster.Value.Disable); } group.AddSpace(10); AddEnabledDisasterCheckbox(group, "Disable scenario disasters (really?)", SettingKeys.DisableScenarioDisasters); }
private void ConfigureProbabilityGroup(IStronglyTypedUIHelper uiHelper) { var probabilityGroup = uiHelper.AddGroup("Disaster probabilities"); if (!GenericDisasterServices.GetDisasterInfos().Any()) { probabilityGroup.AddLabel("You need to be in an active game or scenario to change these settings."); return; } probabilityGroup.AddLabel( "The sliders below indicate the risk of a certain type of disaster spawning.\n\n" + "These are in relation to each other meaning that if two sliders are set equally\n" + "then they have an equal chance of occurring."); var disasterInfos = GenericDisasterServices.GetDisasterInfos().ToList(); foreach (var disasterInfo in disasterInfos) { var settingKey = string.Format("{0}Probability", disasterInfo.name.Replace(" ", string.Empty)); AddProbabilitySlider(probabilityGroup, settingKey, disasterInfo); } }
private void AddBehaviourSettings(IStronglyTypedUIHelper uiHelper) { var group = uiHelper.AddGroup("Filter chirps"); group.AddLabel("Mouse over each setting to see an example of each chirp"); group.AddSpace(25); group.AddLabel("Random \"filler\" chirps"); AddCheckBox( group, "Citizen chatter", SettingKeys.FilterPointlessChirps, LocaleID.CHIRP_RANDOM_EXP8); AddCheckBox( group, "Enacted policies and district themes", SettingKeys.FilterPoliciesAndThemes, LocaleID.CHIRP_ORGANIC_FARMING); group.AddSpace(); group.AddLabel("When you build, unlock or achieve something"); AddCheckBox( group, "First time you build a service building (eg. city's first hospital)", SettingKeys.FilterFirstTypeOfServiceBuilt, LocaleID.CHIRP_FIRST_FIRE_STATION); AddCheckBox( group, "When subsequent service buildings are built (eg. city's second hospital)", SettingKeys.FilterServiceBuilt, LocaleID.CHIRP_NEW_FIRE_STATION); AddCheckBox( group, "When you unlock fishery buildings", SettingKeys.FilterFishingBuildingUnlocked, LocaleID.CHIRP_FISHING_BOAT_HARBOR_04_UNLOCKED); AddCheckBox( group, "Celebrations (high attractiveness, milestone reached etc.)", SettingKeys.FilterCelebrations, LocaleID.CHIRP_ATTRACTIVE_CITY); group.AddSpace(); group.AddLabel("Citizens reacting to events that happen in your city"); AddCheckBox( group, "Varsity sports matches", SettingKeys.FilterVarsitySportsMatches, LocaleID.VARSITYSPORTSCHIRP_WIN); AddCheckBox(group, "Football matches", SettingKeys.FilterFootballMatches, LocaleID.FOOTBALLCHIRP_LOSE); AddCheckBox(group, "Concerts", SettingKeys.FilterConcerts, LocaleID.CHIRP_BAND_MOTI); AddCheckBox(group, "ChirpX launches", SettingKeys.FilterChirpXLaunches, LocaleID.CHIRP_LAUNCH); AddCheckBox( group, "Toga parties and graduations", SettingKeys.FilterTogaPartiesAndGraduations, LocaleID.GRADUATIONCHIRP_GENERIC); group.AddSpace(); AddCheckBox( group, "Actual city problems (high crime, no power etc.)", SettingKeys.FilterCityProblems, LocaleID.CHIRP_NO_WATER); AddCheckBox( group, "Reactions to disasters", SettingKeys.FilterDisasters, LocaleID.CHIRP_RANDOM_DISASTERS); group.AddSpace(); AddCheckBox( group, "Uncategorized chirps (chirps I haven't yet figured out how are triggered)", SettingKeys.FilterUncategorized, LocaleID.CHIRP_ASSISTIVE_TECHNOLOGIES); // foreach (var chirp in Chirps.Uncategorized) // { // group.AddTextField(chirp, Locale.Get(chirp), text => { }, text => { }) // .AsWideAsGroup(group) // .readOnly = true; // } }
public static UITextField AsWideAsGroup(this UITextField textField, IStronglyTypedUIHelper group) { textField.width = group.Component.width - 45; return(textField); }