aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-04-04 17:34:31 +0000
committerbrunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-04-04 17:34:31 +0000
commitaa006bc319af1af81c5c703209ba81f4f517fc77 (patch)
tree33afaafcd9e1635ce4c1d349d800a96c0fa705af
parent19702a2272a014fe62256b1ddfd8f5068feb35d0 (diff)
downloadusdx-aa006bc319af1af81c5c703209ba81f4f517fc77.tar.gz
usdx-aa006bc319af1af81c5c703209ba81f4f517fc77.tar.xz
usdx-aa006bc319af1af81c5c703209ba81f4f517fc77.zip
*NEW: Press Left-Ctrl + * (* on Numpad) or Left-Ctrl + R to Shuffle Player Names in Classic Party Mode "Team- and Player Names"-Screen
*NEW: Set "NewPartyPoints" in config.ini to "On" to give Winner Team 2Points and 2nd placed Team 1Point while playing with 3 Teams (default=on) thx to merc! git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1 Challenge MOD@2214 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rw-r--r--Game/Code/Classes/UIni.pas13
-rw-r--r--Game/Code/Classes/UParty.pas41
-rw-r--r--Game/Code/Classes/UVideo.pas4
-rw-r--r--Game/Code/Screens/UScreenPartyPlayer.pas207
4 files changed, 249 insertions, 16 deletions
diff --git a/Game/Code/Classes/UIni.pas b/Game/Code/Classes/UIni.pas
index df291ec3..e5891f58 100644
--- a/Game/Code/Classes/UIni.pas
+++ b/Game/Code/Classes/UIni.pas
@@ -23,6 +23,7 @@ type
Sorting: integer;
Debug: integer;
LoadFaultySongs:integer;
+ NewPartyPoints: integer;
// Graphics
Screens: integer;
@@ -122,6 +123,7 @@ const
IDebug: array[0..1] of string = ('Off', 'On');
ILoadFaultySongs: array[0..1] of string = ('Off', 'On');
+ INewPartyPoints: array[0..1] of string = ('Off', 'On');
IScreens: array[0..1] of string = ('1', '2');
IFullScreen: array[0..1] of string = ('Off', 'On');
@@ -257,6 +259,11 @@ begin
for Pet := 0 to High(ILoadFaultySongs) do
if Tekst = ILoadFaultySongs[Pet] then Ini.LoadFaultySongs := Pet;
+ // NewPartyPoints
+ Tekst := IniFile.ReadString('Game', 'NewPartyPoints', INewPartyPoints[1]);
+ for Pet := 0 to High(INewPartyPoints) do
+ if Tekst = INewPartyPoints[Pet] then Ini.NewPartyPoints := Pet;
+
//if Ini.Debug = 1 then SongPath := 'E:\UltraStar 03\Songs\';
// Screens
@@ -645,6 +652,10 @@ begin
Tekst := ILoadFaultySongs[Ini.LoadFaultySongs];
IniFile.WriteString('Game', 'LoadFaultySongs', Tekst);
+ // NewPartyPoints
+ Tekst := INewPartyPoints[Ini.NewPartyPoints];
+ IniFile.WriteString('Game', 'NewPartyPoints', Tekst);
+
// Screens
Tekst := IScreens[Ini.Screens];
IniFile.WriteString('Graphics', 'Screens', Tekst);
@@ -849,4 +860,4 @@ begin
end;
end;
-end.
+end. \ No newline at end of file
diff --git a/Game/Code/Classes/UParty.pas b/Game/Code/Classes/UParty.pas
index a843c393..db0328aa 100644
--- a/Game/Code/Classes/UParty.pas
+++ b/Game/Code/Classes/UParty.pas
@@ -2,7 +2,7 @@ unit UParty;
interface
-uses ModiSDK;
+uses ModiSDK, UIni;
type
TRoundInfo = record
@@ -53,6 +53,7 @@ type
var
PartySession: TParty_Session;
+ Placings: Array [0..5] of Byte;
implementation
@@ -320,7 +321,7 @@ end;
//----------
procedure TParty_Session.EndRound;
var
- I, MaxScore: Integer;
+ I, J, MaxScore: Integer;
begin
//Copy Winner
if Rounds[CurRound].Medley then
@@ -362,8 +363,40 @@ begin
Rounds[CurRound].Winner := 0;
end else
Rounds[CurRound].Winner := ScreenSingModi.Winner;
+
//Set Scores
- GenScores;
+
+ if (Ini.NewPartyPoints = 1) then
+ begin
+
+ MaxScore := 0;
+ for I := 0 to ScreenSingModi.PlayerInfo.NumPlayers-1 do
+ if (ScreenSingModi.PlayerInfo.Playerinfo[I].Score > MaxScore) then
+ MaxScore := ScreenSingModi.PlayerInfo.Playerinfo[I].Score;
+
+
+ if (MaxScore > 0) then
+ begin
+ //New Points
+ //Get Placings
+ for I := 0 to Teams.NumTeams-1 do
+ begin
+ Placings[I] := 0;
+ for J := 0 to Teams.NumTeams-1 do
+ If (ScreenSingModi.PlayerInfo.Playerinfo[J].Score > ScreenSingModi.PlayerInfo.Playerinfo[I].Score) then
+ Inc(Placings[I]);
+ end;
+
+ for I := 0 to Teams.NumTeams-1 do
+ Teams.Teaminfo[I].Score := Teams.Teaminfo[I].Score + ((Placings[I] - (Teams.NumTeams-1)) * -1);
+ end
+ end
+ else
+ //Old Points
+ GenScores;
+
+
+
//Increase TimesPlayed 4 all Players
For I := 0 to Teams.NumTeams-1 do
@@ -402,4 +435,4 @@ begin
Result[I] := ATeams[I].TeamNum;
end;
-end.
+end. \ No newline at end of file
diff --git a/Game/Code/Classes/UVideo.pas b/Game/Code/Classes/UVideo.pas
index 68b892c8..b37166c1 100644
--- a/Game/Code/Classes/UVideo.pas
+++ b/Game/Code/Classes/UVideo.pas
@@ -158,7 +158,7 @@ begin
VideoTime := 0;
LastFrameTime := 0;
TimeDifference := 0;
-
+ Counter := 0;
acClose;
if not FileExists(FileName) then
@@ -546,7 +546,7 @@ begin
end else if (mmfps>75) then
begin
if(SkipLines>0) and (Counter<=100) then
- Counter := round(Counter+50/mmfps)
+ Counter := round(Counter+70/mmfps)
else if (SkipLines>0) and (Counter>=100) then
begin
Dec(SkipLines);
diff --git a/Game/Code/Screens/UScreenPartyPlayer.pas b/Game/Code/Screens/UScreenPartyPlayer.pas
index 750d8963..6c3000bb 100644
--- a/Game/Code/Screens/UScreenPartyPlayer.pas
+++ b/Game/Code/Screens/UScreenPartyPlayer.pas
@@ -3,9 +3,13 @@ unit UScreenPartyPlayer;
Interface
uses
- UMenu, SDL, UDisplay, UMusic, UFiles, SysUtils, UThemes;
+ UMenu, SDL, UDisplay, UMusic, UFiles, SysUtils, UThemes, Math;
type
+
+ TArrayElement = String;
+ TArray = array of TArrayElement;
+
TScreenPartyPlayer = class(TMenu)
public
Team1Name: Cardinal;
@@ -30,8 +34,11 @@ type
function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override;
procedure onShow; override;
procedure SetAnimationProgress(Progress: real); override;
+ procedure ShuffleNames(var aArray: TArray);
end;
+
+
const
ID='ID_016'; //for help system
@@ -41,8 +48,9 @@ uses UGraphic, UMain, UIni, UTexture, UParty, UHelp, ULog;
function TScreenPartyPlayer.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean;
var
- I, J: integer;
+ I, J, countPlayer: integer;
SDL_ModState: Word;
+ randomNames: TArray; //new for randomize names
procedure IntNext;
begin
repeat
@@ -55,14 +63,181 @@ var
InteractPrev;
until Button[Interaction].Visible;
end;
+
begin
+
Result := true;
If (PressedDown) Then
-
+ begin // Key Down
SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT
+ KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT);
+
+ if (SDL_ModState = KMOD_LCTRL) then
+ begin
+ case PressedKey of
+ //-------------------------------------randomize player names---------- mod by merc
+ // TODO: rewrite! (some for loops?)
+ SDLK_KP_MULTIPLY, SDLK_R:
+ begin
+
+ countPlayer := 0;
+ SetLength(randomNames, 12);
+
+ If (PartySession.Teams.NumTeams>=1) then
+ begin
+ If (PartySession.Teams.Teaminfo[0].NumPlayers >=1) then
+ begin
+ randomNames[countPlayer] := Button[1].Text[0].Text;
+ inc(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[0].NumPlayers >=2) then
+ begin
+ randomNames[countPlayer] := Button[2].Text[0].Text;
+ inc(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[0].NumPlayers >=3) then
+ begin
+ randomNames[countPlayer] := Button[3].Text[0].Text;
+ inc(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[0].NumPlayers >=4) then
+ begin
+ randomNames[countPlayer] := Button[4].Text[0].Text;
+ inc(countPlayer);
+ end;
+ end;
+
+ If (PartySession.Teams.NumTeams>=2) then
+ begin
+ If (PartySession.Teams.Teaminfo[1].NumPlayers >=1) then
+ begin
+ randomNames[countPlayer] := Button[6].Text[0].Text;
+ inc(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[1].NumPlayers >=2) then
+ begin
+ randomNames[countPlayer] := Button[7].Text[0].Text;
+ inc(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[1].NumPlayers >=3) then
+ begin
+ randomNames[countPlayer] := Button[8].Text[0].Text;
+ inc(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[1].NumPlayers >=4) then
+ begin
+ randomNames[countPlayer] := Button[9].Text[0].Text;
+ inc(countPlayer);
+ end;
+ end;
+
+ If (PartySession.Teams.NumTeams>=3) then
+ begin
+ If (PartySession.Teams.Teaminfo[2].NumPlayers >=1) then
+ begin
+ randomNames[countPlayer] := Button[11].Text[0].Text;
+ inc(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[2].NumPlayers >=2) then
+ begin
+ randomNames[countPlayer] := Button[12].Text[0].Text;
+ inc(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[2].NumPlayers >=3) then
+ begin
+ randomNames[countPlayer] := Button[13].Text[0].Text;
+ inc(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[2].NumPlayers >=4) then
+ begin
+ randomNames[countPlayer] := Button[14].Text[0].Text;
+ inc(countPlayer);
+ end;
+ end;
+
+ SetLength(randomNames, countPlayer);
+ ShuffleNames(randomNames);
+
+
+ //Write Names back to Players
+ dec(countPlayer);
+ If (PartySession.Teams.NumTeams>=1) then
+ begin
+ If (PartySession.Teams.Teaminfo[0].NumPlayers >=1) then
+ begin
+ Button[1].Text[0].Text := randomNames[countPlayer];
+ dec(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[0].NumPlayers >=2) then
+ begin
+ Button[2].Text[0].Text := randomNames[countPlayer];
+ dec(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[0].NumPlayers >=3) then
+ begin
+ Button[3].Text[0].Text := randomNames[countPlayer];
+ dec(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[0].NumPlayers >=4) then
+ begin
+ Button[4].Text[0].Text := randomNames[countPlayer];
+ dec(countPlayer);
+ end;
+ end;
+
+ If (PartySession.Teams.NumTeams>=2) then
+ begin
+ If (PartySession.Teams.Teaminfo[1].NumPlayers >=1) then
+ begin
+ Button[6].Text[0].Text := randomNames[countPlayer];
+ dec(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[1].NumPlayers >=2) then
+ begin
+ Button[7].Text[0].Text := randomNames[countPlayer];
+ dec(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[1].NumPlayers >=3) then
+ begin
+ Button[8].Text[0].Text := randomNames[countPlayer];
+ dec(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[1].NumPlayers >=4) then
+ begin
+ Button[9].Text[0].Text := randomNames[countPlayer];
+ dec(countPlayer);
+ end;
+ end;
+
+ If (PartySession.Teams.NumTeams>=3) then
+ begin
+ If (PartySession.Teams.Teaminfo[2].NumPlayers >=1) then
+ begin
+ Button[11].Text[0].Text := randomNames[countPlayer];
+ dec(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[2].NumPlayers >=2) then
+ begin
+ Button[12].Text[0].Text := randomNames[countPlayer];
+ dec(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[2].NumPlayers >=3) then
+ begin
+ Button[13].Text[0].Text := randomNames[countPlayer];
+ dec(countPlayer);
+ end;
+ If (PartySession.Teams.Teaminfo[2].NumPlayers >=4) then
+ begin
+ Button[14].Text[0].Text := randomNames[countPlayer];
+ //dec(countPlayer); useless...
+ end;
+ end;
+ end;
+ end;
+
+ end else
+ begin
- begin // Key Down
case PressedKey of
SDLK_TAB:
begin
@@ -78,7 +253,7 @@ begin
SDLK_F1:
if (SDL_ModState = KMOD_LALT) then
begin
- Ini.NameTemplate[0] := Button[Interaction].Text[0].Text;
+ Ini.NameTemplate[0] := Button[Interaction].Text[0].Text;
end
else
begin
@@ -223,11 +398,10 @@ begin
SDLK_LEFT: IntPrev;
end;
end;
+ end;
end;
constructor TScreenPartyPlayer.Create;
-var
- I: integer;
begin
inherited Create;
@@ -275,7 +449,8 @@ begin
Button[5].Text[0].Text := Ini.NameTeam[1];
Button[10].Text[0].Text := Ini.NameTeam[2];
// Templates for Names Mod end
-
+
+
If (PartySession.Teams.NumTeams>=1) then
begin
Button[0].Visible := True;
@@ -337,4 +512,18 @@ begin
Button[I].Texture.ScaleW := Progress;
end;
-end.
+ // perfektes Mischen nach Fisher-Yates (for randomize PlayerNames - merc)
+procedure TScreenPartyPlayer.ShuffleNames(var aArray: TArray);
+ var
+ i,j: Integer;
+ tmp: TArrayElement;
+begin
+ for i := Low(aArray) to High(aArray) do begin
+ j := i +Random(Length(aArray) -i +Low(aArray));
+ tmp := aArray[j];
+ aArray[j] := aArray[i];
+ aArray[i] := tmp;
+ end;
+end;
+
+end. \ No newline at end of file