4
4
5
5
public partial class LobbyView : Control
6
6
{
7
+ [ Signal ] public delegate void MatchSelected ( string matchId ) ;
7
8
[ Signal ] public delegate void MessageSubmitted ( string message ) ;
8
9
[ Signal ] public delegate void ScenarioSelected ( string mapName ) ;
10
+ [ Signal ] public delegate void RefreshButtonPressed ( ) ;
9
11
[ Signal ] public delegate void JoinButtonPressed ( ) ;
12
+ [ Signal ] public delegate void CreateButtonPressed ( ) ;
13
+ [ Signal ] public delegate void QueueButtonPressed ( ) ;
10
14
[ Signal ] public delegate void BackButtonPressed ( ) ;
11
15
[ Signal ] public delegate void CancelButtonPressed ( ) ;
12
16
13
17
[ Export ] private PackedScene ChatMessageView ;
18
+ [ Export ] private PackedScene MatchListing ;
14
19
15
20
private VBoxContainer _userListContainer ;
21
+ private VBoxContainer _matchListContainer ;
16
22
private VBoxContainer _messages ;
17
23
private LineEdit _input ;
18
24
19
25
private OptionButton _scenarioOptions ;
26
+ private Button _queueButton ;
20
27
private Button _joinButton ;
21
28
private Label _infoLabel ;
22
29
23
30
public override void _Ready ( )
24
31
{
25
32
_userListContainer = GetNode < VBoxContainer > ( "PanelContainer/HBoxContainer/VBoxContainer2/Panel/VBoxContainer/UserList" ) ;
33
+ _matchListContainer = GetNode < VBoxContainer > ( "PanelContainer/HBoxContainer/VBoxContainer/Panel2/MarginContainer/MatchList" ) ;
34
+
26
35
_messages = GetNode < VBoxContainer > ( "PanelContainer/HBoxContainer/VBoxContainer/Panel/MarginContainer/Messages" ) ;
27
36
_input = GetNode < LineEdit > ( "PanelContainer/HBoxContainer/VBoxContainer/HBoxContainer/LineEdit" ) ;
28
37
29
- _joinButton = GetNode < Button > ( "PanelContainer/HBoxContainer/VBoxContainer2/HBoxContainer/JoinButton" ) ;
38
+ _queueButton = GetNode < Button > ( "PanelContainer/HBoxContainer/VBoxContainer2/HBoxContainer/QueueButton" ) ;
39
+ _joinButton = GetNode < Button > ( "PanelContainer/HBoxContainer/VBoxContainer2/JoinButton" ) ;
30
40
_infoLabel = GetNode < Label > ( "PanelContainer/HBoxContainer/VBoxContainer2/Label" ) ;
31
41
_scenarioOptions = GetNode < OptionButton > ( "PanelContainer/HBoxContainer/VBoxContainer2/MapOptionButton" ) ;
32
42
@@ -39,19 +49,37 @@ public override void _Ready()
39
49
OnMapOptionButtonItemSelected ( 0 ) ;
40
50
}
41
51
42
- public void UpdateInfo ( string text )
52
+ public void UpdateInfoLabel ( string text )
43
53
{
44
54
_infoLabel . Text = text ;
45
55
}
46
56
47
- public void DisableJoinButton ( )
57
+ public void UpdateMatchList ( IApiMatchList matchList )
58
+ {
59
+ foreach ( Node child in _matchListContainer . GetChildren ( ) )
60
+ {
61
+ _matchListContainer . RemoveChild ( child ) ;
62
+ child . QueueFree ( ) ;
63
+ }
64
+
65
+ foreach ( var match in matchList . Matches )
66
+ {
67
+ var listing = MatchListing . Instantiate < MatchListing > ( ) ;
68
+ listing . Connect ( "pressed" , new Callable ( this , nameof ( OnMatchSelected ) ) , new Godot . Collections . Array ( ) { match . MatchId } ) ;
69
+ _matchListContainer . AddChild ( listing ) ;
70
+
71
+ listing . UpdateInfo ( match . MatchId , match . Size ) ;
72
+ }
73
+ }
74
+
75
+ public void DisableQueueButton ( )
48
76
{
49
- _joinButton . Disabled = true ;
77
+ _queueButton . Disabled = true ;
50
78
}
51
79
52
80
public void EnableJoinButton ( )
53
81
{
54
- _joinButton . Disabled = false ;
82
+ _queueButton . Disabled = false ;
55
83
}
56
84
57
85
public void UpdateUsers ( string username , List < IUserPresence > users )
@@ -93,10 +121,29 @@ public void NewMessage(string username, string message, string time)
93
121
}
94
122
}
95
123
124
+ private void OnMatchSelected ( string matchId )
125
+ {
126
+ EmitSignal ( nameof ( MatchSelected ) , matchId ) ;
127
+ }
128
+
129
+ private void OnRefreshButtonPressed ( )
130
+ {
131
+ EmitSignal ( nameof ( RefreshButtonPressed ) ) ;
132
+ }
133
+
96
134
private void OnJoinButtonPressed ( )
97
135
{
98
136
EmitSignal ( nameof ( JoinButtonPressed ) ) ;
99
137
}
138
+ private void OnCreateButtonPressed ( )
139
+ {
140
+ EmitSignal ( nameof ( CreateButtonPressed ) ) ;
141
+ }
142
+
143
+ private void OnQueueButtonPressed ( )
144
+ {
145
+ EmitSignal ( nameof ( QueueButtonPressed ) ) ;
146
+ }
100
147
101
148
private void OnCancelButtonPressed ( )
102
149
{
0 commit comments