aboutsummaryrefslogtreecommitdiffstats
path: root/Lua/src/lua/ULuaScreenSing.pas
diff options
context:
space:
mode:
authorwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-05-23 14:08:58 +0000
committerwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-05-23 14:08:58 +0000
commit1bcf5d3ab366002e8000656b566340c3efd756af (patch)
tree8ed312dd7c2c5860f723825aa7283474d456a481 /Lua/src/lua/ULuaScreenSing.pas
parentc32c264f7ed302d40a84aa56028256b583c678b2 (diff)
downloadusdx-1bcf5d3ab366002e8000656b566340c3efd756af.tar.gz
usdx-1bcf5d3ab366002e8000656b566340c3efd756af.tar.xz
usdx-1bcf5d3ab366002e8000656b566340c3efd756af.zip
new ULuaUtils procedure: lua_PushBinInt
new functions in ScreenSing lua module ScreenSing.GetSettings ScreenSing.SetSettings 3 new settings in UScreenSing that needs to be implemented LyrcsVisible, NotesVisible and PlayerEnabled git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1769 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Lua/src/lua/ULuaScreenSing.pas')
-rw-r--r--Lua/src/lua/ULuaScreenSing.pas78
1 files changed, 75 insertions, 3 deletions
diff --git a/Lua/src/lua/ULuaScreenSing.pas b/Lua/src/lua/ULuaScreenSing.pas
index 75ed6277..09d83403 100644
--- a/Lua/src/lua/ULuaScreenSing.pas
+++ b/Lua/src/lua/ULuaScreenSing.pas
@@ -44,14 +44,25 @@ function ULuaScreenSing_GetScores(L: Plua_State): Integer; cdecl;
an error }
function ULuaScreenSing_Finish(L: Plua_State): Integer; cdecl;
+{ ScreenSing.GetSettings - no arguments
+ returns a table filled with the data of TScreenSing }
+function ULuaScreenSing_GetSettings(L: Plua_State): Integer; cdecl;
+
+{ ScreenSing.SetSettings - arguments: Table
+ sets all attributes of TScreenSing.Settings that are
+ unequal to nil in Table }
+function ULuaScreenSing_SetSettings(L: Plua_State): Integer; cdecl;
+
const
- ULuaScreenSing_Lib_f: array [0..1] of lual_reg = (
+ ULuaScreenSing_Lib_f: array [0..3] of lual_reg = (
(name:'GetScores';func:ULuaScreenSing_GetScores),
- (name:'Finish';func:ULuaScreenSing_Finish)
+ (name:'Finish';func:ULuaScreenSing_Finish),
+ (name:'GetSettings';func:ULuaScreenSing_GetSettings),
+ (name:'SetSettings';func:ULuaScreenSing_SetSettings)
);
implementation
-uses UScreenSing, UMain, UDisplay, UGraphic;
+uses UScreenSing, UMain, UDisplay, UGraphic, ULuaUtils, SysUtils;
{ returns a table with following structure:
t[1..playercount] = score of player i }
@@ -102,4 +113,65 @@ begin
LuaL_error(L, 'Usdx.ScreenSing.Finish is called, but sing screen is not shown.');
end;
+{ ScreenSing.GetSettings - no arguments
+ returns a table filled with the data of TScreenSing }
+function ULuaScreenSing_GetSettings(L: Plua_State): Integer; cdecl;
+ var Top: Integer;
+begin
+ // pop arguments
+ Top := lua_getTop(L);
+ if (Top > 0) then
+ lua_pop(L, Top);
+
+ lua_createtable(L, 0, 3);
+
+ //fill table w/ info
+ lua_pushBoolean(L, ScreenSing.Settings.LyricsVisible);
+ lua_setField(L, -2, 'LyricsVisible');
+
+ lua_pushBinInt(L, ScreenSing.Settings.NotesVisible);
+ lua_setField(L, -2, 'NotesVisible');
+
+ lua_pushBinInt(L, ScreenSing.Settings.PlayerEnabled);
+ lua_setField(L, -2, 'PlayerEnabled');
+
+
+ Result := 1;
+end;
+
+{ ScreenSing.SetSettings - arguments: Table
+ sets all attributes of TScreenSing.Settings that are
+ unequal to nil in Table }
+function ULuaScreenSing_SetSettings(L: Plua_State): Integer; cdecl;
+ var
+ Key: String;
+begin
+ Result := 0;
+
+ // check for table on stack
+ luaL_checkType(L, 1, LUA_TTABLE);
+
+ // go through table elements
+ lua_pushNil(L);
+ while (lua_Next(L, 1) <> 0) do
+ begin
+ Key := lowercase(lua_ToString(L, -2));
+
+ if (Key = 'lyricsvisible') and (lua_isBoolean(L, -1)) then
+ ScreenSing.settings.LyricsVisible := lua_toBoolean(L, -1)
+ else if (Key = 'notesvisible') and (lua_isTable(L, -1)) then
+ ScreenSing.settings.NotesVisible := lua_toBinInt(L, -1)
+ else if (Key = 'playerenabled') and (lua_isTable(L, -1)) then
+ ScreenSing.settings.PlayerEnabled := lua_toBinInt(L, -1);
+
+ // pop value from stack so key is on top
+ lua_pop(L, 1);
+ end;
+
+ // clear stack from table
+ lua_pop(L, lua_gettop(L));
+
+ ScreenSing.ApplySettings;
+end;
+
end. \ No newline at end of file