mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-01-31 07:20:14 -05:00
GameOverlay command handler no longer uses SPDLOG and prints to console.
This commit is contained in:
parent
96c2033361
commit
797d9fab7c
@ -9,6 +9,40 @@
|
|||||||
#include "Utils/StringHelper.h"
|
#include "Utils/StringHelper.h"
|
||||||
|
|
||||||
namespace Ship {
|
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) {
|
void GameOverlay::LoadFont(const std::string& name, const std::string& path, float fontSize) {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
std::shared_ptr<Archive> base = GlobalCtx2::GetInstance()->GetResourceManager()->GetArchive();
|
std::shared_ptr<Archive> base = GlobalCtx2::GetInstance()->GetResourceManager()->GetArchive();
|
||||||
@ -195,40 +229,4 @@ namespace Ship {
|
|||||||
|
|
||||||
ImGui::End();
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,4 @@ namespace Ship {
|
|||||||
void CleanupNotifications();
|
void CleanupNotifications();
|
||||||
void LoadFont(const std::string& name, const std::string& path, float fontSize);
|
void LoadFont(const std::string& name, const std::string& path, float fontSize);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool OverlayCommand(const std::vector<std::string>& args);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user