aboutsummaryrefslogtreecommitdiffstats
path: root/Lua/src/base
diff options
context:
space:
mode:
authorwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-12-15 18:24:48 +0000
committerwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-12-15 18:24:48 +0000
commit0af8fe6180f31951badfd19f0bb7a2adece85ba4 (patch)
treeb31dea3de76101b5c784574c189ffafbb4df0279 /Lua/src/base
parent70cb63e5b4a7ce1b06ceceac92ddf623473301ab (diff)
downloadusdx-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')
-rw-r--r--Lua/src/base/UGraphic.pas5
-rw-r--r--Lua/src/base/UParty.pas97
-rw-r--r--Lua/src/base/UThemes.pas17
3 files changed, 95 insertions, 24 deletions
diff --git a/Lua/src/base/UGraphic.pas b/Lua/src/base/UGraphic.pas
index a1f63366..f658c800 100644
--- a/Lua/src/base/UGraphic.pas
+++ b/Lua/src/base/UGraphic.pas
@@ -77,6 +77,7 @@ uses
UScreenPartyOptions,
UScreenPartyWin,
UScreenPartyPlayer,
+ UScreenPartyRounds,
{Stats Screens}
UScreenStatMain,
UScreenStatDetail,
@@ -139,6 +140,7 @@ var
ScreenPartyWin: TScreenPartyWin;
ScreenPartyOptions: TScreenPartyOptions;
ScreenPartyPlayer: TScreenPartyPlayer;
+ ScreenPartyRounds: TScreenPartyRounds;
//StatsScreens
ScreenStatMain: TScreenStatMain;
@@ -769,6 +771,8 @@ begin
Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen PartyOptions', 3); Log.BenchmarkStart(3);
ScreenPartyPlayer := TScreenPartyPlayer.Create;
Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen PartyPlayer', 3); Log.BenchmarkStart(3);
+ ScreenPartyRounds := TScreenPartyRounds.Create;
+ Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen PartyRounds', 3); Log.BenchmarkStart(3);
ScreenStatMain := TScreenStatMain.Create;
Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Stat Main', 3); Log.BenchmarkStart(3);
ScreenStatDetail := TScreenStatDetail.Create;
@@ -816,6 +820,7 @@ begin
ScreenPartyWin.Destroy;
ScreenPartyOptions.Destroy;
ScreenPartyPlayer.Destroy;
+ ScreenPartyRounds.Destroy;
ScreenStatMain.Destroy;
ScreenStatDetail.Destroy;
end;
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
diff --git a/Lua/src/base/UThemes.pas b/Lua/src/base/UThemes.pas
index 5cf257a8..2ecaa9f4 100644
--- a/Lua/src/base/UThemes.pas
+++ b/Lua/src/base/UThemes.pas
@@ -648,7 +648,6 @@ type
SelectLevel: TThemeSelectSlide;
SelectPlayList: TThemeSelectSlide;
SelectPlayList2: TThemeSelectSlide;
- SelectRounds: TThemeSelectSlide;
{ButtonNext: TThemeButton;
ButtonPrev: TThemeButton;}
@@ -682,6 +681,11 @@ type
ButtonPrev: TThemeButton;}
end;
+ TThemePartyRounds = class(TThemeBasic)
+ SelectRoundCount: TThemeSelectSlide;
+ SelectRound: array [0..6] of TThemeSelectSlide;
+ end;
+
//Stats Screens
TThemeStatMain = class(TThemeBasic)
ButtonScores: TThemeButton;
@@ -757,6 +761,7 @@ type
PartyWin: TThemePartyWin;
PartyOptions: TThemePartyOptions;
PartyPlayer: TThemePartyPlayer;
+ PartyRounds: TThemePartyRounds;
//Stats Screens:
StatMain: TThemeStatMain;
@@ -887,6 +892,7 @@ begin
PartyScore := TThemePartyScore.Create;
PartyOptions := TThemePartyOptions.Create;
PartyPlayer := TThemePartyPlayer.Create;
+ PartyRounds := TThemePartyRounds.Create;
//Stats Screens:
StatMain := TThemeStatMain.Create;
@@ -1436,8 +1442,6 @@ begin
ThemeLoadSelectSlide(PartyOptions.SelectLevel, 'PartyOptionsSelectLevel');
ThemeLoadSelectSlide(PartyOptions.SelectPlayList, 'PartyOptionsSelectPlayList');
ThemeLoadSelectSlide(PartyOptions.SelectPlayList2, 'PartyOptionsSelectPlayList2');
- ThemeLoadSelectSlide(PartyOptions.SelectRounds, 'PartyOptionsSelectRounds');
-
{ThemeLoadButton (ButtonNext, 'ButtonNext');
ThemeLoadButton (ButtonPrev, 'ButtonPrev');}
@@ -1467,6 +1471,13 @@ begin
ThemeLoadButton(PartyPlayer.Player11Name, 'PartyPlayerPlayer11Name');
ThemeLoadButton(PartyPlayer.Player12Name, 'PartyPlayerPlayer12Name');
+ // Party Rounds
+ ThemeLoadBasic(PartyRounds, 'PartyRounds');
+
+ ThemeLoadSelectSlide(PartyRounds.SelectRoundCount, 'PartyRoundsSelectRoundCount');
+ for I := 0 to High(PartyRounds.SelectRound) do
+ ThemeLoadSelectSlide(PartyRounds.SelectRound[I], 'PartyRoundsSelectRound' + IntToStr(I + 1));
+
{ThemeLoadButton(ButtonNext, 'PartyPlayerButtonNext');
ThemeLoadButton(ButtonPrev, 'PartyPlayerButtonPrev');}