SpiecsEngine
 
Loading...
Searching...
No Matches

◆ OnRender()

void Spices::ImguiConsole::OnRender ( )
overridevirtual

This interface is called On SlateRenderer Render.

Begin render Console.

Render ClearConsoleIcon.

Render OpenLogFileIcon.

Open Log file that in writtening.

Render OpenLogFolderIcon.

Get Selected file in Explore.

Open Log file that in writtening.

Render EnableCommandFieldIcon.

Render FilterIcon.

Render VerboseIcon.

Render InfoIcon.

Render WarningIcon.

Render ErrorIcon.

Search String.

Render Search Input Text.

Render Console ScrollingRegion.

Render Console Command-line.

End render Console.

Begin render Console.

Render ClearConsoleIcon.

Render OpenLogFileIcon.

Open Log file that in writtening.

Render OpenLogFolderIcon.

Get Selected file in Explore.

Open Log file that in writtening.

Render EnableCommandFieldIcon.

Render FilterIcon.

Render VerboseIcon.

Render InfoIcon.

Render WarningIcon.

Render ErrorIcon.

Search String.

Render Search Input Text.

Render Console ScrollingRegion.

Render Console Command-line.

End render Console.

Implements Spices::ImguiSlate.

Definition at line 26 of file ImguiConsole.cpp.

