From 9fce064632cbea67454e0bb4aa70667e935e9f36 Mon Sep 17 00:00:00 2001 From: m Date: Sat, 3 Sep 2022 05:06:45 -0500 Subject: [PATCH] add mods menu in lobby --- data/ui_scripts/mods/__init__.lua | 6 ++++-- data/ui_scripts/mods/loading.lua | 18 ++++++++++-------- data/ui_scripts/server_list/lobby.lua | 6 ++++++ src/client/component/mods.cpp | 4 ++-- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/data/ui_scripts/mods/__init__.lua b/data/ui_scripts/mods/__init__.lua index 1ca1f8d2..5c75897c 100644 --- a/data/ui_scripts/mods/__init__.lua +++ b/data/ui_scripts/mods/__init__.lua @@ -1,3 +1,5 @@ -if (game:issingleplayer()) then - require("loading") +require("loading") + +if (Engine.InFrontend()) then + require("download") end diff --git a/data/ui_scripts/mods/loading.lua b/data/ui_scripts/mods/loading.lua index 9600d8a5..85165f24 100644 --- a/data/ui_scripts/mods/loading.lua +++ b/data/ui_scripts/mods/loading.lua @@ -38,14 +38,16 @@ function string:truncate(length) return self:sub(1, length - 3) .. "..." end -LUI.addmenubutton("main_campaign", { - index = 6, - text = "@MENU_MODS", - description = Engine.Localize("@MENU_MODS_DESC"), - callback = function() - LUI.FlowManager.RequestAddMenu(nil, "mods_menu") - end -}) +if (game:issingleplayer()) then + LUI.addmenubutton("main_campaign", { + index = 6, + text = "@MENU_MODS", + description = Engine.Localize("@MENU_MODS_DESC"), + callback = function() + LUI.FlowManager.RequestAddMenu(nil, "mods_menu") + end + }) +end function getmodname(path) local name = path diff --git a/data/ui_scripts/server_list/lobby.lua b/data/ui_scripts/server_list/lobby.lua index 20027026..dc1be437 100644 --- a/data/ui_scripts/server_list/lobby.lua +++ b/data/ui_scripts/server_list/lobby.lua @@ -28,6 +28,12 @@ function menu_xboxlive(f16_arg0, f16_arg1) menu:AddBarracksButton() menu:AddPersonalizationButton() menu:AddDepotButton() + + -- kinda a weird place to do this, but it's whatever + -- add "MODS" button below depot button + local modsButton = menu:AddButton("@MENU_MODS", function(a1, a2) + LUI.FlowManager.RequestAddMenu(a1, "mods_menu", true, nil) + end) end local privateMatchButton = menu:AddButton("@MENU_PRIVATE_MATCH", MPLobbyOnline.OnPrivateMatch, diff --git a/src/client/component/mods.cpp b/src/client/component/mods.cpp index 7a161e28..e4b1b723 100644 --- a/src/client/component/mods.cpp +++ b/src/client/component/mods.cpp @@ -85,7 +85,7 @@ namespace mods return; } - if (!game::Com_InFrontend()) + if (!game::Com_InFrontend() && (game::environment::is_mp() && !game::VirtualLobby_Loaded())) { console::info("Cannot load mod while in-game!\n"); game::CG_GameMessage(0, "^1Cannot unload mod while in-game!"); @@ -125,7 +125,7 @@ namespace mods return; } - if (!game::Com_InFrontend()) + if (!game::Com_InFrontend() && (game::environment::is_mp() && !game::VirtualLobby_Loaded())) { console::info("Cannot unload mod while in-game!\n"); game::CG_GameMessage(0, "^1Cannot unload mod while in-game!");