private SettingsTab CreateTabData(string name, string iconName) { BindableFloat bindableFloat = new BindableFloat(10f, -1, 20f); bindableFloat.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableFloat)} value: {val}"); Bindable<string> bindableString = new Bindable<string>("My Text"); bindableString.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableString)} value: {val}"); BindableInt bindableInt = new BindableInt(-10, -20, 0); bindableInt.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableInt)} value: {val}"); Bindable<TestType> bindableEnum = new Bindable<TestType>(TestType.TypeB); bindableEnum.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableEnum)} value: {val}"); BindableBool bindableBool = new BindableBool(false); bindableBool.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableBool)} value: {val}"); BindableBool bindableBool2 = new BindableBool(true); bindableBool2.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableBool2)} value: {val}"); var tabData = new SettingsTab(name, iconName); tabData.AddEntry(new SettingsEntryFloat(nameof(bindableFloat), bindableFloat)); tabData.AddEntry(new SettingsEntryString(nameof(bindableString), bindableString)); tabData.AddEntry(new SettingsEntryInt(nameof(bindableInt), bindableInt)); tabData.AddEntry(new SettingsEntryAction("Do action!", () => Debug.Log("Performed action"))); tabData.AddEntry(new SettingsEntryEnum<TestType>(nameof(bindableEnum), bindableEnum)); tabData.AddEntry(new SettingsEntryBool(nameof(bindableBool), bindableBool)); tabData.AddEntry(new SettingsEntryBool(nameof(bindableBool2), bindableBool2)); return tabData; }
private void Init() { BindableFloat bindableFloat = new BindableFloat(10f, -1, 20f); bindableFloat.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableFloat)} value: {val}"); Bindable <string> bindableString = new Bindable <string>("My Text"); bindableString.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableString)} value: {val}"); BindableInt bindableInt = new BindableInt(-10, -20, 0); bindableInt.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableInt)} value: {val}"); Bindable <TestType> bindableEnum = new Bindable <TestType>(TestType.TypeB); bindableEnum.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableEnum)} value: {val}"); BindableBool bindableBool = new BindableBool(false); bindableBool.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableBool)} value: {val}"); BindableBool bindableBool2 = new BindableBool(true); bindableBool2.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableBool2)} value: {val}"); tabData = new SettingsTab("A", "icon-arrow-left"); tabData.AddEntry(new SettingsEntryFloat(nameof(bindableFloat), bindableFloat)); tabData.AddEntry(new SettingsEntryString(nameof(bindableString), bindableString)); tabData.AddEntry(new SettingsEntryInt(nameof(bindableInt), bindableInt)); tabData.AddEntry(new SettingsEntryEnum <TestType>(nameof(bindableEnum), bindableEnum)); tabData.AddEntry(new SettingsEntryBool(nameof(bindableBool), bindableBool)); tabData.AddEntry(new SettingsEntryBool(nameof(bindableBool2), bindableBool2)); var bg = RootMain.CreateChild <UguiSprite>("bg", -1); { bg.Size = new Vector2(600f, 600f); bg.Alpha = 0.5f; } contentGroup = RootMain.CreateChild <ContentGroup>(); { contentGroup.Width = 400f; contentGroup.SetTabData(tabData); } }
public GameConfiguration() { Settings = new SettingsData(); RulesetMode = InitEnumBindable(nameof(RulesetMode), GameModeType.BeatsStandard); MapsetSort = InitEnumBindable(nameof(MapsetSort), MapsetSortType.Title); RankDisplay = InitEnumBindable(nameof(RankDisplay), RankDisplayType.Local); Username = InitStringBindable(nameof(Username), ""); Password = InitStringBindable(nameof(Password), ""); SaveCredentials = InitBoolBindable(nameof(SaveCredentials), false); LastLoginApi = InitEnumBindable(nameof(LastLoginApi), ApiProviderType.Osu); // General settings SettingsTab generalTab = Settings.AddTabData(new SettingsTab("General", "icon-settings")); { generalTab.AddEntry(new SettingsEntryBool("Prefer unicode", PreferUnicode = InitBoolBindable(nameof(PreferUnicode), false))); generalTab.AddEntry(new SettingsEntryBool("Show messages", DisplayMessages = InitBoolBindable(nameof(DisplayMessages), true))); DisplayMessages.OnNewValue += (display) => { // Automatically disable messages in game if message displaying is false. if (!display) { DisplayMessagesInGame.Value = false; } }; generalTab.AddEntry(new SettingsEntryBool("Show messages in game", DisplayMessagesInGame = InitBoolBindable(nameof(DisplayMessagesInGame), false))); DisplayMessagesInGame.OnNewValue += (display) => { // Turn off this configuration when toggled on but display message itself is turned off. if (display && !DisplayMessages.Value) { DisplayMessagesInGame.Value = false; } }; generalTab.AddEntry(new SettingsEntryBool("Use parallax", UseParallax = InitBoolBindable(nameof(UseParallax), true))); } // Performance settings SettingsTab performanceTab = Settings.AddTabData(new SettingsTab("Performance", "icon-performance")); { performanceTab.AddEntry(new SettingsEntryBool("Show FPS", ShowFps = InitBoolBindable(nameof(ShowFps), false))); performanceTab.AddEntry(new SettingsEntryBool("Use Blur", UseBlurShader = InitBoolBindable(nameof(UseBlurShader), false))); performanceTab.AddEntry(new SettingsEntryEnum <ResolutionType>("Resolution Quality", ResolutionQuality = InitEnumBindable(nameof(ResolutionQuality), ResolutionType.Best))); performanceTab.AddEntry(new SettingsEntryEnum <FramerateType>("Framerate", Framerate = InitEnumBindable(nameof(Framerate), FramerateType._60fps))); } // Gameplay settings SettingsTab gameplayTab = Settings.AddTabData(new SettingsTab("Gameplay", "icon-game")); { gameplayTab.AddEntry(new SettingsEntryBool("Use Storyboard", ShowStoryboard = InitBoolBindable(nameof(ShowStoryboard), false))); gameplayTab.AddEntry(new SettingsEntryBool("Use Video", ShowVideo = InitBoolBindable(nameof(ShowVideo), false))); gameplayTab.AddEntry(new SettingsEntryBool("Use Map Skins", UseBeatmapSkins = InitBoolBindable(nameof(UseBeatmapSkins), false))); gameplayTab.AddEntry(new SettingsEntryFloat("Background Dim", BackgroundDim = InitFloatBindable(nameof(BackgroundDim), 0.5f, 0f, 1f)) { Formatter = "P0" }); } // Sound settings SettingsTab soundTab = Settings.AddTabData(new SettingsTab("Sound", "icon-sound")); { soundTab.AddEntry(new SettingsEntryFloat("Master Volume", MasterVolume = InitFloatBindable(nameof(MasterVolume), 1f, 0f, 1f)) { Formatter = "P0" }); soundTab.AddEntry(new SettingsEntryFloat("Music Volume", MusicVolume = InitFloatBindable(nameof(MusicVolume), 1f, 0f, 1f)) { Formatter = "P0" }); soundTab.AddEntry(new SettingsEntryFloat("Hitsound Volume", HitsoundVolume = InitFloatBindable(nameof(HitsoundVolume), 1f, 0f, 1f)) { Formatter = "P0" }); soundTab.AddEntry(new SettingsEntryFloat("Effect Volume", EffectVolume = InitFloatBindable(nameof(EffectVolume), 1f, 0f, 1f)) { Formatter = "P0" }); soundTab.AddEntry(new SettingsEntryInt("Global Offset", GlobalOffset = InitIntBindable(nameof(GlobalOffset), 0, -100, 100))); soundTab.AddEntry(new SettingsEntryBool("Use Map Hitsounds", UseBeatmapHitsounds = InitBoolBindable(nameof(UseBeatmapHitsounds), true))); soundTab.AddEntry(new SettingsEntryBool("Button hover sound", UseButtonHoverSound = InitBoolBindable(nameof(UseButtonHoverSound), true))); } // Other settings SettingsTab otherTab = Settings.AddTabData(new SettingsTab("Other", "icon-misc")); { otherTab.AddEntry(new SettingsEntryEnum <NotificationType>("Persistent notification level", PersistNotificationLevel = InitEnumBindable(nameof(NotificationType), NotificationType.Warning))); otherTab.AddEntry(new SettingsEntryEnum <LogType>("Log to notification level", LogToNotificationLevel = InitEnumBindable(nameof(LogType), LogType.Warning))); } // Version settings SettingsTab versionTab = Settings.AddTabData(new SettingsTab("Version", "icon-version")); { versionTab.AddEntry(new SettingsEntryAction($"Game version ({App.GameVersion})", () => { UnityEngine.Application.OpenURL(App.GameRepository); })); versionTab.AddEntry(new SettingsEntryAction($"Framework version ({App.FrameworkVersion})", () => { UnityEngine.Application.OpenURL(App.FrameworkRepository); })); } // Trigger change for all configurations on load. OnLoad += delegate { foreach (var entry in allSettings) { entry.Trigger(); } }; }