Mutually_Assured_Destruction/menu/start_game_menu.cs
MarcEricMartel 00a5104758 MENNU!
2023-06-10 14:01:30 -04:00

120 lines
3.4 KiB
C#

using Godot;
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 TextEdit _ip;
private Label _error, _lip;
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() {
_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 += () => 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() {
}
private void startLocalMultiGame() {
}
private void startLANMultiGame(bool isHost = true) {
}
private void selectLANMultiGame() {
Error = "lanmulti";
}
}