Merge branch 'master' into beatmap-carousel-refactor

This commit is contained in:
Dean Herbert
2020-10-19 20:46:55 +09:00
committed by GitHub
13 changed files with 117 additions and 16 deletions

View File

@ -0,0 +1,34 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using Android.Content.PM;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game;
namespace osu.Android
{
public class GameplayScreenRotationLocker : Component
{
private Bindable<bool> localUserPlaying;
[Resolved]
private OsuGameActivity gameActivity { get; set; }
[BackgroundDependencyLoader]
private void load(OsuGame game)
{
localUserPlaying = game.LocalUserPlaying.GetBoundCopy();
localUserPlaying.BindValueChanged(updateLock, true);
}
private void updateLock(ValueChangedEvent<bool> userPlaying)
{
gameActivity.RunOnUiThread(() =>
{
gameActivity.RequestedOrientation = userPlaying.NewValue ? ScreenOrientation.Locked : ScreenOrientation.FullUser;
});
}
}
}

View File

@ -12,7 +12,7 @@ namespace osu.Android
[Activity(Theme = "@android:style/Theme.NoTitleBar", MainLauncher = true, ScreenOrientation = ScreenOrientation.FullUser, SupportsPictureInPicture = false, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, HardwareAccelerated = false)] [Activity(Theme = "@android:style/Theme.NoTitleBar", MainLauncher = true, ScreenOrientation = ScreenOrientation.FullUser, SupportsPictureInPicture = false, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, HardwareAccelerated = false)]
public class OsuGameActivity : AndroidGameActivity public class OsuGameActivity : AndroidGameActivity
{ {
protected override Framework.Game CreateGame() => new OsuGameAndroid(); protected override Framework.Game CreateGame() => new OsuGameAndroid(this);
protected override void OnCreate(Bundle savedInstanceState) protected override void OnCreate(Bundle savedInstanceState)
{ {

View File

@ -4,6 +4,7 @@
using System; using System;
using Android.App; using Android.App;
using Android.OS; using Android.OS;
using osu.Framework.Allocation;
using osu.Game; using osu.Game;
using osu.Game.Updater; using osu.Game.Updater;
@ -11,6 +12,15 @@ namespace osu.Android
{ {
public class OsuGameAndroid : OsuGame public class OsuGameAndroid : OsuGame
{ {
[Cached]
private readonly OsuGameActivity gameActivity;
public OsuGameAndroid(OsuGameActivity activity)
: base(null)
{
gameActivity = activity;
}
public override Version AssemblyVersion public override Version AssemblyVersion
{ {
get get
@ -55,6 +65,12 @@ namespace osu.Android
} }
} }
protected override void LoadComplete()
{
base.LoadComplete();
LoadComponentAsync(new GameplayScreenRotationLocker(), Add);
}
protected override UpdateManager CreateUpdateManager() => new SimpleUpdateManager(); protected override UpdateManager CreateUpdateManager() => new SimpleUpdateManager();
} }
} }

View File

@ -21,6 +21,7 @@
<AndroidLinkTool>r8</AndroidLinkTool> <AndroidLinkTool>r8</AndroidLinkTool>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="GameplayScreenRotationLocker.cs" />
<Compile Include="OsuGameActivity.cs" /> <Compile Include="OsuGameActivity.cs" />
<Compile Include="OsuGameAndroid.cs" /> <Compile Include="OsuGameAndroid.cs" />
</ItemGroup> </ItemGroup>
@ -53,4 +54,4 @@
<AndroidResource Include="Resources\drawable\lazer.png" /> <AndroidResource Include="Resources\drawable\lazer.png" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project> </Project>

View File

@ -125,12 +125,14 @@ namespace osu.Desktop
{ {
base.SetHost(host); base.SetHost(host);
var iconStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "lazer.ico");
switch (host.Window) switch (host.Window)
{ {
// Legacy osuTK DesktopGameWindow // Legacy osuTK DesktopGameWindow
case DesktopGameWindow desktopGameWindow: case DesktopGameWindow desktopGameWindow:
desktopGameWindow.CursorState |= CursorState.Hidden; desktopGameWindow.CursorState |= CursorState.Hidden;
desktopGameWindow.SetIconFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "lazer.ico")); desktopGameWindow.SetIconFromStream(iconStream);
desktopGameWindow.Title = Name; desktopGameWindow.Title = Name;
desktopGameWindow.FileDrop += (_, e) => fileDrop(e.FileNames); desktopGameWindow.FileDrop += (_, e) => fileDrop(e.FileNames);
break; break;
@ -138,6 +140,7 @@ namespace osu.Desktop
// SDL2 DesktopWindow // SDL2 DesktopWindow
case DesktopWindow desktopWindow: case DesktopWindow desktopWindow:
desktopWindow.CursorState.Value |= CursorState.Hidden; desktopWindow.CursorState.Value |= CursorState.Hidden;
desktopWindow.SetIconFromStream(iconStream);
desktopWindow.Title = Name; desktopWindow.Title = Name;
desktopWindow.DragDrop += f => fileDrop(new[] { f }); desktopWindow.DragDrop += f => fileDrop(new[] { f });
break; break;

View File

@ -123,7 +123,10 @@ namespace osu.Game.Rulesets.Catch.Tests
Origin = Anchor.Centre, Origin = Anchor.Centre,
Scale = new Vector2(4f), Scale = new Vector2(4f),
}, skin); }, skin);
});
AddStep("get trails container", () =>
{
trails = catcherArea.OfType<CatcherTrailDisplay>().Single(); trails = catcherArea.OfType<CatcherTrailDisplay>().Single();
catcherArea.MovableCatcher.SetHyperDashState(2); catcherArea.MovableCatcher.SetHyperDashState(2);
}); });

