MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / initialiseModule

Method initialiseModule

plugins/dm.gameconnection/GameConnection.cpp:820–904  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

818}
819
820void GameConnection::initialiseModule(const IApplicationContext& ctx)
821{
822 // Don't add any commands if the hot_reload feature is not enabled by the current Game
823 if (!GlobalGameManager().currentGame()->hasFeature("hot_reload"))
824 return;
825
826 GlobalMenuManager().add("main/map", "GameConnectionPanel", ui::menu::ItemType::Item, _("Game Connection..."),
827 "", fmt::format("{0}{1}", ui::TOGGLE_CONTROL_STATEMENT_PREFIX, ui::GameConnectionControl::Name));
828
829 GlobalUserInterface().registerControl(std::make_shared<ui::GameConnectionControl>());
830
831 // Add to mainframe after startup, set control default location
832 GlobalMainFrame().signal_MainFrameConstructed().connect([&]()
833 {
834 GlobalMainFrame().addControl(ui::GameConnectionControl::Name, { IMainFrame::Location::FloatingWindow, false });
835 });
836
837 // Restart game
838 GlobalCommandSystem().addCommand(
839 "GameConnectionRestartGame",
840 [this](const cmd::ArgumentList& args)
841 {
842 bool dmap = false;
843 for (int i = 0; i < args.size(); i++)
844 if (args[i].getString() == "dmap")
845 dmap = true;
846 restartGame(dmap);
847 }
848 );
849
850 // Camera sync
851 _event_toggleCameraSync = GlobalEventManager().addAdvancedToggle(
852 "GameConnectionToggleCameraSync",
853 [this](bool v) {
854 bool oldEnabled = isCameraSyncEnabled();
855 setCameraSyncEnabled(v);
856 return isCameraSyncEnabled() != oldEnabled;
857 }
858 );
859 GlobalCommandSystem().addCommand("GameConnectionBackSyncCamera",
860 [this](const cmd::ArgumentList&) { backSyncCamera(); });
861 _event_backSyncCamera = GlobalEventManager().addCommand(
862 "GameConnectionBackSyncCamera", "GameConnectionBackSyncCamera", false
863 );
864
865 // Reload map
866 GlobalCommandSystem().addCommand("GameConnectionReloadMap",
867 [this](const cmd::ArgumentList&) { reloadMap(); });
868 GlobalEventManager().addAdvancedToggle(
869 "GameConnectionToggleAutoMapReload",
870 [this](bool v) {
871 bool oldEnabled = isAutoReloadMapEnabled();
872 setAutoReloadMapEnabled(v);
873 return isAutoReloadMapEnabled() != oldEnabled;
874 }
875 );
876
877 // Update map

Callers

nothing calls this directly

Calls 12

hasFeatureMethod · 0.80
addAdvancedToggleMethod · 0.80
_Function · 0.50
formatFunction · 0.50
currentGameMethod · 0.45
addMethod · 0.45
registerControlMethod · 0.45
connectMethod · 0.45
addControlMethod · 0.45
addCommandMethod · 0.45
sizeMethod · 0.45
getStringMethod · 0.45

Tested by

no test coverage detected