mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 02:22:59 +08:00
commit
800e35b637
osu.Game
@ -17,7 +17,6 @@ namespace osu.Game.Configuration
|
||||
Set(OsuConfig.MouseSpeed, 1.0);
|
||||
|
||||
Set(OsuConfig.Username, string.Empty);
|
||||
Set(OsuConfig.Password, string.Empty);
|
||||
Set(OsuConfig.Token, string.Empty);
|
||||
|
||||
Set(OsuConfig.PlayMode, PlayMode.Osu);
|
||||
@ -144,8 +143,6 @@ namespace osu.Game.Configuration
|
||||
Set(OsuConfig.HiddenShowFirstApproach, true);
|
||||
Set(OsuConfig.ComboColourSliderBall, true);
|
||||
Set(OsuConfig.AlternativeChatFont, false);
|
||||
Set(OsuConfig.Password, string.Empty);
|
||||
Set(OsuConfig.Username, string.Empty);
|
||||
Set(OsuConfig.DisplayStarsMaximum, 10.0, 0.0, 10.0);
|
||||
Set(OsuConfig.DisplayStarsMinimum, 0.0, 0.0, 10.0);
|
||||
Set(OsuConfig.AudioDevice, string.Empty);
|
||||
@ -171,6 +168,16 @@ namespace osu.Game.Configuration
|
||||
Set(OsuConfig.CanForceOptimusCompatibility, true);
|
||||
Set(OsuConfig.ConfineMouse, Get<bool>(OsuConfig.ConfineMouseToFullscreen) ?
|
||||
ConfineMouseMode.Fullscreen : ConfineMouseMode.Never);
|
||||
|
||||
|
||||
GetBindable<bool>(OsuConfig.SavePassword).ValueChanged += delegate
|
||||
{
|
||||
if (Get<bool>(OsuConfig.SavePassword)) Set(OsuConfig.SaveUsername, true);
|
||||
};
|
||||
GetBindable<bool>(OsuConfig.SaveUsername).ValueChanged += delegate
|
||||
{
|
||||
if (!Get<bool>(OsuConfig.SaveUsername)) Set(OsuConfig.SavePassword, false);
|
||||
};
|
||||
#pragma warning restore CS0612 // Type or member is obsolete
|
||||
}
|
||||
|
||||
@ -314,7 +321,6 @@ namespace osu.Game.Configuration
|
||||
HiddenShowFirstApproach,
|
||||
ComboColourSliderBall,
|
||||
AlternativeChatFont,
|
||||
Password,
|
||||
Username,
|
||||
DisplayStarsMaximum,
|
||||
DisplayStarsMinimum,
|
||||
|
@ -70,7 +70,6 @@ namespace osu.Game
|
||||
Dependencies.Cache(API = new APIAccess
|
||||
{
|
||||
Username = LocalConfig.Get<string>(OsuConfig.Username),
|
||||
Password = LocalConfig.Get<string>(OsuConfig.Password),
|
||||
Token = LocalConfig.Get<string>(OsuConfig.Token)
|
||||
});
|
||||
|
||||
@ -83,7 +82,6 @@ namespace osu.Game
|
||||
{
|
||||
case APIState.Online:
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -119,7 +117,7 @@ namespace osu.Game
|
||||
//refresh token may have changed.
|
||||
if (LocalConfig != null && API != null)
|
||||
{
|
||||
LocalConfig.Set(OsuConfig.Token, API.Token);
|
||||
LocalConfig.Set(OsuConfig.Token, LocalConfig.Get<bool>(OsuConfig.SavePassword) ? API.Token : string.Empty);
|
||||
LocalConfig.Save();
|
||||
}
|
||||
|
||||
|
@ -11,14 +11,12 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
|
||||
using osu.Game.Configuration;
|
||||
|
||||
namespace osu.Game.Overlays.Options.General
|
||||
{
|
||||
public class LoginOptions : OptionsSubsection, IOnlineComponent
|
||||
{
|
||||
private Container loginForm;
|
||||
|
||||
private Action performLogout;
|
||||
protected override string Header => "Sign In";
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
@ -76,30 +74,11 @@ namespace osu.Game.Overlays.Options.General
|
||||
class LoginForm : FlowContainer
|
||||
{
|
||||
private TextBox username;
|
||||
private TextBox password;
|
||||
private PasswordTextBox password;
|
||||
private APIAccess api;
|
||||
|
||||
public LoginForm()
|
||||
{
|
||||
Direction = FlowDirection.VerticalOnly;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Spacing = new Vector2(0, 5);
|
||||
// TODO: Wire things up
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteText { Text = "Username" },
|
||||
username = new TextBox { Height = 20, RelativeSizeAxes = Axes.X, Text = api?.Username ?? string.Empty },
|
||||
new SpriteText { Text = "Password" },
|
||||
password = new PasswordTextBox { Height = 20, RelativeSizeAxes = Axes.X },
|
||||
new OsuButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = "Log in",
|
||||
Action = performLogin
|
||||
}
|
||||
};
|
||||
}
|
||||
private CheckBoxOption saveUsername;
|
||||
private CheckBoxOption savePassword;
|
||||
|
||||
private void performLogin()
|
||||
{
|
||||
@ -108,9 +87,51 @@ namespace osu.Game.Overlays.Options.General
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(APIAccess api)
|
||||
private void load(APIAccess api, OsuConfigManager config)
|
||||
{
|
||||
this.api = api;
|
||||
Direction = FlowDirection.VerticalOnly;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Spacing = new Vector2(0, 5);
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteText { Text = "Username" },
|
||||
username = new TextBox
|
||||
{
|
||||
Height = 20,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = api?.Username ?? string.Empty
|
||||
},
|
||||
new SpriteText { Text = "Password" },
|
||||
password = new PasswordTextBox
|
||||
{
|
||||
Height = 20,
|
||||
RelativeSizeAxes = Axes.X
|
||||
},
|
||||
saveUsername = new CheckBoxOption
|
||||
{
|
||||
LabelText = "Remember Username",
|
||||
Bindable = config.GetBindable<bool>(OsuConfig.SaveUsername),
|
||||
},
|
||||
savePassword = new CheckBoxOption
|
||||
{
|
||||
LabelText = "Remember Password",
|
||||
Bindable = config.GetBindable<bool>(OsuConfig.SavePassword),
|
||||
},
|
||||
new OsuButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = "Log in",
|
||||
Action = performLogin
|
||||
},
|
||||
new OsuButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = "Register",
|
||||
//Action = registerLink
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user