A game framework written with osu! in mind.
at master 4.9 kB view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2// See the LICENCE file in the repository root for full licence text. 3 4using System; 5using System.Collections.Generic; 6using System.Drawing; 7using osu.Framework.Configuration.Tracking; 8using osu.Framework.Extensions; 9using osu.Framework.Input; 10using osu.Framework.Platform; 11using osuTK; 12 13namespace osu.Framework.Configuration 14{ 15 public class FrameworkConfigManager : IniConfigManager<FrameworkSetting> 16 { 17 internal const string FILENAME = @"framework.ini"; 18 19 protected override string Filename => FILENAME; 20 21 protected override void InitialiseDefaults() 22 { 23 SetDefault(FrameworkSetting.ShowLogOverlay, false); 24 25 SetDefault(FrameworkSetting.WindowedSize, new Size(1366, 768), new Size(640, 480)); 26 SetDefault(FrameworkSetting.ConfineMouseMode, ConfineMouseMode.Fullscreen); 27 SetDefault(FrameworkSetting.ExecutionMode, ExecutionMode.MultiThreaded); 28 SetDefault(FrameworkSetting.WindowedPositionX, 0.5, -0.5, 1.5); 29 SetDefault(FrameworkSetting.WindowedPositionY, 0.5, -0.5, 1.5); 30 SetDefault(FrameworkSetting.LastDisplayDevice, DisplayIndex.Default); 31 SetDefault(FrameworkSetting.AudioDevice, string.Empty); 32 SetDefault(FrameworkSetting.VolumeUniversal, 1.0, 0.0, 1.0, 0.01); 33 SetDefault(FrameworkSetting.VolumeMusic, 1.0, 0.0, 1.0, 0.01); 34 SetDefault(FrameworkSetting.VolumeEffect, 1.0, 0.0, 1.0, 0.01); 35 SetDefault(FrameworkSetting.SizeFullscreen, new Size(9999, 9999), new Size(320, 240)); 36 SetDefault(FrameworkSetting.FrameSync, FrameSync.Limit2x); 37 SetDefault(FrameworkSetting.WindowMode, WindowMode.Windowed); 38 SetDefault(FrameworkSetting.ShowUnicode, false); 39 SetDefault(FrameworkSetting.Locale, string.Empty); 40 41#pragma warning disable 618 42 SetDefault(FrameworkSetting.MapAbsoluteInputToWindow, false); 43 SetDefault(FrameworkSetting.IgnoredInputHandlers, string.Empty); 44 SetDefault(FrameworkSetting.CursorSensitivity, 1.0, 0.1, 6, 0.01); 45#pragma warning restore 618 46 } 47 48 public FrameworkConfigManager(Storage storage, IDictionary<FrameworkSetting, object> defaultOverrides = null) 49 : base(storage, defaultOverrides) 50 { 51 } 52 53 public override TrackedSettings CreateTrackedSettings() => new TrackedSettings 54 { 55 new TrackedSetting<FrameSync>(FrameworkSetting.FrameSync, v => new SettingDescription(v, "Frame Limiter", v.GetDescription(), "Ctrl+F7")), 56 new TrackedSetting<string>(FrameworkSetting.AudioDevice, v => new SettingDescription(v, "Audio Device", string.IsNullOrEmpty(v) ? "Default" : v, v)), 57 new TrackedSetting<bool>(FrameworkSetting.ShowLogOverlay, v => new SettingDescription(v, "Debug Logs", v ? "visible" : "hidden", "Ctrl+F10")), 58 new TrackedSetting<Size>(FrameworkSetting.WindowedSize, v => new SettingDescription(v, "Screen resolution", $"{v.Width}x{v.Height}")), 59 new TrackedSetting<WindowMode>(FrameworkSetting.WindowMode, v => new SettingDescription(v, "Screen Mode", v.ToString(), "Alt+Enter")), 60#pragma warning disable 618 61 new TrackedSetting<double>(FrameworkSetting.CursorSensitivity, v => new SettingDescription(v, "Cursor Sensitivity", v.ToString(@"0.##x"), "Ctrl+Alt+R to reset")), 62 new TrackedSetting<string>(FrameworkSetting.IgnoredInputHandlers, v => 63 { 64 bool raw = !v.Contains("Raw"); 65 return new SettingDescription(raw, "Raw Input", raw ? "enabled" : "disabled", "Ctrl+Alt+R to reset"); 66 }), 67#pragma warning restore 618 68 }; 69 } 70 71 public enum FrameworkSetting 72 { 73 ShowLogOverlay, 74 75 AudioDevice, 76 VolumeUniversal, 77 VolumeEffect, 78 VolumeMusic, 79 80 WindowedSize, 81 WindowedPositionX, 82 WindowedPositionY, 83 LastDisplayDevice, 84 85 SizeFullscreen, 86 87 WindowMode, 88 ConfineMouseMode, 89 FrameSync, 90 ExecutionMode, 91 92 ShowUnicode, 93 Locale, 94 95 [Obsolete("Input-related settings are now stored in InputConfigManager. Adjustments should be made via Host.AvailableInputHandlers bindables directly.")] // can be removed 20210911 96 IgnoredInputHandlers, 97 98 [Obsolete("Input-related settings are now stored in InputConfigManager. Adjustments should be made via Host.AvailableInputHandlers bindables directly.")] // can be removed 20210911 99 CursorSensitivity, 100 101 [Obsolete("Input-related settings are now stored in InputConfigManager. Adjustments should be made via Host.AvailableInputHandlers bindables directly.")] // can be removed 20210911 102 MapAbsoluteInputToWindow, 103 } 104}