View File

@ -103,6 +103,20 @@ namespace osu.Game.Online.Multiplayer
[JsonIgnore] [JsonIgnore]
public readonly Bindable<int> Position = new Bindable<int>(-1); public readonly Bindable<int> Position = new Bindable<int>(-1);
/// <summary>
/// Create a copy of this room without online information.
/// Should be used to create a local copy of a room for submitting in the future.
/// </summary>
public Room CreateCopy()
{
var copy = new Room();
copy.CopyFrom(this);
copy.RoomID.Value = null;
return copy;
}
public void CopyFrom(Room other) public void CopyFrom(Room other)
{ {
RoomID.Value = other.RoomID.Value; RoomID.Value = other.RoomID.Value;

View File

@ -371,8 +371,10 @@ namespace osu.Game
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);
RulesetStore?.Dispose(); RulesetStore?.Dispose();
BeatmapManager?.Dispose(); BeatmapManager?.Dispose();
LocalConfig?.Dispose();
contextFactory.FlushConnections(); contextFactory.FlushConnections();
} }

View File

@ -21,10 +21,12 @@ using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi.Components; using osu.Game.Screens.Multi.Components;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.UserInterface;
namespace osu.Game.Screens.Multi.Lounge.Components namespace osu.Game.Screens.Multi.Lounge.Components
{ {
public class DrawableRoom : OsuClickableContainer, IStateful<SelectionState>, IFilterable public class DrawableRoom : OsuClickableContainer, IStateful<SelectionState>, IFilterable, IHasContextMenu
{ {
public const float SELECTION_BORDER_WIDTH = 4; public const float SELECTION_BORDER_WIDTH = 4;
private const float corner_radius = 5; private const float corner_radius = 5;
@ -39,6 +41,9 @@ namespace osu.Game.Screens.Multi.Lounge.Components
private readonly Box selectionBox; private readonly Box selectionBox;
private CachedModelDependencyContainer<Room> dependencies; private CachedModelDependencyContainer<Room> dependencies;
[Resolved(canBeNull: true)]
private Multiplayer multiplayer { get; set; }
[Resolved] [Resolved]
private BeatmapManager beatmaps { get; set; } private BeatmapManager beatmaps { get; set; }
@ -232,5 +237,13 @@ namespace osu.Game.Screens.Multi.Lounge.Components
Current = name; Current = name;
} }
} }
public MenuItem[] ContextMenuItems => new MenuItem[]
{
new OsuMenuItem("Create copy", MenuItemType.Standard, () =>
{
multiplayer?.CreateRoom(Room.CreateCopy());
})
};
} }
} }

View File

