Browse Source

No more Font:set(), instead love.graphics.setNewFont

Bart van Strien 13 years ago
parent
commit
e37470f54d

+ 0 - 11
src/modules/graphics/opengl/wrap_Font.cpp

@@ -19,7 +19,6 @@
 **/
 
 // LOVE
-#include "Graphics.h"
 #include "wrap_Font.h"
 
 namespace love
@@ -28,8 +27,6 @@ namespace graphics
 {
 namespace opengl
 {
-	extern Graphics * instance;
-
 	Font * luax_checkfont(lua_State * L, int idx)
 	{
 		return luax_checktype<Font>(L, idx, "Font", GRAPHICS_FONT_T);
@@ -92,20 +89,12 @@ namespace opengl
 		return 1;
 	}
 
-	int w_Font_set(lua_State * L)
-	{
-		Font * t = luax_checkfont(L, 1);
-		instance->setFont(t);
-		return 0;
-	}
-
 	static const luaL_Reg functions[] = {
 		{ "getHeight", w_Font_getHeight },
 		{ "getWidth", w_Font_getWidth },
 		{ "getWrap", w_Font_getWrap },
 		{ "setLineHeight", w_Font_setLineHeight },
 		{ "getLineHeight", w_Font_getLineHeight },
-		{ "set", w_Font_set },
 		{ 0, 0 }
 	};
 

+ 0 - 1
src/modules/graphics/opengl/wrap_Font.h

@@ -37,7 +37,6 @@ namespace opengl
 	int w_Font_getWrap(lua_State * L);
 	int w_Font_setLineHeight(lua_State * L);
 	int w_Font_getLineHeight(lua_State * L);
-	int w_Font_set(lua_State * L);
 	int luaopen_font(lua_State * L);
 
 } // opengl

+ 1 - 1
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -32,7 +32,7 @@ namespace graphics
 {
 namespace opengl
 {
-	Graphics * instance = 0;
+	static Graphics * instance = 0;
 
 	int w_checkMode(lua_State * L)
 	{

+ 8 - 2
src/scripts/graphics.lua

@@ -1252,9 +1252,15 @@ do
 		return love.graphics.newFont1(font, size or 12)
 	end
 
+	love.graphics.setNewFont = function(...)
+		local font = love.graphics.newFont(...)
+		love.graphics.setFont(font)
+		return font
+	end
+
 	love.graphics.print = function (...)
 		if not love.graphics.getFont() then
-			love.graphics.newFont(12):set()
+			love.graphics.setNewFont(12)
 		end
 		love.graphics.print1(...)
 		love.graphics.print = love.graphics.print1
@@ -1262,7 +1268,7 @@ do
 
 	love.graphics.printf = function (...)
 		if not love.graphics.getFont() then
-			love.graphics.newFont(12):set()
+			love.graphics.setNewFont(12)
 		end
 		love.graphics.printf1(...)
 		love.graphics.printf = love.graphics.printf1

+ 14 - 4
src/scripts/graphics.lua.h

@@ -6203,14 +6203,24 @@ const unsigned char graphics_lua[] =
 	0x68, 0x69, 0x63, 0x73, 0x2e, 0x6e, 0x65, 0x77, 0x46, 0x6f, 0x6e, 0x74, 0x31, 0x28, 0x66, 0x6f, 0x6e, 0x74, 
 	0x2c, 0x20, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x6f, 0x72, 0x20, 0x31, 0x32, 0x29, 0x0a,
 	0x09, 0x65, 0x6e, 0x64, 0x0a,0x0a,
+	0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x74, 
+	0x4e, 0x65, 0x77, 0x46, 0x6f, 0x6e, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 
+	0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x0a,
+	0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x76, 
+	0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x6e, 0x65, 0x77, 0x46, 0x6f, 0x6e, 0x74, 
+	0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x0a,
+	0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 
+	0x74, 0x46, 0x6f, 0x6e, 0x74, 0x28, 0x66, 0x6f, 0x6e, 0x74, 0x29, 0x0a,
+	0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x0a,
+	0x09, 0x65, 0x6e, 0x64, 0x0a,0x0a,
 	0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x69, 
 	0x6e, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x2e, 0x2e, 0x2e, 
 	0x29, 0x0a,
 	0x09, 0x09, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 
 	0x68, 0x69, 0x63, 0x73, 0x2e, 0x67, 0x65, 0x74, 0x46, 0x6f, 0x6e, 0x74, 0x28, 0x29, 0x20, 0x74, 0x68, 0x65, 
 	0x6e, 0x0a,
-	0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x6e, 
-	0x65, 0x77, 0x46, 0x6f, 0x6e, 0x74, 0x28, 0x31, 0x32, 0x29, 0x3a, 0x73, 0x65, 0x74, 0x28, 0x29, 0x0a,
+	0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x73, 
+	0x65, 0x74, 0x4e, 0x65, 0x77, 0x46, 0x6f, 0x6e, 0x74, 0x28, 0x31, 0x32, 0x29, 0x0a,
 	0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,
 	0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 
 	0x69, 0x6e, 0x74, 0x31, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x0a,
@@ -6224,8 +6234,8 @@ const unsigned char graphics_lua[] =
 	0x09, 0x09, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 
 	0x68, 0x69, 0x63, 0x73, 0x2e, 0x67, 0x65, 0x74, 0x46, 0x6f, 0x6e, 0x74, 0x28, 0x29, 0x20, 0x74, 0x68, 0x65, 
 	0x6e, 0x0a,
-	0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x6e, 
-	0x65, 0x77, 0x46, 0x6f, 0x6e, 0x74, 0x28, 0x31, 0x32, 0x29, 0x3a, 0x73, 0x65, 0x74, 0x28, 0x29, 0x0a,
+	0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x73, 
+	0x65, 0x74, 0x4e, 0x65, 0x77, 0x46, 0x6f, 0x6e, 0x74, 0x28, 0x31, 0x32, 0x29, 0x0a,
 	0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,
 	0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 
 	0x69, 0x6e, 0x74, 0x66, 0x31, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x0a,