mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-26 22:01:26 +00:00
Added native UI dialog to confirm stats collection
This commit is contained in:
parent
102d2647d3
commit
832fc42e07
2 changed files with 69 additions and 0 deletions
|
@ -2352,6 +2352,9 @@ void D_DoomMain (void)
|
||||||
|
|
||||||
D_DoomInit();
|
D_DoomInit();
|
||||||
|
|
||||||
|
extern void D_ConfirmSendStats();
|
||||||
|
D_ConfirmSendStats();
|
||||||
|
|
||||||
// [RH] Make sure zdoom.pk3 is always loaded,
|
// [RH] Make sure zdoom.pk3 is always loaded,
|
||||||
// as it contains magic stuff we need.
|
// as it contains magic stuff we need.
|
||||||
wad = BaseFileSearch (BASEWAD, NULL, true);
|
wad = BaseFileSearch (BASEWAD, NULL, true);
|
||||||
|
|
|
@ -5,6 +5,10 @@ void D_DoAnonStats()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void D_ConfirmSendStats()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#else // !NO_SEND_STATS
|
#else // !NO_SEND_STATS
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
@ -14,6 +18,11 @@ void D_DoAnonStats()
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
extern int sys_ostype;
|
extern int sys_ostype;
|
||||||
#else
|
#else
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
#else // !__APPLE__
|
||||||
|
#include <SDL.h>
|
||||||
|
#endif // __APPLE__
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
@ -29,6 +38,7 @@ extern int sys_ostype;
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, vid_glswfb)
|
EXTERN_CVAR(Bool, vid_glswfb)
|
||||||
extern int currentrenderer;
|
extern int currentrenderer;
|
||||||
|
CVAR(Int, sys_statsenabled, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOSET)
|
||||||
CVAR(String, sys_statshost, "gzstats.drdteam.org", CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOSET)
|
CVAR(String, sys_statshost, "gzstats.drdteam.org", CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOSET)
|
||||||
CVAR(Int, sys_statsport, 80, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOSET)
|
CVAR(Int, sys_statsport, 80, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOSET)
|
||||||
|
|
||||||
|
@ -275,6 +285,11 @@ static void D_DoHTTPRequest(const char *request)
|
||||||
|
|
||||||
void D_DoAnonStats()
|
void D_DoAnonStats()
|
||||||
{
|
{
|
||||||
|
if (sys_statsenabled != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static bool done = false; // do this only once per session.
|
static bool done = false; // do this only once per session.
|
||||||
if (done) return;
|
if (done) return;
|
||||||
done = true;
|
done = true;
|
||||||
|
@ -291,4 +306,55 @@ void D_DoAnonStats()
|
||||||
t1.detach();
|
t1.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void D_ConfirmSendStats()
|
||||||
|
{
|
||||||
|
if (sys_statsenabled >= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: texts
|
||||||
|
static const char *const MESSAGE_TEXT = "send stats?";
|
||||||
|
static const char *const TITLE_TEXT = GAMENAME;
|
||||||
|
|
||||||
|
UCVarValue enabled = { 0 };
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
extern HWND Window;
|
||||||
|
enabled.Int = MessageBox(Window, MESSAGE_TEXT, TITLE_TEXT, MB_ICONQUESTION | MB_YESNO) == IDYES;
|
||||||
|
#elif defined __APPLE__
|
||||||
|
const CFStringRef messageString = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, MESSAGE_TEXT, kCFStringEncodingASCII, kCFAllocatorNull);
|
||||||
|
const CFStringRef titleString = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, TITLE_TEXT, kCFStringEncodingASCII, kCFAllocatorNull);
|
||||||
|
if (messageString != nullptr && titleString != nullptr)
|
||||||
|
{
|
||||||
|
CFOptionFlags response;
|
||||||
|
const SInt32 result = CFUserNotificationDisplayAlert(0, kCFUserNotificationNoteAlertLevel, nullptr, nullptr, nullptr,
|
||||||
|
titleString, messageString, CFSTR("Yes"), CFSTR("No"), nullptr, &response);
|
||||||
|
enabled.Int = result == 0 && (response & 3) == kCFUserNotificationDefaultResponse;
|
||||||
|
CFRelease(titleString);
|
||||||
|
CFRelease(messageString);
|
||||||
|
}
|
||||||
|
#else // !__APPLE__
|
||||||
|
const SDL_MessageBoxButtonData buttons[] =
|
||||||
|
{
|
||||||
|
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, "Yes" },
|
||||||
|
{ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 1, "No" },
|
||||||
|
};
|
||||||
|
const SDL_MessageBoxData messageboxdata =
|
||||||
|
{
|
||||||
|
SDL_MESSAGEBOX_INFORMATION,
|
||||||
|
nullptr,
|
||||||
|
TITLE_TEXT,
|
||||||
|
MESSAGE_TEXT,
|
||||||
|
SDL_arraysize(buttons),
|
||||||
|
buttons,
|
||||||
|
nullptr
|
||||||
|
};
|
||||||
|
int buttonid;
|
||||||
|
enabled.Int = SDL_ShowMessageBox(&messageboxdata, &buttonid) == 0 && buttonid == 0;
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
|
sys_statsenabled.ForceSet(enabled, CVAR_Int);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // NO_SEND_STATS
|
#endif // NO_SEND_STATS
|
||||||
|
|
Loading…
Reference in a new issue