@ -17,6 +17,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osuTK; using osuTK;
using osu.Game.Graphics.Cursor;
namespace osu.Game.Screens.Multi.Lounge.Components namespace osu.Game.Screens.Multi.Lounge.Components
{ {
@ -38,17 +39,25 @@ namespace osu.Game.Screens.Multi.Lounge.Components
[Resolved] [Resolved]
private IRoomManager roomManager { get; set; } private IRoomManager roomManager { get; set; }
[Resolved(CanBeNull = true)]
private LoungeSubScreen loungeSubScreen { get; set; }
public RoomsContainer() public RoomsContainer()
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
InternalChild = roomFlow = new FillFlowContainer<DrawableRoom> InternalChild = new OsuContextMenuContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical, Child = roomFlow = new FillFlowContainer<DrawableRoom>
Spacing = new Vector2(2), {
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(2),
}
}; };
} }

View File

@ -17,6 +17,7 @@ using osu.Game.Screens.Multi.Match;
namespace osu.Game.Screens.Multi.Lounge namespace osu.Game.Screens.Multi.Lounge
{ {
[Cached]
public class LoungeSubScreen : MultiplayerSubScreen public class LoungeSubScreen : MultiplayerSubScreen
{ {
public override string Title => "Lounge"; public override string Title => "Lounge";
@ -125,7 +126,7 @@ namespace osu.Game.Screens.Multi.Lounge
if (selectedRoom.Value?.RoomID.Value == null) if (selectedRoom.Value?.RoomID.Value == null)
selectedRoom.Value = new Room(); selectedRoom.Value = new Room();
music.EnsurePlayingSomething(); music?.EnsurePlayingSomething();
onReturning(); onReturning();
} }

View File

@ -51,7 +51,7 @@ namespace osu.Game.Screens.Multi
[Cached] [Cached]
private readonly Bindable<FilterCriteria> currentFilter = new Bindable<FilterCriteria>(new FilterCriteria()); private readonly Bindable<FilterCriteria> currentFilter = new Bindable<FilterCriteria>(new FilterCriteria());
[Resolved] [Resolved(CanBeNull = true)]
private MusicController music { get; set; } private MusicController music { get; set; }
[Cached(Type = typeof(IRoomManager))] [Cached(Type = typeof(IRoomManager))]
@ -134,7 +134,7 @@ namespace osu.Game.Screens.Multi
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
Action = createRoom Action = () => CreateRoom()
}, },
roomManager = new RoomManager() roomManager = new RoomManager()
} }
@ -289,10 +289,11 @@ namespace osu.Game.Screens.Multi
logo.Delay(WaveContainer.DISAPPEAR_DURATION / 2).FadeOut(); logo.Delay(WaveContainer.DISAPPEAR_DURATION / 2).FadeOut();
} }
private void createRoom() /// <summary>
{ /// Create a new room.
loungeSubScreen.Open(new Room { Name = { Value = $"{api.LocalUser}'s awesome room" } }); /// </summary>
} /// <param name="room">An optional template to use when creating the room.</param>
public void CreateRoom(Room room = null) => loungeSubScreen.Open(room ?? new Room { Name = { Value = $"{api.LocalUser}'s awesome room" } });
private void beginHandlingTrack() private void beginHandlingTrack()
{ {
@ -350,7 +351,7 @@ namespace osu.Game.Screens.Multi
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime; track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
track.Looping = true; track.Looping = true;
music.EnsurePlayingSomething(); music?.EnsurePlayingSomething();
} }
} }
else else

View File

@ -12,12 +12,16 @@ namespace osu.Game.Skinning
{ {
private readonly LegacyGlyphStore glyphStore; private readonly LegacyGlyphStore glyphStore;
protected override char FixedWidthReferenceCharacter => '5';
protected override char[] FixedWidthExcludeCharacters => new[] { ',', '.', '%', 'x' };
public LegacySpriteText(ISkin skin, string font = "score") public LegacySpriteText(ISkin skin, string font = "score")
{ {
Shadow = false; Shadow = false;
UseFullGlyphHeight = false; UseFullGlyphHeight = false;
Font = new FontUsage(font, 1); Font = new FontUsage(font, 1, fixedWidth: true);
glyphStore = new LegacyGlyphStore(skin); glyphStore = new LegacyGlyphStore(skin);
} }