1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:07:52 +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()
{
#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.Username, string.Empty);
@ -24,11 +23,7 @@ namespace osu.Game.Configuration
Set(OsuConfig.PlayMode, PlayMode.Osu);
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.AutoChatHide, true);
Set(OsuConfig.AutomaticDownload, true);
@ -56,7 +51,7 @@ namespace osu.Game.Configuration
Set(OsuConfig.DisplayCityLocation, false);
Set(OsuConfig.DistanceSpacingEnabled, true);
Set(OsuConfig.EditorTip, 0);
Set(OsuConfig.VideoEditor, Get<bool>(OsuConfig.Fullscreen));
Set(OsuConfig.VideoEditor, true);
Set(OsuConfig.EditorDefaultSkin, false);
Set(OsuConfig.EditorSnakingSliders, true);
Set(OsuConfig.EditorHitAnimations, false);
@ -104,9 +99,7 @@ namespace osu.Game.Configuration
Set(OsuConfig.EditorBeatDivisor, 1, 1, 16);
Set(OsuConfig.EditorGridSize, 32, 4, 32);
Set(OsuConfig.EditorGridSizeDesign, 32, 4, 32);
Set(OsuConfig.HeightFullscreen, 9999, 240, 9999);
Set(OsuConfig.CustomFrameLimit, 240, 240, 999);
Set(OsuConfig.WidthFullscreen, 9999, 320, 9999);
Set(OsuConfig.MsnIntegration, false);
Set(OsuConfig.MyPcSucks, false);
Set(OsuConfig.NotifyFriends, true);
@ -142,7 +135,6 @@ namespace osu.Game.Configuration
Set(OsuConfig.YahooIntegration, false);
Set(OsuConfig.ForceFrameFlush, false);
Set(OsuConfig.DetectPerformanceIssues, true);
Set(OsuConfig.Fullscreen, true);
Set(OsuConfig.MenuMusic, true);
Set(OsuConfig.MenuVoice, true);
Set(OsuConfig.MenuParallax, true);
@ -163,10 +155,6 @@ namespace osu.Game.Configuration
Set(OsuConfig.SaveUsername, true);
//Set(OsuConfig.TreeSortMode, TreeGroupMode.Show_All);
//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;
switch (Get<string>(OsuConfig.Language))
{
@ -202,9 +190,6 @@ namespace osu.Game.Configuration
Token,
// Imported from old osu:
BeatmapDirectory,
VolumeUniversal,
VolumeEffect,
VolumeMusic,
AllowPublicInvites,
AutoChatHide,
AutomaticDownload,
@ -281,11 +266,7 @@ namespace osu.Game.Configuration
EditorBeatDivisor,
EditorGridSize,
EditorGridSizeDesign,
Height,
Width,
HeightFullscreen,
CustomFrameLimit,
WidthFullscreen,
MsnIntegration,
MyPcSucks,
NotifyFriends,
@ -321,7 +302,6 @@ namespace osu.Game.Configuration
YahooIntegration,
ForceFrameFlush,
DetectPerformanceIssues,
Fullscreen,
MenuMusic,
MenuVoice,
MenuParallax,
@ -345,9 +325,6 @@ namespace osu.Game.Configuration
SaveUsername,
TreeSortMode,
TreeSortMode2,
Letterboxing,
LetterboxPositionX,
LetterboxPositionY,
FrameSync,
ShowUnicode,
PermanentSongInfo,

View File

@ -2,16 +2,12 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Threading;
using osu.Framework.Configuration;
using osu.Framework.GameModes;
using osu.Game.Configuration;
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Platform;
using osu.Game.Overlays;
using osu.Framework;
using osu.Framework.Input;
using osu.Game.Input;
using OpenTK.Input;
@ -25,7 +21,6 @@ using osu.Game.Modes;
using osu.Game.Overlays.Toolbar;
using osu.Game.Screens;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Play;
namespace osu.Game
{
@ -55,13 +50,6 @@ namespace osu.Game
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();
[BackgroundDependencyLoader]
@ -78,12 +66,7 @@ namespace osu.Game
Dependencies.Cache(this);
//attach our bindables to the audio subsystem.
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);
PlayMode = LocalConfig.GetBindable<PlayMode>(OsuConfig.PlayMode);
}
protected override void LoadComplete()
@ -239,17 +222,5 @@ namespace osu.Game
{
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
{
internal OsuConfigManager Config;
protected OsuConfigManager LocalConfig;
protected override string MainResourceFile => @"osu.Game.Resources.dll";
@ -40,7 +40,7 @@ namespace osu.Game
private void load()
{
Dependencies.Cache(this);
Dependencies.Cache(Config);
Dependencies.Cache(LocalConfig);
Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host));
Dependencies.Cache(new OsuColour());
@ -69,9 +69,9 @@ namespace osu.Game
Dependencies.Cache(API = new APIAccess
{
Username = Config.Get<string>(OsuConfig.Username),
Password = Config.Get<string>(OsuConfig.Password),
Token = Config.Get<string>(OsuConfig.Token)
Username = LocalConfig.Get<string>(OsuConfig.Username),
Password = LocalConfig.Get<string>(OsuConfig.Password),
Token = LocalConfig.Get<string>(OsuConfig.Token)
});
API.Register(this);
@ -82,8 +82,8 @@ namespace osu.Game
switch (state)
{
case APIState.Online:
Config.Set(OsuConfig.Username, Config.Get<bool>(OsuConfig.SaveUsername) ? API.Username : string.Empty);
Config.Set(OsuConfig.Password, Config.Get<bool>(OsuConfig.SavePassword) ? API.Password : string.Empty);
LocalConfig.Set(OsuConfig.Username, LocalConfig.Get<bool>(OsuConfig.SaveUsername) ? API.Username : string.Empty);
LocalConfig.Set(OsuConfig.Password, LocalConfig.Get<bool>(OsuConfig.SavePassword) ? API.Password : string.Empty);
break;
}
}
@ -103,8 +103,8 @@ namespace osu.Game
public override void SetHost(BasicGameHost host)
{
if (Config == null)
Config = new OsuConfigManager(host.Storage);
if (LocalConfig == null)
LocalConfig = new OsuConfigManager(host.Storage);
base.SetHost(host);
}
@ -117,10 +117,10 @@ namespace osu.Game
protected override void Dispose(bool isDisposing)
{
//refresh token may have changed.
if (Config != null && API != null)
if (LocalConfig != null && API != null)
{
Config.Set(OsuConfig.Token, API.Token);
Config.Save();
LocalConfig.Set(OsuConfig.Token, API.Token);
LocalConfig.Save();
}
base.Dispose(isDisposing);

View File

@ -43,7 +43,6 @@ namespace osu.Game.Overlays
private TrackManager trackManager;
private Bindable<WorkingBeatmap> beatmapSource;
private Bindable<bool> preferUnicode;
private OsuConfigManager config;
private WorkingBeatmap current;
private BeatmapDatabase beatmaps;
private BaseGame game;
@ -87,9 +86,11 @@ namespace osu.Game.Overlays
}
[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)
{
unicodeString = config.GetUnicodeString;
Children = new Drawable[]
{
title = new SpriteText
@ -202,8 +203,7 @@ namespace osu.Game.Overlays
this.beatmaps = beatmaps;
trackManager = osuGame.Audio.Track;
config = osuGame.Config;
preferUnicode = osuGame.Config.GetBindable<bool>(OsuConfig.ShowUnicode);
preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
preferUnicode.ValueChanged += preferUnicode_changed;
beatmapSource = osuGame.Beatmap ?? new Bindable<WorkingBeatmap>();
@ -324,8 +324,8 @@ namespace osu.Game.Overlays
return;
BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
title.Text = config.GetUnicodeString(metadata.Title, metadata.TitleUnicode);
artist.Text = config.GetUnicodeString(metadata.Artist, metadata.ArtistUnicode);
title.Text = unicodeString(metadata.Title, metadata.TitleUnicode);
artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode);
});
MusicControllerBackground newBackground;
@ -354,6 +354,8 @@ namespace osu.Game.Overlays
});
}
private Func<string, string, string> unicodeString;
private void seek(float 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";
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
private void load(FrameworkConfigManager config)
{
Children = new Drawable[]
{
@ -24,22 +24,22 @@ namespace osu.Game.Overlays.Options.Graphics
new CheckBoxOption
{
LabelText = "Fullscreen mode",
Bindable = config.GetBindable<bool>(OsuConfig.Fullscreen),
Bindable = config.GetBindable<bool>(FrameworkConfig.Fullscreen),
},
new CheckBoxOption
{
LabelText = "Letterboxing",
Bindable = config.GetBindable<bool>(OsuConfig.Letterboxing),
Bindable = config.GetBindable<bool>(FrameworkConfig.Letterboxing),
},
new SliderOption<int>
{
LabelText = "Horizontal position",
Bindable = (BindableInt)config.GetBindable<int>(OsuConfig.LetterboxPositionX)
Bindable = (BindableInt)config.GetBindable<int>(FrameworkConfig.LetterboxPositionX)
},
new SliderOption<int>
{
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.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;

View File

@ -48,9 +48,9 @@ namespace osu.Game.Screens.Play
private Bindable<int> dimLevel;
[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
{
if (Beatmap == null)

View File

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