summaryrefslogtreecommitdiffstats
path: root/Samples/OculusRoomTiny/MessageBox.cpp
blob: be3d1361b3c16439dfe621727dba049776b5b666 (plain)
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
#include "MessageBox.h"
#ifdef WIN32
#include <Windows.h>
#endif

#ifdef __APPLE__
#include <CoreFoundation/CoreFoundation.h>
#endif


MessageBoxResult MessageBox(const char * text) {
#ifdef WIN32
        int result = ::MessageBoxA(0, text, "Oculus Rift Detection",
                        MB_CANCELTRYCONTINUE|MB_ICONWARNING);
        switch (result) {
        case IDCANCEL:
            return Cancel;
        case IDCONTINUE:
            return Continue;
        case IDRETRY:
            return Retry;
        }
#endif
    
#ifdef __APPLE__
    CFStringRef headerStrRef  = CFStringCreateWithCString(NULL, "Oculus Rift Detection", kCFStringEncodingMacRoman);
    CFStringRef messageStrRef = CFStringCreateWithCString(NULL, text, kCFStringEncodingMacRoman);
    CFOptionFlags result;
    
//    kCFUserNotificationDefaultResponse = 0,
//    kCFUserNotificationAlternateResponse = 1,
//    kCFUserNotificationOtherResponse = 2,
//    kCFUserNotificationCancelResponse = 3
    
    //launch the message box
    CFUserNotificationDisplayAlert(0,
                                   kCFUserNotificationNoteAlertLevel,
                                   NULL, NULL, NULL,
                                   headerStrRef, // header text
                                   messageStrRef, // message text
                                   CFSTR("Try again"),
                                   CFSTR("Continue"),
                                   CFSTR("Cancel"),
                                   &result);

    //Clean up the strings
    CFRelease(headerStrRef);
    CFRelease(messageStrRef);

    switch (result) {
        case kCFUserNotificationCancelResponse:
        case kCFUserNotificationOtherResponse:
            return Cancel;
        case kCFUserNotificationDefaultResponse:
            return Retry;
        case kCFUserNotificationAlternateResponse:
            return Continue;
    }
#endif
    return Continue;
}