2024-08-15 13:15:33 +00:00
|
|
|
using Godot;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
public partial class main_menu : Control
|
|
|
|
|
{
|
|
|
|
|
// Called when the node enters the scene tree for the first time.
|
2025-04-22 22:51:12 +00:00
|
|
|
private input_menu _inputMenu;
|
2025-04-23 14:56:10 +00:00
|
|
|
private ship_choice _shipChoice;
|
|
|
|
|
private VBoxContainer _layout;
|
2025-04-22 22:51:12 +00:00
|
|
|
|
2024-08-15 13:15:33 +00:00
|
|
|
public override void _Ready()
|
|
|
|
|
{
|
2025-04-24 10:30:55 +00:00
|
|
|
|
|
|
|
|
//input file handling
|
2026-03-06 22:49:24 +00:00
|
|
|
GD.Print(FileAccess.FileExists("user://config/input.cfg"));
|
2025-04-24 10:30:55 +00:00
|
|
|
if (!FileAccess.FileExists("user://config/input.cfg"))
|
|
|
|
|
{
|
|
|
|
|
//GD.Print("No user input.cfg found — copying default config.");
|
|
|
|
|
var src = FileAccess.Open("res://config/input.cfg", FileAccess.ModeFlags.Read);
|
|
|
|
|
var dst = FileAccess.Open("user://config/input.cfg", FileAccess.ModeFlags.Write);
|
|
|
|
|
|
|
|
|
|
//GD.Print("Contents of default input.cfg:\n", src.GetAsText());
|
|
|
|
|
|
|
|
|
|
dst.StoreString(src.GetAsText());
|
|
|
|
|
src.Close();
|
|
|
|
|
dst.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-22 22:51:12 +00:00
|
|
|
_inputMenu = GetNode<input_menu>("InputMenu");
|
2025-04-23 14:56:10 +00:00
|
|
|
_shipChoice = GetNode<ship_choice>("ShipChoice");
|
|
|
|
|
_layout = GetNode<VBoxContainer>("CanvasLayer/CenterContainer/Layout");
|
2025-04-22 22:51:12 +00:00
|
|
|
|
2024-08-15 13:15:33 +00:00
|
|
|
//Connecting Buttons
|
2025-04-23 14:56:10 +00:00
|
|
|
GetNode<Button>("CanvasLayer/CenterContainer/Layout/StartButton").Pressed += OnStartButtonPressed;
|
|
|
|
|
GetNode<Button>("CanvasLayer/CenterContainer/Layout/ExitButton").Pressed += OnExitButtonPressed;
|
|
|
|
|
GetNode<Button>("CanvasLayer/CenterContainer/Layout/InputButton").Pressed += OnInputButtonPressed;
|
|
|
|
|
|
2024-08-15 13:15:33 +00:00
|
|
|
}
|
2025-04-24 10:30:55 +00:00
|
|
|
|
2024-08-15 13:15:33 +00:00
|
|
|
private void OnStartButtonPressed()
|
|
|
|
|
{
|
2025-04-23 14:56:10 +00:00
|
|
|
_layout.Hide();
|
|
|
|
|
_shipChoice.Show();
|
2024-08-15 13:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnExitButtonPressed()
|
|
|
|
|
{
|
|
|
|
|
GetTree().Quit();
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-22 22:51:12 +00:00
|
|
|
private void OnInputButtonPressed()
|
|
|
|
|
{
|
2025-04-24 10:30:55 +00:00
|
|
|
_inputMenu.ShowInputPanel();
|
2025-04-22 22:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
2025-04-19 22:24:46 +00:00
|
|
|
// Called every frame. 'delta' has been the elapsed time since the previous frame.
|
2024-08-15 13:15:33 +00:00
|
|
|
public override void _Process(double delta)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|