mirror of
https://github.com/shadps4-emu/ext-imgui.git
synced 2024-11-23 10:19:55 +00:00
Debug: extracted debug log 0xXXXXXXX scanning into a helper function. (#5855)
This commit is contained in:
parent
109a8632d7
commit
868f444620
@ -162,7 +162,7 @@ See: [Upcoming Changes](https://github.com/ocornut/imgui/wiki/Upcoming-Changes).
|
||||
|
||||
See: [Dear ImGui Test Engine + Test Suite](https://github.com/ocornut/imgui_test_engine) for Automation & Testing.
|
||||
|
||||
For the purposes of getting search engines to crawl the wiki, here's a link to the [Crawable Wiki](https://github-wiki-see.page/m/ocornut/imgui/wiki) (not for humans, [here's why](https://github-wiki-see.page/)).
|
||||
For the purposes of getting search engines to crawl the wiki, here's a link to the [Crawlable Wiki](https://github-wiki-see.page/m/ocornut/imgui/wiki) (not for humans, [here's why](https://github-wiki-see.page/)).
|
||||
|
||||
Getting started? For first-time users having issues compiling/linking/running or issues loading fonts, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions). For ANY other questions, bug reports, requests, feedback, please post on [GitHub Issues](https://github.com/ocornut/imgui/issues). Please read and fill the New Issue template carefully.
|
||||
|
||||
|
42
imgui.cpp
42
imgui.cpp
@ -15637,25 +15637,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
|
||||
clipper.Begin(g.DebugLogIndex.size());
|
||||
while (clipper.Step())
|
||||
for (int line_no = clipper.DisplayStart; line_no < clipper.DisplayEnd; line_no++)
|
||||
{
|
||||
const char* line_begin = g.DebugLogIndex.get_line_begin(g.DebugLogBuf.c_str(), line_no);
|
||||
const char* line_end = g.DebugLogIndex.get_line_end(g.DebugLogBuf.c_str(), line_no);
|
||||
TextUnformatted(line_begin, line_end); // Display line
|
||||
ImRect text_rect = g.LastItemData.Rect;
|
||||
if (IsItemHovered())
|
||||
for (const char* p = line_begin; p <= line_end - 10; p++) // Search for 0x???????? identifiers
|
||||
{
|
||||
ImGuiID id = 0;
|
||||
if (p[0] != '0' || (p[1] != 'x' && p[1] != 'X') || sscanf(p + 2, "%X", &id) != 1)
|
||||
continue;
|
||||
ImVec2 p0 = CalcTextSize(line_begin, p);
|
||||
ImVec2 p1 = CalcTextSize(p, p + 10);
|
||||
g.LastItemData.Rect = ImRect(text_rect.Min + ImVec2(p0.x, 0.0f), text_rect.Min + ImVec2(p0.x + p1.x, p1.y));
|
||||
if (IsMouseHoveringRect(g.LastItemData.Rect.Min, g.LastItemData.Rect.Max, true))
|
||||
DebugLocateItemOnHover(id);
|
||||
p += 10;
|
||||
}
|
||||
}
|
||||
DebugTextUnformattedWithLocateItem(g.DebugLogIndex.get_line_begin(g.DebugLogBuf.c_str(), line_no), g.DebugLogIndex.get_line_end(g.DebugLogBuf.c_str(), line_no));
|
||||
g.DebugLogFlags = backup_log_flags;
|
||||
if (GetScrollY() >= GetScrollMaxY())
|
||||
SetScrollHereY(1.0f);
|
||||
@ -15664,6 +15646,28 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
|
||||
End();
|
||||
}
|
||||
|
||||
// Display line, search for 0xXXXXXXXX identifiers and call DebugLocateItemOnHover() when hovered.
|
||||
void ImGui::DebugTextUnformattedWithLocateItem(const char* line_begin, const char* line_end)
|
||||
{
|
||||
TextUnformatted(line_begin, line_end);
|
||||
if (!IsItemHovered())
|
||||
return;
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImRect text_rect = g.LastItemData.Rect;
|
||||
for (const char* p = line_begin; p <= line_end - 10; p++)
|
||||
{
|
||||
ImGuiID id = 0;
|
||||
if (p[0] != '0' || (p[1] != 'x' && p[1] != 'X') || sscanf(p + 2, "%X", &id) != 1)
|
||||
continue;
|
||||
ImVec2 p0 = CalcTextSize(line_begin, p);
|
||||
ImVec2 p1 = CalcTextSize(p, p + 10);
|
||||
g.LastItemData.Rect = ImRect(text_rect.Min + ImVec2(p0.x, 0.0f), text_rect.Min + ImVec2(p0.x + p1.x, p1.y));
|
||||
if (IsMouseHoveringRect(g.LastItemData.Rect.Min, g.LastItemData.Rect.Max, true))
|
||||
DebugLocateItemOnHover(id);
|
||||
p += 10;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, ID STACK TOOL)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
2
imgui.h
2
imgui.h
@ -28,7 +28,7 @@
|
||||
// Library Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||
#define IMGUI_VERSION "1.90.8 WIP"
|
||||
#define IMGUI_VERSION_NUM 19071
|
||||
#define IMGUI_VERSION_NUM 19072
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
/*
|
||||
|
@ -3495,6 +3495,7 @@ namespace ImGui
|
||||
IMGUI_API void DebugDrawCursorPos(ImU32 col = IM_COL32(255, 0, 0, 255));
|
||||
IMGUI_API void DebugDrawLineExtents(ImU32 col = IM_COL32(255, 0, 0, 255));
|
||||
IMGUI_API void DebugDrawItemRect(ImU32 col = IM_COL32(255, 0, 0, 255));
|
||||
IMGUI_API void DebugTextUnformattedWithLocateItem(const char* line_begin, const char* line_end);
|
||||
IMGUI_API void DebugLocateItem(ImGuiID target_id); // Call sparingly: only 1 at the same time!
|
||||
IMGUI_API void DebugLocateItemOnHover(ImGuiID target_id); // Only call on reaction to a mouse Hover: because only 1 at the same time!
|
||||
IMGUI_API void DebugLocateItemResolveWithLastItem();
|
||||
|
Loading…
Reference in New Issue
Block a user