1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-12 09:47:18 +08:00

Move window/volume configuration to framework level.

This commit is contained in:
Dean Herbert 2017-01-25 18:39:41 +09:00
parent 23938a810b
commit 1853bbdda8
9 changed files with 32 additions and 94 deletions

View File

@ -1,12 +0,0 @@
using System;
namespace osu.Game.Configuration
{
public enum FrameSync
{
VSync = 1,
Limit120 = 0,
Unlimited = 2,
CompletelyUnlimited = 4,
Custom = 5
}
}

View File

@ -13,8 +13,7 @@ namespace osu.Game.Configuration
protected override void InitialiseDefaults() protected override void InitialiseDefaults()
{ {
#pragma warning disable CS0612 // Type or member is obsolete #pragma warning disable CS0612 // Type or member is obsolete
Set(OsuConfig.Width, 1366, 640);
Set(OsuConfig.Height, 768, 480);
Set(OsuConfig.MouseSpeed, 1.0); Set(OsuConfig.MouseSpeed, 1.0);
Set(OsuConfig.Username, string.Empty); Set(OsuConfig.Username, string.Empty);
@ -25,10 +24,6 @@ namespace osu.Game.Configuration
Set(OsuConfig.BeatmapDirectory, @"Songs"); // TODO: use this Set(OsuConfig.BeatmapDirectory, @"Songs"); // TODO: use this
Set(OsuConfig.VolumeUniversal, 0.8, 0, 1);
Set(OsuConfig.VolumeMusic, 1.0, 0, 1);
Set(OsuConfig.VolumeEffect, 1.0, 0, 1);
Set(OsuConfig.AllowPublicInvites, true); Set(OsuConfig.AllowPublicInvites, true);
Set(OsuConfig.AutoChatHide, true); Set(OsuConfig.AutoChatHide, true);
Set(OsuConfig.AutomaticDownload, true); Set(OsuConfig.AutomaticDownload, true);
@ -56,7 +51,7 @@ namespace osu.Game.Configuration
Set(OsuConfig.DisplayCityLocation, false); Set(OsuConfig.DisplayCityLocation, false);
Set(OsuConfig.DistanceSpacingEnabled, true); Set(OsuConfig.DistanceSpacingEnabled, true);
Set(OsuConfig.EditorTip, 0); Set(OsuConfig.EditorTip, 0);
Set(OsuConfig.VideoEditor, Get<bool>(OsuConfig.Fullscreen)); Set(OsuConfig.VideoEditor, true);
Set(OsuConfig.EditorDefaultSkin, false); Set(OsuConfig.EditorDefaultSkin, false);
Set(OsuConfig.EditorSnakingSliders, true); Set(OsuConfig.EditorSnakingSliders, true);
Set(OsuConfig.EditorHitAnimations, false); Set(OsuConfig.EditorHitAnimations, false);
@ -104,9 +99,7 @@ namespace osu.Game.Configuration
Set(OsuConfig.EditorBeatDivisor, 1, 1, 16); Set(OsuConfig.EditorBeatDivisor, 1, 1, 16);
Set(OsuConfig.EditorGridSize, 32, 4, 32); Set(OsuConfig.EditorGridSize, 32, 4, 32);
Set(OsuConfig.EditorGridSizeDesign, 32, 4, 32); Set(OsuConfig.EditorGridSizeDesign, 32, 4, 32);
Set(OsuConfig.HeightFullscreen, 9999, 240, 9999);
Set(OsuConfig.CustomFrameLimit, 240, 240, 999); Set(OsuConfig.CustomFrameLimit, 240, 240, 999);
Set(OsuConfig.WidthFullscreen, 9999, 320, 9999);
Set(OsuConfig.MsnIntegration, false); Set(OsuConfig.MsnIntegration, false);
Set(OsuConfig.MyPcSucks, false); Set(OsuConfig.MyPcSucks, false);
Set(OsuConfig.NotifyFriends, true); Set(OsuConfig.NotifyFriends, true);
@ -142,7 +135,6 @@ namespace osu.Game.Configuration
Set(OsuConfig.YahooIntegration, false); Set(OsuConfig.YahooIntegration, false);
Set(OsuConfig.ForceFrameFlush, false); Set(OsuConfig.ForceFrameFlush, false);
Set(OsuConfig.DetectPerformanceIssues, true); Set(OsuConfig.DetectPerformanceIssues, true);
Set(OsuConfig.Fullscreen, true);
Set(OsuConfig.MenuMusic, true); Set(OsuConfig.MenuMusic, true);
Set(OsuConfig.MenuVoice, true); Set(OsuConfig.MenuVoice, true);
Set(OsuConfig.MenuParallax, true); Set(OsuConfig.MenuParallax, true);
@ -163,10 +155,6 @@ namespace osu.Game.Configuration
Set(OsuConfig.SaveUsername, true); Set(OsuConfig.SaveUsername, true);
//Set(OsuConfig.TreeSortMode, TreeGroupMode.Show_All); //Set(OsuConfig.TreeSortMode, TreeGroupMode.Show_All);
//Set(OsuConfig.TreeSortMode2, TreeSortMode.Title); //Set(OsuConfig.TreeSortMode2, TreeSortMode.Title);
Set(OsuConfig.Letterboxing, Get<bool>(OsuConfig.Fullscreen));
Set(OsuConfig.LetterboxPositionX, 0, -100, 100);
Set(OsuConfig.LetterboxPositionY, 0, -100, 100);
Set(OsuConfig.FrameSync, FrameSync.Limit120);
bool unicodeDefault = false; bool unicodeDefault = false;
switch (Get<string>(OsuConfig.Language)) switch (Get<string>(OsuConfig.Language))
{ {
@ -202,9 +190,6 @@ namespace osu.Game.Configuration
Token, Token,
// Imported from old osu: // Imported from old osu:
BeatmapDirectory, BeatmapDirectory,
VolumeUniversal,
VolumeEffect,
VolumeMusic,
AllowPublicInvites, AllowPublicInvites,
AutoChatHide, AutoChatHide,
AutomaticDownload, AutomaticDownload,
@ -281,11 +266,7 @@ namespace osu.Game.Configuration
EditorBeatDivisor, EditorBeatDivisor,
EditorGridSize, EditorGridSize,
EditorGridSizeDesign, EditorGridSizeDesign,
Height,
Width,
HeightFullscreen,
CustomFrameLimit, CustomFrameLimit,
WidthFullscreen,
MsnIntegration, MsnIntegration,
MyPcSucks, MyPcSucks,
NotifyFriends, NotifyFriends,
@ -321,7 +302,6 @@ namespace osu.Game.Configuration
YahooIntegration, YahooIntegration,
ForceFrameFlush, ForceFrameFlush,
DetectPerformanceIssues, DetectPerformanceIssues,
Fullscreen,
MenuMusic, MenuMusic,
MenuVoice, MenuVoice,
MenuParallax, MenuParallax,
@ -345,9 +325,6 @@ namespace osu.Game.Configuration
SaveUsername, SaveUsername,
TreeSortMode, TreeSortMode,
TreeSortMode2, TreeSortMode2,
Letterboxing,
LetterboxPositionX,
LetterboxPositionY,
FrameSync, FrameSync,
ShowUnicode, ShowUnicode,
PermanentSongInfo, PermanentSongInfo,

View File

@ -2,16 +2,12 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Threading;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.GameModes; using osu.Framework.GameModes;
using osu.Game.Configuration; using osu.Game.Configuration;
using OpenTK;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Platform;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Framework;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Input; using osu.Game.Input;
using OpenTK.Input; using OpenTK.Input;
@ -25,7 +21,6 @@ using osu.Game.Modes;
using osu.Game.Overlays.Toolbar; using osu.Game.Overlays.Toolbar;
using osu.Game.Screens; using osu.Game.Screens;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Screens.Play;
namespace osu.Game namespace osu.Game
{ {
@ -55,13 +50,6 @@ namespace osu.Game
this.args = args; this.args = args;
} }
public override void SetHost(BasicGameHost host)
{
base.SetHost(host);
host.Size = new Vector2(Config.Get<int>(OsuConfig.Width), Config.Get<int>(OsuConfig.Height));
}
public void ToggleOptions() => options.ToggleVisibility(); public void ToggleOptions() => options.ToggleVisibility();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -78,12 +66,7 @@ namespace osu.Game
Dependencies.Cache(this); Dependencies.Cache(this);
//attach our bindables to the audio subsystem. PlayMode = LocalConfig.GetBindable<PlayMode>(OsuConfig.PlayMode);
Audio.Volume.Weld(Config.GetBindable<double>(OsuConfig.VolumeUniversal));
Audio.VolumeSample.Weld(Config.GetBindable<double>(OsuConfig.VolumeEffect));
Audio.VolumeTrack.Weld(Config.GetBindable<double>(OsuConfig.VolumeMusic));
PlayMode = Config.GetBindable<PlayMode>(OsuConfig.PlayMode);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -239,17 +222,5 @@ namespace osu.Game
{ {
modeChanged(newMode); modeChanged(newMode);
} }
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
{
if (!base.Invalidate(invalidation, source, shallPropagate)) return false;
if (Parent != null)
{
Config.Set(OsuConfig.Width, DrawSize.X);
Config.Set(OsuConfig.Height, DrawSize.Y);
}
return true;
}
} }
} }

