Skip to content
This repository was archived by the owner on Sep 15, 2024. It is now read-only.

Commit e336be1

Browse files
Add tabs to options / add web server ip
1 parent 9e31ce3 commit e336be1

3 files changed

Lines changed: 101 additions & 52 deletions

File tree

Scenes/Prefabs/Options.tscn

Lines changed: 91 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[ext_resource path="res://Scripts/Scenes/Menu/UIOptions.cs" type="Script" id=1]
44
[ext_resource path="res://Themes/Main.tres" type="Theme" id=2]
55

6-
[node name="Options" type="PanelContainer"]
6+
[node name="Options" type="TabContainer"]
77
anchor_right = 1.0
88
anchor_bottom = 1.0
99
margin_right = -1767.0
@@ -12,105 +12,145 @@ rect_min_size = Vector2( 400, 0 )
1212
size_flags_horizontal = 0
1313
size_flags_vertical = 0
1414
theme = ExtResource( 2 )
15+
tab_align = 0
1516
script = ExtResource( 1 )
16-
__meta__ = {
17-
"_edit_use_anchors_": false
18-
}
19-
NodePathFullscreenOptions = NodePath("MarginContainer/VBoxContainer/Fullscreen")
20-
NodePathResolutionOptions = NodePath("MarginContainer/VBoxContainer/Resolution")
21-
NodePathSliderMusic = NodePath("MarginContainer/VBoxContainer/Music")
22-
NodePathSliderSFX = NodePath("MarginContainer/VBoxContainer/SFX")
23-
NodePathVSync = NodePath("MarginContainer/VBoxContainer/VSync/VSync")
24-
NodePathInputOnlineUsername = NodePath("MarginContainer/VBoxContainer/Online Username/OnlineUsername")
25-
26-
[node name="MarginContainer" type="MarginContainer" parent="."]
27-
margin_left = 1.0
28-
margin_top = 1.0
29-
margin_right = 399.0
30-
margin_bottom = 211.0
17+
NodePathFullscreenOptions = NodePath("General/VBoxContainer/Fullscreen")
18+
NodePathResolutionOptions = NodePath("General/VBoxContainer/Resolution")
19+
NodePathSliderMusic = NodePath("General/VBoxContainer/Music")
20+
NodePathSliderSFX = NodePath("General/VBoxContainer/SFX")
21+
NodePathVSync = NodePath("General/VBoxContainer/VSync/VSync")
22+
NodePathInputOnlineUsername = NodePath("Multiplayer/VBoxContainer/Online Username/OnlineUsername")
23+
NodePathInputWebServerIp = NodePath("Multiplayer/VBoxContainer/Web Server/WebServerIp")
24+
25+
[node name="General" type="MarginContainer" parent="."]
26+
visible = false
27+
anchor_right = 1.0
28+
anchor_bottom = 1.0
29+
margin_left = 4.0
30+
margin_top = 32.0
31+
margin_right = -4.0
32+
margin_bottom = -4.0
3133
custom_constants/margin_right = 15
3234
custom_constants/margin_top = 15
3335
custom_constants/margin_left = 15
3436
custom_constants/margin_bottom = 15
3537

36-
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
38+
[node name="VBoxContainer" type="VBoxContainer" parent="General"]
3739
margin_left = 15.0
3840
margin_top = 15.0
39-
margin_right = 383.0
40-
margin_bottom = 195.0
41+
margin_right = 377.0
42+
margin_bottom = 174.0
4143

42-
[node name="Label1" type="Label" parent="MarginContainer/VBoxContainer"]
43-
margin_right = 368.0
44+
[node name="Label1" type="Label" parent="General/VBoxContainer"]
45+
margin_right = 362.0
4446
margin_bottom = 17.0
4547
text = "Music"
4648

47-
[node name="Music" type="HSlider" parent="MarginContainer/VBoxContainer"]
49+
[node name="Music" type="HSlider" parent="General/VBoxContainer"]
4850
margin_top = 21.0
49-
margin_right = 368.0
51+
margin_right = 362.0
5052
margin_bottom = 37.0
5153
min_value = -40.0
5254
max_value = 0.0
5355

54-
[node name="Label2" type="Label" parent="MarginContainer/VBoxContainer"]
56+
[node name="Label2" type="Label" parent="General/VBoxContainer"]
5557
margin_top = 41.0
56-
margin_right = 368.0
58+
margin_right = 362.0
5759
margin_bottom = 58.0
5860
text = "SFX"
5961

