Merge branch 'master' into drawnode-composability

This commit is contained in:
Dean Herbert
2019-04-27 18:41:19 +09:00
committed by GitHub
144 changed files with 1303 additions and 626 deletions

View File

@ -13,15 +13,13 @@ namespace osu.Game.Screens.Multi.Components
protected override void AddTabItem(TabItem<T> tab, bool addToDropdown = true)
{
if (tab is DisableableTabItem<T> disableable)
if (tab is DisableableTabItem disableable)
disableable.Enabled.BindTo(Enabled);
base.AddTabItem(tab, addToDropdown);
}
protected abstract class DisableableTabItem<T> : TabItem<T>
protected abstract class DisableableTabItem : TabItem<T>
{
public readonly BindableBool Enabled = new BindableBool();
protected DisableableTabItem(T value)
: base(value)
{

View File

@ -79,7 +79,7 @@ namespace osu.Game.Screens.Multi
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Title = "multiplayer";
Title = "multi";
Icon = OsuIcon.Multi;
AccentColour = colours.Yellow;
}

View File

@ -25,8 +25,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components
private void load(OsuColour colours)
{
OsuSpriteText summary;
OsuSpriteText levelRangeHigher;
OsuSpriteText levelRangeLower;
Container flagContainer;
LinkFlowContainer hostText;
@ -45,21 +43,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components
Width = 22f,
RelativeSizeAxes = Axes.Y,
},
/*new Container //todo: team banners
{
Width = 38f,
RelativeSizeAxes = Axes.Y,
CornerRadius = 2f,
Masking = true,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"ad387e"),
},
},
},*/
hostText = new LinkFlowContainer
{
Anchor = Anchor.CentreLeft,
@ -101,13 +84,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components
}, true);
ParticipantCount.BindValueChanged(count => summary.Text = "participant".ToQuantity(count.NewValue), true);
/*Participants.BindValueChanged(e =>
{
var ranks = v.Select(u => u.Statistics.Ranks.Global);
levelRangeLower.Text = ranks.Min().ToString();
levelRangeHigher.Text = ranks.Max().ToString();
});*/
}
}
}

View File

@ -97,7 +97,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.GetFont(size: 30),
Current = Name
Current = RoomName
},
},
},

View File

@ -36,7 +36,7 @@ namespace osu.Game.Screens.Multi.Match.Components
AddItem(new GameTypeTimeshift());
}
private class GameTypePickerItem : DisableableTabItem<GameType>
private class GameTypePickerItem : DisableableTabItem
{
private const float transition_duration = 200;

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
@ -110,7 +109,7 @@ namespace osu.Game.Screens.Multi.Match.Components
},
};
CurrentItem.BindValueChanged(item => modDisplay.Current.Value = item.NewValue?.RequiredMods ?? Enumerable.Empty<Mod>(), true);
CurrentItem.BindValueChanged(item => modDisplay.Current.Value = item.NewValue?.RequiredMods?.ToArray() ?? Array.Empty<Mod>(), true);
beatmapButton.Action = () => RequestBeatmapSelection?.Invoke();
}

View File

@ -30,7 +30,6 @@ namespace osu.Game.Screens.Multi.Match.Components
ReadyButton readyButton;
ViewBeatmapButton viewBeatmapButton;
HostInfo hostInfo;
RoomStatusInfo statusInfo;
InternalChildren = new Drawable[]
{
@ -63,7 +62,7 @@ namespace osu.Game.Screens.Multi.Match.Components
new OsuSpriteText
{
Font = OsuFont.GetFont(size: 30),
Current = Name
Current = RoomName
},
new RoomStatusInfo(),
}

View File

