diff --git a/DSFML/import/dsfml/graphics/drawableimpl.d b/DSFML/import/dsfml/graphics/drawableimpl.d index 72ea06069..6701f43ab 100644 --- a/DSFML/import/dsfml/graphics/drawableimpl.d +++ b/DSFML/import/dsfml/graphics/drawableimpl.d @@ -41,7 +41,7 @@ import dsfml.graphics.idrawable, * Package base class of all drawable. * Provide implementation of IDrawable and functions aliases. */ -package class Drawableimpl(alias symbol) : DSFMLObject, IDrawable +package class DrawableImpl(alias symbol) : DSFMLObject, IDrawable { protected: this() diff --git a/DSFML/import/dsfml/graphics/renderwindow.d b/DSFML/import/dsfml/graphics/renderwindow.d index 8869c6c82..4f108d0bb 100644 --- a/DSFML/import/dsfml/graphics/renderwindow.d +++ b/DSFML/import/dsfml/graphics/renderwindow.d @@ -66,7 +66,7 @@ public: * windowStyle = Window style (Resize | Close by default) * settings = Context settings (default is default ContextSettings values) */ - this(VideoMode mode, string title, uint windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings()) + this(VideoMode mode, string title, uint windowStyle = Style.Default, ContextSettings settings = ContextSettings()) { super(sfRenderWindow_Create(mode, toStringz(title), windowStyle, &settings)); m_input = new Input(sfRenderWindow_GetInput(m_ptr)); @@ -102,7 +102,7 @@ public: * settings = Context settings (default is default ContextSettings values) * */ - void create(VideoMode mode, string title, uint windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings()) + void create(VideoMode mode, string title, uint windowStyle = Style.Default, ContextSettings settings = ContextSettings()) { if (m_ptr !is null) dispose(); diff --git a/DSFML/import/dsfml/graphics/shape.d b/DSFML/import/dsfml/graphics/shape.d index 958e828c6..972e0e361 100644 --- a/DSFML/import/dsfml/graphics/shape.d +++ b/DSFML/import/dsfml/graphics/shape.d @@ -37,7 +37,7 @@ import dsfml.graphics.drawableimpl; * helper functions to draw simple shapes like * lines, rectangles, circles, etc. */ -class Shape : Drawableimpl!("sfShape") +class Shape : DrawableImpl!("sfShape") { private: this (void* ptr) diff --git a/DSFML/import/dsfml/graphics/sprite.d b/DSFML/import/dsfml/graphics/sprite.d index 5c189223d..fb17ac602 100644 --- a/DSFML/import/dsfml/graphics/sprite.d +++ b/DSFML/import/dsfml/graphics/sprite.d @@ -40,7 +40,7 @@ import dsfml.system.vector2; * See_Also: * IDrawable */ -class Sprite : Drawableimpl!("sfSprite") +class Sprite : DrawableImpl!("sfSprite") { private: Image m_image; //< Image used to draw the sprite @@ -72,7 +72,7 @@ public: { super(); m_image = img; - sfSprite_SetImage(m_ptr, img.getNativePointer); + sfSprite_SetImage(m_ptr, img.getNativePointer, true); setX(left); setY(top); setScaleX(scaleX); @@ -86,11 +86,12 @@ public: * * Params: * img = New image + * adjustToNewSize = adjust sprite subrect to new image size */ - void setImage(Image img) + void setImage(Image img, bool adjustToNewSize = false) { assert(img !is null, "Trying to set a null image."); - sfSprite_SetImage(m_ptr, img.getNativePointer); + sfSprite_SetImage(m_ptr, img.getNativePointer, adjustToNewSize); m_image = img; } @@ -102,8 +103,7 @@ public: */ void setSubRect(IntRect rect) { - IntRect r = rect; - sfSprite_SetSubRect(m_ptr, &r); + sfSprite_SetSubRect(m_ptr, &rect); m_subRect = rect; } @@ -212,7 +212,7 @@ private: extern (C) { - typedef void function(void*, void*) pf_sfSprite_SetImage; + typedef void function(void*, void*, bool) pf_sfSprite_SetImage; typedef void function(void*, IntRect*) pf_sfSprite_SetSubRect; typedef void function(void*, float, float) pf_sfSprite_Resize; typedef void function(void*, int) pf_sfSprite_FlipX; diff --git a/DSFML/import/dsfml/graphics/text.d b/DSFML/import/dsfml/graphics/text.d index f6a6ccd28..244882704 100644 --- a/DSFML/import/dsfml/graphics/text.d +++ b/DSFML/import/dsfml/graphics/text.d @@ -64,7 +64,7 @@ enum TextStyle * See_Also: * IDrawable */ -class Text : Drawableimpl!("sfText") +class Text : DrawableImpl!("sfText") { private: Font m_font; diff --git a/DSFML/import/dsfml/system/dllloader.d b/DSFML/import/dsfml/system/dllloader.d index 61d4ea90b..bdbad5b46 100644 --- a/DSFML/import/dsfml/system/dllloader.d +++ b/DSFML/import/dsfml/system/dllloader.d @@ -40,6 +40,7 @@ else version (Windows) { import std.c.windows.windows; + import std.windows.syserror; // for error strings alias HMODULE MODULEHANDLE; } version (linux) @@ -181,7 +182,13 @@ private: } } if (m_lib is null) + { report("Cannot open library", m_libPath, null); + version (Windows) + { + report("Windows error message: " ~ sysErrorString(GetLastError()), m_libPath, null); + } + } } version (Tango) diff --git a/DSFML/import/dsfml/system/vector2.d b/DSFML/import/dsfml/system/vector2.d index 77d1b4b58..d997f285e 100644 --- a/DSFML/import/dsfml/system/vector2.d +++ b/DSFML/import/dsfml/system/vector2.d @@ -36,16 +36,6 @@ struct Vector2(T) T x; T y; - static Vector2 opCall(T x, T y) - { - Vector2!(T) ret; - - ret.x = x; - ret.y = y; - - return ret; - } - /// unary (-) overload Vector2 opNeg() { @@ -71,19 +61,19 @@ struct Vector2(T) /// (+) overload Vector2 opAdd(Vector2 other) { - return Vector2!(T)( (x + other.x), (y + other.y) ); + return Vector2!(T)( cast(T)(x + other.x), cast(T)(y + other.y) ); } /// (-) overload Vector2 opSub(Vector2 other) { - return Vector2!(T) ( (x - other.x), (y - other.y) ); + return Vector2!(T) ( cast(T)(x - other.x), cast(T)(y - other.y) ); } /// (*) overload Vector2 opMul(int i) { - return Vector2!(T) ( (x * i), (y * i) ); + return Vector2!(T) ( cast(T)(x * i), cast(T)(y * i) ); } /// (*=) overload @@ -97,7 +87,7 @@ struct Vector2(T) /// (/) overload Vector2 opDiv(int i) { - return Vector2!(T) ( (x / i), (y / i)); + return Vector2!(T) ( cast(T)(x / i), cast(T)(y / i)); } /// (/=) overload diff --git a/DSFML/import/dsfml/window/event.d b/DSFML/import/dsfml/window/event.d index 357838574..b0c11020a 100644 --- a/DSFML/import/dsfml/window/event.d +++ b/DSFML/import/dsfml/window/event.d @@ -35,7 +35,7 @@ module dsfml.window.event; * * LBRACKET, RBRACKET, SEMICOLON, COMMA, PERIOD, QUOTE, SLASH, BACKSLASH, TILDE, EQUAL, DASH.$(BR) * * SPACE, RETURN, BACK, TAB, PAGEUP, PAGEDOWN, END, HOME, INSERT, DELETE.$(BR) * * ADD, SUBTRACT, MULTIPLY, DIVIDE, LEFT, RIGHT, UP, DOWN.$(BR) -* * NUMPAD0, NUMPAD1, NUMPAD2, NUMPAD3, NUMPAD4, NUMPAD5, NUMPAD6, NUMPAD7, NUMPAD8, NUMPAD9.$(BR) +* * Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Numpad7, Numpad8, Numpad9.$(BR) * * F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15.$(BR) */ enum KeyCode @@ -66,65 +66,65 @@ enum KeyCode X = 'x', Y = 'y', Z = 'z', - NUM0 = '0', - NUM1 = '1', - NUM2 = '2', - NUM3 = '3', - NUM4 = '4', - NUM5 = '5', - NUM6 = '6', - NUM7 = '7', - NUM8 = '8', - NUM9 = '9', - ESCAPE = 256, - LCONTROL, - LSHIFT, - LALT, - LSYSTEM, - RCONTROL, - RSHIFT, - RALT, - RSYSTEM, - MENU, - LBRACKET, - RBRACKET, - SEMICOLON, - COMMA, - PERIOD, - QUOTE, - SLASH, - BACKSLASH, - TILDE, - EQUAL, - DASH, - SPACE, - RETURN, - BACK, - TAB, - PAGEUP, - PAGEDOWN, - END, - HOME, - INSERT, - DELETE, - ADD, - SUBTRACT, - MULTIPLY, - DIVIDE, - LEFT, - RIGHT, - UP, - DOWN, - NUMPAD0, - NUMPAD1, - NUMPAD2, - NUMPAD3, - NUMPAD4, - NUMPAD5, - NUMPAD6, - NUMPAD7, - NUMPAD8, - NUMPAD9, + Num0 = '0', + Num1 = '1', + Num2 = '2', + Num3 = '3', + Num4 = '4', + Num5 = '5', + Num6 = '6', + Num7 = '7', + Num8 = '8', + Num9 = '9', + Escape = 256, + LControl, + LShift, + LAlt, + LSystem, + RControl, + RShist, + RAlt, + RSystem, + Menu, + LBracket, + RBracket, + Semicolon, + Comma, + Period, + Quote, + Slash, + Backslash, + Tilde, + Equal, + Dash, + Space, + Return, + Back, + Tab, + PageUp, + PageDown, + End, + Home, + Insert, + Delete, + Add, + Substract, + Multiply, + Divide, + Left, + Right, + Up, + Down, + Numpad0, + Numpad1, + Numpad2, + Numpad3, + Numpad4, + Numpad5, + Numpad6, + Numpad7, + Numpad8, + Numpad9, F1, F2, F3, @@ -140,7 +140,7 @@ enum KeyCode F13, F14, F15, - PAUSE, + Pause, } @@ -149,11 +149,11 @@ enum KeyCode */ enum MouseButtons { - LEFT, /// - RIGHT, /// - MIDDLE, /// - XBUTTON1, /// - XBUTTON2 /// + Left, /// + Right, /// + Middle, /// + XButton1, /// + XButton2 /// } @@ -163,42 +163,43 @@ enum MouseButtons */ enum JoyAxis { - AXISX, /// - AXISY, /// - AXISZ, /// - AXISR, /// - AXISU, /// - AXISV, /// - AXISPOV /// + AxisX, /// + AxisY, /// + AxisZ, /// + AxisR, /// + AxisU, /// + AxisV, /// + AxisPOV /// } +/// EventType +enum EventType +{ + Closed, + Resized, + LostFocus, + GainedFocus, + TextEntered, + KeyPressed, + KeyReleased, + MouseWheelMoved, + MouseButtonPressed, + MouseButtonReleased, + MouseMoved, + MouseEntered, + MouseLeft, + JoyButtonPressed, + JoyButtonReleased, + JoyMoved + +} /** * Event defines a system event and its parameters */ align(1) struct Event { - enum EventType - { - CLOSED, - RESIZED, - LOSTFOCUS, - GAINEDFOCUS, - TEXTENTERED, - KEYPRESSED, - KEYRELEASED, - MOUSEWHEELMOVED, - MOUSEBUTTONPRESSED, - MOUSEBUTTONRELEASED, - MOUSEMOVED, - MOUSEENTERED, - MOUSELEFT, - JOYBUTTONPRESSED, - JOYBUTTONRELEASED, - JOYMOVED - } - /** * Enumeration of the different types of events. Accessing a value of another event that the one received (e.g. Event.Size.Width when receiving an KEYPRESSED event) will result in undefined behavior. * $(UL @@ -324,7 +325,4 @@ align(1) struct Event } SSize Size; } -} - - - +} \ No newline at end of file diff --git a/DSFML/import/dsfml/window/window.d b/DSFML/import/dsfml/window/window.d index ba3a10a5b..809d962c8 100644 --- a/DSFML/import/dsfml/window/window.d +++ b/DSFML/import/dsfml/window/window.d @@ -40,11 +40,13 @@ import dsfml.system.stringutil; */ enum Style { - NONE = 0, /// No border / title bar (this flag and all others are mutually exclusive) - TITLEBAR = 1 << 0, /// Title bar + fixed border - RESIZE = 1 << 1, /// Titlebar + resizable border + maximize button - CLOSE = 1 << 2, /// Titlebar + close button - FULLSCREEN = 1 << 3 /// Fullscreen mode (this flag and all others are mutually exclusive) + None = 0, /// No border / title bar (this flag and all others are mutually exclusive) + Titlebar = 1 << 0, /// Title bar + fixed border + Resize = 1 << 1, /// Titlebar + resizable border + maximize button + Close = 1 << 2, /// Titlebar + close button + Fullscreen = 1 << 3, /// Fullscreen mode (this flag and all others are mutually exclusive) + + Default = Titlebar | Resize | Close /// Default window style } @@ -85,7 +87,7 @@ public: * windowStyle = Window style (Resize | Close by default) * settings = Context settings (default is default ContextSettings values) */ - this(VideoMode mode, string title, Style windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings()) + this(VideoMode mode, string title, Style windowStyle = Style.Default, ContextSettings settings = ContextSettings()) { super(sfWindow_Create(mode, toStringz(title), windowStyle, settings)); } @@ -119,7 +121,7 @@ public: * windowStyle = Window style (Resize | Close by default) * settings = Context settings (default is default ContextSettings values) */ - void create(VideoMode mode, string title, Style windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings()) + void create(VideoMode mode, string title, Style windowStyle = Style.Default, ContextSettings settings = ContextSettings()) { if (m_ptr !is null) dispose();