Browse Source

Added love.mouse.hasCursor. Returns true if mouse cursors are available.

--HG--
branch : minor
Alex Szpakowski 10 years ago
parent
commit
8edea22179

+ 2 - 0
src/modules/mouse/Mouse.h

@@ -60,6 +60,8 @@ public:
 
 	virtual Cursor *getCursor() const = 0;
 
+	virtual bool hasCursor() const = 0;
+
 	virtual int getX() const = 0;
 	virtual int getY() const = 0;
 	virtual void getPosition(int &x, int &y) const = 0;

+ 6 - 0
src/modules/mouse/sdl/Mouse.cpp

@@ -112,6 +112,12 @@ love::mouse::Cursor *Mouse::getCursor() const
 	return curCursor.get();
 }
 
+
+bool Mouse::hasCursor() const
+{
+	return SDL_GetDefaultCursor() != nullptr;
+}
+
 int Mouse::getX() const
 {
 	int x;

+ 2 - 0
src/modules/mouse/sdl/Mouse.h

@@ -53,6 +53,8 @@ public:
 
 	love::mouse::Cursor *getCursor() const;
 
+	bool hasCursor() const;
+
 	int getX() const;
 	int getY() const;
 	void getPosition(int &x, int &y) const;

+ 7 - 0
src/modules/mouse/wrap_Mouse.cpp

@@ -91,6 +91,12 @@ int w_getCursor(lua_State *L)
 	return 1;
 }
 
+int w_hasCursor(lua_State *L)
+{
+	luax_pushboolean(L, instance()->hasCursor());
+	return 1;
+}
+
 int w_getX(lua_State *L)
 {
 	lua_pushnumber(L, instance()->getX());
@@ -199,6 +205,7 @@ static const luaL_Reg functions[] =
 	{ "getSystemCursor", w_getSystemCursor },
 	{ "setCursor", w_setCursor },
 	{ "getCursor", w_getCursor },
+	{ "hasCursor", w_hasCursor },
 	{ "getX", w_getX },
 	{ "getY", w_getY },
 	{ "setX", w_setX },

+ 1 - 0
src/modules/mouse/wrap_Mouse.h

@@ -34,6 +34,7 @@ int w_newCursor(lua_State *L);
 int w_getSystemCursor(lua_State *L);
 int w_setCursor(lua_State *L);
 int w_getCursor(lua_State *L);
+int w_hasCursor(lua_State *L);
 int w_getX(lua_State *L);
 int w_getY(lua_State *L);
 int w_getPosition(lua_State *L);