New messagebox system

This commit is contained in:
mkrsym1
2023-06-08 21:44:42 +03:00
parent 38dbf82f7f
commit 8662c84a0a
10 changed files with 64 additions and 47 deletions

37
game_payload/src/msg.c Normal file
View File

@ -0,0 +1,37 @@
#include <windows.h>
#include <stdio.h>
#include <msg.h>
#define DEF_MSG_FN(name, type, printfn, mbfn, projname, flags, suffix) \
void name(const type *format, ...) { \
va_list args; \
va_start(args, format); \
\
int count = printfn(NULL, 0, format, args) + 1; \
\
type *buf = malloc(count * sizeof(type)); \
printfn(buf, count, format, args); \
\
mbfn(NULL, buf, projname, flags); \
\
va_end(args); \
\
free(buf); \
suffix; \
}
const char *TITLE_A = "Jadeite Autopatcher";
const wchar_t *TITLE_W = L"Jadeite Autopatcher";
// Error
DEF_MSG_FN(msg_err_a, char, _vsnprintf, MessageBoxA, TITLE_A, MB_OK | MB_ICONERROR, exit(1))
DEF_MSG_FN(msg_err_w, wchar_t, _vsnwprintf, MessageBoxW, TITLE_W, MB_OK | MB_ICONERROR, exit(1))
// Warn
DEF_MSG_FN(msg_warn_a, char, _vsnprintf, MessageBoxA, TITLE_A, MB_OK | MB_ICONEXCLAMATION,)
DEF_MSG_FN(msg_warn_w, wchar_t, _vsnwprintf, MessageBoxW, TITLE_W, MB_OK | MB_ICONEXCLAMATION,)
// Info
DEF_MSG_FN(msg_info_a, char, _vsnprintf, MessageBoxA, TITLE_A, MB_OK | MB_ICONINFORMATION,)
DEF_MSG_FN(msg_info_w, wchar_t, _vsnwprintf, MessageBoxW, TITLE_W, MB_OK | MB_ICONINFORMATION,)