diff --git a/engine.d b/engine.d index 83fbf4c..11d86fa 100644 --- a/engine.d +++ b/engine.d @@ -152,21 +152,21 @@ Callable[] objs; up2 = 17, down2 = 18, left2 = 19, right2 = 20}; // right stick const int NUM_BUTTONS = 21; class Engine{ - const int NoVideo = 0; - const int Video1024x768 = 1; - const int Video640x480 = 2; - const int Video800x600 = 3; - const int Video320x200 = 4; - const int Video512x512 = 5; + static const int NoVideo = 0; + static const int Video1024x768 = 1; + static const int Video640x480 = 2; + static const int Video800x600 = 3; + static const int Video320x200 = 4; + static const int Video512x512 = 5; - const int VideoFullScreen = 32; + static const int VideoFullScreen = 32; alias int Direction; alias int Buttons; - const int MAX_NET = 8; - const int NET_PORT = 7777; + static const int MAX_NET = 8; + static const int NET_PORT = 7777; // For being a network server..... bool isServer; @@ -856,30 +856,30 @@ class Engine{ bool wantToQuit; - bool buttonsDown[NUM_BUTTONS][16]; - bool buttonsChecked[NUM_BUTTONS][16]; + bool[NUM_BUTTONS][16] buttonsDown; + bool[NUM_BUTTONS][16] buttonsChecked; const int LAG_QUEUE_SIZE = 10; // This lag is used for network games. It sends you old data until the lag time is up, // to try and keep all the players synchronized. - int buttonLagRemaining[NUM_BUTTONS][16][LAG_QUEUE_SIZE]; + int[NUM_BUTTONS][16][LAG_QUEUE_SIZE] buttonLagRemaining; // This way we can queue up activities happening while the lag is waiting - int buttonLagQueueStart[NUM_BUTTONS][16]; - int buttonLagQueueEnd[NUM_BUTTONS][16]; - int buttonLagQueueLength[NUM_BUTTONS][16]; + int[NUM_BUTTONS][16] buttonLagQueueStart; + int[NUM_BUTTONS][16] buttonLagQueueEnd; + int[NUM_BUTTONS][16] buttonLagQueueLength; // These store what the state was before the lag began; it is what is returned while // waiting on the lag to complete - bool lagbuttonsDown[NUM_BUTTONS][16][LAG_QUEUE_SIZE]; + bool[NUM_BUTTONS][16][LAG_QUEUE_SIZE] lagbuttonsDown; - int stickX[3][16]; - int stickY[3][16]; + int[3][16] stickX; + int[3][16] stickY; - bool mouseButtonsDown[8]; - bool mouseButtonsChecked[8]; + bool[8] mouseButtonsDown; + bool[8] mouseButtonsChecked; const int LEFT = SDL_BUTTON_LEFT;//1; const int MIDDLE = SDL_BUTTON_MIDDLE;//2; const int RIGHT = SDL_BUTTON_RIGHT;//3; diff --git a/htmlwidget.d b/htmlwidget.d index 1923624..8280fad 100644 --- a/htmlwidget.d +++ b/htmlwidget.d @@ -1032,7 +1032,7 @@ void addEventListener(string event, Element what, EventHandler handler, bool bub l.capturingEventHandlers[event] ~= handler; } -void addEventListener(string event, Element what[], EventHandler handler, bool bubble = true) { +void addEventListener(string event, Element[] what, EventHandler handler, bool bubble = true) { foreach(w; what) addEventListener(event, w, handler, bubble); } diff --git a/joystick.d b/joystick.d index 3d6d1f0..efd86ad 100644 --- a/joystick.d +++ b/joystick.d @@ -498,7 +498,7 @@ struct JoystickUpdate { final switch(axis) { case PS1AnalogAxes.horizontalDpad: case PS1AnalogAxes.horizontalLeftStick: - short got = (what.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) ? -digitalFallbackValue : + short got = (what.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) ? cast(short)-cast(int)digitalFallbackValue : (what.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) ? digitalFallbackValue : 0; if(got == 0) @@ -508,10 +508,10 @@ struct JoystickUpdate { case PS1AnalogAxes.verticalDpad: case PS1AnalogAxes.verticalLeftStick: short got = (what.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) ? digitalFallbackValue : - (what.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) ? -digitalFallbackValue : + (what.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) ? cast(short)-cast(int)digitalFallbackValue : what.Gamepad.sThumbLY; - return normalizeAxis(-got); + return normalizeAxis(cast(short)-cast(int)got); case PS1AnalogAxes.horizontalRightStick: return normalizeAxis(what.Gamepad.sThumbRX); case PS1AnalogAxes.verticalRightStick: diff --git a/rtud.d b/rtud.d index 214d5ba..df79f7a 100644 --- a/rtud.d +++ b/rtud.d @@ -90,8 +90,13 @@ class UpdateStream { if("close-time" in message) +/ -static import linux = std.c.linux.linux; -static import sock = std.c.linux.socket; +version(D_Version2) { + static import linux = core.sys.posix.unistd; + static import sock = core.sys.posix.sys.socket; +} else { + static import linux = std.c.linux.linux; + static import sock = std.c.linux.socket; +} int openNetworkFd(string host, ushort port) { import std.exception; diff --git a/screen.d b/screen.d index 2bb262c..359a67b 100644 --- a/screen.d +++ b/screen.d @@ -12,8 +12,12 @@ import std.format; import arsd.engine; -static import std.c.string; +version(D_Version2) +static import stdcstring = core.stdc.string; +else +static import stdcstring = std.c.string; +version(none) char[] fmt(...){ char[] o; void putc(dchar c) @@ -278,8 +282,8 @@ class FontEngine{ } - TTF_Font* fonts[8]; - Image[char[]] cache[8]; + TTF_Font*[8] fonts; + Image[char[]][8] cache; } interface Drawable{ @@ -468,7 +472,7 @@ class Image : Drawable{ if(t) return tex; else{ - float f[4]; + float[4] f; tex = SDL_GL_LoadTexture(surface, f.ptr); t = true; total++; @@ -618,7 +622,7 @@ class Screen : Drawable{ // FIXME: this crashes on Windows for(int i = 0; i < yr; i++) - std.c.string.memcpy(temp.sur.pixels + 4 * xr * i, image.sur.pixels + 4 * xr * (yr-1 - i), 4 * xr); + stdcstring.memcpy(temp.sur.pixels + 4 * xr * i, image.sur.pixels + 4 * xr * (yr-1 - i), 4 * xr); // memcpy(image.sur.pixels, tem.psur.pixels, xres * yres * 4); return temp; @@ -929,6 +933,24 @@ scope class Painter{ } } + version(D_Version2) { + import std.format; + void drawTextf(T...)(Point where, T args) { + char[] t; + t.length = 80; + int a = 0; + void putc(dchar c){ + if(a == t.length) + t.length = t.length + 80; + t[a] = cast(char) c; + a++; + } + formattedWrite(&putc, args); + t.length = a; + + drawText(where, t); + } + } else void drawTextf(Point where, ...){ char[] t; t.length = 80; diff --git a/sslsocket.d b/sslsocket.d index 166f107..a378705 100644 --- a/sslsocket.d +++ b/sslsocket.d @@ -81,7 +81,7 @@ version(use_openssl) { ssl = SSL_new(ctx); if(!verifyPeer) SSL_set_verify(ssl, SSL_VERIFY_NONE, null); - SSL_set_fd(ssl, this.handle); + SSL_set_fd(ssl, cast(int) this.handle); } bool dataPending() { diff --git a/stb_truetype.d b/stb_truetype.d index 2638ecc..e3ff494 100644 --- a/stb_truetype.d +++ b/stb_truetype.d @@ -722,7 +722,7 @@ int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_verte flags = vertices[off+i].type; if (flags & 2) { stbtt_int16 dx = *points++; - x += (flags & 16) ? dx : -dx; // ??? + x += (flags & 16) ? dx : -cast(int)dx; // ??? } else { if (!(flags & 16)) { x = x + cast(stbtt_int16) (points[0]*256 + points[1]); @@ -738,7 +738,7 @@ int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_verte flags = vertices[off+i].type; if (flags & 4) { stbtt_int16 dy = *points++; - y += (flags & 32) ? dy : -dy; // ??? + y += (flags & 32) ? dy : -cast(int)dy; // ??? } else { if (!(flags & 32)) { y = y + cast(stbtt_int16) (points[0]*256 + points[1]);