-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsole.hpp
68 lines (57 loc) · 2.4 KB
/
console.hpp
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
#pragma once
#include <module.hpp>
#include <sdk.hpp>
#include <platform.hpp>
#include <functional>
#define TIER0 "libtier0"
#define CONCOLORMSG_SYMBOL "_Z11ConColorMsgRK5ColorPKcz"
#define DEVMSG_SYMBOL "_Z6DevMsgPKcz"
#define DEVWARNINGMSG_SYMBOL "_Z10DevWarningPKcz"
#define MSG_SYMBOL "Msg"
#define WARNING_SYMBOL "Warning"
#define PLUG_PRINT_COLOR Color(52, 183, 235)
#define PLUG_PRINT_ACTIVE_COLOR Color(110, 247, 76)
class Console : public Module {
public:
using _Msg = void(__cdecl*)(const char* pMsgFormat, ...);
using _Warning = void(__cdecl*)(const char* pMsgFormat, ...);
using _ColorMsg = void(__cdecl*)(const Color& clr, const char* pMsgFormat, ...);
using _DevMsg = void(__cdecl*)(const char* pMsgFormat, ...);
using _DevWarning = void(__cdecl*)(const char* pMsgFormat, ...);
using _LoggingSystem_RegisterLoggingListener = void (__cdecl *)(ILoggingListener *listener);
using _LoggingSystem_PushLoggingState = void (__cdecl *)(bool threadLocal, bool clearState);
using _LoggingSystem_PopLoggingState = void (__cdecl *)(bool threadLocal);
using _LoggingSystem_HasTag = bool (__cdecl *)(int channelID, const char *tag);
using _LoggingSystem_SetChannelSpewLevelByTag = void (__cdecl *)(const char *tag, LoggingSeverity severity);
_Msg Msg = nullptr;
_ColorMsg ColorMsg = nullptr;
_Warning Warning = nullptr;
_DevMsg DevMsg = nullptr;
_DevWarning DevWarning = nullptr;
_LoggingSystem_PushLoggingState LoggingSystem_PushLoggingState = nullptr;
_LoggingSystem_PopLoggingState LoggingSystem_PopLoggingState = nullptr;
_LoggingSystem_RegisterLoggingListener LoggingSystem_RegisterLoggingListener = nullptr;
_LoggingSystem_HasTag LoggingSystem_HasTag = nullptr;
_LoggingSystem_SetChannelSpewLevelByTag LoggingSystem_SetChannelSpewLevelByTag = nullptr;
public:
template <typename... T>
void Print(const char* fmt, T... args) {
this->ColorMsg(PLUG_PRINT_COLOR, fmt, args...);
}
template <typename... T>
void PrintActive(const char* fmt, T... args) {
this->ColorMsg(PLUG_PRINT_ACTIVE_COLOR, fmt, args...);
}
bool Init() override;
void Shutdown() override;
const char* Name() override { return "libtier0.so"; }
};
class ConsoleListener : private ILoggingListener {
public:
ConsoleListener(std::function<void (const char *)> cbk);
virtual ~ConsoleListener();
private:
virtual void Log(const LoggingContext* ctx, const char* msg) override;
std::function<void (const char *)> cbk;
};
extern Console* console;