aboutsummaryrefslogtreecommitdiffstats
path: root/Lua/src/lua/ULuaScreenSing.pas
diff options
context:
space:
mode:
authorwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-07-14 19:08:03 +0000
committerwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-07-14 19:08:03 +0000
commit71c0f51aa0d9d01b22e3da401bccfe88c41399f2 (patch)
treed883e36e46483467c9657821791d7ad24022514c /Lua/src/lua/ULuaScreenSing.pas
parente86e99462f608406da825043acde9c7b8147b907 (diff)
downloadusdx-71c0f51aa0d9d01b22e3da401bccfe88c41399f2.tar.gz
usdx-71c0f51aa0d9d01b22e3da401bccfe88c41399f2.tar.xz
usdx-71c0f51aa0d9d01b22e3da401bccfe88c41399f2.zip
4 new lua interface function for module ScreenSing
new procedure in ULuaUtils lua_PushRect git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1846 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Lua/src/lua/ULuaScreenSing.pas')
-rw-r--r--Lua/src/lua/ULuaScreenSing.pas141
1 files changed, 138 insertions, 3 deletions
diff --git a/Lua/src/lua/ULuaScreenSing.pas b/Lua/src/lua/ULuaScreenSing.pas
index 09d83403..c205b65b 100644
--- a/Lua/src/lua/ULuaScreenSing.pas
+++ b/Lua/src/lua/ULuaScreenSing.pas
@@ -1,4 +1,4 @@
- {* UltraStar Deluxe - Karaoke Game
+{* 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
@@ -40,6 +40,21 @@ uses
t[1..playercount] = score of player i }
function ULuaScreenSing_GetScores(L: Plua_State): Integer; cdecl;
+{ returns a table with following structure:
+ t[1..playercount] = rating of player i range: [0..1] }
+function ULuaScreenSing_GetRating(L: Plua_State): Integer; cdecl;
+
+{ returns a table with following structure:
+ t[1..playercount] = rect of players score background: table(x, y, w, h) }
+function ULuaScreenSing_GetScoreBGRect(L: Plua_State): Integer; cdecl;
+
+{ returns a table with following structure:
+ t[1..playercount] = rect of players rating bar: table(x, y, w, h) }
+function ULuaScreenSing_GetRBRect(L: Plua_State): Integer; cdecl;
+
+{ ScreenSing.GetBeat() - returns current beat of lyricstate }
+function ULuaScreenSing_GetBeat(L: Plua_State): Integer; cdecl;
+
{ finishes current song, if sing screen is not shown it will raise
an error }
function ULuaScreenSing_Finish(L: Plua_State): Integer; cdecl;
@@ -54,15 +69,19 @@ function ULuaScreenSing_GetSettings(L: Plua_State): Integer; cdecl;
function ULuaScreenSing_SetSettings(L: Plua_State): Integer; cdecl;
const
- ULuaScreenSing_Lib_f: array [0..3] of lual_reg = (
+ ULuaScreenSing_Lib_f: array [0..7] of lual_reg = (
(name:'GetScores';func:ULuaScreenSing_GetScores),
+ (name:'GetRating';func:ULuaScreenSing_GetRating),
+ (name:'GetBeat';func:ULuaScreenSing_GetBeat),
+ (name:'GetScoreBGRect';func:ULuaScreenSing_GetScoreBGRect),
+ (name:'GetRBRect';func:ULuaScreenSing_GetRBRect),
(name:'Finish';func:ULuaScreenSing_Finish),
(name:'GetSettings';func:ULuaScreenSing_GetSettings),
(name:'SetSettings';func:ULuaScreenSing_SetSettings)
);
implementation
-uses UScreenSing, UMain, UDisplay, UGraphic, ULuaUtils, SysUtils;
+uses UScreenSing, UMain, UDisplay, UGraphic, UMusic, ULuaUtils, SysUtils;
{ returns a table with following structure:
t[1..playercount] = score of player i }
@@ -93,6 +112,107 @@ begin
// leave table on stack, it is our result
end;
+{ returns a table with following structure:
+ t[1..playercount] = rating of player i range: [0..1] }
+function ULuaScreenSing_GetRating(L: Plua_State): Integer; cdecl;
+ var
+ Top: Integer;
+ I: Integer;
+begin
+ Result := 1;
+
+ // pop arguments
+ Top := lua_getTop(L);
+ if (Top > 0) then
+ lua_pop(L, Top);
+
+ // create table
+ lua_createtable(L, Length(Player), 0);
+
+ // fill w/ values
+ for I := 0 to High(ScreenSing.Scores.Players) do
+ begin
+ lua_pushInteger(L, I + 1);
+ lua_pushNumber(L, ScreenSing.Scores.Players[I].RBPos);
+
+ lua_settable(L, -3);
+ end;
+
+ // leave table on stack, it is our result
+end;
+
+{ returns a table with following structure:
+ t[1..playercount] = rect of players ScoreBG: table(x, y, w, h) }
+function ULuaScreenSing_GetScoreBGRect(L: Plua_State): Integer; cdecl;
+ var
+ Top: Integer;
+ I: Integer;
+begin
+ Result := 1;
+
+ // pop arguments
+ Top := lua_getTop(L);
+ if (Top > 0) then
+ lua_pop(L, Top);
+
+ // create table
+ lua_createtable(L, Length(ScreenSing.Scores.Players), 0);
+
+ // fill w/ values
+ for I := 0 to High(ScreenSing.Scores.Players) do
+ begin
+ lua_pushInteger(L, I + 1);
+
+ if (ScreenSing.Scores.Players[I].Position = High(Byte)) then
+ // player has no position, prevent crash by pushing nil
+ lua_pushNil(L)
+ else
+ with ScreenSing.Scores.Positions[ScreenSing.Scores.Players[I].Position] do
+ lua_PushRect(L, BGX, BGY, BGW, BGH);
+
+
+ lua_settable(L, -3);
+ end;
+
+ // leave table on stack, it is our result
+end;
+
+{ returns a table with following structure:
+ t[1..playercount] = rect of players rating bar: table(x, y, w, h) }
+function ULuaScreenSing_GetRBRect(L: Plua_State): Integer; cdecl;
+ var
+ Top: Integer;
+ I: Integer;
+begin
+ Result := 1;
+
+ // pop arguments
+ Top := lua_getTop(L);
+ if (Top > 0) then
+ lua_pop(L, Top);
+
+ // create table
+ lua_createtable(L, Length(ScreenSing.Scores.Players), 0);
+
+ // fill w/ values
+ for I := 0 to High(ScreenSing.Scores.Players) do
+ begin
+ lua_pushInteger(L, I + 1);
+
+ if (ScreenSing.Scores.Players[I].Position = High(Byte)) then
+ // player has no position, prevent crash by pushing nil
+ lua_pushNil(L)
+ else
+ with ScreenSing.Scores.Positions[ScreenSing.Scores.Players[I].Position] do
+ lua_PushRect(L, RBX, RBY, RBW, RBH);
+
+
+ lua_settable(L, -3);
+ end;
+
+ // leave table on stack, it is our result
+end;
+
{ finishes current song, if sing screen is not shown it will raise
an error }
function ULuaScreenSing_Finish(L: Plua_State): Integer; cdecl;
@@ -174,4 +294,19 @@ begin
ScreenSing.ApplySettings;
end;
+{ ScreenSing.GetBeat() - returns current beat of lyricstate }
+function ULuaScreenSing_GetBeat(L: Plua_State): Integer; cdecl;
+var top: Integer;
+begin
+ //remove arguments (if any)
+ top := lua_gettop(L);
+
+ if (top > 0) then
+ lua_pop(L, top);
+
+ //push result
+ lua_pushnumber(L, LyricsState.MidBeat);
+ Result := 1; //one result
+end;
+
end. \ No newline at end of file