2
3
4
5
10#include "Core/Log/Console.h"
11#include "Core/Library/FileLibrary.h"
12#include "Render/Vulkan/VulkanRenderBackend.h"
13#include "Core/Library/ProcessLibrary.h"
18 const std::string& panelName ,
20 std::shared_ptr<
Console> console
31
32
38
39
43 if (ImGui::Button(ICON_MD_FORMAT_CLEAR, ImGuiH::GetLineItemSize()))
47 ImGui::SetItemTooltip(
"Clear Console");
51
52
57 if (ImGui::Button(ICON_MD_EDIT_NOTE, ImGuiH::GetLineItemSize()))
60 ss <<
"C:/Windows/System32/notepad.exe " << m_Console->GetFilePath();
63
64
67 ImGui::SetItemTooltip(
"Open Log File");
71
72
77 if (ImGui::Button(ICON_MD_FOLDER, ImGuiH::GetLineItemSize()))
80
81
82 std::string filepath = FileLibrary::FileLibrary_OpenInExplore(
83 "Spices Log (*.log)\0*.log\0",
84 glfwGetWin32Window((GLFWwindow*)VulkanRenderBackend::GetState().m_Windows)
87 if (!filepath.empty())
90 ss <<
"C:/Windows/System32/notepad.exe " << filepath;
93
94
98 ImGui::SetItemTooltip(
"Open Log Folder");
102
103
109 ImGui::SetItemTooltip(
"Enable Command Field");
113
114
118 ImGui::SameLine(m_PanelSize.x - ImGuiH::GetLineItemSize().x * 5.7f - 220.0f);
119 if (ImGui::Button(ICON_MD_FILTER_ALT, ImGuiH::GetLineItemSize())) {}
120 ImGui::SetItemTooltip(
"Filter");
124
125
130 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.83f, 0.83f, 0.83f, 1.0f));
131 if (ImGui::Button(ICON_MD_EMERGENCY, ImGuiH::GetLineItemSize()))
m_Level = 0;
132 ImGui::PopStyleColor();
133 ImGui::SetItemTooltip(
"Verbose");
137
138
143 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.574f, 0.829f, 1.0f, 1.0f));
144 if (ImGui::Button(ICON_MD_ERROR_OUTLINE, ImGuiH::GetLineItemSize()))
m_Level = 1;
145 ImGui::PopStyleColor();
146 ImGui::SetItemTooltip(
"Info");
150
151
156 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.974f, 0.896f, 0.39f, 1.0f));
157 if (ImGui::Button(ICON_MD_WARNING_AMBER, ImGuiH::GetLineItemSize()))
m_Level = 2;
158 ImGui::PopStyleColor();
159 ImGui::SetItemTooltip(
"Warning");
161 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.974f, 0.896f, 0.39f, 1.0f));
162 ImGui::Text(std::to_string(m_Console->GetInfos().m_WarnLogInfos.size()).c_str());
163 ImGui::PopStyleColor();
167
168
173 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.641f, 0.59f, 1.0f));
174 if (ImGui::Button(ICON_MD_NEARBY_ERROR, ImGuiH::GetLineItemSize()))
m_Level = 3;
175 ImGui::PopStyleColor();
176 ImGui::SetItemTooltip(
"Error");
178 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.641f, 0.59f, 1.0f));
179 ImGui::Text(std::to_string(m_Console->GetInfos().m_ErrorLogInfos.size()).c_str());
180 ImGui::PopStyleColor();
184
185
186 static std::string searchString;
187 static bool isEnableSearch =
false;
190
191
196 ImGui::PushItemWidth(200);
197 static char search[128] =
"";
198 if (ImGui::InputTextWithHint(
"##",
ICON_TEXT(ICON_MD_SEARCH, Search), search, 128))
200 searchString = std::string(search);
201 if (searchString.size() == 0) isEnableSearch =
false;
202 else isEnableSearch =
true;
204 ImGui::PopItemWidth();
206 ImGui::PushStyleColor(ImGuiCol_Separator, ImVec4(0.121f, 0.129f, 0.141f, 1.0f));
208 ImGui::PopStyleColor();
213
214
218 ImGui::PushStyleColor(ImGuiCol_ChildBg, ImGui::GetStyleColorVec4(ImGuiCol_FrameBg));
219 ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImGui::GetStyleColorVec4(ImGuiCol_Border));
221 float itemHeight = m_EnableCmdInput ? 3.0f * ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing() : ImGui::GetStyle().ItemSpacing.y;
222 if (ImGui::BeginChild(
"ScrollingRegion", ImVec2(0, -itemHeight), ImGuiChildFlags_None, ImGuiWindowFlags_HorizontalScrollbar))
224 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1));
226 bool isFiltered = m_Filter.IsActive();
233 for (
auto it = m_Console->GetInfos().m_TraceLogInfos.rbegin(); it != m_Console->GetInfos().m_TraceLogInfos.rend(); ++it)
235 const InfoLevelHelper& helper = *it;
239 if (helper.str.find(searchString) == std::string::npos)
continue;
242 ImGui::PushStyleColor(ImGuiCol_Text, { helper.color.x, helper.color.y, helper.color.z, helper.color.w });
243 if (helper.level ==
"trace")
245 std::stringstream ss;
246 ss << ICON_MD_EMERGENCY <<
" " << helper.str;
248 ImGui::Selectable(ss.str().c_str(),
false);
250 ImGui::PopStyleColor();
254 for (
auto it = m_Console->GetInfos().m_InfoLogInfos.rbegin(); it != m_Console->GetInfos().m_InfoLogInfos.rend(); ++it)
256 const InfoLevelHelper& helper = *it;
260 if (helper.str.find(searchString) == std::string::npos)
continue;
263 ImGui::PushStyleColor(ImGuiCol_Text, { helper.color.x, helper.color.y, helper.color.z, helper.color.w });
264 if (helper.level ==
"info")
266 std::stringstream ss;
267 ss << ICON_MD_ERROR_OUTLINE <<
" " << helper.str;
269 ImGui::Selectable(ss.str().c_str(),
false);
271 ImGui::PopStyleColor();
275 for (
auto it = m_Console->GetInfos().m_WarnLogInfos.rbegin(); it != m_Console->GetInfos().m_WarnLogInfos.rend(); ++it)
277 const InfoLevelHelper& helper = *it;
281 if (helper.str.find(searchString) == std::string::npos)
continue;
284 ImGui::PushStyleColor(ImGuiCol_Text, { helper.color.x, helper.color.y, helper.color.z, helper.color.w });
285 if (helper.level ==
"warn")
287 std::stringstream ss;
288 ss << ICON_MD_WARNING_AMBER <<
" " << helper.str;
290 ImGui::Selectable(ss.str().c_str(),
false);
292 ImGui::PopStyleColor();
296 for (
auto it = m_Console->GetInfos().m_ErrorLogInfos.rbegin(); it != m_Console->GetInfos().m_ErrorLogInfos.rend(); ++it)
298 const InfoLevelHelper& helper = *it;
302 if (helper.str.find(searchString) == std::string::npos)
continue;
305 ImGui::PushStyleColor(ImGuiCol_Text, { helper.color.x, helper.color.y, helper.color.z, helper.color.w });
306 if (helper.level ==
"error")
308 std::stringstream ss;
309 ss << ICON_MD_NEARBY_ERROR <<
" " << helper.str;
311 ImGui::Selectable(ss.str().c_str(),
false);
313 ImGui::PopStyleColor();
318 ImGui::PopStyleVar();
321 ImGui::PopStyleColor(2);
326
327
336 ImGui::PushItemWidth(-1);
337 bool reclaim_focus =
false;
338 char InputBuf[512] =
"";
339 ImGuiInputTextFlags input_text_flags =
340 ImGuiInputTextFlags_EnterReturnsTrue |
341 ImGuiInputTextFlags_EscapeClearsAll |
342 ImGuiInputTextFlags_CallbackCompletion |
343 ImGuiInputTextFlags_CallbackHistory |
344 ImGuiInputTextFlags_CallbackCharFilter ;
345 ImGui::InputTextWithHint(
349 IM_ARRAYSIZE(InputBuf),
351 &ImguiConsole::TextEditCallbackStub,
354 ImGui::PopItemWidth();
359
360
364 int ImguiConsole::TextEditCallbackStub(ImGuiInputTextCallbackData* data)
366 SPICES_CORE_INFO(data->Buf);
#define ICON_TEXT(icon, text)
#define ICON_TEXT_ROW(icon, text)
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
FrameInfo Class. This class defines the FrameInfo data.
bool m_EnableCmdInput
The boolean of enable Cmd Input.
ImguiConsole(const std::string &panelName, FrameInfo &frameInfo, std::shared_ptr< Console > console)
Constructor Function.
virtual void OnRender() override
This interface is called On SlateRenderer Render.
int m_Level
The information level that console show.
The ImguiConsole Class. This class defines how to render a Console.
ImguiSlate(const std::string &panelName, FrameInfo &frameInfo)
Constructor Function. Init with Slate's name.
This Class defines the basic behaves of specific slate. When we add an new Slate, we need inherit fro...
static bool OpenProcess(const char *processPath, const char *commandLine="")
Open a Process with command.
Process Static Function Library.