Karma Engine
Loading...
Searching...
No Matches
KarmaGuiMesa.h
1#pragma once
2
3#include "Karma.h"
4
5extern "C" {
6#include "dmidecode.h"
7}
8
9namespace Karma
10{
12 {
13 std::function< void(std::string) > openSceneCallback;
14 };
15
17 {
18 static KarmaGuiTextBuffer TextBuffer;
19 static KarmaGuiTextFilter TextFilter;
20 static KGVector<int> LineOffsets; // Index to lines offset. We maintain this with AddLog() calls.
21 static bool AutoScroll; // Keep scrolling if already at the bottom.
22 static std::shared_ptr<spdlog::logger> s_MesaCoreLogger;
23 static std::shared_ptr<spdlog::logger> s_MesaClientLogger;
24 static std::shared_ptr<spdlog::pattern_formatter> s_MesaLogFormatter;
25
27 {
28 AutoScroll = true;
29 Clear();
30 }
31
32 static void Clear()
33 {
34 TextBuffer.clear();
35 LineOffsets.clear();
36 LineOffsets.push_back(0);
37 }
38
39 static void AddLog(const char* fmt, ...) /*KG_FMTARGS(2) */// <- what in the name of WYSIWYG is this?
40 {
41 int cacheSize = TextBuffer.size();
42 va_list args;
43 va_start(args, fmt);
44 TextBuffer.appendfv(fmt, args);
45 va_end(args);
46
47 for (int newSize = TextBuffer.size(); cacheSize < newSize; cacheSize++)
48 {
49 if (TextBuffer[cacheSize] == '\n')
50 {
51 LineOffsets.push_back(cacheSize + 1);
52 }
53 }
54 }
55
56 static void Draw(const char* title, bool* pOpen = nullptr)
57 {
58 if (!KarmaGui::Begin(title, pOpen))
59 {
60 KarmaGui::End();
61 return;
62 }
63
64 // Options menu
65 if (KarmaGui::BeginPopup("Options"))
66 {
67 KarmaGui::Checkbox("Auto-scroll", &AutoScroll);
68 KarmaGui::EndPopup();
69 }
70
71 // Main window
72 if (KarmaGui::Button("Options"))
73 {
74 KarmaGui::OpenPopup("Options");
75 }
76
77 KarmaGui::SameLine();
78 bool clear = KarmaGui::Button("Clear");
79 KarmaGui::SameLine();
80 bool copy = KarmaGui::Button("Copy");
81 KarmaGui::SameLine();
82
83 TextFilter.Draw("Filter", -100.0f);
84
85 KarmaGui::Separator();
86 KarmaGui::BeginChild("scrolling", KGVec2(0, 0), false, KGGuiWindowFlags_HorizontalScrollbar);
87
88 if (clear)
89 {
90 Clear();
91 }
92 if (copy)
93 {
94 KarmaGui::LogToClipboard();
95 }
96
97 KarmaGui::PushStyleVar(KGGuiStyleVar_ItemSpacing, KGVec2(0, 0));
98
99 const char* buAlpha = TextBuffer.begin();
100 const char* buOmega = TextBuffer.end();
101
102 if (TextFilter.IsActive())
103 {
104 // In this example we don't use the clipper when TextFilter is enabled.
105 // This is because we don't have a random access on the result on our filter.
106 // A real application processing logs with ten of thousands of entries may want to store the result of
107 // search/filter.. especially if the filtering function is not trivial (e.g. reg-exp).
108 for (int lineNumber = 0; lineNumber < LineOffsets.Size; lineNumber++)
109 {
110 const char* lineStart = buAlpha + LineOffsets[lineNumber];
111 const char* lineEnd = (lineNumber + 1 < LineOffsets.Size) ? (buAlpha + LineOffsets[lineNumber + 1] - 1) : buOmega;
112 if (TextFilter.PassFilter(lineStart, lineEnd))
113 {
114 KarmaGui::TextUnformatted(lineStart, lineEnd);
115 }
116 }
117 }
118 else
119 {
120 // The simplest and easy way to display the entire buffer:
121 // ImGui::TextUnformatted(buBegin, buEnd);
122 // And it'll just work. TextUnformatted() has specialization for large blob of text and will fast-forward
123 // to skip non-visible lines. Here we instead demonstrate using the clipper to only process lines that are
124 // within the visible area.
125 // If you have tens of thousands of items and their processing cost is non-negligible, coarse clipping them
126 // on your side is recommended. Using ImGuiListClipper requires
127 // - A) random access into your data
128 // - B) items all being the same height,
129 // both of which we can handle since we have an array pointing to the beginning of each line of text.
130 // When using the filter (in the block of code above) we don't have random access into the data to display
131 // anymore, which is why we don't use the clipper. Storing or skimming through the search result would make
132 // it possible (and would be recommended if you want to search through tens of thousands of entries).
133 KarmaGuiListClipper clipper;
134 clipper.Begin(LineOffsets.Size);
135
136 while (clipper.Step())
137 {
138 for (int lineNumber = clipper.DisplayStart; lineNumber < clipper.DisplayEnd; lineNumber++)
139 {
140 const char* lineStart = buAlpha + LineOffsets[lineNumber];
141 const char* lineEnd = (lineNumber + 1 < LineOffsets.Size) ? (buAlpha + LineOffsets[lineNumber + 1] - 1) : buOmega;
142 KarmaGui::TextUnformatted(lineStart, lineEnd);
143 }
144 }
145 clipper.End();
146 }
147 KarmaGui::PopStyleVar();
148
149 if (AutoScroll && KarmaGui::GetScrollY() >= KarmaGui::GetScrollMaxY())
150 {
151 KarmaGui::SetScrollHereY(1.0f);
152 }
153
154 KarmaGui::EndChild();
155 KarmaGui::End();
156 }
157 };
158
160 {
161 KGGuiDockNode FutureNode;
162 bool IsDropAllowed;
163 bool IsCenterAvailable;
164 bool IsSidesAvailable; // Hold your breath, grammar freaks..
165 bool IsSplitDirExplicit; // Set when hovered the drop rect (vs. implicit SplitDir==None when hovered the window)
166 KGGuiDockNode* SplitNode;
167 KarmaGuiDir SplitDir;
168 float SplitRatio;
169 KGRect DropRectsDraw[KGGuiDir_COUNT + 1]; // May be slightly different from hit-testing drop rects used in DockNodeCalcDropRects()
170
172 };
173
175 {
176 bool bHasQueried;
177
178 // Bios Information
179 std::string biosVendorName;
180 std::string biosVersion;
181 std::string biosReleaseDate;
182 std::string biosCharacteristics;
183 std::string biosROMSize;
184 std::string biosCurrentSetLanguage;
185 std::string biosRestOfTheSupportedLanguages;
186
187 // System Memory (RAM) overview
188 uint32_t numberOfMemoryDevices;// An estimation. I shall manually introduce logical checks
189
190 // I named estimated because of the lies
191 // https://github.com/ravimohan1991/BiosReader/wiki/The-Life-and-Lies-of-the-BIOS
192 std::string estimatedCapacity;
193 std::string supportingArea;
194
196 {
197 std::string formFactor;
198 std::string ramSize;
199 std::string locator;
200 std::string ramType;
201 std::string bankLocator;
202 std::string manufacturer;
203
204 std::string serialNumber;
205 std::string partNumber;
206 std::string assetTag;
207
208 std::string memorySpeed;
209 std::string configuredMemorySpeed;
210
211 std::string operatingVoltage;
212 std::string rank;
213 };
214 SystemRAM* ramInformation;
215
216 // Let me tell the story of naming. Since the physical slots are the ones
217 // present on board, the array slots in software side, getting filled on a query to BIOS,
218 // naturally get the name "...SoftSlots" from BiosReader's allocation POV
219 std::vector<uint32_t> ramSoftSlots;
220
221 uint32_t totalRamSize;
222 std::string ramSizeDimensions;
223
224 // Processor information
225 // Asssuming only 1 processor
226 std::string cpuDesignation;// Socket designation
227 std::string cpuType; // In order to distinguish from GPU processor :) or DSP https://en.wikipedia.org/wiki/Digital_signal_processor
228 std::string cpuProcessingfamily;
229 std::string cpuManufacturer;
230 std::string cpuFlags;
231 // Kind of the most important element of this struct. eg Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz (completeprocessingunitidentifier)
232 std::string cpuVersion;
233
234 std::string cpuOperatingVoltage;
235 std::string cpuExternalClock;
236 std::string cpuMaximumSpeed;
237 std::string cpuCurrentSpeed;
238
239 // Some OEM specific numbers
240 std::string cpuSerialNumber;
241 std::string cpuPartNumber;
242 std::string cpuAssettag;
243
244 std::string cpuCorescount;
245 std::string cpuEnabledCoresCount;
246 std::string cpuThreadCount;
247 std::string cpuTheCharacterstics;
248
249 // The Cpu ID field contains processor - specific information that describes the processor’s features.
250 std::string cpuid; // in the context of motherboard components
251 std::string cpuSignature;
252
253 // For now, with due respect, let there be enough content with just model number
254 // und vendor. Would be dope to read the GPU just like RAM or CPU, from SMBIOS!!
255 std::string gpuVendor;
256 std::string gpuModelIdentification;
257 std::string gpuVMemory;
258
260 {
261 bHasQueried = false;
262 numberOfMemoryDevices = 0;
263 ramInformation = nullptr;
264 }
265
267
268 // Gauging Ram devices
269 static void GaugeSystemMemoryDevices(random_access_memory* ramCluster);
270
271 // Obtain the real RAM information
272 static void FindRealCapacityOfRam();
273
274 // No-ram conditions. Bit'o hacky stuff
275 static bool IsPhysicalRamPresent(const random_access_memory& ramScam);
276
277 // Filling the SystemRAM structure with relevant information
278 static void FillTheSystemRamStructure(SystemRAM& destinationStructure, random_access_memory& sourceStructure);
279 };
280
282 {
283 float widthCache;
284 float heightCache;
285 float startXCache;
286 float startYCache;
287 float ioDisplayXCache;
288 float ioDisplayYCache;
289 float scrollX;
290 float scrollY;
291 };
292
294 {
295 void* objectPointer;
296 std::string beginAddress;
297 std::string endAddress;
298 size_t size;
299 size_t sizeInPool;
300 std::string uobjectName;
301 uint32_t alignment;
302 UClass* classObject;
303
304 // Placement in memory pool
305 KGVec2 placementCoordi;//nates
306
308 {
309 placementCoordi.x = placementCoordi.y = 0.0f;
310 }
311 };
312
314 {
315 public:
316 // Showtime!
317 static void RevealMainFrame(KGGuiID mainMesaDockID, std::shared_ptr<Scene> scene, const CallbacksFromEditor& editorCallbacks);
318 static void DrawKarmaMainMenuBarMesa();
319 static void DrawMainMenuFileListMesa();
320 static void DrawKarmaLogMesa(KGGuiID mainMesaDockID);
321 static void DrawKarmaSceneHierarchyPanelMesa();
322 static void Draw3DModelExhibitorMesa(std::shared_ptr<Scene> scene);
323 static void DrawContentBrowser(const std::function< void(std::string) >& openSceneCallback);
324 static void DrawMemoryExhibitor();
325
326 // Mesas!
327 static void ShowAboutKarmaMesa(bool* pbOpen);
328
329 // Shiva the Mesa and rest
330 static void MesaShutDownRoutine();
331
332 static KGGuiDockNode* DockNodeTreeFindFallbackLeafNode(KGGuiDockNode* node);
333
334 // Getters
335 static KarmaTuringMachineElectronics& GetGatheredElectronicsInformationForModification() { return electronicsItems; }
336 static const KarmaTuringMachineElectronics& GetGatheredElectronicsInformation() { return electronicsItems; }
337
338 // Setters
339 static void SetElectronicsRamInformationToNull();
340
341 // Helpers
342 static int ImStrlenW(const KGWchar* str);
343 static void QueryForTuringMachineElectronics();
344 static uint32_t ChernUint32FromString(const std::string& ramString);
345 static std::string ChernDimensionsFromString(const std::string& ramString);
346 static double HexStringToDecimal(const std::string& hexString);
347
348 // Statistics
349 static void DumpUObjectStatistics(void* InObject, const std::string& InName, size_t InSize, size_t InAlignment, class UClass* InClass);
350
351 public:
352 static std::string notAvailableText;
353 static KarmaLogMesa m_KarmaLog;
354
355 private:
356 static KarmaTuringMachineElectronics electronicsItems;
357 static WindowManipulationGaugeData m_3DExhibitor;
358 static WindowManipulationGaugeData m_MemoryExhibitor;
359 static bool m_EditorInitialized;
360 static bool m_RefreshRenderingResources;
361
362 // Content browser
363 static std::filesystem::path m_CurrentDirectory;
364
365 // Need agnostic naming scheme
366 static uint32_t m_DirectoryIcon;
367 static uint32_t m_FileIcon;
368
369 // UObjects statistics
370 static KarmaVector<UObjectsStatistics> m_UObjectStatistics;
371
372 public:
373 static bool m_ViewportFocused;
374 static bool m_ViewportHovered;
375 };
376}
Karma's std::vector wrapper.
Definition KarmaTypes.h:128
Definition KarmaGuiMesa.h:314
Definition Class.h:99
Definition KarmaGuiInternal.h:1437
Definition KarmaGuiInternal.h:387
Definition KarmaGui.h:145
Definition KarmaGui.h:1761
Definition KarmaGui.h:2326
Definition KarmaGui.h:2236
Definition KarmaGui.h:2209
Definition KarmaGuiMesa.h:12
Definition KarmaGuiMesa.h:160
Definition KarmaGuiMesa.h:17
Definition KarmaGuiMesa.h:175
Definition KarmaGuiMesa.h:294
Definition KarmaGuiMesa.h:282