src/SDL_assert.c
changeset 5086 c2539ff054c8
parent 5064 eae20af0b983
child 5090 327f181542f1
     1.1 --- a/src/SDL_assert.c	Mon Jan 24 15:10:16 2011 -0800
     1.2 +++ b/src/SDL_assert.c	Mon Jan 24 15:46:11 2011 -0800
     1.3 @@ -26,9 +26,19 @@
     1.4  #include "SDL_assert_c.h"
     1.5  #include "video/SDL_sysvideo.h"
     1.6  
     1.7 -#ifdef __WINDOWS__
     1.8 +#ifdef __WIN32__
     1.9  #define WIN32_LEAN_AND_MEAN
    1.10  #include <windows.h>
    1.11 +
    1.12 +#ifndef WS_OVERLAPPEDWINDOW
    1.13 +#define WS_OVERLAPPEDWINDOW 0
    1.14 +#endif
    1.15 +
    1.16 +#ifdef UNICODE
    1.17 +#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)S, SDL_strlen(S)+1)
    1.18 +#else
    1.19 +#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1)
    1.20 +#endif
    1.21  #else  /* fprintf, _exit(), etc. */
    1.22  #include <stdio.h>
    1.23  #include <stdlib.h>
    1.24 @@ -57,11 +67,12 @@
    1.25  static void
    1.26  debug_print(const char *fmt, ...)
    1.27  {
    1.28 -#ifdef __WINDOWS__
    1.29 +#ifdef __WIN32__
    1.30      /* Format into a buffer for OutputDebugStringA(). */
    1.31      char buf[1024];
    1.32      char *startptr;
    1.33      char *ptr;
    1.34 +    LPTSTR tstr;
    1.35      int len;
    1.36      va_list ap;
    1.37      va_start(ap, fmt);
    1.38 @@ -78,15 +89,19 @@
    1.39      for (ptr = startptr; *ptr; ptr++) {
    1.40          if (*ptr == '\n') {
    1.41              *ptr = '\0';
    1.42 -            OutputDebugStringA(startptr);
    1.43 -            OutputDebugStringA("\r\n");
    1.44 +            tstr = WIN_UTF8ToString(startptr);
    1.45 +            OutputDebugString(tstr);
    1.46 +            SDL_free(tstr);
    1.47 +            OutputDebugString(TEXT("\r\n"));
    1.48              startptr = ptr+1;
    1.49          }
    1.50      }
    1.51  
    1.52      /* catch that last piece if it didn't have a newline... */
    1.53      if (startptr != ptr) {
    1.54 -        OutputDebugStringA(startptr);
    1.55 +        tstr = WIN_UTF8ToString(startptr);
    1.56 +        OutputDebugString(tstr);
    1.57 +        SDL_free(tstr);
    1.58      }
    1.59  #else
    1.60      /* Unix has it easy. Just dump it to stderr. */
    1.61 @@ -99,7 +114,7 @@
    1.62  }
    1.63  
    1.64  
    1.65 -#ifdef __WINDOWS__
    1.66 +#ifdef __WIN32__
    1.67  static SDL_assert_state SDL_Windows_AssertChoice = SDL_ASSERTION_ABORT;
    1.68  static const SDL_assert_data *SDL_Windows_AssertData = NULL;
    1.69  
    1.70 @@ -113,6 +128,7 @@
    1.71              /* !!! FIXME: all this code stinks. */
    1.72              const SDL_assert_data *data = SDL_Windows_AssertData;
    1.73              char buf[1024];
    1.74 +            LPTSTR tstr;
    1.75              const int w = 100;
    1.76              const int h = 25;
    1.77              const int gap = 10;
    1.78 @@ -121,14 +137,14 @@
    1.79              int len;
    1.80              int i;
    1.81              static const struct { 
    1.82 -                const char *name;
    1.83 +                LPCTSTR name;
    1.84                  SDL_assert_state state;
    1.85              } buttons[] = {
    1.86 -                {"Abort", SDL_ASSERTION_ABORT },
    1.87 -                {"Break", SDL_ASSERTION_BREAK },
    1.88 -                {"Retry", SDL_ASSERTION_RETRY },
    1.89 -                {"Ignore", SDL_ASSERTION_IGNORE },
    1.90 -                {"Always Ignore", SDL_ASSERTION_ALWAYS_IGNORE },
    1.91 +                {TEXT("Abort"), SDL_ASSERTION_ABORT },
    1.92 +                {TEXT("Break"), SDL_ASSERTION_BREAK },
    1.93 +                {TEXT("Retry"), SDL_ASSERTION_RETRY },
    1.94 +                {TEXT("Ignore"), SDL_ASSERTION_IGNORE },
    1.95 +                {TEXT("Always Ignore"), SDL_ASSERTION_ALWAYS_IGNORE },
    1.96              };
    1.97  
    1.98              len = (int) SDL_snprintf(buf, sizeof (buf), 
    1.99 @@ -140,14 +156,16 @@
   1.100                  buf[sizeof (buf) - 1] = '\0';
   1.101              }
   1.102  
   1.103 -            CreateWindowA("STATIC", buf,
   1.104 +            tstr = WIN_UTF8ToString(buf);
   1.105 +            CreateWindow(TEXT("STATIC"), tstr,
   1.106                           WS_VISIBLE | WS_CHILD | SS_LEFT,
   1.107                           x, y, 550, 100,
   1.108                           hwnd, (HMENU) 1, NULL, NULL);
   1.109 +            SDL_free(tstr);
   1.110              y += 110;
   1.111  
   1.112              for (i = 0; i < (sizeof (buttons) / sizeof (buttons[0])); i++) {
   1.113 -                CreateWindowA("BUTTON", buttons[i].name,
   1.114 +                CreateWindow(TEXT("BUTTON"), buttons[i].name,
   1.115                           WS_VISIBLE | WS_CHILD,
   1.116                           x, y, w, h,
   1.117                           hwnd, (HMENU) buttons[i].state, NULL, NULL);
   1.118 @@ -248,7 +266,7 @@
   1.119  
   1.120  static void SDL_ExitProcess(int exitcode)
   1.121  {
   1.122 -#ifdef __WINDOWS__
   1.123 +#ifdef __WIN32__
   1.124      ExitProcess(42);
   1.125  #else
   1.126      _exit(42);
   1.127 @@ -311,7 +329,7 @@
   1.128  
   1.129      /* platform-specific UI... */
   1.130  
   1.131 -#ifdef __WINDOWS__
   1.132 +#ifdef __WIN32__
   1.133      state = SDL_PromptAssertion_windows(data);
   1.134  
   1.135  #elif __MACOSX__