From 0da8d77a5f6ae619a7df70cf3f882e077879ab1b Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Sat, 22 Nov 2014 14:44:41 +0000 Subject: more eol work in game git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@3098 b956fd51-792f-4845-bead-9b4dfca2ff2c --- game/plugins/5000points.usdx | 146 ++++++------ game/plugins/blind.usdx | 104 ++++----- game/plugins/duel.usdx | 80 +++---- game/plugins/holdtheline.usdx | 436 +++++++++++++++++------------------ game/plugins/teamduel.usdx | 514 +++++++++++++++++++++--------------------- 5 files changed, 640 insertions(+), 640 deletions(-) (limited to 'game/plugins') diff --git a/game/plugins/5000points.usdx b/game/plugins/5000points.usdx index 75dc4e03..1e529895 100644 --- a/game/plugins/5000points.usdx +++ b/game/plugins/5000points.usdx @@ -1,74 +1,74 @@ ---[[ - * 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$ - *]] - -function plugin_init() - register('party mode: 5000points', '1.00', 'USDX Team', 'http://www.UltrastarDeluxe.org'); - - require('Usdx.Party') - require('Usdx.ScreenSing'); - - local Mode = {} - - Mode.Name = '5000points' - Mode.CanNonParty = true; - Mode.CanParty = true; - Mode.OnSing = 'Sing'; - Mode.AfterSing = 'Calculate_Winner'; - - Usdx.Party.Register(Mode) - - return true; -end - -function Sing() - Scores = ScreenSing.GetScores(); - - for i = 1, #Scores do - if (Scores[i] >= 5000) then - ScreenSing.Finish(); - break; - end - end - - return true; -end - -function Calculate_Winner() - Scores = Scores or ScreenSing.GetScores(); - local Ranking = {}; - for i = 1, #Scores do - if Scores[i] >= 5000 then - Ranking[i] = 1 - else - Ranking[i] = #Scores - end - end - - Party.SetRoundRanking(Ranking); - Scores = nil; - - return true; +--[[ + * 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$ + *]] + +function plugin_init() + register('party mode: 5000points', '1.00', 'USDX Team', 'http://www.UltrastarDeluxe.org'); + + require('Usdx.Party') + require('Usdx.ScreenSing'); + + local Mode = {} + + Mode.Name = '5000points' + Mode.CanNonParty = true; + Mode.CanParty = true; + Mode.OnSing = 'Sing'; + Mode.AfterSing = 'Calculate_Winner'; + + Usdx.Party.Register(Mode) + + return true; +end + +function Sing() + Scores = ScreenSing.GetScores(); + + for i = 1, #Scores do + if (Scores[i] >= 5000) then + ScreenSing.Finish(); + break; + end + end + + return true; +end + +function Calculate_Winner() + Scores = Scores or ScreenSing.GetScores(); + local Ranking = {}; + for i = 1, #Scores do + if Scores[i] >= 5000 then + Ranking[i] = 1 + else + Ranking[i] = #Scores + end + end + + Party.SetRoundRanking(Ranking); + Scores = nil; + + return true; end \ No newline at end of file diff --git a/game/plugins/blind.usdx b/game/plugins/blind.usdx index 73bbd98d..74f42aa8 100644 --- a/game/plugins/blind.usdx +++ b/game/plugins/blind.usdx @@ -1,53 +1,53 @@ ---[[ - * 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$ - *]] - -function plugin_init() - register('party mode: blind', '1.00', 'USDX Team', 'http://www.UltrastarDeluxe.org'); - - require('Usdx.Party') - require('Usdx.ScreenSing') - - local Mode = {} - - Mode.Name = 'Blind' - Mode.CanNonParty = true; - Mode.CanParty = true; - - Mode.BeforeSing = 'BeforeSing'; - - Usdx.Party.Register(Mode) - - return true; -end - -function BeforeSing() - local Settings = {}; - Settings['NotesVisible'] = {}; -- notes hidden for every player - - ScreenSing.SetSettings(Settings); - - return true; +--[[ + * 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$ + *]] + +function plugin_init() + register('party mode: blind', '1.00', 'USDX Team', 'http://www.UltrastarDeluxe.org'); + + require('Usdx.Party') + require('Usdx.ScreenSing') + + local Mode = {} + + Mode.Name = 'Blind' + Mode.CanNonParty = true; + Mode.CanParty = true; + + Mode.BeforeSing = 'BeforeSing'; + + Usdx.Party.Register(Mode) + + return true; +end + +function BeforeSing() + local Settings = {}; + Settings['NotesVisible'] = {}; -- notes hidden for every player + + ScreenSing.SetSettings(Settings); + + return true; end \ No newline at end of file diff --git a/game/plugins/duel.usdx b/game/plugins/duel.usdx index 596aa270..ccc2f7aa 100644 --- a/game/plugins/duel.usdx +++ b/game/plugins/duel.usdx @@ -1,41 +1,41 @@ ---[[ - * 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$ - *]] - -function plugin_init() - register('party mode: duel', '1.00', 'USDX Team', 'http://www.UltrastarDeluxe.org'); - - require('Usdx.Party') - - local Mode = {} - - Mode.Name = 'Duel' - Mode.CanNonParty = true; - Mode.CanParty = true; - - Usdx.Party.Register(Mode) - - return true; +--[[ + * 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$ + *]] + +function plugin_init() + register('party mode: duel', '1.00', 'USDX Team', 'http://www.UltrastarDeluxe.org'); + + require('Usdx.Party') + + local Mode = {} + + Mode.Name = 'Duel' + Mode.CanNonParty = true; + Mode.CanParty = true; + + Usdx.Party.Register(Mode) + + return true; end \ No newline at end of file diff --git a/game/plugins/holdtheline.usdx b/game/plugins/holdtheline.usdx index 85a57d21..6f1def92 100644 --- a/game/plugins/holdtheline.usdx +++ b/game/plugins/holdtheline.usdx @@ -1,219 +1,219 @@ ---[[ - * 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: https://ultrastardx.svn.sourceforge.net/svnroot/ultrastardx/trunk/game/plugins/holdtheline.usdx $ - * $Id: holdtheline.usdx 2258 2010-06-17 17:30:16Z b_krueger $ - *]] - ---Configuration --- limit to get -local startRatingLimit = 0; --percentage : from 0 to 1 , eg. 0.1 -local fullRatingLimit = 1; --percentage : from 0 to 1 , eg. 0.95 -local ratingLimit = startRatingLimit; - --- percentage of the song-time, to need the full rating ( [start.beat + line.length] of the last line is the "end" of the song -local percentageToFullRating = 0.75; --percentage : from 0 to 1 , eg. 0.75 - --- position of big progress bar in the center -local Indicator = {}; -Indicator.Width = 10; --pixles -Indicator.Height = 10; --pixles - ---Do not Change a Line if ya do not know what ya doing! --- scoring -local scores = {}; -local lastDissmissedNo; -local dissmissedCount; - - -function plugin_init() - register('party mode: holdtheline', '0.6', 'USDX Team', 'http://www.UltrastarDeluxe.org'); - - require('math', 'Usdx.Party', 'Usdx.ScreenSing', 'Usdx.Gl', 'Usdx.TextGl'); - local Mode = {} - - Mode.Name = 'holdtheline'; - Mode.CanParty = true; - Mode.PlayerCount = {1,2,3,4,5,6}; - - Mode.BeforeSing = 'BeforeSing' - Mode.OnSing = 'Sing'; - Mode.AfterSing = 'Finish'; - - Usdx.Party.Register(Mode); - - return true; -end - - -function BeforeSing() - hSongLoaded = Usdx.Hook('ScreenSing.SongLoaded', 'Prepare'); - hDraw = Usdx.Hook('Display.Draw', 'Draw'); - - return true; -end; - - -function Prepare() - - -- get beat-sum of the whole song - local Lines = ScreenSing.GetSongLines(); - local lastNote = Lines[#Lines].Notes[#Lines[#Lines].Notes]; - TotalBeats = lastNote.Start + lastNote.Length; - - -- calculate OSD position for players - do - local RBRect = ScreenSing.GetRBRect(); - OSD = {}; - - for i = 1, #RBRect do - OSD[i] = {}; - OSD[i].Left = RBRect[i].x; - OSD[i].Right = RBRect[i].x + RBRect[i].w; - OSD[i].Top = RBRect[i].y + RBRect[i].h; - OSD[i].Bottom = RBRect[i].y + RBRect[i].h + math.max(RBRect[i].h, 13); - scores[i] = false; - end; - end; - - --fill some Vars with values - Teams = Party.GetTeams(); --team-infos - lastDissmissedNo = 1; --dismissed-runner - dissmissedCount = 0; --dismissed-counter - - -- remove hook - hSongLoaded:Unhook(); - hSongLoaded = nil; -end; - -function DrawPlayerIndicator(i) - Gl.Disable('GL_TEXTURE_2D'); - - local xOffset = ratingLimit * (OSD[i].Right - OSD[i].Left) - - -- background - Gl.Color (0, 1, 0, 1); - Gl.Begin('GL_QUADS'); - Gl.Vertex(OSD[i].Left+xOffset-(Indicator.Width/2), OSD[i].Top+Indicator.Height); - Gl.Vertex(OSD[i].Left+xOffset, OSD[i].Top); - Gl.Vertex(OSD[i].Left+xOffset, OSD[i].Top); - Gl.Vertex(OSD[i].Left+xOffset+(Indicator.Width/2), OSD[i].Top+Indicator.Height); - Gl.End(); -end; - -function DrawOut(i) - Gl.Disable('GL_TEXTURE_2D'); - - local Text = ' OUT '; - - -- text - Gl.Color(1, 0, 0, 1); - TextGl.Size(18); - TextGl.Style(1); - TextGl.Italic(false); - local PosX = (OSD[i].Left + OSD[i].Right) / 2; - PosX = PosX - TextGl.Width(Text) / 2; - TextGl.Pos(PosX, OSD[i].Top - 3); - TextGl.Print(Text); - -end; - - -function Finish() - - -- remove hook - hDraw:Unhook(); - --hDraw = nil; - - if dissmissedCount >= (#Teams-1) then - --calculate scoring out of the dissmissed-order - local Ranking = {}; - for i = 1, #Teams do - if (type(scores[i]) == "boolean") then - Ranking[i] = 1; - else - Ranking[i] = #Teams - scores[i] + 1; - end; - end; - - Party.SetRoundRanking(Ranking); - end; - - return (dissmissedCount < (#Teams-1)); -end; - - -function Draw() - for i = 1, #Teams do - if scores[i] == false then - DrawPlayerIndicator(i); - else - --todo: draw dismissed-texture OVER the scoreing as a stamp or sth else - DrawOut(i); - end; - end; -end; - - -function Sing() - local Ratings = Usdx.ScreenSing.GetRating(); - local finished = true; - local dismissedAPlayer = false; - - -- calculate the x-offset of the indicator (ratingLimit) - local currentBeat = ScreenSing.GetBeat(); - - if (currentBeat<0) then - ratingLimit = startRatingLimit; - elseif (currentBeat <= (TotalBeats*percentageToFullRating)) then - ratingLimit = ((fullRatingLimit-startRatingLimit) / (TotalBeats*percentageToFullRating)) * currentBeat + startRatingLimit; - else - ratingLimit = fullRatingLimit; - end; - - for i = 1, #Teams do - if scores[i] == false then - --player no. i is still in game - if Ratings[i] >= ratingLimit then - finished = false; - else - --todo: play dismissed-sound - --todo: disable player i (bars from player i) - dismissedAPlayer = true; - dissmissedCount = dissmissedCount + 1; - scores[i] = lastDissmissedNo; - end; - end; - end; - - --if more than one player is dismissed in one round, - --this guarantees correct scoring - if dismissedAPlayer == true then - lastDissmissedNo = lastDissmissedNo + 1; - end; - - --if only one player is in game, this round is finished - if dissmissedCount >= (#Teams-1) then - ScreenSing.Finish(); - end; - +--[[ + * 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: https://ultrastardx.svn.sourceforge.net/svnroot/ultrastardx/trunk/game/plugins/holdtheline.usdx $ + * $Id: holdtheline.usdx 2258 2010-06-17 17:30:16Z b_krueger $ + *]] + +--Configuration +-- limit to get +local startRatingLimit = 0; --percentage : from 0 to 1 , eg. 0.1 +local fullRatingLimit = 1; --percentage : from 0 to 1 , eg. 0.95 +local ratingLimit = startRatingLimit; + +-- percentage of the song-time, to need the full rating ( [start.beat + line.length] of the last line is the "end" of the song +local percentageToFullRating = 0.75; --percentage : from 0 to 1 , eg. 0.75 + +-- position of big progress bar in the center +local Indicator = {}; +Indicator.Width = 10; --pixles +Indicator.Height = 10; --pixles + +--Do not Change a Line if ya do not know what ya doing! +-- scoring +local scores = {}; +local lastDissmissedNo; +local dissmissedCount; + + +function plugin_init() + register('party mode: holdtheline', '0.6', 'USDX Team', 'http://www.UltrastarDeluxe.org'); + + require('math', 'Usdx.Party', 'Usdx.ScreenSing', 'Usdx.Gl', 'Usdx.TextGl'); + local Mode = {} + + Mode.Name = 'holdtheline'; + Mode.CanParty = true; + Mode.PlayerCount = {1,2,3,4,5,6}; + + Mode.BeforeSing = 'BeforeSing' + Mode.OnSing = 'Sing'; + Mode.AfterSing = 'Finish'; + + Usdx.Party.Register(Mode); + + return true; +end + + +function BeforeSing() + hSongLoaded = Usdx.Hook('ScreenSing.SongLoaded', 'Prepare'); + hDraw = Usdx.Hook('Display.Draw', 'Draw'); + + return true; +end; + + +function Prepare() + + -- get beat-sum of the whole song + local Lines = ScreenSing.GetSongLines(); + local lastNote = Lines[#Lines].Notes[#Lines[#Lines].Notes]; + TotalBeats = lastNote.Start + lastNote.Length; + + -- calculate OSD position for players + do + local RBRect = ScreenSing.GetRBRect(); + OSD = {}; + + for i = 1, #RBRect do + OSD[i] = {}; + OSD[i].Left = RBRect[i].x; + OSD[i].Right = RBRect[i].x + RBRect[i].w; + OSD[i].Top = RBRect[i].y + RBRect[i].h; + OSD[i].Bottom = RBRect[i].y + RBRect[i].h + math.max(RBRect[i].h, 13); + scores[i] = false; + end; + end; + + --fill some Vars with values + Teams = Party.GetTeams(); --team-infos + lastDissmissedNo = 1; --dismissed-runner + dissmissedCount = 0; --dismissed-counter + + -- remove hook + hSongLoaded:Unhook(); + hSongLoaded = nil; +end; + +function DrawPlayerIndicator(i) + Gl.Disable('GL_TEXTURE_2D'); + + local xOffset = ratingLimit * (OSD[i].Right - OSD[i].Left) + + -- background + Gl.Color (0, 1, 0, 1); + Gl.Begin('GL_QUADS'); + Gl.Vertex(OSD[i].Left+xOffset-(Indicator.Width/2), OSD[i].Top+Indicator.Height); + Gl.Vertex(OSD[i].Left+xOffset, OSD[i].Top); + Gl.Vertex(OSD[i].Left+xOffset, OSD[i].Top); + Gl.Vertex(OSD[i].Left+xOffset+(Indicator.Width/2), OSD[i].Top+Indicator.Height); + Gl.End(); +end; + +function DrawOut(i) + Gl.Disable('GL_TEXTURE_2D'); + + local Text = ' OUT '; + + -- text + Gl.Color(1, 0, 0, 1); + TextGl.Size(18); + TextGl.Style(1); + TextGl.Italic(false); + local PosX = (OSD[i].Left + OSD[i].Right) / 2; + PosX = PosX - TextGl.Width(Text) / 2; + TextGl.Pos(PosX, OSD[i].Top - 3); + TextGl.Print(Text); + +end; + + +function Finish() + + -- remove hook + hDraw:Unhook(); + --hDraw = nil; + + if dissmissedCount >= (#Teams-1) then + --calculate scoring out of the dissmissed-order + local Ranking = {}; + for i = 1, #Teams do + if (type(scores[i]) == "boolean") then + Ranking[i] = 1; + else + Ranking[i] = #Teams - scores[i] + 1; + end; + end; + + Party.SetRoundRanking(Ranking); + end; + + return (dissmissedCount < (#Teams-1)); +end; + + +function Draw() + for i = 1, #Teams do + if scores[i] == false then + DrawPlayerIndicator(i); + else + --todo: draw dismissed-texture OVER the scoreing as a stamp or sth else + DrawOut(i); + end; + end; +end; + + +function Sing() + local Ratings = Usdx.ScreenSing.GetRating(); + local finished = true; + local dismissedAPlayer = false; + + -- calculate the x-offset of the indicator (ratingLimit) + local currentBeat = ScreenSing.GetBeat(); + + if (currentBeat<0) then + ratingLimit = startRatingLimit; + elseif (currentBeat <= (TotalBeats*percentageToFullRating)) then + ratingLimit = ((fullRatingLimit-startRatingLimit) / (TotalBeats*percentageToFullRating)) * currentBeat + startRatingLimit; + else + ratingLimit = fullRatingLimit; + end; + + for i = 1, #Teams do + if scores[i] == false then + --player no. i is still in game + if Ratings[i] >= ratingLimit then + finished = false; + else + --todo: play dismissed-sound + --todo: disable player i (bars from player i) + dismissedAPlayer = true; + dissmissedCount = dissmissedCount + 1; + scores[i] = lastDissmissedNo; + end; + end; + end; + + --if more than one player is dismissed in one round, + --this guarantees correct scoring + if dismissedAPlayer == true then + lastDissmissedNo = lastDissmissedNo + 1; + end; + + --if only one player is in game, this round is finished + if dissmissedCount >= (#Teams-1) then + ScreenSing.Finish(); + end; + end; \ No newline at end of file diff --git a/game/plugins/teamduel.usdx b/game/plugins/teamduel.usdx index 68e91da3..254f67a6 100644 --- a/game/plugins/teamduel.usdx +++ b/game/plugins/teamduel.usdx @@ -1,258 +1,258 @@ ---[[ - * 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$ - *]] - --- some values to adjust the creation of PlayerChanges -local MinPercentage = 0.06; -- minimal amount of points between changes (in percent) -local MaxPercentage = 0.12; -- maximal amount of points between changes (in percent) --- position of big progress bar in the center -local BarPos = {}; -BarPos.Top = 30 -BarPos.Bottom = 50 -BarPos.Left = 300 -BarPos.Right = 500 - -function plugin_init() - register('party mode: teamduel', '1.00', 'USDX Team', 'http://www.UltrastarDeluxe.org'); - - require('math', 'Usdx.Party', 'Usdx.ScreenSing', 'Usdx.Gl', 'Usdx.TextGl'); - local Mode = {} - - Mode.Name = 'teamduel'; - Mode.CanParty = true; - Mode.PlayerCount = {2,3,4,5,6}; - - Mode.BeforeSing = 'BeforeSing' - Mode.OnSing = 'Sing'; - - Usdx.Party.Register(Mode) - - ScreenSing.GetBeat(); - - return true; -end - --- called everytime a singing session w/ this party mode is startet --- we just hook ScreenSing.SongLoaded to prepare the mic changes here -function BeforeSing() - hSongLoaded = Usdx.Hook('ScreenSing.SongLoaded', 'PrepareChanges'); - - -- execute default action (e.g. set correct singing playercount) - return true -end; - --- adds a new SentenceChange at Line to the PlayerChanges array -function AddChange(Line) - PlayerChanges[#PlayerChanges + 1] = {}; - PlayerChanges[#PlayerChanges].OnBeat = Lines[Line].Start; - - PlayerChanges[#PlayerChanges].NextPlayer = {} - for i = 1, #Teams do - repeat - PlayerChanges[#PlayerChanges].NextPlayer[i] = math.random(#Teams[i].Players); - until (1 == #PlayerChanges) or (PlayerChanges[#PlayerChanges].NextPlayer[i] ~= PlayerChanges[#PlayerChanges-1].NextPlayer[i]) or (#Teams[i].Players == 1); - end; -end; - -function PrepareChanges() - Lines = ScreenSing.GetSongLines(); - Teams = Party.GetTeams(); - - -- get sum of hittable beats (per line and total) - local TotalBeats = 0; - local LineValue = {}; - for i = 1, #Lines do - for j = 1, #Lines[i].Notes do - LineValue[i] = (LineValue[i] or 0) + Lines[i].Notes[j].Length * Lines[i].Notes[j].NoteType; - end; - TotalBeats = TotalBeats + LineValue[i]; - end; - - -- calculate changes - PlayerChanges = {}; - -- fallback if there are only freestyle notes - -- random count of lines between changes - if (TotalBeats == 0) then - local i = 1; - repeat - if i > 1 then - AddChange(i); - end - - local step = math.ceil((MinPercentage + (MaxPercentage - MinPercentage) * math.random()) * #Lines); - if step < 1 then - step = 1; - end; - - i = i + step; - until i >= #Lines; - else -- calculate changes by amount of hittable beats - local i = 1; - local BeatsToChange = math.ceil((MinPercentage + (MaxPercentage - MinPercentage) * math.random()) * TotalBeats); - local Beats = 0; - - repeat - Beats = Beats + LineValue[i]; - if Beats >= BeatsToChange then - AddChange(i); - BeatsToChange = BeatsToChange + math.ceil((MinPercentage + (MaxPercentage - MinPercentage) * math.random()) * TotalBeats); - end - i = i + 1; - until i >= #Lines; - end; - - -- free lines - Lines = nil; - - -- init NextPlayerChange - NextPlayerChange = 1; - - -- calculate OSD position for players - do - local RBRect = ScreenSing.GetRBRect(); - OSD = {}; - - for i = 1, #RBRect do - OSD[i] = {}; - OSD[i].Left = RBRect[i].x; - OSD[i].Right = RBRect[i].x + RBRect[i].w; - OSD[i].Top = RBRect[i].y + RBRect[i].h; - OSD[i].Bottom = RBRect[i].y + RBRect[i].h + math.max(RBRect[i].h, 13); - end; - end; - - -- remove hook - hSongLoaded:Unhook(); - hSongLoaded = nil; -end - -function DrawPlayerText(i, Text) - Gl.Disable('GL_TEXTURE_2D'); - - -- background - Gl.Color (0, 0, 0, 1); - Gl.Begin('GL_QUADS'); - Gl.Vertex(OSD[i].Left, OSD[i].Top); - Gl.Vertex(OSD[i].Left, OSD[i].Bottom); - Gl.Vertex(OSD[i].Right, OSD[i].Bottom); - Gl.Vertex(OSD[i].Right, OSD[i].Top); - Gl.End(); - - -- text - Gl.Color(1, 0, 0, 1); - TextGl.Style(1); - TextGl.Size(18); - TextGl.Italic(false); - local PosX = (OSD[i].Left + OSD[i].Right) / 2; - PosX = PosX - TextGl.Width(Text) / 2; - - TextGl.Pos(PosX, OSD[i].Top - 3); - - TextGl.Print(Text); -end; - --- draws the progress bar for player i -function DrawPlayerProgress(i, Progress) - Gl.Disable('GL_TEXTURE_2D'); - - -- background - Gl.Color (0, 0, 0, 1); - Gl.Begin('GL_QUADS'); - Gl.Vertex(OSD[i].Left, OSD[i].Top); - Gl.Vertex(OSD[i].Left, OSD[i].Bottom); - Gl.Vertex(OSD[i].Right, OSD[i].Bottom); - Gl.Vertex(OSD[i].Right, OSD[i].Top); - Gl.End(); - - -- bar - Gl.Color(1, 0, 0, 1); - Gl.Begin('GL_QUADS'); - Gl.Vertex(OSD[i].Left + 2, OSD[i].Top + 2); - Gl.Vertex(OSD[i].Left + 2, OSD[i].Bottom - 2); - Gl.Vertex(OSD[i].Left + 2 + (OSD[i].Right - OSD[i].Left - 4) * Progress, OSD[i].Bottom - 2); - Gl.Vertex(OSD[i].Left + 2 + (OSD[i].Right - OSD[i].Left - 4) * Progress, OSD[i].Top + 2); - Gl.End(); -end; - --- draws the big progress bar in the screen center -function DrawCenterProgress(Progress) - Gl.Disable('GL_TEXTURE_2D'); - - -- background - Gl.Color (0, 0, 0, 1); - Gl.Begin('GL_QUADS'); - Gl.Vertex(BarPos.Left, BarPos.Top); - Gl.Vertex(BarPos.Left, BarPos.Bottom); - Gl.Vertex(BarPos.Right, BarPos.Bottom); - Gl.Vertex(BarPos.Right, BarPos.Top); - Gl.End(); - - -- bar - Gl.Color(1, 0, 0, 1); - Gl.Begin('GL_QUADS'); - Gl.Vertex(BarPos.Left + 2, BarPos.Top + 2); - Gl.Vertex(BarPos.Left + 2, BarPos.Bottom - 2); - Gl.Vertex(BarPos.Left + 2 + (BarPos.Right - BarPos.Left - 4) * Progress, BarPos.Bottom - 2); - Gl.Vertex(BarPos.Left + 2 + (BarPos.Right - BarPos.Left - 4) * Progress, BarPos.Top + 2); - Gl.End(); -end; - -function Sing() - if (NextPlayerChange <= #PlayerChanges) then - local BeatsToNextChange = PlayerChanges[NextPlayerChange].OnBeat - ScreenSing.GetBeat(); - local TimeToNextChange = ScreenSing.BeatsToSeconds(BeatsToNextChange); - - -- draw next player text or progress bar - if (TimeToNextChange <= 0) then - --there is a change - NextPlayerChange = NextPlayerChange + 1; - - elseif (TimeToNextChange <= 5) then - for i = 1, #Teams do - DrawPlayerProgress(i, 1 - TimeToNextChange/5); - end; - elseif (TimeToNextChange <= 6.5) then - for i = 1, #Teams do - DrawPlayerText(i, Teams[i].Players[PlayerChanges[NextPlayerChange].NextPlayer[i]].Name); - end; - elseif (TimeToNextChange <= 8) then - for i = 1, #Teams do - DrawPlayerText(i, 'Next Player'); - end; - elseif (TimeToNextChange <= 9.5) then - for i = 1, #Teams do - DrawPlayerText(i, Teams[i].Players[PlayerChanges[NextPlayerChange].NextPlayer[i]].Name); - end; - elseif (TimeToNextChange <= 11) then - for i = 1, #Teams do - DrawPlayerText(i, 'Next Player'); - end; - end - - if (TimeToNextChange <= 11) then - DrawCenterProgress(1 - TimeToNextChange/11); - end; - end; +--[[ + * 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$ + *]] + +-- some values to adjust the creation of PlayerChanges +local MinPercentage = 0.06; -- minimal amount of points between changes (in percent) +local MaxPercentage = 0.12; -- maximal amount of points between changes (in percent) +-- position of big progress bar in the center +local BarPos = {}; +BarPos.Top = 30 +BarPos.Bottom = 50 +BarPos.Left = 300 +BarPos.Right = 500 + +function plugin_init() + register('party mode: teamduel', '1.00', 'USDX Team', 'http://www.UltrastarDeluxe.org'); + + require('math', 'Usdx.Party', 'Usdx.ScreenSing', 'Usdx.Gl', 'Usdx.TextGl'); + local Mode = {} + + Mode.Name = 'teamduel'; + Mode.CanParty = true; + Mode.PlayerCount = {2,3,4,5,6}; + + Mode.BeforeSing = 'BeforeSing' + Mode.OnSing = 'Sing'; + + Usdx.Party.Register(Mode) + + ScreenSing.GetBeat(); + + return true; +end + +-- called everytime a singing session w/ this party mode is startet +-- we just hook ScreenSing.SongLoaded to prepare the mic changes here +function BeforeSing() + hSongLoaded = Usdx.Hook('ScreenSing.SongLoaded', 'PrepareChanges'); + + -- execute default action (e.g. set correct singing playercount) + return true +end; + +-- adds a new SentenceChange at Line to the PlayerChanges array +function AddChange(Line) + PlayerChanges[#PlayerChanges + 1] = {}; + PlayerChanges[#PlayerChanges].OnBeat = Lines[Line].Start; + + PlayerChanges[#PlayerChanges].NextPlayer = {} + for i = 1, #Teams do + repeat + PlayerChanges[#PlayerChanges].NextPlayer[i] = math.random(#Teams[i].Players); + until (1 == #PlayerChanges) or (PlayerChanges[#PlayerChanges].NextPlayer[i] ~= PlayerChanges[#PlayerChanges-1].NextPlayer[i]) or (#Teams[i].Players == 1); + end; +end; + +function PrepareChanges() + Lines = ScreenSing.GetSongLines(); + Teams = Party.GetTeams(); + + -- get sum of hittable beats (per line and total) + local TotalBeats = 0; + local LineValue = {}; + for i = 1, #Lines do + for j = 1, #Lines[i].Notes do + LineValue[i] = (LineValue[i] or 0) + Lines[i].Notes[j].Length * Lines[i].Notes[j].NoteType; + end; + TotalBeats = TotalBeats + LineValue[i]; + end; + + -- calculate changes + PlayerChanges = {}; + -- fallback if there are only freestyle notes + -- random count of lines between changes + if (TotalBeats == 0) then + local i = 1; + repeat + if i > 1 then + AddChange(i); + end + + local step = math.ceil((MinPercentage + (MaxPercentage - MinPercentage) * math.random()) * #Lines); + if step < 1 then + step = 1; + end; + + i = i + step; + until i >= #Lines; + else -- calculate changes by amount of hittable beats + local i = 1; + local BeatsToChange = math.ceil((MinPercentage + (MaxPercentage - MinPercentage) * math.random()) * TotalBeats); + local Beats = 0; + + repeat + Beats = Beats + LineValue[i]; + if Beats >= BeatsToChange then + AddChange(i); + BeatsToChange = BeatsToChange + math.ceil((MinPercentage + (MaxPercentage - MinPercentage) * math.random()) * TotalBeats); + end + i = i + 1; + until i >= #Lines; + end; + + -- free lines + Lines = nil; + + -- init NextPlayerChange + NextPlayerChange = 1; + + -- calculate OSD position for players + do + local RBRect = ScreenSing.GetRBRect(); + OSD = {}; + + for i = 1, #RBRect do + OSD[i] = {}; + OSD[i].Left = RBRect[i].x; + OSD[i].Right = RBRect[i].x + RBRect[i].w; + OSD[i].Top = RBRect[i].y + RBRect[i].h; + OSD[i].Bottom = RBRect[i].y + RBRect[i].h + math.max(RBRect[i].h, 13); + end; + end; + + -- remove hook + hSongLoaded:Unhook(); + hSongLoaded = nil; +end + +function DrawPlayerText(i, Text) + Gl.Disable('GL_TEXTURE_2D'); + + -- background + Gl.Color (0, 0, 0, 1); + Gl.Begin('GL_QUADS'); + Gl.Vertex(OSD[i].Left, OSD[i].Top); + Gl.Vertex(OSD[i].Left, OSD[i].Bottom); + Gl.Vertex(OSD[i].Right, OSD[i].Bottom); + Gl.Vertex(OSD[i].Right, OSD[i].Top); + Gl.End(); + + -- text + Gl.Color(1, 0, 0, 1); + TextGl.Style(1); + TextGl.Size(18); + TextGl.Italic(false); + local PosX = (OSD[i].Left + OSD[i].Right) / 2; + PosX = PosX - TextGl.Width(Text) / 2; + + TextGl.Pos(PosX, OSD[i].Top - 3); + + TextGl.Print(Text); +end; + +-- draws the progress bar for player i +function DrawPlayerProgress(i, Progress) + Gl.Disable('GL_TEXTURE_2D'); + + -- background + Gl.Color (0, 0, 0, 1); + Gl.Begin('GL_QUADS'); + Gl.Vertex(OSD[i].Left, OSD[i].Top); + Gl.Vertex(OSD[i].Left, OSD[i].Bottom); + Gl.Vertex(OSD[i].Right, OSD[i].Bottom); + Gl.Vertex(OSD[i].Right, OSD[i].Top); + Gl.End(); + + -- bar + Gl.Color(1, 0, 0, 1); + Gl.Begin('GL_QUADS'); + Gl.Vertex(OSD[i].Left + 2, OSD[i].Top + 2); + Gl.Vertex(OSD[i].Left + 2, OSD[i].Bottom - 2); + Gl.Vertex(OSD[i].Left + 2 + (OSD[i].Right - OSD[i].Left - 4) * Progress, OSD[i].Bottom - 2); + Gl.Vertex(OSD[i].Left + 2 + (OSD[i].Right - OSD[i].Left - 4) * Progress, OSD[i].Top + 2); + Gl.End(); +end; + +-- draws the big progress bar in the screen center +function DrawCenterProgress(Progress) + Gl.Disable('GL_TEXTURE_2D'); + + -- background + Gl.Color (0, 0, 0, 1); + Gl.Begin('GL_QUADS'); + Gl.Vertex(BarPos.Left, BarPos.Top); + Gl.Vertex(BarPos.Left, BarPos.Bottom); + Gl.Vertex(BarPos.Right, BarPos.Bottom); + Gl.Vertex(BarPos.Right, BarPos.Top); + Gl.End(); + + -- bar + Gl.Color(1, 0, 0, 1); + Gl.Begin('GL_QUADS'); + Gl.Vertex(BarPos.Left + 2, BarPos.Top + 2); + Gl.Vertex(BarPos.Left + 2, BarPos.Bottom - 2); + Gl.Vertex(BarPos.Left + 2 + (BarPos.Right - BarPos.Left - 4) * Progress, BarPos.Bottom - 2); + Gl.Vertex(BarPos.Left + 2 + (BarPos.Right - BarPos.Left - 4) * Progress, BarPos.Top + 2); + Gl.End(); +end; + +function Sing() + if (NextPlayerChange <= #PlayerChanges) then + local BeatsToNextChange = PlayerChanges[NextPlayerChange].OnBeat - ScreenSing.GetBeat(); + local TimeToNextChange = ScreenSing.BeatsToSeconds(BeatsToNextChange); + + -- draw next player text or progress bar + if (TimeToNextChange <= 0) then + --there is a change + NextPlayerChange = NextPlayerChange + 1; + + elseif (TimeToNextChange <= 5) then + for i = 1, #Teams do + DrawPlayerProgress(i, 1 - TimeToNextChange/5); + end; + elseif (TimeToNextChange <= 6.5) then + for i = 1, #Teams do + DrawPlayerText(i, Teams[i].Players[PlayerChanges[NextPlayerChange].NextPlayer[i]].Name); + end; + elseif (TimeToNextChange <= 8) then + for i = 1, #Teams do + DrawPlayerText(i, 'Next Player'); + end; + elseif (TimeToNextChange <= 9.5) then + for i = 1, #Teams do + DrawPlayerText(i, Teams[i].Players[PlayerChanges[NextPlayerChange].NextPlayer[i]].Name); + end; + elseif (TimeToNextChange <= 11) then + for i = 1, #Teams do + DrawPlayerText(i, 'Next Player'); + end; + end + + if (TimeToNextChange <= 11) then + DrawCenterProgress(1 - TimeToNextChange/11); + end; + end; end \ No newline at end of file -- cgit v1.2.3