View File

@ -22,7 +22,7 @@ namespace osu.Game
{ {
public class OsuGameBase : BaseGame, IOnlineComponent public class OsuGameBase : BaseGame, IOnlineComponent
{ {
internal OsuConfigManager Config; protected OsuConfigManager LocalConfig;
protected override string MainResourceFile => @"osu.Game.Resources.dll"; protected override string MainResourceFile => @"osu.Game.Resources.dll";
@ -40,7 +40,7 @@ namespace osu.Game
private void load() private void load()
{ {
Dependencies.Cache(this); Dependencies.Cache(this);
Dependencies.Cache(Config); Dependencies.Cache(LocalConfig);
Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host)); Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host));
Dependencies.Cache(new OsuColour()); Dependencies.Cache(new OsuColour());
@ -69,9 +69,9 @@ namespace osu.Game
Dependencies.Cache(API = new APIAccess Dependencies.Cache(API = new APIAccess
{ {
Username = Config.Get<string>(OsuConfig.Username), Username = LocalConfig.Get<string>(OsuConfig.Username),
Password = Config.Get<string>(OsuConfig.Password), Password = LocalConfig.Get<string>(OsuConfig.Password),
Token = Config.Get<string>(OsuConfig.Token) Token = LocalConfig.Get<string>(OsuConfig.Token)
}); });
API.Register(this); API.Register(this);
@ -82,8 +82,8 @@ namespace osu.Game
switch (state) switch (state)
{ {
case APIState.Online: case APIState.Online:
Config.Set(OsuConfig.Username, Config.Get<bool>(OsuConfig.SaveUsername) ? API.Username : string.Empty); LocalConfig.Set(OsuConfig.Username, LocalConfig.Get<bool>(OsuConfig.SaveUsername) ? API.Username : string.Empty);
Config.Set(OsuConfig.Password, Config.Get<bool>(OsuConfig.SavePassword) ? API.Password : string.Empty); LocalConfig.Set(OsuConfig.Password, LocalConfig.Get<bool>(OsuConfig.SavePassword) ? API.Password : string.Empty);
break; break;
} }
} }
@ -103,8 +103,8 @@ namespace osu.Game
public override void SetHost(BasicGameHost host) public override void SetHost(BasicGameHost host)
{ {
if (Config == null) if (LocalConfig == null)
Config = new OsuConfigManager(host.Storage); LocalConfig = new OsuConfigManager(host.Storage);
base.SetHost(host); base.SetHost(host);
} }
@ -117,10 +117,10 @@ namespace osu.Game
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
//refresh token may have changed. //refresh token may have changed.
if (Config != null && API != null) if (LocalConfig != null && API != null)
{ {
Config.Set(OsuConfig.Token, API.Token); LocalConfig.Set(OsuConfig.Token, API.Token);
Config.Save(); LocalConfig.Save();
} }
base.Dispose(isDisposing); base.Dispose(isDisposing);

