Skip to content

Commit

Permalink
part2
Browse files Browse the repository at this point in the history
  • Loading branch information
Green-Sky committed Aug 2, 2022
1 parent 917969a commit c4d742d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/main_tox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ bool setup_service<MM::Services::Tox::ToxService>(MM::Engine& engine, [[maybe_un
return true;
}

template<>
bool setup_service<Services::LobbyClient>(MM::Engine& engine, [[maybe_unused]] int argc, [[maybe_unused]] char** argv) {
auto& service = engine.addService<Services::LobbyClient>();

// ???
service.registerHandler<MM::Services::Tox::ToxNetChanneled>("tox", engine);

// dont auto enable
//if (!engine.enableService<Services::LobbyClient>()) {
//SPDLOG_ERROR("failed to enable service {}", ((MM::Services::Service*)engine.tryService<Services::LobbyClient>())->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
Expand Down
14 changes: 12 additions & 2 deletions src/screens/game_mp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <mm/services/organizer_scene.hpp>
#include "../services/game_hud.hpp"
#include <mm/services/sound_service.hpp>
#include "../services/lobby_host.hpp"
#include "../services/lobby_client.hpp"

#include <mm/resource_manager.hpp>

Expand Down Expand Up @@ -149,6 +151,7 @@ void create_game_mp_host(MM::Engine& engine, MM::Services::ScreenDirector::Scree
screen.start_enable.push_back(engine.type<MM::Services::ImGuiService>());
screen.start_enable.push_back(engine.type<MM::Services::OrganizerSceneService>());
screen.start_enable.push_back(engine.type<mini_td::Services::GameHUD>());
screen.start_enable.push_back(engine.type<::Services::LobbyHost>());

// start disable
//screen.start_disable.push_back();
Expand All @@ -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<MM::Services::SoundService>()); // shold be active
screen.start_enable.push_back(engine.type<MM::Services::OpenGLRenderer>());
screen.start_enable.push_back(engine.type<MM::Services::ImGuiService>());
screen.start_enable.push_back(engine.type<MM::Services::OrganizerSceneService>());
screen.start_enable.push_back(engine.type<mini_td::Services::GameHUD>());
//screen.start_enable.push_back(engine.type<mini_td::Services::GameHUD>());
screen.start_enable.push_back(engine.type<::Services::LobbyClient>());

// start disable
//screen.start_disable.push_back();
Expand All @@ -179,7 +189,7 @@ void create_game_mp_client(MM::Engine& engine, MM::Services::ScreenDirector::Scr
screen.end_disable.push_back(engine.type<mini_td::Services::GameHUD>());
screen.end_disable.push_back(engine.type<MM::Services::OrganizerSceneService>());

//screen.start_fn = game_sp_start_fn;
screen.start_fn = game_mp_client_start_fn;
}

} // mini_td::Screens
Expand Down

0 comments on commit c4d742d

Please sign in to comment.