begin network

This commit is contained in:
2024-08-16 19:00:45 +02:00
parent 65e2a0b3ce
commit 3769fd3ace
18 changed files with 305 additions and 77 deletions

View File

@@ -5,11 +5,14 @@
using namespace godot;
static constexpr char MainScenePath[] = "res://Scenes/Levels/world.tscn";
namespace blitz {
void MainMenu::_bind_methods() {}
void MainMenu::_bind_methods() {
godot::ClassDB::bind_method(godot::D_METHOD("on_connected"), &MainMenu::OnConnected);
ADD_SIGNAL(MethodInfo("create_game", PropertyInfo(Variant::INT, "port"), PropertyInfo(Variant::BOOL, "dedicated")));
ADD_SIGNAL(MethodInfo("join_game", PropertyInfo(Variant::STRING, "address"), PropertyInfo(Variant::INT, "port")));
ADD_SIGNAL(MethodInfo("change_scene"));
}
MainMenu::MainMenu() {}
@@ -32,12 +35,17 @@ void MainMenu::_ready() {
m_QuitButton->connect("pressed", callable_mp(this, &MainMenu::OnQuitPressed));
}
void MainMenu::OnConnected() {
emit_signal("change_scene");
queue_free();
}
void MainMenu::OnJoinPressed() {
get_tree()->change_scene_to_file(MainScenePath);
emit_signal("join_game", "localhost", 25565);
}
void MainMenu::OnCreatePressed() {
get_tree()->change_scene_to_file(MainScenePath);
emit_signal("create_game", 25565, false);
}
void MainMenu::OnQuitPressed() {