1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 18:03:11 +08:00

Improve file layouts

This commit is contained in:
Dean Herbert 2019-02-12 13:02:33 +09:00
parent 78b47f9fe3
commit 272584eb79
2 changed files with 84 additions and 94 deletions

View File

@ -45,41 +45,17 @@ namespace osu.Game.Screens.Multi.Match
[Resolved]
protected Bindable<IEnumerable<Mod>> CurrentMods { get; private set; }
public MatchSubScreen(Room room)
{
Title = room.RoomID.Value == null ? "New room" : room.Name;
}
private MatchLeaderboard leaderboard;
[Resolved]
private BeatmapManager beatmapManager { get; set; }
[Resolved(CanBeNull = true)]
private OsuGame game { get; set; }
protected override void LoadComplete()
private MatchLeaderboard leaderboard;
public MatchSubScreen(Room room)
{
base.LoadComplete();
CurrentItem.BindValueChanged(currentItemChanged, true);
}
private void currentItemChanged(PlaylistItem item)
{
// Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info
var localBeatmap = item?.Beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == item.Beatmap.OnlineBeatmapID);
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
CurrentMods.Value = item?.RequiredMods ?? Enumerable.Empty<Mod>();
if (item?.Ruleset != null)
Ruleset.Value = item.Ruleset;
}
public override bool OnExiting(IScreen next)
{
RoomManager?.PartRoom();
return base.OnExiting(next);
Title = room.RoomID.Value == null ? "New room" : room.Name;
}
[BackgroundDependencyLoader]
@ -196,6 +172,30 @@ namespace osu.Game.Screens.Multi.Match
beatmapManager.ItemAdded += beatmapAdded;
}
protected override void LoadComplete()
{
base.LoadComplete();
CurrentItem.BindValueChanged(currentItemChanged, true);
}
private void currentItemChanged(PlaylistItem item)
{
// Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info
var localBeatmap = item?.Beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == item.Beatmap.OnlineBeatmapID);
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
CurrentMods.Value = item?.RequiredMods ?? Enumerable.Empty<Mod>();
if (item?.Ruleset != null)
Ruleset.Value = item.Ruleset;
}
public override bool OnExiting(IScreen next)
{
RoomManager?.PartRoom();
return base.OnExiting(next);
}
/// <summary>
/// Handle the case where a beatmap is imported (and can be used by this match).
/// </summary>

View File

@ -64,64 +64,61 @@ namespace osu.Game.Screens.Multi
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.Both;
Padding = new MarginPadding { Horizontal = -HORIZONTAL_OVERFLOW_PADDING };
InternalChild = waves = new MultiplayerWaveContainer
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"3e3a44"),
},
new Triangles
{
RelativeSizeAxes = Axes.Both,
ColourLight = OsuColour.FromHex(@"3c3842"),
ColourDark = OsuColour.FromHex(@"393540"),
TriangleScale = 5,
},
},
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = Header.HEIGHT },
Child = screenStack = new ScreenStack(loungeSubScreen = new LoungeSubScreen()) { RelativeSizeAxes = Axes.Both }
},
new Header(screenStack),
createButton = new HeaderButton
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.None,
Size = new Vector2(150, Header.HEIGHT - 20),
Margin = new MarginPadding
{
Top = 10,
Right = 10 + HORIZONTAL_OVERFLOW_PADDING,
},
Text = "Create room",
Action = () => loungeSubScreen.Open(new Room
{
Name = { Value = $"{api.LocalUser}'s awesome room" }
}),
},
roomManager = new RoomManager()
}
};
screenStack = new ScreenStack(loungeSubScreen = new LoungeSubScreen()) { RelativeSizeAxes = Axes.Both };
Padding = new MarginPadding { Horizontal = -HORIZONTAL_OVERFLOW_PADDING };
waves.AddRange(new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"3e3a44"),
},
new Triangles
{
RelativeSizeAxes = Axes.Both,
ColourLight = OsuColour.FromHex(@"3c3842"),
ColourDark = OsuColour.FromHex(@"393540"),
TriangleScale = 5,
},
},
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = Header.HEIGHT },
Child = screenStack
},
new Header(screenStack),
createButton = new HeaderButton
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.None,
Size = new Vector2(150, Header.HEIGHT - 20),
Margin = new MarginPadding
{
Top = 10,
Right = 10 + HORIZONTAL_OVERFLOW_PADDING,
},
Text = "Create room",
Action = () => loungeSubScreen.Open(new Room
{
Name = { Value = $"{api.LocalUser}'s awesome room" }
}),
},
roomManager = new RoomManager()
});
screenStack.ScreenPushed += screenPushed;
screenStack.ScreenExited += screenExited;
}
@ -141,11 +138,9 @@ namespace osu.Game.Screens.Multi
isIdle.BindValueChanged(updatePollingRate, true);
}
private CachedModelDependencyContainer<Room> dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
dependencies = new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent));
var dependencies = new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent));
dependencies.Model.BindTo(currentRoom);
return dependencies;
}
@ -156,12 +151,16 @@ namespace osu.Game.Screens.Multi
Logger.Log($"Polling adjusted to {roomManager.TimeBetweenPolls}");
}
private void pushGameplayScreen(IScreen gameplayScreen)
/// <summary>
/// Push a <see cref="Player"/> to the main screen stack to begin gameplay.
/// Generally called from a <see cref="MatchSubScreen"/> via DI resolution.
/// </summary>
public void Start(Func<Player> player)
{
if (!this.IsCurrentScreen())
return;
this.Push(gameplayScreen);
this.Push(new PlayerLoader(player));
}
public void APIStateChanged(APIAccess api, APIState state)
@ -294,14 +293,5 @@ namespace osu.Game.Screens.Multi
FourthWaveColour = OsuColour.FromHex(@"392850");
}
}
/// <summary>
/// Push a <see cref="Player"/> to the main screen stack to begin gameplay.
/// Generally called from a <see cref="MatchSubScreen"/> via DI resolution.
/// </summary>
public void Start(Func<Player> player)
{
this.Push(new PlayerLoader(player));
}
}
}