This commit is contained in:
Victor Turgeon 2023-06-10 14:15:23 -04:00
commit 69a1132362
3 changed files with 113 additions and 36 deletions

View File

@ -3,39 +3,111 @@ using System;
public partial class start_game_menu : Control
{
enum _state { START, LAN, QUIT };
private _state _currState = _state.START;
private const string _path = "/root/StartGameMenu/";
private Button _localMulti, _single, _LANMulti, _join, _host, _cancel, _quit, _yes, _no;
private Label _error;
private TextEdit _ip;
private Label _error, _lip;
private string Error {
set { _error.Set("text", value); }
private string Error { set { _error.Set("text", value); } }
private string IP_address {
set {
_ip.Set("text", value);
}
get => (string)_ip.Get("text");
}
private _state State { get => _currState; set {
if (value == _currState)
return;
IP_address = "";
switch (value) {
case _state.START:
Error = "";
_single.Set("visible", true);
_localMulti.Set("visible", true);
_LANMulti.Set("visible", true);
_cancel.Set("visible", false);
_yes.Set("visible", false);
_no.Set("visible", false);
_join.Set("visible", false);
_host.Set("visible", false);
_quit.Set("visible", true);
_ip.Set("visible", false);
_lip.Set("visible", false);
break;
case _state.LAN:
Error = "";
_single.Set("visible", false);
_localMulti.Set("visible", false);
_LANMulti.Set("visible", false);
_cancel.Set("visible", true);
_yes.Set("visible", false);
_no.Set("visible", false);
_join.Set("visible", true);
_host.Set("visible", true);
_quit.Set("visible", true);
_ip.Set("visible", true);
_lip.Set("visible", true);
break;
case _state.QUIT:
Error = "Are you sure you want to quit?";
_single.Set("visible", false);
_localMulti.Set("visible", false);
_LANMulti.Set("visible", false);
_cancel.Set("visible", false);
_yes.Set("visible", true);
_no.Set("visible", true);
_join.Set("visible", false);
_host.Set("visible", false);
_quit.Set("visible", false);
_ip.Set("visible", false);
_lip.Set("visible", false);
break;
}
_currState = value;
}}
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
public override void _Ready() {
_single = GetNode<Button>(_path + "Btn_Single");
_localMulti = GetNode<Button>(_path + "Btn_LocalMulti");
_LANMulti = GetNode<Button>(_path + "Btn_LANMulti");
_cancel = GetNode<Button>(_path + "Btn_Cancel");
_quit = GetNode<Button>(_path + "Btn_Quit");
_yes = GetNode<Button>(_path + "Btn_Yes");
_no = GetNode<Button>(_path + "Btn_No");
_host = GetNode<Button>(_path + "Btn_Host");
_join = GetNode<Button>(_path + "Btn_Join");
_error = GetNode<Label>(_path + "lbl_err");
_ip = GetNode<TextEdit>(_path + "txt_IP");
_lip = GetNode<Label>(_path + "lbl_IP");
_single.Pressed += () => startSingleGame();
_localMulti.Pressed += () => startLocalMultiGame();
_LANMulti.Pressed += () => selectLANMultiGame();
_LANMulti.Pressed += () => State = _state.LAN;
_host.Pressed += () => startLANMultiGame();
_join.Pressed += () => startLANMultiGame(false);
_quit.Pressed += () => State = _state.QUIT;
_cancel.Pressed += () => State = _state.START;
_no.Pressed += () => State = _state.START;
_yes.Pressed += () => GetTree().Quit();
State = _state.START;
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
private void startSingleGame() {
Error = "single";
}
private void startLocalMultiGame() {
Error = "localmulti";
}
private void startLANMultiGame(bool isHost = true) {
@ -44,5 +116,4 @@ public partial class start_game_menu : Control
private void selectLANMultiGame() {
Error = "lanmulti";
}
}

View File

@ -34,14 +34,6 @@ offset_bottom = 622.0
text = "M.A.D"
label_settings = SubResource("LabelSettings_n38oc")
[node name="Btn_LocalMulti" type="Button" parent="."]
layout_mode = 0
offset_left = 863.0
offset_top = 672.0
offset_right = 1046.0
offset_bottom = 703.0
text = "Local Multiplayer"
[node name="Btn_Single" type="Button" parent="."]
layout_mode = 0
offset_left = 617.0
@ -52,6 +44,14 @@ shortcut = SubResource("Shortcut_pweny")
text = "Single Player
"
[node name="Btn_LocalMulti" type="Button" parent="."]
layout_mode = 0
offset_left = 863.0
offset_top = 672.0
offset_right = 1046.0
offset_bottom = 703.0
text = "Local Multiplayer"
[node name="Btn_LANMulti" type="Button" parent="."]
layout_mode = 0
offset_left = 1097.0
@ -60,24 +60,8 @@ offset_right = 1279.0
offset_bottom = 701.0
text = "LAN Multiplayer"
[node name="Btn_Host" type="Button" parent="."]
layout_mode = 0
offset_left = 614.0
offset_top = 710.0
offset_right = 1285.0
offset_bottom = 741.0
text = "Host"
[node name="Btn_Join" type="Button" parent="."]
layout_mode = 0
offset_left = 613.0
offset_top = 748.0
offset_right = 825.0
offset_bottom = 779.0
text = "Join
"
[node name="Btn_Cancel" type="Button" parent="."]
visible = false
layout_mode = 0
offset_left = 615.0
offset_top = 787.0
@ -94,6 +78,7 @@ offset_bottom = 817.0
text = "Quit Game"
[node name="Btn_Yes" type="Button" parent="."]
visible = false
layout_mode = 0
offset_left = 614.0
offset_top = 635.0
@ -102,6 +87,7 @@ offset_bottom = 666.0
text = "Yes"
[node name="Btn_No" type="Button" parent="."]
visible = false
layout_mode = 0
offset_left = 949.0
offset_top = 634.0
@ -109,7 +95,27 @@ offset_right = 1283.0
offset_bottom = 665.0
text = "No"
[node name="Btn_Host" type="Button" parent="."]
visible = false
layout_mode = 0
offset_left = 614.0
offset_top = 710.0
offset_right = 1285.0
offset_bottom = 741.0
text = "Host"
[node name="Btn_Join" type="Button" parent="."]
visible = false
layout_mode = 0
offset_left = 613.0
offset_top = 748.0
offset_right = 825.0
offset_bottom = 779.0
text = "Join
"
[node name="txt_IP" type="TextEdit" parent="."]
visible = false
layout_mode = 0
offset_left = 1034.0
offset_top = 749.0
@ -117,6 +123,7 @@ offset_right = 1286.0
offset_bottom = 779.0
[node name="lbl_IP" type="Label" parent="."]
visible = false
layout_mode = 0
offset_left = 835.0
offset_top = 750.0

View File

@ -18,7 +18,6 @@ config/icon="res://icon.svg"
window/size/viewport_width=1920
window/size/viewport_height=1080
window/size/mode=3
[dotnet]