Skip to content

Commit 519cf7b

Browse files
committed
设计的一部分
完成了(但没有测试)阶段显示 热手 赛点 TB
1 parent faf6cd8 commit 519cf7b

File tree

11 files changed

+210
-117
lines changed

11 files changed

+210
-117
lines changed

osu.Game.Tournament.Tests/Components/TestSceneDrawableTournamentTeam.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using osu.Game.Tournament.Models;
1010
using osu.Game.Tournament.Screens.Drawings.Components;
1111
using osu.Game.Tournament.Screens.Gameplay.Components;
12+
using osu.Game.Tournament.Screens.Gameplay.Components.MatchHeader;
1213
using osu.Game.Tournament.Screens.Ladder.Components;
1314

1415
namespace osu.Game.Tournament.Tests.Components

osu.Game.Tournament.Tests/Components/TestSceneMatchHeader.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using osu.Framework.Graphics.Containers;
66
using osu.Game.Graphics;
77
using osu.Game.Tournament.Screens.Gameplay.Components;
8+
using osu.Game.Tournament.Screens.Gameplay.Components.MatchHeader;
89
using osuTK;
910

1011
namespace osu.Game.Tournament.Tests.Components

osu.Game.Tournament/Screens/Gameplay/Components/MatchHeader.cs renamed to osu.Game.Tournament/Screens/Gameplay/Components/MatchHeader/MatchHeader.cs

Lines changed: 22 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44
using osu.Framework.Allocation;
55
using osu.Framework.Graphics;
66
using osu.Framework.Graphics.Containers;
7-
using osu.Game.Tournament.Components;
87
using osu.Game.Tournament.Models;
98
using osuTK;
109

11-
namespace osu.Game.Tournament.Screens.Gameplay.Components
10+
namespace osu.Game.Tournament.Screens.Gameplay.Components.MatchHeader
1211
{
1312
public partial class MatchHeader : Container
1413
{
1514
private TeamScoreDisplay teamDisplay1 = null!;
1615
private TeamScoreDisplay teamDisplay2 = null!;
17-
private DrawableTournamentHeaderLogo logo = null!;
18-
private MatchRoundDisplay roundDisplay = null!;
16+
private RoundStage roundStage = null!;
1917

2018
private bool showScores = true;
2119

@@ -34,34 +32,17 @@ public bool ShowScores
3432
}
3533
}
3634

37-
private bool showLogo = true;
38-
39-
public bool ShowLogo
40-
{
41-
get => showLogo;
42-
set
43-
{
44-
if (value == showLogo)
45-
return;
46-
47-
showLogo = value;
48-
49-
if (IsLoaded)
50-
updateDisplay();
51-
}
52-
}
53-
54-
private bool showRound = true;
35+
private bool showPoint = true;
5536

