From 797d9fab7cbf300af1d10fc25ca10e5fff737755 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 9 Aug 2022 23:14:31 -0400 Subject: [PATCH] GameOverlay command handler no longer uses SPDLOG and prints to console. --- libultraship/libultraship/GameOverlay.cpp | 70 +++++++++++------------ libultraship/libultraship/GameOverlay.h | 2 - 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/libultraship/libultraship/GameOverlay.cpp b/libultraship/libultraship/GameOverlay.cpp index 8fe028667..1a3a1e3bb 100644 --- a/libultraship/libultraship/GameOverlay.cpp +++ b/libultraship/libultraship/GameOverlay.cpp @@ -9,6 +9,40 @@ #include "Utils/StringHelper.h" namespace Ship { + bool OverlayCommand(std::shared_ptr Console, const std::vector& args) { + if (args.size() < 3) { + return CMD_FAILED; + } + + if (CVar_Get(args[2].c_str()) != nullptr) { + const char* key = args[2].c_str(); + GameOverlay* overlay = SohImGui::overlay; + if (args[1] == "add") { + if (!overlay->RegisteredOverlays.contains(key)) { + overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f }); + SohImGui::console->SendInfoMessage("Added overlay: %s", key); + } + else { + SohImGui::console->SendErrorMessage("Overlay already exists: %s", key); + } + } + else if (args[1] == "remove") { + if (overlay->RegisteredOverlays.contains(key)) { + overlay->RegisteredOverlays.erase(key); + SohImGui::console->SendInfoMessage("Removed overlay: %s", key); + } + else { + SohImGui::console->SendErrorMessage("Overlay not found: %s", key); + } + } + } + else { + SohImGui::console->SendErrorMessage("CVar {} does not exist", args[2].c_str()); + } + + return CMD_SUCCESS; + } + void GameOverlay::LoadFont(const std::string& name, const std::string& path, float fontSize) { ImGuiIO& io = ImGui::GetIO(); std::shared_ptr base = GlobalCtx2::GetInstance()->GetResourceManager()->GetArchive(); @@ -195,40 +229,4 @@ namespace Ship { ImGui::End(); } - - - bool OverlayCommand(const std::vector& args) { - if (args.size() < 3) { - return CMD_FAILED; - } - - if (CVar_Get(args[2].c_str()) != nullptr) { - const char* key = args[2].c_str(); - GameOverlay* overlay = SohImGui::overlay; - if (args[1] == "add") { - if (!overlay->RegisteredOverlays.contains(key)) { - overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f }); - SPDLOG_INFO("Added overlay: {} ", key); - SohImGui::console->SendInfoMessage("Added overlay: %s", key); - } - else { - SPDLOG_ERROR("Overlay already exists: {}", key); - } - } - else if (args[1] == "remove") { - if (overlay->RegisteredOverlays.contains(key)) { - overlay->RegisteredOverlays.erase(key); - SPDLOG_INFO("Removed overlay: {} ", key); - } - else { - SPDLOG_ERROR("Overlay not found: {}", key); - } - } - } - else { - SPDLOG_ERROR("CVar {} does not exist", args[2].c_str()); - } - - return CMD_SUCCESS; - } } diff --git a/libultraship/libultraship/GameOverlay.h b/libultraship/libultraship/GameOverlay.h index 061d259ba..57bc41864 100644 --- a/libultraship/libultraship/GameOverlay.h +++ b/libultraship/libultraship/GameOverlay.h @@ -37,6 +37,4 @@ namespace Ship { void CleanupNotifications(); void LoadFont(const std::string& name, const std::string& path, float fontSize); }; - - bool OverlayCommand(const std::vector& args); }