From fea86032586710c90eaf1c22deedf302cc74fa8c Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 1 Jul 2024 00:25:31 +0200 Subject: [PATCH] ImGui: add shortcut button for reparsing all scripts The "Reparse all scripts" button reparses every script file, and reloads/reconnects the game. --- src/gameui/IBrowser.cpp | 55 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/src/gameui/IBrowser.cpp b/src/gameui/IBrowser.cpp index 41223dbc..38dd7164 100644 --- a/src/gameui/IBrowser.cpp +++ b/src/gameui/IBrowser.cpp @@ -591,7 +591,9 @@ void CBrowser::DrawHostPanel(void) ImGui::Spacing(); const ImVec2 contentRegionMax = ImGui::GetContentRegionAvail(); + const bool serverActive = g_pServer->IsActive(); + const bool clientActive = g_pClientState->IsActive(); if (!g_pHostState->m_bActiveGame) { @@ -665,7 +667,7 @@ void CBrowser::DrawHostPanel(void) ImGui::Separator(); ImGui::Spacing(); - if (ImGui::Button("AI network rebuild", ImVec2(contentRegionMax.x, 32))) + if (ImGui::Button("Rebuild AI network", ImVec2(contentRegionMax.x, 32))) { ProcessCommand("BuildAINFile"); } @@ -679,9 +681,9 @@ void CBrowser::DrawHostPanel(void) ImGui::Separator(); ImGui::Spacing(); - if (ImGui::Button("AI settings reparse", ImVec2(contentRegionMax.x, 32))) + if (ImGui::Button("Reparse AI settings", ImVec2(contentRegionMax.x, 32))) { - Msg(eDLL_T::ENGINE, "Reparsing AI data on %s\n", g_pClientState->IsActive() ? "server and client" : "server"); + Msg(eDLL_T::ENGINE, "Reparsing AI data on %s\n", clientActive ? "server and client" : "server"); ProcessCommand("aisettings_reparse"); if (g_pClientState->IsActive()) @@ -690,13 +692,56 @@ void CBrowser::DrawHostPanel(void) } } - if (ImGui::Button("Weapon settings reparse", ImVec2(contentRegionMax.x, 32))) + if (ImGui::Button("Reparse Weapon settings", ImVec2(contentRegionMax.x, 32))) { - Msg(eDLL_T::ENGINE, "Reparsing weapon data on %s\n", g_pClientState->IsActive() ? "server and client" : "server"); + Msg(eDLL_T::ENGINE, "Reparsing weapon data on %s\n", clientActive ? "server and client" : "server"); ProcessCommand("weapon_reparse"); } } } + + ImGui::Spacing(); + ImGui::Separator(); + ImGui::Spacing(); + + if (ImGui::Button("Reparse all scripts", ImVec2(contentRegionMax.x, 32))) + { + Msg(eDLL_T::ENGINE, "Reparsing all scripts on %s\n", "server and client"); + + // NOTE: the following are already called during "reload" or "reconnect". + //"aisettings_reparse" + //"aisettings_reparse_client" + + //"damagedefs_reparse" + //"damagedefs_reparse_client" + + //"playerSettings_reparse" + //"fx_impact_reparse" + + ProcessCommand("ReloadAimAssistSettings"); + ProcessCommand("reload_localization"); + + ProcessCommand("playlist_reload"); + ProcessCommand("banlist_reload"); + + ProcessCommand("weapon_reparse"); + + // Recompile all UI scripts + ProcessCommand("uiscript_reset"); + + if (serverActive) + { + // If we hit this code path, we are connected to a listen server, + // reconnect to it to recompile all server and client side scripts. + ProcessCommand("reload"); + } + else if (clientActive) + { + // If we hit this code path, we are connected to a remote server, + // reconnect to it to recompile all client side scripts. + ProcessCommand("reconnect"); + } + } #endif // !CLIENT_DLL }