5637
public bool ShowRound
5738
{
58-
get => showRound;
39+
get => showPoint;
5940
set
6041
{
61-
if (value == showRound)
42+
if (value == showPoint)
6243
return;
6344

64-
showRound = value;
45+
showPoint = value;
6546

6647
if (IsLoaded)
6748
updateDisplay();
@@ -73,45 +54,38 @@ private void load()
7354
{
7455
RelativeSizeAxes = Axes.X;
7556
Height = 95;
57+
7658
Children = new Drawable[]
7759
{
7860
new FillFlowContainer
7961
{
62+
Origin = Anchor.Centre,
63+
Anchor = Anchor.Centre,
8064
RelativeSizeAxes = Axes.Both,
81-
Direction = FillDirection.Vertical,
65+
Direction = FillDirection.Horizontal,
8266
Padding = new MarginPadding(20),
8367
Spacing = new Vector2(5),
8468
Children = new Drawable[]
8569
{
86-
logo = new DrawableTournamentHeaderLogo
70+
teamDisplay1 = new TeamScoreDisplay(TeamColour.Red)
8771
{
88-
Anchor = Anchor.TopCentre,
89-
Origin = Anchor.TopCentre,
90-
Alpha = showLogo ? 1 : 0
72+
Anchor = Anchor.TopLeft,
73+
Origin = Anchor.TopLeft,
9174
},
92-
new DrawableTournamentHeaderText
75+
new MatchRoundDisplay
9376
{
94-
Anchor = Anchor.TopCentre,
95-
Origin = Anchor.TopCentre,
77+
Anchor = Anchor.TopLeft,
78+
Origin = Anchor.TopLeft,
79+
Scale = new Vector2(0.4f)
9680
},
97-
roundDisplay = new MatchRoundDisplay
81+
teamDisplay2 = new TeamScoreDisplay(TeamColour.Blue)
9882
{
99-
Anchor = Anchor.TopCentre,
100-
Origin = Anchor.TopCentre,
101-
Scale = new Vector2(0.4f)
83+
Anchor = Anchor.TopLeft,
84+
Origin = Anchor.TopLeft,
10285
},
10386
}
10487
},
105-
teamDisplay1 = new TeamScoreDisplay(TeamColour.Red)
106-
{
107-
Anchor = Anchor.TopLeft,
108-
Origin = Anchor.TopLeft,
109-
},
110-
teamDisplay2 = new TeamScoreDisplay(TeamColour.Blue)
111-
{
112-
Anchor = Anchor.TopRight,
113-
Origin = Anchor.TopRight,
114-
},
88+
roundStage = new RoundStage()
11589
};
11690
}
11791

@@ -125,13 +99,7 @@ private void updateDisplay()
12599
{
126100
teamDisplay1.ShowScore = showScores;
127101
teamDisplay2.ShowScore = showScores;
128-
129-
logo.Alpha = showLogo ? 1 : 0;
130-
131-
if (showRound)
132-
roundDisplay.FadeIn(250);
133-
else
134-
roundDisplay.FadeOut(250);
102+
roundStage.WarmUp.Value = !showScores;
135103
}
136104
}
137105
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using osu.Framework.Allocation;
5+
using osu.Framework.Bindables;
6+
using osu.Framework.Graphics;
7+
using osu.Framework.Graphics.Containers;
8+
using osu.Framework.Graphics.Shapes;
9+
using osu.Game.Graphics;
10+
using osu.Game.Tournament.Models;
11+
using osuTK.Graphics;
12+
13+
namespace osu.Game.Tournament.Screens.Gameplay.Components.MatchHeader
14+
{
15+
public partial class MatchRoundDisplay : Container
16+
{
17+
private readonly Bindable<TournamentMatch?> currentMatch = new Bindable<TournamentMatch?>();
18+
private readonly Bindable<TournamentRound?> currentRound = new Bindable<TournamentRound?>();
19+
private TournamentSpriteText roundName = null!;
20+
private TournamentSpriteText roundInfo = null!;
21+
22+
[BackgroundDependencyLoader]
23+
private void load(LadderInfo ladder)
24+
{
25+
Height = 24;
26+
AutoSizeAxes = Axes.X;
27+
28+
InternalChildren = new Drawable[]
29+
{
30+
new Box
31+
{
32+
RelativeSizeAxes = Axes.Both,
33+
Colour = Color4.White,
34+
},
35+
roundName = new TournamentSpriteText
36+
{
37+
Anchor = Anchor.TopCentre,
38+
Origin = Anchor.TopCentre,
39+
Font = OsuFont.Torus.With(size: 13),
40+
},
41+
roundInfo = new TournamentSpriteText
42+
{
43+
Anchor = Anchor.TopCentre,
44+
Origin = Anchor.TopCentre,
45+
Font = OsuFont.Torus.With(size: 11),
46+
},
47+
};
48+
49+
roundName.Margin = new MarginPadding { Horizontal = 10f };
50+
51+
currentMatch.BindValueChanged(matchChanged);
52+
currentMatch.BindTo(ladder.CurrentMatch);
53+
}
54+
55+
private void matchChanged(ValueChangedEvent<TournamentMatch?> match)
56+
{
57+
currentRound.Value = match.NewValue?.Round.Value;
58+
currentRound.Value?.Name.BindValueChanged(_ => Schedule(updateText), true);
59+
}
60+
61+
private void updateText()
62+
{
63+
roundName.Text = currentMatch.Value?.Round.Value?.Name.Value ?? "Unknown Round";
64+
}
65+
}
66+
}

osu.Game.Tournament/Screens/Gameplay/Components/MatchRoundNameTextBox.cs renamed to osu.Game.Tournament/Screens/Gameplay/Components/MatchHeader/MatchRoundNameTextBox.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using osu.Game.Overlays.Settings;
66
using osu.Game.Tournament.Models;
77

8-
namespace osu.Game.Tournament.Screens.Gameplay.Components
8+
namespace osu.Game.Tournament.Screens.Gameplay.Components.MatchHeader
99
{
1010
public partial class MatchRoundNameTextBox : SettingsTextBox
1111
{
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using System;
5+
using osu.Framework.Allocation;
6+
using osu.Framework.Bindables;
7+
using osu.Framework.Extensions.Color4Extensions;
8+
using osu.Framework.Graphics;
9+
using osu.Game.Tournament.Components;
10+
using osu.Game.Tournament.Models;
11+
using osuTK.Graphics;
12+
13+
namespace osu.Game.Tournament.Screens.Gameplay.Components.MatchHeader
14+
{
15+
public partial class RoundStage : TournamentSpriteTextWithBackground
16+
{
17+
[Resolved]
18+
private LadderInfo ladder { get; set; } = null!;
19+
20+
private readonly Bindable<TournamentMatch?> currentMatch = new Bindable<TournamentMatch?>();
21+
private readonly Bindable<int?> team1Score = new Bindable<int?>();
22+
private readonly Bindable<int?> team2Score = new Bindable<int?>();
23+
24+
public BindableBool WarmUp { get; } = new BindableBool();
25+
26+
public RoundStage()
27+
{
28+
AutoSizeAxes = Axes.None;
29+
Height = 16;
30+
Width = 120;
31+
32+
Text.Alpha = 0;
33+
Background.Alpha = 0;
34+
}
35+
36+
[BackgroundDependencyLoader]
37+
private void load()
38+
{
39+
currentMatch.BindTo(ladder.CurrentMatch);
40+
currentMatch.BindValueChanged(matchChanged);
41+
WarmUp.BindValueChanged(_ => updateDisplay());
42+
43+
updateMatch();
44+
}
45+
46+
private void matchChanged(ValueChangedEvent<TournamentMatch?> match)
47+
{
48+
team1Score.UnbindBindings();
49+
team2Score.UnbindBindings();
50+
51+
Scheduler.AddOnce(updateMatch);
52+
}
53+
54+
private void updateMatch()
55+
{
56+
var match = currentMatch.Value;
57+
58+
if (match == null) return;
59+
60+
match.StartMatch();
61+
62+
team1Score.BindTo(match.Team1Score);
63+
team2Score.BindTo(match.Team2Score);
64+
65+
updateDisplay();
66+
}
67+
68+
private void updateDisplay()
69+
{
70+
if (currentMatch.Value == null)
71+
{
72+
this.FadeOut(200);
73+
return;
74+
}
75+
76+
if (WarmUp.Value)
77+
{
78+
this.FadeIn(200);
79+
Background.FadeColour(Color4Extensions.FromHex("#FFC300"), 200);
80+
Text.FadeColour(Color4.Black, 200);
81+
Text.Text = "热 身 阶 段";
82+
return;
83+
}
84+
85+
int pointToWin = currentMatch.Value.PointsToWin;
86+
int score1 = team1Score.Value ?? 0;
87+
int score2 = team2Score.Value ?? 0;
88+
89+
bool matchPoint = Math.Max(score1, score2) >= pointToWin - 1;
90+
91+
if (!matchPoint)
92+
{
93+
this.FadeOut(200);
94+
return;
95+
}
96+
97+
this.FadeIn(200);
98+
Text.FadeColour(Color4.White, 200);
99+
100+
if (score1 + score2 >= pointToWin * 2 - 1)
101+
{
102+
Background.FadeColour(Color4Extensions.FromHex("#E33C64"), 200);
103+
Text.Text = "决 胜 局";
104+
}
105+
else
106+
{
107+
Background.FadeColour(Color4Extensions.FromHex("#2A82E4"), 200);
108+
Text.Text = "赛 点";
109+
}
110+
}
111+
}
112+
}

osu.Game.Tournament/Screens/Gameplay/Components/TeamDisplay.cs renamed to osu.Game.Tournament/Screens/Gameplay/Components/MatchHeader/TeamDisplay.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using osu.Game.Tournament.Models;
99
using osuTK;
1010

11-
namespace osu.Game.Tournament.Screens.Gameplay.Components
11+
namespace osu.Game.Tournament.Screens.Gameplay.Components.MatchHeader
1212
{
1313
public partial class TeamDisplay : DrawableTournamentTeam
1414
{

osu.Game.Tournament/Screens/Gameplay/Components/MatchRoundDisplay.cs

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)