GameOverlay command handler no longer uses SPDLOG and prints to console.

This commit is contained in:
Kenix3 2022-08-09 23:14:31 -04:00
parent 96c2033361
commit 797d9fab7c
2 changed files with 34 additions and 38 deletions

View File

@ -9,6 +9,40 @@
#include "Utils/StringHelper.h"
namespace Ship {
bool OverlayCommand(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& 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<Archive> base = GlobalCtx2::GetInstance()->GetResourceManager()->GetArchive();
@ -195,40 +229,4 @@ namespace Ship {
ImGui::End();
}
bool OverlayCommand(const std::vector<std::string>& 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;
}
}

View File

@ -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<std::string>& args);
}