|
9 | 9 | #include "Utils/StringHelper.h" |
10 | 10 |
|
11 | 11 | 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 | + |
12 | 46 | void GameOverlay::LoadFont(const std::string& name, const std::string& path, float fontSize) { |
13 | 47 | ImGuiIO& io = ImGui::GetIO(); |
14 | 48 | std::shared_ptr<Archive> base = GlobalCtx2::GetInstance()->GetResourceManager()->GetArchive(); |
@@ -195,40 +229,4 @@ namespace Ship { |
195 | 229 |
|
196 | 230 | ImGui::End(); |
197 | 231 | } |
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 | | - } |
234 | 232 | } |
0 commit comments