-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.h
101 lines (76 loc) · 2.55 KB
/
helper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#pragma once
#ifndef LATENCYMETERREFRESHED_HELPER_H
#define LATENCYMETERREFRESHED_HELPER_H
#include "External/ImGui/imgui.h"
#include "structs.h"
#include <vector>
#include <string>
#ifdef __linux__
#include <unistd.h>
#define _min(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
#define _max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
#else
#include <windows.h>
#define _min(a,b) min(a,b)
#define _max(a,b) max(a,b)
#endif
#ifndef ZeroMemory
#ifdef __linux__
#define ZeroMemory(ptr, size) (memset(ptr, 0, size))
#endif
#endif
inline ImGuiTableSortSpecs* sortSpec;
namespace helper {
inline unsigned long External2Micros = 1000;
// idk why I didn't just expose it in GUI.h...
#ifdef _WIN32
//HWND hwnd; // I have exposed it in GUI namespace
#endif
/* ---- User Data ---- (Don't ask me why I didn't create structures for these things earlier) */
inline const int styleColorNum = 2;
inline const unsigned int colorSize = 16;
inline ImFont* boldFont;
#ifdef _WIN32
inline const char* fonts[4]{ "Courier Prime", "Source Sans Pro", "Franklin Gothic", "Lucida Console" };
inline const int fontIndex[4]{ 0, 2, 4, 5 };
#else
inline const char* fonts[]{ "Courier Prime", "Source Sans Pro" };
inline const int fontIndex[]{ 0, 2};
#endif
/* ---- User Data ---- */
inline UserData currentUserData{};
inline UserData backupUserData{};
inline std::vector<TabInfo> tabsInfo{};
inline int selectedTab = 0;
inline bool isFullscreen = false;
inline bool fullscreenModeOpenPopup = false;
inline bool fullscreenModeClosePopup = false;
int LatencyCompare(const void* a, const void* b);
#ifdef _WIN32
inline LARGE_INTEGER StartingTime{ 0 };
#endif
uint64_t micros();
void ApplyStyle(float colors[styleColorNum][4], float brightnesses[styleColorNum]);
void RevertConfig();
void SaveCurrentUserConfig();
bool LoadCurrentUserConfig();
void ApplyCurrentStyle();
void SetPlotLinesColor(ImVec4 color);
ImFont* GetFontBold(int baseFontIndex);
bool HasConfigChanged();
void RecalculateStats(bool recalculate_Average = false, int tabIdx = selectedTab);
void RemoveMeasurement(size_t index);
bool SaveMeasurements();
bool SaveAsMeasurements();
bool SavePackMeasurements();
bool SavePackAsMeasurements();
JSON_HANDLE_INFO OpenMeasurements();
void mouseClick(); // This might not work for some applications
} // helper
#endif //LATENCYMETERREFRESHED_HELPER_H