mirror of
https://github.com/SFML/SFML.git
synced 2025-02-08 01:18:02 +08:00
+ window Style.Default
+ windows error message for dll loading errors * made identifiers in event match SFML's style git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1347 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
6c44a1d33a
commit
77d248f79e
@ -41,7 +41,7 @@ import dsfml.graphics.idrawable,
|
|||||||
* Package base class of all drawable.
|
* Package base class of all drawable.
|
||||||
* Provide implementation of IDrawable and functions aliases.
|
* Provide implementation of IDrawable and functions aliases.
|
||||||
*/
|
*/
|
||||||
package class Drawableimpl(alias symbol) : DSFMLObject, IDrawable
|
package class DrawableImpl(alias symbol) : DSFMLObject, IDrawable
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
this()
|
this()
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
* windowStyle = Window style (Resize | Close by default)
|
* windowStyle = Window style (Resize | Close by default)
|
||||||
* settings = Context settings (default is default ContextSettings values)
|
* 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));
|
super(sfRenderWindow_Create(mode, toStringz(title), windowStyle, &settings));
|
||||||
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
|
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
|
||||||
@ -102,7 +102,7 @@ public:
|
|||||||
* settings = Context settings (default is default ContextSettings values)
|
* 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)
|
if (m_ptr !is null)
|
||||||
dispose();
|
dispose();
|
||||||
|
@ -37,7 +37,7 @@ import dsfml.graphics.drawableimpl;
|
|||||||
* helper functions to draw simple shapes like
|
* helper functions to draw simple shapes like
|
||||||
* lines, rectangles, circles, etc.
|
* lines, rectangles, circles, etc.
|
||||||
*/
|
*/
|
||||||
class Shape : Drawableimpl!("sfShape")
|
class Shape : DrawableImpl!("sfShape")
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
this (void* ptr)
|
this (void* ptr)
|
||||||
|
@ -40,7 +40,7 @@ import dsfml.system.vector2;
|
|||||||
* See_Also:
|
* See_Also:
|
||||||
* IDrawable
|
* IDrawable
|
||||||
*/
|
*/
|
||||||
class Sprite : Drawableimpl!("sfSprite")
|
class Sprite : DrawableImpl!("sfSprite")
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Image m_image; //< Image used to draw the sprite
|
Image m_image; //< Image used to draw the sprite
|
||||||
@ -72,7 +72,7 @@ public:
|
|||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
m_image = img;
|
m_image = img;
|
||||||
sfSprite_SetImage(m_ptr, img.getNativePointer);
|
sfSprite_SetImage(m_ptr, img.getNativePointer, true);
|
||||||
setX(left);
|
setX(left);
|
||||||
setY(top);
|
setY(top);
|
||||||
setScaleX(scaleX);
|
setScaleX(scaleX);
|
||||||
@ -86,11 +86,12 @@ public:
|
|||||||
*
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* img = New image
|
* 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.");
|
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;
|
m_image = img;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,8 +103,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setSubRect(IntRect rect)
|
void setSubRect(IntRect rect)
|
||||||
{
|
{
|
||||||
IntRect r = rect;
|
sfSprite_SetSubRect(m_ptr, &rect);
|
||||||
sfSprite_SetSubRect(m_ptr, &r);
|
|
||||||
m_subRect = rect;
|
m_subRect = rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ private:
|
|||||||
|
|
||||||
extern (C)
|
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*, IntRect*) pf_sfSprite_SetSubRect;
|
||||||
typedef void function(void*, float, float) pf_sfSprite_Resize;
|
typedef void function(void*, float, float) pf_sfSprite_Resize;
|
||||||
typedef void function(void*, int) pf_sfSprite_FlipX;
|
typedef void function(void*, int) pf_sfSprite_FlipX;
|
||||||
|
@ -64,7 +64,7 @@ enum TextStyle
|
|||||||
* See_Also:
|
* See_Also:
|
||||||
* IDrawable
|
* IDrawable
|
||||||
*/
|
*/
|
||||||
class Text : Drawableimpl!("sfText")
|
class Text : DrawableImpl!("sfText")
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Font m_font;
|
Font m_font;
|
||||||
|
@ -40,6 +40,7 @@ else
|
|||||||
version (Windows)
|
version (Windows)
|
||||||
{
|
{
|
||||||
import std.c.windows.windows;
|
import std.c.windows.windows;
|
||||||
|
import std.windows.syserror; // for error strings
|
||||||
alias HMODULE MODULEHANDLE;
|
alias HMODULE MODULEHANDLE;
|
||||||
}
|
}
|
||||||
version (linux)
|
version (linux)
|
||||||
@ -181,7 +182,13 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_lib is null)
|
if (m_lib is null)
|
||||||
|
{
|
||||||
report("Cannot open library", m_libPath, null);
|
report("Cannot open library", m_libPath, null);
|
||||||
|
version (Windows)
|
||||||
|
{
|
||||||
|
report("Windows error message: " ~ sysErrorString(GetLastError()), m_libPath, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
version (Tango)
|
version (Tango)
|
||||||
|
@ -36,16 +36,6 @@ struct Vector2(T)
|
|||||||
T x;
|
T x;
|
||||||
T y;
|
T y;
|
||||||
|
|
||||||
static Vector2 opCall(T x, T y)
|
|
||||||
{
|
|
||||||
Vector2!(T) ret;
|
|
||||||
|
|
||||||
ret.x = x;
|
|
||||||
ret.y = y;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// unary (-) overload
|
/// unary (-) overload
|
||||||
Vector2 opNeg()
|
Vector2 opNeg()
|
||||||
{
|
{
|
||||||
@ -71,19 +61,19 @@ struct Vector2(T)
|
|||||||
/// (+) overload
|
/// (+) overload
|
||||||
Vector2 opAdd(Vector2 other)
|
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
|
/// (-) overload
|
||||||
Vector2 opSub(Vector2 other)
|
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
|
/// (*) overload
|
||||||
Vector2 opMul(int i)
|
Vector2 opMul(int i)
|
||||||
{
|
{
|
||||||
return Vector2!(T) ( (x * i), (y * i) );
|
return Vector2!(T) ( cast(T)(x * i), cast(T)(y * i) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// (*=) overload
|
/// (*=) overload
|
||||||
@ -97,7 +87,7 @@ struct Vector2(T)
|
|||||||
/// (/) overload
|
/// (/) overload
|
||||||
Vector2 opDiv(int i)
|
Vector2 opDiv(int i)
|
||||||
{
|
{
|
||||||
return Vector2!(T) ( (x / i), (y / i));
|
return Vector2!(T) ( cast(T)(x / i), cast(T)(y / i));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// (/=) overload
|
/// (/=) overload
|
||||||
|
@ -35,7 +35,7 @@ module dsfml.window.event;
|
|||||||
* * LBRACKET, RBRACKET, SEMICOLON, COMMA, PERIOD, QUOTE, SLASH, BACKSLASH, TILDE, EQUAL, DASH.$(BR)
|
* * LBRACKET, RBRACKET, SEMICOLON, COMMA, PERIOD, QUOTE, SLASH, BACKSLASH, TILDE, EQUAL, DASH.$(BR)
|
||||||
* * SPACE, RETURN, BACK, TAB, PAGEUP, PAGEDOWN, END, HOME, INSERT, DELETE.$(BR)
|
* * SPACE, RETURN, BACK, TAB, PAGEUP, PAGEDOWN, END, HOME, INSERT, DELETE.$(BR)
|
||||||
* * ADD, SUBTRACT, MULTIPLY, DIVIDE, LEFT, RIGHT, UP, DOWN.$(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)
|
* * F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15.$(BR)
|
||||||
*/
|
*/
|
||||||
enum KeyCode
|
enum KeyCode
|
||||||
@ -66,65 +66,65 @@ enum KeyCode
|
|||||||
X = 'x',
|
X = 'x',
|
||||||
Y = 'y',
|
Y = 'y',
|
||||||
Z = 'z',
|
Z = 'z',
|
||||||
NUM0 = '0',
|
Num0 = '0',
|
||||||
NUM1 = '1',
|
Num1 = '1',
|
||||||
NUM2 = '2',
|
Num2 = '2',
|
||||||
NUM3 = '3',
|
Num3 = '3',
|
||||||
NUM4 = '4',
|
Num4 = '4',
|
||||||
NUM5 = '5',
|
Num5 = '5',
|
||||||
NUM6 = '6',
|
Num6 = '6',
|
||||||
NUM7 = '7',
|
Num7 = '7',
|
||||||
NUM8 = '8',
|
Num8 = '8',
|
||||||
NUM9 = '9',
|
Num9 = '9',
|
||||||
ESCAPE = 256,
|
Escape = 256,
|
||||||
LCONTROL,
|
LControl,
|
||||||
LSHIFT,
|
LShift,
|
||||||
LALT,
|
LAlt,
|
||||||
LSYSTEM,
|
LSystem,
|
||||||
RCONTROL,
|
RControl,
|
||||||
RSHIFT,
|
RShist,
|
||||||
RALT,
|
RAlt,
|
||||||
RSYSTEM,
|
RSystem,
|
||||||
MENU,
|
Menu,
|
||||||
LBRACKET,
|
LBracket,
|
||||||
RBRACKET,
|
RBracket,
|
||||||
SEMICOLON,
|
Semicolon,
|
||||||
COMMA,
|
Comma,
|
||||||
PERIOD,
|
Period,
|
||||||
QUOTE,
|
Quote,
|
||||||
SLASH,
|
Slash,
|
||||||
BACKSLASH,
|
Backslash,
|
||||||
TILDE,
|
Tilde,
|
||||||
EQUAL,
|
Equal,
|
||||||
DASH,
|
Dash,
|
||||||
SPACE,
|
Space,
|
||||||
RETURN,
|
Return,
|
||||||
BACK,
|
Back,
|
||||||
TAB,
|
Tab,
|
||||||
PAGEUP,
|
PageUp,
|
||||||
PAGEDOWN,
|
PageDown,
|
||||||
END,
|
End,
|
||||||
HOME,
|
Home,
|
||||||
INSERT,
|
Insert,
|
||||||
DELETE,
|
Delete,
|
||||||
ADD,
|
Add,
|
||||||
SUBTRACT,
|
Substract,
|
||||||
MULTIPLY,
|
Multiply,
|
||||||
DIVIDE,
|
Divide,
|
||||||
LEFT,
|
Left,
|
||||||
RIGHT,
|
Right,
|
||||||
UP,
|
Up,
|
||||||
DOWN,
|
Down,
|
||||||
NUMPAD0,
|
Numpad0,
|
||||||
NUMPAD1,
|
Numpad1,
|
||||||
NUMPAD2,
|
Numpad2,
|
||||||
NUMPAD3,
|
Numpad3,
|
||||||
NUMPAD4,
|
Numpad4,
|
||||||
NUMPAD5,
|
Numpad5,
|
||||||
NUMPAD6,
|
Numpad6,
|
||||||
NUMPAD7,
|
Numpad7,
|
||||||
NUMPAD8,
|
Numpad8,
|
||||||
NUMPAD9,
|
Numpad9,
|
||||||
F1,
|
F1,
|
||||||
F2,
|
F2,
|
||||||
F3,
|
F3,
|
||||||
@ -140,7 +140,7 @@ enum KeyCode
|
|||||||
F13,
|
F13,
|
||||||
F14,
|
F14,
|
||||||
F15,
|
F15,
|
||||||
PAUSE,
|
Pause,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -149,11 +149,11 @@ enum KeyCode
|
|||||||
*/
|
*/
|
||||||
enum MouseButtons
|
enum MouseButtons
|
||||||
{
|
{
|
||||||
LEFT, ///
|
Left, ///
|
||||||
RIGHT, ///
|
Right, ///
|
||||||
MIDDLE, ///
|
Middle, ///
|
||||||
XBUTTON1, ///
|
XButton1, ///
|
||||||
XBUTTON2 ///
|
XButton2 ///
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -163,42 +163,43 @@ enum MouseButtons
|
|||||||
*/
|
*/
|
||||||
enum JoyAxis
|
enum JoyAxis
|
||||||
{
|
{
|
||||||
AXISX, ///
|
AxisX, ///
|
||||||
AXISY, ///
|
AxisY, ///
|
||||||
AXISZ, ///
|
AxisZ, ///
|
||||||
AXISR, ///
|
AxisR, ///
|
||||||
AXISU, ///
|
AxisU, ///
|
||||||
AXISV, ///
|
AxisV, ///
|
||||||
AXISPOV ///
|
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
|
* Event defines a system event and its parameters
|
||||||
*/
|
*/
|
||||||
align(1) struct Event
|
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.
|
* 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
|
* $(UL
|
||||||
@ -325,6 +326,3 @@ align(1) struct Event
|
|||||||
SSize Size;
|
SSize Size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,11 +40,13 @@ import dsfml.system.stringutil;
|
|||||||
*/
|
*/
|
||||||
enum Style
|
enum Style
|
||||||
{
|
{
|
||||||
NONE = 0, /// No border / title bar (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
|
Titlebar = 1 << 0, /// Title bar + fixed border
|
||||||
RESIZE = 1 << 1, /// Titlebar + resizable border + maximize button
|
Resize = 1 << 1, /// Titlebar + resizable border + maximize button
|
||||||
CLOSE = 1 << 2, /// Titlebar + close button
|
Close = 1 << 2, /// Titlebar + close button
|
||||||
FULLSCREEN = 1 << 3 /// Fullscreen mode (this flag and all others are mutually exclusive)
|
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)
|
* windowStyle = Window style (Resize | Close by default)
|
||||||
* settings = Context settings (default is default ContextSettings values)
|
* 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));
|
super(sfWindow_Create(mode, toStringz(title), windowStyle, settings));
|
||||||
}
|
}
|
||||||
@ -119,7 +121,7 @@ public:
|
|||||||
* windowStyle = Window style (Resize | Close by default)
|
* windowStyle = Window style (Resize | Close by default)
|
||||||
* settings = Context settings (default is default ContextSettings values)
|
* 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)
|
if (m_ptr !is null)
|
||||||
dispose();
|
dispose();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user