27 {
29
33 Begin();
34
35 ImGui::Spacing();
36
40 {
41 SPICES_PROFILE_ZONEN("Console ClearConsoleIcon");
42
43 if (ImGui::Button(ICON_MD_FORMAT_CLEAR, ImGuiH::GetLineItemSize()))
44 {
45 m_Console->Clear();
46 }
47 ImGui::SetItemTooltip("Clear Console");
48 }
49
53 {
54 SPICES_PROFILE_ZONEN("Console OpenLogFileIcon");
55
56 ImGui::SameLine();
57 if (ImGui::Button(ICON_MD_EDIT_NOTE, ImGuiH::GetLineItemSize()))
58 {
59 std::stringstream ss;
60 ss << "C:/Windows/System32/notepad.exe " << m_Console->GetFilePath();
61
65 ProcessLibrary::OpenProcess("C:/Windows/System32/notepad.exe ", ss.str().c_str());
66 }
67 ImGui::SetItemTooltip("Open Log File");
68 }
69
73 {
74 SPICES_PROFILE_ZONEN("Console OpenLogFolderIcon");
75
76 ImGui::SameLine();
77 if (ImGui::Button(ICON_MD_FOLDER, ImGuiH::GetLineItemSize()))
78 {
82 std::string filepath = FileLibrary::FileLibrary_OpenInExplore(
83 "Spices Log (*.log)\0*.log\0",
84 glfwGetWin32Window((GLFWwindow*)VulkanRenderBackend::GetState().m_Windows)
85 );
86
87 if (!filepath.empty())
88 {
89 std::stringstream ss;
90 ss << "C:/Windows/System32/notepad.exe " << filepath;
91
95 ProcessLibrary::OpenProcess("C:/Windows/System32/notepad.exe ", ss.str().c_str());
96 }
97 }
98 ImGui::SetItemTooltip("Open Log Folder");
99 }
100
104 {
105 SPICES_PROFILE_ZONEN("Console EnableCommandFieldIcon");
106
107 ImGui::SameLine();
108 if (ImGui::Button(ICON_MD_TERMINAL, ImGuiH::GetLineItemSize())) m_EnableCmdInput = !m_EnableCmdInput;
109 ImGui::SetItemTooltip("Enable Command Field");
110 }
111
115 {
116 SPICES_PROFILE_ZONEN("Console FilterIcon");
117
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");
121 }
122
126 {
127 SPICES_PROFILE_ZONEN("Console VerboseIcon");
128
129 ImGui::SameLine();
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");
134 }
135
139 {
140 SPICES_PROFILE_ZONEN("Console InfoIcon");
141
142 ImGui::SameLine();
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");
147 }
148
152 {
153 SPICES_PROFILE_ZONEN("Console WarningIcon");
154
155 ImGui::SameLine();
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");
160 ImGui::SameLine();
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();
164 }
165
169 {
170 SPICES_PROFILE_ZONEN("Console ErrorIcon");
171
172 ImGui::SameLine();
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");
177 ImGui::SameLine();
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();
181 }
182
186 static std::string searchString;
187 static bool isEnableSearch = false;
188
192 {
193 SPICES_PROFILE_ZONEN("Console Search Input Text");
194
195 ImGui::SameLine();
196 ImGui::PushItemWidth(200);
197 static char search[128] = "";
198 if (ImGui::InputTextWithHint("##", ICON_TEXT(ICON_MD_SEARCH, Search), search, 128))
199 {
200 searchString = std::string(search);
201 if (searchString.size() == 0) isEnableSearch = false;
202 else isEnableSearch = true;
203 }
204 ImGui::PopItemWidth();
205 ImGui::Spacing();
206 ImGui::PushStyleColor(ImGuiCol_Separator, ImVec4(0.121f, 0.129f, 0.141f, 1.0f));
207 ImGui::Separator();
208 ImGui::PopStyleColor();
209 ImGui::Spacing();
210 }
211
215 {
216 SPICES_PROFILE_ZONEN("Console ScrollingRegion");
217
218 ImGui::PushStyleColor(ImGuiCol_ChildBg, ImGui::GetStyleColorVec4(ImGuiCol_FrameBg));
219 ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImGui::GetStyleColorVec4(ImGuiCol_Border));
220
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))
223 {
224 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1));
225
226 bool isFiltered = m_Filter.IsActive();
227
228 switch (m_Level)
229 {
230 default:
231 break;
232 case 0:
233 for (auto it = m_Console->GetInfos().m_TraceLogInfos.rbegin(); it != m_Console->GetInfos().m_TraceLogInfos.rend(); ++it)
234 {
235 const InfoLevelHelper& helper = *it;
236
237 if (isEnableSearch)
238 {
239 if (helper.str.find(searchString) == std::string::npos) continue;
240 }
241
242 ImGui::PushStyleColor(ImGuiCol_Text, { helper.color.x, helper.color.y, helper.color.z, helper.color.w });
243 if (helper.level == "trace")
244 {
245 std::stringstream ss;
246 ss << ICON_MD_EMERGENCY << " " << helper.str;
247
248 ImGui::Selectable(ss.str().c_str(), false);
249 }
250 ImGui::PopStyleColor();
251 }
252 break;
253 case 1:
254 for (auto it = m_Console->GetInfos().m_InfoLogInfos.rbegin(); it != m_Console->GetInfos().m_InfoLogInfos.rend(); ++it)
255 {
256 const InfoLevelHelper& helper = *it;
257
258 if (isEnableSearch)
259 {
260 if (helper.str.find(searchString) == std::string::npos) continue;
261 }
262
263 ImGui::PushStyleColor(ImGuiCol_Text, { helper.color.x, helper.color.y, helper.color.z, helper.color.w });
264 if (helper.level == "info")
265 {
266 std::stringstream ss;
267 ss << ICON_MD_ERROR_OUTLINE << " " << helper.str;
268
269 ImGui::Selectable(ss.str().c_str(), false);
270 }
271 ImGui::PopStyleColor();
272 }
273 break;
274 case 2:
275 for (auto it = m_Console->GetInfos().m_WarnLogInfos.rbegin(); it != m_Console->GetInfos().m_WarnLogInfos.rend(); ++it)
276 {
277 const InfoLevelHelper& helper = *it;
278
279 if (isEnableSearch)
280 {
281 if (helper.str.find(searchString) == std::string::npos) continue;
282 }
283
284 ImGui::PushStyleColor(ImGuiCol_Text, { helper.color.x, helper.color.y, helper.color.z, helper.color.w });
285 if (helper.level == "warn")
286 {
287 std::stringstream ss;
288 ss << ICON_MD_WARNING_AMBER << " " << helper.str;
289
290 ImGui::Selectable(ss.str().c_str(), false);
291 }
292 ImGui::PopStyleColor();
293 }
294 break;
295 case 3:
296 for (auto it = m_Console->GetInfos().m_ErrorLogInfos.rbegin(); it != m_Console->GetInfos().m_ErrorLogInfos.rend(); ++it)
297 {
298 const InfoLevelHelper& helper = *it;
299
300 if (isEnableSearch)
301 {
302 if (helper.str.find(searchString) == std::string::npos) continue;
303 }
304
305 ImGui::PushStyleColor(ImGuiCol_Text, { helper.color.x, helper.color.y, helper.color.z, helper.color.w });
306 if (helper.level == "error")
307 {
308 std::stringstream ss;
309 ss << ICON_MD_NEARBY_ERROR << " " << helper.str;
310
311 ImGui::Selectable(ss.str().c_str(), false);
312 }
313 ImGui::PopStyleColor();
314 }
315 break;
316 }
317
318 ImGui::PopStyleVar();
319 }
320
321 ImGui::PopStyleColor(2);
322 ImGui::EndChild();
323 }
324
328 {
330 {
331 SPICES_PROFILE_ZONEN("Console Command-line");
332
333 ImGui::Spacing();
334 ImGui::Separator();
335 ImGui::Spacing();
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(
346 "Cmd",
347 ICON_TEXT_ROW(" ", "Cmd"),
348 InputBuf,
349 IM_ARRAYSIZE(InputBuf),
350 input_text_flags,
352 (void*)this
353 );
354 ImGui::PopItemWidth();
355 }
356 }
357
361 End();
362 }
#define ICON_TEXT(icon, text)
Definition ImguiHelper.h:24
#define ICON_TEXT_ROW(icon, text)
Definition ImguiHelper.h:25
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
static std::string FileLibrary_OpenInExplore(const char *filter, HWND hwnd)
Select a file to open in explore.
static ImVec2 GetLineItemSize()
Get Line Width's Square Size.
std::shared_ptr< Console > m_Console
The shared pointer of Console.
bool m_EnableCmdInput
The boolean of enable Cmd Input.
ImGuiTextFilter m_Filter
The Filter of console.
int m_Level
The information level that console show.
static int TextEditCallbackStub(ImGuiInputTextCallbackData *data)
Input Text Call back function.
void Begin(float alpha=1.0f, ImGuiWindowFlags flags=0)
Begin a common slate.
void End()
End a slate.
ImVec2 m_PanelSize
This slate's size.
Definition ImguiUtils.h:151
static bool OpenProcess(const char *processPath, const char *commandLine="")
Open a Process with command.
static VulkanState & GetState()
Get VulkanState in use.
std::string to_string(GFSDK_Aftermath_Result result)
Convert GFSDK_Aftermath_Result to string.

References Spices::ImguiSlate::End(), m_EnableCmdInput, m_Level, and Spices::ProcessLibrary::OpenProcess().