LUS Cleanup: Console class is now in the Ship namespace

This commit is contained in:
Kenix3 2022-07-31 23:36:21 -04:00
commit 352b46c1f5
6 changed files with 266 additions and 263 deletions

View file

@ -10,6 +10,7 @@
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#include "Lib/ImGui/imgui_internal.h" #include "Lib/ImGui/imgui_internal.h"
namespace Ship {
std::map<ImGuiKey, std::string> Bindings; std::map<ImGuiKey, std::string> Bindings;
std::map<ImGuiKey, std::string> BindingToggle; std::map<ImGuiKey, std::string> BindingToggle;
@ -329,3 +330,4 @@ void Console::Append(const std::string& channel, Priority priority, const char*
va_end(args); va_end(args);
this->Log[channel].push_back({ std::string(buf), priority }); this->Log[channel].push_back({ std::string(buf), priority });
} }
}

View file

@ -7,10 +7,11 @@
#include "Lib/ImGui/imgui.h" #include "Lib/ImGui/imgui.h"
#define LOG(msg, ...) SohImGui::console->Append("Main", Priority::LOG_LVL, msg, ##__VA_ARGS__) namespace Ship {
#define INFO(msg, ...) SohImGui::console->Append("Main", Priority::INFO_LVL, msg, ##__VA_ARGS__) #define LOG(msg, ...) SohImGui::console->Append("Main", Ship::Priority::LOG_LVL, msg, ##__VA_ARGS__)
#define WARNING(msg, ...) SohImGui::console->Append("Main", Priority::WARNING_LVL, msg, ##__VA_ARGS__) #define INFO(msg, ...) SohImGui::console->Append("Main", Ship::Priority::INFO_LVL, msg, ##__VA_ARGS__)
#define ERROR(msg, ...) SohImGui::console->Append("Main", Priority::ERROR_LVL, msg, ##__VA_ARGS__) #define WARNING(msg, ...) SohImGui::console->Append("Main", Ship::Priority::WARNING_LVL, msg, ##__VA_ARGS__)
#define ERROR(msg, ...) SohImGui::console->Append("Main", Ship::Priority::ERROR_LVL, msg, ##__VA_ARGS__)
#define CMD_SUCCESS true #define CMD_SUCCESS true
#define CMD_FAILED false #define CMD_FAILED false
#define MAX_BUFFER_SIZE 255 #define MAX_BUFFER_SIZE 255
@ -79,3 +80,4 @@ public:
void Dispatch(const std::string& line); void Dispatch(const std::string& line);
static int CallbackStub(ImGuiInputTextCallbackData* data); static int CallbackStub(ImGuiInputTextCallbackData* data);
}; };
}

View file

@ -69,7 +69,7 @@ namespace SohImGui {
WindowDrawFunc drawFunc; WindowDrawFunc drawFunc;
} CustomWindow; } CustomWindow;
extern Console* console; extern Ship::Console* console;
extern Ship::InputEditor* controller; extern Ship::InputEditor* controller;
extern Ship::GameOverlay* overlay; extern Ship::GameOverlay* overlay;
extern bool needs_save; extern bool needs_save;
@ -92,7 +92,7 @@ namespace SohImGui {
void Render(void); void Render(void);
void CancelFrame(void); void CancelFrame(void);
void ShowCursor(bool hide, Dialogues w); void ShowCursor(bool hide, Dialogues w);
void BindCmd(const std::string& cmd, CommandEntry entry); void BindCmd(const std::string& cmd, Ship::CommandEntry entry);
void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc, bool isEnabled=false, bool isHidden=false); void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc, bool isEnabled=false, bool isHidden=false);
void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint = ImVec4(1, 1, 1, 1)); void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint = ImVec4(1, 1, 1, 1));
void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha=false); void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha=false);

View file

@ -358,7 +358,6 @@ static void gfx_dxgi_show_cursor(bool hide) {
* @bug When menubar is open in windowed mode and you toggle fullscreen * @bug When menubar is open in windowed mode and you toggle fullscreen
* ShowCursor no longer responds. Debugging shows the bool to be correct. * ShowCursor no longer responds. Debugging shows the bool to be correct.
**/ **/
INFO("renderer: %s", hide ? "true" : "false");
ShowCursor(hide); ShowCursor(hide);
} }