@ -265,7 +265,7 @@ namespace osu.Game.Screens.Multi.Match.Components
};
TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue?.Name ?? string.Empty, true);
Name.BindValueChanged(name => NameField.Text = name.NewValue, true);
RoomName.BindValueChanged(name => NameField.Text = name.NewValue, true);
Availability.BindValueChanged(availability => AvailabilityPicker.Current.Value = availability.NewValue, true);
Type.BindValueChanged(type => TypePicker.Current.Value = type.NewValue, true);
MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true);
@ -285,7 +285,7 @@ namespace osu.Game.Screens.Multi.Match.Components
{
hideError();
Name.Value = NameField.Text;
RoomName.Value = NameField.Text;
Availability.Value = AvailabilityPicker.Current.Value;
Type.Value = TypePicker.Current.Value;

View File

@ -33,7 +33,7 @@ namespace osu.Game.Screens.Multi.Match.Components
AddItem(RoomAvailability.InviteOnly);
}
private class RoomAvailabilityPickerItem : DisableableTabItem<RoomAvailability>
private class RoomAvailabilityPickerItem : DisableableTabItem
{
private const float transition_duration = 200;

View File

@ -1,8 +1,7 @@
// 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 System.Collections.Generic;
using System.Linq;
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -42,9 +41,6 @@ namespace osu.Game.Screens.Multi.Match
[Resolved(typeof(Room))]
protected Bindable<PlaylistItem> CurrentItem { get; private set; }
[Resolved]
protected Bindable<IEnumerable<Mod>> SelectedMods { get; private set; }
[Resolved]
private BeatmapManager beatmapManager { get; set; }
@ -182,6 +178,9 @@ namespace osu.Game.Screens.Multi.Match
public override bool OnExiting(IScreen next)
{
RoomManager?.PartRoom();
Mods.Value = Array.Empty<Mod>();
return base.OnExiting(next);
}
@ -194,7 +193,7 @@ namespace osu.Game.Screens.Multi.Match
var localBeatmap = e.NewValue?.Beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == e.NewValue.Beatmap.OnlineBeatmapID);
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
SelectedMods.Value = e.NewValue?.RequiredMods ?? Enumerable.Empty<Mod>();
Mods.Value = e.NewValue?.RequiredMods?.ToArray() ?? Array.Empty<Mod>();
if (e.NewValue?.Ruleset != null)
Ruleset.Value = e.NewValue.Ruleset;
}
@ -222,8 +221,6 @@ namespace osu.Game.Screens.Multi.Match
private void onStart()
{
Beatmap.Value.Mods.Value = SelectedMods.Value.ToArray();
switch (type.Value)
{
default:

View File

@ -276,7 +276,7 @@ namespace osu.Game.Screens.Multi
updatePollingRate(isIdle.Value);
if (screenStack.CurrentScreen == null)
if (screenStack.CurrentScreen == null && this.IsCurrentScreen())
this.Exit();
}

View File

@ -16,8 +16,8 @@ namespace osu.Game.Screens.Multi
[Resolved(typeof(Room))]
protected Bindable<int?> RoomID { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<string> Name { get; private set; }
[Resolved(typeof(Room), nameof(Room.Name))]
protected Bindable<string> RoomName { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<User> Host { get; private set; }

View File

@ -3,22 +3,17 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input.Bindings;
using osu.Framework.Screens;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
namespace osu.Game.Screens.Multi
{
public abstract class MultiplayerSubScreen : OsuScreen, IMultiplayerSubScreen, IKeyBindingHandler<GlobalAction>
public abstract class MultiplayerSubScreen : OsuScreen, IMultiplayerSubScreen
{
public override bool DisallowExternalBeatmapRulesetChanges => false;
public virtual string ShortTitle => Title;
[Resolved(CanBeNull = true)]
protected OsuGame Game { get; private set; }
[Resolved(CanBeNull = true)]
protected IRoomManager RoomManager { get; private set; }
@ -56,21 +51,6 @@ namespace osu.Game.Screens.Multi
this.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
}
public override bool OnPressed(GlobalAction action)
{
if (!this.IsCurrentScreen()) return false;
if (action == GlobalAction.Back)
{
this.Exit();
return true;
}
return false;
}
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back;
public override string ToString() => Title;
}
}

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
@ -14,7 +13,6 @@ using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Multi.Ranking;
using osu.Game.Screens.Play;
@ -37,9 +35,6 @@ namespace osu.Game.Screens.Multi.Play
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
[Resolved]
private Bindable<IEnumerable<Mod>> selectedMods { get; set; }
public TimeshiftPlayer(PlaylistItem playlistItem)
{
this.playlistItem = playlistItem;
@ -61,7 +56,7 @@ namespace osu.Game.Screens.Multi.Play
if (ruleset.Value.ID != playlistItem.Ruleset.ID)
throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset");
if (!playlistItem.RequiredMods.All(m => selectedMods.Value.Contains(m)))
if (!playlistItem.RequiredMods.All(m => Mods.Value.Contains(m)))
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID);

View File

@ -171,7 +171,7 @@ namespace osu.Game.Screens.Multi
/// <summary>
/// Adds a <see cref="Room"/> to the list of available rooms.
/// </summary>
/// <param name="room">The <see cref="Room"/> to add.<</param>
/// <param name="room">The <see cref="Room"/> to add.</param>
private void addRoom(Room room)
{
var existing = rooms.FirstOrDefault(e => e.RoomID.Value == room.RoomID.Value);