60-
[node name="SFX" type="HSlider" parent="MarginContainer/VBoxContainer"]
62+
[node name="SFX" type="HSlider" parent="General/VBoxContainer"]
6163
margin_top = 62.0
62-
margin_right = 368.0
64+
margin_right = 362.0
6365
margin_bottom = 78.0
6466
min_value = -40.0
6567
max_value = 0.0
6668

67-
[node name="Resolution" type="OptionButton" parent="MarginContainer/VBoxContainer"]
69+
[node name="Resolution" type="OptionButton" parent="General/VBoxContainer"]
6870
margin_top = 82.0
69-
margin_right = 368.0
71+
margin_right = 362.0
7072
margin_bottom = 105.0
7173
text = "Resolution"
7274

73-
[node name="Fullscreen" type="OptionButton" parent="MarginContainer/VBoxContainer"]
75+
[node name="Fullscreen" type="OptionButton" parent="General/VBoxContainer"]
7476
margin_top = 109.0
75-
margin_right = 368.0
77+
margin_right = 362.0
7678
margin_bottom = 132.0
7779
text = "Fullscreen Mode"
7880

79-
[node name="VSync" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
81+
[node name="VSync" type="HBoxContainer" parent="General/VBoxContainer"]
8082
margin_top = 136.0
81-
margin_right = 368.0
83+
margin_right = 362.0
8284
margin_bottom = 159.0
8385

84-
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/VSync"]
86+
[node name="Label" type="Label" parent="General/VBoxContainer/VSync"]
8587
margin_top = 3.0
8688
margin_right = 39.0
8789
margin_bottom = 20.0
8890
text = "VSync"
8991

90-
[node name="VSync" type="CheckBox" parent="MarginContainer/VBoxContainer/VSync"]
92+
[node name="VSync" type="CheckBox" parent="General/VBoxContainer/VSync"]
9193
margin_left = 43.0
9294
margin_right = 65.0
9395
margin_bottom = 23.0
9496

95-
[node name="Online Username" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
96-
margin_top = 163.0
97-
margin_right = 368.0
98-
margin_bottom = 180.0
97+
[node name="Multiplayer" type="MarginContainer" parent="."]
98+
anchor_right = 1.0
99+
anchor_bottom = 1.0
100+
margin_left = 4.0
101+
margin_top = 32.0
102+
margin_right = -4.0
103+
margin_bottom = -4.0
104+
custom_constants/margin_right = 15
105+
custom_constants/margin_top = 15
106+
custom_constants/margin_left = 15
107+
custom_constants/margin_bottom = 15
99108

100-
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/Online Username"]
109+
[node name="VBoxContainer" type="VBoxContainer" parent="Multiplayer"]
110+
margin_left = 15.0
111+
margin_top = 15.0
112+
margin_right = 377.0
113+
margin_bottom = 53.0
114+
115+
[node name="Online Username" type="HBoxContainer" parent="Multiplayer/VBoxContainer"]
116+
margin_right = 362.0
117+
margin_bottom = 17.0
118+
119+
[node name="Label" type="Label" parent="Multiplayer/VBoxContainer/Online Username"]
101120
margin_right = 111.0
102121
margin_bottom = 17.0
103122
text = "Online Username: "
104123

105-
[node name="OnlineUsername" type="LineEdit" parent="MarginContainer/VBoxContainer/Online Username"]
106-
margin_left = 115.0
107-
margin_right = 368.0
124+
[node name="OnlineUsername" type="LineEdit" parent="Multiplayer/VBoxContainer/Online Username"]
125+
margin_left = 162.0
126+
margin_right = 362.0
127+
margin_bottom = 17.0
128+
rect_min_size = Vector2( 200, 0 )
129+
size_flags_horizontal = 10
130+
caret_blink = true
131+
caret_blink_speed = 0.5
132+
133+
[node name="Web Server" type="HBoxContainer" parent="Multiplayer/VBoxContainer"]
134+
margin_top = 21.0
135+
margin_right = 362.0
136+
margin_bottom = 38.0
137+
138+
[node name="Label" type="Label" parent="Multiplayer/VBoxContainer/Web Server"]
139+
margin_right = 72.0
140+
margin_bottom = 17.0
141+
text = "Web Server:"
142+
143+
[node name="WebServerIp" type="LineEdit" parent="Multiplayer/VBoxContainer/Web Server"]
144+
margin_left = 162.0
145+
margin_right = 362.0
108146
margin_bottom = 17.0
109-
size_flags_horizontal = 3
110-
111-
[connection signal="value_changed" from="MarginContainer/VBoxContainer/Music" to="." method="_on_Music_value_changed"]
112-
[connection signal="value_changed" from="MarginContainer/VBoxContainer/SFX" to="." method="_on_SFX_value_changed"]
113-
[connection signal="item_selected" from="MarginContainer/VBoxContainer/Resolution" to="." method="_on_Resolution_item_selected"]
114-
[connection signal="item_selected" from="MarginContainer/VBoxContainer/Fullscreen" to="." method="_on_Fullscreen_item_selected"]
115-
[connection signal="toggled" from="MarginContainer/VBoxContainer/VSync/VSync" to="." method="_on_VSync_toggled"]
116-
[connection signal="text_changed" from="MarginContainer/VBoxContainer/Online Username/OnlineUsername" to="." method="_on_OnlineUsername_text_changed"]
147+
rect_min_size = Vector2( 200, 0 )
148+
size_flags_horizontal = 10
149+
150+
[connection signal="value_changed" from="General/VBoxContainer/Music" to="." method="_on_Music_value_changed"]
151+
[connection signal="value_changed" from="General/VBoxContainer/SFX" to="." method="_on_SFX_value_changed"]
152+
[connection signal="item_selected" from="General/VBoxContainer/Resolution" to="." method="_on_Resolution_item_selected"]
153+
[connection signal="item_selected" from="General/VBoxContainer/Fullscreen" to="." method="_on_Fullscreen_item_selected"]
154+
[connection signal="toggled" from="General/VBoxContainer/VSync/VSync" to="." method="_on_VSync_toggled"]
155+
[connection signal="text_changed" from="Multiplayer/VBoxContainer/Online Username/OnlineUsername" to="." method="_on_OnlineUsername_text_changed"]
156+
[connection signal="text_changed" from="Multiplayer/VBoxContainer/Web Server/WebServerIp" to="." method="_on_WebServerIp_text_changed"]

Scripts/Netcode/Web/WebClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class WebClient : IDisposable
1616
public static Task<WebServerResponse<LobbyListing[]>> TaskGetServers { get; set; }
1717
public static string ExternalIp { get; set; }
1818
private static int FailedPingAttempts { get; set; }
19-
private const string WEB_SERVER_IP = "localhost:4000";
19+
public static string WEB_SERVER_IP = "localhost:4000";
2020
private const int WEB_PING_INTERVAL = 10000;
2121
private static bool LogExceptions = true;
2222
public static Timer TimerPingMasterServer { get; set; }

Scripts/Scenes/Menu/UIOptions.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ public class UIOptions : Node
1212
[Export] public readonly NodePath NodePathSliderSFX;
1313
[Export] public readonly NodePath NodePathVSync;
1414
[Export] public readonly NodePath NodePathInputOnlineUsername;
15+
[Export] public readonly NodePath NodePathInputWebServerIp;
1516

1617
public HSlider SliderMusic { get; set; }
1718
public HSlider SliderSFX { get; set; }
1819
private OptionButton FullscreenOptions { get; set; }
1920
private OptionButton ResolutionOptions { get; set; }
2021
private CheckBox VSync { get; set; }
2122
public LineEdit InputUsername { get; set; }
23+
private LineEdit InputWebServer { get; set; }
2224

2325
public OptionsData Options { get; set; }
2426

@@ -30,6 +32,7 @@ public override void _Ready()
3032
SliderSFX = GetNode<HSlider>(NodePathSliderSFX);
3133
VSync = GetNode<CheckBox>(NodePathVSync);
3234
InputUsername = GetNode<LineEdit>(NodePathInputOnlineUsername);
35+
InputWebServer = GetNode<LineEdit>(NodePathInputWebServerIp);
3336
SetupFullscreenOptions();
3437
SetupResolutionOptions();
3538
SetupUI();
@@ -45,6 +48,7 @@ private void SetupUI()
4548
SliderSFX.Value = Options.VolumeSFX;
4649
VSync.Pressed = Options.VSync;
4750
InputUsername.Text = Options.OnlineUsername;
51+
InputWebServer.Text = WebClient.WEB_SERVER_IP;
4852
}
4953

5054
private void SetupFullscreenOptions()
@@ -99,5 +103,10 @@ private void _on_OnlineUsername_text_changed(string text)
99103
{
100104
Options.OnlineUsername = text.Validate(ref previousTextOnlineUsername, InputUsername, () => text.IsMatch("^[A-Za-z]+$"));
101105
}
106+
107+
private void _on_WebServerIp_text_changed(string text)
108+
{
109+
WebClient.WEB_SERVER_IP = text;
110+
}
102111
}
103112
}

0 commit comments

Comments
 (0)