mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 17:47:29 +08:00
Split up options into subclasses
This commit is contained in:
parent
2f990b884e
commit
2aa85a4b18
@ -16,13 +16,13 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
|
|
||||||
public override string Description => @"Tests the options overlay";
|
public override string Description => @"Tests the options overlay";
|
||||||
|
|
||||||
private Options options;
|
private OptionsOverlay options;
|
||||||
|
|
||||||
public override void Reset()
|
public override void Reset()
|
||||||
{
|
{
|
||||||
base.Reset();
|
base.Reset();
|
||||||
|
|
||||||
Children = new[] { options = new Options() };
|
Children = new[] { options = new OptionsOverlay() };
|
||||||
options.ToggleVisibility();
|
options.ToggleVisibility();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
protected override string MainResourceFile => @"osu.Game.Resources.dll";
|
protected override string MainResourceFile => @"osu.Game.Resources.dll";
|
||||||
|
|
||||||
public Options Options;
|
public OptionsOverlay Options;
|
||||||
public APIAccess API;
|
public APIAccess API;
|
||||||
|
|
||||||
protected override Container Content => ratioContainer;
|
protected override Container Content => ratioContainer;
|
||||||
@ -44,7 +44,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Options = new Options(),
|
Options = new OptionsOverlay(),
|
||||||
Cursor = new OsuCursorContainer()
|
Cursor = new OsuCursorContainer()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
25
osu.Game/Overlays/Options/GeneralOptions.cs
Normal file
25
osu.Game/Overlays/Options/GeneralOptions.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Platform;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Options
|
||||||
|
{
|
||||||
|
public class GeneralOptions : OptionsSection
|
||||||
|
{
|
||||||
|
public GeneralOptions(BasicStorage storage, APIAccess api)
|
||||||
|
{
|
||||||
|
Header = "General";
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new LoginOptions(api),
|
||||||
|
new LanguageOptions(),
|
||||||
|
new UpdateOptions(storage),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
27
osu.Game/Overlays/Options/LanguageOptions.cs
Normal file
27
osu.Game/Overlays/Options/LanguageOptions.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Options
|
||||||
|
{
|
||||||
|
public class LanguageOptions : OptionsSubsection
|
||||||
|
{
|
||||||
|
public LanguageOptions()
|
||||||
|
{
|
||||||
|
Header = "Language";
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new SpriteText { Text = "TODO: Dropdown" },
|
||||||
|
new BasicCheckBox
|
||||||
|
{
|
||||||
|
Children = new[] { new SpriteText { Text = "Prefer metadata in original language" } }
|
||||||
|
},
|
||||||
|
new BasicCheckBox
|
||||||
|
{
|
||||||
|
Children = new[] { new SpriteText { Text = "Use alternative font for chat display" } }
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
64
osu.Game/Overlays/Options/LoginOptions.cs
Normal file
64
osu.Game/Overlays/Options/LoginOptions.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using System;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Options
|
||||||
|
{
|
||||||
|
public class LoginOptions : OptionsSubsection
|
||||||
|
{
|
||||||
|
public LoginOptions(APIAccess api)
|
||||||
|
{
|
||||||
|
var state = api == null ? APIAccess.APIState.Offline : api.State;
|
||||||
|
Header = "Sign In";
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Alpha = state == APIAccess.APIState.Online ? 1 : 0,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
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 Button
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Text = "Log in",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
osu.Game/Overlays/Options/UpdateOptions.cs
Normal file
29
osu.Game/Overlays/Options/UpdateOptions.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Platform;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Options
|
||||||
|
{
|
||||||
|
public class UpdateOptions : OptionsSubsection
|
||||||
|
{
|
||||||
|
public UpdateOptions(BasicStorage storage)
|
||||||
|
{
|
||||||
|
Header = "Updates";
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new SpriteText { Text = "TODO: Dropdown" },
|
||||||
|
new SpriteText { Text = "Your osu! is up to date" }, // TODO: map this to reality
|
||||||
|
new Button
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Text = "Open osu! folder",
|
||||||
|
Action = storage.OpenInNativeExplorer,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,15 +14,20 @@ using osu.Framework.Graphics.Transformations;
|
|||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Overlays.Options;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
public class Options : OverlayContainer
|
public class OptionsOverlay : OverlayContainer
|
||||||
{
|
{
|
||||||
internal const float SideMargins = 10;
|
internal const float SideMargins = 10;
|
||||||
private const float width = 400;
|
private const float width = 400;
|
||||||
private FlowContainer optionsContainer;
|
private FlowContainer optionsContainer;
|
||||||
private BasicStorage storage;
|
private BasicStorage storage;
|
||||||
|
private OsuConfigManager configManager;
|
||||||
|
private APIAccess api;
|
||||||
|
|
||||||
protected override void Load(BaseGame game)
|
protected override void Load(BaseGame game)
|
||||||
{
|
{
|
||||||
@ -30,6 +35,13 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
storage = game.Host.Storage;
|
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);
|
||||||
@ -54,7 +66,7 @@ namespace osu.Game.Overlays
|
|||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Direction = FlowDirection.VerticalOnly,
|
Direction = FlowDirection.VerticalOnly,
|
||||||
Children = new[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SpriteText
|
new SpriteText
|
||||||
{
|
{
|
||||||
@ -68,65 +80,13 @@ namespace osu.Game.Overlays
|
|||||||
Text = "Change the way osu! behaves",
|
Text = "Change the way osu! behaves",
|
||||||
TextSize = 18,
|
TextSize = 18,
|
||||||
Margin = new MarginPadding { Left = SideMargins, Bottom = 30 },
|
Margin = new MarginPadding { Left = SideMargins, Bottom = 30 },
|
||||||
}
|
},
|
||||||
|
new GeneralOptions(storage, api),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
addGeneral();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addGeneral()
|
|
||||||
{
|
|
||||||
optionsContainer.Add(new OptionsSection
|
|
||||||
{
|
|
||||||
Header = "General",
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
new OptionsSubsection
|
|
||||||
{
|
|
||||||
Header = "Sign In",
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
new SpriteText { Text = "TODO" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new OptionsSubsection
|
|
||||||
{
|
|
||||||
Header = "Language",
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new SpriteText { Text = "TODO: Dropdown" },
|
|
||||||
new BasicCheckBox
|
|
||||||
{
|
|
||||||
Children = new[] { new SpriteText { Text = "Prefer metadata in original language" } }
|
|
||||||
},
|
|
||||||
new BasicCheckBox
|
|
||||||
{
|
|
||||||
Children = new[] { new SpriteText { Text = "Use alternative font for chat display" } }
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new OptionsSubsection
|
|
||||||
{
|
|
||||||
Header = "Updates",
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new SpriteText { Text = "TODO: Dropdown" },
|
|
||||||
new SpriteText { Text = "Your osu! is up to date" }, // TODO: map this to reality
|
|
||||||
new Button
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Colour = new Color4(14, 132, 165, 255),
|
|
||||||
Text = "Open osu! folder",
|
|
||||||
Action = storage.OpenInNativeExplorer,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
@ -153,7 +113,7 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OptionsSection : Container
|
public class OptionsSection : Container
|
||||||
{
|
{
|
||||||
private SpriteText header;
|
private SpriteText header;
|
||||||
private FlowContainer content;
|
private FlowContainer content;
|
||||||
@ -184,8 +144,8 @@ namespace osu.Game.Overlays
|
|||||||
Padding = new MarginPadding
|
Padding = new MarginPadding
|
||||||
{
|
{
|
||||||
Top = 10 + borderSize,
|
Top = 10 + borderSize,
|
||||||
Left = Options.SideMargins,
|
Left = OptionsOverlay.SideMargins,
|
||||||
Right = Options.SideMargins,
|
Right = OptionsOverlay.SideMargins,
|
||||||
},
|
},
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
@ -210,7 +170,7 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OptionsSubsection : Container
|
public class OptionsSubsection : Container
|
||||||
{
|
{
|
||||||
private SpriteText header;
|
private SpriteText header;
|
||||||
private Container content;
|
private Container content;
|
||||||
@ -233,6 +193,7 @@ namespace osu.Game.Overlays
|
|||||||
Direction = FlowDirection.VerticalOnly,
|
Direction = FlowDirection.VerticalOnly,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Spacing = new Vector2(0, 5),
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
header = new SpriteText
|
header = new SpriteText
|
@ -177,7 +177,7 @@
|
|||||||
<Compile Include="OsuGame.cs" />
|
<Compile Include="OsuGame.cs" />
|
||||||
<Compile Include="OsuGameBase.cs" />
|
<Compile Include="OsuGameBase.cs" />
|
||||||
<Compile Include="Overlays\ChatConsole.cs" />
|
<Compile Include="Overlays\ChatConsole.cs" />
|
||||||
<Compile Include="Overlays\Options.cs" />
|
<Compile Include="Overlays\OptionsOverlay.cs" />
|
||||||
<Compile Include="Overlays\Toolbar.cs" />
|
<Compile Include="Overlays\Toolbar.cs" />
|
||||||
<Compile Include="Overlays\ToolbarButton.cs" />
|
<Compile Include="Overlays\ToolbarButton.cs" />
|
||||||
<Compile Include="Overlays\ToolbarModeButton.cs" />
|
<Compile Include="Overlays\ToolbarModeButton.cs" />
|
||||||
@ -196,6 +196,10 @@
|
|||||||
<Compile Include="Database\BeatmapMetadata.cs" />
|
<Compile Include="Database\BeatmapMetadata.cs" />
|
||||||
<Compile Include="Database\BeatmapInfo.cs" />
|
<Compile Include="Database\BeatmapInfo.cs" />
|
||||||
<Compile Include="Database\BaseDifficulty.cs" />
|
<Compile Include="Database\BaseDifficulty.cs" />
|
||||||
|
<Compile Include="Overlays\Options\LoginOptions.cs" />
|
||||||
|
<Compile Include="Overlays\Options\GeneralOptions.cs" />
|
||||||
|
<Compile Include="Overlays\Options\LanguageOptions.cs" />
|
||||||
|
<Compile Include="Overlays\Options\UpdateOptions.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">
|
||||||
@ -215,6 +219,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Overlays\Options\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
Loading…
Reference in New Issue
Block a user