refactoring

This commit is contained in:
quaK 2022-06-04 00:39:57 +03:00
parent f78bb85033
commit 4fbc2bf4ce
5 changed files with 291 additions and 263 deletions

View File

@ -55,9 +55,14 @@ namespace console
} }
} }
namespace sys namespace syscon
{ {
//#define COMMAND_HISTORY 64 #define CONSOLE_BK_COLOR RGB(50, 50, 50)
#define CONSOLE_TEXT_COLOR RGB(232, 230, 227)
// todo:
// - history
// - resize
struct WinConData struct WinConData
{ {
@ -66,128 +71,113 @@ namespace console
HWND codLogo; HWND codLogo;
HFONT hfBufferFont; HFONT hfBufferFont;
HWND hwndInputLine; HWND hwndInputLine;
//char errorString[512];
char consoleText[512]; char consoleText[512];
//char returnedText[512];
//char consoleHistory[COMMAND_HISTORY][512];
//int consoleHistoryPos;
//int consoleHistoryCount;
int windowWidth; int windowWidth;
int windowHeight; int windowHeight;
WNDPROC SysInputLineWndProc; WNDPROC SysInputLineWndProc;
char cleanBuffer[65536]; char cleanBuffer[65536];
//char buffer[32768];
//unsigned int bufferLen;
_RTL_CRITICAL_SECTION critSect; _RTL_CRITICAL_SECTION critSect;
//bool disabled;
} s_wcd; } s_wcd;
HICON icon; HICON icon;
HANDLE logo; HANDLE logo;
const char* ClassName = "IW7-Mod WinConsole"; LRESULT ConWndProc(const HWND hwnd, const UINT umsg, const WPARAM wparam, const LPARAM lparam)
const char* WindowName = "IW7-Mod Console";
LRESULT ConWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
switch (uMsg) switch (umsg)
{ {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_SIZE:
// todo: window size?
return DefWindowProcA(hWnd, uMsg, wParam, lParam);
case WM_ACTIVATE: case WM_ACTIVATE:
if (LOWORD(wParam) != WA_INACTIVE) if (LOWORD(wparam) != WA_INACTIVE)
{
SetFocus(s_wcd.hwndInputLine); SetFocus(s_wcd.hwndInputLine);
return DefWindowProcA(hWnd, uMsg, wParam, lParam); }
break;
case WM_CLOSE: case WM_CLOSE:
DestroyWindow(hWnd); game::Cbuf_AddText(0, "quit\n");
return 0; return 0;
case WM_CTLCOLORSTATIC: case WM_CTLCOLORSTATIC:
SetBkColor((HDC)wParam, RGB(50, 50, 50)); SetBkColor(reinterpret_cast<HDC>(wparam), CONSOLE_BK_COLOR);
SetTextColor((HDC)wParam, RGB(232, 230, 227)); SetTextColor(reinterpret_cast<HDC>(wparam), CONSOLE_TEXT_COLOR);
return (INT_PTR)CreateSolidBrush(RGB(50, 50, 50)); return reinterpret_cast<INT_PTR>(CreateSolidBrush(CONSOLE_BK_COLOR));
case WM_CTLCOLOREDIT: case WM_CTLCOLOREDIT:
SetBkColor((HDC)wParam, RGB(50, 50, 50)); SetBkColor(reinterpret_cast<HDC>(wparam), CONSOLE_BK_COLOR);
SetTextColor((HDC)wParam, RGB(232, 230, 227)); SetTextColor(reinterpret_cast<HDC>(wparam), CONSOLE_TEXT_COLOR);
return (INT_PTR)CreateSolidBrush(RGB(50, 50, 50)); return reinterpret_cast<INT_PTR>(CreateSolidBrush(CONSOLE_BK_COLOR));
default:
return DefWindowProcA(hWnd, uMsg, wParam, lParam);
}
} }
void Conbuf_AppendText(const char* pMsg) return DefWindowProcA(hwnd, umsg, wparam, lparam);
}
unsigned int Conbuf_CleanText(const char* source, char* target, size_t size)
{ {
char* b = s_wcd.cleanBuffer; char* b = target;
const char* msg;
unsigned int bufLen;
int i = 0; int i = 0;
static unsigned int s_totalChars; while (source && source[i] && (reinterpret_cast<size_t>(b) - reinterpret_cast<size_t>(target)) < (size - 1))
if (console::is_enabled() && s_wcd.hwndBuffer)
{ {
// if the message is REALLY long, use just the last portion of it if (source[i] == '\n' && source[i + 1] == '\r')
if (strlen(pMsg) > ((sizeof(s_wcd.cleanBuffer) / 2) - 1))
{
msg = pMsg + strlen(pMsg) - ((sizeof(s_wcd.cleanBuffer) / 2) + 1);
}
else
{
msg = pMsg;
}
// copy into an intermediate buffer
while (msg[i] && ((b - s_wcd.cleanBuffer) < sizeof(s_wcd.cleanBuffer) - 1))
{
if (msg[i] == '\n' && msg[i + 1] == '\r')
{ {
b[0] = '\r'; b[0] = '\r';
b[1] = '\n'; b[1] = '\n';
b += 2; b += 2;
i++; i++;
} }
else if (msg[i] == '\r') else if (source[i] == '\r' || source[i] == '\n')
{ {
b[0] = '\r'; b[0] = '\r';
b[1] = '\n'; b[1] = '\n';
b += 2; b += 2;
} }
else if (msg[i] == '\n') else if (source[0] == '^' && source[1] && source[1] != '^' && source[1] >= 48 && source[1] <= 64) // Q_IsColorString
{ {
b[0] = '\r'; i++;
b[1] = '\n';
b += 2;
} }
// else if (idStr::IsColor(&msg[i]))
//{
// i++;
//}
else else
{ {
*b = msg[i]; *b = source[i];
b++; b++;
} }
i++; i++;
} }
*b = '\0'; *b = '\0';
bufLen = static_cast<unsigned int>(b - s_wcd.cleanBuffer); return static_cast<unsigned int>(b - target);
s_totalChars += bufLen; }
if (s_totalChars <= 0x8000) void Conbuf_AppendText(const char* pmsg)
{
const char* msg;
unsigned int buf_len;
static unsigned int s_total_chars = 0;
if (s_wcd.hwndBuffer)
{
// if the message is REALLY long, use just the last portion of it
if (strlen(pmsg) > ((sizeof(s_wcd.cleanBuffer) / 2) - 1))
{
msg = pmsg + strlen(pmsg) - ((sizeof(s_wcd.cleanBuffer) / 2) + 1);
}
else
{
msg = pmsg;
}
// copy into an intermediate buffer
buf_len = Conbuf_CleanText(msg, s_wcd.cleanBuffer, sizeof(s_wcd.cleanBuffer));
s_total_chars += buf_len;
if (s_total_chars <= 0x8000)
{ {
SendMessageA(s_wcd.hwndBuffer, EM_SETSEL, 0xFFFF, 0xFFFF); SendMessageA(s_wcd.hwndBuffer, EM_SETSEL, 0xFFFF, 0xFFFF);
} }
else else
{ {
SendMessageA(s_wcd.hwndBuffer, EM_SETSEL, 0, -1); SendMessageA(s_wcd.hwndBuffer, EM_SETSEL, 0, -1);
s_totalChars = bufLen; s_total_chars = buf_len;
} }
SendMessageA(s_wcd.hwndBuffer, EM_LINESCROLL, 0, 0xFFFF); SendMessageA(s_wcd.hwndBuffer, EM_LINESCROLL, 0, 0xFFFF);
SendMessageA(s_wcd.hwndBuffer, EM_SCROLLCARET, 0, 0); SendMessageA(s_wcd.hwndBuffer, EM_SCROLLCARET, 0, 0);
SendMessageA(s_wcd.hwndBuffer, EM_REPLACESEL, 0, (LPARAM)s_wcd.cleanBuffer); SendMessageA(s_wcd.hwndBuffer, EM_REPLACESEL, 0, reinterpret_cast<LPARAM>(s_wcd.cleanBuffer));
} }
} }
@ -199,24 +189,21 @@ namespace console
} }
} }
LRESULT InputLineWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT InputLineWndProc(const HWND hwnd, const UINT umsg, const WPARAM wparam, const LPARAM lparam)
{ {
char dest[sizeof(s_wcd.consoleText) + 8]; char dest[sizeof(s_wcd.consoleText) + 8];
switch (uMsg) switch (umsg)
{ {
case WM_KILLFOCUS: case WM_KILLFOCUS:
if ((HWND)wParam != s_wcd.hWnd) if (reinterpret_cast<HWND>(wparam) == s_wcd.hWnd)
{ {
return CallWindowProcA(s_wcd.SysInputLineWndProc, hWnd, uMsg, wParam, lParam); SetFocus(hwnd);
}
SetFocus(hWnd);
return 0; return 0;
case WM_KEYDOWN: }
// todo: add history
break; break;
case WM_CHAR: case WM_CHAR:
auto key = wParam; auto key = wparam;
// enter the line // enter the line
if (key == VK_RETURN) if (key == VK_RETURN)
@ -232,8 +219,6 @@ namespace console
Sys_Print(dest); Sys_Print(dest);
game::Cbuf_AddText(0, s_wcd.consoleText); game::Cbuf_AddText(0, s_wcd.consoleText);
// todo: add history
} }
return 0; return 0;
@ -241,128 +226,166 @@ namespace console
break; break;
} }
return CallWindowProcA(s_wcd.SysInputLineWndProc, hWnd, uMsg, wParam, lParam); return CallWindowProcA(s_wcd.SysInputLineWndProc, hwnd, umsg, wparam, lparam);
} }
void Sys_CreateConsole(HINSTANCE hInstance) void Sys_CreateConsole(const HINSTANCE hinstance)
{ {
tagRECT Rect; RECT rect;
WNDCLASSA WndClass; WNDCLASSA wndclass;
HDC hdc;
int nheight;
int swidth, sheight;
DWORD DEDSTYLE = WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX;
memset(&Rect, 0, sizeof(Rect)); const char* class_name = "IW7-Mod WinConsole";
memset(&WndClass, 0, sizeof(WndClass)); const char* window_name = "IW7-Mod Console";
memset(&rect, 0, sizeof(rect));
memset(&wndclass, 0, sizeof(rect));
memset(&hdc, 0, sizeof(hdc));
memset(&s_wcd, 0, sizeof(s_wcd)); memset(&s_wcd, 0, sizeof(s_wcd));
WndClass.style = 0; wndclass.style = 0;
WndClass.cbClsExtra = 0; wndclass.cbClsExtra = 0;
WndClass.lpfnWndProc = ConWndProc; wndclass.cbWndExtra = 0;
WndClass.hInstance = hInstance; wndclass.lpfnWndProc = ConWndProc;
WndClass.hIcon = icon; wndclass.hInstance = hinstance;
WndClass.hbrBackground = CreateSolidBrush(RGB(50, 50, 50)); wndclass.hIcon = icon;
WndClass.hCursor = LoadCursorA(0, (LPCSTR)0x7F00); wndclass.hbrBackground = CreateSolidBrush(CONSOLE_BK_COLOR);
WndClass.lpszMenuName = NULL; wndclass.hCursor = LoadCursorA(0, IDC_ARROW);
WndClass.lpszClassName = ClassName; wndclass.lpszMenuName = nullptr;
if (RegisterClassA(&WndClass)) wndclass.lpszClassName = class_name;
if (!RegisterClassA(&wndclass))
{ {
Rect.top = 0; return;
Rect.left = 0; }
Rect.right = 620;
Rect.bottom = 430; rect.top = 0;
AdjustWindowRect(&Rect, 0x80CA0000, 0); rect.left = 0;
auto v4 = GetDesktopWindow(); rect.right = 620;
auto v5 = GetDC(v4); rect.bottom = 430;
auto v6 = GetDeviceCaps(v5, 8); AdjustWindowRect(&rect, DEDSTYLE, 0);
auto v7 = GetDeviceCaps(v5, 10);
auto v8 = GetDesktopWindow(); hdc = GetDC(GetDesktopWindow());
ReleaseDC(v8, v5); swidth = GetDeviceCaps(hdc, HORZRES);
s_wcd.windowHeight = Rect.bottom - Rect.top + 1; sheight = GetDeviceCaps(hdc, VERTRES);
s_wcd.windowWidth = Rect.right - Rect.left + 1; ReleaseDC(GetDesktopWindow(), hdc);
//s_wcd.consoleHistoryPos = 0;
auto v9 = CreateWindowExA( s_wcd.windowHeight = rect.bottom - rect.top + 1;
s_wcd.windowWidth = rect.right - rect.left + 1;
// create main window
s_wcd.hWnd = CreateWindowExA(
0, 0,
ClassName, class_name,
WindowName, window_name,
0x80CA0000, DEDSTYLE,
(v6 - 600) / 2, (swidth - 600) / 2,
(v7 - 450) / 2, (sheight - 450) / 2,
Rect.right - Rect.left + 1, rect.right - rect.left + 1,
Rect.bottom - Rect.top + 1, rect.bottom - rect.top + 1,
0, 0,
0, 0,
hInstance, hinstance,
0); nullptr);
s_wcd.hWnd = v9;
if (v9) if (!s_wcd.hWnd)
{ {
auto v10 = GetDC(v9); return;
auto v11 = GetDeviceCaps(v10, 90); }
auto v12 = MulDiv(8, v11, 72);
s_wcd.hfBufferFont = CreateFontA(-v12, 0, 0, 0, 300, 0, 0, 0, 1u, 0, 0, 0, 0x31u, "Courier New"); // create fonts
ReleaseDC(s_wcd.hWnd, v10); hdc = GetDC(s_wcd.hWnd);
auto v13 = logo; nheight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
if (v13) s_wcd.hfBufferFont = CreateFontA(
nheight,
0,
0,
0,
FW_LIGHT,
0,
0,
0,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
FF_MODERN | FIXED_PITCH,
"Courier New");
ReleaseDC(s_wcd.hWnd, hdc);
// create logo
if (logo)
{ {
s_wcd.codLogo = CreateWindowExA( s_wcd.codLogo = CreateWindowExA(
0, 0,
"Static", "Static",
0, 0,
0x5000000Eu, WS_CHILDWINDOW | WS_VISIBLE | 0xE,
5, 5,
5, 5,
0, 0,
0, 0,
s_wcd.hWnd, s_wcd.hWnd,
(HMENU)1, reinterpret_cast<HMENU>(1),
hInstance, hinstance,
0); nullptr);
SendMessageA(s_wcd.codLogo, 0x172u, 0, (LPARAM)v13); SendMessageA(s_wcd.codLogo, 0x172u, 0, reinterpret_cast<LPARAM>(logo));
} }
// create the input line
s_wcd.hwndInputLine = CreateWindowExA( s_wcd.hwndInputLine = CreateWindowExA(
0, 0,
"edit", "edit",
0, 0,
0x50800080u, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOHSCROLL,
6, 6,
400, 400,
608, 608,
20, 20,
s_wcd.hWnd, s_wcd.hWnd,
(HMENU)0x65, reinterpret_cast<HMENU>(0x65),
hInstance, hinstance,
0); 0);
// create the scrollbuffer
s_wcd.hwndBuffer = CreateWindowExA( s_wcd.hwndBuffer = CreateWindowExA(
0, 0,
"edit", "edit",
0, 0,
0x50A00844u, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY,
6, 6,
70, 70,
606, 608,
324, 324,
s_wcd.hWnd, s_wcd.hWnd,
(HMENU)0x64, reinterpret_cast<HMENU>(0x64),
hInstance, hinstance,
0); 0);
SendMessageA(s_wcd.hwndBuffer, 0x30u, (WPARAM)s_wcd.hfBufferFont, 0);
SendMessageA(s_wcd.hwndBuffer, WM_SETFONT, reinterpret_cast<WPARAM>(s_wcd.hfBufferFont), 0);
SendMessageA(s_wcd.hwndBuffer, 0xC5u, 0x8000u, 0); SendMessageA(s_wcd.hwndBuffer, 0xC5u, 0x8000u, 0);
s_wcd.SysInputLineWndProc = (WNDPROC)SetWindowLongPtrA(s_wcd.hwndInputLine, -4, (LONG_PTR)InputLineWndProc); s_wcd.SysInputLineWndProc = reinterpret_cast<WNDPROC>(SetWindowLongPtrA(s_wcd.hwndInputLine, -4,
SendMessageA(s_wcd.hwndInputLine, 0x30u, (WPARAM)s_wcd.hfBufferFont, 0); reinterpret_cast<LONG_PTR>(InputLineWndProc)));
SendMessageA(s_wcd.hwndInputLine, WM_SETFONT, reinterpret_cast<WPARAM>(s_wcd.hfBufferFont), 0);
SetFocus(s_wcd.hwndInputLine); SetFocus(s_wcd.hwndInputLine);
//s_wcd.buffer[0] = 0;
//s_wcd.cleanBuffer[0] = 0;
SetWindowTextA(s_wcd.hwndBuffer, s_wcd.cleanBuffer); SetWindowTextA(s_wcd.hwndBuffer, s_wcd.cleanBuffer);
//s_wcd.bufferLen = 0;
InitializeCriticalSection(&s_wcd.critSect); InitializeCriticalSection(&s_wcd.critSect);
} }
}
}
void Sys_ShowConsole() void Sys_ShowConsole()
{ {
if (!console::is_enabled())
{
return;
}
if (!s_wcd.hWnd) if (!s_wcd.hWnd)
{ {
Sys_CreateConsole(GetModuleHandleA((LPCSTR)s_wcd.hWnd)); Sys_CreateConsole(GetModuleHandleA(reinterpret_cast<LPCSTR>(s_wcd.hWnd)));
} }
if (s_wcd.hWnd) if (s_wcd.hWnd)
{ {
@ -370,6 +393,18 @@ namespace console
SendMessageA(s_wcd.hwndBuffer, EM_LINESCROLL, 0, 0xFFFF); SendMessageA(s_wcd.hwndBuffer, EM_LINESCROLL, 0, 0xFFFF);
} }
} }
void Sys_DestroyConsole()
{
if (s_wcd.hWnd)
{
ShowWindow(s_wcd.hWnd, SW_HIDE);
CloseWindow(s_wcd.hWnd);
DestroyWindow(s_wcd.hWnd);
s_wcd.hWnd = nullptr;
DeleteCriticalSection(&s_wcd.critSect);
}
}
} }
std::string format(va_list* ap, const char* message) std::string format(va_list* ap, const char* message)
@ -392,7 +427,7 @@ namespace console
} }
else else
{ {
sys::Sys_Print(message.data()); syscon::Sys_Print(message.data());
} }
} }
@ -416,7 +451,9 @@ namespace console
{ {
if (!console::is_enabled() || native::is_enabled()) return; if (!console::is_enabled() || native::is_enabled()) return;
//hide_console(); const utils::nt::library self;
syscon::icon = LoadIconA(self.get_handle(), MAKEINTRESOURCEA(ID_ICON));
syscon::logo = LoadImageA(self.get_handle(), MAKEINTRESOURCEA(IMAGE_LOGO), 0, 0, 0, LR_COPYFROMRESOURCE);
(void)_pipe(this->handles_, 1024, _O_TEXT); (void)_pipe(this->handles_, 1024, _O_TEXT);
(void)_dup2(this->handles_[1], 1); (void)_dup2(this->handles_[1], 1);
@ -426,12 +463,12 @@ namespace console
//setvbuf(stderr, nullptr, _IONBF, 0); //setvbuf(stderr, nullptr, _IONBF, 0);
} }
~component() override ~component()
{ {
if (!console::is_enabled() || native::is_enabled()) return; if (!console::is_enabled() || native::is_enabled()) return;
if (sys::icon) DestroyIcon(sys::icon); if (syscon::icon) DestroyIcon(syscon::icon);
if (sys::logo) DeleteObject(sys::logo); if (syscon::logo) DeleteObject(syscon::logo);
} }
void post_start() override void post_start() override
@ -440,16 +477,13 @@ namespace console
{ {
if (native::is_enabled()) if (native::is_enabled())
{ {
CreateThread(0, 0, native::console, 0, 0, 0); const auto handle = CreateThread(0, 0, native::console, 0, 0, 0);
utils::thread::set_name(handle, "Console");
} }
else else
{ {
const utils::nt::library self;
sys::icon = LoadIconA(self.get_handle(), MAKEINTRESOURCEA(ID_ICON));
sys::logo = LoadImageA(self.get_handle(), MAKEINTRESOURCEA(IMAGE_LOGO), 0, 0, 0, LR_COPYFROMRESOURCE);
this->terminate_runner_ = false; this->terminate_runner_ = false;
this->console_runner_ = utils::thread::create_named_thread("Console IO", [this] this->console_runner_ = utils::thread::create_named_thread("Console IO", [this]()
{ {
this->runner(); this->runner();
}); });
@ -483,28 +517,7 @@ namespace console
} }
else else
{ {
this->terminate_runner_ = true; this->destroy();
printf("\r\n");
_flushall();
if (this->console_runner_.joinable())
{
this->console_runner_.join();
}
if (this->console_thread_.joinable())
{
this->console_thread_.join();
}
_close(this->handles_[0]);
_close(this->handles_[1]);
messages.access([&](message_queue& msgs)
{
msgs = {};
});
} }
} }
} }
@ -526,12 +539,12 @@ namespace console
{ {
this->console_thread_ = utils::thread::create_named_thread("Console", [this]() this->console_thread_ = utils::thread::create_named_thread("Console", [this]()
{ {
sys::Sys_ShowConsole(); syscon::Sys_ShowConsole();
if (!game::environment::is_dedi()) if (!game::environment::is_dedi())
{ {
// Hide that shit // Hide that shit
ShowWindow(console::get_window(), SW_MINIMIZE); ShowWindow(syscon::s_wcd.hWnd, SW_MINIMIZE);
} }
{ {
@ -546,12 +559,6 @@ namespace console
{ {
if (PeekMessageA(&msg, nullptr, NULL, NULL, PM_REMOVE)) if (PeekMessageA(&msg, nullptr, NULL, NULL, PM_REMOVE))
{ {
if (msg.message == WM_QUIT)
{
game::Cbuf_AddText(0, "quit");
break;
}
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
} }
@ -564,6 +571,34 @@ namespace console
}); });
} }
void destroy()
{
syscon::Sys_DestroyConsole();
this->terminate_runner_ = true;
printf("\r\n");
_flushall();
if (this->console_runner_.joinable())
{
this->console_runner_.join();
}
if (this->console_thread_.joinable())
{
this->console_thread_.join();
}
_close(this->handles_[0]);
_close(this->handles_[1]);
messages.access([&](message_queue& msgs)
{
msgs = {};
});
}
void log_messages() void log_messages()
{ {
/*while*/ /*while*/
@ -593,7 +628,7 @@ namespace console
static void log_message(const std::string& message) static void log_message(const std::string& message)
{ {
OutputDebugStringA(message.data()); OutputDebugStringA(message.data());
sys::Conbuf_AppendText(message.data()); syscon::Conbuf_AppendText(message.data());
} }
void runner() void runner()
@ -617,25 +652,19 @@ namespace console
} }
}; };
HWND get_window()
{
return sys::s_wcd.hWnd;
}
void set_title(std::string title) void set_title(std::string title)
{ {
SetWindowTextA(get_window(), title.data()); if (console::is_enabled())
}
void set_size(const int width, const int height)
{ {
RECT rect; if (native::is_enabled())
GetWindowRect(get_window(), &rect); {
SetConsoleTitleA(title.data());
SetWindowPos(get_window(), nullptr, rect.left, rect.top, width, height, 0); }
else if (syscon::s_wcd.hWnd)
auto* const logo_window = sys::s_wcd.codLogo; {
SetWindowPos(logo_window, nullptr, 5, 5, width - 25, 60, 0); SetWindowTextA(syscon::s_wcd.hWnd, title.data());
}
}
} }
} }

View File

@ -8,9 +8,7 @@ namespace console
bool is_enabled(); bool is_enabled();
} }
HWND get_window();
void set_title(std::string title); void set_title(std::string title);
void set_size(int width, int height);
enum console_type enum console_type
{ {

View File

@ -30,7 +30,7 @@ namespace resources
class component final : public component_interface class component final : public component_interface
{ {
public: public:
~component() override ~component()
{ {
if (icon) DestroyIcon(icon); if (icon) DestroyIcon(icon);
if (splash) DeleteObject(splash); if (splash) DeleteObject(splash);

View File

@ -140,7 +140,8 @@ namespace game
{ {
bool is_dedi() bool is_dedi()
{ {
return utils::flags::has_flag("dedicated"); static const auto dedicated = utils::flags::has_flag("dedicated");
return dedicated;
} }
} }
} }

View File

@ -20,7 +20,7 @@ namespace game
T* get() const T* get() const
{ {
return reinterpret_cast<T*>((uint64_t)address_ + base_address); return reinterpret_cast<T*>(reinterpret_cast<uint64_t>(address_) + base_address);
} }
operator T* () const operator T* () const