Add ability to adjust scores from gameplay screen

This commit is contained in:
Dean Herbert
2018-11-10 07:31:06 +09:00
parent e170372932
commit 1756ef95cb
2 changed files with 23 additions and 1 deletions

View File

@ -8,12 +8,14 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.Screens.Ladder.Components; using osu.Game.Tournament.Screens.Ladder.Components;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Input;
namespace osu.Game.Tournament.Screens.Gameplay namespace osu.Game.Tournament.Screens.Gameplay
{ {
@ -119,12 +121,30 @@ namespace osu.Game.Tournament.Screens.Gameplay
teamChanged(currentTeam.Value); teamChanged(currentTeam.Value);
} }
protected override bool OnMouseDown(MouseDownEvent e)
{
switch (e.Button)
{
case MouseButton.Left:
if (currentTeamScore.Value < currentMatch.Value.PointsToWin)
currentTeamScore.Value++;
return true;
case MouseButton.Right:
if (currentTeamScore.Value > 0)
currentTeamScore.Value--;
return true;
}
return base.OnMouseDown(e);
}
private void teamChanged(TournamentTeam team) private void teamChanged(TournamentTeam team)
{ {
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new TeamDisplay(team, teamColour == TeamColour.Red ? red : blue, teamColour != TeamColour.Red), new TeamDisplay(team, teamColour == TeamColour.Red ? red : blue, teamColour != TeamColour.Red),
new ScoreDisplay(currentTeamScore, teamColour != TeamColour.Red, currentMatch.Value.Grouping.Value.BestOf / 2 + 1) new ScoreDisplay(currentTeamScore, teamColour != TeamColour.Red, currentMatch.Value.PointsToWin)
}; };
} }
} }

View File

@ -74,6 +74,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
[JsonIgnore] [JsonIgnore]
public TournamentTeam Loser => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team2.Value : Team1.Value; public TournamentTeam Loser => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team2.Value : Team1.Value;
public int PointsToWin => Grouping.Value.BestOf / 2 + 1;
/// <summary> /// <summary>
/// Remove scores from the match, in case of a false click or false start. /// Remove scores from the match, in case of a false click or false start.
/// </summary> /// </summary>