diff options
author | whiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-12-15 18:24:48 +0000 |
---|---|---|
committer | whiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-12-15 18:24:48 +0000 |
commit | 0af8fe6180f31951badfd19f0bb7a2adece85ba4 (patch) | |
tree | b31dea3de76101b5c784574c189ffafbb4df0279 /Lua/src/base/UParty.pas | |
parent | 70cb63e5b4a7ce1b06ceceac92ddf623473301ab (diff) | |
download | usdx-0af8fe6180f31951badfd19f0bb7a2adece85ba4.tar.gz usdx-0af8fe6180f31951badfd19f0bb7a2adece85ba4.tar.xz usdx-0af8fe6180f31951badfd19f0bb7a2adece85ba4.zip |
- added ScreenPartyRounds (a screen to select the modes to play)
- added missing language entries to German and English language file
- themed ScreenPartyOptions
- some minor theme changes concerning party screens
- some minor code changes concerning party screens
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@2039 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Lua/src/base/UParty.pas')
-rw-r--r-- | Lua/src/base/UParty.pas | 97 |
1 files changed, 76 insertions, 21 deletions
diff --git a/Lua/src/base/UParty.pas b/Lua/src/base/UParty.pas index e4060e95..94580241 100644 --- a/Lua/src/base/UParty.pas +++ b/Lua/src/base/UParty.pas @@ -48,7 +48,13 @@ type Team: Integer; //< id of team Rank: Integer; //< 1 to Length(Teams) e.g. 1 is for placed first end; - AParty_TeamRanking = Array of TParty_TeamRanking; //< returned by TPartyGame.GetTeamRanking + AParty_TeamRanking = array of TParty_TeamRanking; //< returned by TPartyGame.GetTeamRanking + + TParty_RoundList = record + Index: integer; + Name: UTF8String; + end; + AParty_ModeList = array of TParty_RoundList; { record used by TPartyGame to store round specific data } TParty_Round = record @@ -113,6 +119,9 @@ type function GetRandomMode: integer; function GetRandomPlayer(Team: integer): integer; + { returns true if a mode is playable with current playerconfig } + function ModePlayable(I: integer): boolean; + function CallLua(Parent: Integer; Func: String):Boolean; procedure SetRankingByScore; @@ -140,6 +149,10 @@ type if there are any party modes available } function ModesAvailable: Boolean; + { returns an array with the name of all available modes (that + are playable with current player configuration } + function GetAvailableModes: AParty_ModeList; + { clears all party specific data previously stored } procedure Clear; @@ -289,14 +302,17 @@ begin // search for the plugins less played yet for I := 0 to high(Modes) do begin - if (TimesPlayed[I] < lowestTP) then - begin - lowestTP := TimesPlayed[I]; - NumPwithLTP := 1; - end - else if (TimesPlayed[I] = lowestTP) then + if (ModePlayable(I)) then begin - Inc(NumPwithLTP); + if (TimesPlayed[I] < lowestTP) then + begin + lowestTP := TimesPlayed[I]; + NumPwithLTP := 1; + end + else if (TimesPlayed[I] = lowestTP) then + begin + Inc(NumPwithLTP); + end; end; end; @@ -306,7 +322,7 @@ begin // select the random mode from the modes with less timesplayed for I := 0 to high(Modes) do begin - if (TimesPlayed[I] = lowestTP) { and (((Modis[I].Info.LoadingSettings and MLS_TeamOnly) <> 0) = TeamMode) }then + if (TimesPlayed[I] = lowestTP) and (ModePlayable(I)) then begin //Plugin found if (R = 0) then @@ -436,14 +452,35 @@ begin end; end; +{ returns true if a mode is playable with current playerconfig } +function TPartyGame.ModePlayable(I: integer): boolean; + var + J: integer; +begin + if (Length(Teams) = 0) then + Result := true + else + begin + if (Modes[I].TeamCount and (1 shl (Length(Teams) - 1)) <> 0) then + begin + Result := true; + + for J := 0 to High(Teams) do + Result := Result and (Modes[I].PlayerCount and (1 shl (Length(Teams[J].Players) - 1)) <> 0); + end + else + Result := false; + end; +end; + { returns true if modes are available for players and teams that are currently set up. if there are no teams set up it returns if there are any party modes available } function TPartyGame.ModesAvailable: Boolean; var - I, J: Integer; - CountTeams: Integer; + I: integer; + CountTeams: integer; begin CountTeams := Length(Teams); if CountTeams = 0 then @@ -452,19 +489,37 @@ begin end else begin - Result := False; + Result := false; for I := 0 to High(Modes) do - if (Modes[I].TeamCount and (1 shl (CountTeams - 1)) <> 0) then - begin - Result := True; - - for J := 0 to High(Teams) do - Result := Result and (Modes[I].PlayerCount and (1 shl (Length(Teams[J].Players) - 1)) <> 0); + begin + Result := ModePlayable(I); - if Result then - Exit; - end; + if Result then + Exit; + end; end; +end; + +{ returns an array with the name of all available modes (that + are playable with current player configuration } +function TPartyGame.GetAvailableModes: AParty_ModeList; + var + I: integer; + Len: integer; +begin + Len := 0; + SetLength(Result, Len + 1); + Result[Len].Index := Party_Round_Random; + Result[Len].Name := Language.Translate('MODE_RANDOM_NAME'); + + for I := 0 to High(Modes) do + if (ModePlayable(I)) then + begin + Inc(Len); + SetLength(Result, Len + 1); + Result[Len].Index := I; + Result[Len].Name := Language.Translate('MODE_' + Uppercase(Modes[I].Name) + '_NAME'); + end; end; { adds a team to the team array, returning its id |