From 4711217f127aa0c10fa52755fd567c570277a1a1 Mon Sep 17 00:00:00 2001 From: s_alexander Date: Tue, 12 Jan 2010 17:42:41 +0000 Subject: merged lua into trunk git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2071 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/lua/ULuaTextGL.pas | 147 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 src/lua/ULuaTextGL.pas (limited to 'src/lua/ULuaTextGL.pas') diff --git a/src/lua/ULuaTextGL.pas b/src/lua/ULuaTextGL.pas new file mode 100644 index 00000000..1db41b21 --- /dev/null +++ b/src/lua/ULuaTextGL.pas @@ -0,0 +1,147 @@ +{* UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + *} + +unit ULuaTextGL; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +{$I switches.inc} + +uses + TextGL, + ULua; + +{ TextGl.Pos(X, Y: Float) : sets font position } +function ULuaTextGL_Pos(L: Plua_State): Integer; cdecl; + +{ TextGl.Size(Size: Float) : sets font size } +function ULuaTextGL_Size(L: Plua_State): Integer; cdecl; + +{ TextGl.Style(Style: int) : sets font style (from 0 to 3) } +function ULuaTextGL_Style(L: Plua_State): Integer; cdecl; + +{ TextGl.Italic(isItalic: boolean) : sets if font is italic } +function ULuaTextGL_Italic(L: Plua_State): Integer; cdecl; + +{ TextGl.Width(Text: String) : returns width of Text if printed + w/ current settings in pixels } +function ULuaTextGL_Width(L: Plua_State): Integer; cdecl; + +{ TextGl.Print(Text: String) : prints text to screen w/ current + settings} +function ULuaTextGL_Print(L: Plua_State): Integer; cdecl; + +const + ULuaTextGl_Lib_f: array [0..5] of lual_reg = ( + (name:'Pos'; func:ULuaTextGl_Pos), + (name:'Size'; func:ULuaTextGl_Size), + (name:'Style'; func:ULuaTextGl_Style), + (name:'Italic'; func:ULuaTextGl_Italic), + (name:'Width'; func:ULuaTextGl_Width), + (name:'Print'; func:ULuaTextGl_Print) + ); + + +implementation + +{ TextGl.Pos(X, Y: Float) : sets font position } +function ULuaTextGL_Pos(L: Plua_State): Integer; cdecl; + var X, Y: Double; +begin + X := luaL_checknumber(L, 1); + Y := luaL_checknumber(L, 2); + + SetFontPos(X, Y); + + Result := 0; +end; + +{ TextGl.Size(Size: Float) : sets font size } +function ULuaTextGL_Size(L: Plua_State): Integer; cdecl; + var Size: Double; +begin + Size := luaL_checknumber(L, 1); + + SetFontSize(Size); + + Result := 0; +end; + +{ TextGl.Style(Style: int) : sets font style (from 0 to 3) } +function ULuaTextGL_Style(L: Plua_State): Integer; cdecl; + var Style: Integer; +begin + Style := luaL_checkinteger(L, 1); + + if (Style >= 0) and (Style <= 3) then + SetFontStyle(Style) + else + luaL_ArgError(L, 1, PChar('number from 0 to 3 expected')); + + Result := 0; +end; + +{ TextGl.Italic(isItalic: boolean) : sets if font is italic } +function ULuaTextGL_Italic(L: Plua_State): Integer; cdecl; + var isItalic: Boolean; +begin + luaL_checkany(L, 1); + isItalic := lua_toBoolean(L, 1); + + SetFontItalic(isItalic); + + Result := 0; +end; + +{ TextGl.Width(Text: String) : returns width of Text if printed + w/ current settings in pixels } +function ULuaTextGL_Width(L: Plua_State): Integer; cdecl; + var Text: String; +begin + Text := luaL_checkstring(L, 1); + lua_pop(L, lua_gettop(L)); + + lua_PushNumber(L, glTextWidth(Text)); + + Result := 1; +end; + +{ TextGl.Print(Text: String) : prints text to screen w/ current + settings} +function ULuaTextGL_Print(L: Plua_State): Integer; cdecl; + var Text: String; +begin + Text := luaL_checkstring(L, 1); + + glPrint(Text); + + Result := 0; +end; + +end. -- cgit v1.2.3