From 396b28dba11b2b222861460eb37907451e104493 Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Tue, 18 Feb 2025 18:31:27 +0100 Subject: [PATCH] WIP: Something --- godot/src/entrypoint.gd | 39 ++++++++++--------- godot/src/entrypoint.tscn | 13 ++++++- godot/src/interfaces/main_menu/main_menu.gd | 11 ++++++ godot/src/interfaces/main_menu/main_menu.tscn | 12 ++++++ 4 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 godot/src/interfaces/main_menu/main_menu.gd create mode 100644 godot/src/interfaces/main_menu/main_menu.tscn diff --git a/godot/src/entrypoint.gd b/godot/src/entrypoint.gd index 6547ffc..b5182e0 100644 --- a/godot/src/entrypoint.gd +++ b/godot/src/entrypoint.gd @@ -3,30 +3,33 @@ extends EntryPoint # -- A path to the config file for setting up the dedicated server var config_file_path: String = "" +@export var main_menu: MainMenu = null + # -- Called when the node enters the scene tree for the first time. func _ready() -> void: - parse_args() - - if OS.has_feature("dedicated_server") or DisplayServer.get_name() == "headless": - var err := start_dedicated_server() - if err != OK: - push_error("Couldn't start the dedicated server, err: " + str(err)) - else: - var err := start_game() - if err != OK: - push_error("Couldn't start the game, err: " + str(err)) + parse_args() + if OS.has_feature("dedicated_server") or DisplayServer.get_name() == "headless": + var err := start_dedicated_server() + if err != OK: + push_error("Couldn't start the dedicated server, err: " + str(err)) + else: + var err := start_game() + if err != OK: + push_error("Couldn't start the game, err: " + str(err)) # -- Parse command line arguments func parse_args() -> void: - var args := Array(OS.get_cmdline_args()) - var config_arg: String = "--config" - if args.has(config_arg): - var index := args.find(config_arg) - config_file_path = args[index + 1] + var args := Array(OS.get_cmdline_args()) + var config_arg: String = "--config" + if args.has(config_arg): + var index := args.find(config_arg) + config_file_path = args[index + 1] func start_dedicated_server() -> Error: - push_error("Dedicated server is not yet implemented") - return ERR_METHOD_NOT_FOUND + push_error("Dedicated server is not yet implemented") + return ERR_METHOD_NOT_FOUND +# -- When not dedicated server, just start the full game and load menu func start_game() -> Error: - return OK + # -- Draw the main menu + return OK diff --git a/godot/src/entrypoint.tscn b/godot/src/entrypoint.tscn index 89fa199..772c132 100644 --- a/godot/src/entrypoint.tscn +++ b/godot/src/entrypoint.tscn @@ -1,9 +1,18 @@ -[gd_scene load_steps=2 format=3 uid="uid://0hsqnr1kunv5"] +[gd_scene load_steps=3 format=3 uid="uid://0hsqnr1kunv5"] [ext_resource type="Script" path="res://src/entrypoint.gd" id="1_ce80t"] +[ext_resource type="Script" path="res://src/interfaces/main_menu/main_menu.gd" id="2_nmo60"] -[node name="Entrypoint" type="EntryPoint"] +[node name="Entrypoint" type="EntryPoint" node_paths=PackedStringArray("main_menu")] script = ExtResource("1_ce80t") +main_menu = NodePath("MainMenu") [node name="LevelPlaceholder" type="Node3D" parent="."] editor_description = "This node should be used for storing the map that is currently loaded" + +[node name="MainMenu" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 +script = ExtResource("2_nmo60") diff --git a/godot/src/interfaces/main_menu/main_menu.gd b/godot/src/interfaces/main_menu/main_menu.gd new file mode 100644 index 0000000..d1168b8 --- /dev/null +++ b/godot/src/interfaces/main_menu/main_menu.gd @@ -0,0 +1,11 @@ +class_name MainMenu extends Control + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass diff --git a/godot/src/interfaces/main_menu/main_menu.tscn b/godot/src/interfaces/main_menu/main_menu.tscn new file mode 100644 index 0000000..bc3726a --- /dev/null +++ b/godot/src/interfaces/main_menu/main_menu.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=3 uid="uid://dt7rhpcor1wh7"] + +[ext_resource type="Script" path="res://src/interfaces/main_menu/main_menu.gd" id="1_dfg40"] + +[node name="MainMenu" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_dfg40")