From e37470f54db7fd0779c3c12ee33c5c2e35964b77 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Tue, 13 Dec 2011 19:22:59 +0100 Subject: [PATCH] No more Font:set(), instead love.graphics.setNewFont --- src/modules/graphics/opengl/wrap_Font.cpp | 11 ----------- src/modules/graphics/opengl/wrap_Font.h | 1 - src/modules/graphics/opengl/wrap_Graphics.cpp | 2 +- src/scripts/graphics.lua | 10 ++++++++-- src/scripts/graphics.lua.h | 18 ++++++++++++++---- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/modules/graphics/opengl/wrap_Font.cpp b/src/modules/graphics/opengl/wrap_Font.cpp index 8dd532880..b5ef28403 100644 --- a/src/modules/graphics/opengl/wrap_Font.cpp +++ b/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(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 } }; diff --git a/src/modules/graphics/opengl/wrap_Font.h b/src/modules/graphics/opengl/wrap_Font.h index a289c9d4a..85e2a6b5f 100644 --- a/src/modules/graphics/opengl/wrap_Font.h +++ b/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 diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index 81f889c14..efeef4116 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/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) { diff --git a/src/scripts/graphics.lua b/src/scripts/graphics.lua index 0d2cc4781..ebdd9bea8 100644 --- a/src/scripts/graphics.lua +++ b/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 diff --git a/src/scripts/graphics.lua.h b/src/scripts/graphics.lua.h index 9e4c0f5f4..dd881cfa7 100644 --- a/src/scripts/graphics.lua.h +++ b/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,