View File

@ -43,7 +43,6 @@ namespace osu.Game.Overlays
private TrackManager trackManager; private TrackManager trackManager;
private Bindable<WorkingBeatmap> beatmapSource; private Bindable<WorkingBeatmap> beatmapSource;
private Bindable<bool> preferUnicode; private Bindable<bool> preferUnicode;
private OsuConfigManager config;
private WorkingBeatmap current; private WorkingBeatmap current;
private BeatmapDatabase beatmaps; private BeatmapDatabase beatmaps;
private BaseGame game; private BaseGame game;
@ -87,9 +86,11 @@ namespace osu.Game.Overlays
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuGameBase osuGame, BeatmapDatabase beatmaps, AudioManager audio, private void load(OsuGameBase osuGame, OsuConfigManager config, BeatmapDatabase beatmaps, AudioManager audio,
TextureStore textures, OsuColour colours) TextureStore textures, OsuColour colours)
{ {
unicodeString = config.GetUnicodeString;
Children = new Drawable[] Children = new Drawable[]
{ {
title = new SpriteText title = new SpriteText
@ -202,8 +203,7 @@ namespace osu.Game.Overlays
this.beatmaps = beatmaps; this.beatmaps = beatmaps;
trackManager = osuGame.Audio.Track; trackManager = osuGame.Audio.Track;
config = osuGame.Config; preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
preferUnicode = osuGame.Config.GetBindable<bool>(OsuConfig.ShowUnicode);
preferUnicode.ValueChanged += preferUnicode_changed; preferUnicode.ValueChanged += preferUnicode_changed;
beatmapSource = osuGame.Beatmap ?? new Bindable<WorkingBeatmap>(); beatmapSource = osuGame.Beatmap ?? new Bindable<WorkingBeatmap>();
@ -324,8 +324,8 @@ namespace osu.Game.Overlays
return; return;
BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
title.Text = config.GetUnicodeString(metadata.Title, metadata.TitleUnicode); title.Text = unicodeString(metadata.Title, metadata.TitleUnicode);
artist.Text = config.GetUnicodeString(metadata.Artist, metadata.ArtistUnicode); artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode);
}); });
MusicControllerBackground newBackground; MusicControllerBackground newBackground;
@ -354,6 +354,8 @@ namespace osu.Game.Overlays
}); });
} }
private Func<string, string, string> unicodeString;
private void seek(float position) private void seek(float position)
{ {
current?.Track?.Seek(current.Track.Length * position); current?.Track?.Seek(current.Track.Length * position);

View File

@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Options.Graphics
protected override string Header => "Layout"; protected override string Header => "Layout";
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config) private void load(FrameworkConfigManager config)
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
@ -24,22 +24,22 @@ namespace osu.Game.Overlays.Options.Graphics
new CheckBoxOption new CheckBoxOption
{ {
LabelText = "Fullscreen mode", LabelText = "Fullscreen mode",
Bindable = config.GetBindable<bool>(OsuConfig.Fullscreen), Bindable = config.GetBindable<bool>(FrameworkConfig.Fullscreen),
}, },
new CheckBoxOption new CheckBoxOption
{ {
LabelText = "Letterboxing", LabelText = "Letterboxing",
Bindable = config.GetBindable<bool>(OsuConfig.Letterboxing), Bindable = config.GetBindable<bool>(FrameworkConfig.Letterboxing),
}, },
new SliderOption<int> new SliderOption<int>
{ {
LabelText = "Horizontal position", LabelText = "Horizontal position",
Bindable = (BindableInt)config.GetBindable<int>(OsuConfig.LetterboxPositionX) Bindable = (BindableInt)config.GetBindable<int>(FrameworkConfig.LetterboxPositionX)
}, },
new SliderOption<int> new SliderOption<int>
{ {
LabelText = "Vertical position", LabelText = "Vertical position",
Bindable = (BindableInt)config.GetBindable<int>(OsuConfig.LetterboxPositionY) Bindable = (BindableInt)config.GetBindable<int>(FrameworkConfig.LetterboxPositionY)
}, },
}; };
} }

