#pragma once #include #include #if defined(DEBUG) #define DBG_DEFINE_DEBUG_VARIABLE(type, name) \ static type name; \ hex::dbg::impl::drawDebugVariable(name, WOLV_STRINGIFY(name)); #else #define DBG_DEFINE_DEBUG_VARIABLE(type, name) \ static_assert(false, "Debug variables are only intended for use during development."); #endif namespace hex::dbg { namespace impl { bool &getDebugWindowState(); template static void drawDebugVariable(T &variable, std::string_view name) { if (!getDebugWindowState()) return; if (ImGui::Begin("Debug Variables", &getDebugWindowState(), ImGuiWindowFlags_AlwaysAutoResize)) { using Type = std::remove_cvref_t; if constexpr (std::same_as) { ImGui::Checkbox(name.data(), &variable); } else if constexpr (std::integral || std::floating_point) { ImGui::InputScalar(name.data(), ImGui::getImGuiDataType(), &variable); } else if constexpr (std::same_as) { ImGui::InputFloat2(name.data(), &variable.x); } else if constexpr (std::same_as) { ImGui::InputText(name.data(), variable); } else if constexpr (std::same_as) { ImGui::ColorEdit4(name.data(), &variable.Value.x, ImGuiColorEditFlags_AlphaBar); } else { static_assert(hex::always_false::value, "Unsupported type"); } } ImGui::End(); } } }