More documentation

This commit is contained in:
smoogipoo 2021-04-08 00:06:32 +09:00
parent 024adb699c
commit 5dc939c2f3
2 changed files with 24 additions and 1 deletions

View File

@ -1,16 +1,25 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osuTK; using osuTK;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
{ {
/// <summary>
/// A grid of players playing the multiplayer match.
/// </summary>
public partial class PlayerGrid : CompositeDrawable public partial class PlayerGrid : CompositeDrawable
{ {
private const float player_spacing = 5; private const float player_spacing = 5;
/// <summary>
/// The currently-maximised facade.
/// </summary>
public Drawable MaximisedFacade => maximisedFacade; public Drawable MaximisedFacade => maximisedFacade;
private readonly Facade maximisedFacade; private readonly Facade maximisedFacade;
@ -52,6 +61,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
/// <exception cref="InvalidOperationException">If more than 16 cells are added.</exception> /// <exception cref="InvalidOperationException">If more than 16 cells are added.</exception>
public void Add(Drawable content) public void Add(Drawable content)
{ {
if (cellContainer.Count == 16)
throw new InvalidOperationException("Only 16 cells are supported.");
int index = cellContainer.Count; int index = cellContainer.Count;
var facade = new Facade(); var facade = new Facade();
@ -99,6 +111,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
{ {
base.Update(); base.Update();
// Different layouts are used for varying cell counts in order to maximise dimensions.
Vector2 cellsPerDimension; Vector2 cellsPerDimension;
switch (facadeContainer.Count) switch (facadeContainer.Count)
@ -141,7 +154,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
break; break;
} }
// Total spacing between cells // Total inter-cell spacing.
Vector2 totalCellSpacing = player_spacing * (cellsPerDimension - Vector2.One); Vector2 totalCellSpacing = player_spacing * (cellsPerDimension - Vector2.One);
Vector2 fullSize = paddingContainer.ChildSize - totalCellSpacing; Vector2 fullSize = paddingContainer.ChildSize - totalCellSpacing;

View File

@ -12,6 +12,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
{ {
public partial class PlayerGrid public partial class PlayerGrid
{ {
/// <summary>
/// A cell of the grid. Contains the content and tracks to the linked facade.
/// </summary>
private class Cell : CompositeDrawable private class Cell : CompositeDrawable
{ {
/// <summary> /// <summary>
@ -24,7 +27,14 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
/// </summary> /// </summary>
public readonly Drawable Content; public readonly Drawable Content;
/// <summary>
/// An action that toggles the maximisation state of this cell.
/// </summary>
public Action<Cell> ToggleMaximisationState; public Action<Cell> ToggleMaximisationState;
/// <summary>
/// Whether this cell is currently maximised.
/// </summary>
public bool IsMaximised; public bool IsMaximised;
private Facade facade; private Facade facade;