View File

@ -3,6 +3,7 @@
using osu.Framework; using osu.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;

View File

@ -48,9 +48,9 @@ namespace osu.Game.Screens.Play
private Bindable<int> dimLevel; private Bindable<int> dimLevel;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game) private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game, OsuConfigManager config)
{ {
dimLevel = game.Config.GetBindable<int>(OsuConfig.DimLevel); dimLevel = config.GetBindable<int>(OsuConfig.DimLevel);
try try
{ {
if (Beatmap == null) if (Beatmap == null)

View File

@ -230,7 +230,6 @@
<Compile Include="Configuration\ScoreMeterType.cs" /> <Compile Include="Configuration\ScoreMeterType.cs" />
<Compile Include="Configuration\ReleaseStream.cs" /> <Compile Include="Configuration\ReleaseStream.cs" />
<Compile Include="Configuration\ScreenshotFormat.cs" /> <Compile Include="Configuration\ScreenshotFormat.cs" />
<Compile Include="Configuration\FrameSync.cs" />
<Compile Include="Configuration\ConfineMouseMode.cs" /> <Compile Include="Configuration\ConfineMouseMode.cs" />
<Compile Include="Graphics\OsuColour.cs" /> <Compile Include="Graphics\OsuColour.cs" />
</ItemGroup> </ItemGroup>