From d673da20f94a310e1d03158681896900d248f710 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Tue, 2 Aug 2022 14:47:43 +0200 Subject: [PATCH] part2 --- src/main_tox.cpp | 16 ++++++++++++++++ src/screens/game_mp.cpp | 14 ++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/main_tox.cpp b/src/main_tox.cpp index 51c5cdf..cc84de2 100644 --- a/src/main_tox.cpp +++ b/src/main_tox.cpp @@ -43,6 +43,22 @@ bool setup_service(MM::Engine& engine, [[maybe_un return true; } +template<> +bool setup_service(MM::Engine& engine, [[maybe_unused]] int argc, [[maybe_unused]] char** argv) { + auto& service = engine.addService(); + + // ??? + service.registerHandler("tox", engine); + + // dont auto enable + //if (!engine.enableService()) { + //SPDLOG_ERROR("failed to enable service {}", ((MM::Services::Service*)engine.tryService())->name()); + //return false; + //} + + return true; +} + bool setup_engine(MM::Engine& engine, int argc, char** argv) { return setup_engine_t< MM::Services::SDLService, // enabled by default diff --git a/src/screens/game_mp.cpp b/src/screens/game_mp.cpp index b2f166e..1e33e1b 100644 --- a/src/screens/game_mp.cpp +++ b/src/screens/game_mp.cpp @@ -5,6 +5,8 @@ #include #include "../services/game_hud.hpp" #include +#include "../services/lobby_host.hpp" +#include "../services/lobby_client.hpp" #include @@ -149,6 +151,7 @@ void create_game_mp_host(MM::Engine& engine, MM::Services::ScreenDirector::Scree screen.start_enable.push_back(engine.type()); screen.start_enable.push_back(engine.type()); screen.start_enable.push_back(engine.type()); + screen.start_enable.push_back(engine.type<::Services::LobbyHost>()); // start disable //screen.start_disable.push_back(); @@ -162,13 +165,20 @@ void create_game_mp_host(MM::Engine& engine, MM::Services::ScreenDirector::Scree //screen.start_fn = game_sp_start_fn; } +static void game_mp_client_start_fn(MM::Engine& engine) { + SPDLOG_INFO("starting game_mp_client screen"); + + engine.getService<::Services::LobbyClient>().join("tox:000"); +} + void create_game_mp_client(MM::Engine& engine, MM::Services::ScreenDirector::Screen& screen) { // start enable screen.start_enable.push_back(engine.type()); // shold be active screen.start_enable.push_back(engine.type()); screen.start_enable.push_back(engine.type()); screen.start_enable.push_back(engine.type()); - screen.start_enable.push_back(engine.type()); + //screen.start_enable.push_back(engine.type()); + screen.start_enable.push_back(engine.type<::Services::LobbyClient>()); // start disable //screen.start_disable.push_back(); @@ -179,7 +189,7 @@ void create_game_mp_client(MM::Engine& engine, MM::Services::ScreenDirector::Scr screen.end_disable.push_back(engine.type()); screen.end_disable.push_back(engine.type()); - //screen.start_fn = game_sp_start_fn; + screen.start_fn = game_mp_client_start_fn; } } // mini_td::Screens