public void TestRestoreDefaultValueButtonPrecision(float initialValue) { BindableFloat current = null; SettingsSlider <float> sliderBar = null; RestoreDefaultValueButton <float> restoreDefaultValueButton = null; AddStep("create settings item", () => { Child = sliderBar = new SettingsSlider <float> { Current = current = new BindableFloat(initialValue) { MinValue = 0f, MaxValue = 10f, Precision = 0.1f, } }; }); AddUntilStep("wait for loaded", () => sliderBar.IsLoaded); AddStep("retrieve restore default button", () => restoreDefaultValueButton = sliderBar.ChildrenOfType <RestoreDefaultValueButton <float> >().Single()); AddAssert("restore button hidden", () => restoreDefaultValueButton.Alpha == 0); AddStep("change value to next closest", () => sliderBar.Current.Value += current.Precision * 0.6f); AddUntilStep("restore button shown", () => restoreDefaultValueButton.Alpha > 0); AddStep("restore default", () => sliderBar.Current.SetDefault()); AddUntilStep("restore button hidden", () => restoreDefaultValueButton.Alpha == 0); }
private void load(RulesetStore rulesets) { Lyric = DemoKaraokeObject.GenerateDemo001(); DrawableKaraokeObject = new DrawableLyric(Lyric) { Position = new Vector2(), ProgressUpdateByTime = false, }; var slider = new SettingsSlider <double>() { LabelText = "Background dim ", Bindable = new BindableDouble { MinValue = 0, MaxValue = 500, Default = 300, Value = DrawableKaraokeObject.Progress, }, Width = 0.5f }; slider.Bindable.ValueChanged += (v) => { DrawableKaraokeObject.Progress = v; }; Children = new Drawable[] { slider, }; Add(DrawableKaraokeObject); }
private void load() { Flow.AddRange(new[] { multiplier = new SettingsSlider <double> { LabelText = "ιεΊ¦εη", Bindable = new DifficultyControlPoint().SpeedMultiplierBindable, RelativeSizeAxes = Axes.X, } }); }
private void loadSettingsMenu() { GameInfo.info.loadPlayerSettings(); setSlider("VolumeRow", GameInfo.info.volume); setSlider("SensitivityRow", GameInfo.info.mouseSpeed); setSlider("FovRow", GameInfo.info.fov); setSlider("VsyncRow", GameInfo.info.vsyncLevel, SettingsSlider.translateFloat(GameInfo.info.vsyncLevel)); setSlider("LightingRow", GameInfo.info.lightingLevel); setSlider("AntiAliasingRow", GameInfo.info.antiAliasing); setSlider("AnisotropicFilteringRow", boolToFloat(GameInfo.info.anisotropicFiltering), SettingsSlider.translateFloat(boolToFloat(GameInfo.info.anisotropicFiltering))); setSlider("TextureSizeRow", GameInfo.info.textureSize, SettingsSlider.translateTextureSize(GameInfo.info.textureSize)); }
private void load() { // use local bindable to avoid changing enabled state of game host's bindable. handlerDeadzone = joystickHandler.DeadzoneThreshold.GetBoundCopy(); localDeadzone = handlerDeadzone.GetUnboundCopy(); Children = new Drawable[] { new SettingsCheckbox { LabelText = CommonStrings.Enabled, Current = enabled }, deadzoneSlider = new SettingsSlider <float> { LabelText = JoystickSettingsStrings.DeadzoneThreshold, KeyboardStep = 0.01f, DisplayAsPercentage = true, Current = localDeadzone, }, }; }
/// <summary> /// Adds a <see cref="Slider"/> to a panel /// </summary> /// <param name="panel"></param> /// <param name="sideText"></param> /// <param name="currentValue"></param> /// <param name="wholeNumbers"></param> /// <param name="min"></param> /// <param name="max"></param> /// <returns></returns> public Slider AddSliderToPanel(GameObject panel, string sideText, float currentValue, bool wholeNumbers = false, float min = 0, float max = 100) { //Create new slider object GameObject sliderObject = Instantiate(settingsSliderPrefab, GetPanelItemArea(panel), false); SettingsSlider sliderSettings = sliderObject.GetComponent <SettingsSlider>(); //Set up the existing value sliderSettings.Setup(currentValue); //Set the text sliderSettings.propertyText.text = GameUILocale.ResolveString(sideText); //Set up the slider itself Slider slider = sliderSettings.slider; slider.wholeNumbers = wholeNumbers; slider.minValue = min; slider.maxValue = max; slider.value = currentValue; return(slider); }
private void load(Storage storage, DialogOverlay dialog, OsuGame game) { var config = Config as GamebosuConfigManager; lockClockRate = config.GetBindable <bool>(GamebosuSetting.LockClockRate); Children = new Drawable[] { clockRate = new SettingsSlider <double> { LabelText = "Gameboy Clock rate", Current = config.GetBindable <double>(GamebosuSetting.ClockRate) }, new SettingsCheckbox { LabelText = "Lock gameboy clock rate", Current = lockClockRate }, new SettingsCheckbox { LabelText = "Prefer Gameboy Color mode when launching original gameboy ROMs", Current = config.GetBindable <bool>(GamebosuSetting.PreferGBCMode) }, new SettingsSlider <float> { LabelText = "Gameboy Scale", Current = config.GetBindable <float>(GamebosuSetting.GameboyScale) }, new SettingsButton { Text = "Open ROMs folder", Action = () => storage.GetStorageForDirectory("roms")?.PresentExternally() }, new DangerousSettingsButton { Text = "Delete ROM save data", Action = () => { Action deleteAction = delegate { var saves = storage.GetStorageForDirectory("roms/saves"); var files = saves.GetFiles("."); try { files.ForEach(file => saves.Delete(file)); } catch (Exception) { dialog.Push(new DeleteDataErrorDialog { BodyText = $"Couldn't delete ROM save data (save data may be used by the currently loaded ROM). Try deleting save data from the main menu" }); } }; dialog.Push(new DeleteDataDialog(deleteAction)); } }, new SettingsCheckbox { LabelText = "Enable Sound Playback (VERY EXPERIMENTAL)", Current = config.GetBindable <bool>(GamebosuSetting.EnableSoundPlayback) }, new SettingsCheckbox { LabelText = "Disable that annoying disclaimer when launching gamebosu!", Current = config.GetBindable <bool>(GamebosuSetting.DisableDisplayingThatAnnoyingDisclaimer) }, new YellowSettingsButton { Text = "Open ROM listing", Action = () => game?.PerformFromScreen(scr => scr.Push(new GamebosuMainScreen(ruleset))) }, }; lockClockRate.BindValueChanged(e => clockRate.Current.Disabled = e.NewValue, true); }
private static GameObject SetupSubPanel(Transform parent) { GameObject subPanelToInstantiate = parent.Find("SettingsSubPanel, Controls (Gamepad)").gameObject; GameObject subPanelInstance = GameObject.Instantiate(subPanelToInstantiate, parent); Transform instanceLayout = subPanelInstance.transform.Find("Scroll View/Viewport/VerticalLayout"); foreach (Transform child in instanceLayout) { GameObject.Destroy(child.gameObject); } GameObject sliderSetting = subPanelToInstantiate.transform.Find("Scroll View/Viewport/VerticalLayout/SettingsEntryButton, Slider (Look Scale X)").gameObject; GameObject boolSetting = subPanelToInstantiate.transform.Find("Scroll View/Viewport/VerticalLayout/SettingsEntryButton, Bool (Invert X)").gameObject; GameObject carouselSetting = parent.transform.Find("SettingsSubPanel, Video/Scroll View/Viewport/VerticalLayout/SettingsEntryButton, Carousel (Vsync)").gameObject; LanguageTextMeshController descriptionText = parent.transform.Find("GenericDescriptionPanel/ContentSizeFitter/DescriptionText").GetComponent <LanguageTextMeshController>(); bool first = true; foreach (KeyValuePair <string, ModConfig.ConfigSetting> keyValuePair in ModConfig.settings) { ModConfig.ConfigSetting setting = keyValuePair.Value; BaseSettingsControl settingInstance; if (setting.entry.SettingType == typeof(float) || setting.entry.SettingType == typeof(int)) { settingInstance = GameObject.Instantiate(sliderSetting, instanceLayout).GetComponent <BaseSettingsControl>(); SettingsSlider slider = settingInstance as SettingsSlider; slider.minValue = setting.minValue; slider.maxValue = setting.maxValue; slider.formatString = setting.entry.SettingType == typeof(float) ? "{0:0.00}" : "{0:N0}"; } else if (setting.entry.SettingType == typeof(bool)) { settingInstance = GameObject.Instantiate(boolSetting, instanceLayout).GetComponent <BaseSettingsControl>(); } else { settingInstance = GameObject.Instantiate(carouselSetting, instanceLayout).GetComponent <BaseSettingsControl>(); CarouselController carousel = settingInstance as CarouselController; List <CarouselController.Choice> choices = new List <CarouselController.Choice>(); if (keyValuePair.Key == "vr_ray_color") { string[] choiceStrings = new string[] { "White", "Green", "Red", "Blue", "Yellow", "Magenta", "Cyan", "Lime", "Black" }; string[] hexStrings = new string[] { "#FFFFFF", "#008000", "#FF0000", "#0000FF", "#FFFF00", "#FF00FF", "#00FFFF", "#00FF00", "#000000" }; for (int i = 0; i < choiceStrings.Length; i++) { CarouselController.Choice choice = new CarouselController.Choice(); choice.convarValue = hexStrings[i]; choice.suboptionDisplayToken = choiceStrings[i]; choices.Add(choice); } } carousel.choices = choices.ToArray(); } settingInstance.settingSource = BaseSettingsControl.SettingSource.ConVar; settingInstance.nameToken = setting.entry.Definition.Key; settingInstance.settingName = keyValuePair.Key; settingInstance.gameObject.name = "VRModSetting, " + settingInstance.nameToken; HGButton button = settingInstance.GetComponent <HGButton>(); if (button) { string prefixString = ""; if (setting.settingUpdate == ModConfig.ConfigSetting.SettingUpdate.NextStage) { prefixString = "[WILL APPLY NEXT STAGE] "; } else if (setting.settingUpdate == ModConfig.ConfigSetting.SettingUpdate.AfterRestart) { prefixString = "[RESTART REQUIRED] "; } button.updateTextOnHover = true; button.hoverToken = prefixString + setting.entry.Description.Description; button.hoverLanguageTextMeshController = descriptionText; button.defaultFallbackButton = first; first = false; } } GameObject controllerBindingSetting = subPanelToInstantiate.transform.Find("Scroll View/Viewport/VerticalLayout/SettingsEntryButton, Binding (Jump)").gameObject; GameObject keyboardBindingSetting = parent.Find("SettingsSubPanel, Controls (M&KB)/Scroll View/Viewport/VerticalLayout/SettingsEntryButton, Binding (Jump)").gameObject; ActionAddons.ActionDef[] actionDefs = ActionAddons.actionDefs; foreach (var actionDef in actionDefs) { if (actionDef.keyboardMap != KeyboardKeyCode.None) { AddBindingSetting(actionDef, keyboardBindingSetting, instanceLayout); } if (actionDef.joystickMap != ActionAddons.ControllerInput.None) { AddBindingSetting(actionDef, controllerBindingSetting, instanceLayout); } } subPanelInstance.transform.Find("Scroll View").gameObject.AddComponent <ScrollToSelection>(); return(subPanelInstance); }
private void load(VignetteConfigManager config) { colour = config.GetBindable <Colour4>(VignetteSetting.BackgroundColour); AddRange(new Drawable[] { new Container { Height = 100, Masking = true, CornerRadius = 2.5f, RelativeSizeAxes = Axes.X, Child = previewBox = new Box { Colour = Colour4.Red, RelativeSizeAxes = Axes.Both, } }, new SettingsHexColourBox { Label = "Hex", Current = colour, }, red = new SettingsSlider <float> { Label = "Red", Current = new BindableFloat { Value = colour.Value.R, MinValue = 0, MaxValue = 1, }, }, green = new SettingsSlider <float> { Label = "Green", Current = new BindableFloat { Value = colour.Value.G, MinValue = 0, MaxValue = 1, }, }, blue = new SettingsSlider <float> { Label = "Blue", Current = new BindableFloat { Value = colour.Value.B, MinValue = 0, MaxValue = 1, }, }, }); red.Current.ValueChanged += e => colour.Value = new Colour4(e.NewValue, colour.Value.G, colour.Value.B, 1); green.Current.ValueChanged += e => colour.Value = new Colour4(colour.Value.R, e.NewValue, colour.Value.B, 1); blue.Current.ValueChanged += e => colour.Value = new Colour4(colour.Value.R, colour.Value.G, e.NewValue, 1); colour.BindValueChanged(e => { previewBox.Colour = e.NewValue; red.Current.Value = e.NewValue.R; green.Current.Value = e.NewValue.G; blue.Current.Value = e.NewValue.B; }, true); }