mirror of
https://github.com/osukey/osukey.git
synced 2025-06-17 01:08:00 +09:00
Rework how references are passed about
This commit is contained in:
parent
55821a1a2b
commit
cb40b7079f
13
osu.Game/Graphics/UserInterface/LoadingAnimation.cs
Normal file
13
osu.Game/Graphics/UserInterface/LoadingAnimation.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.UserInterface
|
||||||
|
{
|
||||||
|
public class LoadingAnimation : SpriteText
|
||||||
|
{
|
||||||
|
public LoadingAnimation()
|
||||||
|
{
|
||||||
|
Text = "Loading";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,14 +10,14 @@ namespace osu.Game.Overlays.Options
|
|||||||
{
|
{
|
||||||
public class GeneralOptions : OptionsSection
|
public class GeneralOptions : OptionsSection
|
||||||
{
|
{
|
||||||
public GeneralOptions(BasicStorage storage, APIAccess api)
|
public GeneralOptions()
|
||||||
{
|
{
|
||||||
Header = "General";
|
Header = "General";
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new LoginOptions(api),
|
new LoginOptions(),
|
||||||
new LanguageOptions(),
|
new LanguageOptions(),
|
||||||
new UpdateOptions(storage),
|
new UpdateOptions(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
@ -12,54 +13,56 @@ namespace osu.Game.Overlays.Options
|
|||||||
{
|
{
|
||||||
public class LoginOptions : OptionsSubsection
|
public class LoginOptions : OptionsSubsection
|
||||||
{
|
{
|
||||||
public LoginOptions(APIAccess api)
|
private Container loginForm;
|
||||||
|
|
||||||
|
public LoginOptions()
|
||||||
{
|
{
|
||||||
var state = api == null ? APIAccess.APIState.Offline : api.State;
|
|
||||||
Header = "Sign In";
|
Header = "Sign In";
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new Container
|
loginForm = new Container
|
||||||
{
|
{
|
||||||
Alpha = state == APIAccess.APIState.Online ? 1 : 0,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Children = new[]
|
Children = new[] { new LoadingAnimation() }
|
||||||
{
|
|
||||||
new SpriteText { Text = $"Logged in as {api?.Username}" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
Alpha = state == APIAccess.APIState.Offline ? 1 : 0,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Children = new[] { new LoginForm() }
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LoginForm : FlowContainer
|
|
||||||
{
|
|
||||||
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" },
|
|
||||||
new TextBox { Height = 20, RelativeSizeAxes = Axes.X },
|
|
||||||
new SpriteText { Text = "Password" },
|
|
||||||
new TextBox { Height = 20, RelativeSizeAxes = Axes.X },
|
|
||||||
new OsuButton
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Text = "Log in",
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Load(BaseGame game)
|
||||||
|
{
|
||||||
|
base.Load(game);
|
||||||
|
var osuGame = game as OsuGameBase;
|
||||||
|
if (osuGame == null)
|
||||||
|
return;
|
||||||
|
loginForm.Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new LoginForm(osuGame.API)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class LoginForm : FlowContainer
|
||||||
|
{
|
||||||
|
public LoginForm(APIAccess api)
|
||||||
|
{
|
||||||
|
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" },
|
||||||
|
new TextBox { Height = 20, RelativeSizeAxes = Axes.X, Text = api?.Username ?? string.Empty },
|
||||||
|
new SpriteText { Text = "Password" },
|
||||||
|
new TextBox { Height = 20, RelativeSizeAxes = Axes.X },
|
||||||
|
new OsuButton
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Text = "Log in",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework;
|
||||||
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;
|
||||||
@ -10,7 +11,9 @@ namespace osu.Game.Overlays.Options
|
|||||||
{
|
{
|
||||||
public class UpdateOptions : OptionsSubsection
|
public class UpdateOptions : OptionsSubsection
|
||||||
{
|
{
|
||||||
public UpdateOptions(BasicStorage storage)
|
private BasicStorage storage;
|
||||||
|
|
||||||
|
public UpdateOptions()
|
||||||
{
|
{
|
||||||
Header = "Updates";
|
Header = "Updates";
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -21,10 +24,16 @@ namespace osu.Game.Overlays.Options
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Text = "Open osu! folder",
|
Text = "Open osu! folder",
|
||||||
Action = storage.OpenInNativeExplorer,
|
Action = () => storage?.OpenInNativeExplorer(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Load(BaseGame game)
|
||||||
|
{
|
||||||
|
base.Load(game);
|
||||||
|
this.storage = game.Host.Storage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,24 +24,9 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
internal const float SideMargins = 10;
|
internal const float SideMargins = 10;
|
||||||
private const float width = 400;
|
private const float width = 400;
|
||||||
private FlowContainer optionsContainer;
|
|
||||||
private BasicStorage storage;
|
|
||||||
private OsuConfigManager configManager;
|
|
||||||
private APIAccess api;
|
|
||||||
|
|
||||||
protected override void Load(BaseGame game)
|
public OptionsOverlay()
|
||||||
{
|
{
|
||||||
base.Load(game);
|
|
||||||
|
|
||||||
storage = game.Host.Storage;
|
|
||||||
|
|
||||||
var osuGame = game as OsuGameBase;
|
|
||||||
if (osuGame != null)
|
|
||||||
{
|
|
||||||
configManager = osuGame.Config;
|
|
||||||
api = osuGame.API;
|
|
||||||
}
|
|
||||||
|
|
||||||
Depth = float.MaxValue;
|
Depth = float.MaxValue;
|
||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
Size = new Vector2(width, 1);
|
Size = new Vector2(width, 1);
|
||||||
@ -61,7 +46,7 @@ namespace osu.Game.Overlays
|
|||||||
ScrollDraggerOnLeft = true,
|
ScrollDraggerOnLeft = true,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
optionsContainer = new FlowContainer
|
new FlowContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
@ -81,7 +66,7 @@ namespace osu.Game.Overlays
|
|||||||
TextSize = 18,
|
TextSize = 18,
|
||||||
Margin = new MarginPadding { Left = SideMargins, Bottom = 30 },
|
Margin = new MarginPadding { Left = SideMargins, Bottom = 30 },
|
||||||
},
|
},
|
||||||
new GeneralOptions(storage, api),
|
new GeneralOptions(),
|
||||||
new GraphicsOptions(),
|
new GraphicsOptions(),
|
||||||
new GameplayOptions(),
|
new GameplayOptions(),
|
||||||
new AudioOptions(),
|
new AudioOptions(),
|
||||||
|
@ -227,6 +227,7 @@
|
|||||||
<Compile Include="Overlays\Options\MaintenanceOptions.cs" />
|
<Compile Include="Overlays\Options\MaintenanceOptions.cs" />
|
||||||
<Compile Include="Overlays\Options\OptionsSection.cs" />
|
<Compile Include="Overlays\Options\OptionsSection.cs" />
|
||||||
<Compile Include="Overlays\Options\OptionsSubsection.cs" />
|
<Compile Include="Overlays\Options\OptionsSubsection.cs" />
|
||||||
|
<Compile Include="Graphics\UserInterface\LoadingAnimation.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user