Skip to content

Commit 797d9fa

Browse files
committed
GameOverlay command handler no longer uses SPDLOG and prints to console.
1 parent 96c2033 commit 797d9fa

File tree

2 files changed

+34
-38
lines changed

2 files changed

+34
-38
lines changed

libultraship/libultraship/GameOverlay.cpp

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,40 @@
99
#include "Utils/StringHelper.h"
1010

1111
namespace Ship {
12+
bool OverlayCommand(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args) {
13+
if (args.size() < 3) {
14+
return CMD_FAILED;
15+
}
16+
17+
if (CVar_Get(args[2].c_str()) != nullptr) {
18+
const char* key = args[2].c_str();
19+
GameOverlay* overlay = SohImGui::overlay;
20+
if (args[1] == "add") {
21+
if (!overlay->RegisteredOverlays.contains(key)) {
22+
overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f });
23+
SohImGui::console->SendInfoMessage("Added overlay: %s", key);
24+
}
25+
else {
26+
SohImGui::console->SendErrorMessage("Overlay already exists: %s", key);
27+
}
28+
}
29+
else if (args[1] == "remove") {
30+
if (overlay->RegisteredOverlays.contains(key)) {
31+
overlay->RegisteredOverlays.erase(key);
32+
SohImGui::console->SendInfoMessage("Removed overlay: %s", key);
33+
}
34+
else {
35+
SohImGui::console->SendErrorMessage("Overlay not found: %s", key);
36+
}
37+
}
38+
}
39+
else {
40+
SohImGui::console->SendErrorMessage("CVar {} does not exist", args[2].c_str());
41+
}
42+
43+
return CMD_SUCCESS;
44+
}
45+
1246
void GameOverlay::LoadFont(const std::string& name, const std::string& path, float fontSize) {
1347
ImGuiIO& io = ImGui::GetIO();
1448
std::shared_ptr<Archive> base = GlobalCtx2::GetInstance()->GetResourceManager()->GetArchive();
@@ -195,40 +229,4 @@ namespace Ship {
195229

196230
ImGui::End();
197231
}
198-
199-
200-
bool OverlayCommand(const std::vector<std::string>& args) {
201-
if (args.size() < 3) {
202-
return CMD_FAILED;
203-
}
204-
205-
if (CVar_Get(args[2].c_str()) != nullptr) {
206-
const char* key = args[2].c_str();
207-
GameOverlay* overlay = SohImGui::overlay;
208-
if (args[1] == "add") {
209-
if (!overlay->RegisteredOverlays.contains(key)) {
210-
overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f });
211-
SPDLOG_INFO("Added overlay: {} ", key);
212-
SohImGui::console->SendInfoMessage("Added overlay: %s", key);
213-
}
214-
else {
215-
SPDLOG_ERROR("Overlay already exists: {}", key);
216-
}
217-
}
218-
else if (args[1] == "remove") {
219-
if (overlay->RegisteredOverlays.contains(key)) {
220-
overlay->RegisteredOverlays.erase(key);
221-
SPDLOG_INFO("Removed overlay: {} ", key);
222-
}
223-
else {
224-
SPDLOG_ERROR("Overlay not found: {}", key);
225-
}
226-
}
227-
}
228-
else {
229-
SPDLOG_ERROR("CVar {} does not exist", args[2].c_str());
230-
}
231-
232-
return CMD_SUCCESS;
233-
}
234232
}

libultraship/libultraship/GameOverlay.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,4 @@ namespace Ship {
3737
void CleanupNotifications();
3838
void LoadFont(const std::string& name, const std::string& path, float fontSize);
3939
};
40-
41-
bool OverlayCommand(const std::vector<std::string>& args);
4240
}

0 commit comments

Comments
 (0)