View file

@ -34,7 +34,7 @@ public:
protected: protected:
void sink_it_(const details::log_msg &msg) override void sink_it_(const details::log_msg &msg) override
{ {
const Priority priority = convert_to_soh(msg.level); const Ship::Priority priority = convert_to_soh(msg.level);
memory_buf_t formatted; memory_buf_t formatted;
if (use_raw_msg_) if (use_raw_msg_)
{ {
@ -53,24 +53,25 @@ protected:
void flush_() override {} void flush_() override {}
private: private:
static Priority convert_to_soh(spdlog::level::level_enum level) { static Ship::Priority convert_to_soh(spdlog::level::level_enum level)
{
switch (level) { switch (level) {
case spdlog::level::trace: case spdlog::level::trace:
return Priority::INFO_LVL; return Ship::Priority::INFO_LVL;
case spdlog::level::debug: case spdlog::level::debug:
return Priority::LOG_LVL; return Ship::Priority::LOG_LVL;
case spdlog::level::info: case spdlog::level::info:
return Priority::LOG_LVL; return Ship::Priority::LOG_LVL;
case spdlog::level::warn: case spdlog::level::warn:
return Priority::WARNING_LVL; return Ship::Priority::WARNING_LVL;
case spdlog::level::err: case spdlog::level::err:
return Priority::ERROR_LVL; return Ship::Priority::ERROR_LVL;
case spdlog::level::critical: case spdlog::level::critical:
return Priority::ERROR_LVL; return Ship::Priority::ERROR_LVL;
default: default:
break; break;
} }
return Priority::LOG_LVL; return Ship::Priority::LOG_LVL;
} }
std::string tag_; std::string tag_;

View file

@ -463,50 +463,49 @@ void DebugConsole_Init(void) {
CMD_REGISTER("kill", { KillPlayerHandler, "Commit suicide." }); CMD_REGISTER("kill", { KillPlayerHandler, "Commit suicide." });
CMD_REGISTER("map", { LoadSceneHandler, "Load up kak?" }); CMD_REGISTER("map", { LoadSceneHandler, "Load up kak?" });
CMD_REGISTER("rupee", { RuppeHandler, "Set your rupee counter.", { CMD_REGISTER("rupee", { RuppeHandler, "Set your rupee counter.", {
{"amount", ArgumentType::NUMBER } {"amount", Ship::ArgumentType::NUMBER }
}}); }});
CMD_REGISTER("bItem", { BHandler, "Set an item to the B button.", { { "Item ID", ArgumentType::NUMBER } } }); CMD_REGISTER("bItem", { BHandler, "Set an item to the B button.", { { "Item ID", Ship::ArgumentType::NUMBER } } });
CMD_REGISTER("health", { SetPlayerHealthHandler, "Set the health of the player.", { CMD_REGISTER("health", { SetPlayerHealthHandler, "Set the health of the player.", { { "health", Ship::ArgumentType::NUMBER }
{"health", ArgumentType::NUMBER }
}}); }});
CMD_REGISTER("spawn", { ActorSpawnHandler, "Spawn an actor.", { CMD_REGISTER("spawn", { ActorSpawnHandler, "Spawn an actor.", { { "actor_id", Ship::ArgumentType::NUMBER },
{ "actor_id", ArgumentType::NUMBER }, { "data", Ship::ArgumentType::NUMBER },
{ "data", ArgumentType::NUMBER }, { "x", Ship::ArgumentType::PLAYER_POS, true },
{ "x", ArgumentType::PLAYER_POS, true }, { "y", Ship::ArgumentType::PLAYER_POS, true },
{ "y", ArgumentType::PLAYER_POS, true }, { "z", Ship::ArgumentType::PLAYER_POS, true },
{ "z", ArgumentType::PLAYER_POS, true }, { "rx", Ship::ArgumentType::PLAYER_ROT, true },
{ "rx", ArgumentType::PLAYER_ROT, true }, { "ry", Ship::ArgumentType::PLAYER_ROT, true },
{ "ry", ArgumentType::PLAYER_ROT, true }, { "rz", Ship::ArgumentType::PLAYER_ROT, true }
{ "rz", ArgumentType::PLAYER_ROT, true }
}}); }});
CMD_REGISTER("pos", { SetPosHandler, "Sets the position of the player.", { CMD_REGISTER("pos", { SetPosHandler, "Sets the position of the player.", { { "x", Ship::ArgumentType::PLAYER_POS, true },
{ "x", ArgumentType::PLAYER_POS, true }, { "y", Ship::ArgumentType::PLAYER_POS, true },
{ "y", ArgumentType::PLAYER_POS, true }, { "z", Ship::ArgumentType::PLAYER_POS, true }
{ "z", ArgumentType::PLAYER_POS, true }
}}); }});
CMD_REGISTER("set", { SetCVarHandler, CMD_REGISTER("set", { SetCVarHandler,
"Sets a console variable.", "Sets a console variable.",
{ { "varName", ArgumentType::TEXT }, { "varValue", ArgumentType::TEXT } } }); { { "varName", Ship::ArgumentType::TEXT }, { "varValue", Ship::ArgumentType::TEXT } } });
CMD_REGISTER("get", { GetCVarHandler, "Gets a console variable.", { { "varName", ArgumentType::TEXT } } }); CMD_REGISTER("get", { GetCVarHandler, "Gets a console variable.", { { "varName", Ship::ArgumentType::TEXT } } });
CMD_REGISTER("reset", { ResetHandler, "Resets the game." }); CMD_REGISTER("reset", { ResetHandler, "Resets the game." });
CMD_REGISTER("ammo", { AmmoHandler, "Changes ammo of an item.", CMD_REGISTER("ammo", { AmmoHandler, "Changes ammo of an item.",
{ { "item", ArgumentType::TEXT }, { { "item", Ship::ArgumentType::TEXT }, { "count", Ship::ArgumentType::NUMBER } } });
{ "count", ArgumentType::NUMBER } } });
CMD_REGISTER("bottle", { BottleHandler, CMD_REGISTER("bottle", { BottleHandler,
"Changes item in a bottle slot.", "Changes item in a bottle slot.",
{ { "item", ArgumentType::TEXT }, { "slot", ArgumentType::NUMBER } } }); { { "item", Ship::ArgumentType::TEXT }, { "slot", Ship::ArgumentType::NUMBER } } });
CMD_REGISTER("item", { ItemHandler, CMD_REGISTER("item", { ItemHandler,
"Sets item ID in arg 1 into slot arg 2. No boundary checks. Use with caution.", "Sets item ID in arg 1 into slot arg 2. No boundary checks. Use with caution.",
{ { "slot", ArgumentType::NUMBER }, { "item id", ArgumentType::NUMBER } } }); { { "slot", Ship::ArgumentType::NUMBER }, { "item id", Ship::ArgumentType::NUMBER } } });
CMD_REGISTER("entrance", CMD_REGISTER("entrance", { EntranceHandler,
{ EntranceHandler, "Sends player to the entered entrance (hex)", { { "entrance", ArgumentType::NUMBER } } }); "Sends player to the entered entrance (hex)",
{ { "entrance", Ship::ArgumentType::NUMBER } } });
CMD_REGISTER("save_state", { SaveStateHandler, "Save a state." }); CMD_REGISTER("save_state", { SaveStateHandler, "Save a state." });
CMD_REGISTER("load_state", { LoadStateHandler, "Load a state." }); CMD_REGISTER("load_state", { LoadStateHandler, "Load a state." });
CMD_REGISTER("set_slot", { StateSlotSelectHandler, "Selects a SaveState slot", { CMD_REGISTER("set_slot", { StateSlotSelectHandler, "Selects a SaveState slot", { {
{ "Slot number", ArgumentType::NUMBER, } "Slot number",
Ship::ArgumentType::NUMBER,
}
} }); } });
DebugConsole_LoadCVars(); DebugConsole_LoadCVars();
} }