From 987ead98aca9e8b87343741980a30aeeb7f765f7 Mon Sep 17 00:00:00 2001 From: canni2007 Date: Sat, 3 Nov 2007 13:53:10 +0000 Subject: Added missing files :( sry git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1@569 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/TextGL.pas | 345 ++++ Game/Code/Classes/UCatCovers.pas | 143 ++ Game/Code/Classes/UCommandLine.pas | 280 ++++ Game/Code/Classes/UCovers.pas | 226 +++ Game/Code/Classes/UDLLManager.pas | 226 +++ Game/Code/Classes/UDataBase.pas | 294 ++++ Game/Code/Classes/UDraw.pas | 1669 +++++++++++++++++++ Game/Code/Classes/UFiles.pas | 810 +++++++++ Game/Code/Classes/UGraphic.pas | 536 ++++++ Game/Code/Classes/UGraphicClasses.pas | 655 ++++++++ Game/Code/Classes/UIni.pas | 772 +++++++++ Game/Code/Classes/UJoystick.pas | 273 +++ Game/Code/Classes/ULCD.pas | 289 ++++ Game/Code/Classes/ULanguage.pas | 222 +++ Game/Code/Classes/ULight.pas | 116 ++ Game/Code/Classes/ULog.pas | 227 +++ Game/Code/Classes/ULyrics.pas | 389 +++++ Game/Code/Classes/UMain.pas | 714 ++++++++ Game/Code/Classes/UMusic.pas | 810 +++++++++ Game/Code/Classes/UParty.pas | 374 +++++ Game/Code/Classes/UPlaylist.pas | 453 +++++ Game/Code/Classes/UPliki.pas | 833 +++++++++ Game/Code/Classes/URecord.pas | 371 +++++ Game/Code/Classes/USkins.pas | 162 ++ Game/Code/Classes/USongs.pas | 743 +++++++++ Game/Code/Classes/UTexture.pas | 867 ++++++++++ Game/Code/Classes/UThemes.pas | 2317 ++++++++++++++++++++++++++ Game/Code/Classes/UTime.pas | 81 + Game/Code/Menu/UDisplay.pas | 438 +++++ Game/Code/Menu/UDrawTexture.pas | 101 ++ Game/Code/Menu/UMenu.pas | 1448 ++++++++++++++++ Game/Code/Menu/UMenuButton.pas | 488 ++++++ Game/Code/Menu/UMenuButtonCollection.pas | 68 + Game/Code/Menu/UMenuInteract.pas | 14 + Game/Code/Menu/UMenuSelect.pas | 198 +++ Game/Code/Menu/UMenuSelectSlide.pas | 345 ++++ Game/Code/Menu/UMenuStatic.pas | 84 + Game/Code/Menu/UMenuText.pas | 324 ++++ Game/Code/SMpeg/USmpeg.pas | 305 ++++ Game/Code/Screens/UScreenCredits.pas | 1088 ++++++++++++ Game/Code/Screens/UScreenEdit.pas | 109 ++ Game/Code/Screens/UScreenEditConvert.pas | 531 ++++++ Game/Code/Screens/UScreenEditHeader.pas | 366 ++++ Game/Code/Screens/UScreenEditSub.pas | 1371 +++++++++++++++ Game/Code/Screens/UScreenLevel.pas | 90 + Game/Code/Screens/UScreenLoading.pas | 46 + Game/Code/Screens/UScreenMain.pas | 275 +++ Game/Code/Screens/UScreenName.pas | 234 +++ Game/Code/Screens/UScreenOpen.pas | 165 ++ Game/Code/Screens/UScreenOptions.pas | 167 ++ Game/Code/Screens/UScreenOptionsAdvanced.pas | 102 ++ Game/Code/Screens/UScreenOptionsGame.pas | 107 ++ Game/Code/Screens/UScreenOptionsGraphics.pas | 96 ++ Game/Code/Screens/UScreenOptionsLyrics.pas | 91 + Game/Code/Screens/UScreenOptionsRecord.pas | 132 ++ Game/Code/Screens/UScreenOptionsSound.pas | 97 ++ Game/Code/Screens/UScreenOptionsThemes.pas | 159 ++ Game/Code/Screens/UScreenPartyNewRound.pas | 416 +++++ Game/Code/Screens/UScreenPartyOptions.pas | 256 +++ Game/Code/Screens/UScreenPartyPlayer.pas | 329 ++++ Game/Code/Screens/UScreenPartyScore.pas | 290 ++++ Game/Code/Screens/UScreenPartyWin.pas | 256 +++ Game/Code/Screens/UScreenPopup.pas | 247 +++ Game/Code/Screens/UScreenScore.pas | 385 +++++ Game/Code/Screens/UScreenSing.pas | 1287 ++++++++++++++ Game/Code/Screens/UScreenSingModi.pas | 1091 ++++++++++++ Game/Code/Screens/UScreenSong.pas | 1881 +++++++++++++++++++++ Game/Code/Screens/UScreenSongJumpto.pas | 203 +++ Game/Code/Screens/UScreenSongMenu.pas | 614 +++++++ Game/Code/Screens/UScreenStatDetail.pas | 247 +++ Game/Code/Screens/UScreenStatMain.pas | 225 +++ Game/Code/Screens/UScreenTop5.pas | 160 ++ Game/Code/Screens/UScreenWelcome.pas | 118 ++ Game/Code/UltraStar.dpr | 364 ++++ Game/Code/UltraStar.rc | 38 + Game/Code/bamboo-build-win-delphi.bat | 20 + Game/Code/rccompillieren.bat | 1 + 77 files changed, 32664 insertions(+) create mode 100644 Game/Code/Classes/TextGL.pas create mode 100644 Game/Code/Classes/UCatCovers.pas create mode 100644 Game/Code/Classes/UCommandLine.pas create mode 100644 Game/Code/Classes/UCovers.pas create mode 100644 Game/Code/Classes/UDLLManager.pas create mode 100644 Game/Code/Classes/UDataBase.pas create mode 100644 Game/Code/Classes/UDraw.pas create mode 100644 Game/Code/Classes/UFiles.pas create mode 100644 Game/Code/Classes/UGraphic.pas create mode 100644 Game/Code/Classes/UGraphicClasses.pas create mode 100644 Game/Code/Classes/UIni.pas create mode 100644 Game/Code/Classes/UJoystick.pas create mode 100644 Game/Code/Classes/ULCD.pas create mode 100644 Game/Code/Classes/ULanguage.pas create mode 100644 Game/Code/Classes/ULight.pas create mode 100644 Game/Code/Classes/ULog.pas create mode 100644 Game/Code/Classes/ULyrics.pas create mode 100644 Game/Code/Classes/UMain.pas create mode 100644 Game/Code/Classes/UMusic.pas create mode 100644 Game/Code/Classes/UParty.pas create mode 100644 Game/Code/Classes/UPlaylist.pas create mode 100644 Game/Code/Classes/UPliki.pas create mode 100644 Game/Code/Classes/URecord.pas create mode 100644 Game/Code/Classes/USkins.pas create mode 100644 Game/Code/Classes/USongs.pas create mode 100644 Game/Code/Classes/UTexture.pas create mode 100644 Game/Code/Classes/UThemes.pas create mode 100644 Game/Code/Classes/UTime.pas create mode 100644 Game/Code/Menu/UDisplay.pas create mode 100644 Game/Code/Menu/UDrawTexture.pas create mode 100644 Game/Code/Menu/UMenu.pas create mode 100644 Game/Code/Menu/UMenuButton.pas create mode 100644 Game/Code/Menu/UMenuButtonCollection.pas create mode 100644 Game/Code/Menu/UMenuInteract.pas create mode 100644 Game/Code/Menu/UMenuSelect.pas create mode 100644 Game/Code/Menu/UMenuSelectSlide.pas create mode 100644 Game/Code/Menu/UMenuStatic.pas create mode 100644 Game/Code/Menu/UMenuText.pas create mode 100644 Game/Code/SMpeg/USmpeg.pas create mode 100644 Game/Code/Screens/UScreenCredits.pas create mode 100644 Game/Code/Screens/UScreenEdit.pas create mode 100644 Game/Code/Screens/UScreenEditConvert.pas create mode 100644 Game/Code/Screens/UScreenEditHeader.pas create mode 100644 Game/Code/Screens/UScreenEditSub.pas create mode 100644 Game/Code/Screens/UScreenLevel.pas create mode 100644 Game/Code/Screens/UScreenLoading.pas create mode 100644 Game/Code/Screens/UScreenMain.pas create mode 100644 Game/Code/Screens/UScreenName.pas create mode 100644 Game/Code/Screens/UScreenOpen.pas create mode 100644 Game/Code/Screens/UScreenOptions.pas create mode 100644 Game/Code/Screens/UScreenOptionsAdvanced.pas create mode 100644 Game/Code/Screens/UScreenOptionsGame.pas create mode 100644 Game/Code/Screens/UScreenOptionsGraphics.pas create mode 100644 Game/Code/Screens/UScreenOptionsLyrics.pas create mode 100644 Game/Code/Screens/UScreenOptionsRecord.pas create mode 100644 Game/Code/Screens/UScreenOptionsSound.pas create mode 100644 Game/Code/Screens/UScreenOptionsThemes.pas create mode 100644 Game/Code/Screens/UScreenPartyNewRound.pas create mode 100644 Game/Code/Screens/UScreenPartyOptions.pas create mode 100644 Game/Code/Screens/UScreenPartyPlayer.pas create mode 100644 Game/Code/Screens/UScreenPartyScore.pas create mode 100644 Game/Code/Screens/UScreenPartyWin.pas create mode 100644 Game/Code/Screens/UScreenPopup.pas create mode 100644 Game/Code/Screens/UScreenScore.pas create mode 100644 Game/Code/Screens/UScreenSing.pas create mode 100644 Game/Code/Screens/UScreenSingModi.pas create mode 100644 Game/Code/Screens/UScreenSong.pas create mode 100644 Game/Code/Screens/UScreenSongJumpto.pas create mode 100644 Game/Code/Screens/UScreenSongMenu.pas create mode 100644 Game/Code/Screens/UScreenStatDetail.pas create mode 100644 Game/Code/Screens/UScreenStatMain.pas create mode 100644 Game/Code/Screens/UScreenTop5.pas create mode 100644 Game/Code/Screens/UScreenWelcome.pas create mode 100644 Game/Code/UltraStar.dpr create mode 100644 Game/Code/UltraStar.rc create mode 100644 Game/Code/bamboo-build-win-delphi.bat create mode 100644 Game/Code/rccompillieren.bat (limited to 'Game/Code') diff --git a/Game/Code/Classes/TextGL.pas b/Game/Code/Classes/TextGL.pas new file mode 100644 index 00000000..0f4ae82e --- /dev/null +++ b/Game/Code/Classes/TextGL.pas @@ -0,0 +1,345 @@ +unit TextGL; + +interface + +uses OpenGL12, SDL, UTexture, Classes, ULog; + +procedure BuildFont; // Build Our Bitmap Font +procedure KillFont; // Delete The Font +function glTextWidth(text: pchar): real; // Returns Text Width +procedure glPrintDone(text: pchar; Done: real; ColR, ColG, ColB: real); +procedure glPrintLetter(letter: char); +procedure glPrintLetterCut(letter: char; Start, Finish: real); +procedure glPrint(text: pchar); // Custom GL "Print" Routine +procedure glPrintCut(text: pchar); +procedure SetFontPos(X, Y: real); // Sets X And Y +procedure SetFontSize(Size: real); +procedure SetFontStyle(Style: integer); // sets active font style (normal, bold, etc) +procedure SetFontItalic(Enable: boolean); // sets italic type letter (works for all fonts) +procedure SetFontAspectW(Aspect: real); + +type + TTextGL = record + X: real; + Y: real; + Text: string; + Size: real; + ColR: real; + ColG: real; + ColB: real; + end; + + TFont = record + Tex: TTexture; + Width: array[0..255] of byte; + AspectW: real; + Centered: boolean; + Done: real; + Outline: real; + Italic: boolean; + end; + + +var + base: GLuint; // Base Display List For The Font Set + Fonts: array of TFont; + ActFont: integer; + PColR: real; // temps for glPrintDone + PColG: real; + PColB: real; + +implementation + +uses UMain, Windows, SysUtils, UGraphic; + +procedure BuildFont; // Build Our Bitmap Font +var + font: HFONT; // Windows Font ID + h_dc: hdc; + Rejestr: TResourceStream; + Pet: integer; +begin + ActFont := 0; + + SetLength(Fonts, 5); + Fonts[0].Tex := Texture.LoadTexture(true, 'Font', 'PNG', 'Font', 0); + Fonts[0].Tex.H := 30; + Fonts[0].AspectW := 0.9; + Fonts[0].Done := -1; + Fonts[0].Outline := 0; + + Fonts[1].Tex := Texture.LoadTexture(true, 'FontB', 'PNG', 'Font', 0); + Fonts[1].Tex.H := 30; + Fonts[1].AspectW := 1; + Fonts[1].Done := -1; + Fonts[1].Outline := 0; + + Fonts[2].Tex := Texture.LoadTexture(true, 'FontO', 'PNG', 'Font Outline', 0); + Fonts[2].Tex.H := 30; + Fonts[2].AspectW := 0.95; + Fonts[2].Done := -1; + Fonts[2].Outline := 5; + + Fonts[3].Tex := Texture.LoadTexture(true, 'FontO2', 'PNG', 'Font Outline 2', 0); + Fonts[3].Tex.H := 30; + Fonts[3].AspectW := 0.95; + Fonts[3].Done := -1; + Fonts[3].Outline := 4; + +{ Fonts[4].Tex := Texture.LoadTexture('FontO', 'BMP', 'Arrow', 0); // for score screen + Fonts[4].Tex.H := 30; + Fonts[4].AspectW := 0.95; + Fonts[4].Done := -1; + Fonts[4].Outline := 5;} + + + Rejestr := TResourceStream.Create(HInstance, 'Font', 'FNT'); + Rejestr.Read(Fonts[0].Width, 256); + Rejestr.Free; + + Rejestr := TResourceStream.Create(HInstance, 'FontB', 'FNT'); + Rejestr.Read(Fonts[1].Width, 256); + Rejestr.Free; + + Rejestr := TResourceStream.Create(HInstance, 'FontO', 'FNT'); + Rejestr.Read(Fonts[2].Width, 256); + Rejestr.Free; + + Rejestr := TResourceStream.Create(HInstance, 'FontO2', 'FNT'); + Rejestr.Read(Fonts[3].Width, 256); + Rejestr.Free; + +{ Rejestr := TResourceStream.Create(HInstance, 'FontO', 'FNT'); + Rejestr.Read(Fonts[4].Width, 256); + Rejestr.Free;} + + for Pet := 0 to 255 do + Fonts[1].Width[Pet] := Fonts[1].Width[Pet] div 2; + + for Pet := 0 to 255 do + Fonts[2].Width[Pet] := Fonts[2].Width[Pet] div 2 + 2; + + for Pet := 0 to 255 do + Fonts[3].Width[Pet] := Fonts[3].Width[Pet] + 1; + +{ for Pet := 0 to 255 do + Fonts[4].Width[Pet] := Fonts[4].Width[Pet] div 2 + 2;} + +end; + +procedure KillFont; // Delete The Font +begin +// glDeleteLists(base, 256); // Delete All 96 Characters +end; + +function glTextWidth(text: pchar): real; +var + Letter: char; +begin +// Log.LogStatus(Text, 'glTextWidth'); + Result := 0; + while (length(text) > 0) do begin + Letter := Text[0]; + text := pchar(Copy(text, 2, Length(text)-1)); + Result := Result + Fonts[ActFont].Width[Ord(Letter)] * Fonts[ActFont].Tex.H / 30 * Fonts[ActFont].AspectW; + end; // while +end; + +procedure glPrintDone(text: pchar; Done: real; ColR, ColG, ColB: real); +begin + Fonts[ActFont].Done := Done; + PColR := ColR; + PColG := ColG; + PColB := ColB; + glPrintCut(text); + Fonts[ActFont].Done := -1; +end; + +procedure glPrintLetter(Letter: char); +var + TexX, TexY: real; + TexR, TexB: real; + FWidth: real; + PL, PT: real; + PR, PB: real; + XItal: real; // X shift for italic type letter +begin + with Fonts[ActFont].Tex do begin + FWidth := Fonts[ActFont].Width[Ord(Letter)]; + + W := FWidth * (H/30) * Fonts[ActFont].AspectW; +// H := 30; + + // set texture positions + TexX := (ord(Letter) mod 16) * 1/16 + 1/32 - FWidth/1024 - Fonts[ActFont].Outline/1024; + TexY := (ord(Letter) div 16) * 1/16 + 2/1024; // 2/1024 + TexR := (ord(Letter) mod 16) * 1/16 + 1/32 + FWidth/1024 + Fonts[ActFont].Outline/1024; + TexB := (1 + ord(Letter) div 16) * 1/16 - 2/1024; + + // set vector positions + PL := X - Fonts[ActFont].Outline * (H/30) * Fonts[ActFont].AspectW /2; + PT := Y; + PR := PL + W + Fonts[ActFont].Outline * (H/30) * Fonts[ActFont].AspectW; + PB := PT + H; + if Fonts[ActFont].Italic = false then + XItal := 0 + else + XItal := 12; + + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, TexNum); + glBegin(GL_QUADS); + glTexCoord2f(TexX, TexY); glVertex2f(PL+XItal, PT); + glTexCoord2f(TexX, TexB); glVertex2f(PL, PB); + glTexCoord2f(TexR, TexB); glVertex2f(PR, PB); + glTexCoord2f(TexR, TexY); glVertex2f(PR+XItal, PT); + glEnd; + X := X + W; + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + end; // with +end; + +procedure glPrintLetterCut(letter: char; Start, Finish: real); +var + TexX, TexY: real; + TexR, TexB: real; + TexTemp: real; + FWidth: real; + PL, PT: real; + PR, PB: real; + OutTemp: real; + XItal: real; +begin + with Fonts[ActFont].Tex do begin + FWidth := Fonts[ActFont].Width[Ord(Letter)]; + + W := FWidth * (H/30) * Fonts[ActFont].AspectW; +// H := 30; + OutTemp := Fonts[ActFont].Outline * (H/30) * Fonts[ActFont].AspectW; + + // set texture positions + TexX := (ord(Letter) mod 16) * 1/16 + 1/32 - FWidth/1024 - Fonts[ActFont].Outline/1024; + TexY := (ord(Letter) div 16) * 1/16 + 2/1024; // 2/1024 + TexR := (ord(Letter) mod 16) * 1/16 + 1/32 + FWidth/1024 + Fonts[ActFont].Outline/1024; + TexB := (1 + ord(Letter) div 16) * 1/16 - 2/1024; + + TexTemp := TexX + Start * (TexR - TexX); + TexR := TexX + Finish * (TexR - TexX); + TexX := TexTemp; + + // set vector positions + PL := X - OutTemp / 2 + OutTemp * Start; + PT := Y; + PR := PL + (W + OutTemp) * (Finish - Start); + PB := PT + H; + if Fonts[ActFont].Italic = false then + XItal := 0 + else + XItal := 12; + + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, TexNum); + glBegin(GL_QUADS); + glTexCoord2f(TexX, TexY); glVertex2f(PL+XItal, PT); + glTexCoord2f(TexX, TexB); glVertex2f(PL, PB); + glTexCoord2f(TexR, TexB); glVertex2f(PR, PB); + glTexCoord2f(TexR, TexY); glVertex2f(PR+XItal, PT); // not tested with XItal + glEnd; + X := X + W * (Finish - Start); + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + end; // with + +end; + +procedure glPrint(text: pchar); // Custom GL "Print" Routine +var + Letter: char; +begin + if (Text = '') then // If There's No Text + Exit; // Do Nothing + + while (length(text) > 0) do begin + // cut + Letter := Text[0]; + Text := pchar(Copy(Text, 2, Length(Text)-1)); + + // print + glPrintLetter(Letter); + end; // while +end; + +procedure glPrintCut(text: pchar); +var + Letter: char; + PToDo: real; + PTotWidth: real; + PDoingNow: real; + S: string; +begin + if (Text = '') then // If There's No Text + Exit; // Do Nothing + + PTotWidth := glTextWidth(Text); + PToDo := Fonts[ActFont].Done; + + while (length(text) > 0) do begin + // cut + Letter := Text[0]; + Text := pchar(Copy(Text, 2, Length(Text)-1)); + + // analyze + S := Letter; + PDoingNow := glTextWidth(pchar(S)) / PTotWidth; + + // drawing + if (PToDo > 0) and (PDoingNow <= PToDo) then + glPrintLetter(Letter); + + if (PToDo > 0) and (PDoingNow > PToDo) then begin + glPrintLetterCut(Letter, 0, PToDo / PDoingNow); + glColor3f(PColR, PColG, PColB); + glPrintLetterCut(Letter, PToDo / PDoingNow, 1); + end; + + if (PToDo <= 0) then + glPrintLetter(Letter); + + PToDo := PToDo - PDoingNow; + + end; // while +end; + + +procedure SetFontPos(X, Y: real); +begin + Fonts[ActFont].Tex.X := X; + Fonts[ActFont].Tex.Y := Y; +end; + +procedure SetFontSize(Size: real); +begin + Fonts[ActFont].Tex.H := 30 * (Size/10); +end; + +procedure SetFontStyle(Style: integer); +begin + ActFont := Style; +end; + +procedure SetFontItalic(Enable: boolean); +begin + Fonts[ActFont].Italic := Enable; +end; + +procedure SetFontAspectW(Aspect: real); +begin + Fonts[ActFont].AspectW := Aspect; +end; + +end. diff --git a/Game/Code/Classes/UCatCovers.pas b/Game/Code/Classes/UCatCovers.pas new file mode 100644 index 00000000..34742902 --- /dev/null +++ b/Game/Code/Classes/UCatCovers.pas @@ -0,0 +1,143 @@ +unit UCatCovers; +///////////////////////////////////////////////////////////////////////// +// UCatCovers by Whiteshark // +// Class for listing and managing the Category Covers // +///////////////////////////////////////////////////////////////////////// + +interface +uses UIni; + +type + TCatCovers = class + protected + cNames: array [low(ISorting)..high(ISorting)] of array of string; + cFiles: array [low(ISorting)..high(ISorting)] of array of string; + public + constructor Create; + procedure Load; //Load Cover aus Cover.ini and Cover Folder + procedure Add(Sorting: integer; Name, Filename: string); //Add a Cover + function CoverExists(Sorting: integer; Name: string): boolean; //Returns True when a cover with the given Name exists + function GetCover(Sorting: integer; Name: string): string; //Returns the Filename of a Cover + end; + +var +CatCovers: TCatCovers; + +implementation +uses IniFiles, SysUtils, Classes, UFiles, ULog; + +constructor TCatCovers.Create; +begin + Load; +end; + + //Load Cover aus Cover.ini and Cover Folder +procedure TCatCovers.Load; +var + Ini: TMemIniFile; + SR: TSearchRec; + List: TStringlist; + I, J: Integer; + Name, Filename, Temp: string; +begin +try + Ini := TMemIniFile.Create(CoversPath + 'covers.ini'); + List := TStringlist.Create; + + //Add every Cover in Covers Ini for Every Sorting option + for I := low(ISorting) to high(ISorting) do + begin + Ini.ReadSection(ISorting[I], List); + + for J := 0 to List.Count - 1 do + Add(I, List.Strings[J], CoversPath + Ini.ReadString(ISorting[I], List.Strings[J], 'NoCover.jpg')); + end; + +finally + Ini.Free; + List.Free; +end; + +try + //Add Covers from Folder + if (FindFirst (CoversPath + '*.jpg', faAnyFile, SR) = 0) then + repeat + //Add Cover if it doesn't exist for every Section + Name := SR.Name; + Filename := CoversPath + Name; + Delete (Name, length(Name) - 3, 4); + + for I := low(ISorting) to high(ISorting) do + begin + Temp := Name; + if ((I = sTitle) or (I = sTitle2)) and (Pos ('Title', Temp) <> 0) then + Delete (Temp, Pos ('Title', Temp), 5) + else if (I = sArtist) or (I = sArtist2) and (Pos ('Artist', Temp) <> 0) then + Delete (Temp, Pos ('Artist', Temp), 6); + + if not CoverExists(I, Temp) then + Add (I, Temp, Filename); + end; + until FindNext (SR) <> 0; + +finally + FindClose (SR); +end; + +end; + + //Add a Cover +procedure TCatCovers.Add(Sorting: integer; Name, Filename: string); +begin +if FileExists (Filename) then //If Exists -> Add +begin +SetLength (CNames[Sorting], Length(CNames[Sorting]) + 1); +SetLength (CFiles[Sorting], Length(CNames[Sorting]) + 1); + +CNames[Sorting][high(cNames[Sorting])] := Uppercase(Name); +CFiles[Sorting][high(cNames[Sorting])] := FileName; +end; +end; + + //Returns True when a cover with the given Name exists +function TCatCovers.CoverExists(Sorting: integer; Name: string): boolean; +var +I: Integer; +begin +Result := False; +Name := Uppercase(Name); //Case Insensitiv + +for I := low(cNames[Sorting]) to high(cNames[Sorting]) do +begin + if (cNames[Sorting][I] = Name) then //Found Name + begin + Result := true; + break; //Break For Loop + end; +end; +end; + + //Returns the Filename of a Cover +function TCatCovers.GetCover(Sorting: integer; Name: string): string; +var +I: Integer; +begin +Result := ''; +Name := Uppercase(Name); + +for I := low(cNames[Sorting]) to high(cNames[Sorting]) do +begin + if cNames[Sorting][I] = Name then + begin + Result := cFiles[Sorting][I]; + Break; + end; +end; + +//No Cover +if (Result = '') AND (FileExists(CoversPath + 'NoCover.jpg')) then + Result := CoversPath + 'NoCover.jpg'; + +end; + +end. diff --git a/Game/Code/Classes/UCommandLine.pas b/Game/Code/Classes/UCommandLine.pas new file mode 100644 index 00000000..03229721 --- /dev/null +++ b/Game/Code/Classes/UCommandLine.pas @@ -0,0 +1,280 @@ +unit UCommandLine; + +interface + +type + //----------- + // TCMDParams - Class Reaads Infos from ParamStr and set some easy Interface Variables + //----------- + TCMDParams = class + private + sLanguage: String; + sResolution: String; + public + //Some Boolean Variables Set when Reading Infos + Debug: Boolean; + Benchmark: Boolean; + NoLog: Boolean; + FullScreen: Boolean; + Joypad: Boolean; + + //Some Value Variables Set when Reading Infos {-1: Not Set, others: Value} + Depth: Integer; + Screens: Integer; + + //Some Strings Set when Reading Infos {Length=0 Not Set} + SongPath: String; + ConfigFile: String; + ScoreFile: String; + + //Pseudo Integer Values + Function GetLanguage: Integer; + Property Language: Integer read GetLanguage; + + Function GetResolution: Integer; + Property Resolution: Integer read GetResolution; + + //Some Procedures for Reading Infos + Constructor Create; + + Procedure ResetVariables; + Procedure ReadParamInfo; + end; + +var + Params: TCMDParams; + +implementation +uses SysUtils, UIni; + +//------------- +// Constructor - Create class, Reset Variables and Read Infos +//------------- +Constructor TCMDParams.Create; +begin + ResetVariables; + ReadParamInfo; +end; + +//------------- +// ResetVariables - Reset Class Variables +//------------- +Procedure TCMDParams.ResetVariables; +begin + Debug := False; + Benchmark := False; + NoLog := False; + FullScreen := False; + Joypad := False; + + //Some Value Variables Set when Reading Infos {-1: Not Set, others: Value} + sResolution := ''; + sLanguage := ''; + Depth := -1; + Screens := -1; + + //Some Strings Set when Reading Infos {Length=0 Not Set} + SongPath := ''; + ConfigFile := ''; + ScoreFile := ''; +end; + +//------------- +// ReadParamInfo - Read Infos from Parameters +//------------- +Procedure TCMDParams.ReadParamInfo; +var + I: Integer; + PCount: Integer; + Command: String; +begin + PCount := ParamCount; + //Log.LogError('ParamCount: ' + Inttostr(PCount)); + + //Check all Parameters + For I := 1 to PCount do + begin + Command := Paramstr(I); + //Log.LogError('Start parsing Command: ' + Command); + //Is String Parameter ? + if (Length(Command) > 1) AND (Command[1] = '-') then + begin + //Remove - from Command + Command := Lowercase(Trim(Copy(Command, 2, Length(Command) - 1))); + //Log.LogError('Command prepared: ' + Command); + + //Check Command + + // Boolean Triggers: + if (Command = 'debug') then + Debug := True + else if (Command = 'benchmark') then + Benchmark := True + else if (Command = 'nolog') then + NoLog := True + else if (Command = 'fullscreen') then + Fullscreen := True + else if (Command = 'joypad') then + Joypad := True + + //Integer Variables + else if (Command = 'depth') then + begin + //Check if there is another Parameter to get the Value from + if (PCount > I) then + begin + Command := ParamStr(I + 1); + + //Check for valid Value + If (Command = '16') then + Depth := 0 + Else If (Command = '32') then + Depth := 1; + end; + end + + else if (Command = 'screens') then + begin + //Check if there is another Parameter to get the Value from + if (PCount > I) then + begin + Command := ParamStr(I + 1); + + //Check for valid Value + If (Command = '1') then + Screens := 0 + Else If (Command = '2') then + Screens := 1; + end; + end + + //Pseudo Integer Values + else if (Command = 'language') then + begin + //Check if there is another Parameter to get the Value from + if (PCount > I) then + begin + //Write Value to String + sLanguage := Lowercase(ParamStr(I + 1)); + end; + end + + else if (Command = 'resolution') then + begin + //Check if there is another Parameter to get the Value from + if (PCount > I) then + begin + //Write Value to String + sResolution := Lowercase(ParamStr(I + 1)); + end; + end + + //String Values + else if (Command = 'songpath') then + begin + //Check if there is another Parameter to get the Value from + if (PCount > I) then + begin + //Write Value to String + SongPath := ParamStr(I + 1); + end; + end + + else if (Command = 'configfile') then + begin + //Check if there is another Parameter to get the Value from + if (PCount > I) then + begin + //Write Value to String + ConfigFile := ParamStr(I + 1); + + //is this a relative PAth -> then add Gamepath + if Not ((Length(ConfigFile) > 2) AND (ConfigFile[2] = ':')) then + ConfigFile := ExtractFilePath(ParamStr(0)) + Configfile; + end; + end + + else if (Command = 'scorefile') then + begin + //Check if there is another Parameter to get the Value from + if (PCount > I) then + begin + //Write Value to String + ScoreFile := ParamStr(I + 1); + end; + end; + + end; + + end; + +{ Log.LogError('Values: '); + + if Debug then + Log.LogError('Debug'); + + if Benchmark then + Log.LogError('Benchmark'); + + if NoLog then + Log.LogError('NoLog'); + + if Fullscreen then + Log.LogError('FullScreen'); + + if JoyStick then + Log.LogError('Joystick'); + + + Log.LogError('Screens: ' + Inttostr(Screens)); + Log.LogError('Depth: ' + Inttostr(Depth)); + + Log.LogError('Resolution: ' + Inttostr(Resolution)); + Log.LogError('Resolution: ' + Inttostr(Language)); + + Log.LogError('sResolution: ' + sResolution); + Log.LogError('sLanguage: ' + sLanguage); + + Log.LogError('ConfigFile: ' + ConfigFile); + Log.LogError('SongPath: ' + SongPath); + Log.LogError('ScoreFile: ' + ScoreFile); } + +end; + +//------------- +// GetLanguage - Get Language ID from saved String Information +//------------- +Function TCMDParams.GetLanguage: Integer; +var + I: integer; +begin + Result := -1; + + //Search for Language + For I := 0 to high(ILanguage) do + if (LowerCase(ILanguage[I]) = sLanguage) then + begin + Result := I; + Break; + end; +end; + +//------------- +// GetResolution - Get Resolution ID from saved String Information +//------------- +Function TCMDParams.GetResolution: Integer; +var + I: integer; +begin + Result := -1; + + //Search for Resolution + For I := 0 to high(IResolution) do + if (LowerCase(IResolution[I]) = sResolution) then + begin + Result := I; + Break; + end; +end; + +end. \ No newline at end of file diff --git a/Game/Code/Classes/UCovers.pas b/Game/Code/Classes/UCovers.pas new file mode 100644 index 00000000..5b0a06d4 --- /dev/null +++ b/Game/Code/Classes/UCovers.pas @@ -0,0 +1,226 @@ +unit UCovers; + +interface +uses OpenGL12, Windows, Math, Classes, SysUtils, Graphics, UThemes, UTexture; + +type + TCover = record + Name: string; + W: word; + H: word; + Size: integer; + Position: integer; // position of picture in the cache file +// Data: array of byte; + end; + + TCovers = class + Cover: array of TCover; + W: word; + H: word; + Size: integer; + Data: array of byte; + WritetoFile: Boolean; + + constructor Create; + procedure Load; + procedure Save; + procedure AddCover(Name: string); + function CoverExists(Name: string): boolean; + function CoverNumber(Name: string): integer; + procedure PrepareData(Name: string); + end; + +var + Covers: TCovers; + +implementation +uses UFiles, ULog, DateUtils; + +constructor TCovers.Create; +begin + W := 128; + H := 128; + Size := W*H*3; + Load; + WritetoFile := True; +end; + +procedure TCovers.Load; +var + F: File; + C: integer; // cover number + W: word; + H: word; + Bits: byte; + NLen: word; + Name: string; +// Data: array of byte; +begin + if FileExists(GamePath + 'covers.cache') then begin + AssignFile(F, GamePath + 'covers.cache'); + Reset(F, 1); + + WritetoFile := not FileIsReadOnly(GamePath + 'covers.cache'); + + SetLength(Cover, 0); + + while not EOF(F) do begin + SetLength(Cover, Length(Cover)+1); + + BlockRead(F, W, 2); + Cover[High(Cover)].W := W; + + BlockRead(F, H, 2); + Cover[High(Cover)].H := H; + + BlockRead(F, Bits, 1); + + Cover[High(Cover)].Size := W * H * (Bits div 8); + + // test +// W := 128; +// H := 128; +// Bits := 24; +// Seek(F, FilePos(F) + 3); + + BlockRead(F, NLen, 2); + SetLength(Name, NLen); + + BlockRead(F, Name[1], NLen); + Cover[High(Cover)].Name := Name; + + Cover[High(Cover)].Position := FilePos(F); + Seek(F, FilePos(F) + W*H*(Bits div 8)); + +// SetLength(Cover[High(Cover)].Data, W*H*(Bits div 8)); +// BlockRead(F, Cover[High(Cover)].Data[0], W*H*(Bits div 8)); + + end; + + CloseFile(F); + end; // fileexists +end; + +procedure TCovers.Save; +var + F: File; + C: integer; // cover number + W: word; + H: word; + NLen: word; + Bits: byte; +begin +{ AssignFile(F, GamePath + 'covers.cache'); + Rewrite(F, 1); + + Bits := 24; + for C := 0 to High(Cover) do begin + W := Cover[C].W; + H := Cover[C].H; + + BlockWrite(F, W, 2); + BlockWrite(F, H, 2); + BlockWrite(F, Bits, 1); + + NLen := Length(Cover[C].Name); + BlockWrite(F, NLen, 2); + BlockWrite(F, Cover[C].Name[1], NLen); + BlockWrite(F, Cover[C].Data[0], W*H*(Bits div 8)); + end; + + CloseFile(F);} +end; + +procedure TCovers.AddCover(Name: string); +var + B: integer; + F: File; + C: integer; // cover number + NLen: word; + Bits: byte; +begin + if not CoverExists(Name) then begin + SetLength(Cover, Length(Cover)+1); + Cover[High(Cover)].Name := Name; + + Cover[High(Cover)].W := W; + Cover[High(Cover)].H := H; + Cover[High(Cover)].Size := Size; + + // do not copy data. write them directly to file +// SetLength(Cover[High(Cover)].Data, Size); +// for B := 0 to Size-1 do +// Cover[High(Cover)].Data[B] := CacheMipmap[B]; + + if WritetoFile then + begin + AssignFile(F, GamePath + 'covers.cache'); + if FileExists(GamePath + 'covers.cache') then begin + Reset(F, 1); + Seek(F, FileSize(F)); + end else + Rewrite(F, 1); + + Bits := 24; + + BlockWrite(F, W, 2); + BlockWrite(F, H, 2); + BlockWrite(F, Bits, 1); + + NLen := Length(Name); + BlockWrite(F, NLen, 2); + BlockWrite(F, Name[1], NLen); + + Cover[High(Cover)].Position := FilePos(F); + BlockWrite(F, CacheMipmap[0], W*H*(Bits div 8)); + + CloseFile(F); + end; + end + else + Cover[High(Cover)].Position := 0; +end; + +function TCovers.CoverExists(Name: string): boolean; +var + C: integer; // cover +begin + Result := false; + C := 0; + while (C <= High(Cover)) and (Result = false) do begin + if Cover[C].Name = Name then Result := true; + Inc(C); + end; +end; + +function TCovers.CoverNumber(Name: string): integer; +var + C: integer; +begin + Result := -1; + C := 0; + while (C <= High(Cover)) and (Result = -1) do begin + if Cover[C].Name = Name then Result := C; + Inc(C); + end; +end; + +procedure TCovers.PrepareData(Name: string); +var + F: File; + C: integer; +begin + if FileExists(GamePath + 'covers.cache') then begin + AssignFile(F, GamePath + 'covers.cache'); + Reset(F, 1); + + C := CoverNumber(Name); + SetLength(Data, Cover[C].Size); + if Length(Data) < 6 then beep; + Seek(F, Cover[C].Position); + BlockRead(F, Data[0], Cover[C].Size); + CloseFile(F); + end; +end; + +end. diff --git a/Game/Code/Classes/UDLLManager.pas b/Game/Code/Classes/UDLLManager.pas new file mode 100644 index 00000000..4b8838b9 --- /dev/null +++ b/Game/Code/Classes/UDLLManager.pas @@ -0,0 +1,226 @@ +unit UDLLManager; + +interface +uses ModiSDK, UFiles; + +type + TDLLMan = class + private + hLib: THandle; + P_Init: fModi_Init; + P_Draw: fModi_Draw; + P_Finish: fModi_Finish; + P_RData: pModi_RData; + public + Plugins: array of TPluginInfo; + PluginPaths: array of String; + Selected: ^TPluginInfo; + + constructor Create; + + procedure GetPluginList; + procedure ClearPluginInfo(No: Cardinal); + function LoadPluginInfo(Filename: String; No: Cardinal): boolean; + + function LoadPlugin(No: Cardinal): boolean; + procedure UnLoadPlugin; + + function PluginInit (const TeamInfo: TTeamInfo; var Playerinfo: TPlayerinfo; const Sentences: TSentences; const LoadTex: fModi_LoadTex; const Print: fModi_Print; LoadSound: fModi_LoadSound; PlaySound: pModi_PlaySound): boolean; + function PluginDraw (var Playerinfo: TPlayerinfo; const CurSentence: Cardinal): boolean; + function PluginFinish (var Playerinfo: TPlayerinfo): byte; + procedure PluginRData (handle: HSTREAM; buffer: Pointer; len: DWORD; user: DWORD); + end; + +var + DLLMan: TDLLMan; + +const DLLPath = 'Plugins\'; + +implementation +uses Windows, ULog, SysUtils; + + +constructor TDLLMan.Create; +begin + SetLength(Plugins, 0); + SetLength(PluginPaths, Length(Plugins)); + GetPluginList; +end; + +procedure TDLLMan.GetPluginList; +var + SR: TSearchRec; +begin + + if FindFirst(DLLPath + '*.dll', faAnyFile , SR) = 0 then + begin + repeat + SetLength(Plugins, Length(Plugins)+1); + SetLength(PluginPaths, Length(Plugins)); + + if LoadPluginInfo(SR.Name, High(Plugins)) then //Loaded succesful + begin + PluginPaths[High(PluginPaths)] := SR.Name; + end + else //Error Loading + begin + SetLength(Plugins, Length(Plugins)-1); + SetLength(PluginPaths, Length(Plugins)); + end; + + until FindNext(SR) <> 0; + FindClose(SR); + end; +end; + +procedure TDLLMan.ClearPluginInfo(No: Cardinal); +begin + //Set to Party Modi Plugin + Plugins[No].Typ := 8; + + Plugins[No].Name := 'unknown'; + Plugins[No].NumPlayers := 0; + + Plugins[No].Creator := 'Nobody'; + Plugins[No].PluginDesc := 'NO_PLUGIN_DESC'; + + Plugins[No].LoadSong := True; + Plugins[No].ShowScore := True; + Plugins[No].ShowBars := False; + Plugins[No].ShowNotes := True; + Plugins[No].LoadVideo := True; + Plugins[No].LoadBack := True; + + Plugins[No].TeamModeOnly := False; + Plugins[No].GetSoundData := False; + Plugins[No].Dummy := False; + + + Plugins[No].BGShowFull := False; + Plugins[No].BGShowFull_O := True; + + Plugins[No].ShowRateBar:= False; + Plugins[No].ShowRateBar_O := True; + + Plugins[No].EnLineBonus := False; + Plugins[No].EnLineBonus_O := True; +end; + +function TDLLMan.LoadPluginInfo(Filename: String; No: Cardinal): boolean; +var + hLibg: THandle; + Info: pModi_PluginInfo; + I: Integer; +begin + Result := False; + //Clear Plugin Info + ClearPluginInfo(No); + + {//Workaround Plugins Loaded 2 Times + For I := low(PluginPaths) to high(PluginPaths) do + if (PluginPaths[I] = Filename) then + exit; } + + //Load Libary + hLibg := LoadLibrary(PChar(DLLPath + Filename)); + //If Loaded + if (hLibg <> 0) then + begin + //Load Info Procedure + @Info := GetProcAddress (hLibg, PChar('PluginInfo')); + + //If Loaded + if (@Info <> nil) then + begin + //Load PluginInfo + Info (Plugins[No]); + Result := True; + end + else + Log.LogError('Could not Load Plugin "' + Filename + '": Info Procedure not Found'); + + FreeLibrary (hLibg); + end + else + Log.LogError('Could not Load Plugin "' + Filename + '": Libary not Loaded'); +end; + +function TDLLMan.LoadPlugin(No: Cardinal): boolean; +begin + Result := False; + //Load Libary + hLib := LoadLibrary(PChar(DLLPath + PluginPaths[No])); + //If Loaded + if (hLib <> 0) then + begin + //Load Info Procedure + @P_Init := GetProcAddress (hLib, PChar('Init')); + @P_Draw := GetProcAddress (hLib, PChar('Draw')); + @P_Finish := GetProcAddress (hLib, PChar('Finish')); + + //If Loaded + if (@P_Init <> nil) And (@P_Draw <> nil) And (@P_Finish <> nil) then + begin + Selected := @Plugins[No]; + Result := True; + end + else + begin + Log.LogError('Could not Load Plugin "' + PluginPaths[No] + '": Procedures not Found'); + + end; + end + else + Log.LogError('Could not Load Plugin "' + PluginPaths[No] + '": Libary not Loaded'); +end; + +procedure TDLLMan.UnLoadPlugin; +begin +if (hLib <> 0) then + FreeLibrary (hLib); + +//Selected := nil; +@P_Init := nil; +@P_Draw := nil; +@P_Finish := nil; +@P_RData := nil; +end; + +function TDLLMan.PluginInit (const TeamInfo: TTeamInfo; var Playerinfo: TPlayerinfo; const Sentences: TSentences; const LoadTex: fModi_LoadTex; const Print: fModi_Print; LoadSound: fModi_LoadSound; PlaySound: pModi_PlaySound): boolean; +var + Methods: TMethodRec; +begin + Methods.LoadTex := LoadTex; + Methods.Print := Print; + Methods.LoadSound := LoadSound; + Methods.PlaySound := PlaySound; + + if (@P_Init <> nil) then + Result := P_Init (TeamInfo, PlayerInfo, Sentences, Methods) + else + Result := False +end; + +function TDLLMan.PluginDraw (var Playerinfo: TPlayerinfo; const CurSentence: Cardinal): boolean; +begin +if (@P_Draw <> nil) then + Result := P_Draw (PlayerInfo, CurSentence) +else + Result := False +end; + +function TDLLMan.PluginFinish (var Playerinfo: TPlayerinfo): byte; +begin +if (@P_Finish <> nil) then + Result := P_Finish (PlayerInfo) +else + Result := 0; +end; + +procedure TDLLMan.PluginRData (handle: HSTREAM; buffer: Pointer; len: DWORD; user: DWORD); +begin +if (@P_RData <> nil) then + P_RData (handle, buffer, len, user); +end; + +end. diff --git a/Game/Code/Classes/UDataBase.pas b/Game/Code/Classes/UDataBase.pas new file mode 100644 index 00000000..b8b41bc1 --- /dev/null +++ b/Game/Code/Classes/UDataBase.pas @@ -0,0 +1,294 @@ +unit UDataBase; + +interface + +uses USongs, SQLiteTable3; + +//-------------------- +//DataBaseSystem - Class including all DB Methods +//-------------------- +type + TStatResult = record + Case Typ: Byte of + 0: (Singer: ShortString; + Score: Word; + Difficulty: Byte; + SongArtist: ShortString; + SongTitle: ShortString); + + 1: (Player: ShortString; + AverageScore: Word); + + 2: (Artist: ShortString; + Title: ShortString; + TimesSung: Word); + + 3: (ArtistName: ShortString; + TimesSungtot: Word); + end; + AStatResult = Array of TStatResult; + + TDataBaseSystem = class + private + ScoreDB: TSqliteDatabase; + sFilename: string; + public + + + property Filename: String read sFilename; + + Destructor Free; + + Procedure Init(const Filename: string); + procedure ReadScore(var Song: TSong); + procedure AddScore(var Song: TSong; Level: integer; Name: string; Score: integer); + procedure WriteScore(var Song: TSong); + + Function GetStats(var Stats: AStatResult; const Typ, Count: Byte; const Page: Cardinal; const Reversed: Boolean): Boolean; + Function GetTotalEntrys(const Typ: Byte): Cardinal; + end; + +var + DataBase: TDataBaseSystem; + +implementation + +uses IniFiles, SysUtils; + +//-------------------- +//Create - Opens Database and Create Tables if not Exist +//-------------------- + +Procedure TDataBaseSystem.Init(const Filename: string); +begin + //Open Database + ScoreDB := TSqliteDatabase.Create(Filename); + sFilename := Filename; + + try + //Look for Tables => When not exist Create them + if not ScoreDB.TableExists('US_Scores') then + ScoreDB.execsql('CREATE TABLE `US_Scores` (`SongID` INT( 11 ) NOT NULL , `Difficulty` INT( 1 ) NOT NULL , `Player` VARCHAR( 150 ) NOT NULL , `Score` INT( 5 ) NOT NULL );'); + + if not ScoreDB.TableExists('US_Songs') then + ScoreDB.execsql('CREATE TABLE `US_Songs` (`ID` INTEGER PRIMARY KEY, `Artist` VARCHAR( 255 ) NOT NULL , `Title` VARCHAR( 255 ) NOT NULL , `TimesPlayed` int(5) NOT NULL );'); + //Not possible because of String Limitation to 255 Chars //Need to rewrite Wrapper + {if not ScoreDB.TableExists('US_SongCache') then + ScoreDB.ExecSQL('CREATE TABLE `US_SongCache` (`Path` VARCHAR( 255 ) NOT NULL , `Filename` VARCHAR( 255 ) NOT NULL , `Title` VARCHAR( 255 ) NOT NULL , `Artist` VARCHAR( 255 ) NOT NULL , `Folder` VARCHAR( 255 ) NOT NULL , `Genre` VARCHAR( 255 ) NOT NULL , `Edition` VARCHAR( 255 ) NOT NULL , `Language` VARCHAR( 255 ) NOT NULL , `Creator` VARCHAR( 255 ) NOT NULL , `Cover` VARCHAR( 255 ) NOT NULL , `Background` VARCHAR( 255 ) NOT NULL , `Video` VARCHAR( 255 ) NOT NULL , `VideoGap` FLOAT NOT NULL , `Gap` FLOAT NOT NULL , `Start` FLOAT NOT NULL , `Finish` INT( 11 ) NOT NULL , `BPM` INT( 5 ) NOT NULL , `Relative` BOOLEAN NOT NULL , `NotesGap` INT( 11 ) NOT NULL);');} + + + finally + //ScoreDB.Free; + end; + +end; + +//-------------------- +//Free - Frees Database +//-------------------- +Destructor TDataBaseSystem.Free; +begin + ScoreDB.Free; +end; + +//-------------------- +//ReadScore - Read Scores into SongArray +//-------------------- +procedure TDataBaseSystem.ReadScore(var Song: TSong); +var + TableData: TSqliteTable; + Dif: Byte; +begin + //ScoreDB := TSqliteDatabase.Create(sFilename); + try + try + //Search Song in DB + TableData := ScoreDB.GetTable('SELECT `Difficulty`, `Player`, `Score` FROM `us_scores` WHERE `SongID` = (SELECT `ID` FROM `us_songs` WHERE `Artist` = "' + Song.Artist + '" AND `Title` = "' + Song.Title + '" LIMIT 1) ORDER BY `Score` DESC LIMIT 15'); + //Empty Old Scores + SetLength (Song.Score[0], 0); + SetLength (Song.Score[1], 0); + SetLength (Song.Score[2], 0); + + while not TableData.Eof do//Go through all Entrys + begin//Add one Entry to Array + Dif := StrtoInt(TableData.FieldAsString(TableData.FieldIndex['Difficulty'])); + if (Dif>=0) AND (Dif<=2) then + begin + SetLength(Song.Score[Dif], Length(Song.Score[Dif]) + 1); + + Song.Score[Dif, high(Song.Score[Dif])].Name := TableData.FieldAsString(TableData.FieldIndex['Player']); + Song.Score[Dif, high(Song.Score[Dif])].Score:= StrtoInt(TableData.FieldAsString(TableData.FieldIndex['Score'])); + end; + TableData.Next; + end; + + except //Im Fehlerfall + for Dif := 0 to 2 do + begin + SetLength(Song.Score[Dif], 1); + Song.Score[Dif, 1].Name := 'Error Reading ScoreDB'; + end; + end; + finally + //ScoreDb.Free; + end; +end; + +//-------------------- +//AddScore - Add one new Score to DB +//-------------------- +procedure TDataBaseSystem.AddScore(var Song: TSong; Level: integer; Name: string; Score: integer); +var +ID: Integer; +TableData: TSqliteTable; +begin + //ScoreDB := TSqliteDatabase.Create(sFilename); + try + //Prevent 0 Scores from being added + if (Score > 0) then + begin + + ID := ScoreDB.GetTableValue('SELECT `ID` FROM `US_Songs` WHERE `Artist` = "' + Song.Artist + '" AND `Title` = "' + Song.Title + '"'); + if ID = 0 then //Song doesn't exist -> Create + begin + ScoreDB.ExecSQL ('INSERT INTO `US_Songs` ( `ID` , `Artist` , `Title` , `TimesPlayed` ) VALUES (NULL , "' + Song.Artist + '", "' + Song.Title + '", "0");'); + ID := ScoreDB.GetTableValue('SELECT `ID` FROM `US_Songs` WHERE `Artist` = "' + Song.Artist + '" AND `Title` = "' + Song.Title + '"'); + if ID = 0 then //Could not Create Table + exit; + end; + //Create new Entry + ScoreDB.ExecSQL('INSERT INTO `US_Scores` ( `SongID` , `Difficulty` , `Player` , `Score` ) VALUES ("' + InttoStr(ID) + '", "' + InttoStr(Level) + '", "' + Name + '", "' + InttoStr(Score) + '");'); + + //Delete Last Position when there are more than 5 Entrys + if ScoreDB.GetTableValue('SELECT COUNT(`SongID`) FROM `US_Scores` WHERE `SongID` = "' + InttoStr(ID) + '" AND `Difficulty` = "' + InttoStr(Level) +'"') > 5 then + begin + TableData := ScoreDB.GetTable('SELECT `Player`, `Score` FROM `US_Scores` WHERE SongID = "' + InttoStr(ID) + '" AND `Difficulty` = "' + InttoStr(Level) +'" ORDER BY `Score` ASC LIMIT 1'); + ScoreDB.ExecSQL('DELETE FROM `US_Scores` WHERE SongID = "' + InttoStr(ID) + '" AND `Difficulty` = "' + InttoStr(Level) +'" AND `Player` = "' + TableData.FieldAsString(TableData.FieldIndex['Player']) + '" AND `Score` = "' + TableData.FieldAsString(TableData.FieldIndex['Score']) + '"'); + end; + + end; + finally + //ScoreDB.Free; + end; +end; + +//-------------------- +//WriteScore - Not needed with new System; But used for Increment Played Count +//-------------------- +procedure TDataBaseSystem.WriteScore(var Song: TSong); +begin + try + //Increase TimesPlayed + ScoreDB.ExecSQL ('UPDATE `us_songs` SET `TimesPlayed` = `TimesPlayed` + "1" WHERE `Title` = "' + Song.Title + '" AND `Artist` = "' + Song.Artist + '";'); + except + + end; +end; + +//-------------------- +//GetStats - Write some Stats to Array, Returns True if Chossen Page has Entrys +//Case Typ of +//0 - Best Scores +//1 - Best Singers +//2 - Most sung Songs +//3 - Most popular Band +//-------------------- +Function TDataBaseSystem.GetStats(var Stats: AStatResult; const Typ, Count: Byte; const Page: Cardinal; const Reversed: Boolean): Boolean; +var + Query: String; + TableData: TSqliteTable; +begin + Result := False; + + if (Length(Stats) < Count) then + Exit; + + {Todo: + Add Prevention that only Players with more than 5 Scores are Selected at Typ 2} + + //Create Query + Case Typ of + 0: Query := 'SELECT `Player` , `Difficulty` , `Score` , `Artist` , `Title` FROM `US_Scores` INNER JOIN `US_Songs` ON (`SongID` = `ID`) ORDER BY `Score`'; + 1: Query := 'SELECT `Player` , ROUND (Sum(`Score`) / COUNT(`Score`)) FROM `US_Scores` GROUP BY `Player` ORDER BY (Sum(`Score`) / COUNT(`Score`))'; + 2: Query := 'SELECT `Artist` , `Title` , `TimesPlayed` FROM `US_Songs` ORDER BY `TimesPlayed`'; + 3: Query := 'SELECT `Artist` , Sum(`TimesPlayed`) FROM `US_Songs` GROUP BY `Artist` ORDER BY Sum(`TimesPlayed`)'; + end; + + //Add Order Direction + If Reversed then + Query := Query + ' ASC' + else + Query := Query + ' DESC'; + + //Add Limit + Query := Query + ' LIMIT ' + InttoStr(Count * Page) + ', ' + InttoStr(Count) + ';'; + + //Execute Query + //try + TableData := ScoreDB.GetTable(Query); + {except + exit; + end;} + + //if Result empty -> Exit + if (TableData.RowCount < 1) then + exit; + + //Copy Result to Stats Array + while not TableData.Eof do + begin + Stats[TableData.Row].Typ := Typ; + + Case Typ of + 0:begin + Stats[TableData.Row].Singer := TableData.Fields[0]; + + Stats[TableData.Row].Difficulty := StrtoIntDef(TableData.Fields[1], 0); + + Stats[TableData.Row].Score := StrtoIntDef(TableData.Fields[2], 0){TableData.FieldAsInteger(2)}; + Stats[TableData.Row].SongArtist := TableData.Fields[3]; + Stats[TableData.Row].SongTitle := TableData.Fields[4]; + end; + + 1:begin + Stats[TableData.Row].Player := TableData.Fields[0]; + Stats[TableData.Row].AverageScore := StrtoIntDef(TableData.Fields[1], 0); + end; + + 2:begin + Stats[TableData.Row].Artist := TableData.Fields[0]; + Stats[TableData.Row].Title := TableData.Fields[1]; + Stats[TableData.Row].TimesSung := StrtoIntDef(TableData.Fields[2], 0); + end; + + 3:begin + Stats[TableData.Row].ArtistName := TableData.Fields[0]; + Stats[TableData.Row].TimesSungtot := StrtoIntDef(TableData.Fields[1], 0); + end; + + end; + + TableData.Next; + end; + + Result := True; +end; + +//-------------------- +//GetTotalEntrys - Get Total Num of entrys for a Stats Query +//-------------------- +Function TDataBaseSystem.GetTotalEntrys(const Typ: Byte): Cardinal; +var Query: String; +begin + //Create Query + Case Typ of + 0: Query := 'SELECT COUNT(`SongID`) FROM `US_Scores`;'; + 1: Query := 'SELECT COUNT(DISTINCT `Player`) FROM `US_Scores`;'; + 2: Query := 'SELECT COUNT(`ID`) FROM `US_Songs`;'; + 3: Query := 'SELECT COUNT(DISTINCT `Artist`) FROM `US_Songs`;'; + end; + + Result := ScoreDB.GetTableValue(Query); +end; + +end. diff --git a/Game/Code/Classes/UDraw.pas b/Game/Code/Classes/UDraw.pas new file mode 100644 index 00000000..077f5121 --- /dev/null +++ b/Game/Code/Classes/UDraw.pas @@ -0,0 +1,1669 @@ +unit UDraw; + +interface +uses UThemes, ModiSDK, UGraphicClasses; + +procedure SingDraw; +procedure SingModiDraw (PlayerInfo: TPlayerInfo); +procedure SingDrawBackground; +procedure SingDrawOscilloscope(X, Y, W, H: real; NrSound: integer); +procedure SingDrawNoteLines(Left, Top, Right: real; Space: integer); +procedure SingDrawBeatDelimeters(Left, Top, Right: real; NrCzesci: integer); +procedure SingDrawCzesc(Left, Top, Right: real; NrCzesci: integer; Space: integer); +procedure SingDrawPlayerCzesc(X, Y, W: real; NrGracza: integer; Space: integer); +procedure SingDrawPlayerBGCzesc(Left, Top, Right: real; NrCzesci, NrGracza: integer; Space: integer); + +// TimeBar mod +procedure SingDrawTimeBar(); +// eoa TimeBar mod + +{ for no use since we have UGraphicClasses +procedure SingDrawStar(X, Y, A: real); +procedure SingGoldenStar(X, Y, A: real); +} +// The Singbar +procedure SingDrawSingbar(X, Y, W, H: real; Percent: integer); + +//Phrasen Bonus - Line Bonus +procedure SingDrawLineBonus( const X, Y: Single; Color: TRGB; Alpha: Single; Text: string; Age: Integer); + +//Draw Editor NoteLines +procedure EditDrawCzesc(Left, Top, Right: real; NrCzesci: integer; Space: integer); + + +type + TRecR = record + Top: real; + Left: real; + Right: real; + Bottom: real; + + Width: real; + WMid: real; + Height: real; + HMid: real; + + Mid: real; + end; + +var + NotesW: real; + NotesH: real; + Starfr: integer; + StarfrG: integer; + + + + //SingBar Mod + TickOld: cardinal; + TickOld2:cardinal; + //end Singbar Mod + + + + +const + Przedz = 32; + +implementation + +uses Windows, OpenGL12, UGraphic, SysUtils, UMusic, URecord, ULog, UScreenSing, UScreenSingModi, ULyrics, UMain, TextGL, UTexture, UDrawTexture, UIni, Math, UDLLManager; + +procedure SingDrawBackground; +var + Rec: TRecR; + TexRec: TRecR; +begin + if ScreenSing.Tex_Background.TexNum >= 1 then begin + + glClearColor (1, 1, 1, 1); + glColor4f (1, 1, 1, 1); + + if (Ini.MovieSize <= 1) then //HalfSize BG + begin + (* half screen + gradient *) + Rec.Top := 110; // 80 + Rec.Bottom := Rec.Top + 20; + Rec.Left := 0; + Rec.Right := 800; + + TexRec.Top := (Rec.Top / 600) * ScreenSing.Tex_Background.TexH; + TexRec.Bottom := (Rec.Bottom / 600) * ScreenSing.Tex_Background.TexH; + TexRec.Left := 0; + TexRec.Right := ScreenSing.Tex_Background.TexW; + + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, ScreenSing.Tex_Background.TexNum); + glEnable(GL_BLEND); + glBegin(GL_QUADS); + (* gradient draw *) + (* top *) + glColor4f(1, 1, 1, 0); + glTexCoord2f(TexRec.Right, TexRec.Top); glVertex2f(Rec.Right, Rec.Top); + glTexCoord2f(TexRec.Left, TexRec.Top); glVertex2f(Rec.Left, Rec.Top); + glColor4f(1, 1, 1, 1); + glTexCoord2f(TexRec.Left, TexRec.Bottom); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(TexRec.Right, TexRec.Bottom); glVertex2f(Rec.Right, Rec.Bottom); + (* mid *) + Rec.Top := Rec.Bottom; + Rec.Bottom := 490 - 20; // 490 - 20 + TexRec.Top := TexRec.Bottom; + TexRec.Bottom := (Rec.Bottom / 600) * ScreenSing.Tex_Background.TexH; + glTexCoord2f(TexRec.Left, TexRec.Top); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(TexRec.Left, TexRec.Bottom); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(TexRec.Right, TexRec.Bottom); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(TexRec.Right, TexRec.Top); glVertex2f(Rec.Right, Rec.Top); + (* bottom *) + Rec.Top := Rec.Bottom; + Rec.Bottom := 490; // 490 + TexRec.Top := TexRec.Bottom; + TexRec.Bottom := (Rec.Bottom / 600) * ScreenSing.Tex_Background.TexH; + glTexCoord2f(TexRec.Right, TexRec.Top); glVertex2f(Rec.Right, Rec.Top); + glTexCoord2f(TexRec.Left, TexRec.Top); glVertex2f(Rec.Left, Rec.Top); + glColor4f(1, 1, 1, 0); + glTexCoord2f(TexRec.Left, TexRec.Bottom); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(TexRec.Right, TexRec.Bottom); glVertex2f(Rec.Right, Rec.Bottom); + + glEnd; + glDisable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + end + else //Full Size BG + begin + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, ScreenSing.Tex_Background.TexNum); + //glEnable(GL_BLEND); + glBegin(GL_QUADS); + + glTexCoord2f(0, 0); glVertex2f(0, 0); + glTexCoord2f(0, ScreenSing.Tex_Background.TexH); glVertex2f(0, 600); + glTexCoord2f( ScreenSing.Tex_Background.TexW, ScreenSing.Tex_Background.TexH); glVertex2f(800, 600); + glTexCoord2f( ScreenSing.Tex_Background.TexW, 0); glVertex2f(800, 0); + + glEnd; + glDisable(GL_TEXTURE_2D); + //glDisable(GL_BLEND); + end; + end; +end; + +procedure SingDrawOscilloscope(X, Y, W, H: real; NrSound: integer); +var + Pet: integer; +begin; +// Log.LogStatus('Oscilloscope', 'SingDraw'); + glColor3f(Skin_OscR, Skin_OscG, Skin_OscB); + {if (ParamStr(1) = '-black') or (ParamStr(1) = '-fsblack') then + glColor3f(1, 1, 1); } + + glBegin(GL_LINE_STRIP); + glVertex2f(X, -Sound[NrSound].BufferArray[1] / $10000 * H + Y + H/2); + for Pet := 2 to Sound[NrSound].n div 1 do begin + glVertex2f(X + (Pet-1) * W / (Sound[NrSound].n - 1), + -Sound[NrSound].BufferArray[Pet] / $10000 * H + Y + H/2); + end; + glEnd; +end; + +procedure SingDrawNoteLines(Left, Top, Right: real; Space: integer); +var + Pet: integer; +begin + glEnable(GL_BLEND); + glColor4f(Skin_P1_LinesR, Skin_P1_LinesG, Skin_P1_LinesB, 0.4); + glBegin(GL_LINES); + for Pet := 0 to 9 do begin + glVertex2f(Left, Top + Pet * Space); + glVertex2f(Right, Top + Pet * Space); + end; + glEnd; + glDisable(GL_BLEND); +end; + +procedure SingDrawBeatDelimeters(Left, Top, Right: real; NrCzesci: integer); +var + Pet: integer; + TempR: real; +begin + TempR := (Right-Left) / (Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].Koniec - Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].StartNote); + glEnable(GL_BLEND); + glBegin(GL_LINES); + for Pet := Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].StartNote to Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].Koniec do begin + if (Pet mod Czesci[NrCzesci].Resolution) = Czesci[NrCzesci].NotesGAP then + glColor4f(0, 0, 0, 1) + else + glColor4f(0, 0, 0, 0.3); + glVertex2f(Left + TempR * (Pet - Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].StartNote), Top); + glVertex2f(Left + TempR * (Pet - Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].StartNote), Top + 135); + end; + glEnd; + glDisable(GL_BLEND); +end; + +// draw blank Notebars +procedure SingDrawCzesc(Left, Top, Right: real; NrCzesci: integer; Space: integer); +var + Rec: TRecR; + Pet: integer; + TempR: real; + R,G,B: real; + + GoldenStarPos : real; +begin + glColor3f(1, 1, 1); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + TempR := (Right-Left) / (Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].Koniec - Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].StartNote); + with Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt] do begin + for Pet := 0 to HighNut do begin + with Nuta[Pet] do begin + if not FreeStyle then begin + + + if Ini.EffectSing = 0 then + // If Golden note Effect of then Change not Color + begin + case Wartosc of + 1: glColor4f(1, 1, 1, 0.85); + 2: glColor4f(1, 1, 0.3, 0.85); // no stars, paint yellow -> glColor4f(1, 1, 0.3, 0.85); + end; // case + end //Else all Notes same Color + else + glColor4f(1, 1, 1, 0.85); + + // lewa czesc - left part + Rec.Left := (Start-Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].StartNote) * TempR + Left + 0.5 + 10*ScreenX; + Rec.Right := Rec.Left + NotesW; + Rec.Top := Top - (Ton-BaseNote)*Space/2 - NotesH; + Rec.Bottom := Rec.Top + 2 * NotesH; + glBindTexture(GL_TEXTURE_2D, Tex_Left[Color].TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + + //We keep the postion of the top left corner b4 it's overwritten + GoldenStarPos := Rec.Left; + //done + + + // srodkowa czesc - middle part + Rec.Left := Rec.Right; + Rec.Right := (Start+Dlugosc-Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].StartNote) * TempR + Left - NotesW - 0.5 + 10*ScreenX; + + glBindTexture(GL_TEXTURE_2D, Tex_Mid[Color].TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + + // prawa czesc - right part + Rec.Left := Rec.Right; + Rec.Right := Rec.Right + NotesW; + + glBindTexture(GL_TEXTURE_2D, Tex_Right[Color].TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + + // Golden Star Patch + if (Wartosc = 2) AND (Ini.EffectSing=1) then + begin + GoldenRec.SaveGoldenStarsRec(GoldenStarPos, Rec.Top, Rec.Right, Rec.Bottom); + end; + + end; // if not FreeStyle + end; // with + end; // for + end; // with + + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); +end; + + +// draw sung notes +procedure SingDrawPlayerCzesc(X, Y, W: real; NrGracza: integer; Space: integer); +var + TempR: real; + Rec: TRecR; + N: integer; + R: real; + G: real; + B: real; + A: real; + NotesH2: real; + begin +// Log.LogStatus('Player notes', 'SingDraw'); + +// if NrGracza = 0 then LoadColor(R, G, B, 'P1Light') +// else LoadColor(R, G, B, 'P2Light'); + +// R := 71/255; +// G := 175/255; +// B := 247/255; + + + glColor3f(1, 1, 1); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + if Player[NrGracza].IlNut > 0 then begin + TempR := W / (Czesci[0].Czesc[Czesci[0].Akt].Koniec - Czesci[0].Czesc[Czesci[0].Akt].StartNote); + for N := 0 to Player[NrGracza].HighNut do begin + with Player[NrGracza].Nuta[N] do begin + // lewa czesc + Rec.Left := X + (Start-Czesci[0].Czesc[Czesci[0].Akt].StartNote) * TempR + 0.5 + 10*ScreenX; + Rec.Right := Rec.Left + NotesW; + + + // Half size Notes Patch + if Hit then begin + NotesH2 := NotesH + end else begin + NotesH2 := int(NotesH * 0.65); + end; //if + + + + // if True then + Rec.Top := Y - (Ton-Czesci[0].Czesc[Czesci[0].Akt].BaseNote)*Space/2 - NotesH2; + Rec.Bottom := Rec.Top + 2 *NotesH2; + + glColor3f(1, 1, 1); + glBindTexture(GL_TEXTURE_2D, Tex_Left[NrGracza+1].TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + + // srodkowa czesc + Rec.Left := Rec.Right; + Rec.Right := X + (Start+Dlugosc-Czesci[0].Czesc[Czesci[0].Akt].StartNote) * TempR - NotesW - 0.5 + 10*ScreenX; + // (nowe) + if (Start+Dlugosc-1 = Czas.AktBeatD) then + Rec.Right := Rec.Right - (1-Frac(Czas.MidBeatD)) * TempR; + + if Rec.Right <= Rec.Left then Rec.Right := Rec.Left; + + +// glColor3f(R, G, B); +// glBindTexture(GL_TEXTURE_2D, Tex_MidGray.TexNum); + glBindTexture(GL_TEXTURE_2D, Tex_Mid[NrGracza+1].TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + glColor3f(1, 1, 1); + + // prawa czesc + Rec.Left := Rec.Right; + Rec.Right := Rec.Right + NotesW; + + glBindTexture(GL_TEXTURE_2D, Tex_Right[NrGracza+1].TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + + + + //Rec.Right := X + (Start+Dlugosc-Czesci[0].Czesc[Czesci[0].Akt].StartNote) * TempR - NotesW - 0.5 + 10*ScreenX; + //if (Start+Dlugosc-1 = Czas.AktBeatD) then + if Perfect and (Ini.EffectSing=1) then begin +// A := sqrt((1+sin(Music.Position * 3))/2); + A := 1 - 2*(Czas.Teraz - GetTimeFromBeat(Start+Dlugosc)); + if not (Start+Dlugosc-1 = Czas.AktBeatD) then + + //Star animation counter + //inc(Starfr); + //Starfr := Starfr mod 128; + GoldenRec.SavePerfectNotePos(Rec.Left, Rec.Top); + { SingDrawStar(Rec.Left+2, Rec.Top+4, A);} + end; + + // detekt +{ Rec.Left := Round((Detekt-Czesci.Czesc[Czesci.Akt].Start) * TempR) + 130; + glColor3f(1, 0.2, 0.2); + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBegin(GL_QUADS); + glVertex(Rec.Left, Rec.Top-5); + glVertex(Rec.Left, Rec.Bottom+5); + glVertex(Rec.Left+1, Rec.Bottom+5); + glVertex(Rec.Left+1, Rec.Top-5); + glEnd; + glColor3f(1, 1, 1); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D);} + + // detekt + FFT length +{ Rec.Right := (Detekt-Czesci.Czesc[Czesci.Akt].Start) * TempR + 130; + // TempR = dlugosc 1 kostki + // 60 * 4 / BPM = czas w sekundach na 1 kostke, np. 0,4s + // 4096 / 44100 = czas jednego sampla FFT, np. 0,1s + // ile to ma kostek? np. 0.25 + // (4096 / 44100) / (60 * 4 / BPM), np. 0,1s / 0,4s = 0.25 + // * TempR = dlugosc sampla FFT + Rec.Left := Rec.Right - (Sound.n / 44100) / (60 * 4 / Muzyka.BPM) * TempR; + + glColor3f(1, 0.2, 0.2); + glVertex(Rec.Left, Rec.Top-4); + glVertex(Rec.Left, Rec.Bottom+4); + glVertex(Rec.Right, Rec.Bottom+4); + glVertex(Rec.Right, Rec.Top-4);} + + end; // with + end; // for + // eigentlich brauchen wir hier einen vergleich, um festzustellen, ob wir mit + // singen schon weiter wären, als bei Rec.Right, _auch, wenn nicht gesungen wird_ + + // passing on NrGracza... hope this is really something like the player-number, not only + // some kind of weird index into a colour-table + + if (Ini.EffectSing=1) then + GoldenRec.GoldenNoteTwinkle(Rec.Top,Rec.Bottom,Rec.Right, NrGracza); + end; // if +end; + +//draw Note glow +procedure SingDrawPlayerBGCzesc(Left, Top, Right: real; NrCzesci, NrGracza: integer; Space: integer); +var + Rec: TRecR; + Pet: integer; + TempR: real; + R,G,B: real; + X1, X2, X3, X4: real; + W, H: real; +begin + if (Player[NrGracza].ScoreTotalI >= 0) then begin + glColor4f(1, 1, 1, sqrt((1+sin(Music.Position * 3))/4)/ 2 + 0.5 ); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + TempR := (Right-Left) / (Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].Koniec - Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].StartNote); + with Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt] do begin + for Pet := 0 to HighNut do begin + with Nuta[Pet] do begin + if not FreeStyle then begin + // begin: 14, 20 + // easy: 6, 11 + W := NotesW * 2 + 2; + H := NotesH * 1.5 + 3.5; + + X2 := (Start-Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].StartNote) * TempR + Left + 0.5 + 10*ScreenX + 4; // wciecie + X1 := X2-W; + + X3 := (Start+Dlugosc-Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].StartNote) * TempR + Left - 0.5 + 10*ScreenX - 4; // wciecie + X4 := X3+W; + + // left + Rec.Left := X1; + Rec.Right := X2; + Rec.Top := Top - (Ton-BaseNote)*Space/2 - H; + Rec.Bottom := Rec.Top + 2 * H; + + glBindTexture(GL_TEXTURE_2D, Tex_BG_Left[NrGracza+1].TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + + + // srodkowa czesc + Rec.Left := X2; + Rec.Right := X3; + + glBindTexture(GL_TEXTURE_2D, Tex_BG_Mid[NrGracza+1].TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + + // prawa czesc + Rec.Left := X3; + Rec.Right := X4; + + glBindTexture(GL_TEXTURE_2D, Tex_BG_Right[NrGracza+1].TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + end; // if not FreeStyle + end; // with + end; // for + end; // with + + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + end; +end; + +{not used anymore tough we have UGraphicClasses +procedure SingDrawStar(X, Y, A: real); +var + TempR: real; + W, H: real; + Starframe: real; + begin + W := 32; + H := 32; + +// Golden Star Patch +// case Z of +// 1: glColor4f(1, 1, 1, A); +// 2: glColor4f(1, 1, 0.3, A); +// end; // case + + glColor4f(1, 1, 1, A); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, Tex_Note_Star.TexNum); + + Starframe := 15 - ((GetTickCount div 33) mod 16); + + glBegin(GL_QUADS); + glTexCoord2f((1/16) * Starframe, 0); glVertex2f(X-W, Y-H); + glTexCoord2f((1/16) * Starframe + (1/16), 0); glVertex2f(X-W, Y+H); + glTexCoord2f((1/16) * Starframe + (1/16), 1); glVertex2f(X+W, Y+H); + glTexCoord2f((1/16) * Starframe, 1); glVertex2f(X+W, Y-H); + glEnd; +end; +} + +{not used anymore tough we have UGraphicClasses +procedure SingGoldenStar(X, Y, A: real); +var + TempR: real; + W, H: real; + StarfrG2: real; + begin + W := 16; + H := 16; + glColor4f(1, 1, 0.3, A); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, Tex_Note_Star.TexNum); + StarfrG2 := 15 - ((GetTickCount div 67) mod 16); + glBegin(GL_QUADS); + //x1 + glTexCoord2f((1/16) * StarfrG2, 0); glVertex2f(X-W, Y-H); + glTexCoord2f((1/16) * StarfrG2 + (1/16), 0); glVertex2f(X-W, Y+H); + glTexCoord2f((1/16) * StarfrG2 + (1/16), 1); glVertex2f(X+W, Y+H); + glTexCoord2f((1/16) * StarfrG2, 1); glVertex2f(X+W, Y-H); + glEnd; +end; +} + +procedure SingDraw; +var + Pet: integer; + Pet2: integer; + TempR: real; + Rec: TRecR; + TexRec: TRecR; + NR: TRecR; + FS: real; + BarFrom: integer; + BarAlpha: real; + BarWspol: real; + TempCol: real; + Tekst: string; + LyricTemp: string; + PetCz: integer; + + + + //SingBar Mod + A: Integer; + E: Integer; + I: Integer; + //end Singbar Mod + + + +begin + // positions + if Ini.SingWindow = 0 then begin + NR.Left := 120; + end else begin + NR.Left := 20; + end; + NR.Right := 780; + + NR.Width := NR.Right - NR.Left; + NR.WMid := NR.Width / 2; + NR.Mid := NR.Left + NR.WMid; + + // background //BG Fullsize Mod + //SingDrawBackground; + + //TimeBar mod + SingDrawTimeBar(); + //eoa TimeBar mod + + // rysuje paski pod nutami + if PlayersPlay = 1 then + SingDrawNoteLines(Nr.Left + 10*ScreenX, Skin_P2_NotesB - 105, Nr.Right + 10*ScreenX, 15); + if (PlayersPlay = 2) or (PlayersPlay = 4) then begin + SingDrawNoteLines(Nr.Left + 10*ScreenX, Skin_P1_NotesB - 105, Nr.Right + 10*ScreenX, 15); + SingDrawNoteLines(Nr.Left + 10*ScreenX, Skin_P2_NotesB - 105, Nr.Right + 10*ScreenX, 15); + end; + + if (PlayersPlay = 3) or (PlayersPlay = 6) then begin + SingDrawNoteLines(Nr.Left + 10*ScreenX, 120, Nr.Right + 10*ScreenX, 12); + SingDrawNoteLines(Nr.Left + 10*ScreenX, 245, Nr.Right + 10*ScreenX, 12); + SingDrawNoteLines(Nr.Left + 10*ScreenX, 370, Nr.Right + 10*ScreenX, 12); + end; + + // rysuje tekst - new Lyric engine + ScreenSing.LyricMain.Draw; + ScreenSing.LyricSub.Draw; + + // rysuje pasek, podpowiadajacy poczatek spiwania w scenie + FS := 1.3; + BarFrom := Czesci[0].Czesc[Czesci[0].Akt].StartNote - Czesci[0].Czesc[Czesci[0].Akt].Start; + if BarFrom > 40 then BarFrom := 40; + if (Czesci[0].Czesc[Czesci[0].Akt].StartNote - Czesci[0].Czesc[Czesci[0].Akt].Start > 8) and // dluga przerwa //16->12 for more help bars and then 12->8 for even more + (Czesci[0].Czesc[Czesci[0].Akt].StartNote - Czas.MidBeat > 0) and // przed tekstem + (Czesci[0].Czesc[Czesci[0].Akt].StartNote - Czas.MidBeat < 40) then begin // ale nie za wczesnie + BarWspol := (Czas.MidBeat - (Czesci[0].Czesc[Czesci[0].Akt].StartNote - BarFrom)) / BarFrom; + Rec.Left := NR.Left + BarWspol * +// (NR.WMid - Czesci[0].Czesc[Czesci[0].Akt].LyricWidth / 2 * FS - 50); + (ScreenSing.LyricMain.ClientX - NR.Left - 50) + 10*ScreenX; + Rec.Right := Rec.Left + 50; + Rec.Top := Skin_LyricsT + 3; + Rec.Bottom := Rec.Top + 33;//SingScreen.LyricMain.Size * 3; +{ // zapalanie + BarAlpha := (BarWspol*10) * 0.5; + if BarAlpha > 0.5 then BarAlpha := 0.5; + + // gaszenie + if BarWspol > 0.95 then BarAlpha := 0.5 * (1 - (BarWspol - 0.95) * 20);} + + //Change fuer Crazy Joker + + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, Tex_Lyric_Help_Bar.TexNum); + glBegin(GL_QUADS); + glColor4f(1, 1, 1, 0); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glColor4f(1, 1, 1, 0.5); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + glDisable(GL_BLEND); + + end; + + // oscilloscope + if Ini.Oscilloscope = 1 then begin + if PlayersPlay = 1 then + SingDrawOscilloscope(190 + 10*ScreenX, 55, 180, 40, 0); + + if PlayersPlay = 2 then begin + SingDrawOscilloscope(190 + 10*ScreenX, 55, 180, 40, 0); + SingDrawOscilloscope(425 + 10*ScreenX, 55, 180, 40, 1); + end; + + if PlayersPlay = 4 then begin + if ScreenAct = 1 then begin + SingDrawOscilloscope(190 + 10*ScreenX, 55, 180, 40, 0); + SingDrawOscilloscope(425 + 10*ScreenX, 55, 180, 40, 1); + end; + if ScreenAct = 2 then begin + SingDrawOscilloscope(190 + 10*ScreenX, 55, 180, 40, 2); + SingDrawOscilloscope(425 + 10*ScreenX, 55, 180, 40, 3); + end; + end; + + if PlayersPlay = 3 then begin + SingDrawOscilloscope(75 + 10*ScreenX, 95, 100, 20, 0); + SingDrawOscilloscope(370 + 10*ScreenX, 95, 100, 20, 1); + SingDrawOscilloscope(670 + 10*ScreenX, 95, 100, 20, 2); + end; + + if PlayersPlay = 6 then begin + if ScreenAct = 1 then begin + SingDrawOscilloscope( 75 + 10*ScreenX, 95, 100, 20, 0); + SingDrawOscilloscope(370 + 10*ScreenX, 95, 100, 20, 1); + SingDrawOscilloscope(670 + 10*ScreenX, 95, 100, 20, 2); + end; + if ScreenAct = 2 then begin + SingDrawOscilloscope( 75 + 10*ScreenX, 95, 100, 20, 3); + SingDrawOscilloscope(370 + 10*ScreenX, 95, 100, 20, 4); + SingDrawOscilloscope(670 + 10*ScreenX, 95, 100, 20, 5); + end; + end; + + end + + //SingBar Mod + //modded again to make it moveable: it's working, so why try harder + else if Ini.Oscilloscope = 2 then begin + A := GetTickCount div 33; + if A <> Tickold then begin + Tickold := A; + for E := 0 to (PlayersPlay - 1) do begin //Set new Pos + Alpha + I := Player[E].ScorePercentTarget - Player[E].ScorePercent; + if I > 0 then Inc(Player[E].ScorePercent) + else if I < 0 then Dec(Player[E].ScorePercent); + end; //for + end; //if + if PlayersPlay = 1 then begin + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[0].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1SingBar.x, Theme.Sing.StaticP1SingBar.y, Theme.Sing.StaticP1SingBar.w, Theme.Sing.StaticP1SingBar.h , Player[0].ScorePercent); + end; + if PlayersPlay = 2 then begin + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[0].ScorePercent); + //SingDrawSingbar(620 + 10*ScreenX, 95, 100, 8, Player[1].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1TwoPSingBar.x, Theme.Sing.StaticP1TwoPSingBar.y, Theme.Sing.StaticP1TwoPSingBar.w, Theme.Sing.StaticP1TwoPSingBar.h , Player[0].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP2RSingBar.x, Theme.Sing.StaticP2RSingBar.y, Theme.Sing.StaticP2RSingBar.w, Theme.Sing.StaticP2RSingBar.h , Player[1].ScorePercent); + end; + if PlayersPlay = 3 then begin + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[0].ScorePercent); + //SingDrawSingbar(370 + 10*ScreenX, 95, 100, 8, Player[1].ScorePercent); + //SingDrawSingbar(670 + 10*ScreenX, 95, 100, 8, Player[2].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1ThreePSingBar.x, Theme.Sing.StaticP1ThreePSingBar.y, Theme.Sing.StaticP1ThreePSingBar.w, Theme.Sing.StaticP1ThreePSingBar.h , Player[0].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP2MSingBar.x, Theme.Sing.StaticP2MSingBar.y, Theme.Sing.StaticP2MSingBar.w, Theme.Sing.StaticP2MSingBar.h , Player[1].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP3SingBar.x, Theme.Sing.StaticP3SingBar.y, Theme.Sing.StaticP3SingBar.w, Theme.Sing.StaticP3SingBar.h , Player[2].ScorePercent); + end; + if PlayersPlay = 4 then begin + if ScreenAct = 1 then begin + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[0].ScorePercent); + //SingDrawSingbar(620 + 10*ScreenX, 95, 100, 8, Player[1].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1TwoPSingBar.x, Theme.Sing.StaticP1TwoPSingBar.y, Theme.Sing.StaticP1TwoPSingBar.w, Theme.Sing.StaticP1TwoPSingBar.h , Player[0].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP2RSingBar.x, Theme.Sing.StaticP2RSingBar.y, Theme.Sing.StaticP2RSingBar.w, Theme.Sing.StaticP2RSingBar.h , Player[1].ScorePercent); + end; + if ScreenAct = 2 then begin + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[2].ScorePercent); + //SingDrawSingbar(620 + 10*ScreenX, 95, 100, 8, Player[3].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1TwoPSingBar.x, Theme.Sing.StaticP1TwoPSingBar.y, Theme.Sing.StaticP1TwoPSingBar.w, Theme.Sing.StaticP1TwoPSingBar.h , Player[2].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP2RSingBar.x, Theme.Sing.StaticP2RSingBar.y, Theme.Sing.StaticP2RSingBar.w, Theme.Sing.StaticP2RSingBar.h , Player[3].ScorePercent); + end; + end; + if PlayersPlay = 6 then begin + if ScreenAct = 1 then begin + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[0].ScorePercent); + //SingDrawSingbar(370 + 10*ScreenX, 95, 100, 8, Player[1].ScorePercent); + //SingDrawSingbar(670 + 10*ScreenX, 95, 100, 8, Player[2].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1ThreePSingBar.x, Theme.Sing.StaticP1ThreePSingBar.y, Theme.Sing.StaticP1ThreePSingBar.w, Theme.Sing.StaticP1ThreePSingBar.h , Player[0].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP2MSingBar.x, Theme.Sing.StaticP2MSingBar.y, Theme.Sing.StaticP2MSingBar.w, Theme.Sing.StaticP2MSingBar.h , Player[1].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP3SingBar.x, Theme.Sing.StaticP3SingBar.y, Theme.Sing.StaticP3SingBar.w, Theme.Sing.StaticP3SingBar.h , Player[2].ScorePercent); + end; + if ScreenAct = 2 then begin + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[3].ScorePercent); + //SingDrawSingbar(370 + 10*ScreenX, 95, 100, 8, Player[4].ScorePercent); + //SingDrawSingbar(670 + 10*ScreenX, 95, 100, 8, Player[5].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1ThreePSingBar.x, Theme.Sing.StaticP1ThreePSingBar.y, Theme.Sing.StaticP1ThreePSingBar.w, Theme.Sing.StaticP1ThreePSingBar.h , Player[3].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP2MSingBar.x, Theme.Sing.StaticP2MSingBar.y, Theme.Sing.StaticP2MSingBar.w, Theme.Sing.StaticP2MSingBar.h , Player[4].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP3SingBar.x, Theme.Sing.StaticP3SingBar.y, Theme.Sing.StaticP3SingBar.w, Theme.Sing.StaticP3SingBar.h , Player[5].ScorePercent); + end; + end; + end; + //end Singbar Mod + + //PhrasenBonus - Line Bonus Mod + if Ini.LineBonus > 0 then begin + A := GetTickCount div 33; + if (A <> Tickold2) AND (Player[0].LineBonus_Visible) then begin + Tickold2 := A; + for E := 0 to (PlayersPlay - 1) do begin + //Change Alpha + Player[E].LineBonus_Alpha := Player[E].LineBonus_Alpha - 0.02; + if Player[E].LineBonus_Alpha <= 0 then + begin + Player[E].LineBonus_Age := 0; + Player[E].LineBonus_Visible := False + end + else + begin + inc(Player[E].LineBonus_Age, 1); + //Change Position + if (Player[E].LineBonus_PosX < Player[E].LineBonus_TargetX) then + Player[E].LineBonus_PosX := Player[E].LineBonus_PosX + (2 - Player[E].LineBonus_Alpha * 1.5) + else if (Player[E].LineBonus_PosX > Player[E].LineBonus_TargetX) then + Player[E].LineBonus_PosX := Player[E].LineBonus_PosX - (2 - Player[E].LineBonus_Alpha * 1.5); + + if (Player[E].LineBonus_PosY < Player[E].LineBonus_TargetY) then + Player[E].LineBonus_PosY := Player[E].LineBonus_PosY + (2 - Player[E].LineBonus_Alpha * 1.5) + else if (Player[E].LineBonus_PosY > Player[E].LineBonus_TargetY) then + Player[E].LineBonus_PosY := Player[E].LineBonus_PosY - (2 - Player[E].LineBonus_Alpha * 1.5); + + end; + end; + end; //if + + if PlayersPlay = 1 then begin + SingDrawLineBonus( Player[0].LineBonus_PosX, Player[0].LineBonus_PosY, Player[0].LineBonus_Color, Player[0].LineBonus_Alpha, Player[0].LineBonus_Text, Player[0].LineBonus_Age); + end + else if PlayersPlay = 2 then begin + SingDrawLineBonus( Player[0].LineBonus_PosX, Player[0].LineBonus_PosY, Player[0].LineBonus_Color, Player[0].LineBonus_Alpha, Player[0].LineBonus_Text, Player[0].LineBonus_Age); + SingDrawLineBonus( Player[1].LineBonus_PosX, Player[1].LineBonus_PosY, Player[1].LineBonus_Color, Player[1].LineBonus_Alpha, Player[1].LineBonus_Text, Player[1].LineBonus_Age); + end + else if PlayersPlay = 3 then begin + SingDrawLineBonus( Player[0].LineBonus_PosX, Player[0].LineBonus_PosY, Player[0].LineBonus_Color, Player[0].LineBonus_Alpha, Player[0].LineBonus_Text, Player[0].LineBonus_Age); + SingDrawLineBonus( Player[1].LineBonus_PosX, Player[1].LineBonus_PosY, Player[1].LineBonus_Color, Player[1].LineBonus_Alpha, Player[1].LineBonus_Text, Player[1].LineBonus_Age); + SingDrawLineBonus( Player[2].LineBonus_PosX, Player[2].LineBonus_PosY, Player[2].LineBonus_Color, Player[2].LineBonus_Alpha, Player[2].LineBonus_Text, Player[2].LineBonus_Age); + end + else if PlayersPlay = 4 then begin + if ScreenAct = 1 then begin + SingDrawLineBonus( Player[0].LineBonus_PosX, Player[0].LineBonus_PosY, Player[0].LineBonus_Color, Player[0].LineBonus_Alpha, Player[0].LineBonus_Text, Player[0].LineBonus_Age); + SingDrawLineBonus( Player[1].LineBonus_PosX, Player[1].LineBonus_PosY, Player[1].LineBonus_Color, Player[1].LineBonus_Alpha, Player[1].LineBonus_Text, Player[1].LineBonus_Age); + end; + if ScreenAct = 2 then begin + SingDrawLineBonus( Player[2].LineBonus_PosX, Player[2].LineBonus_PosY, Player[2].LineBonus_Color, Player[2].LineBonus_Alpha, Player[2].LineBonus_Text, Player[2].LineBonus_Age); + SingDrawLineBonus( Player[3].LineBonus_PosX, Player[3].LineBonus_PosY, Player[3].LineBonus_Color, Player[3].LineBonus_Alpha, Player[3].LineBonus_Text, Player[3].LineBonus_Age); + end; + end; + if PlayersPlay = 6 then begin + if ScreenAct = 1 then begin + SingDrawLineBonus( Player[0].LineBonus_PosX, Player[0].LineBonus_PosY, Player[0].LineBonus_Color, Player[0].LineBonus_Alpha, Player[0].LineBonus_Text, Player[0].LineBonus_Age); + SingDrawLineBonus( Player[1].LineBonus_PosX, Player[1].LineBonus_PosY, Player[1].LineBonus_Color, Player[1].LineBonus_Alpha, Player[1].LineBonus_Text, Player[1].LineBonus_Age); + SingDrawLineBonus( Player[2].LineBonus_PosX, Player[2].LineBonus_PosY, Player[2].LineBonus_Color, Player[2].LineBonus_Alpha, Player[2].LineBonus_Text, Player[2].LineBonus_Age); + end; + if ScreenAct = 2 then begin + SingDrawLineBonus( Player[3].LineBonus_PosX, Player[3].LineBonus_PosY, Player[3].LineBonus_Color, Player[3].LineBonus_Alpha, Player[3].LineBonus_Text, Player[3].LineBonus_Age); + SingDrawLineBonus( Player[4].LineBonus_PosX, Player[4].LineBonus_PosY, Player[4].LineBonus_Color, Player[4].LineBonus_Alpha, Player[4].LineBonus_Text, Player[4].LineBonus_Age); + SingDrawLineBonus( Player[5].LineBonus_PosX, Player[5].LineBonus_PosY, Player[5].LineBonus_Color, Player[5].LineBonus_Alpha, Player[5].LineBonus_Text, Player[5].LineBonus_Age); + end; + end; + end; + //PhrasenBonus - Line Bonus Mod End + + + // rysuje paski +// Log.LogStatus('Original notes', 'SingDraw'); + case Ini.Difficulty of + 0: + begin + NotesH := 11; // 9 + NotesW := 6; // 5 + end; + 1: + begin + NotesH := 8; // 7 + NotesW := 4; // 4 + end; + 2: + begin + NotesH := 5; + NotesW := 3; + end; + end; + + if PlayersPlay = 1 then begin + SingDrawPlayerBGCzesc(NR.Left + 20, Skin_P2_NotesB, NR.Right - 20, 0, 0, 15); + SingDrawCzesc(NR.Left + 20, Skin_P2_NotesB, NR.Right - 20, 0, 15); + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Width - 40, 0, 15); + end; + + if (PlayersPlay = 2) then begin + SingDrawPlayerBGCzesc(Nr.Left + 20, Skin_P1_NotesB, Nr.Right - 20, 0, 0, 15); + SingDrawPlayerBGCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Right - 20, 0, 1, 15); + + SingDrawCzesc(NR.Left + 20, Skin_P1_NotesB, NR.Right - 20, 0, 15); + SingDrawCzesc(NR.Left + 20, Skin_P2_NotesB, NR.Right - 20, 0, 15); + + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P1_NotesB, Nr.Width - 40, 0, 15); + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Width - 40, 1, 15); + end; + + if PlayersPlay = 3 then begin + NotesW := NotesW * 0.8; + NotesH := NotesH * 0.8; + + SingDrawPlayerBGCzesc(Nr.Left + 20, 120+95, Nr.Right - 20, 0, 0, 12); + SingDrawPlayerBGCzesc(Nr.Left + 20, 245+95, Nr.Right - 20, 0, 1, 12); + SingDrawPlayerBGCzesc(Nr.Left + 20, 370+95, Nr.Right - 20, 0, 2, 12); + + SingDrawCzesc(NR.Left + 20, 120+95, NR.Right - 20, 0, 12); + SingDrawCzesc(NR.Left + 20, 245+95, NR.Right - 20, 0, 12); + SingDrawCzesc(NR.Left + 20, 370+95, NR.Right - 20, 0, 12); + + SingDrawPlayerCzesc(Nr.Left + 20, 120+95, Nr.Width - 40, 0, 12); + SingDrawPlayerCzesc(Nr.Left + 20, 245+95, Nr.Width - 40, 1, 12); + SingDrawPlayerCzesc(Nr.Left + 20, 370+95, Nr.Width - 40, 2, 12); + end; + + if PlayersPlay = 4 then begin + if ScreenAct = 1 then begin + SingDrawPlayerBGCzesc(Nr.Left + 20, Skin_P1_NotesB, Nr.Right - 20, 0, 0, 15); + SingDrawPlayerBGCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Right - 20, 0, 1, 15); + end; + if ScreenAct = 2 then begin + SingDrawPlayerBGCzesc(Nr.Left + 20, Skin_P1_NotesB, Nr.Right - 20, 0, 2, 15); + SingDrawPlayerBGCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Right - 20, 0, 3, 15); + end; + + SingDrawCzesc(NR.Left + 20, Skin_P1_NotesB, NR.Right - 20, 0, 15); + SingDrawCzesc(NR.Left + 20, Skin_P2_NotesB, NR.Right - 20, 0, 15); + + if ScreenAct = 1 then begin + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P1_NotesB, Nr.Width - 40, 0, 15); + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Width - 40, 1, 15); + end; + if ScreenAct = 2 then begin + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P1_NotesB, Nr.Width - 40, 2, 15); + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Width - 40, 3, 15); + end; + end; + + if PlayersPlay = 6 then begin + NotesW := NotesW * 0.8; + NotesH := NotesH * 0.8; + + if ScreenAct = 1 then begin + SingDrawPlayerBGCzesc(Nr.Left + 20, 120+95, Nr.Right - 20, 0, 0, 12); + SingDrawPlayerBGCzesc(Nr.Left + 20, 245+95, Nr.Right - 20, 0, 1, 12); + SingDrawPlayerBGCzesc(Nr.Left + 20, 370+95, Nr.Right - 20, 0, 2, 12); + end; + if ScreenAct = 2 then begin + SingDrawPlayerBGCzesc(Nr.Left + 20, 120+95, Nr.Right - 20, 0, 3, 12); + SingDrawPlayerBGCzesc(Nr.Left + 20, 245+95, Nr.Right - 20, 0, 4, 12); + SingDrawPlayerBGCzesc(Nr.Left + 20, 370+95, Nr.Right - 20, 0, 5, 12); + end; + + SingDrawCzesc(NR.Left + 20, 120+95, NR.Right - 20, 0, 12); + SingDrawCzesc(NR.Left + 20, 245+95, NR.Right - 20, 0, 12); + SingDrawCzesc(NR.Left + 20, 370+95, NR.Right - 20, 0, 12); + + if ScreenAct = 1 then begin + SingDrawPlayerCzesc(Nr.Left + 20, 120+95, Nr.Width - 40, 0, 12); + SingDrawPlayerCzesc(Nr.Left + 20, 245+95, Nr.Width - 40, 1, 12); + SingDrawPlayerCzesc(Nr.Left + 20, 370+95, Nr.Width - 40, 2, 12); + end; + if ScreenAct = 2 then begin + SingDrawPlayerCzesc(Nr.Left + 20, 120+95, Nr.Width - 40, 3, 12); + SingDrawPlayerCzesc(Nr.Left + 20, 245+95, Nr.Width - 40, 4, 12); + SingDrawPlayerCzesc(Nr.Left + 20, 370+95, Nr.Width - 40, 5, 12); + end; + end; + + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); +end; + +procedure SingModiDraw (PlayerInfo: TPlayerInfo); +var + Pet: integer; + Pet2: integer; + TempR: real; + Rec: TRecR; + TexRec: TRecR; + NR: TRecR; + FS: real; + BarFrom: integer; + BarAlpha: real; + BarWspol: real; + TempCol: real; + Tekst: string; + LyricTemp: string; + PetCz: integer; + + + + //SingBar Mod + A: Integer; + E: Integer; + I: Integer; + //end Singbar Mod + + + +begin + // positions + if Ini.SingWindow = 0 then begin + NR.Left := 120; + end else begin + NR.Left := 20; + end; + NR.Right := 780; + + NR.Width := NR.Right - NR.Left; + NR.WMid := NR.Width / 2; + NR.Mid := NR.Left + NR.WMid; + + // background //BG Fullsize Mod + //SingDrawBackground; + + // time bar +// Log.LogStatus('Time Bar', 'SingDraw'); + SingDrawTimeBar(); + + if DLLMan.Selected.ShowNotes then + begin + // rysuje paski pod nutami + if PlayersPlay = 1 then + SingDrawNoteLines(Nr.Left + 10*ScreenX, Skin_P2_NotesB - 105, Nr.Right + 10*ScreenX, 15); + if (PlayersPlay = 2) or (PlayersPlay = 4) then begin + SingDrawNoteLines(Nr.Left + 10*ScreenX, Skin_P1_NotesB - 105, Nr.Right + 10*ScreenX, 15); + SingDrawNoteLines(Nr.Left + 10*ScreenX, Skin_P2_NotesB - 105, Nr.Right + 10*ScreenX, 15); + end; + + if (PlayersPlay = 3) or (PlayersPlay = 6) then begin + SingDrawNoteLines(Nr.Left + 10*ScreenX, 120, Nr.Right + 10*ScreenX, 12); + SingDrawNoteLines(Nr.Left + 10*ScreenX, 245, Nr.Right + 10*ScreenX, 12); + SingDrawNoteLines(Nr.Left + 10*ScreenX, 370, Nr.Right + 10*ScreenX, 12); + end; + end; + + // rysuje tekst - new Lyric engine + ScreenSingModi.LyricMain.Draw; + ScreenSingModi.LyricSub.Draw; + + // rysuje pasek, podpowiadajacy poczatek spiwania w scenie + FS := 1.3; + BarFrom := Czesci[0].Czesc[Czesci[0].Akt].StartNote - Czesci[0].Czesc[Czesci[0].Akt].Start; + if BarFrom > 40 then BarFrom := 40; + if (Czesci[0].Czesc[Czesci[0].Akt].StartNote - Czesci[0].Czesc[Czesci[0].Akt].Start > 8) and // dluga przerwa //16->12 for more help bars and then 12->8 for even more + (Czesci[0].Czesc[Czesci[0].Akt].StartNote - Czas.MidBeat > 0) and // przed tekstem + (Czesci[0].Czesc[Czesci[0].Akt].StartNote - Czas.MidBeat < 40) then begin // ale nie za wczesnie + BarWspol := (Czas.MidBeat - (Czesci[0].Czesc[Czesci[0].Akt].StartNote - BarFrom)) / BarFrom; + Rec.Left := NR.Left + BarWspol * + // (NR.WMid - Czesci[0].Czesc[Czesci[0].Akt].LyricWidth / 2 * FS - 50); + (ScreenSingModi.LyricMain.ClientX - NR.Left - 50) + 10*ScreenX; + Rec.Right := Rec.Left + 50; + Rec.Top := Skin_LyricsT + 3; + Rec.Bottom := Rec.Top + 33;//SingScreen.LyricMain.Size * 3; +{ // zapalanie + BarAlpha := (BarWspol*10) * 0.5; + if BarAlpha > 0.5 then BarAlpha := 0.5; + + // gaszenie + if BarWspol > 0.95 then BarAlpha := 0.5 * (1 - (BarWspol - 0.95) * 20);} + + //Change fuer Crazy Joker + + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, Tex_Lyric_Help_Bar.TexNum); + glBegin(GL_QUADS); + glColor4f(1, 1, 1, 0); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glColor4f(1, 1, 1, 0.5); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + glDisable(GL_BLEND); + end; + + // oscilloscope + if (((Ini.Oscilloscope = 1) AND (DLLMan.Selected.ShowRateBar_O)) AND (NOT DLLMan.Selected.ShowRateBar)) then begin + if PlayersPlay = 1 then + if PlayerInfo.Playerinfo[0].Enabled then + SingDrawOscilloscope(190 + 10*ScreenX, 55, 180, 40, 0); + + if PlayersPlay = 2 then begin + if PlayerInfo.Playerinfo[0].Enabled then + SingDrawOscilloscope(190 + 10*ScreenX, 55, 180, 40, 0); + if PlayerInfo.Playerinfo[1].Enabled then + SingDrawOscilloscope(425 + 10*ScreenX, 55, 180, 40, 1); + end; + + if PlayersPlay = 4 then begin + if ScreenAct = 1 then begin + if PlayerInfo.Playerinfo[0].Enabled then + SingDrawOscilloscope(190 + 10*ScreenX, 55, 180, 40, 0); + if PlayerInfo.Playerinfo[1].Enabled then + SingDrawOscilloscope(425 + 10*ScreenX, 55, 180, 40, 1); + end; + if ScreenAct = 2 then begin + if PlayerInfo.Playerinfo[2].Enabled then + SingDrawOscilloscope(190 + 10*ScreenX, 55, 180, 40, 2); + if PlayerInfo.Playerinfo[3].Enabled then + SingDrawOscilloscope(425 + 10*ScreenX, 55, 180, 40, 3); + end; + end; + + if PlayersPlay = 3 then begin + if PlayerInfo.Playerinfo[0].Enabled then + SingDrawOscilloscope(75 + 10*ScreenX, 95, 100, 20, 0); + if PlayerInfo.Playerinfo[1].Enabled then + SingDrawOscilloscope(370 + 10*ScreenX, 95, 100, 20, 1); + if PlayerInfo.Playerinfo[2].Enabled then + SingDrawOscilloscope(670 + 10*ScreenX, 95, 100, 20, 2); + end; + + if PlayersPlay = 6 then begin + if ScreenAct = 1 then begin + if PlayerInfo.Playerinfo[0].Enabled then + SingDrawOscilloscope( 75 + 10*ScreenX, 95, 100, 20, 0); + if PlayerInfo.Playerinfo[1].Enabled then + SingDrawOscilloscope(370 + 10*ScreenX, 95, 100, 20, 1); + if PlayerInfo.Playerinfo[2].Enabled then + SingDrawOscilloscope(670 + 10*ScreenX, 95, 100, 20, 2); + end; + if ScreenAct = 2 then begin + if PlayerInfo.Playerinfo[3].Enabled then + SingDrawOscilloscope( 75 + 10*ScreenX, 95, 100, 20, 3); + if PlayerInfo.Playerinfo[4].Enabled then + SingDrawOscilloscope(370 + 10*ScreenX, 95, 100, 20, 4); + if PlayerInfo.Playerinfo[5].Enabled then + SingDrawOscilloscope(670 + 10*ScreenX, 95, 100, 20, 5); + end; + end; + + end + + //SingBar Mod + // was fürn sinn hattn der quark hier? + else if ((Ini.Oscilloscope = 2) AND (DLLMan.Selected.ShowRateBar_O)) OR (DLLMan.Selected.ShowRateBar) then begin + A := GetTickCount div 33; + if A <> Tickold then begin + Tickold := A; + for E := 0 to (PlayersPlay - 1) do begin //Set new Pos + Alpha + I := Player[E].ScorePercentTarget - Player[E].ScorePercent; + if I > 0 then Inc(Player[E].ScorePercent) + else if I < 0 then Dec(Player[E].ScorePercent); + end; //for + end; //if + if PlayersPlay = 1 then begin + if PlayerInfo.Playerinfo[0].Enabled then + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[0].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1SingBar.x, Theme.Sing.StaticP1SingBar.y, Theme.Sing.StaticP1SingBar.w, Theme.Sing.StaticP1SingBar.h , Player[0].ScorePercent); + end; + if PlayersPlay = 2 then begin + if PlayerInfo.Playerinfo[0].Enabled then + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[0].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1TwoPSingBar.x, Theme.Sing.StaticP1TwoPSingBar.y, Theme.Sing.StaticP1TwoPSingBar.w, Theme.Sing.StaticP1TwoPSingBar.h , Player[0].ScorePercent); + if PlayerInfo.Playerinfo[1].Enabled then + //SingDrawSingbar(620 + 10*ScreenX, 95, 100, 8, Player[1].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP2RSingBar.x, Theme.Sing.StaticP2RSingBar.y, Theme.Sing.StaticP2RSingBar.w, Theme.Sing.StaticP2RSingBar.h , Player[1].ScorePercent); + end; + if PlayersPlay = 3 then begin + if PlayerInfo.Playerinfo[0].Enabled then + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[0].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1ThreePSingBar.x, Theme.Sing.StaticP1ThreePSingBar.y, Theme.Sing.StaticP1ThreePSingBar.w, Theme.Sing.StaticP1ThreePSingBar.h , Player[0].ScorePercent); + if PlayerInfo.Playerinfo[1].Enabled then + //SingDrawSingbar(370 + 10*ScreenX, 95, 100, 8, Player[1].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP2MSingBar.x, Theme.Sing.StaticP2MSingBar.y, Theme.Sing.StaticP2MSingBar.w, Theme.Sing.StaticP2MSingBar.h , Player[1].ScorePercent); + if PlayerInfo.Playerinfo[2].Enabled then + //SingDrawSingbar(670 + 10*ScreenX, 95, 100, 8, Player[2].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP3SingBar.x, Theme.Sing.StaticP3SingBar.y, Theme.Sing.StaticP3SingBar.w, Theme.Sing.StaticP3SingBar.h , Player[2].ScorePercent); + end; + if PlayersPlay = 4 then begin + if ScreenAct = 1 then begin + if PlayerInfo.Playerinfo[0].Enabled then + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[0].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1TwoPSingBar.x, Theme.Sing.StaticP1TwoPSingBar.y, Theme.Sing.StaticP1TwoPSingBar.w, Theme.Sing.StaticP1TwoPSingBar.h , Player[0].ScorePercent); + if PlayerInfo.Playerinfo[1].Enabled then + //SingDrawSingbar(620 + 10*ScreenX, 95, 100, 8, Player[1].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP2RSingBar.x, Theme.Sing.StaticP2RSingBar.y, Theme.Sing.StaticP2RSingBar.w, Theme.Sing.StaticP2RSingBar.h , Player[1].ScorePercent); + end; + if ScreenAct = 2 then begin + if PlayerInfo.Playerinfo[2].Enabled then + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[2].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1TwoPSingBar.x, Theme.Sing.StaticP1TwoPSingBar.y, Theme.Sing.StaticP1TwoPSingBar.w, Theme.Sing.StaticP1TwoPSingBar.h , Player[2].ScorePercent); + if PlayerInfo.Playerinfo[3].Enabled then + //SingDrawSingbar(620 + 10*ScreenX, 95, 100, 8, Player[3].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP2RSingBar.x, Theme.Sing.StaticP2RSingBar.y, Theme.Sing.StaticP2RSingBar.w, Theme.Sing.StaticP2RSingBar.h , Player[3].ScorePercent); + end; + end; + if PlayersPlay = 6 then begin + if ScreenAct = 1 then begin + if PlayerInfo.Playerinfo[0].Enabled then + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[0].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1ThreePSingBar.x, Theme.Sing.StaticP1ThreePSingBar.y, Theme.Sing.StaticP1ThreePSingBar.w, Theme.Sing.StaticP1ThreePSingBar.h , Player[0].ScorePercent); + if PlayerInfo.Playerinfo[1].Enabled then + //SingDrawSingbar(370 + 10*ScreenX, 95, 100, 8, Player[1].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP2MSingBar.x, Theme.Sing.StaticP2MSingBar.y, Theme.Sing.StaticP2MSingBar.w, Theme.Sing.StaticP2MSingBar.h , Player[1].ScorePercent); + if PlayerInfo.Playerinfo[2].Enabled then + //SingDrawSingbar(670 + 10*ScreenX, 95, 100, 8, Player[2].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP3SingBar.x, Theme.Sing.StaticP3SingBar.y, Theme.Sing.StaticP3SingBar.w, Theme.Sing.StaticP3SingBar.h , Player[2].ScorePercent); + end; + if ScreenAct = 2 then begin + if PlayerInfo.Playerinfo[3].Enabled then + //SingDrawSingbar( 75 + 10*ScreenX, 95, 100, 8, Player[3].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP1ThreePSingBar.x, Theme.Sing.StaticP1ThreePSingBar.y, Theme.Sing.StaticP1ThreePSingBar.w, Theme.Sing.StaticP1ThreePSingBar.h , Player[3].ScorePercent); + if PlayerInfo.Playerinfo[4].Enabled then + //SingDrawSingbar(370 + 10*ScreenX, 95, 100, 8, Player[4].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP2MSingBar.x, Theme.Sing.StaticP2MSingBar.y, Theme.Sing.StaticP2MSingBar.w, Theme.Sing.StaticP2MSingBar.h , Player[4].ScorePercent); + if PlayerInfo.Playerinfo[5].Enabled then + //SingDrawSingbar(670 + 10*ScreenX, 95, 100, 8, Player[5].ScorePercent); + SingDrawSingbar(Theme.Sing.StaticP3SingBar.x, Theme.Sing.StaticP3SingBar.y, Theme.Sing.StaticP3SingBar.w, Theme.Sing.StaticP3SingBar.h , Player[5].ScorePercent); + end; + end; + end; + //end Singbar Mod + + //PhrasenBonus - Line Bonus Mod + if ((Ini.LineBonus > 0) AND (DLLMan.Selected.EnLineBonus_O)) OR (DLLMan.Selected.EnLineBonus) then begin + A := GetTickCount div 33; + if (A <> Tickold2) AND (Player[0].LineBonus_Visible) then begin + Tickold2 := A; + for E := 0 to (PlayersPlay - 1) do begin + //Change Alpha + Player[E].LineBonus_Alpha := Player[E].LineBonus_Alpha - 0.02; + + + if Player[E].LineBonus_Alpha <= 0 then + begin + Player[E].LineBonus_Age := 0; + Player[E].LineBonus_Visible := False + + end + else + begin + inc(Player[E].LineBonus_Age, 1); + + //Change Position + if (Player[E].LineBonus_PosX < Player[E].LineBonus_TargetX) then + Player[E].LineBonus_PosX := Player[E].LineBonus_PosX + (2 - Player[E].LineBonus_Alpha * 1.5) + else if (Player[E].LineBonus_PosX > Player[E].LineBonus_TargetX) then + Player[E].LineBonus_PosX := Player[E].LineBonus_PosX - (2 - Player[E].LineBonus_Alpha * 1.5); + + if (Player[E].LineBonus_PosY < Player[E].LineBonus_TargetY) then + Player[E].LineBonus_PosY := Player[E].LineBonus_PosY + (2 - Player[E].LineBonus_Alpha * 1.5) + else if (Player[E].LineBonus_PosY > Player[E].LineBonus_TargetY) then + Player[E].LineBonus_PosY := Player[E].LineBonus_PosY - (2 - Player[E].LineBonus_Alpha * 1.5); + + end; + end; + end; //if + + if PlayersPlay = 1 then begin + if PlayerInfo.Playerinfo[0].Enabled then + SingDrawLineBonus( Player[0].LineBonus_PosX, Player[0].LineBonus_PosY, Player[0].LineBonus_Color, Player[0].LineBonus_Alpha, Player[0].LineBonus_Text, Player[0].LineBonus_Age); + end + else if PlayersPlay = 2 then begin + if PlayerInfo.Playerinfo[0].Enabled then + SingDrawLineBonus( Player[0].LineBonus_PosX, Player[0].LineBonus_PosY, Player[0].LineBonus_Color, Player[0].LineBonus_Alpha, Player[0].LineBonus_Text, Player[0].LineBonus_Age); + if PlayerInfo.Playerinfo[1].Enabled then + SingDrawLineBonus( Player[1].LineBonus_PosX, Player[1].LineBonus_PosY, Player[1].LineBonus_Color, Player[1].LineBonus_Alpha, Player[1].LineBonus_Text, Player[1].LineBonus_Age); + end + else if PlayersPlay = 3 then begin + if PlayerInfo.Playerinfo[0].Enabled then + SingDrawLineBonus( Player[0].LineBonus_PosX, Player[0].LineBonus_PosY, Player[0].LineBonus_Color, Player[0].LineBonus_Alpha, Player[0].LineBonus_Text, Player[0].LineBonus_Age); + if PlayerInfo.Playerinfo[1].Enabled then + SingDrawLineBonus( Player[1].LineBonus_PosX, Player[1].LineBonus_PosY, Player[1].LineBonus_Color, Player[1].LineBonus_Alpha, Player[1].LineBonus_Text, Player[1].LineBonus_Age); + if PlayerInfo.Playerinfo[2].Enabled then + SingDrawLineBonus( Player[2].LineBonus_PosX, Player[2].LineBonus_PosY, Player[2].LineBonus_Color, Player[2].LineBonus_Alpha, Player[2].LineBonus_Text, Player[2].LineBonus_Age); + end + else if PlayersPlay = 4 then begin + if ScreenAct = 1 then begin + if PlayerInfo.Playerinfo[0].Enabled then + SingDrawLineBonus( Player[0].LineBonus_PosX, Player[0].LineBonus_PosY, Player[0].LineBonus_Color, Player[0].LineBonus_Alpha, Player[0].LineBonus_Text, Player[0].LineBonus_Age); + if PlayerInfo.Playerinfo[1].Enabled then + SingDrawLineBonus( Player[1].LineBonus_PosX, Player[1].LineBonus_PosY, Player[1].LineBonus_Color, Player[1].LineBonus_Alpha, Player[1].LineBonus_Text, Player[1].LineBonus_Age); + end; + if ScreenAct = 2 then begin + if PlayerInfo.Playerinfo[2].Enabled then + SingDrawLineBonus( Player[2].LineBonus_PosX, Player[2].LineBonus_PosY, Player[2].LineBonus_Color, Player[2].LineBonus_Alpha, Player[2].LineBonus_Text, Player[2].LineBonus_Age); + if PlayerInfo.Playerinfo[3].Enabled then + SingDrawLineBonus( Player[3].LineBonus_PosX, Player[3].LineBonus_PosY, Player[3].LineBonus_Color, Player[3].LineBonus_Alpha, Player[3].LineBonus_Text, Player[3].LineBonus_Age); + end; + end; + if PlayersPlay = 6 then begin + if ScreenAct = 1 then begin + if PlayerInfo.Playerinfo[0].Enabled then + SingDrawLineBonus( Player[0].LineBonus_PosX, Player[0].LineBonus_PosY, Player[0].LineBonus_Color, Player[0].LineBonus_Alpha, Player[0].LineBonus_Text, Player[0].LineBonus_Age); + if PlayerInfo.Playerinfo[1].Enabled then + SingDrawLineBonus( Player[1].LineBonus_PosX, Player[1].LineBonus_PosY, Player[1].LineBonus_Color, Player[1].LineBonus_Alpha, Player[1].LineBonus_Text, Player[1].LineBonus_Age); + if PlayerInfo.Playerinfo[2].Enabled then + SingDrawLineBonus( Player[2].LineBonus_PosX, Player[2].LineBonus_PosY, Player[2].LineBonus_Color, Player[2].LineBonus_Alpha, Player[2].LineBonus_Text, Player[2].LineBonus_Age); + end; + if ScreenAct = 2 then begin + if PlayerInfo.Playerinfo[3].Enabled then + SingDrawLineBonus( Player[3].LineBonus_PosX, Player[3].LineBonus_PosY, Player[3].LineBonus_Color, Player[3].LineBonus_Alpha, Player[3].LineBonus_Text, Player[3].LineBonus_Age); + if PlayerInfo.Playerinfo[4].Enabled then + SingDrawLineBonus( Player[4].LineBonus_PosX, Player[4].LineBonus_PosY, Player[4].LineBonus_Color, Player[4].LineBonus_Alpha, Player[4].LineBonus_Text, Player[4].LineBonus_Age); + if PlayerInfo.Playerinfo[5].Enabled then + SingDrawLineBonus( Player[5].LineBonus_PosX, Player[5].LineBonus_PosY, Player[5].LineBonus_Color, Player[5].LineBonus_Alpha, Player[5].LineBonus_Text, Player[5].LineBonus_Age); + end; + end; + end; + //PhrasenBonus - Line Bonus Mod End + + + // rysuje paski +// Log.LogStatus('Original notes', 'SingDraw'); + case Ini.Difficulty of + 0: + begin + NotesH := 11; // 9 + NotesW := 6; // 5 + end; + 1: + begin + NotesH := 8; // 7 + NotesW := 4; // 4 + end; + 2: + begin + NotesH := 5; + NotesW := 3; + end; + end; + + if (DLLMAn.Selected.ShowNotes And DLLMan.Selected.LoadSong) then + begin + if (PlayersPlay = 1) And PlayerInfo.Playerinfo[0].Enabled then begin + SingDrawPlayerBGCzesc(NR.Left + 20, Skin_P2_NotesB, NR.Right - 20, 0, 0, 15); + SingDrawCzesc(NR.Left + 20, Skin_P2_NotesB, NR.Right - 20, 0, 15); + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Width - 40, 0, 15); + end; + + if (PlayersPlay = 2) then begin + if PlayerInfo.Playerinfo[0].Enabled then + begin + SingDrawPlayerBGCzesc(Nr.Left + 20, Skin_P1_NotesB, Nr.Right - 20, 0, 0, 15); + SingDrawCzesc(NR.Left + 20, Skin_P1_NotesB, NR.Right - 20, 0, 15); + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P1_NotesB, Nr.Width - 40, 0, 15); + end; + if PlayerInfo.Playerinfo[1].Enabled then + begin + SingDrawPlayerBGCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Right - 20, 0, 1, 15); + SingDrawCzesc(NR.Left + 20, Skin_P2_NotesB, NR.Right - 20, 0, 15); + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Width - 40, 1, 15); + end; + + end; + + if PlayersPlay = 3 then begin + NotesW := NotesW * 0.8; + NotesH := NotesH * 0.8; + + if PlayerInfo.Playerinfo[0].Enabled then + begin + SingDrawPlayerBGCzesc(Nr.Left + 20, 120+95, Nr.Right - 20, 0, 0, 12); + SingDrawCzesc(NR.Left + 20, 120+95, NR.Right - 20, 0, 12); + SingDrawPlayerCzesc(Nr.Left + 20, 120+95, Nr.Width - 40, 0, 12); + end; + + if PlayerInfo.Playerinfo[1].Enabled then + begin + SingDrawPlayerBGCzesc(Nr.Left + 20, 245+95, Nr.Right - 20, 0, 1, 12); + SingDrawCzesc(NR.Left + 20, 245+95, NR.Right - 20, 0, 12); + SingDrawPlayerCzesc(Nr.Left + 20, 245+95, Nr.Width - 40, 1, 12); + end; + + if PlayerInfo.Playerinfo[2].Enabled then + begin + SingDrawPlayerBGCzesc(Nr.Left + 20, 370+95, Nr.Right - 20, 0, 2, 12); + SingDrawCzesc(NR.Left + 20, 370+95, NR.Right - 20, 0, 12); + SingDrawPlayerCzesc(Nr.Left + 20, 370+95, Nr.Width - 40, 2, 12); + end; + end; + + if PlayersPlay = 4 then begin + if ScreenAct = 1 then begin + SingDrawPlayerBGCzesc(Nr.Left + 20, Skin_P1_NotesB, Nr.Right - 20, 0, 0, 15); + SingDrawPlayerBGCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Right - 20, 0, 1, 15); + end; + if ScreenAct = 2 then begin + SingDrawPlayerBGCzesc(Nr.Left + 20, Skin_P1_NotesB, Nr.Right - 20, 0, 2, 15); + SingDrawPlayerBGCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Right - 20, 0, 3, 15); + end; + + SingDrawCzesc(NR.Left + 20, Skin_P1_NotesB, NR.Right - 20, 0, 15); + SingDrawCzesc(NR.Left + 20, Skin_P2_NotesB, NR.Right - 20, 0, 15); + + if ScreenAct = 1 then begin + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P1_NotesB, Nr.Width - 40, 0, 15); + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Width - 40, 1, 15); + end; + if ScreenAct = 2 then begin + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P1_NotesB, Nr.Width - 40, 2, 15); + SingDrawPlayerCzesc(Nr.Left + 20, Skin_P2_NotesB, Nr.Width - 40, 3, 15); + end; + end; + + if PlayersPlay = 6 then begin + NotesW := NotesW * 0.8; + NotesH := NotesH * 0.8; + + if ScreenAct = 1 then begin + SingDrawPlayerBGCzesc(Nr.Left + 20, 120+95, Nr.Right - 20, 0, 0, 12); + SingDrawPlayerBGCzesc(Nr.Left + 20, 245+95, Nr.Right - 20, 0, 1, 12); + SingDrawPlayerBGCzesc(Nr.Left + 20, 370+95, Nr.Right - 20, 0, 2, 12); + end; + if ScreenAct = 2 then begin + SingDrawPlayerBGCzesc(Nr.Left + 20, 120+95, Nr.Right - 20, 0, 3, 12); + SingDrawPlayerBGCzesc(Nr.Left + 20, 245+95, Nr.Right - 20, 0, 4, 12); + SingDrawPlayerBGCzesc(Nr.Left + 20, 370+95, Nr.Right - 20, 0, 5, 12); + end; + + SingDrawCzesc(NR.Left + 20, 120+95, NR.Right - 20, 0, 12); + SingDrawCzesc(NR.Left + 20, 245+95, NR.Right - 20, 0, 12); + SingDrawCzesc(NR.Left + 20, 370+95, NR.Right - 20, 0, 12); + + if ScreenAct = 1 then begin + SingDrawPlayerCzesc(Nr.Left + 20, 120+95, Nr.Width - 40, 0, 12); + SingDrawPlayerCzesc(Nr.Left + 20, 245+95, Nr.Width - 40, 1, 12); + SingDrawPlayerCzesc(Nr.Left + 20, 370+95, Nr.Width - 40, 2, 12); + end; + if ScreenAct = 2 then begin + SingDrawPlayerCzesc(Nr.Left + 20, 120+95, Nr.Width - 40, 3, 12); + SingDrawPlayerCzesc(Nr.Left + 20, 245+95, Nr.Width - 40, 4, 12); + SingDrawPlayerCzesc(Nr.Left + 20, 370+95, Nr.Width - 40, 5, 12); + end; + end; + end; + + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); +end; + + +//SingBar Mod +procedure SingDrawSingbar(X, Y, W, H: real; Percent: integer); +var + R: Real; + G: Real; + B: Real; + A: cardinal; + I: Integer; + +begin; + + //SingBar Background + glColor4f(1, 1, 1, 0.8); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, Tex_SingBar_Back.TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(X, Y); + glTexCoord2f(0, 1); glVertex2f(X, Y+H); + glTexCoord2f(1, 1); glVertex2f(X+W, Y+H); + glTexCoord2f(1, 0); glVertex2f(X+W, Y); + glEnd; + + //SingBar coloured Bar + Case Percent of + 0..22: begin + R := 1; + G := 0; + B := 0; + end; + 23..42: begin + R := 1; + G := ((Percent-23)/100)*5; + B := 0; + end; + 43..57: begin + R := 1; + G := 1; + B := 0; + end; + 58..77: begin + R := 1-(Percent - 58)/100*5; + G := 1; + B := 0; + end; + 78..99: begin + R := 0; + G := 1; + B := 0; + end; + End; //Case + + glColor4f(R, G, B, 1); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, Tex_SingBar_Bar.TexNum); + //Size= Player[PlayerNum].ScorePercent of W + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(X, Y); + glTexCoord2f(0, 1); glVertex2f(X, Y+H); + glTexCoord2f(1, 1); glVertex2f(X+(W/100 * (Percent +1)), Y+H); + glTexCoord2f(1, 0); glVertex2f(X+(W/100 * (Percent +1)), Y); + glEnd; + + //SingBar Front + glColor4f(1, 1, 1, 0.6); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, Tex_SingBar_Front.TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(X, Y); + glTexCoord2f(0, 1); glVertex2f(X, Y+H); + glTexCoord2f(1, 1); glVertex2f(X+W, Y+H); + glTexCoord2f(1, 0); glVertex2f(X+W, Y); + glEnd; +end; +//end Singbar Mod + +//PhrasenBonus - Line Bonus Mod +procedure SingDrawLineBonus( const X, Y: Single; Color: TRGB; Alpha: Single; Text: string; Age: Integer); +var +Length, X2: Real; //Length of Text +Size: Integer; //Size of Popup +begin +if Alpha <> 0 then +begin + +//Set Font Propertys +SetFontStyle(2); //Font: Outlined1 +if Age < 5 then SetFontSize(Age + 1) else SetFontSize(6); +SetFontItalic(False); + +//Check Font Size +Length := glTextWidth ( PChar(Text)) + 3; //Little Space for a Better Look ^^ + +//Text +SetFontPos (X + 50 - (Length / 2), Y + 12); //Position + + +if Age < 5 then Size := Age * 10 else Size := 50; + + //Draw Background + glColor4f(Color.R, Color.G, Color.B, Alpha); //Set Color + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + + //New Method, Not Variable + glBindTexture(GL_TEXTURE_2D, Tex_SingLineBonusBack.TexNum); + + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(X + 50 - Size, Y + 25 - (Size/2)); + glTexCoord2f(0, 1); glVertex2f(X + 50 - Size, Y + 25 + (Size/2)); + glTexCoord2f(1, 1); glVertex2f(X + 50 + Size, Y + 25 + (Size/2)); + glTexCoord2f(1, 0); glVertex2f(X + 50 + Size, Y + 25 - (Size/2)); + glEnd; + + glColor4f(1, 1, 1, Alpha); //Set Color + //Draw Text + glPrint (PChar(Text)); +end; +end; +//PhrasenBonus - Line Bonus Mod + +// Draw Note Bars for Editor +//There are 11 Resons for a new Procdedure: +// 1. It don't look good when you Draw the Golden Note Star Effect in the Editor +// 2. You can see the Freestyle Notes in the Editor SemiTransparent +// 3. Its easier and Faster then changing the old Procedure +procedure EditDrawCzesc(Left, Top, Right: real; NrCzesci: integer; Space: integer); +var + Rec: TRecR; + Pet: integer; + TempR: real; +begin + glColor3f(1, 1, 1); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + TempR := (Right-Left) / (Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].Koniec - Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].StartNote); + with Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt] do begin + for Pet := 0 to HighNut do begin + with Nuta[Pet] do begin + + // Golden Note Patch + case Wartosc of + 0: glColor4f(1, 1, 1, 0.35); + 1: glColor4f(1, 1, 1, 0.85); + 2: glColor4f(1, 1, 0.3, 0.85); + end; // case + + + + // lewa czesc - left part + Rec.Left := (Start-Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].StartNote) * TempR + Left + 0.5 + 10*ScreenX; + Rec.Right := Rec.Left + NotesW; + Rec.Top := Top - (Ton-BaseNote)*Space/2 - NotesH; + Rec.Bottom := Rec.Top + 2 * NotesH; + glBindTexture(GL_TEXTURE_2D, Tex_Left[Color].TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + + // srodkowa czesc - middle part + Rec.Left := Rec.Right; + Rec.Right := (Start+Dlugosc-Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].StartNote) * TempR + Left - NotesW - 0.5 + 10*ScreenX; + + glBindTexture(GL_TEXTURE_2D, Tex_Mid[Color].TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + + // prawa czesc - right part + Rec.Left := Rec.Right; + Rec.Right := Rec.Right + NotesW; + + glBindTexture(GL_TEXTURE_2D, Tex_Right[Color].TexNum); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top); + glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom); + glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom); + glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top); + glEnd; + + end; // with + end; // for + end; // with + + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); +end; + +procedure SingDrawTimeBar(); +var x,y: real; + width, height: real; +begin + x := Theme.Sing.StaticTimeProgress.x; + y := Theme.Sing.StaticTimeProgress.y; + width:= Theme.Sing.StaticTimeProgress.w; + height:= Theme.Sing.StaticTimeProgress.h; + + glColor4f(Theme.Sing.StaticTimeProgress.ColR, + Theme.Sing.StaticTimeProgress.ColG, + Theme.Sing.StaticTimeProgress.ColB, 1); //Set Color + + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + glBindTexture(GL_TEXTURE_2D, Tex_TimeProgress.TexNum); + + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2f(x,y); + glTexCoord2f(0, 1); glVertex2f(x+width*(Czas.Teraz/Czas.Razem), y); + glTexCoord2f(1, 1); glVertex2f(x+width*(Czas.Teraz/Czas.Razem), y+height); + glTexCoord2f(1, 0); glVertex2f(x, y+height); + glEnd; + + glDisable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + glcolor4f(1,1,1,1); +end; + +end. + diff --git a/Game/Code/Classes/UFiles.pas b/Game/Code/Classes/UFiles.pas new file mode 100644 index 00000000..06744271 --- /dev/null +++ b/Game/Code/Classes/UFiles.pas @@ -0,0 +1,810 @@ +unit UFiles; + +interface + +uses USongs, + SysUtils, + ULog, + UMusic; + +procedure InitializePaths; //Function sets All Absolute Paths eg. for Songs +function ReadTXTHeader(var Song: TSong): boolean; //Reads Standard TXT Header +function AnalyseFile(var Song: TSong): boolean; //Analyse Song File and Read Header +procedure ClearSong(var Song: TSong); //Clears Song Header values + +//Methodes Loading and Saving Songfiles +procedure ResetSingTemp; +procedure ParseNote(NrCzesci: integer; TypeP: char; StartP, DurationP, NoteP: integer; LyricS: string); +procedure NewSentence(NrCzesciP: integer; Param1, Param2: integer); +function LoadSong(Name: string): boolean; +function SaveSong(Song: TSong; Czesc: TCzesci; Name: string; Relative: boolean): boolean; + + + +var + //Absolute Paths + GamePath: string; + SoundPath: string; + SongPath: string; + LogPath: string; + ThemePath: string; + ScreenshotsPath: string; + CoversPath: string; + LanguagesPath: string; + PluginPath: string; + PlayListPath: string; + + SongFile: TextFile; // all procedures in this unit operates on this file + FileLineNo: integer; //Line which is readed at Last, for error reporting + + // variables available for all procedures + Base: array[0..1] of integer; + Rel: array[0..1] of integer; + Mult: integer = 1; + MultBPM: integer = 4; + +implementation +uses TextGL, UIni, UMain; + +//-------------------- +// Function sets all Absolute Paths e.g. Song Path and makes sure the Directorys exist +//-------------------- +procedure InitializePaths; +var + Writeable: Boolean; +begin + GamePath := ExtractFilePath(ParamStr(0)); + + SoundPath := GamePath + 'Sounds\'; + SongPath := GamePath + 'Songs\'; + LogPath := GamePath; + ThemePath := GamePath + 'Themes\'; + ScreenshotsPath := GamePath + 'Screenshots\'; + CoversPath := GamePath + 'Covers\'; + LanguagesPath := GamePath + 'Languages\'; + PluginPath := GamePath + 'Plugins\'; + PlaylistPath := GamePath + 'Playlists\'; + + //After Setting Paths, make sure that Paths exist + If not DirectoryExists(SoundPath) then + Writeable := ForceDirectories(SoundPath); + + If Writeable And (not DirectoryExists(SongPath)) then + Writeable := ForceDirectories(SongPath); + + If Writeable And (not DirectoryExists(ThemePath)) then + Writeable := ForceDirectories(ThemePath); + + If Writeable And (not DirectoryExists(ScreenshotsPath)) then + Writeable := ForceDirectories(ScreenshotsPath); + + If Writeable And (not DirectoryExists(CoversPath)) then + Writeable := ForceDirectories(CoversPath); + + If Writeable And (not DirectoryExists(LanguagesPath)) then + Writeable := ForceDirectories(LanguagesPath); + + If Writeable And (not DirectoryExists(PluginPath)) then + Writeable := ForceDirectories(PluginPath); + + If Writeable And (not DirectoryExists(PlaylistPath)) then + Writeable := ForceDirectories(PlaylistPath); + + if not Writeable then + Log.LogError('Error: Dir is Readonly'); + + DecimalSeparator := ','; +end; + +//-------------------- +// Clears Song Header values +//-------------------- +procedure ClearSong(var Song: TSong); +begin + //Main Information + Song.Title := ''; + Song.Artist := ''; + + //Sortings: + Song.Genre := 'Unknown'; + Song.Edition := 'Unknown'; + Song.Language := 'Unknown'; //Language Patch + + //Required Information + Song.Mp3 := ''; + Song.BPM := 0; + Song.GAP := 0; + Song.Start := 0; + Song.Finish := 0; + + //Additional Information + Song.Background := ''; + Song.Cover := ''; + Song.Video := ''; + Song.VideoGAP := 0; + Song.NotesGAP := 0; + Song.Resolution := 4; + Song.Creator := ''; +end; + +//-------------------- +// Reads Standard TXT Header +//-------------------- +function ReadTXTHeader(var Song: TSong): boolean; +var + Line, Identifier, Value: String; + Temp: word; + Done: byte; + lWarnIfTagsNotFound : Boolean; +begin + Result := true; + + lWarnIfTagsNotFound := ( lowercase( Song.Filename ) <> 'license.txt' ) AND + ( lowercase( Song.Filename ) <> 'readme.txt' ) ; + + + //Read first Line + ReadLn (SongFile, Line); + + if (Length(Line)<=0) then + begin + Log.LogError('File Starts with Empty Line: ' + Song.FileName); + Result := False; + Exit; + end; + + //Read Lines while Line starts with # + While (Length(Line) = 0) OR (Line[1] = '#') do + begin + //Increase Line Number + Inc (FileLineNo); + Temp := Pos(':', Line); + + //Line has a Seperator-> Headerline + if (Temp <> 0) then + begin + //Read Identifier and Value + Identifier := Uppercase(Trim(Copy(Line, 2, Temp - 2))); //Uppercase is for Case Insensitive Checks + Value := Trim(Copy(Line, Temp + 1,Length(Line) - Temp)); + + //Check the Identifier (If Value is given) + if (Length(Value) <> 0) then + begin + + //----------- + //Required Attributes + //----------- + + //Title + if (Identifier = 'TITLE') then + begin + Song.Title := Value; + + //Add Title Flag to Done + Done := Done or 1; + end + + //Artist + else if (Identifier = 'ARTIST') then + begin + Song.Artist := Value; + + //Add Artist Flag to Done + Done := Done or 2; + end + + //MP3 File //Test if Exists + else if (Identifier = 'MP3') AND (FileExists(Song.Path + Value)) then + begin + Song.Mp3 := Value; + + //Add Mp3 Flag to Done + Done := Done or 4; + end + + //Beats per Minute + else if (Identifier = 'BPM') then + begin + // Replace . with , + if (Pos('.', Value) <> 0) then + Value[Pos('.', Value)] := ','; + + SetLength(Song.BPM, 1); + Song.BPM[0].StartBeat := 0; + + Song.BPM[0].BPM := StrtoFloatDef(Value, 0) * Mult * MultBPM; + + if Song.BPM[0].BPM <> 0 then + begin + //Add BPM Flag to Done + Done := Done or 8; + end; + end + + //--------- + //Additional Header Information + //--------- + + // Video Gap + else if (Identifier = 'GAP') then + begin + // Replace . with , + if (Pos('.', Value) <> 0) then + Value[Pos('.', Value)] := ','; + + Song.GAP := StrtoFloatDef (Value, 0); + end + + //Cover Picture + else if (Identifier = 'COVER') then + begin + Song.Cover := Value; + end + + //Background Picture + else if (Identifier = 'BACKGROUND') then + begin + Song.Background := Value; + end + + // Video File + else if (Identifier = 'VIDEO') then + begin + if (FileExists(Song.Path + Value)) then + Song.Video := Value + else + Log.LogError('Can''t find Video File in Song: ' + Song.Path + Song.FileName); + end + + // Video Gap + else if (Identifier = 'VIDEOGAP') then + begin + // Replace . with , + if (Pos('.', Value) <> 0) then + Value[Pos('.', Value)] := ','; + + Song.VideoGAP := StrtoFloatDef (Value, 0); + end + + //Genre Sorting + else if (Identifier = 'GENRE') then + begin + Song.Genre := Value; + end + + //Edition Sorting + else if (Identifier = 'EDITION') then + begin + Song.Edition := Value; + end + + //Creator Tag + else if (Identifier = 'CREATOR') then + begin + Song.Creator := Value; + end + + //Language Sorting + else if (Identifier = 'LANGUAGE') then + begin + Song.Language := Value; + end + + // Song Start + else if (Identifier = 'START') then + begin + // Replace . with , + if (Pos('.', Value) <> 0) then + Value[Pos('.', Value)] := ','; + + Song.Start := StrtoFloatDef(Value, 0); + end + + // Song Ending + else if (Identifier = 'END') then + begin + TryStrtoInt(Value, Song.Finish); + end + + // Resolution + else if (Identifier = 'RESOLUTION') then + begin + TryStrtoInt(Value, Song.Resolution); + end + + // Notes Gap + else if (Identifier = 'NOTESGAP') then + begin + TryStrtoInt(Value, Song.NotesGAP); + end + + // Relative Notes + else if (Identifier = 'RELATIVE') AND (uppercase(Value) = 'YES') then + begin + Song.Relative := True; + end; + + end; + end; + + if not EOf(SongFile) then + ReadLn (SongFile, Line) + else + begin + Result := False; + + if lWarnIfTagsNotFound then + begin + Log.LogError('File Incomplete or not Ultrastar TxT: ' + Song.FileName); + end; + + break; + end; + + {//End on first empty Line + if (Length(Line) = 0) then + break;} + end; + + //Check if all Required Values are given + if (Done <> 15) then + begin + Result := False; + If lWarnIfTagsNotFound then + begin + if (Done and 8) = 0 then //No BPM Flag + Log.LogError('BPM Tag Missing: ' + Song.FileName) + else if (Done and 4) = 0 then //No MP3 Flag + Log.LogError('MP3 Tag/File Missing: ' + Song.FileName) + else if (Done and 2) = 0 then //No Artist Flag + Log.LogError('Artist Tag Missing: ' + Song.FileName) + else if (Done and 1) = 0 then //No Title Flag + Log.LogError('Title Tag Missing: ' + Song.FileName) + else //unknown Error + Log.LogError('File Incomplete or not Ultrastar TxT: ' + Song.FileName); + end; + end; + +end; + +//-------------------- +// Analyse Song File and Read Header +//-------------------- +function AnalyseFile(var Song: TSong): boolean; +begin +Result := False; +{try } + //Reset LineNo + FileLineNo := 0; + + //Open File and set File Pointer to the beginning + AssignFile(SongFile, Song.Path + Song.FileName); + Reset(SongFile); + + //Clear old Song Header + ClearSong(Song); + + //Read Header + Result := ReadTxTHeader(Song); + + //And Close File + CloseFile(SongFile); +{except + CloseFile(SongFile); + + Result := False; + //Error Reporting + Log.LogError('An Error occured reading Line ' + inttostr(FileLineNo) + ' from SongHeader: ' + Song.FileName); +end;} +end; + +//-------------------- +// Resets the temporary Sentence Arrays for each Player and some other Variables +//-------------------- +procedure ResetSingTemp; +var + Pet: integer; +begin + SetLength(Czesci, Length(Player)); + SetLength(AktSong.BPM, 0); + for Pet := 0 to High(Player) do begin + SetLength(Czesci[Pet].Czesc, 1); + SetLength(Czesci[Pet].Czesc[0].Nuta, 0); + Czesci[Pet].Czesc[0].Lyric := ''; + Czesci[Pet].Czesc[0].LyricWidth := 0; + Player[pet].Score := 0; + Player[pet].IlNut := 0; + Player[pet].HighNut := -1; + end; + //Reset Path and Filename Values to Prevent Errors in Editor + AktSong.Path := ''; + AktSong.FileName := ''; +end; + +//-------------------- +// Parses Note Infos and save them to Array +//-------------------- +procedure ParseNote(NrCzesci: integer; TypeP: char; StartP, DurationP, NoteP: integer; LyricS: string); +var + Space: boolean; +begin + case Ini.Solmization of + 1: // european + begin + case (NoteP mod 12) of + 0..1: LyricS := ' do '; + 2..3: LyricS := ' re '; + 4: LyricS := ' mi '; + 5..6: LyricS := ' fa '; + 7..8: LyricS := ' sol '; + 9..10: LyricS := ' la '; + 11: LyricS := ' si '; + end; + end; + 2: // japanese + begin + case (NoteP mod 12) of + 0..1: LyricS := ' do '; + 2..3: LyricS := ' re '; + 4: LyricS := ' mi '; + 5..6: LyricS := ' fa '; + 7..8: LyricS := ' so '; + 9..10: LyricS := ' la '; + 11: LyricS := ' shi '; + end; + end; + 3: // american + begin + case (NoteP mod 12) of + 0..1: LyricS := ' do '; + 2..3: LyricS := ' re '; + 4: LyricS := ' mi '; + 5..6: LyricS := ' fa '; + 7..8: LyricS := ' sol '; + 9..10: LyricS := ' la '; + 11: LyricS := ' ti '; + end; + end; + end; // case + + with Czesci[NrCzesci].Czesc[Czesci[NrCzesci].High] do begin + SetLength(Nuta, Length(Nuta) + 1); + IlNut := IlNut + 1; + HighNut := HighNut + 1; + Muzyka.IlNut := Muzyka.IlNut + 1; + + Nuta[HighNut].Start := StartP; + if IlNut = 1 then begin + StartNote := Nuta[HighNut].Start; + if Czesci[NrCzesci].Ilosc = 1 then + Start := -100; +// Start := Nuta[HighNut].Start; + end; + + Nuta[HighNut].Dlugosc := DurationP; + Muzyka.DlugoscNut := Muzyka.DlugoscNut + Nuta[HighNut].Dlugosc; + + // back to the normal system with normal, golden and now freestyle notes + case TypeP of + 'F': Nuta[HighNut].Wartosc := 0; + ':': Nuta[HighNut].Wartosc := 1; + '*': Nuta[HighNut].Wartosc := 2; + end; + + Czesci[NrCzesci].Wartosc := Czesci[NrCzesci].Wartosc + Nuta[HighNut].Dlugosc * Nuta[HighNut].Wartosc; + + Nuta[HighNut].Ton := NoteP; + if Nuta[HighNut].Ton < Base[NrCzesci] then Base[NrCzesci] := Nuta[HighNut].Ton; + Nuta[HighNut].TonGamy := Nuta[HighNut].TonGamy mod 12; + + Nuta[HighNut].Tekst := Copy(LyricS, 2, 100); + Lyric := Lyric + Nuta[HighNut].Tekst; + + if TypeP = 'F' then + Nuta[HighNut].FreeStyle := true; + + Koniec := Nuta[HighNut].Start + Nuta[HighNut].Dlugosc; + end; // with +end; + +//-------------------- +// Called when a new Sentence is found in the TXT File +//-------------------- +procedure NewSentence(NrCzesciP: integer; Param1, Param2: integer); +var +I: Integer; +begin + + // stara czesc //Alter Satz //Update Old Part + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].BaseNote := Base[NrCzesciP]; + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].LyricWidth := glTextWidth(PChar(Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Lyric)); + + //Total Notes Patch + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].TotalNotes := 0; + for I := low(Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Nuta) to high(Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Nuta) do + begin + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].TotalNotes := Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].TotalNotes + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Nuta[I].Dlugosc * Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Nuta[I].Wartosc; + end; + //Total Notes Patch End + + + // nowa czesc //Neuer Satz //Update New Part + SetLength(Czesci[NrCzesciP].Czesc, Czesci[NrCzesciP].Ilosc + 1); + Czesci[NrCzesciP].High := Czesci[NrCzesciP].High + 1; + Czesci[NrCzesciP].Ilosc := Czesci[NrCzesciP].Ilosc + 1; + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].HighNut := -1; + + if not AktSong.Relative then + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Start := Param1; + + if AktSong.Relative then begin + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Start := Param1; + Rel[NrCzesciP] := Rel[NrCzesciP] + Param2; + end; + + Base[NrCzesciP] := 100; // high number +end; + +//-------------------- +// Load a Song +//-------------------- +function LoadSong(Name: string): boolean; +var + TempC: char; + Tekst: string; + CP: integer; // Current Player (0 or 1) + Pet: integer; + Both: boolean; + Param1: integer; + Param2: integer; + Param3: integer; + ParamS: string; + I: Integer; +begin + Result := false; + + if not FileExists(Name) then begin + Log.LogError('File not found: "' + Name + '"', 'WczytajCzesci'); + exit; + end; + + try + MultBPM := 4; // 4 - mnoznik dla czasu nut + Mult := 1; // 4 - dokladnosc pomiaru nut + Base[0] := 100; // high number +// Base[1] := 100; // high number + Czesci[0].Wartosc := 0; +// Czesci[1].Wartosc := 0; // here was the error in 0.3.2 + AktSong.Relative := false; + + Rel[0] := 0; +// Rel[1] := 0; + CP := 0; + Both := false; + if Length(Player) = 2 then Both := true; + + FileMode := fmOpenRead; + AssignFile(SongFile, Name); + Reset(SongFile); + + //Clear old Song Header + ClearSong(AktSong); + + if (AktSong.Path = '') then + AktSong.Path := ExtractFilePath(Name); + + if (AktSong.FileName = '') then + AktSong.Filename := ExtractFileName(Name); + //Read Header + Result := ReadTxTHeader(AktSong); + if not Result then + begin + CloseFile(SongFile); + Log.LogError('Error Loading SongHeader, abort Song Loading'); + Exit; + end; + + Result := False; + + Reset(SongFile); + FileLineNo := 0; + //Search for Note Begining + repeat + ReadLn(SongFile, Tekst); + Inc(FileLineNo); + + if (EoF(SongFile)) then + begin //Song File Corrupted - No Notes + CloseFile(SongFile); + Log.LogError('Could not load txt File, no Notes found: ' + Name); + Result := False; + Exit; + end; + Read(SongFile, TempC); + until ((TempC = ':') or (TempC = 'F') or (TempC = '*')); + + SetLength(Czesci, 2); + for Pet := 0 to High(Czesci) do begin + SetLength(Czesci[Pet].Czesc, 1); + Czesci[Pet].High := 0; + Czesci[Pet].Ilosc := 1; + Czesci[Pet].Akt := 0; + Czesci[Pet].Resolution := AktSong.Resolution; + Czesci[Pet].NotesGAP := AktSong.NotesGAP; + Czesci[Pet].Czesc[0].IlNut := 0; + Czesci[Pet].Czesc[0].HighNut := -1; + end; + +// TempC := ':'; +// TempC := Tekst[1]; // read from backup variable, don't use default ':' value + + while (TempC <> 'E') AND (not EOF(SongFile)) do begin + if (TempC = ':') or (TempC = '*') or (TempC = 'F') then begin + // wczytuje nute + Read(SongFile, Param1); + Read(SongFile, Param2); + Read(SongFile, Param3); + Read(SongFile, ParamS); + + // dodaje nute + if not Both then + // P1 + ParseNote(0, TempC, (Param1+Rel[0]) * Mult, Param2 * Mult, Param3, ParamS) + else begin + // P1 + P2 + ParseNote(0, TempC, (Param1+Rel[0]) * Mult, Param2 * Mult, Param3, ParamS); + ParseNote(1, TempC, (Param1+Rel[1]) * Mult, Param2 * Mult, Param3, ParamS); + end; + end; // if + if TempC = '-' then begin + // reads sentence + Read(SongFile, Param1); + if AktSong.Relative then Read(SongFile, Param2); // read one more data for relative system + + // new sentence + if not Both then + // P1 + NewSentence(0, (Param1 + Rel[0]) * Mult, Param2) + else begin + // P1 + P2 + NewSentence(0, (Param1 + Rel[0]) * Mult, Param2); + NewSentence(1, (Param1 + Rel[1]) * Mult, Param2); + end; + + end; // if + + if TempC = 'B' then begin + SetLength(AktSong.BPM, Length(AktSong.BPM) + 1); + Read(SongFile, AktSong.BPM[High(AktSong.BPM)].StartBeat); + AktSong.BPM[High(AktSong.BPM)].StartBeat := AktSong.BPM[High(AktSong.BPM)].StartBeat + Rel[0]; + + Read(SongFile, Tekst); + AktSong.BPM[High(AktSong.BPM)].BPM := StrToFloat(Tekst); + AktSong.BPM[High(AktSong.BPM)].BPM := AktSong.BPM[High(AktSong.BPM)].BPM * Mult * MultBPM; + end; + + + if not Both then begin + Czesci[CP].Czesc[Czesci[CP].High].BaseNote := Base[CP]; + Czesci[CP].Czesc[Czesci[CP].High].LyricWidth := glTextWidth(PChar(Czesci[CP].Czesc[Czesci[CP].High].Lyric)); + //Total Notes Patch + Czesci[CP].Czesc[Czesci[CP].High].TotalNotes := 0; + for I := low(Czesci[CP].Czesc[Czesci[CP].High].Nuta) to high(Czesci[CP].Czesc[Czesci[CP].High].Nuta) do + begin + Czesci[CP].Czesc[Czesci[CP].High].TotalNotes := Czesci[CP].Czesc[Czesci[CP].High].TotalNotes + Czesci[CP].Czesc[Czesci[CP].High].Nuta[I].Dlugosc * Czesci[CP].Czesc[Czesci[CP].High].Nuta[I].Wartosc; + end; + //Total Notes Patch End + end else begin + for Pet := 0 to High(Czesci) do begin + Czesci[Pet].Czesc[Czesci[Pet].High].BaseNote := Base[Pet]; + Czesci[Pet].Czesc[Czesci[Pet].High].LyricWidth := glTextWidth(PChar(Czesci[Pet].Czesc[Czesci[Pet].High].Lyric)); + //Total Notes Patch + Czesci[Pet].Czesc[Czesci[Pet].High].TotalNotes := 0; + for I := low(Czesci[Pet].Czesc[Czesci[Pet].High].Nuta) to high(Czesci[Pet].Czesc[Czesci[Pet].High].Nuta) do + begin + Czesci[Pet].Czesc[Czesci[Pet].High].TotalNotes := Czesci[Pet].Czesc[Czesci[Pet].High].TotalNotes + Czesci[Pet].Czesc[Czesci[Pet].High].Nuta[I].Dlugosc * Czesci[Pet].Czesc[Czesci[Pet].High].Nuta[I].Wartosc; + end; + //Total Notes Patch End + end; + end; + + Read(SongFile, TempC); + Inc(FileLineNo); + end; // while} + + CloseFile(SongFile); + except + try + CloseFile(SongFile); + except + + end; + + Log.LogError('Error Loading File: "' + Name + '" in Line ' + inttostr(FileLineNo)); + exit; + end; + + Result := true; +end; + +//-------------------- +// Saves a Song +//-------------------- +function SaveSong(Song: TSong; Czesc: TCzesci; Name: string; Relative: boolean): boolean; +var + C: integer; + N: integer; + S: string; + B: integer; + RelativeSubTime: integer; + NoteState: String; + +begin +// Relative := true; // override (idea - use shift+S to save with relative) + AssignFile(SongFile, Name); + Rewrite(SongFile); + + WriteLn(SongFile, '#TITLE:' + Song.Title + ''); + WriteLn(SongFile, '#ARTIST:' + Song.Artist); + + if Song.Creator <> '' then WriteLn(SongFile, '#CREATOR:' + Song.Creator); + if Song.Edition <> 'Unknown' then WriteLn(SongFile, '#EDITION:' + Song.Edition); + if Song.Genre <> 'Unknown' then WriteLn(SongFile, '#GENRE:' + Song.Genre); + if Song.Language <> 'Unknown' then WriteLn(SongFile, '#LANGUAGE:' + Song.Language); + + WriteLn(SongFile, '#MP3:' + Song.Mp3); + + if Song.Cover <> '' then WriteLn(SongFile, '#COVER:' + Song.Cover); + if Song.Background <> '' then WriteLn(SongFile, '#BACKGROUND:' + Song.Background); + if Song.Video <> '' then WriteLn(SongFile, '#VIDEO:' + Song.Video); + if Song.VideoGAP <> 0 then WriteLn(SongFile, '#VIDEOGAP:' + FloatToStr(Song.VideoGAP)); + if Song.Resolution <> 4 then WriteLn(SongFile, '#RESOLUTION:' + IntToStr(Song.Resolution)); + if Song.NotesGAP <> 0 then WriteLn(SongFile, '#NOTESGAP:' + IntToStr(Song.NotesGAP)); + if Song.Start <> 0 then WriteLn(SongFile, '#START:' + FloatToStr(Song.Start)); + if Song.Finish <> 0 then WriteLn(SongFile, '#END:' + IntToStr(Song.Finish)); + if Relative then WriteLn(SongFile, '#RELATIVE:yes'); + + WriteLn(SongFile, '#BPM:' + FloatToStr(Song.BPM[0].BPM / 4)); + WriteLn(SongFile, '#GAP:' + FloatToStr(Song.GAP)); + + RelativeSubTime := 0; + for B := 1 to High(AktSong.BPM) do + WriteLn(SongFile, 'B ' + FloatToStr(AktSong.BPM[B].StartBeat) + ' ' + FloatToStr(AktSong.BPM[B].BPM/4)); + + for C := 0 to Czesc.High do begin + for N := 0 to Czesc.Czesc[C].HighNut do begin + with Czesc.Czesc[C].Nuta[N] do begin + + + //Golden + Freestyle Note Patch + case Czesc.Czesc[C].Nuta[N].Wartosc of + 0: NoteState := 'F '; + 1: NoteState := ': '; + 2: NoteState := '* '; + end; // case + S := NoteState + IntToStr(Start-RelativeSubTime) + ' ' + IntToStr(Dlugosc) + ' ' + IntToStr(Ton) + ' ' + Tekst; + + + WriteLn(SongFile, S); + end; // with + end; // N + + if C < Czesc.High then begin // don't write end of last sentence + if not Relative then + S := '- ' + IntToStr(Czesc.Czesc[C+1].Start) + else begin + S := '- ' + IntToStr(Czesc.Czesc[C+1].Start - RelativeSubTime) + + ' ' + IntToStr(Czesc.Czesc[C+1].Start - RelativeSubTime); + RelativeSubTime := Czesc.Czesc[C+1].Start; + end; + WriteLn(SongFile, S); + end; + + end; // C + + + WriteLn(SongFile, 'E'); + CloseFile(SongFile); +end; + +end. \ No newline at end of file diff --git a/Game/Code/Classes/UGraphic.pas b/Game/Code/Classes/UGraphic.pas new file mode 100644 index 00000000..9e494b5c --- /dev/null +++ b/Game/Code/Classes/UGraphic.pas @@ -0,0 +1,536 @@ +unit UGraphic; + +interface +uses + SDL, OpenGL12, UTexture, TextGL, ULog, SysUtils, ULyrics, UScreenLoading, + UScreenWelcome, UScreenMain, UScreenName, UScreenLevel, UScreenOptions, UScreenOptionsGame, + UScreenOptionsGraphics, UScreenOptionsSound, UScreenOptionsLyrics, UScreenOptionsThemes, UScreenOptionsRecord, UScreenOptionsAdvanced, + UScreenSong, UScreenSing, UScreenScore, UScreenTop5, UScreenEditSub, + UScreenEdit, UScreenEditConvert, UScreenEditHeader, UScreenOpen, UThemes, USkins, UScreenSongMenu, UScreenSongJumpto, + {Party Screens} UScreenSingModi, UScreenPartyNewRound, UScreenPartyScore, UScreenPartyOptions, UScreenPartyWin, UScreenPartyPlayer, + {Stats Screens} UScreenStatMain, UScreenStatDetail, + {CreditsScreen} UScreenCredits, + {Popup for errors, etc.} UScreenPopup; + +type + TRecR = record + Top: real; + Left: real; + Right: real; + Bottom: real; + end; + +var + Screen: PSDL_Surface; + + RenderW: integer; + RenderH: integer; + ScreenW: integer; + ScreenH: integer; + Screens: integer; + ScreenAct: integer; + ScreenX: integer; + + ScreenLoading: TScreenLoading; + ScreenWelcome: TScreenWelcome; + ScreenMain: TScreenMain; + ScreenName: TScreenName; + ScreenLevel: TScreenLevel; + ScreenSong: TScreenSong; + ScreenSing: TScreenSing; + ScreenScore: TScreenScore; + ScreenTop5: TScreenTop5; + ScreenOptions: TScreenOptions; + ScreenOptionsGame: TScreenOptionsGame; + ScreenOptionsGraphics: TScreenOptionsGraphics; + ScreenOptionsSound: TScreenOptionsSound; + ScreenOptionsLyrics: TScreenOptionsLyrics; + ScreenOptionsThemes: TScreenOptionsThemes; + ScreenOptionsRecord: TScreenOptionsRecord; + ScreenOptionsAdvanced: TScreenOptionsAdvanced; + ScreenEditSub: TScreenEditSub; + ScreenEdit: TScreenEdit; + ScreenEditConvert: TScreenEditConvert; + ScreenEditHeader: TScreenEditHeader; + ScreenOpen: TScreenOpen; + + ScreenSongMenu: TScreenSongMenu; + ScreenSongJumpto: TScreenSongJumpto; + + //Party Screens + ScreenSingModi: TScreenSingModi; + ScreenPartyNewRound: TScreenPartyNewRound; + ScreenPartyScore: TScreenPartyScore; + ScreenPartyWin: TScreenPartyWin; + ScreenPartyOptions: TScreenPartyOptions; + ScreenPartyPlayer: TScreenPartyPlayer; + + //StatsScreens + ScreenStatMain: TScreenStatMain; + ScreenStatDetail: TScreenStatDetail; + + //CreditsScreen + ScreenCredits: TScreenCredits; + + //popup mod + ScreenPopupCheck: TScreenPopupCheck; + ScreenPopupError: TScreenPopupError; + + //Notes + Tex_Left: array[0..6] of TTexture; + Tex_Mid: array[0..6] of TTexture; + Tex_Right: array[0..6] of TTexture; + + Tex_BG_Left: array[1..6] of TTexture; + Tex_BG_Mid: array[1..6] of TTexture; + Tex_BG_Right: array[1..6] of TTexture; + + Tex_Note_Star: TTexture; + Tex_Note_Perfect_Star: TTexture; + + + Tex_Ball: TTexture; + Tex_Lyric_Help_Bar: TTexture; + FullScreen: boolean; + + Tex_TimeProgress: TTexture; + + //Sing Bar Mod + Tex_SingBar_Back: TTexture; + Tex_SingBar_Bar: TTexture; + Tex_SingBar_Front: TTexture; + //end Singbar Mod + + //PhrasenBonus - Line Bonus Mod + Tex_SingLineBonusBack: TTexture; + //End PhrasenBonus - Line Bonus Mod + +const + Skin_BGColorR = 1; + Skin_BGColorG = 1; + Skin_BGColorB = 1; + + Skin_SpectrumR = 0; + Skin_SpectrumG = 0; + Skin_SpectrumB = 0; + + Skin_Spectograph1R = 0.6; + Skin_Spectograph1G = 0.8; + Skin_Spectograph1B = 1; + + Skin_Spectograph2R = 0; + Skin_Spectograph2G = 0; + Skin_Spectograph2B = 0.2; + + Skin_SzczytR = 0.8; + Skin_SzczytG = 0; + Skin_SzczytB = 0; + + Skin_SzczytLimitR = 0; + Skin_SzczytLimitG = 0.8; + Skin_SzczytLimitB = 0; + + Skin_FontR = 0; + Skin_FontG = 0; + Skin_FontB = 0; + + Skin_FontHighlightR = 0.3; // 0.3 + Skin_FontHighlightG = 0.3; // 0.3 + Skin_FontHighlightB = 1; // 1 + + Skin_TimeR = 0.25; //0,0,0 + Skin_TimeG = 0.25; + Skin_TimeB = 0.25; + + Skin_OscR = 0; + Skin_OscG = 0; + Skin_OscB = 0; + + Skin_LyricsT = 494; // 500 / 510 / 400 + Skin_SpectrumT = 470; + Skin_SpectrumBot = 570; + Skin_SpectrumH = 100; + + Skin_P1_LinesR = 0.5; // 0.6 0.6 1 + Skin_P1_LinesG = 0.5; + Skin_P1_LinesB = 0.5; + + Skin_P2_LinesR = 0.5; // 1 0.6 0.6 + Skin_P2_LinesG = 0.5; + Skin_P2_LinesB = 0.5; + + Skin_P1_NotesB = 250; + Skin_P2_NotesB = 430; // 430 / 300 + + Skin_P1_ScoreT = 50; + Skin_P1_ScoreL = 20; + + Skin_P2_ScoreT = 50; + Skin_P2_ScoreL = 640; + +procedure Initialize3D (Title: string); +procedure Reinitialize3D; +procedure SwapBuffers; + +procedure LoadTextures; +procedure InitializeScreen; +procedure LoadScreens( aShowLoading : boolean = true ); +procedure UnLoadScreens; + + +implementation +uses UMain, UIni, UDisplay, UCommandLine, Graphics, Classes, Windows; + +procedure LoadTextures; +var + P: integer; + R, G, B: real; + Col: integer; +begin + // zaladowanie tekstur + Log.LogStatus('Loading Textures', 'LoadTextures'); + Tex_Left[0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayLeft')), 'BMP', 'Transparent', 0); + Tex_Mid[0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayMid')), 'BMP', 'Plain', 0); + Tex_Right[0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayRight')), 'BMP', 'Transparent', 0); + + // P1-6 + for P := 1 to 6 do begin + LoadColor(R, G, B, 'P' + IntToStr(P) + 'Light'); + Col := $10000 * Round(R*255) + $100 * Round(G*255) + Round(B*255); + Tex_Left[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayLeft')), 'BMP', 'Note Transparent', Col); + Tex_Mid[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayMid')), 'BMP', 'Note Plain', Col); + Tex_Right[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayRight')), 'BMP', 'Note Transparent', Col); + + Tex_BG_Left[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NoteBGLeft')), 'BMP', 'Alpha Black Colored', Col); + Tex_BG_Mid[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NoteBGMid')), 'BMP', 'Alpha Black Colored', Col); + Tex_BG_Right[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NoteBGRight')), 'BMP', 'Alpha Black Colored', Col); + end; + + Tex_Note_Perfect_Star := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NotePerfectStar')), 'JPG', 'Font Black', 0); + Tex_Note_Star := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NoteStar')) , 'JPG', 'Alpha Black Colored', $FFFFFF); + Tex_Ball := Texture.LoadTexture(pchar(Skin.GetTextureFileName('Ball')), 'BMP', 'Transparent', $FF00FF); + Tex_Lyric_Help_Bar := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricHelpBar')), 'BMP', 'Transparent', $FF00FF); + + + //TimeBar mod + Tex_TimeProgress := Texture.LoadTexture(pchar(Skin.GetTextureFileName('TimeBar'))); + //eoa TimeBar mod + + //SingBar Mod + Tex_SingBar_Back := Texture.LoadTexture(pchar(Skin.GetTextureFileName('SingBarBack')), 'JPG', 'Plain', 0); + Tex_SingBar_Bar := Texture.LoadTexture(pchar(Skin.GetTextureFileName('SingBarBar')), 'JPG', 'Plain', 0); + Tex_SingBar_Front := Texture.LoadTexture(pchar(Skin.GetTextureFileName('SingBarFront')), 'JPG', 'Font', 0); + //end Singbar Mod + + //PhrasenBonus - Line Bonus Mod + Tex_SingLineBonusBack := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LineBonusBack')), 'JPG', 'Font Black', 0); + {//Set Texture to Font High + Tex_SingLineBonusL.H := 32; Tex_SingLineBonusL.W := 8; + Tex_SingLineBonusM.H := 32; //Tex_SingLineBonusM.TexW := Tex_SingLineBonusM.TexW/2; + Tex_SingLineBonusR.H := 32; Tex_SingLineBonusR.W := 8; } + //PhrasenBonus - Line Bonus Mod End + + // tworzenie czcionek + Log.LogStatus('Building Fonts', 'LoadTextures'); + BuildFont; +end; + +procedure Initialize3D (Title: string); +var + Icon: TIcon; + Res: TResourceStream; + ISurface: PSDL_Surface; + Pixel: PByteArray; +begin + Log.LogStatus('LoadOpenGL', 'Initialize3D'); + Log.BenchmarkStart(2); + + LoadOpenGL; + + Log.LogStatus('SDL_Init', 'Initialize3D'); + if ( SDL_Init(SDL_INIT_VIDEO or SDL_INIT_AUDIO)= -1 ) then begin + Log.LogError('SDL_Init Failed', 'Initialize3D'); + exit; + end; + + { //Load Icon + Res := TResourceStream.CreateFromID(HInstance, 3, RT_ICON); + Icon := TIcon.Create; + Icon.LoadFromStream(Res); + Res.Free; + Icon. + //Create icon Surface + SDL_CreateRGBSurfaceFrom ( + SDL_SWSURFACE, + Icon.Width, + Icon.Height, + 32, + 128 or 64, + 32 or 16, + 8 or 4, + 2 or 1); + //SDL_BlitSurface( + + + SDL_WM_SetIcon(SDL_LoadBMP('DEFAULT_WINDOW_ICON'), 0); //} + + SDL_WM_SetCaption(PChar(Title), nil); + + InitializeScreen; + + Log.BenchmarkEnd(2); + Log.LogBenchmark('--> Setting Screen', 2); + + // ladowanie tekstur + Log.BenchmarkStart(2); + Texture := TTextureUnit.Create; + Texture.Limit := 1024*1024; + + LoadTextures; + Log.BenchmarkEnd(2); + Log.LogBenchmark('--> Loading Textures', 2); + + Log.BenchmarkStart(2); + Lyric := TLyric.Create; + Log.BenchmarkEnd(2); + Log.LogBenchmark('--> Loading Fonts', 2); + + Log.BenchmarkStart(2); + Display := TDisplay.Create; + SDL_EnableUnicode(1); + Log.BenchmarkEnd(2); Log.LogBenchmark('====> Creating Display', 2); + + Log.LogStatus('Loading Screens', 'Initialize3D'); + Log.BenchmarkStart(3); + + LoadScreens; + Display.ActualScreen^.FadeTo(@ScreenMain); + + Log.BenchmarkEnd(2); + Log.LogBenchmark('--> Loading Screens', 2); + + Log.LogStatus('Finish', 'Initialize3D'); +end; + +procedure SwapBuffers; +begin + SDL_GL_SwapBuffers; + glMatrixMode(GL_PROJECTION); + glLoadIdentity; + glOrtho(0, 800, 600, 0, -1, 100); + glMatrixMode(GL_MODELVIEW); +end; + +procedure Reinitialize3D; +begin +// InitializeScreen; +// LoadTextures; +// LoadScreens; +end; + +procedure InitializeScreen; +var + S: string; + I: integer; + W, H: integer; + Depth: Integer; +begin + if (Params.Screens <> -1) then + Screens := Params.Screens + 1 + else + Screens := Ini.Screens + 1; + + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + + // If there is a resolution in Parameters, use it, else use the Ini value + I := Params.Resolution; + if (I <> -1) then + S := IResolution[I] + else + S := IResolution[Ini.Resolution]; + + I := Pos('x', S); + W := StrToInt(Copy(S, 1, I-1)) * Screens; + H := StrToInt(Copy(S, I+1, 1000)); + + {if ParamStr(1) = '-fsblack' then begin + W := 800; + H := 600; + end; + if ParamStr(1) = '-320x240' then begin + W := 320; + H := 240; + end; } + + If (Params.Depth <> -1) then + Depth := Params.Depth + else + Depth := Ini.Depth; + + + Log.LogStatus('SDL_SetVideoMode', 'Initialize3D'); +// SDL_SetRefreshrate(85); +// SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + if (Ini.FullScreen = 0) and (Not Params.FullScreen) then + screen := SDL_SetVideoMode(W, H, (Depth+1) * 16, SDL_OPENGL) + else begin + screen := SDL_SetVideoMode(W, H, (Depth+1) * 16, SDL_OPENGL or SDL_FULLSCREEN); + SDL_ShowCursor(0); + end; + if (screen = nil) then begin + Log.LogError('SDL_SetVideoMode Failed', 'Initialize3D'); + exit; + end; + + // clear screen once window is being shown + glClearColor(1, 1, 1, 1); + glClear(GL_COLOR_BUFFER_BIT); + SwapBuffers; + + // zmienne + RenderW := 800; + RenderH := 600; + ScreenW := W; + ScreenH := H; +end; + +procedure LoadScreens( aShowLoading : boolean = true ); +begin + + ScreenLoading := TScreenLoading.Create; + if aShowLoading then + begin + ScreenLoading.onShow; + Display.ActualScreen := @ScreenLoading; + ScreenLoading.Draw; + Display.Draw; + SwapBuffers; + end; + + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Loading', 3); Log.BenchmarkStart(3); +{ ScreenWelcome := TScreenWelcome.Create; //'BG', 4, 3); + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Welcome', 3); Log.BenchmarkStart(3);} + ScreenMain := TScreenMain.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Main', 3); Log.BenchmarkStart(3); + ScreenName := TScreenName.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Name', 3); Log.BenchmarkStart(3); + ScreenLevel := TScreenLevel.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Level', 3); Log.BenchmarkStart(3); + ScreenSong := TScreenSong.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Song', 3); Log.BenchmarkStart(3); + ScreenSongMenu := TScreenSongMenu.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Song Menu', 3); Log.BenchmarkStart(3); + ScreenSing := TScreenSing.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Sing', 3); Log.BenchmarkStart(3); + ScreenScore := TScreenScore.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Score', 3); Log.BenchmarkStart(3); + ScreenTop5 := TScreenTop5.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Top5', 3); Log.BenchmarkStart(3); + ScreenOptions := TScreenOptions.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Options', 3); Log.BenchmarkStart(3); + ScreenOptionsGame := TScreenOptionsGame.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Options Game', 3); Log.BenchmarkStart(3); + ScreenOptionsGraphics := TScreenOptionsGraphics.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Options Graphics', 3); Log.BenchmarkStart(3); + ScreenOptionsSound := TScreenOptionsSound.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Options Sound', 3); Log.BenchmarkStart(3); + ScreenOptionsLyrics := TScreenOptionsLyrics.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Options Lyrics', 3); Log.BenchmarkStart(3); + ScreenOptionsThemes := TScreenOptionsThemes.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Options Themes', 3); Log.BenchmarkStart(3); + ScreenOptionsRecord := TScreenOptionsRecord.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Options Record', 3); Log.BenchmarkStart(3); + ScreenOptionsAdvanced := TScreenOptionsAdvanced.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Options Advanced', 3); Log.BenchmarkStart(3); + ScreenEditSub := TScreenEditSub.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Edit Sub', 3); Log.BenchmarkStart(3); + ScreenEdit := TScreenEdit.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Edit', 3); Log.BenchmarkStart(3); + ScreenEditConvert := TScreenEditConvert.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen EditConvert', 3); Log.BenchmarkStart(3); +// ScreenEditHeader := TScreenEditHeader.Create(Skin.ScoreBG); +// Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Edit Header', 3); Log.BenchmarkStart(3); + ScreenOpen := TScreenOpen.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Open', 3); Log.BenchmarkStart(3); + ScreenSingModi := TScreenSingModi.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Sing with Modi support', 3); Log.BenchmarkStart(3); + ScreenSongMenu := TScreenSongMenu.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen SongMenu', 3); Log.BenchmarkStart(3); + ScreenSongJumpto := TScreenSongJumpto.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen SongJumpto', 3); Log.BenchmarkStart(3); + ScreenPopupCheck := TScreenPopupCheck.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Popup (Check)', 3); Log.BenchmarkStart(3); + ScreenPopupError := TScreenPopupError.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Popup (Error)', 3); Log.BenchmarkStart(3); + ScreenPartyNewRound := TScreenPartyNewRound.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen PartyNewRound', 3); Log.BenchmarkStart(3); + ScreenPartyScore := TScreenPartyScore.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen PartyScore', 3); Log.BenchmarkStart(3); + ScreenPartyWin := TScreenPartyWin.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen PartyWin', 3); Log.BenchmarkStart(3); + ScreenPartyOptions := TScreenPartyOptions.Create; + 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); + ScreenStatMain := TScreenStatMain.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Stat Main', 3); Log.BenchmarkStart(3); + ScreenStatDetail := TScreenStatDetail.Create; + Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Stat Detail', 3); Log.BenchmarkStart(3); + //Now Created when needed + //ScreenCredits := TScreenCredits.Create; + //Log.BenchmarkEnd(3); Log.LogBenchmark('====> Screen Credits', 3); Log.BenchmarkStart(3); + + end; + +procedure UnLoadScreens; +begin +(* + ScreenLoading := TScreenLoading.Create; + ScreenLoading.onShow; + + Display.ActualScreen := @ScreenLoading; + + ScreenLoading.Draw; + Display.Draw; + SwapBuffers; +*) + + freeandnil( ScreenMain ); + freeandnil( ScreenName ); + freeandnil( ScreenLevel); + freeandnil( ScreenSong ); + freeandnil( ScreenSongMenu ); + freeandnil( ScreenSing ); + freeandnil( ScreenScore); + freeandnil( ScreenTop5 ); + freeandnil( ScreenOptions ); + freeandnil( ScreenOptionsGame ); + freeandnil( ScreenOptionsGraphics ); + freeandnil( ScreenOptionsSound ); + freeandnil( ScreenOptionsLyrics ); +// freeandnil( ScreenOptionsThemes ); + freeandnil( ScreenOptionsRecord ); + freeandnil( ScreenOptionsAdvanced ); + freeandnil( ScreenEditSub ); + freeandnil( ScreenEdit ); + freeandnil( ScreenEditConvert ); + freeandnil( ScreenOpen ); + freeandnil( ScreenSingModi ); + freeandnil( ScreenSongMenu ); + freeandnil( ScreenSongJumpto); + freeandnil( ScreenPopupCheck ); + freeandnil( ScreenPopupError ); + freeandnil( ScreenPartyNewRound ); + freeandnil( ScreenPartyScore ); + freeandnil( ScreenPartyWin ); + freeandnil( ScreenPartyOptions ); + freeandnil( ScreenPartyPlayer ); + freeandnil( ScreenStatMain ); + freeandnil( ScreenStatDetail ); +end; + +end. diff --git a/Game/Code/Classes/UGraphicClasses.pas b/Game/Code/Classes/UGraphicClasses.pas new file mode 100644 index 00000000..032830b9 --- /dev/null +++ b/Game/Code/Classes/UGraphicClasses.pas @@ -0,0 +1,655 @@ +// notes: +unit UGraphicClasses; + +interface +uses UTexture; +const DelayBetweenFrames : Cardinal = 60; +type + + TParticleType=(GoldenNote, PerfectNote, NoteHitTwinkle, PerfectLineTwinkle, ColoredStar, Flare); + + TColour3f = Record + r, g, b: Real; + end; + + TParticle = Class + X, Y : Real; //Position + Screen : Integer; + W, H : Cardinal; //dimensions of particle + Col : array of TColour3f; // Colour(s) of particle + Scale : array of Real; // Scaling factors of particle layers + Frame : Byte; //act. Frame + Tex : Cardinal; //Tex num from Textur Manager + Live : Byte; //How many Cycles before Kill + RecIndex : Integer; //To which rectangle this particle belongs (only GoldenNote) + StarType : TParticleType; // GoldenNote | PerfectNote | NoteHitTwinkle | PerfectLineTwinkle + Alpha : Real; // used for fading... + mX, mY : Real; // movement-vector for PerfectLineTwinkle + SizeMod : Real; // experimental size modifier + SurviveSentenceChange : Boolean; + + Constructor Create(cX,cY: Real; cScreen: Integer; cLive: Byte; cFrame : integer; cRecArrayIndex : Integer; cStarType : TParticleType; Player: Cardinal); + Destructor Destroy(); + procedure Draw; + procedure LiveOn; + end; + + RectanglePositions = Record + xTop, yTop, xBottom, yBottom : Real; + TotalStarCount : Integer; + CurrentStarCount : Integer; + Screen : Integer; + end; + + PerfectNotePositions = Record + xPos, yPos : Real; + Screen : Integer; + end; + + TEffectManager = Class + Particle : array of TParticle; + LastTime : Cardinal; + RecArray : Array of RectanglePositions; + TwinkleArray : Array[0..5] of Real; // store x-position of last twinkle for every player + PerfNoteArray : Array of PerfectNotePositions; + + FlareTex: TTexture; + + constructor Create; + destructor Destroy; override; + procedure Draw; + function Spawn(X, Y: Real; + Screen: Integer; + Live: Byte; + StartFrame: Integer; + RecArrayIndex: Integer; // this is only used with GoldenNotes + StarType: TParticleType; + Player: Cardinal // for PerfectLineTwinkle + ): Cardinal; + procedure SpawnRec(); + procedure Kill(index: Cardinal); + procedure KillAll(); + procedure SentenceChange(); + procedure SaveGoldenStarsRec(Xtop, Ytop, Xbottom, Ybottom: Real); + procedure SavePerfectNotePos(Xtop, Ytop: Real); + procedure GoldenNoteTwinkle(Top,Bottom,Right: Real; Player: Integer); + procedure SpawnPerfectLineTwinkle(); + end; + +var GoldenRec : TEffectManager; + +implementation +uses sysutils, Windows,OpenGl12, UIni, UMain, UThemes, USkins, UGraphic, UDrawTexture, math, dialogs; + +//TParticle +Constructor TParticle.Create(cX,cY: Real; cScreen: Integer; cLive: Byte; cFrame : integer; cRecArrayIndex : Integer; cStarType : TParticleType; Player: Cardinal); +begin + inherited Create; + // in this constructor we set all initial values for our particle + X := cX; + Y := cY; + Screen := cScreen; + Live := cLive; + Frame:= cFrame; + RecIndex := cRecArrayIndex; + StarType := cStarType; + Alpha := (-cos((Frame+1)*2*pi/16)+1); // neat fade-in-and-out + SetLength(Scale,1); + Scale[0] := 1; + SurviveSentenceChange := False; + SizeMod := 1; + case cStarType of + GoldenNote: + begin + Tex := Tex_Note_Star.TexNum; + W := 20; + H := 20; + SetLength(Scale,4); + Scale[1]:=0.8; + Scale[2]:=0.4; + Scale[3]:=0.3; + SetLength(Col,4); + Col[0].r := 1; + Col[0].g := 0.7; + Col[0].b := 0.1; + + Col[1].r := 1; + Col[1].g := 1; + Col[1].b := 0.4; + + Col[2].r := 1; + Col[2].g := 1; + Col[2].b := 1; + + Col[3].r := 1; + Col[3].g := 1; + Col[3].b := 1; + end; + PerfectNote: + begin + Tex := Tex_Note_Perfect_Star.TexNum; + W := 30; + H := 30; + SetLength(Col,1); + Col[0].r := 1; + Col[0].g := 1; + Col[0].b := 0.95; + end; + NoteHitTwinkle: + begin + Tex := Tex_Note_Star.TexNum; + Alpha := (Live/16); // linear fade-out + W := 15; + H := 15; + Setlength(Col,1); + Col[0].r := 1; + Col[0].g := 1; + Col[0].b := RandomRange(10*Live,100)/90; //0.9; + end; + PerfectLineTwinkle: + begin + Tex := Tex_Note_Star.TexNum; + W := RandomRange(10,20); + H := W; + SizeMod := (-cos((Frame+1)*5*2*pi/16)*0.5+1.1); + SurviveSentenceChange:=True; + // assign colours according to player given + SetLength(Scale,3); + Scale[1]:=0.3; + Scale[2]:=0.2; + SetLength(Col,3); + case Player of + 0: LoadColor(Col[0].r,Col[0].g,Col[0].b,'P1Light'); + 1: LoadColor(Col[0].r,Col[0].g,Col[0].b,'P2Light'); + 2: LoadColor(Col[0].r,Col[0].g,Col[0].b,'P3Light'); + 3: LoadColor(Col[0].r,Col[0].g,Col[0].b,'P4Light'); + 4: LoadColor(Col[0].r,Col[0].g,Col[0].b,'P5Light'); + 5: LoadColor(Col[0].r,Col[0].g,Col[0].b,'P6Light'); + else LoadColor(Col[0].r,Col[0].g,Col[0].b,'P1Light'); + end; + Col[1].r := 1; + Col[1].g := 1; + Col[1].b := 0.4; + Col[2].r:=Col[0].r+0.5; + Col[2].g:=Col[0].g+0.5; + Col[2].b:=Col[0].b+0.5; + mX := RandomRange(-5,5); + mY := RandomRange(-5,5); + end; + ColoredStar: + begin + Tex := Tex_Note_Star.TexNum; + W := RandomRange(10,20); + H := W; + SizeMod := (-cos((Frame+1)*5*2*pi/16)*0.5+1.1); + SurviveSentenceChange:=True; + // assign colours according to player given + SetLength(Scale,1); + SetLength(Col,1); + Col[0].b := (Player and $ff)/255; + Col[0].g := ((Player shr 8) and $ff)/255; + Col[0].r := ((Player shr 16) and $ff)/255; + mX := 0; + mY := 0; + end; + Flare: + begin + Tex := Tex_Note_Star.TexNum; + W := 7; + H := 7; + SizeMod := (-cos((Frame+1)*5*2*pi/16)*0.5+1.1); + mX := RandomRange(-5,5); + mY := RandomRange(-5,5); + SetLength(Scale,4); + Scale[1]:=0.8; + Scale[2]:=0.4; + Scale[3]:=0.3; + SetLength(Col,4); + Col[0].r := 1; + Col[0].g := 0.7; + Col[0].b := 0.1; + + Col[1].r := 1; + Col[1].g := 1; + Col[1].b := 0.4; + + Col[2].r := 1; + Col[2].g := 1; + Col[2].b := 1; + + Col[3].r := 1; + Col[3].g := 1; + Col[3].b := 1; + + end; + else // just some random default values + begin + Tex := Tex_Note_Star.TexNum; + Alpha := 1; + W := 20; + H := 20; + SetLength(Col,1); + Col[0].r := 1; + Col[0].g := 1; + Col[0].b := 1; + end; + end; +end; + +Destructor TParticle.Destroy(); +begin + SetLength(Scale,0); + SetLength(Col,0); + inherited; +end; + +procedure TParticle.LiveOn; +begin + //Live = 0 => Live forever ?? die werden doch aber im Manager bei Draw getötet, wenns 0 is + if (Live > 0) then + Dec(Live); + + // animate frames + Frame := ( Frame + 1 ) mod 16; + + // make our particles do funny stuff (besides being animated) + // changes of any particle-values throughout its life are done here + case StarType of + GoldenNote: + begin + Alpha := (-cos((Frame+1)*2*pi/16)+1); // neat fade-in-and-out + end; + PerfectNote: + begin + Alpha := (-cos((Frame+1)*2*pi/16)+1); // neat fade-in-and-out + end; + NoteHitTwinkle: + begin + Alpha := (Live/10); // linear fade-out + end; + PerfectLineTwinkle: + begin + Alpha := (-cos((Frame+1)*2*pi/16)+1); // neat fade-in-and-out + SizeMod := (-cos((Frame+1)*5*2*pi/16)*0.5+1.1); + // move around + X := X + mX; + Y := Y + mY; + end; + ColoredStar: + begin + Alpha := (-cos((Frame+1)*2*pi/16)+1); // neat fade-in-and-out + end; + Flare: + begin + Alpha := (-cos((Frame+1)/16*1.7*pi+0.3*pi)+1); // neat fade-in-and-out + SizeMod := (-cos((Frame+1)*5*2*pi/16)*0.5+1.1); + // move around + X := X + mX; + Y := Y + mY; + mY:=mY+1.8; +// mX:=mX/2; + end; + end; +end; + +procedure TParticle.Draw; +var L: Cardinal; +begin + if ScreenAct = Screen then + // this draws (multiple) texture(s) of our particle + for L:=0 to High(Col) do + begin + glColor4f(Col[L].r, Col[L].g, Col[L].b, Alpha); + + glBindTexture(GL_TEXTURE_2D, Tex); + glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + begin + glBegin(GL_QUADS); + glTexCoord2f((1/16) * Frame, 0); glVertex2f(X-W*Scale[L]*SizeMod, Y-H*Scale[L]*SizeMod); + glTexCoord2f((1/16) * Frame + (1/16), 0); glVertex2f(X-W*Scale[L]*SizeMod, Y+H*Scale[L]*SizeMod); + glTexCoord2f((1/16) * Frame + (1/16), 1); glVertex2f(X+W*Scale[L]*SizeMod, Y+H*Scale[L]*SizeMod); + glTexCoord2f((1/16) * Frame, 1); glVertex2f(X+W*Scale[L]*SizeMod, Y-H*Scale[L]*SizeMod); + glEnd; + end; + end; + glcolor4f(1,1,1,1); +end; +// end of TParticle + +// TEffectManager + +constructor TEffectManager.Create; +var c: Cardinal; +begin + inherited; + LastTime := GetTickCount; + for c:=0 to 5 do + begin + TwinkleArray[c] := 0; + end; +end; + +destructor TEffectManager.Destroy; +begin + Killall; + inherited; +end; + + +procedure TEffectManager.Draw; +var + I: Integer; + CurrentTime: Cardinal; +//const +// DelayBetweenFrames : Cardinal = 100; +begin + + CurrentTime := GetTickCount; + //Manage particle life + if (CurrentTime - LastTime) > DelayBetweenFrames then + begin + LastTime := CurrentTime; + for I := 0 to high(Particle) do + Particle[I].LiveOn; + end; + + I := 0; + //Kill dead particles + while (I <= High(Particle)) do + begin + if (Particle[I].Live <= 0) then + begin + kill(I); + end + else + begin + inc(I); + end; + end; + + //Draw + for I := 0 to high(Particle) do + begin + Particle[I].Draw; + end; +end; + +// this method creates just one particle +function TEffectManager.Spawn(X, Y: Real; Screen: Integer; Live: Byte; StartFrame : Integer; RecArrayIndex : Integer; StarType : TParticleType; Player: Cardinal): Cardinal; +begin + Result := Length(Particle); + SetLength(Particle, (Result + 1)); + Particle[Result] := TParticle.Create(X, Y, Screen, Live, StartFrame, RecArrayIndex, StarType, Player); +end; + +// manage Sparkling of GoldenNote Bars +procedure TEffectManager.SpawnRec(); +Var + Xkatze, Ykatze : Real; + RandomFrame : Integer; + P : Integer; // P as seen on TV as Positionman +begin +//Spawn a random amount of stars within the given coordinates +//RandomRange(0,14) <- this one starts at a random frame, 16 is our last frame - would be senseless to start a particle with 16, cause it would be dead at the next frame +for P:= 0 to high(RecArray) do + begin + while (RecArray[P].TotalStarCount > RecArray[P].CurrentStarCount) do + begin + Xkatze := RandomRange(Ceil(RecArray[P].xTop), Ceil(RecArray[P].xBottom)); + Ykatze := RandomRange(Ceil(RecArray[P].yTop), Ceil(RecArray[P].yBottom)); + RandomFrame := RandomRange(0,14); + // Spawn a GoldenNote Particle + Spawn(Xkatze, Ykatze, RecArray[P].Screen, 16 - RandomFrame, RandomFrame, P, GoldenNote, 0); + inc(RecArray[P].CurrentStarCount); + end; + end; + draw; +end; + +// kill one particle (with given index in our particle array) +procedure TEffectManager.Kill(Index: Cardinal); +var + LastParticleIndex : Integer; +begin +// delete particle indexed by Index, +// overwrite it's place in our particle-array with the particle stored at the last array index, +// shorten array + LastParticleIndex := high(Particle); + if not(LastParticleIndex = -1) then // is there still a particle to delete? + begin + if not(Particle[Index].RecIndex = -1) then // if it is a GoldenNote particle... + dec(RecArray[Particle[Index].RecIndex].CurrentStarCount); // take care of its associated GoldenRec + // now get rid of that particle + Particle[Index].Destroy; + Particle[Index] := Particle[LastParticleIndex]; + SetLength(Particle, LastParticleIndex); + end; +end; + +// clean up all particles and management structures +procedure TEffectManager.KillAll(); +var c: Cardinal; +begin +//It's the kill all kennies rotuine + while Length(Particle) > 0 do // kill all existing particles + Kill(0); + SetLength(RecArray,0); // remove GoldenRec positions + SetLength(PerfNoteArray,0); // remove PerfectNote positions + for c:=0 to 5 do + begin + TwinkleArray[c] := 0; // reset GoldenNoteHit memory + end; +end; + +procedure TEffectManager.SentenceChange(); +var c: Cardinal; +begin + c:=0; + while c <= High(Particle) do + begin + if Particle[c].SurviveSentenceChange then + inc(c) + else + Kill(c); + end; + SetLength(RecArray,0); // remove GoldenRec positions + SetLength(PerfNoteArray,0); // remove PerfectNote positions + for c:=0 to 5 do + begin + TwinkleArray[c] := 0; // reset GoldenNoteHit memory + end; +end; + +procedure TeffectManager.GoldenNoteTwinkle(Top,Bottom,Right: Real; Player: Integer); +//Twinkle stars while golden note hit +// this is called from UDraw.pas, SingDrawPlayerCzesc +var + C, P, XKatze, YKatze, LKatze: Integer; + H: Real; +begin + // make sure we spawn only one time at one position + if (TwinkleArray[Player] < Right) then + For P := 0 to high(RecArray) do // Are we inside a GoldenNoteRectangle? + begin + H := (Top+Bottom)/2; // helper... + with RecArray[P] do + if ((xBottom >= Right) and (xTop <= Right) and + (yTop <= H) and (yBottom >= H)) + and (Screen = ScreenAct) then + begin + TwinkleArray[Player] := Right; // remember twinkle position for this player + for C := 1 to 10 do + begin + Ykatze := RandomRange(ceil(Top) , ceil(Bottom)); + XKatze := RandomRange(-7,3); + LKatze := RandomRange(7,13); + Spawn(Ceil(Right)+XKatze, YKatze, ScreenAct, LKatze, 0, -1, NoteHitTwinkle, 0); + end; + for C := 1 to 3 do + begin + Ykatze := RandomRange(ceil(Top)-6 , ceil(Top)); + XKatze := RandomRange(-5,1); + LKatze := RandomRange(4,7); + Spawn(Ceil(Right)+XKatze, YKatze, ScreenAct, LKatze, 0, -1, NoteHitTwinkle, 0); + end; + for C := 1 to 3 do + begin + Ykatze := RandomRange(ceil(Bottom), ceil(Bottom)+6); + XKatze := RandomRange(-5,1); + LKatze := RandomRange(4,7); + Spawn(Ceil(Right)+XKatze, YKatze, ScreenAct, LKatze, 0, -1, NoteHitTwinkle, 0); + end; + for C := 1 to 3 do + begin + Ykatze := RandomRange(ceil(Top)-10 , ceil(Top)-6); + XKatze := RandomRange(-5,1); + LKatze := RandomRange(1,4); + Spawn(Ceil(Right)+XKatze, YKatze, ScreenAct, LKatze, 0, -1, NoteHitTwinkle, 0); + end; + for C := 1 to 3 do + begin + Ykatze := RandomRange(ceil(Bottom)+6 , ceil(Bottom)+10); + XKatze := RandomRange(-5,1); + LKatze := RandomRange(1,4); + Spawn(Ceil(Right)+XKatze, YKatze, ScreenAct, LKatze, 0, -1, NoteHitTwinkle, 0); + end; + + exit; // found a matching GoldenRec, did spawning stuff... done + end; + end; +end; + +procedure TEffectManager.SaveGoldenStarsRec(Xtop, Ytop, Xbottom, Ybottom: Real); +var + P : Integer; // P like used in Positions + NewIndex : Integer; +begin + For P := 0 to high(RecArray) do // Do we already have that "new" position? + begin + if (ceil(RecArray[P].xTop) = ceil(Xtop)) and + (ceil(RecArray[P].yTop) = ceil(Ytop)) and + (ScreenAct = RecArray[p].Screen) then + exit; // it's already in the array, so we don't have to create a new one + end; + + // we got a new position, add the new positions to our array + NewIndex := Length(RecArray); + SetLength(RecArray, NewIndex + 1); + RecArray[NewIndex].xTop := Xtop; + RecArray[NewIndex].yTop := Ytop; + RecArray[NewIndex].xBottom := Xbottom; + RecArray[NewIndex].yBottom := Ybottom; + RecArray[NewIndex].TotalStarCount := ceil(Xbottom - Xtop) div 12 + 3; + RecArray[NewIndex].CurrentStarCount := 0; + RecArray[NewIndex].Screen := ScreenAct; +end; + +procedure TEffectManager.SavePerfectNotePos(Xtop, Ytop: Real); +var + P : Integer; // P like used in Positions + NewIndex : Integer; + RandomFrame : Integer; + Xkatze, Ykatze : Integer; +begin + For P := 0 to high(PerfNoteArray) do // Do we already have that "new" position? + begin + with PerfNoteArray[P] do + if (ceil(xPos) = ceil(Xtop)) and (ceil(yPos) = ceil(Ytop)) and + (Screen = ScreenAct) then + exit; // it's already in the array, so we don't have to create a new one + end; //for + + // we got a new position, add the new positions to our array + NewIndex := Length(PerfNoteArray); + SetLength(PerfNoteArray, NewIndex + 1); + PerfNoteArray[NewIndex].xPos := Xtop; + PerfNoteArray[NewIndex].yPos := Ytop; + PerfNoteArray[NewIndex].Screen := ScreenAct; + + for P:= 0 to 2 do + begin + Xkatze := RandomRange(ceil(Xtop) - 5 , ceil(Xtop) + 10); + Ykatze := RandomRange(ceil(Ytop) - 5 , ceil(Ytop) + 10); + RandomFrame := RandomRange(0,14); + Spawn(Xkatze, Ykatze, ScreenAct, 16 - RandomFrame, RandomFrame, -1, PerfectNote, 0); + end; //for + +end; + +procedure TEffectManager.SpawnPerfectLineTwinkle(); +var + P,I,Life: Cardinal; + Left, Right, Top, Bottom: Cardinal; + cScreen: Integer; +begin +// calculation of coordinates done with hardcoded values like in UDraw.pas +// might need to be adjusted if drawing of SingScreen is modified +// coordinates may still be a bit weird and need adjustment + if Ini.SingWindow = 0 then begin + Left := 130; + end else begin + Left := 30; + end; + Right := 770; + // spawn effect for every player with a perfect line + for P:=0 to PlayersPlay-1 do + if Player[P].LastSentencePerfect then + begin + // calculate area where notes of this player are drawn + case PlayersPlay of + 1: begin + Bottom:=Skin_P2_NotesB+10; + Top:=Bottom-105; + cScreen:=1; + end; + 2,4: begin + case P of + 0,2: begin + Bottom:=Skin_P1_NotesB+10; + Top:=Bottom-105; + end; + else begin + Bottom:=Skin_P2_NotesB+10; + Top:=Bottom-105; + end; + end; + case P of + 0,1: cScreen:=1; + else cScreen:=2; + end; + end; + 3,6: begin + case P of + 0,3: begin + Top:=130; + Bottom:=Top+85; + end; + 1,4: begin + Top:=255; + Bottom:=Top+85; + end; + 2,5: begin + Top:=380; + Bottom:=Top+85; + end; + end; + case P of + 0,1,2: cScreen:=1; + else cScreen:=2; + end; + end; + end; + // spawn Sparkling Stars inside calculated coordinates + for I:= 0 to 80 do + begin + Life:=RandomRange(8,16); + Spawn(RandomRange(Left,Right), RandomRange(Top,Bottom), cScreen, Life, 16-Life, -1, PerfectLineTwinkle, P); + end; + end; +end; + +end. + diff --git a/Game/Code/Classes/UIni.pas b/Game/Code/Classes/UIni.pas new file mode 100644 index 00000000..82bae011 --- /dev/null +++ b/Game/Code/Classes/UIni.pas @@ -0,0 +1,772 @@ +unit UIni; + +interface +uses IniFiles, ULog, SysUtils; + +type + TIni = class + Name: array[0..11] of string; + + // Templates for Names Mod + NameTeam: array[0..2] of string; + NameTemplate: array[0..11] of string; + + //Filename of the opened iniFile + Filename: string; + + // Game + Players: integer; + Difficulty: integer; + Language: integer; + Tabs: integer; + Tabs_at_startup:integer; //Tabs at Startup fix + Sorting: integer; + Debug: integer; + + // Graphics + Screens: integer; + Resolution: integer; + Depth: integer; + FullScreen: integer; + TextureSize: integer; + SingWindow: integer; + Oscilloscope: integer; + Spectrum: integer; + Spectrograph: integer; + MovieSize: integer; + + // Sound + MicBoost: integer; + ClickAssist: integer; + BeatClick: integer; + SavePlayback: integer; + Threshold: integer; + + //Song Preview + PreviewVolume: integer; + PreviewFading: integer; + + // Lyrics + LyricsFont: integer; + LyricsEffect: integer; + Solmization: integer; + + // Themes + Theme: integer; + SkinNo: integer; + Color: integer; + + // Record + Card: integer; // not saved in config.ini + + CardList: array of record + Name: string; + Input: integer; + ChannelL: integer; + ChannelR: integer; + end; + + // Advanced + LoadAnimation: integer; + EffectSing: integer; + ScreenFade: integer; + AskbeforeDel: integer; + OnSongClick: integer; + LineBonus: integer; + PartyPopup: integer; + + // Controller + Joypad: integer; + + // Soundcards + SoundCard: array[0..7, 1..2] of integer; + + // Devices + LPT: integer; + + procedure Load; + procedure Save; + procedure SaveNames; + procedure SaveLevel; + end; + + +var + Ini: TIni; + IResolution: array of string; + ILanguage: array of string; + ITheme: array of string; + ISkin: array of string; + ICard: array of string; + IInput: array of string; + +const + IPlayers: array[0..4] of string = ('1', '2', '3', '4', '6'); + IDifficulty: array[0..2] of string = ('Easy', 'Medium', 'Hard'); + ITabs: array[0..1] of string = ('Off', 'On'); + + ISorting: array[0..7] of string = ('Edition', 'Genre', 'Language', 'Folder', 'Title', 'Artist', 'Title2', 'Artist2'); + sEdition = 0; + sGenre = 1; + sLanguage = 2; + sFolder = 3; + sTitle = 4; + sArtist = 5; + sTitle2 = 6; + sArtist2 = 7; + + IDebug: array[0..1] of string = ('Off', 'On'); + + IScreens: array[0..1] of string = ('1', '2'); + IFullScreen: array[0..1] of string = ('Off', 'On'); + IDepth: array[0..1] of string = ('16 bit', '32 bit'); + ITextureSize: array[0..2] of string = ('128', '256', '512'); + ISingWindow: array[0..1] of string = ('Small', 'Big'); + + //SingBar Mod + IOscilloscope: array[0..2] of string = ('Off', 'Osci', 'Bar'); + //IOscilloscope: array[0..1] of string = ('Off', 'On'); + + ISpectrum: array[0..1] of string = ('Off', 'On'); + ISpectrograph: array[0..1] of string = ('Off', 'On'); + IMovieSize: array[0..2] of string = ('Half', 'Full [Vid]', 'Full [BG+Vid]'); + + IMicBoost: array[0..3] of string = ('Off', '+6dB', '+12dB', '+18dB'); + IClickAssist: array[0..1] of string = ('Off', 'On'); + IBeatClick: array[0..1] of string = ('Off', 'On'); + ISavePlayback: array[0..1] of string = ('Off', 'On'); + IThreshold: array[0..3] of string = ('5%', '10%', '15%', '20%'); + //Song Preview + IPreviewVolume: array[0..10] of string = ('Off', '10%', '20%', '30%', '40%', '50%', '60%', '70%', '80%', '90%', '100%'); + IPreviewFading: array[0..5] of string = ('Off', '1 Sec', '2 Secs', '3 Secs', '4 Secs', '5 Secs'); + + + ILyricsFont: array[0..2] of string = ('Plain', 'OLine1', 'OLine2'); + ILyricsEffect: array[0..3] of string = ('Simple', 'Zoom', 'Slide', 'Ball'); + ISolmization: array[0..3] of string = ('Off', 'Euro', 'Jap', 'American'); + + IColor: array[0..8] of string = ('Blue', 'Green', 'Pink', 'Red', 'Violet', 'Orange', 'Yellow', 'Brown', 'Black'); + + // Advanced + ILoadAnimation: array[0..1] of string = ('Off', 'On'); + IEffectSing: array[0..1] of string = ('Off', 'On'); + IScreenFade: array [0..1] of String =('Off', 'On'); + IAskbeforeDel: array[0..1] of string = ('Off', 'On'); + IOnSongClick: array[0..2] of string = ('Sing', 'Select Players', 'Open Menu'); + ILineBonus: array[0..2] of string = ('Off', 'At Score', 'At Notes'); + IPartyPopup: array[0..1] of string = ('Off', 'On'); + + IJoypad: array[0..1] of string = ('Off', 'On'); + ILPT: array[0..2] of string = ('Off', 'LCD', 'Lights'); + + IChannel: array[0..6] of string = ('0', '1', '2', '3', '4', '5', '6'); + +implementation +uses UFiles, SDL, ULanguage, USkins, URecord, UCommandLine; + +procedure TIni.Load; +var + IniFile: TMemIniFile; + ThemeIni: TMemIniFile; + Tekst: string; + Pet: integer; + B: boolean; + I, I2, I3: integer; + S: string; + Modes: PPSDL_Rect; + SR: TSearchRec; //Skin List Patch + + function GetFileName (S: String):String; + begin + //Result := copy (S,0,StrRScan (PChar(S),char('.'))+1); + Result := copy (S,0,Pos ('.ini',S)-1); + end; + +begin + GamePath := ExtractFilePath(ParamStr(0)); + + if (Params.ConfigFile <> '') then + try + IniFile := TMemIniFile.Create(Params.ConfigFile); + except + IniFile := TMemIniFile.Create(GamePath + 'config.ini'); + end + else + IniFile := TMemIniFile.Create(GamePath + 'config.ini'); + + + // Name + for I := 0 to 11 do + Ini.Name[I] := IniFile.ReadString('Name', 'P'+IntToStr(I+1), 'Player'+IntToStr(I+1)); + + + // Templates for Names Mod + for I := 0 to 2 do + Ini.NameTeam[I] := IniFile.ReadString('NameTeam', 'T'+IntToStr(I+1), 'Team'+IntToStr(I+1)); + for I := 0 to 11 do + Ini.NameTemplate[I] := IniFile.ReadString('NameTemplate', 'Name'+IntToStr(I+1), 'Template'+IntToStr(I+1)); + + // Players + Tekst := IniFile.ReadString('Game', 'Players', IPlayers[0]); + for Pet := 0 to High(IPlayers) do + if Tekst = IPlayers[Pet] then Ini.Players := Pet; + + // Difficulty + Tekst := IniFile.ReadString('Game', 'Difficulty', 'Easy'); + for Pet := 0 to High(IDifficulty) do + if Tekst = IDifficulty[Pet] then Ini.Difficulty := Pet; + + // Language + Tekst := IniFile.ReadString('Game', 'Language', 'English'); + for Pet := 0 to High(ILanguage) do + if Tekst = ILanguage[Pet] then Ini.Language := Pet; + +// Language.ChangeLanguage(ILanguage[Ini.Language]); + + // Tabs + Tekst := IniFile.ReadString('Game', 'Tabs', ITabs[0]); + for Pet := 0 to High(ITabs) do + if Tekst = ITabs[Pet] then Ini.Tabs := Pet; + + //Tabs at Startup fix + Ini.Tabs_at_startup := Ini.Tabs; + + // Sorting + Tekst := IniFile.ReadString('Game', 'Sorting', ISorting[0]); + for Pet := 0 to High(ISorting) do + if Tekst = ISorting[Pet] then Ini.Sorting := Pet; + + // Debug + Tekst := IniFile.ReadString('Game', 'Debug', IDebug[0]); + for Pet := 0 to High(IDebug) do + if Tekst = IDebug[Pet] then Ini.Debug := Pet; + + //if Ini.Debug = 1 then SongPath := 'E:\UltraStar 03\Songs\'; + + // Screens + Tekst := IniFile.ReadString('Graphics', 'Screens', IScreens[0]); + for Pet := 0 to High(IScreens) do + if Tekst = IScreens[Pet] then Ini.Screens := Pet; + + // Resolution + SetLength(IResolution, 0); + Modes := SDL_ListModes(nil, SDL_OPENGL or SDL_FULLSCREEN); // Check if there are any modes available + repeat + SetLength(IResolution, Length(IResolution) + 1); + IResolution[High(IResolution)] := IntToStr(Modes^.w) + 'x' + IntToStr(Modes^.h); + Inc(Modes); + until Modes^ = nil; + + // if no modes were set, then failback to 800x600 + // as per http://sourceforge.net/forum/message.php?msg_id=4544965 + // THANKS : linnex at users.sourceforge.net + if Length(IResolution) < 1 then + begin + SetLength(IResolution, Length(IResolution) + 1); + IResolution[High(IResolution)] := IntToStr(800) + 'x' + IntToStr(600); + end; + + // reverse order + for I := 0 to (Length(IResolution) div 2) - 1 do begin + S := IResolution[I]; + IResolution[I] := IResolution[High(IResolution)-I]; + IResolution[High(IResolution)-I] := S; + end; + + Tekst := IniFile.ReadString('Graphics', 'Resolution', '800x600'); + for Pet := 0 to High(IResolution) do + if Tekst = IResolution[Pet] then Ini.Resolution := Pet; + + // FullScreen + Tekst := IniFile.ReadString('Graphics', 'FullScreen', 'On'); + for Pet := 0 to High(IFullScreen) do + if Tekst = IFullScreen[Pet] then Ini.FullScreen := Pet; + + // Resolution + Tekst := IniFile.ReadString('Graphics', 'Depth', '32 bit'); + for Pet := 0 to High(IDepth) do + if Tekst = IDepth[Pet] then Ini.Depth := Pet; + + // Texture Size + Tekst := IniFile.ReadString('Graphics', 'TextureSize', ITextureSize[1]); + for Pet := 0 to High(ITextureSize) do + if Tekst = ITextureSize[Pet] then Ini.TextureSize := Pet; + + // SingWindow + Tekst := IniFile.ReadString('Graphics', 'SingWindow', 'Big'); + for Pet := 0 to High(ISingWindow) do + if Tekst = ISingWindow[Pet] then Ini.SingWindow := Pet; + + // Oscilloscope + Tekst := IniFile.ReadString('Graphics', 'Oscilloscope', 'Bar'); + for Pet := 0 to High(IOscilloscope) do + if Tekst = IOscilloscope[Pet] then Ini.Oscilloscope := Pet; + + // Spectrum + Tekst := IniFile.ReadString('Graphics', 'Spectrum', 'Off'); + for Pet := 0 to High(ISpectrum) do + if Tekst = ISpectrum[Pet] then Ini.Spectrum := Pet; + + // Spectrograph + Tekst := IniFile.ReadString('Graphics', 'Spectrograph', 'Off'); + for Pet := 0 to High(ISpectrograph) do + if Tekst = ISpectrograph[Pet] then Ini.Spectrograph := Pet; + + // MovieSize + Tekst := IniFile.ReadString('Graphics', 'MovieSize', IMovieSize[2]); + for Pet := 0 to High(IMovieSize) do + if Tekst = IMovieSize[Pet] then Ini.MovieSize := Pet; + + // MicBoost + Tekst := IniFile.ReadString('Sound', 'MicBoost', 'Off'); + for Pet := 0 to High(IMicBoost) do + if Tekst = IMicBoost[Pet] then Ini.MicBoost := Pet; + + // ClickAssist + Tekst := IniFile.ReadString('Sound', 'ClickAssist', 'Off'); + for Pet := 0 to High(IClickAssist) do + if Tekst = IClickAssist[Pet] then Ini.ClickAssist := Pet; + + // BeatClick + Tekst := IniFile.ReadString('Sound', 'BeatClick', IBeatClick[0]); + for Pet := 0 to High(IBeatClick) do + if Tekst = IBeatClick[Pet] then Ini.BeatClick := Pet; + + // SavePlayback + Tekst := IniFile.ReadString('Sound', 'SavePlayback', ISavePlayback[0]); + for Pet := 0 to High(ISavePlayback) do + if Tekst = ISavePlayback[Pet] then Ini.SavePlayback := Pet; + + // Threshold + Tekst := IniFile.ReadString('Sound', 'Threshold', IThreshold[2]); + for Pet := 0 to High(IThreshold) do + if Tekst = IThreshold[Pet] then Ini.Threshold := Pet; + + //Song Preview + Tekst := IniFile.ReadString('Sound', 'PreviewVolume', IPreviewVolume[7]); + for Pet := 0 to High(IPreviewVolume) do + if Tekst = IPreviewVolume[Pet] then Ini.PreviewVolume := Pet; + + Tekst := IniFile.ReadString('Sound', 'PreviewFading', IPreviewFading[1]); + for Pet := 0 to High(IPreviewFading) do + if Tekst = IPreviewFading[Pet] then Ini.PreviewFading := Pet; + + // Lyrics Font + Tekst := IniFile.ReadString('Lyrics', 'LyricsFont', ILyricsFont[1]); + for Pet := 0 to High(ILyricsFont) do + if Tekst = ILyricsFont[Pet] then Ini.LyricsFont := Pet; + + // Lyrics Effect + Tekst := IniFile.ReadString('Lyrics', 'LyricsEffect', ILyricsEffect[1]); + for Pet := 0 to High(ILyricsEffect) do + if Tekst = ILyricsEffect[Pet] then Ini.LyricsEffect := Pet; + + // Solmization + Tekst := IniFile.ReadString('Lyrics', 'Solmization', ISolmization[0]); + for Pet := 0 to High(ISolmization) do + if Tekst = ISolmization[Pet] then Ini.Solmization := Pet; + + // Theme + + //Theme List Patch + + //I2 Saves the no of the Deluxe (Standard-) Theme + I2 := 0; + //I counts is the cur. Theme no + I := 0; + + SetLength(ITheme, 0); + FindFirst('Themes\*.ini',faAnyFile,SR); + Repeat + //Read Themename from Theme + ThemeIni := TMemIniFile.Create(SR.Name); + Tekst := UpperCase(ThemeIni.ReadString('Theme','Name',GetFileName(SR.Name))); + ThemeIni.Free; + + //if Deluxe Theme then save Themeno to I2 + if (Tekst = 'DELUXE') then + I2 := I; + + //Search for Skins for this Theme + for Pet := low(Skin.Skin) to high(Skin.Skin) do + begin + if UpperCase(Skin.Skin[Pet].Theme) = Tekst then + begin + SetLength(ITheme, Length(ITheme)+1); + ITheme[High(ITheme)] := GetFileName(SR.Name); + break; + end; + end; + + Inc(I); + Until FindNext(SR) <> 0; + FindClose(SR); + //Theme List Patch End } + + //No Theme Found + if (Length(ITheme)=0) then + begin + Log.CriticalError('Could not find any valid Themes.'); + end; + + + Tekst := IniFile.ReadString('Themes', 'Theme', ITheme[I2]); + Ini.Theme := 0; + for Pet := 0 to High(ITheme) do + if Uppercase(Tekst) = Uppercase(ITheme[Pet]) then Ini.Theme := Pet; + + // Skin + Skin.onThemeChange; + Ini.SkinNo := 0; + + Tekst := IniFile.ReadString('Themes', 'Skin', ISkin[0]); + for Pet := 0 to High(ISkin) do + if Tekst = ISkin[Pet] then Ini.SkinNo := Pet; + + // Color + Tekst := IniFile.ReadString('Themes', 'Color', IColor[0]); + for Pet := 0 to High(IColor) do + if Tekst = IColor[Pet] then Ini.Color := Pet; + + // Record - load ini list + SetLength(CardList, 0); + I := 1; + while (IniFile.ValueExists('Record', 'DeviceName' + IntToStr(I)) = true) do begin + //Automatically Delete not Existing Sound Cards + S := IniFile.ReadString('Record', 'DeviceName' + IntToStr(I), ''); + //{ + B := False; + //Look for Soundcard + for I2 := 0 to High(Recording.SoundCard) do + begin + if (S = Trim(Recording.SoundCard[I2].Description)) then + begin + B := True; + Break; + end; + end; + + if B then + begin //} + I3 := Length(CardList); + SetLength(CardList, I3+1); + Ini.CardList[I3].Name := S; + Ini.CardList[I3].Input := IniFile.ReadInteger('Record', 'Input' + IntToStr(I), 0); + Ini.CardList[I3].ChannelL := IniFile.ReadInteger('Record', 'ChannelL' + IntToStr(I), 0); + Ini.CardList[I3].ChannelR := IniFile.ReadInteger('Record', 'ChannelR' + IntToStr(I), 0); + end; + Inc(I); + end; + + // Record - append detected soundcards + for I := 0 to High(Recording.SoundCard) do + begin + B := False; + For I2 := 0 to High(CardList) do + begin //Search for Card in List + if (CardList[I2].Name = Trim(Recording.SoundCard[I].Description)) then + begin + B := True; + Break; + end; + end; + + //If not in List -> Add + If not B then + begin + I3 := Length(CardList); + SetLength(CardList, I3+1); + CardList[I3].Name := Trim(Recording.SoundCard[I].Description); + CardList[I3].Input := 0; + CardList[I3].ChannelL := 0; + CardList[I3].ChannelR := 0; + // default for new users + if (Length(CardList) = 1) then + CardList[I].ChannelL := 1; + end; + end; + + //Advanced Settings + + // LoadAnimation + Tekst := IniFile.ReadString('Advanced', 'LoadAnimation', 'On'); + for Pet := 0 to High(ILoadAnimation) do + if Tekst = ILoadAnimation[Pet] then Ini.LoadAnimation := Pet; + + // ScreenFade + Tekst := IniFile.ReadString('Advanced', 'ScreenFade', 'On'); + for Pet := 0 to High(IScreenFade) do + if Tekst = IScreenFade[Pet] then Ini.ScreenFade := Pet; + + // EffectSing + Tekst := IniFile.ReadString('Advanced', 'EffectSing', 'On'); + for Pet := 0 to High(IEffectSing) do + if Tekst = IEffectSing[Pet] then Ini.EffectSing := Pet; + + // AskbeforeDel + Tekst := IniFile.ReadString('Advanced', 'AskbeforeDel', 'On'); + for Pet := 0 to High(IAskbeforeDel) do + if Tekst = IAskbeforeDel[Pet] then Ini.AskbeforeDel := Pet; + + // OnSongClick + Tekst := IniFile.ReadString('Advanced', 'OnSongClick', 'Sing'); + for Pet := 0 to High(IOnSongClick) do + if Tekst = IOnSongClick[Pet] then Ini.OnSongClick := Pet; + + // Linebonus + Tekst := IniFile.ReadString('Advanced', 'LineBonus', 'At Score'); + for Pet := 0 to High(ILineBonus) do + if Tekst = ILineBonus[Pet] then Ini.LineBonus := Pet; + + // PartyPopup + Tekst := IniFile.ReadString('Advanced', 'PartyPopup', 'On'); + for Pet := 0 to High(IPartyPopup) do + if Tekst = IPartyPopup[Pet] then Ini.PartyPopup := Pet; + + + // Joypad + Tekst := IniFile.ReadString('Controller', 'Joypad', IJoypad[0]); + for Pet := 0 to High(IJoypad) do + if Tekst = IJoypad[Pet] then Ini.Joypad := Pet; + + // LCD + Tekst := IniFile.ReadString('Devices', 'LPT', ILPT[0]); + for Pet := 0 to High(ILPT) do + if Tekst = ILPT[Pet] then Ini.LPT := Pet; + + + // SongPath + if (Params.SongPath <> '') then + SongPath := IncludeTrailingPathDelimiter(Params.SongPath) + else + SongPath := IncludeTrailingPathDelimiter(IniFile.ReadString('Path', 'Songs', SongPath)); + + Filename := IniFile.FileName; + IniFile.Free; +end; + +procedure TIni.Save; +var + IniFile: TIniFile; + Tekst: string; + I: Integer; + S: String; +begin + //if not (FileExists(GamePath + 'config.ini') and FileIsReadOnly(GamePath + 'config.ini')) then begin + if not (FileExists(Filename) and FileIsReadOnly(Filename)) then begin + + IniFile := TIniFile.Create(Filename); + + // Players + Tekst := IPlayers[Ini.Players]; + IniFile.WriteString('Game', 'Players', Tekst); + + // Difficulty + Tekst := IDifficulty[Ini.Difficulty]; + IniFile.WriteString('Game', 'Difficulty', Tekst); + + // Language + Tekst := ILanguage[Ini.Language]; + IniFile.WriteString('Game', 'Language', Tekst); + + // Tabs + Tekst := ITabs[Ini.Tabs]; + IniFile.WriteString('Game', 'Tabs', Tekst); + + // Sorting + Tekst := ISorting[Ini.Sorting]; + IniFile.WriteString('Game', 'Sorting', Tekst); + + // Debug + Tekst := IDebug[Ini.Debug]; + IniFile.WriteString('Game', 'Debug', Tekst); + + // Screens + Tekst := IScreens[Ini.Screens]; + IniFile.WriteString('Graphics', 'Screens', Tekst); + + // FullScreen + Tekst := IFullScreen[Ini.FullScreen]; + IniFile.WriteString('Graphics', 'FullScreen', Tekst); + + // Resolution + Tekst := IResolution[Ini.Resolution]; + IniFile.WriteString('Graphics', 'Resolution', Tekst); + + // Depth + Tekst := IDepth[Ini.Depth]; + IniFile.WriteString('Graphics', 'Depth', Tekst); + + // Resolution + Tekst := ITextureSize[Ini.TextureSize]; + IniFile.WriteString('Graphics', 'TextureSize', Tekst); + + // Sing Window + Tekst := ISingWindow[Ini.SingWindow]; + IniFile.WriteString('Graphics', 'SingWindow', Tekst); + + // Oscilloscope + Tekst := IOscilloscope[Ini.Oscilloscope]; + IniFile.WriteString('Graphics', 'Oscilloscope', Tekst); + + // Spectrum + Tekst := ISpectrum[Ini.Spectrum]; + IniFile.WriteString('Graphics', 'Spectrum', Tekst); + + // Spectrograph + Tekst := ISpectrograph[Ini.Spectrograph]; + IniFile.WriteString('Graphics', 'Spectrograph', Tekst); + + // Movie Size + Tekst := IMovieSize[Ini.MovieSize]; + IniFile.WriteString('Graphics', 'MovieSize', Tekst); + + // MicBoost + Tekst := IMicBoost[Ini.MicBoost]; + IniFile.WriteString('Sound', 'MicBoost', Tekst); + + // ClickAssist + Tekst := IClickAssist[Ini.ClickAssist]; + IniFile.WriteString('Sound', 'ClickAssist', Tekst); + + // BeatClick + Tekst := IBeatClick[Ini.BeatClick]; + IniFile.WriteString('Sound', 'BeatClick', Tekst); + + // Threshold + Tekst := IThreshold[Ini.Threshold]; + IniFile.WriteString('Sound', 'Threshold', Tekst); + + // Song Preview + Tekst := IPreviewVolume[Ini.PreviewVolume]; + IniFile.WriteString('Sound', 'PreviewVolume', Tekst); + + Tekst := IPreviewFading[Ini.PreviewFading]; + IniFile.WriteString('Sound', 'PreviewFading', Tekst); + + // SavePlayback + Tekst := ISavePlayback[Ini.SavePlayback]; + IniFile.WriteString('Sound', 'SavePlayback', Tekst); + + // Lyrics Font + Tekst := ILyricsFont[Ini.LyricsFont]; + IniFile.WriteString('Lyrics', 'LyricsFont', Tekst); + + // Lyrics Effect + Tekst := ILyricsEffect[Ini.LyricsEffect]; + IniFile.WriteString('Lyrics', 'LyricsEffect', Tekst); + + // Solmization + Tekst := ISolmization[Ini.Solmization]; + IniFile.WriteString('Lyrics', 'Solmization', Tekst); + + // Theme + Tekst := ITheme[Ini.Theme]; + IniFile.WriteString('Themes', 'Theme', Tekst); + + // Skin + Tekst := ISkin[Ini.SkinNo]; + IniFile.WriteString('Themes', 'Skin', Tekst); + + // Color + Tekst := IColor[Ini.Color]; + IniFile.WriteString('Themes', 'Color', Tekst); + + // Record + for I := 0 to High(CardList) do begin + S := IntToStr(I+1); + + Tekst := CardList[I].Name; + IniFile.WriteString('Record', 'DeviceName' + S, Tekst); + + Tekst := IntToStr(CardList[I].Input); + IniFile.WriteString('Record', 'Input' + S, Tekst); + + Tekst := IntToStr(CardList[I].ChannelL); + IniFile.WriteString('Record', 'ChannelL' + S, Tekst); + + Tekst := IntToStr(CardList[I].ChannelR); + IniFile.WriteString('Record', 'ChannelR' + S, Tekst); + end; + + //Log.LogError(InttoStr(Length(CardList)) + ' Cards Saved'); + + //Advanced Settings + + //LoadAnimation + Tekst := ILoadAnimation[Ini.LoadAnimation]; + IniFile.WriteString('Advanced', 'LoadAnimation', Tekst); + + //EffectSing + Tekst := IEffectSing[Ini.EffectSing]; + IniFile.WriteString('Advanced', 'EffectSing', Tekst); + + //ScreenFade + Tekst := IScreenFade[Ini.ScreenFade]; + IniFile.WriteString('Advanced', 'ScreenFade', Tekst); + + //AskbeforeDel + Tekst := IAskbeforeDel[Ini.AskbeforeDel]; + IniFile.WriteString('Advanced', 'AskbeforeDel', Tekst); + + //OnSongClick + Tekst := IOnSongClick[Ini.OnSongClick]; + IniFile.WriteString('Advanced', 'OnSongClick', Tekst); + + //Line Bonus + Tekst := ILineBonus[Ini.LineBonus]; + IniFile.WriteString('Advanced', 'LineBonus', Tekst); + + //Party Popup + Tekst := IPartyPopup[Ini.PartyPopup]; + IniFile.WriteString('Advanced', 'PartyPopup', Tekst); + + // Joypad + Tekst := IJoypad[Ini.Joypad]; + IniFile.WriteString('Controller', 'Joypad', Tekst); + + IniFile.Free; + end; +end; + +procedure TIni.SaveNames; +var + IniFile: TIniFile; + I: integer; +begin + //if not FileIsReadOnly(GamePath + 'config.ini') then begin + //IniFile := TIniFile.Create(GamePath + 'config.ini'); + if not FileIsReadOnly(Filename) then begin + IniFile := TIniFile.Create(Filename); + + //Name + // Templates for Names Mod + for I := 1 to 12 do + IniFile.WriteString('Name', 'P' + IntToStr(I), Ini.Name[I-1]); + for I := 1 to 3 do + IniFile.WriteString('NameTeam', 'T' + IntToStr(I), Ini.NameTeam[I-1]); + for I := 1 to 12 do + IniFile.WriteString('NameTemplate', 'Name' + IntToStr(I), Ini.NameTemplate[I-1]); + + IniFile.Free; + end; +end; + +procedure TIni.SaveLevel; +var + IniFile: TIniFile; + I: integer; +begin + //if not FileIsReadOnly(GamePath + 'config.ini') then begin + //IniFile := TIniFile.Create(GamePath + 'config.ini'); + if not FileIsReadOnly(Filename) then begin + IniFile := TIniFile.Create(Filename); + + // Difficulty + IniFile.WriteString('Game', 'Difficulty', IDifficulty[Ini.Difficulty]); + + IniFile.Free; + end; +end; + +end. diff --git a/Game/Code/Classes/UJoystick.pas b/Game/Code/Classes/UJoystick.pas new file mode 100644 index 00000000..b0c7b8cc --- /dev/null +++ b/Game/Code/Classes/UJoystick.pas @@ -0,0 +1,273 @@ +unit UJoystick; + +interface + +uses SDL; + +type + TJoyButton = record + State: integer; + Enabled: boolean; + Type_: byte; + Sym: cardinal; + end; + + TJoyHatState = record + State: Boolean; + LastTick: Cardinal; + Enabled: boolean; + Type_: byte; + Sym: cardinal; + end; + + TJoyUnit = record + Button: array[0..15] of TJoyButton; + HatState: Array[0..3] of TJoyHatState; + end; + + TJoy = class + constructor Create; + procedure Update; + end; + +var + Joy: TJoy; + JoyUnit: TJoyUnit; + SDL_Joy: PSDL_Joystick; + JoyEvent: TSDL_Event; + +implementation + +uses SysUtils, Windows, ULog; + +constructor TJoy.Create; +var + B, N: integer; +begin + //Old Corvus5 Method + {// joystick support + SDL_JoystickEventState(SDL_IGNORE); + SDL_InitSubSystem(SDL_INIT_JOYSTICK); + if SDL_NumJoysticks <> 1 then beep; + + SDL_Joy := SDL_JoystickOpen(0); + if SDL_Joy = nil then beep; + + if SDL_JoystickNumButtons(SDL_Joy) <> 16 then beep; + +// SDL_JoystickEventState(SDL_ENABLE); + // Events don't work - thay hang the whole application with SDL_JoystickEventState(SDL_ENABLE) + + // clear states + for B := 0 to 15 do + JoyUnit.Button[B].State := 1; + + // mapping + JoyUnit.Button[1].Enabled := true; + JoyUnit.Button[1].Type_ := SDL_KEYDOWN; + JoyUnit.Button[1].Sym := SDLK_RETURN; + JoyUnit.Button[2].Enabled := true; + JoyUnit.Button[2].Type_ := SDL_KEYDOWN; + JoyUnit.Button[2].Sym := SDLK_ESCAPE; + + JoyUnit.Button[12].Enabled := true; + JoyUnit.Button[12].Type_ := SDL_KEYDOWN; + JoyUnit.Button[12].Sym := SDLK_LEFT; + JoyUnit.Button[13].Enabled := true; + JoyUnit.Button[13].Type_ := SDL_KEYDOWN; + JoyUnit.Button[13].Sym := SDLK_DOWN; + JoyUnit.Button[14].Enabled := true; + JoyUnit.Button[14].Type_ := SDL_KEYDOWN; + JoyUnit.Button[14].Sym := SDLK_RIGHT; + JoyUnit.Button[15].Enabled := true; + JoyUnit.Button[15].Type_ := SDL_KEYDOWN; + JoyUnit.Button[15].Sym := SDLK_UP; + } + //New Sarutas method + SDL_JoystickEventState(SDL_IGNORE); + SDL_InitSubSystem(SDL_INIT_JOYSTICK); + if SDL_NumJoysticks < 1 then + begin + Log.LogError('No Joystick found'); + exit; + end; + + + SDL_Joy := SDL_JoystickOpen(0); + if SDL_Joy = nil then + begin + Log.LogError('Could not Init Joystick'); + exit; + end; + N := SDL_JoystickNumButtons(SDL_Joy); + //if N < 6 then beep; + + for B := 0 to 5 do begin + JoyUnit.Button[B].Enabled := true; + JoyUnit.Button[B].State := 1; + JoyUnit.Button[B].Type_ := SDL_KEYDOWN; + end; + + JoyUnit.Button[0].Sym := SDLK_Return; + JoyUnit.Button[1].Sym := SDLK_Escape; + JoyUnit.Button[2].Sym := SDLK_M; + JoyUnit.Button[3].Sym := SDLK_R; + + JoyUnit.Button[4].Sym := SDLK_RETURN; + JoyUnit.Button[5].Sym := SDLK_ESCAPE; + + //Set HatState + for B := 0 to 3 do begin + JoyUnit.HatState[B].Enabled := true; + JoyUnit.HatState[B].State := False; + JoyUnit.HatState[B].Type_ := SDL_KEYDOWN; + end; + + JoyUnit.HatState[0].Sym := SDLK_UP; + JoyUnit.HatState[1].Sym := SDLK_RIGHT; + JoyUnit.HatState[2].Sym := SDLK_DOWN; + JoyUnit.HatState[3].Sym := SDLK_LEFT; +end; + +procedure TJoy.Update; +var + B: integer; + State: UInt8; + Tick: Cardinal; + Axes: Smallint; +begin + SDL_JoystickUpdate; + + //Manage Buttons + for B := 0 to 15 do begin + if (JoyUnit.Button[B].Enabled) and (JoyUnit.Button[B].State <> SDL_JoystickGetButton(SDL_Joy, B)) and (JoyUnit.Button[B].State = 0) then begin + JoyEvent.type_ := JoyUnit.Button[B].Type_; + JoyEvent.key.keysym.sym := JoyUnit.Button[B].Sym; + SDL_PushEvent(@JoyEvent); + end; + end; + + + for B := 0 to 15 do begin + JoyUnit.Button[B].State := SDL_JoystickGetButton(SDL_Joy, B); + end; + + //Get Tick + Tick := Gettickcount; + + //Get CoolieHat + if (SDL_JoystickNumHats(SDL_Joy)>=1) then + State := SDL_JoystickGetHat(SDL_Joy, 0) + else + State := 0; + + //Get Axis + if (SDL_JoystickNumAxes(SDL_Joy)>=2) then + begin + //Down - Up (X- Axis) + Axes := SDL_JoystickGetAxis(SDL_Joy, 1); + If Axes >= 15000 then + State := State or SDL_HAT_Down + Else If Axes <= -15000 then + State := State or SDL_HAT_UP; + + //Left - Right (Y- Axis) + Axes := SDL_JoystickGetAxis(SDL_Joy, 0); + If Axes >= 15000 then + State := State or SDL_HAT_Right + Else If Axes <= -15000 then + State := State or SDL_HAT_Left; + end; + + //Manage Hat and joystick Events + if (SDL_JoystickNumHats(SDL_Joy)>=1) OR (SDL_JoystickNumAxes(SDL_Joy)>=2) then + begin + + //Up Button + If (JoyUnit.HatState[0].Enabled) and ((SDL_HAT_UP AND State) = SDL_HAT_UP) then + begin //IF Button is newly Pressed or if he is Pressed longer than 500 msecs + if (JoyUnit.HatState[0].State = False) OR (JoyUnit.HatState[0].Lasttick < Tick) then + begin + //Set Tick and State + if JoyUnit.HatState[0].State then + JoyUnit.HatState[0].Lasttick := Tick + 200 + else + JoyUnit.HatState[0].Lasttick := Tick + 500; + + JoyUnit.HatState[0].State := True; + + JoyEvent.type_ := JoyUnit.HatState[0].Type_; + JoyEvent.key.keysym.sym := JoyUnit.HatState[0].Sym; + SDL_PushEvent(@JoyEvent); + end; + end + else + JoyUnit.HatState[0].State := False; + + //Right Button + If (JoyUnit.HatState[1].Enabled) and ((SDL_HAT_RIGHT AND State) = SDL_HAT_RIGHT) then + begin //IF Button is newly Pressed or if he is Pressed longer than 500 msecs + if (JoyUnit.HatState[1].State = False) OR (JoyUnit.HatState[1].Lasttick < Tick) then + begin + //Set Tick and State + if JoyUnit.HatState[1].State then + JoyUnit.HatState[1].Lasttick := Tick + 200 + else + JoyUnit.HatState[1].Lasttick := Tick + 500; + + JoyUnit.HatState[1].State := True; + + JoyEvent.type_ := JoyUnit.HatState[1].Type_; + JoyEvent.key.keysym.sym := JoyUnit.HatState[1].Sym; + SDL_PushEvent(@JoyEvent); + end; + end + else + JoyUnit.HatState[1].State := False; + + //Down button + If (JoyUnit.HatState[2].Enabled) and ((SDL_HAT_DOWN AND State) = SDL_HAT_DOWN) then + begin //IF Button is newly Pressed or if he is Pressed longer than 230 msecs + if (JoyUnit.HatState[2].State = False) OR (JoyUnit.HatState[2].Lasttick < Tick) then + begin + //Set Tick and State + if JoyUnit.HatState[2].State then + JoyUnit.HatState[2].Lasttick := Tick + 200 + else + JoyUnit.HatState[2].Lasttick := Tick + 500; + + JoyUnit.HatState[2].State := True; + + JoyEvent.type_ := JoyUnit.HatState[2].Type_; + JoyEvent.key.keysym.sym := JoyUnit.HatState[2].Sym; + SDL_PushEvent(@JoyEvent); + end; + end + else + JoyUnit.HatState[2].State := False; + + //Left Button + If (JoyUnit.HatState[3].Enabled) and ((SDL_HAT_LEFT AND State) = SDL_HAT_LEFT) then + begin //IF Button is newly Pressed or if he is Pressed longer than 230 msecs + if (JoyUnit.HatState[3].State = False) OR (JoyUnit.HatState[3].Lasttick < Tick) then + begin + //Set Tick and State + if JoyUnit.HatState[3].State then + JoyUnit.HatState[3].Lasttick := Tick + 200 + else + JoyUnit.HatState[3].Lasttick := Tick + 500; + + JoyUnit.HatState[3].State := True; + + JoyEvent.type_ := JoyUnit.HatState[3].Type_; + JoyEvent.key.keysym.sym := JoyUnit.HatState[3].Sym; + SDL_PushEvent(@JoyEvent); + end; + end + else + JoyUnit.HatState[3].State := False; + end; + +end; + +end. diff --git a/Game/Code/Classes/ULCD.pas b/Game/Code/Classes/ULCD.pas new file mode 100644 index 00000000..abdf3584 --- /dev/null +++ b/Game/Code/Classes/ULCD.pas @@ -0,0 +1,289 @@ +unit ULCD; + +interface + +type + TLCD = class + private + Enabled: boolean; + Text: array[1..6] of string; + StartPos: integer; + LineBR: integer; + Position: integer; + procedure WriteCommand(B: byte); + procedure WriteData(B: byte); + procedure WriteString(S: string); + public + HalfInterface: boolean; + constructor Create; + procedure Enable; + procedure Clear; + procedure WriteText(Line: integer; S: string); + procedure MoveCursor(Line, Pos: integer); + procedure ShowCursor; + procedure HideCursor; + + // for 2x16 + procedure AddTextBR(S: string); + procedure MoveCursorBR(Pos: integer); + procedure ScrollUpBR; + procedure AddTextArray(Line:integer; S: string); + end; + +var + LCD: TLCD; + +const + Data = $378; // domyœlny adres portu + Status = Data + 1; + Control = Data + 2; + +implementation + +uses + SysUtils, + zlportio, + UTime; + +procedure TLCD.WriteCommand(B: Byte); +// Wysylanie komend sterujacych +begin + if not HalfInterface then begin + zlioportwrite(Control, 0, $02); + zlioportwrite(Data, 0, B); + zlioportwrite(Control, 0, $03); + end else begin + zlioportwrite(Control, 0, $02); + zlioportwrite(Data, 0, B and $F0); + zlioportwrite(Control, 0, $03); + + TimeSleep(0.1); + + zlioportwrite(Control, 0, $02); + zlioportwrite(Data, 0, (B * 16) and $F0); + zlioportwrite(Control, 0, $03); + end; + + if (B=1) or (B=2) then + Sleep(2) + else + TimeSleep(0.1); +end; + +procedure TLCD.WriteData(B: Byte); +// Wysylanie danych +begin + if not HalfInterface then begin + zlioportwrite(Control, 0, $06); + zlioportwrite(Data, 0, B); + zlioportwrite(Control, 0, $07); + end else begin + zlioportwrite(Control, 0, $06); + zlioportwrite(Data, 0, B and $F0); + zlioportwrite(Control, 0, $07); + + TimeSleep(0.1); + + zlioportwrite(Control, 0, $06); + zlioportwrite(Data, 0, (B * 16) and $F0); + zlioportwrite(Control, 0, $07); + end; + + TimeSleep(0.1); + Inc(Position); +end; + +procedure TLCD.WriteString(S: string); +// Wysylanie slow +var + I: integer; +begin + for I := 1 to Length(S) do + WriteData(Ord(S[I])); +end; + +constructor TLCD.Create; +begin +// +end; + +procedure TLCD.Enable; +var + A: byte; + B: byte; +begin + Enabled := true; + if not HalfInterface then + WriteCommand($38) + else begin + WriteCommand($33); + WriteCommand($32); + WriteCommand($28); + end; + +// WriteCommand($06); +// WriteCommand($0C); +// sleep(10); +end; + +procedure TLCD.Clear; +begin + if Enabled then begin + WriteCommand(1); + WriteCommand(2); + Text[1] := ''; + Text[2] := ''; + Text[3] := ''; + Text[4] := ''; + Text[5] := ''; + Text[6] := ''; + StartPos := 1; + LineBR := 1; + end; +end; + +procedure TLCD.WriteText(Line: integer; S: string); +begin + if Enabled then begin + if Line <= 2 then begin + MoveCursor(Line, 1); + WriteString(S); + end; + + Text[Line] := ''; + AddTextArray(Line, S); + end; +end; + +procedure TLCD.MoveCursor(Line, Pos: integer); +var + I: integer; +begin + if Enabled then begin + Pos := Pos + (Line-1) * 40; + + if Position > Pos then begin + WriteCommand(2); + for I := 1 to Pos-1 do + WriteCommand(20); + end; + + if Position < Pos then + for I := 1 to Pos - Position do + WriteCommand(20); + + Position := Pos; + end; +end; + +procedure TLCD.ShowCursor; +begin + if Enabled then begin + WriteCommand(14); + end; +end; + +procedure TLCD.HideCursor; +begin + if Enabled then begin + WriteCommand(12); + end; +end; + +procedure TLCD.AddTextBR(S: string); +var + Word: string; + W: integer; + P: integer; + L: integer; +begin + if Enabled then begin + if LineBR <= 6 then begin + L := LineBR; + P := Pos(' ', S); + + if L <= 2 then + MoveCursor(L, 1); + + while (L <= 6) and (P > 0) do begin + Word := Copy(S, 1, P); + if (Length(Text[L]) + Length(Word)-1) > 16 then begin + L := L + 1; + if L <= 2 then + MoveCursor(L, 1); + end; + + if L <= 6 then begin + if L <= 2 then + WriteString(Word); + AddTextArray(L, Word); + end; + + Delete(S, 1, P); + P := Pos(' ', S) + end; + + LineBR := L + 1; + end; + end; +end; + +procedure TLCD.MoveCursorBR(Pos: integer); +var + I: integer; + L: integer; +begin + if Enabled then begin + Pos := Pos - (StartPos-1); + if Pos <= Length(Text[1]) then + MoveCursor(1, Pos); + + if Pos > Length(Text[1]) then begin + // bez zawijania +// Pos := Pos - Length(Text[1]); +// MoveCursor(2, Pos); + + // z zawijaniem + Pos := Pos - Length(Text[1]); + ScrollUpBR; + MoveCursor(1, Pos); + end; + end; +end; + +procedure TLCD.ScrollUpBR; +var + T: array[1..5] of string; + SP: integer; + LBR: integer; +begin + if Enabled then begin + T[1] := Text[2]; + T[2] := Text[3]; + T[3] := Text[4]; + T[4] := Text[5]; + T[5] := Text[6]; + SP := StartPos + Length(Text[1]); + LBR := LineBR; + + Clear; + + StartPos := SP; + WriteText(1, T[1]); + WriteText(2, T[2]); + WriteText(3, T[3]); + WriteText(4, T[4]); + WriteText(5, T[5]); + LineBR := LBR-1; + end; +end; + +procedure TLCD.AddTextArray(Line: integer; S: string); +begin + if Enabled then begin + Text[Line] := Text[Line] + S; + end; +end; + +end. + diff --git a/Game/Code/Classes/ULanguage.pas b/Game/Code/Classes/ULanguage.pas new file mode 100644 index 00000000..4649c089 --- /dev/null +++ b/Game/Code/Classes/ULanguage.pas @@ -0,0 +1,222 @@ +unit ULanguage; + +interface + +type + TLanguageEntry = record + ID: string; + Text: string; + end; + + TLanguageList = record + Name: string; + {FileName: string; } + end; + + TLanguage = class + public + Entry: array of TLanguageEntry; //Entrys of Chosen Language + SEntry: array of TLanguageEntry; //Entrys of Standard Language + CEntry: array of TLanguageEntry; //Constant Entrys e.g. Version + Implode_Glue1, Implode_Glue2: String; + public + List: array of TLanguageList; + + constructor Create; + procedure LoadList; + function Translate(Text: String): String; + procedure ChangeLanguage(Language: String); + procedure AddConst(ID, Text: String); + procedure ChangeConst(ID, Text: String); + function Implode(Pieces: Array of String): String; + end; + +var + Language: TLanguage; + +implementation + +uses UFiles, UIni, IniFiles, Classes, SysUtils, Windows, ULog; + +//---------- +//Create - Construct Class then LoadList + Standard Language + Set Standard Implode Glues +//---------- +constructor TLanguage.Create; +var + I, J: Integer; +begin + LoadList; + + //Set Implode Glues for Backward Compatibility + Implode_Glue1 := ', '; + Implode_Glue2 := ' and '; + + if (Length(List) = 0) then //No Language Files Loaded -> Abort Loading + Log.CriticalError('Could not load any Language File'); + + //Standard Language (If a Language File is Incomplete) + //Then use English Language + for I := 0 to high(List) do //Search for English Language + begin + //English Language Found -> Load + if Uppercase(List[I].Name) = 'ENGLISH' then + begin + ChangeLanguage('English'); + + SetLength(SEntry, Length(Entry)); + for J := low(Entry) to high(Entry) do + SEntry[J] := Entry[J]; + + SetLength(Entry, 0); + + Break; + end; + + if (I = high(List)) then + Log.LogError('English Languagefile missing! No standard Translation loaded'); + end; + //Standard Language END + +end; + +//---------- +//LoadList - Parse the Language Dir searching Translations +//---------- +procedure TLanguage.LoadList; +var + SR: TSearchRec; // for parsing directory +begin + SetLength(List, 0); + SetLength(ILanguage, 0); + + if FindFirst(LanguagesPath + '*.ini', 0, SR) = 0 then begin + repeat + SetLength(List, Length(List)+1); + SetLength(ILanguage, Length(ILanguage)+1); + SR.Name := ChangeFileExt(SR.Name, ''); + + List[High(List)].Name := SR.Name; + ILanguage[High(ILanguage)] := SR.Name; + + until FindNext(SR) <> 0; + SysUtils.FindClose(SR); + end; // if FindFirst +end; + +//---------- +//ChangeLanguage - Load the specified LanguageFile +//---------- +procedure TLanguage.ChangeLanguage(Language: String); +var + IniFile: TIniFile; + E: integer; // entry + S: TStringList; +begin + SetLength(Entry, 0); + IniFile := TIniFile.Create(LanguagesPath + Language + '.ini'); + S := TStringList.Create; + + IniFile.ReadSectionValues('Text', S); + SetLength(Entry, S.Count); + for E := 0 to high(Entry) do + begin + if S.Names[E] = 'IMPLODE_GLUE1' then + Implode_Glue1 := S.ValueFromIndex[E]+ ' ' + else if S.Names[E] = 'IMPLODE_GLUE2' then + Implode_Glue2 := ' ' + S.ValueFromIndex[E] + ' '; + + Entry[E].ID := S.Names[E]; + Entry[E].Text := S.ValueFromIndex[E]; + end; + + S.Free; + IniFile.Free; +end; + +//---------- +//Translate - Translate the Text +//---------- +Function TLanguage.Translate(Text: String): String; +var + E: integer; // entry +begin + Result := Text; + Text := Uppercase(Result); + + //Const Mod + for E := 0 to high(CEntry) do + if Text = CEntry[E].ID then + begin + Result := CEntry[E].Text; + exit; + end; + //Const Mod End + + for E := 0 to high(Entry) do + if Text = Entry[E].ID then + begin + Result := Entry[E].Text; + exit; + end; + + //Standard Language (If a Language File is Incomplete) + //Then use Standard Language + for E := low(SEntry) to high(SEntry) do + if Text = SEntry[E].ID then + begin + Result := SEntry[E].Text; + Break; + end; + //Standard Language END +end; + +//---------- +//AddConst - Add a Constant ID that will be Translated but not Loaded from the LanguageFile +//---------- +procedure TLanguage.AddConst (ID, Text: String); +begin + SetLength (CEntry, Length(CEntry) + 1); + CEntry[high(CEntry)].ID := ID; + CEntry[high(CEntry)].Text := Text; +end; + +//---------- +//ChangeConst - Change a Constant Value by ID +//---------- +procedure TLanguage.ChangeConst(ID, Text: String); +var + I: Integer; +begin + for I := 0 to high(CEntry) do + begin + if CEntry[I].ID = ID then + begin + CEntry[I].Text := Text; + Break; + end; + end; +end; + +//---------- +//Implode - Connect an Array of Strings with ' and ' or ', ' to one String +//---------- +function TLanguage.Implode(Pieces: Array of String): String; +var + I: Integer; +begin + Result := ''; + //Go through Pieces + for I := low(Pieces) to high(Pieces) do + begin + //Add Value + Result := Result + Pieces[I]; + + //Add Glue + if (I < high(Pieces) - 1) then + Result := Result + Implode_Glue1 + else if (I < high(Pieces)) then + Result := Result + Implode_Glue2; + end; +end; + +end. diff --git a/Game/Code/Classes/ULight.pas b/Game/Code/Classes/ULight.pas new file mode 100644 index 00000000..967d2ea1 --- /dev/null +++ b/Game/Code/Classes/ULight.pas @@ -0,0 +1,116 @@ +unit ULight; +interface + +type + TLight = class + private + Enabled: boolean; + Light: array[0..7] of boolean; + LightTime: array[0..7] of real; // time to stop, need to call update to change state + LastTime: real; + public + constructor Create; + procedure Enable; + procedure SetState(State: integer); + procedure AutoSetState; + procedure TurnOn; + procedure TurnOff; + procedure LightOne(Number: integer; Time: real); + procedure Refresh; + end; + +var + Light: TLight; + +const + Data = $378; // default port address + Status = Data + 1; + Control = Data + 2; + +implementation + +uses + SysUtils, zlportio, UTime; + +constructor TLight.Create; +begin + Enabled := false; +end; + +procedure TLight.Enable; +begin + Enabled := true; + LastTime := GetTime; +end; + +procedure TLight.SetState(State: integer); +begin + if Enabled then + PortWriteB($378, State); +end; + +procedure TLight.AutoSetState; +var + State: integer; +begin + if Enabled then begin + State := 0; + if Light[0] then State := State + 2; + if Light[1] then State := State + 1; + // etc + SetState(State); + end; +end; + +procedure TLight.TurnOn; +begin + if Enabled then + SetState(3); +end; + +procedure TLight.TurnOff; +begin + if Enabled then + SetState(0); +end; + +procedure TLight.LightOne(Number: integer; Time: real); +begin + if Enabled then begin + if Light[Number] = false then begin + Light[Number] := true; + AutoSetState; + end; + + LightTime[Number] := GetTime + Time/1000; // [s] + end; +end; + +procedure TLight.Refresh; +var + Time: real; + TimeSkip: real; + L: integer; +begin + if Enabled then begin + Time := GetTime; + TimeSkip := Time - LastTime; + for L := 0 to 7 do begin + if Light[L] = true then begin + if LightTime[L] > Time then begin + // jest jeszcze zapas - bez zmian + //LightTime[L] := LightTime[L] - TimeSkip; + end else begin + // czas minal + Light[L] := false; + end; + end; + end; + LastTime := Time; + AutoSetState; + end; +end; + +end. + + diff --git a/Game/Code/Classes/ULog.pas b/Game/Code/Classes/ULog.pas new file mode 100644 index 00000000..9d20d2f1 --- /dev/null +++ b/Game/Code/Classes/ULog.pas @@ -0,0 +1,227 @@ +unit ULog; + +interface + +uses Classes; + +type + TLog = class + BenchmarkTimeStart: array[0..7] of real; + BenchmarkTimeLength: array[0..7] of real;//TDateTime; + + FileBenchmark: TextFile; + FileBenchmarkO: boolean; // opened + FileError: TextFile; + FileErrorO: boolean; // opened + + Title: String; //Application Title + + //Should Log Files be written + Enabled: Boolean; + + // destuctor + destructor Free; + + // benchmark + procedure BenchmarkStart(Number: integer); + procedure BenchmarkEnd(Number: integer); + procedure LogBenchmark(Text: string; Number: integer); + + // error + procedure LogError(Text: string); overload; + + //Critical Error (Halt + MessageBox) + procedure CriticalError(Text: string); + + // voice + procedure LogVoice(SoundNr: integer); + + // compability + procedure LogStatus(Log1, Log2: string); + procedure LogError(Log1, Log2: string); overload; + end; + +var + Log: TLog; + +implementation +uses UFiles, SysUtils, DateUtils, URecord, UTime, UIni, Windows, UCommandLine; + +destructor TLog.Free; +begin + if FileBenchmarkO then CloseFile(FileBenchmark); +// if FileAnalyzeO then CloseFile(FileAnalyze); + if FileErrorO then CloseFile(FileError); +end; + +procedure TLog.BenchmarkStart(Number: integer); +begin + BenchmarkTimeStart[Number] := USTime.GetTime; //Time; +end; + +procedure TLog.BenchmarkEnd(Number: integer); +begin + BenchmarkTimeLength[Number] := USTime.GetTime {Time} - BenchmarkTimeStart[Number]; +end; + +procedure TLog.LogBenchmark(Text: string; Number: integer); +var + Minutes: integer; + Seconds: integer; + Miliseconds: integer; + + MinutesS: string; + SecondsS: string; + MilisecondsS: string; + + ValueText: string; +begin + if Enabled AND (Params.Benchmark) then begin + if not FileBenchmarkO then begin + FileBenchmarkO := true; + AssignFile(FileBenchmark, LogPath + 'Benchmark.log'); + {$I-} + Rewrite(FileBenchmark); + if IOResult = 0 then FileBenchmarkO := true; + {$I+} + + //If File is opened write Date to Benchmark File + If (FileBenchmarkO) then + begin + WriteLn(FileBenchmark, Title + ' Benchmark File'); + WriteLn(FileBenchmark, 'Date: ' + DatetoStr(Now) + ' Time: ' + TimetoStr(Now)); + WriteLn(FileBenchmark, '-------------------'); + + Flush(FileBenchmark); + end; + end; + + if FileBenchmarkO then begin + Miliseconds := Trunc(Frac(BenchmarkTimeLength[Number]) * 1000); + Seconds := Trunc(BenchmarkTimeLength[Number]) mod 60; + Minutes := Trunc((BenchmarkTimeLength[Number] - Seconds) / 60); +// ValueText := FloatToStr(BenchmarkTimeLength[Number]); + +{ ValueText := FloatToStr( + SecondOf(BenchmarkTimeLength[Number]) + MilliSecondOf(BenchmarkTimeLength[Number])/1000 + ); + if MinuteOf(BenchmarkTimeLength[Number]) >= 1 then + ValueText := IntToStr(MinuteOf(BenchmarkTimeLength[Number])) + ':' + ValueText; + WriteLn(FileBenchmark, Text + ': ' + ValueText + ' seconds');} + + if (Minutes = 0) and (Seconds = 0) then begin + MilisecondsS := IntToStr(Miliseconds); + ValueText := MilisecondsS + ' miliseconds'; + end; + + if (Minutes = 0) and (Seconds >= 1) then begin + MilisecondsS := IntToStr(Miliseconds); + while Length(MilisecondsS) < 3 do MilisecondsS := '0' + MilisecondsS; + + SecondsS := IntToStr(Seconds); + + ValueText := SecondsS + ',' + MilisecondsS + ' seconds'; + end; + + if Minutes >= 1 then begin + MilisecondsS := IntToStr(Miliseconds); + while Length(MilisecondsS) < 3 do MilisecondsS := '0' + MilisecondsS; + + SecondsS := IntToStr(Seconds); + while Length(SecondsS) < 2 do SecondsS := '0' + SecondsS; + + MinutesS := IntToStr(Minutes); + + ValueText := MinutesS + ':' + SecondsS + ',' + MilisecondsS + ' minutes'; + end; + + WriteLn(FileBenchmark, Text + ': ' + ValueText); + Flush(FileBenchmark); + end; + end; +end; + +procedure TLog.LogError(Text: string); +begin + if Enabled AND (not FileErrorO) then begin + FileErrorO := true; + AssignFile(FileError, LogPath + 'Error.log'); + {$I-} + Rewrite(FileError); + if IOResult = 0 then FileErrorO := true; + {$I+} + + //If File is opened write Date to Error File + If (FileErrorO) then + begin + WriteLn(FileError, Title + ' Error Log'); + WriteLn(FileError, 'Date: ' + DatetoStr(Now) + ' Time: ' + TimetoStr(Now)); + WriteLn(FileError, '-------------------'); + + Flush(FileError); + end; + end; + + if FileErrorO then begin + try + WriteLn(FileError, Text); + Flush(FileError); + except + FileErrorO := false; + end; + end; +end; + +procedure TLog.LogVoice(SoundNr: integer); +var + FileVoice: File; + FS: TFileStream; + FileName: string; + Num: integer; + BL: integer; +begin + for Num := 1 to 9999 do begin + FileName := IntToStr(Num); + while Length(FileName) < 4 do FileName := '0' + FileName; + FileName := LogPath + 'Voice' + FileName + '.raw'; + if not FileExists(FileName) then break + end; + + + FS := TFileStream.Create(FileName, fmCreate); + + for BL := 0 to High(Sound[SoundNr].BufferLong) do begin + Sound[SoundNr].BufferLong[BL].Seek(0, soBeginning); + FS.CopyFrom(Sound[SoundNr].BufferLong[BL], Sound[SoundNr].BufferLong[BL].Size); + end; + + FS.Free; +end; + +procedure TLog.LogStatus(Log1, Log2: string); +begin + //Just for Debugging + //Comment for Release + //LogAnalyze (Log2 + ': ' + Log1); +end; + +procedure TLog.LogError(Log1, Log2: string); +begin +//asd +end; + +procedure TLog.CriticalError(Text: string); +begin + //Write Error to Logfile: + LogError (Text); + + //Show Errormessage + Messagebox(0, PChar(Text), PChar(Title), MB_ICONERROR or MB_OK); + + //Exit Application + Halt; +end; + +end. + + diff --git a/Game/Code/Classes/ULyrics.pas b/Game/Code/Classes/ULyrics.pas new file mode 100644 index 00000000..105f36d1 --- /dev/null +++ b/Game/Code/Classes/ULyrics.pas @@ -0,0 +1,389 @@ +unit ULyrics; + +interface +uses SysUtils, OpenGL12, UMusic; + +type + TWord = record + X: real; + Y: real; + Size: real; + Width: real; + Text: string; + ColR: real; + ColG: real; + ColB: real; + Scale: real; + Done: real; + FontStyle: integer; + Italic: boolean; + Selected: boolean; + end; + + TLyric = class + private + AlignI: integer; + XR: real; + YR: real; + SizeR: real; + SelectedI: integer; + ScaleR: real; + StyleI: integer; // 0 - one selection, 1 - long selection, 2 - one selection with fade to normal text, 3 - long selection with fade with color from left + FontStyleI: integer; // font number + Word: array of TWord; + procedure SetX(Value: real); + procedure SetY(Value: real); + function GetClientX: real; + procedure SetAlign(Value: integer); + function GetSize: real; + procedure SetSize(Value: real); + procedure SetSelected(Value: integer); + procedure SetDone(Value: real); + procedure SetScale(Value: real); + procedure SetStyle(Value: integer); + procedure SetFStyle(Value: integer); + procedure Refresh; + procedure DrawNormal(W: integer); + procedure DrawPlain(W: integer); + procedure DrawScaled(W: integer); + procedure DrawSlide(W: integer); + public + ColR: real; + ColG: real; + ColB: real; + ColSR: real; + ColSG: real; + ColSB: real; + Italic: boolean; + Text: string; // LCD + + published + property X: real write SetX; + property Y: real write SetY; + property ClientX: real read GetClientX; + property Align: integer write SetAlign; + property Size: real read GetSize write SetSize; + property Selected: integer read SelectedI write SetSelected; + property Done: real write SetDone; + property Scale: real write SetScale; + property Style: integer write SetStyle; + property FontStyle: integer write SetFStyle; + procedure AddWord(Text: string); + procedure AddCzesc(NrCzesci: integer); + procedure ChangeCurText(Text: String); + + function SelectedLetter: integer; // LCD + function SelectedLength: integer; // LCD + + procedure Clear; + procedure Draw; + + end; + +var + Lyric: TLyric; + +implementation +uses TextGL, UGraphic, UDrawTexture; + +procedure TLyric.SetX(Value: real); +begin + XR := Value; +end; + +procedure TLyric.SetY(Value: real); +begin + YR := Value; +end; + +function TLyric.GetClientX: real; +begin + Result := Word[0].X; +end; + +procedure TLyric.SetAlign(Value: integer); +begin + AlignI := Value; +// if AlignInt = 0 then beep; +end; + +function TLyric.GetSize: real; +begin + Result := SizeR; +end; + +procedure TLyric.SetSize(Value: real); +begin + SizeR := Value; +end; + +procedure TLyric.SetSelected(Value: integer); +var + W: integer; +begin + if (StyleI = 0) or (StyleI = 2) or (StyleI = 4) then begin + if (SelectedI > -1) and (SelectedI <= High(Word)) then begin + Word[SelectedI].Selected := false; + Word[SelectedI].ColR := ColR; + Word[SelectedI].ColG := ColG; + Word[SelectedI].ColB := ColB; + Word[SelectedI].Done := 0; + end; + + SelectedI := Value; + if (Value > -1) and (Value <= High(Word)) then begin + Word[Value].Selected := true; + Word[Value].ColR := ColSR; + Word[Value].ColG := ColSG; + Word[Value].ColB := ColSB; + Word[Value].Scale := ScaleR; + end; + end; + + if (StyleI = 1) or (StyleI = 3) then begin + if (SelectedI > -1) and (SelectedI <= High(Word)) then begin + for W := SelectedI to High(Word) do begin + Word[W].Selected := false; + Word[W].ColR := ColR; + Word[W].ColG := ColG; + Word[W].ColB := ColB; + Word[W].Done := 0; + end; + end; + + SelectedI := Value; + if (Value > -1) and (Value <= High(Word)) then begin + for W := 0 to Value do begin + Word[W].Selected := true; + Word[W].ColR := ColSR; + Word[W].ColG := ColSG; + Word[W].ColB := ColSB; + Word[W].Scale := ScaleR; + Word[W].Done := 1; + end; + end; + end; + + Refresh; +end; + +procedure TLyric.SetDone(Value: real); +var + W: integer; +begin + W := SelectedI; + if W > -1 then + Word[W].Done := Value; +end; + +procedure TLyric.SetScale(Value: real); +begin + ScaleR := Value; +end; + +procedure TLyric.SetStyle(Value: integer); +begin + StyleI := Value; +end; + +procedure TLyric.SetFStyle(Value: integer); +begin + FontStyleI := Value; +end; + +procedure TLyric.AddWord(Text: string); +var + WordNum: integer; +begin + WordNum := Length(Word); + SetLength(Word, WordNum + 1); + if WordNum = 0 then begin + Word[WordNum].X := XR; + end else begin + Word[WordNum].X := Word[WordNum - 1].X + Word[WordNum - 1].Width; + end; + + Word[WordNum].Y := YR; + Word[WordNum].Size := SizeR; + Word[WordNum].FontStyle := FontStyleI; // new + SetFontStyle(FontStyleI); + SetFontSize(SizeR); + Word[WordNum].Width := glTextWidth(pchar(Text)); + Word[WordNum].Text := Text; + Word[WordNum].ColR := ColR; + Word[WordNum].ColG := ColG; + Word[WordNum].ColB := ColB; + Word[WordNum].Scale := 1; + Word[WordNum].Done := 0; + Word[WordNum].Italic := Italic; + + Refresh; +end; + +procedure TLyric.AddCzesc(NrCzesci: integer); +var + N: integer; +begin + Clear; + for N := 0 to Czesci[0].Czesc[NrCzesci].HighNut do begin + Italic := Czesci[0].Czesc[NrCzesci].Nuta[N].FreeStyle; + AddWord(Czesci[0].Czesc[NrCzesci].Nuta[N].Tekst); + Text := Text + Czesci[0].Czesc[NrCzesci].Nuta[N].Tekst; + end; + Selected := -1; +end; + +procedure TLyric.Clear; +begin +{ ColR := Skin_FontR; + ColG := Skin_FontG; + ColB := Skin_FontB;} + SetLength(Word, 0); + Text := ''; + SelectedI := -1; +end; + +procedure TLyric.Refresh; +var + W: integer; + TotWidth: real; +begin + if AlignI = 1 then begin + TotWidth := 0; + for W := 0 to High(Word) do + TotWidth := TotWidth + Word[W].Width; + + Word[0].X := XR - TotWidth / 2; + for W := 1 to High(Word) do + Word[W].X := Word[W - 1].X + Word[W - 1].Width; + end; +end; + +procedure TLyric.Draw; +var + W: integer; +begin + case StyleI of + 0: + begin + for W := 0 to High(Word) do + DrawNormal(W); + end; + 1: + begin + for W := 0 to High(Word) do + DrawPlain(W); + end; + 2: // zoom + begin + for W := 0 to High(Word) do + if not Word[W].Selected then + DrawNormal(W); + + for W := 0 to High(Word) do + if Word[W].Selected then + DrawScaled(W); + end; + 3: // slide + begin + for W := 0 to High(Word) do begin + if not Word[W].Selected then + DrawNormal(W) + else + DrawSlide(W); + end; + end; + 4: // ball + begin + for W := 0 to High(Word) do + DrawNormal(W); + + for W := 0 to High(Word) do + if Word[W].Selected then begin + Tex_Ball.X := (Word[W].X - 10) + Word[W].Done * Word[W].Width; + Tex_Ball.Y := 480 - 10*sin(Word[W].Done * pi); + Tex_Ball.W := 20; + Tex_Ball.H := 20; + DrawTexture(Tex_Ball); + end; + end; + end; // case +end; + +procedure TLyric.DrawNormal(W: integer); +begin + SetFontStyle(Word[W].FontStyle); + SetFontPos(Word[W].X+ 10*ScreenX, Word[W].Y); + SetFontSize(Word[W].Size); + SetFontItalic(Word[W].Italic); + glColor3f(Word[W].ColR, Word[W].ColG, Word[W].ColB); + glPrint(pchar(Word[W].Text)); +end; + +procedure TLyric.DrawPlain(W: integer); +var + D: real; +begin + D := Word[W].Done; // przyrost + + SetFontStyle(Word[W].FontStyle); + SetFontPos(Word[W].X, Word[W].Y); + SetFontSize(Word[W].Size); + SetFontItalic(Word[W].Italic); + + if D = 0 then + glColor3f(ColR, ColG, ColB) + else + glColor3f(ColSR, ColSG, ColSB); + + glPrint(pchar(Word[W].Text)); +end; + +procedure TLyric.DrawScaled(W: integer); +var + D: real; +begin + // previous plus dynamic scaling effect + D := 1-Word[W].Done; // przyrost + SetFontStyle(Word[W].FontStyle); + SetFontPos(Word[W].X - D * Word[W].Width * (Word[W].Scale - 1) / 2 + (D+1)*10*ScreenX, Word[W].Y - D * 1.5 * Word[W].Size *(Word[W].Scale - 1)); + SetFontSize(Word[W].Size + D * (Word[W].Size * Word[W].Scale - Word[W].Size)); + SetFontItalic(Word[W].Italic); + glColor3f(Word[W].ColR, Word[W].ColG, Word[W].ColB); + glPrint(pchar(Word[W].Text)) +end; + +procedure TLyric.DrawSlide(W: integer); +var + D: real; +begin + D := Word[W].Done; // przyrost + SetFontStyle(Word[W].FontStyle); + SetFontPos(Word[W].X, Word[W].Y); + SetFontSize(Word[W].Size); + SetFontItalic(Word[W].Italic); + glColor3f(Word[W].ColR, Word[W].ColG, Word[W].ColB); + glPrintDone(pchar(Word[W].Text), D, ColR, ColG, ColB); +end; + +function TLyric.SelectedLetter; // LCD +var + W: integer; +begin + Result := 1; + + for W := 0 to SelectedI-1 do + Result := Result + Length(Word[W].Text); +end; + +function TLyric.SelectedLength: integer; // LCD +begin + Result := Length(Word[SelectedI].Text); +end; + +procedure TLyric.ChangeCurText(Text: String); +begin + Word[Selected].Text := Text; +end; + +end. diff --git a/Game/Code/Classes/UMain.pas b/Game/Code/Classes/UMain.pas new file mode 100644 index 00000000..b47047a5 --- /dev/null +++ b/Game/Code/Classes/UMain.pas @@ -0,0 +1,714 @@ +unit UMain; + +interface +uses SDL, UGraphic, UMusic, URecord, UTime, SysUtils, UDisplay, UIni, ULog, ULyrics, UScreenSing, + OpenGL12, zlportio {you can disable it and all PortWriteB calls}, ULCD, ULight, UThemes{, UScreenPopup}; + +type + TPlayer = record + Name: string; + + Score: real; + ScoreLine: real; + ScoreGolden: real; + + ScoreI: integer; + ScoreLineI: integer; + ScoreGoldenI: integer; + ScoreTotalI: integer; + + + + //SingBar Mod + ScoreLast: Real;//Last Line Score + ScorePercent: integer;//Aktual Fillstate of the SingBar + ScorePercentTarget: integer;//Target Fillstate of the SingBar + //end Singbar Mod + + //PhrasenBonus - Line Bonus Mod + LineBonus_PosX: Single; + LineBonus_PosY: Single; + LineBonus_Alpha: Single; + LineBonus_Visible: boolean; + LineBonus_Text: string; + LineBonus_Color: TRGB; + LineBonus_Age: Integer; + + //Variable vor Positioning -> Set on ScreenShow, different when Playercount Changes + LineBonus_TargetX: integer; + LineBonus_TargetY: integer; + LineBonus_StartX: integer; + LineBonus_StartY: integer; + //PhrasenBonus - Line Bonus Mod End + + //PerfectLineTwinkle Mod (effect) + LastSentencePerfect: Boolean; + //PerfectLineTwinkle Mod end + + +// Meter: real; + + HighNut: integer; + IlNut: integer; + Nuta: array of record + Start: integer; + Dlugosc: integer; + Detekt: real; // dokladne miejsce, w ktorym wykryto ta nute + Ton: real; + Perfect: boolean; // true if the note matches the original one, lit the star + + + + // Half size Notes Patch + Hit: boolean; // true if the note Hits the Line + //end Half size Notes Patch + + + + end; + end; + + +var + OGL: Boolean; + Done: Boolean; + Event: TSDL_event; + FileName: string; + Restart: boolean; + + // gracz i jego nuty + Player: array of TPlayer; + PlayersPlay: integer; + + +procedure MainLoop; +procedure CheckEvents; +procedure Sing(Sender: TScreenSing); +procedure NewSentence(Sender: TScreenSing); +procedure NewBeat(Sender: TScreenSing); // executed when on then new beat +procedure NewBeatC(Sender: TScreenSing); // executed when on then new beat for click +procedure NewBeatD(Sender: TScreenSing); // executed when on then new beat for detection +//procedure NewHalf; // executed when in the half between beats +procedure NewNote(Sender: TScreenSing); // detect note +function GetMidBeat(Time: real): real; +function GetTimeFromBeat(Beat: integer): real; +procedure ClearScores(PlayerNum: integer); + +implementation +uses USongs, UJoystick, math, UCommandLine; + +procedure MainLoop; +var + Delay: integer; +begin + SDL_EnableKeyRepeat(125, 125); + While not Done do + Begin + // joypad + if (Ini.Joypad = 1) OR (Params.Joypad) then + Joy.Update; + + // keyboard events + CheckEvents; + + // display + done := not Display.Draw; + SwapBuffers; + + // light + Light.Refresh; + + // delay + CountMidTime; +// if 1000*TimeMid > 100 then beep; + Delay := Floor(1000 / 100 - 1000 * TimeMid); + if Delay >= 1 then + SDL_Delay(Delay); // dynamic, maximum is 100 fps + CountSkipTime; + + // reinitialization of graphics + if Restart then begin + Reinitialize3D; + Restart := false; + end; + + End; + UnloadOpenGL; +End; + +Procedure CheckEvents; +//var +// p: pointer; +Begin + if not Assigned(Display.NextScreen) then + While SDL_PollEvent( @event ) = 1 Do + Begin +// beep; + Case Event.type_ Of + SDL_QUITEV: begin + Display.Fade := 0; + Display.NextScreenWithCheck := nil; + Display.CheckOK := True; + end; +{ SDL_MOUSEBUTTONDOWN: + With Event.button Do + Begin + If State = SDL_BUTTON_LEFT Then + Begin + // + End; + End; // With} + SDL_KEYDOWN: + begin + //ScreenShot hack. If Print is pressed-> Make screenshot and Save to Screenshots Path + if (Event.key.keysym.sym = SDLK_SYSREQ) then + Display.ScreenShot + + // popup hack... if there is a visible popup then let it handle input instead of underlying screen + // shoud be done in a way to be sure the topmost popup has preference (maybe error, then check) + else if (ScreenPopupError <> NIL) and (ScreenPopupError.Visible) then + done := not ScreenPopupError.ParseInput(Event.key.keysym.sym, Event.key.keysym.unicode, True) + else if (ScreenPopupCheck <> NIL) AND (ScreenPopupCheck.Visible) then + done := not ScreenPopupCheck.ParseInput(Event.key.keysym.sym, Event.key.keysym.unicode, True) + // end of popup hack + + else + begin + // check for Screen want to Exit + done := Not Display.ActualScreen^.ParseInput(Event.key.keysym.sym, Event.key.keysym.unicode, True); + + //If Screen wants to Exit + if done then + begin + //If Question Option is enabled then Show Exit Popup + if (Ini.AskbeforeDel = 1) then + begin + Display.ActualScreen^.CheckFadeTo(NIL,'MSG_QUIT_USDX'); + end + else //When asking for exit is disabled then simply exit + begin + Display.Fade := 0; + Display.NextScreenWithCheck := nil; + Display.CheckOK := True; + end; + end; + + end; // if (Not Display.ActualScreen^.ParseInput(Event.key.keysym.scancode, True)) then + end; +// SDL_JOYAXISMOTION: +// begin +// beep +// end; + SDL_JOYBUTTONDOWN: + begin + beep + end; + End; // Case Event.type_ + End; // While +End; // CheckEvents + +function GetTimeForBeats(BPM, Beats: real): real; +begin + Result := 60 / BPM * Beats; +end; + +function GetBeats(BPM, msTime: real): real; +begin + Result := BPM * msTime / 60; +end; + +procedure GetMidBeatSub(BPMNum: integer; var Time: real; var CurBeat: real); +var + NewTime: real; +begin + if High(AktSong.BPM) = BPMNum then begin + // last BPM + CurBeat := AktSong.BPM[BPMNum].StartBeat + GetBeats(AktSong.BPM[BPMNum].BPM, Time); + Time := 0; + end else begin + // not last BPM + // count how much time is it for start of the new BPM and store it in NewTime + NewTime := GetTimeForBeats(AktSong.BPM[BPMNum].BPM, AktSong.BPM[BPMNum+1].StartBeat - AktSong.BPM[BPMNum].StartBeat); + + // compare it to remaining time + if (Time - NewTime) > 0 then begin + // there is still remaining time + CurBeat := AktSong.BPM[BPMNum].StartBeat; + Time := Time - NewTime; + end else begin + // there is no remaining time + CurBeat := AktSong.BPM[BPMNum].StartBeat + GetBeats(AktSong.BPM[BPMNum].BPM, Time); + Time := 0; + end; // if + end; // if +end; + +function GetMidBeat(Time: real): real; +var + CurBeat: real; + CurBPM: integer; +// TopBeat: real; +// TempBeat: real; +// TempTime: real; +begin + Result := 0; + if Length(AktSong.BPM) = 1 then Result := Time * AktSong.BPM[0].BPM / 60; + + (* 2 BPMs *) +{ if Length(AktSong.BPM) > 1 then begin + (* new system *) + CurBeat := 0; + TopBeat := GetBeats(AktSong.BPM[0].BPM, Time); + if TopBeat > AktSong.BPM[1].StartBeat then begin + // analyze second BPM + Time := Time - GetTimeForBeats(AktSong.BPM[0].BPM, AktSong.BPM[1].StartBeat - CurBeat); + CurBeat := AktSong.BPM[1].StartBeat; + TopBeat := GetBeats(AktSong.BPM[1].BPM, Time); + Result := CurBeat + TopBeat; + + end else begin + (* pierwszy przedzial *) + Result := TopBeat; + end; + end; // if} + + (* more BPMs *) + if Length(AktSong.BPM) > 1 then begin + + CurBeat := 0; + CurBPM := 0; + while (Time > 0) do begin + GetMidBeatSub(CurBPM, Time, CurBeat); + Inc(CurBPM); + end; + + Result := CurBeat; + end; // if +end; + +function GetTimeFromBeat(Beat: integer): real; +var + CurBPM: integer; +begin + Result := 0; + if Length(AktSong.BPM) = 1 then Result := AktSong.GAP / 1000 + Beat * 60 / AktSong.BPM[0].BPM; + + (* more BPMs *) + if Length(AktSong.BPM) > 1 then begin + Result := AktSong.GAP / 1000; + CurBPM := 0; + while (CurBPM <= High(AktSong.BPM)) and (Beat > AktSong.BPM[CurBPM].StartBeat) do begin + if (CurBPM < High(AktSong.BPM)) and (Beat >= AktSong.BPM[CurBPM+1].StartBeat) then begin + // full range + Result := Result + (60 / AktSong.BPM[CurBPM].BPM) * (AktSong.BPM[CurBPM+1].StartBeat - AktSong.BPM[CurBPM].StartBeat); + end; + + if (CurBPM = High(AktSong.BPM)) or (Beat < AktSong.BPM[CurBPM+1].StartBeat) then begin + // in the middle + Result := Result + (60 / AktSong.BPM[CurBPM].BPM) * (Beat - AktSong.BPM[CurBPM].StartBeat); + end; + Inc(CurBPM); + end; + +{ while (Time > 0) do begin + GetMidBeatSub(CurBPM, Time, CurBeat); + Inc(CurBPM); + end;} + end; // if} +end; + +procedure Sing(Sender: TScreenSing); +var + Pet: integer; + PetGr: integer; + CP: integer; + Done: real; + N: integer; +begin + Czas.Teraz := Czas.Teraz + TimeSkip; + + Czas.OldBeat := Czas.AktBeat; + Czas.MidBeat := GetMidBeat(Czas.Teraz - (AktSong.Gap{ + 90 I've forgotten for what it is}) / 1000); // new system with variable BPM in function + Czas.AktBeat := Floor(Czas.MidBeat); + +// Czas.OldHalf := Czas.AktHalf; +// Czas.MidHalf := Czas.MidBeat + 0.5; +// Czas.AktHalf := Floor(Czas.MidHalf); + + Czas.OldBeatC := Czas.AktBeatC; + Czas.MidBeatC := GetMidBeat(Czas.Teraz - (AktSong.Gap) / 1000); + Czas.AktBeatC := Floor(Czas.MidBeatC); + + Czas.OldBeatD := Czas.AktBeatD; + Czas.MidBeatD := -0.5+GetMidBeat(Czas.Teraz - (AktSong.Gap + 120 + 20) / 1000); // MidBeat with addition GAP + Czas.AktBeatD := Floor(Czas.MidBeatD); + Czas.FracBeatD := Frac(Czas.MidBeatD); + + // sentences routines + for PetGr := 0 to 0 do begin;//High(Gracz) do begin + CP := PetGr; + // ustawianie starej czesci + Czas.OldCzesc := Czesci[CP].Akt; + + // wybieranie aktualnej czesci + for Pet := 0 to Czesci[CP].High do + if Czas.AktBeat >= Czesci[CP].Czesc[Pet].Start then Czesci[CP].Akt := Pet; + + // czysczenie nut gracza, gdy to jest nowa plansza + // (optymizacja raz na halfbeat jest zla) + if Czesci[CP].Akt <> Czas.OldCzesc then NewSentence(Sender); + + end; // for PetGr + + // wykonuje operacje raz na beat + if (Czas.AktBeat >= 0) and (Czas.OldBeat <> Czas.AktBeat) then + NewBeat(Sender); + + // make some operations on clicks + if {(Czas.AktBeatC >= 0) and }(Czas.OldBeatC <> Czas.AktBeatC) then + NewBeatC(Sender); + + // make some operations when detecting new voice pitch + if (Czas.AktBeatD >= 0) and (Czas.OldBeatD <> Czas.AktBeatD) then + NewBeatD(Sender); + + // wykonuje operacje w polowie beatu +// if (Czas.AktHalf >= 1) and (Czas.OldHalf <> Czas.AktHalf) then +// NewHalf; + + // plynnie przesuwa text + Done := 1; + for N := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[N].Start <= Czas.MidBeat) + and (Czesci[0].Czesc[Czesci[0].Akt].Nuta[N].Start + Czesci[0].Czesc[Czesci[0].Akt].Nuta[N].Dlugosc >= Czas.MidBeat) then + Done := (Czas.MidBeat - Czesci[0].Czesc[Czesci[0].Akt].Nuta[N].Start) / (Czesci[0].Czesc[Czesci[0].Akt].Nuta[N].Dlugosc); + + N := Czesci[0].Czesc[Czesci[0].Akt].HighNut; + + // wylacza ostatnia nute po przejsciu + if (Ini.LyricsEffect = 1) and (Done = 1) and + (Czas.MidBeat > Czesci[0].Czesc[Czesci[0].Akt].Nuta[N].Start + Czesci[0].Czesc[Czesci[0].Akt].Nuta[N].Dlugosc) + then Sender.LyricMain.Selected := -1; + + if Done > 1 then Done := 1; + Sender.LyricMain.Done := Done; + + // use Done with LCD +{ with ScreenSing do begin + if LyricMain.Selected >= 0 then begin + LCD.MoveCursor(1, LyricMain.SelectedLetter + Round((LyricMain.SelectedLength-1) * Done)); + LCD.ShowCursor; + end; + end;} + + +end; + +procedure NewSentence(Sender: TScreenSing); +var +G: Integer; +begin + // czyszczenie nut graczy + for G := 0 to High(Player) do begin + Player[G].IlNut := 0; + Player[G].HighNut := -1; + SetLength(Player[G].Nuta, 0); + end; + + // wstawianie tekstow + with Sender do begin + LyricMain.AddCzesc(Czesci[0].Akt); + if Czesci[0].Akt < Czesci[0].High then + LyricSub.AddCzesc(Czesci[0].Akt+1) + else + LyricSub.Clear; + end; + + Sender.UpdateLCD; + + //On Sentence Change... + Sender.onSentenceChange(Czesci[0].Akt); +end; + +procedure NewBeat(Sender: TScreenSing); +var + Pet: integer; +// TempBeat: integer; +begin + // ustawia zaznaczenie tekstu +// SingScreen.LyricMain.Selected := -1; + for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = Czas.AktBeat) then begin + // operates on currently beated note + Sender.LyricMain.Selected := Pet; + +// LCD.MoveCursor(1, ScreenSing.LyricMain.SelectedLetter); +// LCD.ShowCursor; + + LCD.MoveCursorBR(Sender.LyricMain.SelectedLetter); + LCD.ShowCursor; + + end; +end; + +procedure NewBeatC; +var + Pet: integer; +// LPT_1: integer; +// LPT_2: integer; +begin +// LPT_1 := 1; +// LPT_2 := 1; + + // beat click + if (Ini.BeatClick = 1) and ((Czas.AktBeatC + Czesci[0].Resolution + Czesci[0].NotesGAP) mod Czesci[0].Resolution = 0) then + Music.PlayClick; + + // debug system on LPT + if ((Czas.AktBeatC + Czesci[0].Resolution + Czesci[0].NotesGAP) mod Czesci[0].Resolution = 0) then begin + //LPT_1 := 0; +// Light.LightOne(0, 150); + + Light.LightOne(1, 200); // beat light + if ParamStr(1) = '-doublelights' then + Light.LightOne(0, 200); // beat light + + +{ if ((Czas.AktBeatC + Czesci[0].Resolution + Czesci[0].NotesGAP) mod (Czesci[0].Resolution * 2) = 0) then + Light.LightOne(0, 150) + else + Light.LightOne(1, 150)} + end; + + for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = Czas.AktBeatC) then begin + // click assist + if Ini.ClickAssist = 1 then + Music.PlayClick; + + //LPT_2 := 0; + if ParamStr(1) <> '-doublelights' then + Light.LightOne(0, 150); //125 + + + // drum machine +(* TempBeat := Czas.AktBeat;// + 2; + if (TempBeat mod 8 = 0) then Music.PlayDrum; + if (TempBeat mod 8 = 4) then Music.PlayClap; +// if (TempBeat mod 4 = 2) then Music.PlayHihat; + if (TempBeat mod 4 <> 0) then Music.PlayHihat;*) + end; + + //PortWriteB($378, LPT_1 + LPT_2 * 2); // 0 zapala +end; + +procedure NewBeatD(Sender: TScreenSing); +begin + NewNote(Sender); +end; + +//procedure NewHalf; +//begin +// NewNote; +//end; + +procedure NewNote(Sender: TScreenSing); +var + CP: integer; // current player + S: integer; // sentence + SMin: integer; + SMax: integer; + SDet: integer; // temporary: sentence of detected note + Pet: integer; + Mozna: boolean; + Nowa: boolean; + Range: integer; + NoteHit:boolean; +begin +// Log.LogStatus('Beat ' + IntToStr(Czas.AktBeat) + ' HalfBeat ' + IntToStr(Czas.AktHalf), 'NewBeat'); +// beep; + + // analizuje dla obu graczy ten sam sygnal (Sound.OneSrcForBoth) + // albo juz lepiej nie + for CP := 0 to PlayersPlay-1 do begin + + // analyze buffer + Sound[CP].AnalizujBufor; + + // adds some noise +// Czas.Ton := Czas.Ton + Round(Random(3)) - 1; + + // 0.5.0: count min and max sentence range for checking (detection is delayed to the notes we see on the screen) + SMin := Czesci[0].Akt-1; + if SMin < 0 then SMin := 0; + SMax := Czesci[0].Akt; + + // check if we can add new note + Mozna := false; + for S := SMin to SMax do + for Pet := 0 to Czesci[0].Czesc[S].HighNut do + if ((Czesci[0].Czesc[S].Nuta[Pet].Start <= Czas.AktBeatD) + and (Czesci[0].Czesc[S].Nuta[Pet].Start + Czesci[0].Czesc[S].Nuta[Pet].Dlugosc - 1 >= Czas.AktBeatD)) + and (not Czesci[0].Czesc[S].Nuta[Pet].FreeStyle) // but don't allow when it's FreeStyle note + and (Czesci[0].Czesc[S].Nuta[Pet].Dlugosc > 0) // and make sure the note lenghts is at least 1 + then begin + SDet := S; + Mozna := true; + Break; + end; + + S := SDet; + + + + + +// Czas.SzczytJest := true; +// Czas.Ton := 27; + + // gdy moze, to dodaje nute + if (Sound[CP].SzczytJest) and (Mozna) then begin + // operowanie na ostatniej nucie + for Pet := 0 to Czesci[0].Czesc[S].HighNut do + if (Czesci[0].Czesc[S].Nuta[Pet].Start <= Czas.OldBeatD+1) + and (Czesci[0].Czesc[S].Nuta[Pet].Start + + Czesci[0].Czesc[S].Nuta[Pet].Dlugosc > Czas.OldBeatD+1) then begin + // to robi, tylko dla pary nut (oryginalnej i gracza) + + // przesuwanie tonu w odpowiednia game + while (Sound[CP].Ton - Czesci[0].Czesc[S].Nuta[Pet].Ton > 6) do + Sound[CP].Ton := Sound[CP].Ton - 12; + while (Sound[CP].Ton - Czesci[0].Czesc[S].Nuta[Pet].Ton < -6) do + Sound[CP].Ton := Sound[CP].Ton + 12; + + // Half size Notes Patch + NoteHit := false; + + //if Ini.Difficulty = 0 then Range := 2; + //if Ini.Difficulty = 1 then Range := 1; + //if Ini.Difficulty = 2 then Range := 0; + Range := 2 - Ini.Difficulty; + if abs(Czesci[0].Czesc[S].Nuta[Pet].Ton - Sound[CP].Ton) <= Range then begin + Sound[CP].Ton := Czesci[0].Czesc[S].Nuta[Pet].Ton; + + + // Half size Notes Patch + NoteHit := true; + + + if (Ini.LineBonus = 0) then + begin + // add points without LineBonus + case Czesci[0].Czesc[S].Nuta[Pet].Wartosc of + 1: Player[CP].Score := Player[CP].Score + 10000 / Czesci[0].Wartosc * + Czesci[0].Czesc[S].Nuta[Pet].Wartosc; + 2: Player[CP].ScoreGolden := Player[CP].ScoreGolden + 10000 / Czesci[0].Wartosc * + Czesci[0].Czesc[S].Nuta[Pet].Wartosc; + end; + end + else + begin + // add points with Line Bonus + case Czesci[0].Czesc[S].Nuta[Pet].Wartosc of + 1: Player[CP].Score := Player[CP].Score + 9000 / Czesci[0].Wartosc * + Czesci[0].Czesc[S].Nuta[Pet].Wartosc; + 2: Player[CP].ScoreGolden := Player[CP].ScoreGolden + 9000 / Czesci[0].Wartosc * + Czesci[0].Czesc[S].Nuta[Pet].Wartosc; + end; + end; + + Player[CP].ScoreI := Floor(Player[CP].Score / 10) * 10; + Player[CP].ScoreGoldenI := Floor(Player[CP].ScoreGolden / 10) * 10; + + Player[CP].ScoreTotalI := Player[CP].ScoreI + Player[CP].ScoreGoldenI + Player[CP].ScoreLineI; + end; + + end; // operowanie + + // sprawdzanie czy to nowa nuta, czy przedluzenie + if S = SMax then begin + Nowa := true; + // jezeli ostatnia ma ten sam ton + if (Player[CP].IlNut > 0 ) and (Player[CP].Nuta[Player[CP].HighNut].Ton = Sound[CP].Ton) + and (Player[CP].Nuta[Player[CP].HighNut].Start + Player[CP].Nuta[Player[CP].HighNut].Dlugosc = Czas.AktBeatD) + then Nowa := false; + // jezeli jest jakas nowa nuta na sprawdzanym beacie + for Pet := 0 to Czesci[0].Czesc[S].HighNut do + if (Czesci[0].Czesc[S].Nuta[Pet].Start = Czas.AktBeatD) then + Nowa := true; + + // dodawanie nowej nuty + if Nowa then begin + // nowa nuta + Player[CP].IlNut := Player[CP].IlNut + 1; + Player[CP].HighNut := Player[CP].HighNut + 1; + SetLength(Player[CP].Nuta, Player[CP].IlNut); + Player[CP].Nuta[Player[CP].HighNut].Start := Czas.AktBeatD; + Player[CP].Nuta[Player[CP].HighNut].Dlugosc := 1; + Player[CP].Nuta[Player[CP].HighNut].Ton := Sound[CP].Ton; // Ton || TonDokl + Player[CP].Nuta[Player[CP].HighNut].Detekt := Czas.MidBeat; + + + // Half Note Patch + Player[CP].Nuta[Player[CP].HighNut].Hit := NoteHit; + + + // Log.LogStatus('Nowa Nuta ' + IntToStr(Gracz.Nuta[Gracz.HighNut].Start), 'NewBeat'); + + end else begin + // przedluzenie nuty + Player[CP].Nuta[Player[CP].HighNut].Dlugosc := Player[CP].Nuta[Player[CP].HighNut].Dlugosc + 1; + end; + + + // check for perfect note and then lit the star (on Draw) + for Pet := 0 to Czesci[0].Czesc[S].HighNut do + if (Czesci[0].Czesc[S].Nuta[Pet].Start = Player[CP].Nuta[Player[CP].HighNut].Start) + and (Czesci[0].Czesc[S].Nuta[Pet].Dlugosc = Player[CP].Nuta[Player[CP].HighNut].Dlugosc) + and (Czesci[0].Czesc[S].Nuta[Pet].Ton = Player[CP].Nuta[Player[CP].HighNut].Ton) then begin + Player[CP].Nuta[Player[CP].HighNut].Perfect := true; + end; + + end;// else beep; // if S = SMax + + end; // if moze + end; // for CP +// Log.LogStatus('EndBeat', 'NewBeat'); + +//On Sentence End -> For LineBonus + SingBar +if (sDet >= low(Czesci[0].Czesc)) AND (sDet <= high(Czesci[0].Czesc)) then +if ((Czesci[0].Czesc[SDet].Nuta[Czesci[0].Czesc[SDet].HighNut].Start + Czesci[0].Czesc[SDet].Nuta[Czesci[0].Czesc[SDet].HighNut].Dlugosc - 1) = Czas.AktBeatD) then + Sender.onSentenceEnd(sDet); + +end; + +procedure ClearScores(PlayerNum: integer); +begin + Player[PlayerNum].Score := 0; + Player[PlayerNum].ScoreI := 0; + Player[PlayerNum].ScoreLine := 0; + Player[PlayerNum].ScoreLineI := 0; + Player[PlayerNum].ScoreGolden := 0; + Player[PlayerNum].ScoreGoldenI := 0; + Player[PlayerNum].ScoreTotalI := 0; + + + //SingBar Mod + Player[PlayerNum].ScoreLast := 0; + Player[PlayerNum].ScorePercent := 50;// Sets to 50% when song starts + Player[PlayerNum].ScorePercentTarget := 50;// Sets to 50% when song starts + //end SingBar Mod + + //PhrasenBonus - Line Bonus Mod + Player[PlayerNum].LineBonus_Visible := False; //Hide Line Bonus + Player[PlayerNum].LineBonus_Alpha := 0; + Player[PlayerNum].LineBonus_TargetX := 70 + PlayerNum*500; + Player[PlayerNum].LineBonus_TargetY := 30; + //PhrasenBonus - Line Bonus Mod End + + + +end; + +end. + diff --git a/Game/Code/Classes/UMusic.pas b/Game/Code/Classes/UMusic.pas new file mode 100644 index 00000000..735210c1 --- /dev/null +++ b/Game/Code/Classes/UMusic.pas @@ -0,0 +1,810 @@ +unit UMusic; + +interface + +uses Classes, MPlayer, Windows, Messages, SysUtils, Forms, ULog, USongs, Bass;//, DXSounds; + +procedure InitializeSound; + +type + TSoundCard = record + Name: string; + Source: array of string; + end; + + TFFTData = array [0..256] of Single; + + TCustomSoundEntry = record + Filename: String; + Handle: hStream; + end; + + + TMusic = class + private +// MediaPlayer: TMediaPlayer; // It will be replaced by another component; +{ MediaPlayerStart: TMediaPlayer; // or maybe not if done this way ;) + MediaPlayerBack: TMediaPlayer; + MediaPlayerSwoosh: TMediaPlayer; + MediaPlayerChange: TMediaPlayer; + MediaPlayerOption: TMediaPlayer; + MediaPlayerClick: TMediaPlayer; + MediaPlayerDrum: TMediaPlayer; + MediaPlayerHihat: TMediaPlayer; + MediaPlayerClap: TMediaPlayer; + MediaPlayerShuffle: TMediaPlayer;} + BassStart: hStream; // Wait, I've replaced this with BASS + BassBack: hStream; // It has almost all features we need + BassSwoosh: hStream; + BassChange: hStream; // Almost? It aleady has them all :) + BassOption: hStream; + BassClick: hStream; + BassDrum: hStream; + BassHihat: hStream; + BassClap: hStream; + BassShuffle: hStream; + + //Custom Sounds + CustomSounds: array of TCustomSoundEntry; + + + Loaded: boolean; + Loop: boolean; +// DXSound: TDXSound; +// Player: TcmxMp3; + public + Bass: hStream; + +// SoundCard: array of TSoundCard; + procedure InitializePlayback; + procedure InitializeRecord; + procedure SetVolume(Volume: integer); + procedure SetMusicVolume(Volume: integer); + procedure SetLoop(Enabled: boolean); + function Open(Name: string): boolean; // true if succeed + procedure Rewind; + procedure MoveTo(Time: real); + procedure Play; + procedure Pause; //Pause Mod + procedure Stop; + procedure Close; + function Finished: boolean; + function Length: real; + function Position: real; + procedure PlayStart; + procedure PlayBack; + procedure PlaySwoosh; + procedure PlayChange; + procedure PlayOption; + procedure PlayClick; + procedure PlayDrum; + procedure PlayHihat; + procedure PlayClap; + procedure PlayShuffle; + procedure StopShuffle; + procedure CaptureStart; + procedure CaptureStop; + procedure CaptureCard(RecordI, PlayerLeft, PlayerRight: byte); + procedure StopCard(Card: byte); + function LoadPlayerFromFile(var MediaPlayer: TMediaPlayer; Name: string): boolean; + function LoadSoundFromFile(var hStream: hStream; Name: string): boolean; + + //Equalizer + function GetFFTData: TFFTData; + + //Custom Sounds + function LoadCustomSound(const Filename: String): Cardinal; + procedure PlayCustomSound(const Index: Cardinal); + +end; + +const + RecordSystem = 1; + +type + TMuzyka = record + Path: string; + Start: integer; // start of song in ms +// BPM: array of TBPM; +// Gap: real; + IlNut: integer; + DlugoscNut: integer; +// WartoscNut: integer; + end; + + TCzesci = record + Akt: integer; // aktualna czesc utworu do rysowania + High: integer; + Ilosc: integer; + Resolution: integer; + NotesGAP: integer; + Wartosc: integer; + Czesc: array of record + Start: integer; + StartNote: integer; + Lyric: string; + LyricWidth: real; + Koniec: integer; + BaseNote: integer; + HighNut: integer; + IlNut: integer; + TotalNotes: integer; + Nuta: array of record + Color: integer; + Start: integer; + Dlugosc: integer; + Ton: integer; + TonGamy: integer; + Tekst: string; + FreeStyle: boolean; + Wartosc: integer; // zwykla nuta x1, zlota nuta x2 + + + + + end; + end; + end; + + TCzas = record // wszystko, co dotyczy aktualnej klatki +// BajtowTotal: integer; +// BajtowTeraz: integer; +// BajtowNaSek: integer; + OldBeat: integer; // poprzednio wykryty beat w utworze + AktBeat: integer; // aktualny beat w utworze + MidBeat: real; // dokladny AktBeat + + // should not be used +// OldHalf: integer; // poprzednio wykryta polowka +// AktHalf: integer; // aktualna polowka w utworze +// MidHalf: real; // dokladny AktHalf + + // now we use this for super synchronization! + // only used when analyzing voice + OldBeatD: integer; // poprzednio wykryty beat w utworze + AktBeatD: integer; // aktualny beat w utworze + MidBeatD: real; // dokladny AktBeatD + FracBeatD: real; // fractional part of MidBeatD + + // we use this for audiable clicks + OldBeatC: integer; // poprzednio wykryty beat w utworze + AktBeatC: integer; // aktualny beat w utworze + MidBeatC: real; // dokladny AktBeatC + FracBeatC: real; // fractional part of MidBeatC + + + OldCzesc: integer; // poprzednio wyswietlana czesc + // akt jest w czesci.akt + + Teraz: real; // aktualny czas w utworze + Razem: real; // caly czas utworu +// TerazSek: integer; + end; + +var + Form: TForm; + Music: TMusic; + + // muzyka + Muzyka: TMuzyka; + + // czesci z nutami; + Czesci: array of TCzesci; + + // czas + Czas: TCzas; + + fHWND: Thandle; + +const + ModeStr: array[TMPModes] of string = ('Not ready', 'Stopped', 'Playing', 'Recording', 'Seeking', 'Paused', 'Open'); + +implementation +uses UGraphic, URecord, UFiles, UIni, UMain, UThemes; + +procedure InitializeSound; +begin + Log.LogStatus('Initializing Playback', 'InitializeSound'); Music.InitializePlayback; + Log.LogStatus('Initializing Record', 'InitializeSound'); Music.InitializeRecord; +end; + +procedure TMusic.InitializePlayback; +var + Pet: integer; + S: integer; +begin + Log.BenchmarkStart(4); + Log.LogStatus('Initializing Playback Subsystem', 'Music Initialize'); + Loaded := false; + Loop := false; + fHWND := AllocateHWND( nil); + + if BASS_Init(1, 44100, 0, fHWND, nil) = false then + begin + Application.MessageBox ('Could not initialize BASS', 'Error'); + Exit; + end; + + Log.BenchmarkEnd(4); Log.LogBenchmark('--> Bass Init', 4); + + // config playing buffer +// BASS_SetConfig(BASS_CONFIG_UPDATEPERIOD, 10); +// BASS_SetConfig(BASS_CONFIG_BUFFER, 100); + +{ MediaPlayer := TMediaPlayer.Create( nil ); + MediaPlayer.ParentWindow := fHWND; + MediaPlayer.Wait := true;} + + Log.LogStatus('Loading Sounds', 'Music Initialize'); + +{ LoadPlayerFromFile(MediaPlayerStart, SoundPath + 'Common Start.mp3'); + LoadPlayerFromFile(MediaPlayerBack, SoundPath + 'Common Back.mp3'); + LoadPlayerFromFile(MediaPlayerSwoosh, SoundPath + 'menu swoosh.mp3'); + LoadPlayerFromFile(MediaPlayerChange, SoundPath + 'select music change music.mp3'); + LoadPlayerFromFile(MediaPlayerOption, SoundPath + 'option change col.mp3'); + LoadPlayerFromFile(MediaPlayerClick, SoundPath + 'rimshot022b.mp3'); + + LoadPlayerFromFile(MediaPlayerDrum, SoundPath + 'bassdrumhard076b.mp3'); + LoadPlayerFromFile(MediaPlayerHihat, SoundPath + 'hihatclosed068b.mp3'); + LoadPlayerFromFile(MediaPlayerClap, SoundPath + 'claps050b.mp3'); + + LoadPlayerFromFile(MediaPlayerShuffle, SoundPath + 'Shuffle.mp3');} + + Log.BenchmarkStart(4); + LoadSoundFromFile(BassStart, SoundPath + 'Common Start.mp3'); + LoadSoundFromFile(BassBack, SoundPath + 'Common Back.mp3'); + LoadSoundFromFile(BassSwoosh, SoundPath + 'menu swoosh.mp3'); + LoadSoundFromFile(BassChange, SoundPath + 'select music change music 50.mp3'); + LoadSoundFromFile(BassOption, SoundPath + 'option change col.mp3'); + LoadSoundFromFile(BassClick, SoundPath + 'rimshot022b.mp3'); + +// LoadSoundFromFile(BassDrum, SoundPath + 'bassdrumhard076b.mp3'); +// LoadSoundFromFile(BassHihat, SoundPath + 'hihatclosed068b.mp3'); +// LoadSoundFromFile(BassClap, SoundPath + 'claps050b.mp3'); + +// LoadSoundFromFile(BassShuffle, SoundPath + 'Shuffle.mp3'); + + Log.BenchmarkEnd(4); Log.LogBenchmark('--> Loading Sounds', 4); +end; + +procedure TMusic.InitializeRecord; +var + S: integer; + device: integer; + descr: string; + input: integer; + input2: integer; + flags: integer; + mic: array[0..15] of integer; + SC: integer; // soundcard + SCI: integer; // soundcard input +begin + if RecordSystem = 1 then begin + SetLength(Sound, 6 {max players});//Ini.Players+1); + for S := 0 to High(Sound) do begin //Ini.Players do begin + Sound[S] := TSound.Create; + Sound[S].Num := S; + Sound[S].BufferNew := TMemoryStream.Create; + SetLength(Sound[S].BufferLong, 1); + Sound[S].BufferLong[0] := TMemoryStream.Create; + Sound[S].n := 4*1024; + end; + + + // check for recording devices; + {device := 0; + descr := BASS_RecordGetDeviceDescription(device); + + SetLength(SoundCard, 0); + while (descr <> '') do begin + SC := High(SoundCard) + 1; + SetLength(SoundCard, SC+1); + + Log.LogAnalyze('Device #'+IntToStr(device)+': '+ descr); + SoundCard[SC].Description := Descr; + + // check for recording inputs + mic[device] := -1; // default to no change + input := 0; + BASS_RecordInit(device); + Log.LogAnalyze('Input #' + IntToStr(Input) + ': ' + BASS_RecordGetInputName(input)); + flags := BASS_RecordGetInput(input); + + SetLength(SoundCard[SC].Input, 0); + while (flags <> -1) do begin + SCI := High(SoundCard[SC].Input) + 1; + SetLength(SoundCard[SC].Input, SCI+1); + + Log.LogAnalyze('Input #' + IntToStr(Input) + ': ' + BASS_RecordGetInputName(input)); + SoundCard[SC].Input[SCI].Name := BASS_RecordGetInputName(Input); + + if (flags and BASS_INPUT_TYPE_MASK) = BASS_INPUT_TYPE_MIC then begin + mic[device] := input; // auto set microphone + end; + Inc(Input); + flags := BASS_RecordGetInput(input); + end; + + if mic[device] <> -1 then begin + Log.LogAnalyze('Found the mic at input ' + IntToStr(Mic[device])) + end else begin + Log.LogAnalyze('Mic not found'); + mic[device] := 0; // setting to the first one (for kxproject) + end; + SoundCard[SC].InputSeleceted := Mic[Device]; + + + BASS_RecordFree; + + inc(Device); + descr := BASS_RecordGetDeviceDescription(Device); + end; // while} + end; // if +end; + +procedure TMusic.SetVolume(Volume: integer); +begin + //Old Sets Wave Volume + //BASS_SetVolume(Volume); + //New: Sets Volume only for this Application + BASS_SetConfig(BASS_CONFIG_GVOL_SAMPLE, Volume); + BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, Volume); + BASS_SetConfig(BASS_CONFIG_GVOL_MUSIC, Volume); +end; + +procedure TMusic.SetMusicVolume(Volume: Integer); +begin + //Max Volume Prevention + if Volume > 100 then + Volume := 100; + + //Set Volume + BASS_ChannelSetAttributes (Bass, -1, Volume, -101); +end; + +procedure TMusic.SetLoop(Enabled: boolean); +begin + Loop := Enabled; +end; + +function TMusic.Open(Name: string): boolean; +begin + Loaded := false; + if FileExists(Name) then begin +{ MediaPlayer.FileName := Name; + MediaPlayer.Open;} + + Bass := Bass_StreamCreateFile(false, pchar(Name), 0, 0, 0); + Loaded := true; + //Set Max Volume + SetMusicVolume (100); + end; + + Result := Loaded; + +// Player := TcmxMp3.Create(Name); +end; + +procedure TMusic.Rewind; +begin + if Loaded then begin +// MediaPlayer.Position := 0; + + end; +end; + +procedure TMusic.MoveTo(Time: real); +var + bytes: integer; +begin +// if Loaded then begin +// MediaPlayer.StartPos := Round(Time); + bytes := BASS_ChannelSeconds2Bytes(Bass, Time); + BASS_ChannelSetPosition(Bass, bytes); +// end; +end; + +procedure TMusic.Play; +begin + if Loaded then begin +// MediaPlayer.Play; + if Loop then BASS_ChannelPlay(Bass, True); // start from beginning... actually bass itself does not loop, nor does this TMusic Class + BASS_ChannelPlay(Bass, False); // for setting position before playing + end; +end; + +procedure TMusic.Pause; //Pause Mod +begin + if Loaded then begin + BASS_ChannelPause(Bass); // Pauses Song + end; +end; + +procedure TMusic.Stop; +begin + Bass_ChannelStop(Bass); +// Bass_StreamFree(Bass); +// if ModeStr[MediaPlayer.Mode] = 'Playing' then begin +// MediaPlayer.Stop; +// end; +end; + +procedure TMusic.Close; +begin + Bass_StreamFree(Bass); +// Player.Free; +// MediaPlayer.Close; +end; + +function TMusic.Length: real; +var + bytes: integer; +begin + Result := 60; + + bytes := BASS_ChannelGetLength( Bass ); + Result := BASS_ChannelBytes2Seconds(Bass, bytes); + +{ if Assigned(MediaPlayer) then begin + if Loaded then Result := MediaPlayer.Length / 1000; + end;} +// if Assigned(Player) then +// Result := Player.LengthInSeconds; +end; + +function TMusic.Position: real; +var + bytes: integer; +begin + Result := 0;//MediaPlayer.Position / 1000; + bytes := BASS_ChannelGetPosition(BASS); + Result := BASS_ChannelBytes2Seconds(BASS, bytes); +end; + +function TMusic.Finished: boolean; +begin + Result := false; +// if ModeStr[MediaPlayer.Mode] = 'Stopped' then Result := true; + if BASS_ChannelIsActive(BASS) = BASS_ACTIVE_STOPPED then begin +// beep; + Result := true; + end; +end; + +{function myeffect( chan : integer; stream : Pointer; len : integer; udata : Pointer ): Pointer; cdecl; +var + dane: pwordarray; + pet: integer; + Prev: smallint; + PrevNew: smallint; +begin + dane := stream; + Prev := 0; + for pet := 0 to len div 2 -1 do begin + PrevNew := Dane[Pet]; + +// Dane[pet] := Round(PrevNew*1/8 + Prev*7/8); + + Prev := Dane[Pet]; + end; +end;} + +procedure TMusic.PlayStart; +{var + Music: PMix_Chunk;} +begin +{ Mix_OpenAudio(44100, 16, 1, 16*1024); + Music := Mix_LoadWAV('D:\Rozne\UltraStar\Old\Boys - Hej Sokoly 30s.wav'); + Mix_RegisterEffect(0, myeffect, nil, 0); + Mix_PlayChannel(0, Music, 0);} + +// MediaPlayerStart.Rewind; +// MediaPlayerStart.Play; + BASS_ChannelPlay(BassStart, True); +end; + +procedure TMusic.PlayBack; +begin +// MediaPlayerBack.Rewind; +// MediaPlayerBack.Play; +// if not + BASS_ChannelPlay(BassBack, True);// then +// Application.MessageBox ('Error playing stream!', 'Error'); +end; + +procedure TMusic.PlaySwoosh; +begin +// MediaPlayerSwoosh.Rewind; +// MediaPlayerSwoosh.Play; + BASS_ChannelPlay(BassSwoosh, True); +end; + +procedure TMusic.PlayChange; +begin +// MediaPlayerChange.Rewind; +// MediaPlayerChange.Play; + BASS_ChannelPlay(BassChange, True); +end; + +procedure TMusic.PlayOption; +begin +// MediaPlayerOption.Rewind; +// MediaPlayerOption.Play; + BASS_ChannelPlay(BassOption, True); +end; + +procedure TMusic.PlayClick; +begin +// MediaPlayerClick.Rewind; +// MediaPlayerClick.Play; + BASS_ChannelPlay(BassClick, True); +end; + +procedure TMusic.PlayDrum; +begin +// MediaPlayerDrum.Rewind; +// MediaPlayerDrum.Play; + BASS_ChannelPlay(BassDrum, True); +end; + +procedure TMusic.PlayHihat; +begin +// MediaPlayerHihat.Rewind; +// MediaPlayerHihat.Play; + BASS_ChannelPlay(BassHihat, True); +end; + +procedure TMusic.PlayClap; +begin +// MediaPlayerClap.Rewind; +// MediaPlayerClap.Play; + BASS_ChannelPlay(BassClap, True); +end; + +procedure TMusic.PlayShuffle; +begin +// MediaPlayerShuffle.Rewind; +// MediaPlayerShuffle.Play; + BASS_ChannelPlay(BassShuffle, True); +end; + +procedure TMusic.StopShuffle; +begin + BASS_ChannelStop(BassShuffle); +end; + +procedure TMusic.CaptureStart; +var + S: integer; + SC: integer; + P1: integer; + P2: integer; +begin + for S := 0 to High(Sound) do + Sound[S].BufferLong[0].Clear; + +{ case PlayersPlay of + 1: begin + CaptureCard(0, 0, 1, 0); + end; + 2: begin + if Ini.TwoPlayerMode = 0 then begin + CaptureCard(0, 0, 1, 2); + end else begin + CaptureCard(0, 0, 1, 0); + CaptureCard(1, 1, 2, 0); + end; + end; + 3: begin + CaptureCard(0, 0, 1, 2); + CaptureCard(1, 1, 3, 0); + end; + end; // case} + +// CaptureCard(0, 0, 0, 0); +// end; + + {for SC := 0 to High(SoundCard) do begin + P1 := Ini.SoundCard[SC, 1]; + P2 := Ini.SoundCard[SC, 2]; + if P1 > PlayersPlay then P1 := 0; + if P2 > PlayersPlay then P2 := 0; + CaptureCard(SC, P1, P2); + end; } + // 0.5.2: new + for SC := 0 to High(Ini.CardList) do begin + P1 := Ini.CardList[SC].ChannelL; + P2 := Ini.CardList[SC].ChannelR; + if P1 > PlayersPlay then P1 := 0; + if P2 > PlayersPlay then P2 := 0; + if (P1 > 0) or (P2 > 0) then + CaptureCard(SC, P1, P2); + end; +end; + +procedure TMusic.CaptureStop; +var + SC: integer; + P1: integer; + P2: integer; +begin +{ if RecordSystem = 1 then begin + case PlayersPlay of + 1: begin + StopCard(0); + end; + 2: begin + if Ini.TwoPlayerMode = 0 then begin + StopCard(0); + end else begin + StopCard(0); + StopCard(1); + end; + end; + 3: begin + StopCard(0); + StopCard(1); + end; + end; + end;} + + {for SC := 0 to High(SoundCard) do begin + StopCard(SC); + end; } + + // 0.5.2 + for SC := 0 to High(Ini.CardList) do begin + P1 := Ini.CardList[SC].ChannelL; + P2 := Ini.CardList[SC].ChannelR; + if P1 > PlayersPlay then P1 := 0; + if P2 > PlayersPlay then P2 := 0; + if (P1 > 0) or (P2 > 0) then StopCard(SC); + end; + +end; + +//procedure TMusic.CaptureCard(RecordI, SoundNum, PlayerLeft, PlayerRight: byte); +procedure TMusic.CaptureCard(RecordI, PlayerLeft, PlayerRight: byte); +var + Error: integer; + ErrorMsg: string; +begin + if not BASS_RecordInit(RecordI) then begin + Error := BASS_ErrorGetCode; + + ErrorMsg := IntToStr(Error); + if Error = BASS_ERROR_DX then ErrorMsg := 'No DX5'; + if Error = BASS_ERROR_ALREADY then ErrorMsg := 'The device has already been initialized'; + if Error = BASS_ERROR_DEVICE then ErrorMsg := 'The device number specified is invalid'; + if Error = BASS_ERROR_DRIVER then ErrorMsg := 'There is no available device driver'; + + {Log.LogAnalyze('Error initializing record [' + IntToStr(RecordI) + ', ' + + IntToStr(PlayerLeft) + ', '+ IntToStr(PlayerRight) + ']: ' + + ErrorMsg);} + Log.LogError('Error initializing record [' + IntToStr(RecordI) + ', ' + + IntToStr(PlayerLeft) + ', '+ IntToStr(PlayerRight) + ']: ' + + ErrorMsg); + Log.LogError('Music -> CaptureCard: Error initializing record: ' + ErrorMsg); + + + end else begin + + //SoundCard[RecordI].BassRecordStream := BASS_RecordStart(44100, 2, MakeLong(0, 20) , @GetMicrophone, PlayerLeft + PlayerRight*256); + Recording.SoundCard[RecordI].BassRecordStream := BASS_RecordStart(44100, 2, MakeLong(0, 20) , @GetMicrophone, PlayerLeft + PlayerRight*256); + + {if SoundCard[RecordI].BassRecordStream = 0 then begin + Error := BASS_ErrorGetCode; + + ErrorMsg := IntToStr(Error); + if Error = BASS_ERROR_INIT then ErrorMsg := 'Not successfully called'; + if Error = BASS_ERROR_ALREADY then ErrorMsg := 'Recording is already in progress'; + if Error = BASS_ERROR_NOTAVAIL then ErrorMsg := 'The recording device is not available'; + if Error = BASS_ERROR_FORMAT then ErrorMsg := 'The specified format is not supported'; + if Error = BASS_ERROR_MEM then ErrorMsg := 'There is insufficent memory'; + if Error = BASS_ERROR_UNKNOWN then ErrorMsg := 'Unknown'; + + Log.LogError('Error creating record stream [' + IntToStr(RecordI) + ', ' + + IntToStr(PlayerLeft) + ', '+ IntToStr(PlayerRight) + ']: ' + + ErrorMsg); + end; } + end; +end; + +procedure TMusic.StopCard(Card: byte); +begin + BASS_RecordSetDevice(Card); + BASS_RecordFree; +end; + +function TMusic.LoadPlayerFromFile(var MediaPlayer: TMediaPlayer; Name: string): boolean; +begin + Log.LogStatus('Loading Sound: "' + Name + '"', 'LoadPlayerFromFile'); + if FileExists(Name) then begin + try + MediaPlayer := TMediaPlayer.Create( nil ); + except + Log.LogError('Failed to create MediaPlayer', 'LoadPlayerFromFile'); + end; + try + MediaPlayer.ParentWindow := fHWND; + MediaPlayer.Wait := true; + MediaPlayer.FileName := Name; + MediaPlayer.DeviceType := dtAutoSelect; + MediaPlayer.Display := nil; + except + Log.LogError('Failed setting MediaPlayer: ' + MediaPlayer.ErrorMessage, 'LoadPlayerFromFile'); + end; + try + MediaPlayer.Open; + except + Log.LogError('Failed to open using MediaPlayer', 'LoadPlayerFromFile'); + end; + end else begin + Log.LogError('Sound not found: "' + Name + '"', 'LoadPlayerFromFile'); + exit; + end; +end; + +function TMusic.LoadSoundFromFile(var hStream: hStream; Name: string): boolean; +var + L: Integer; +begin + if FileExists(Name) then begin + Log.LogStatus('Loading Sound: "' + Name + '"', 'LoadPlayerFromFile'); + try + hStream := BASS_StreamCreateFile(False, pchar(Name), 0, 0, 0); + //Add CustomSound + L := High(CustomSounds) + 1; + SetLength (CustomSounds, L + 1); + CustomSounds[L].Filename := Name; + CustomSounds[L].Handle := hStream; + except + Log.LogError('Failed to open using BASS', 'LoadPlayerFromFile'); + end; + end else begin + Log.LogError('Sound not found: "' + Name + '"', 'LoadPlayerFromFile'); + exit; + end; +end; + +//Equalizer +function TMusic.GetFFTData: TFFTData; +var +Data: TFFTData; +begin + //Get Channel Data Mono and 256 Values + BASS_ChannelGetData(Bass, @Result, BASS_DATA_FFT512); + //Result := Data; +end; + +function TMusic.LoadCustomSound(const Filename: String): Cardinal; +var + S: hStream; + I: Integer; + F: String; +begin + //Search for Sound in already loaded Sounds + F := UpperCase(SoundPath + FileName); + For I := 0 to High(CustomSounds) do + begin + if (UpperCase(CustomSounds[I].Filename) = F) then + begin + Result := I; + Exit; + end; + end; + + if LoadSoundFromFile(S, SoundPath + Filename) then + Result := High(CustomSounds) + else + Result := 0; +end; + +procedure TMusic.PlayCustomSound(const Index: Cardinal); +begin +if Index <= High(CustomSounds) then + BASS_ChannelPlay(CustomSounds[Index].Handle, True); +end; + + +end. diff --git a/Game/Code/Classes/UParty.pas b/Game/Code/Classes/UParty.pas new file mode 100644 index 00000000..7bf3dd1b --- /dev/null +++ b/Game/Code/Classes/UParty.pas @@ -0,0 +1,374 @@ +unit UParty; + +interface + +uses ModiSDK; + +type + TRoundInfo = record + Plugin: Word; + Winner: Byte; + end; + + TeamOrderEntry = record + Teamnum: Byte; + Score: Byte; + end; + + TeamOrderArray = Array[0..5] of Byte; + + TParty_Session = class + private + function GetRandomPlayer(Team: Byte): Byte; + function IsWinner(Player, Winner: Byte): boolean; + procedure GenScores; + public + Teams: TTeamInfo; + Rounds: array of TRoundInfo; + CurRound: Byte; + + constructor Create; + + procedure StartNewParty(NumRounds: Byte); + procedure StartRound; + procedure EndRound; + function GetTeamOrder: TeamOrderArray; + function GetWinnerString(Round: Byte): String; + end; + +var + PartySession: TParty_Session; + +implementation + +uses UDLLManager, UGraphic, UMain, ULanguage, ULog; + +//---------- +//Constructor - Prepares the Class +//---------- +constructor TParty_Session.Create; +begin +// - Nothing in here atm +end; + +//---------- +//StartNewParty - Clears the Class and Prepares for new Party +//---------- +procedure TParty_Session.StartNewParty(NumRounds: Byte); +var + Plugins: Array of record + ID: Byte; + TimesPlayed: Byte; + end; + TeamMode: Boolean; + Len: Integer; + I, J: Integer; + + function GetRandomPlugin: Byte; + var + LowestTP: Byte; + NumPwithLTP: Word; + I: Integer; + R: Word; + begin + LowestTP := high(Byte); + NumPwithLTP := 0; + + //Search for Plugins not often played yet + For I := 0 to high(Plugins) do + begin + if (Plugins[I].TimesPlayed < lowestTP) then + begin + lowestTP := Plugins[I].TimesPlayed; + NumPwithLTP := 1; + end + else if (Plugins[I].TimesPlayed = lowestTP) then + begin + Inc(NumPwithLTP); + end; + end; + + //Create Random No + R := Random(NumPwithLTP); + + //Search for Random Plugin + For I := 0 to high(Plugins) do + begin + if Plugins[I].TimesPlayed = lowestTP then + begin + //Plugin Found + if (R = 0) then + begin + Result := Plugins[I].ID; + Inc(Plugins[I].TimesPlayed); + Break; + end; + + Dec(R); + end; + end; + end; +begin + //Set cur Round to Round 1 + CurRound := 255; + + PlayersPlay := Teams.NumTeams; + + //Get Teammode and Set Joker, also set TimesPlayed + TeamMode := True; + For I := 0 to Teams.NumTeams-1 do + begin + if Teams.Teaminfo[I].NumPlayers < 2 then + begin + TeamMode := False; + end; + //Set Player Attributes + For J := 0 to Teams.TeamInfo[I].NumPlayers-1 do + begin + Teams.TeamInfo[I].Playerinfo[J].TimesPlayed := 0; + end; + Teams.Teaminfo[I].Joker := Round(NumRounds*0.7); + Teams.Teaminfo[I].Score := 0; + end; + + //Fill Plugin Array + SetLength(Plugins, 0); + For I := 0 to high(DLLMan.Plugins) do + begin + if TeamMode or (Not DLLMan.Plugins[I].TeamModeOnly) then + begin //Add only Plugins Playable with cur. PlayerConfiguration + Len := Length(Plugins); + SetLength(Plugins, Len + 1); + Plugins[Len].ID := I; + Plugins[Len].TimesPlayed := 0; + end; + end; + + //Set Rounds + If (Length(Plugins) >= 1) then + begin + SetLength (Rounds, NumRounds); + For I := 0 to NumRounds-1 do + begin + PartySession.Rounds[I].Plugin := GetRandomPlugin; + PartySession.Rounds[I].Winner := 255; + end; + end + else SetLength (Rounds, 0); +end; + +//---------- +//GetRandomPlayer - Gives back a Random Player to Play next Round +//---------- +function TParty_Session.GetRandomPlayer(Team: Byte): Byte; +var + I, R: Integer; + lowestTP: Byte; + NumPwithLTP: Byte; +begin + LowestTP := high(Byte); + NumPwithLTP := 0; + Result := 0; + + //Search for Players that have not often played yet + For I := 0 to Teams.Teaminfo[Team].NumPlayers-1 do + begin + if (Teams.Teaminfo[Team].Playerinfo[I].TimesPlayed < lowestTP) then + begin + lowestTP := Teams.Teaminfo[Team].Playerinfo[I].TimesPlayed; + NumPwithLTP := 1; + end + else if (Teams.Teaminfo[Team].Playerinfo[I].TimesPlayed = lowestTP) then + begin + Inc(NumPwithLTP); + end; + end; + + //Create Random No + R := Random(NumPwithLTP); + + //Search for Random Player + For I := 0 to Teams.Teaminfo[Team].NumPlayers-1 do + begin + if Teams.Teaminfo[Team].Playerinfo[I].TimesPlayed = lowestTP then + begin + //Player Found + if (R = 0) then + begin + Result := I; + Break; + end; + + Dec(R); + end; + end; + {//Get lowest TimesPlayed + lowestTP := high(Byte); + J := -1; + for I := 0 to Teams.Teaminfo[Team].NumPlayers-1 do + begin + if (Teams.Teaminfo[Team].Playerinfo[I].TimesPlayed < lowestTP) then + begin + lowestTP := Teams.Teaminfo[Team].Playerinfo[I].TimesPlayed; + J := I; + end + else if (Teams.Teaminfo[Team].Playerinfo[I].TimesPlayed = lowestTP) then + begin + J := -1; + end; + end; + + //If more than one Person has lowestTP then Select Random Player + if (J < 0) then + repeat + Result := Random(Teams.Teaminfo[Team].NumPlayers); + until (Teams.Teaminfo[Team].Playerinfo[Result].TimesPlayed = lowestTP) + else //Else Select the one with lowest TP + Result:= J;} +end; + +//---------- +//StartNextRound - Prepares ScreenSingModi for Next Round And Load Plugin +//---------- +procedure TParty_Session.StartRound; +var + I: Integer; +begin + if ((CurRound < high(Rounds)) OR (CurRound = high(CurRound))) then + begin + //Increase Current Round + Inc (CurRound); + + Rounds[CurRound].Winner := 255; + DllMan.LoadPlugin(Rounds[CurRound].Plugin); + + //Select Players + for I := 0 to Teams.NumTeams-1 do + Teams.Teaminfo[I].CurPlayer := GetRandomPlayer(I); + + //Set ScreenSingModie Variables + ScreenSingModi.TeamInfo := Teams; + + //Set + end; +end; + +//---------- +//IsWinner - Returns True if the Players Bit is set in the Winner Byte +//---------- +function TParty_Session.IsWinner(Player, Winner: Byte): boolean; +var + Bit: Byte; +begin + Case Player of + 0: Bit := 1; + 1: Bit := 2; + 2: Bit := 4; + 3: Bit := 8; + 4: Bit := 16; + 5: Bit := 32; + end; + + Result := ((Winner AND Bit) = Bit); +end; + +//---------- +//GenScores - Inc Scores for Cur. Round +//---------- +procedure TParty_Session.GenScores; +var + I: Byte; +begin + for I := 0 to Teams.NumTeams-1 do + begin + if isWinner(I, Rounds[CurRound].Winner) then + Inc(Teams.Teaminfo[I].Score); + end; +end; + +//---------- +//GetWinnerString - Get String with WinnerTeam Name, when there is more than one Winner than Connect with and or , +//---------- +function TParty_Session.GetWinnerString(Round: Byte): String; +var + Winners: Array of String; + I: Integer; +begin + Result := Language.Translate('PARTY_NOBODY'); + + if (Round > High(Rounds)) then + exit; + + if (Rounds[Round].Winner = 0) then + begin + exit; + end; + + if (Rounds[Round].Winner = 255) then + begin + Result := Language.Translate('PARTY_NOTPLAYEDYET'); + exit; + end; + + SetLength(Winners, 0); + for I := 0 to Teams.NumTeams-1 do + begin + if isWinner(I, Rounds[Round].Winner) then + begin + SetLength(Winners, Length(Winners) + 1); + Winners[high(Winners)] := Teams.TeamInfo[I].Name; + end; + end; + Result := Language.Implode(Winners); +end; + +//---------- +//EndRound - Get Winner from ScreenSingModi and Save Data to RoundArray +//---------- +procedure TParty_Session.EndRound; +var + I: Integer; +begin + //Copy Winner + Rounds[CurRound].Winner := ScreenSingModi.Winner; + //Set Scores + GenScores; + + //Increase TimesPlayed 4 all Players + For I := 0 to Teams.NumTeams-1 do + Inc(Teams.Teaminfo[I].Playerinfo[Teams.Teaminfo[I].CurPlayer].TimesPlayed); + +end; + +//---------- +//GetTeamOrder - Gives back the Placing of eacb Team [First Position of Array is Teamnum of first placed Team, ...] +//---------- +function TParty_Session.GetTeamOrder: TeamOrderArray; +var + I, J: Integer; + ATeams: array [0..5] of TeamOrderEntry; + TempTeam: TeamOrderEntry; +begin + //Fill Team Array + For I := 0 to Teams.NumTeams-1 do + begin + ATeams[I].Teamnum := I; + ATeams[I].Score := Teams.Teaminfo[I].Score; + end; + + //Sort Teams + for J := 0 to Teams.NumTeams-1 do + for I := 1 to Teams.NumTeams-1 do + if ATeams[I].Score > ATeams[I-1].Score then + begin + TempTeam := ATeams[I-1]; + ATeams[I-1] := ATeams[I]; + ATeams[I] := TempTeam; + end; + + //Copy to Result + For I := 0 to Teams.NumTeams-1 do + Result[I] := ATeams[I].TeamNum; +end; + +end. diff --git a/Game/Code/Classes/UPlaylist.pas b/Game/Code/Classes/UPlaylist.pas new file mode 100644 index 00000000..e3f68239 --- /dev/null +++ b/Game/Code/Classes/UPlaylist.pas @@ -0,0 +1,453 @@ +unit UPlaylist; + +interface + +type + TPlaylistItem = record + Artist: String; + Title: String; + SongID: Integer; + end; + + APlaylistItem = array of TPlaylistItem; + + TPlaylist = record + Name: String; + Filename: String; + Items: APlaylistItem; + end; + + APlaylist = array of TPlaylist; + + //---------- + //TPlaylistManager - Class for Managing Playlists (Loading, Displaying, Saving) + //---------- + TPlaylistManager = class + private + + public + Mode: Byte; //Current Playlist Mode for SongScreen + CurPlayList: Cardinal; + CurItem: Cardinal; + + Playlists: APlaylist; + + constructor Create; + Procedure LoadPlayLists; + Function LoadPlayList(Index: Cardinal; Filename: String): Boolean; + Procedure SavePlayList(Index: Cardinal); + + Procedure SetPlayList(Index: Cardinal); + + Function AddPlaylist(Name: String): Cardinal; + Procedure DelPlaylist(const Index: Cardinal); + + Procedure AddItem(const SongID: Cardinal; const iPlaylist: Integer = -1); + Procedure DelItem(const iItem: Cardinal; const iPlaylist: Integer = -1); + + Procedure GetNames(var PLNames: array of String); + Function GetIndexbySongID(const SongID: Cardinal; const iPlaylist: Integer = -1): Integer; + end; + + {Modes: + 0: Standard Mode + 1: Category Mode + 2: PlayList Mode} + + var + PlayListMan: TPlaylistManager; + + +implementation +uses USongs, ULog, UFiles, UGraphic, UThemes, SysUtils; + +//---------- +//Create - Construct Class - Dummy for now +//---------- +constructor TPlayListManager.Create; +begin + LoadPlayLists; +end; + +//---------- +//LoadPlayLists - Load list of Playlists from PlayList Folder +//---------- +Procedure TPlayListManager.LoadPlayLists; +var + SR: TSearchRec; + Len: Integer; +begin + SetLength(Playlists, 0); + + if FindFirst(PlayListPath + '*.upl', 0, SR) = 0 then + begin + repeat + Len := Length(Playlists); + SetLength(Playlists, Len +1); + + if not LoadPlayList (Len, Sr.Name) then + SetLength(Playlists, Len); + + until FindNext(SR) <> 0; + FindClose(SR); + end; +end; + +//---------- +//LoadPlayList - Load a Playlist in the Array +//---------- +Function TPlayListManager.LoadPlayList(Index: Cardinal; Filename: String): Boolean; + var + F: TextFile; + Line: String; + PosDelimiter: Integer; + SongID: Integer; + Len: Integer; + + Function FindSong(Artist, Title: String): Integer; + var I: Integer; + begin + Result := -1; + + For I := low(CatSongs.Song) to high(CatSongs.Song) do + begin + if (CatSongs.Song[I].Title = Title) AND (CatSongs.Song[I].Artist = Artist) then + begin + Result := I; + Break; + end; + end; + end; +begin + if not FileExists(PlayListPath + Filename) then + begin + Log.LogError('Could not load Playlist: ' + Filename); + Result := False; + Exit; + end; + Result := True; + + //Load File + AssignFile(F, PlayListPath + FileName); + Reset(F); + + //Set Filename + PlayLists[Index].Filename := Filename; + PlayLists[Index].Name := ''; + + //Read Until End of File + While not Eof(F) do + begin + //Read Curent Line + Readln(F, Line); + + if (Length(Line) > 0) then + begin + PosDelimiter := Pos(':', Line); + if (PosDelimiter <> 0) then + begin + //Comment or Name String + if (Line[1] = '#') then + begin + //Found Name Value + if (Uppercase(Trim(copy(Line, 2, PosDelimiter - 2))) = 'NAME') then + PlayLists[Index].Name := Trim(copy(Line, PosDelimiter + 1,Length(Line) - PosDelimiter)) + + end + //Song Entry + else + begin + SongID := FindSong(Trim(copy(Line, 1, PosDelimiter - 1)), Trim(copy(Line, PosDelimiter + 1, Length(Line) - PosDelimiter))); + if (SongID <> -1) then + begin + Len := Length(PlayLists[Index].Items); + SetLength(PlayLists[Index].Items, Len + 1); + + PlayLists[Index].Items[Len].SongID := SongID; + + PlayLists[Index].Items[Len].Artist := Trim(copy(Line, 1, PosDelimiter - 1)); + PlayLists[Index].Items[Len].Title := Trim(copy(Line, PosDelimiter + 1, Length(Line) - PosDelimiter)); + end + else Log.LogError('Could not find Song in Playlist: ' + PlayLists[Index].Filename + ', ' + Line); + end; + end; + end; + end; + + //If no special name is given, use Filename + if PlayLists[Index].Name = '' then + begin + PlayLists[Index].Name := ChangeFileExt(FileName, ''); + end; + + //Finish (Close File) + CloseFile(F); +end; + +//---------- +//SavePlayList - Saves the specified Playlist +//---------- +Procedure TPlayListManager.SavePlayList(Index: Cardinal); +var + F: TextFile; + I: Integer; +begin + if (Not FileExists(PlaylistPath + Playlists[Index].Filename)) OR (Not FileisReadOnly(PlaylistPath + Playlists[Index].Filename)) then + begin + + //open File for Rewriting + AssignFile(F, PlaylistPath + Playlists[Index].Filename); + try + try + Rewrite(F); + + //Write Version (not nessecary but helpful) + WriteLn(F, '######################################'); + WriteLn(F, '#Ultrastar Deluxe Playlist Format v1.0'); + WriteLn(F, '#Playlist "' + Playlists[Index].Name + '" with ' + InttoStr(Length(Playlists[Index].Items)) + ' Songs.'); + WriteLn(F, '######################################'); + + //Write Name Information + WriteLn(F, '#Name: ' + Playlists[Index].Name); + + //Write Song Information + WriteLn(F, '#Songs:'); + + For I := 0 to high(Playlists[Index].Items) do + begin + WriteLn(F, Playlists[Index].Items[I].Artist + ' : ' + Playlists[Index].Items[I].Title); + end; + except + log.LogError('Could not write Playlistfile "' + Playlists[Index].Name + '"'); + end; + finally + CloseFile(F); + end; + end; +end; + +//---------- +//SetPlayList - Display a Playlist in CatSongs +//---------- +Procedure TPlayListManager.SetPlayList(Index: Cardinal); +var + I: Integer; +begin + If (Index > High(PlayLists)) then + exit; + + //Hide all Songs + For I := 0 to high(CatSongs.Song) do + CatSongs.Song[I].Visible := False; + + //Show Songs in PL + For I := 0 to high(PlayLists[Index].Items) do + begin + CatSongs.Song[PlayLists[Index].Items[I].SongID].Visible := True; + end; + + //Set CatSongsMode + Playlist Mode + CatSongs.CatNumShow := -3; + Mode := 2; + + //Set CurPlaylist + CurPlaylist := Index; + + //Show Cat in Topleft: + ScreenSong.ShowCatTLCustom(Format(Theme.Playlist.CatText,[Playlists[Index].Name])); + + //Fix SongSelection + ScreenSong.Interaction := 0; + ScreenSong.SelectNext; + ScreenSong.FixSelected; + + //Play correct Music + ScreenSong.ChangeMusic; +end; + +//---------- +//AddPlaylist - Adds a Playlist and Returns the Index +//---------- +Function TPlayListManager.AddPlaylist(Name: String): Cardinal; +var I: Integer; +begin + Result := Length(Playlists); + SetLength(Playlists, Result + 1); + + Playlists[Result].Name := Name; + + I := 1; + + if (not FileExists(PlaylistPath + Name + '.upl')) then + Playlists[Result].Filename := Name + '.upl' + else + begin + repeat + Inc(I); + until not FileExists(PlaylistPath + Name + InttoStr(I) + '.upl'); + Playlists[Result].Filename := Name + InttoStr(I) + '.upl'; + end; + + //Save new Playlist + SavePlayList(Result); +end; + +//---------- +//DelPlaylist - Deletes a Playlist +//---------- +Procedure TPlayListManager.DelPlaylist(const Index: Cardinal); +var + I: Integer; + Filename: String; +begin + If Index > High(Playlists) then + Exit; + + Filename := PlaylistPath + Playlists[Index].Filename; + + //If not FileExists or File is not Writeable then exit + If (Not FileExists(Filename)) OR (FileisReadOnly(Filename)) then + Exit; + + + //Delete Playlist from FileSystem + if Not DeleteFile(Filename) then + Exit; + + //Delete Playlist from Array + //move all PLs to the Hole + For I := Index to High(Playlists)-1 do + PlayLists[I] := PlayLists[I+1]; + + //Delete last Playlist + SetLength (Playlists, High(Playlists)); + + //If Playlist is Displayed atm + //-> Display Songs + if (CatSongs.CatNumShow = -3) and (Index = CurPlaylist) then + begin + ScreenSong.UnLoadDetailedCover; + ScreenSong.HideCatTL; + CatSongs.SetFilter('', 0); + ScreenSong.Interaction := 0; + ScreenSong.FixSelected; + ScreenSong.ChangeMusic; + end; +end; + +//---------- +//AddItem - Adds an Item to a specific Playlist +//---------- +Procedure TPlayListManager.AddItem(const SongID: Cardinal; const iPlaylist: Integer); +var + P: Cardinal; + Len: Cardinal; +begin + if iPlaylist = -1 then + P := CurPlaylist + else if (iPlaylist >= 0) AND (iPlaylist <= high(Playlists)) then + P := iPlaylist + else + exit; + + if (SongID <= High(CatSongs.Song)) AND (NOT CatSongs.Song[SongID].Main) then + begin + Len := Length(Playlists[P].Items); + SetLength(Playlists[P].Items, Len + 1); + + Playlists[P].Items[Len].SongID := SongID; + Playlists[P].Items[Len].Title := CatSongs.Song[SongID].Title; + Playlists[P].Items[Len].Artist := CatSongs.Song[SongID].Artist; + + //Save Changes + SavePlayList(P); + + //Correct Display when Editing current Playlist + if (CatSongs.CatNumShow = -3) and (P = CurPlaylist) then + SetPlaylist(P); + end; +end; + +//---------- +//DelItem - Deletes an Item from a specific Playlist +//---------- +Procedure TPlayListManager.DelItem(const iItem: Cardinal; const iPlaylist: Integer); +var + I: Integer; + P: Cardinal; +begin + if iPlaylist = -1 then + P := CurPlaylist + else if (iPlaylist >= 0) AND (iPlaylist <= high(Playlists)) then + P := iPlaylist + else + exit; + + if (iItem <= high(Playlists[P].Items)) then + begin + //Move all entrys behind deleted one to Front + For I := iItem to High(Playlists[P].Items) - 1 do + Playlists[P].Items[I] := Playlists[P].Items[I + 1]; + + //Delete Last Entry + SetLength(PlayLists[P].Items, Length(PlayLists[P].Items) - 1); + + //Save Changes + SavePlayList(P); + end; + + //Delete Playlist if Last Song is deleted + if (Length(PlayLists[P].Items) = 0) then + begin + DelPlaylist(P); + end + //Correct Display when Editing current Playlist + else if (CatSongs.CatNumShow = -3) and (P = CurPlaylist) then + SetPlaylist(P); +end; + +//---------- +//GetNames - Writes Playlist Names in a Array +//---------- +Procedure TPlayListManager.GetNames(var PLNames: array of String); +var + I: Integer; + Len: Integer; +begin + Len := High(Playlists); + + if (Length(PLNames) <> Len + 1) then + exit; + + For I := 0 to Len do + PLNames[I] := Playlists[I].Name; +end; + +//---------- +//GetIndexbySongID - Returns Index in the specified Playlist of the given Song +//---------- +Function TPlayListManager.GetIndexbySongID(const SongID: Cardinal; const iPlaylist: Integer): Integer; +var + P: Integer; + I: Integer; +begin + if iPlaylist = -1 then + P := CurPlaylist + else if (iPlaylist >= 0) AND (iPlaylist <= high(Playlists)) then + P := iPlaylist + else + exit; + + Result := -1; + + For I := 0 to high(Playlists[P].Items) do + begin + if (Playlists[P].Items[I].SongID = SongID) then + begin + Result := I; + Break; + end; + end; +end; + +end. diff --git a/Game/Code/Classes/UPliki.pas b/Game/Code/Classes/UPliki.pas new file mode 100644 index 00000000..f7692990 --- /dev/null +++ b/Game/Code/Classes/UPliki.pas @@ -0,0 +1,833 @@ +unit UPliki; + +interface + +uses USongs, SysUtils, ULog, UMusic; + +procedure InitializePaths; +function ReadHeader(var Song: TSong): boolean; +function SkanujPlik(var Song: TSong): boolean; +procedure CzyscNuty; +function WczytajCzesci(Name: string): boolean; +function SaveSong(Song: TSong; Czesc: TCzesci; Name: string; Relative: boolean): boolean; +function SaveSongDebug(Song: TSong; Czesc: TCzesci; Name: string; Relative: boolean): boolean; + +var + GamePath: string; + SoundPath: string; + SongPath: string; + LogPath: string; + ThemePath: string; + ScreenshotsPath: string; + CoversPath: string; + LanguagesPath: string; + PluginPath: string; + PlayListPath: string; + + Plik: TextFile; // all procedures in this unit operates on this file + PlikC: char; + Lineno: integer; + + // variables available for all procedures + Base: array[0..1] of integer; + Rel: array[0..1] of integer; + Mult: integer; + MultBPM: integer; + +implementation +uses TextGL, UIni, UMain, math; + +procedure InitializePaths; +begin + GamePath := ExtractFilePath(ParamStr(0)); + SoundPath := GamePath + 'Sounds\'; + SongPath := GamePath + 'Songs\'; + LogPath := GamePath; + ThemePath := GamePath + 'Themes\'; + ScreenshotsPath := GamePath + 'Screenshots\'; + CoversPath := GamePath + 'Covers\'; + LanguagesPath := GamePath + 'Languages\'; + //Modi Loader + PluginPath := GamePath + 'Plugins\'; + + PlaylistPath := GamePath + 'Playlists\'; + + DecimalSeparator := ','; +end; + +function ReadHeader(var Song: TSong): boolean; +var + TempC: char; + Tekst: string; + Done: integer; +begin + // clear + Song.Title := ''; + Song.Artist := ''; + Song.Genre := 'Unknown'; + Song.Edition := 'Unknown'; + Song.Language := 'Unknown'; //Language Patch + Song.Mp3 := ''; + Song.BPM := 0; + Song.GAP := 0; + Song.Start := 0; + Song.Finish := 0; + Song.Background := ''; + Song.Video := ''; + Song.VideoGAP := 0; + Song.NotesGAP := 0; + Song.Resolution := 4; + + //Creator Patch + Song.Creator := ''; + + Done := 0; + + //Editor Error Reporting Hack + LineNo := 0; + try + + // read + Read(Plik, PlikC); + while (PlikC = '#') do begin + ReadLn(Plik, Tekst); + + //Editor Error Reporting Hack + Inc (LineNo); + + //Header Improvements Patch + + if UpperCase(Copy(Tekst, 1, 6)) = 'TITLE:' then begin + Delete(Tekst, 1, 6); + Song.Title := Trim(Tekst); + Tekst := ''; + Done := Done or 1; + end + + else if UpperCase(Copy(Tekst, 1, 7)) = 'ARTIST:' then begin + Delete(Tekst, 1, 7); + Song.Artist := Trim(Tekst); + Tekst := ''; + Done := Done or 2; + end + + else if UpperCase(Copy(Tekst, 1, 4)) = 'MP3:' then begin + Delete(Tekst, 1, 4); + Song.Mp3 := Trim(Tekst); + Tekst := ''; + Done := Done or 4; + end + + else if UpperCase(Copy(Tekst, 1, 8)) = 'CREATOR:' then begin // this goes for edit + Delete(Tekst, 1, 8); + Song.Creator := Trim(Tekst); + Tekst := ''; + end + + else if UpperCase(Copy(Tekst, 1, 6)) = 'GENRE:' then begin // this goes for edit + Delete(Tekst, 1, 6); + Song.Genre := Trim(Tekst); + Tekst := ''; + end + + else if UpperCase(Copy(Tekst, 1, 8)) = 'EDITION:' then begin // this goes for edit + Delete(Tekst, 1, 8); + Song.Edition := Trim(Tekst); + Tekst := ''; + end + + else if UpperCase(Copy(Tekst, 1, 9)) = 'LANGUAGE:' then begin // this goes for edit + Delete(Tekst, 1, 9); + Song.Language := Trim(Tekst); + Tekst := ''; + end + + else if UpperCase(Copy(Tekst, 1, 6)) = 'COVER:' then begin + Delete(Tekst, 1, 6); + Song.Cover := Trim(Tekst); + Tekst := ''; + end + + else if UpperCase(Copy(Tekst, 1, 11)) = 'BACKGROUND:' then begin + Delete(Tekst, 1, 11); + Song.Background := Trim(Tekst); + Tekst := ''; + end + + else if UpperCase(Copy(Tekst, 1, 6)) = 'VIDEO:' then begin + Delete(Tekst, 1, 6); + Song.Video := Trim(Tekst); + Tekst := ''; + end + + else if UpperCase(Copy(Tekst, 1, 9)) = 'VIDEOGAP:' then begin + Delete(Tekst, 1, 9); + + //Change . to , Mod by Whiteshark :P + if (Pos('.',Tekst) <> 0) then + begin + Tekst[Pos('.',Tekst)] := ','; + //Little Annonce for the User + Log.LogError('VideoGap Seperator wrong in SongHeader: ' + Song.FileName + ' [Corrected for this Session]'); + end; + + Song.VideoGAP := StrToFloat(Tekst); + Tekst := '' + end + + else if UpperCase(Copy(Tekst, 1, 9)) = 'NOTESGAP:' then begin + Delete(Tekst, 1, 9); + Song.NotesGAP := StrToInt(Tekst); + Tekst := '' + end + + else if UpperCase(Copy(Tekst, 1, 9)) = 'RELATIVE:' then begin + Delete(Tekst, 1, 9); + if LowerCase(Tekst) = 'yes' then Song.Relative := true; + end + + else if UpperCase(Copy(Tekst, 1, 6)) = 'START:' then begin + Delete(Tekst, 1, 6); + Song.Start := StrToFloat(Tekst); +// Muzyka.Start := StrToInt(Tekst); + end + + else if UpperCase(Copy(Tekst, 1, 4)) = 'END:' then begin + Delete(Tekst, 1, 4); + Song.Finish := StrToInt(Tekst); + end + + else if UpperCase(Copy(Tekst, 1, 11)) = 'RESOLUTION:' then begin + Delete(Tekst, 1, 11); + Song.Resolution := StrToInt(Tekst); + end + + else if UpperCase(Copy(Tekst, 1, 4)) = 'BPM:' then begin + Delete(Tekst, 1, 4); + +// Muzyka.BPMOld := StrToFloat(Tekst) * Mult * MultBPM; // old system + + (* new system with variable BPM *) +// Muzyka.BPMOld := 50; + + //Change . to , Mod by Whiteshark :P + if (Pos('.',Tekst) <> 0) then + begin + Tekst[Pos('.',Tekst)] := ','; + //Little Annonce for the User + Log.LogError('BPM Seperator wrong in SongHeader: ' + Song.FileName + ' [Corrected for this Session]'); + end; + + SetLength(Song.BPM, 1); + Song.BPM[0].StartBeat := 0; + Song.BPM[0].BPM := StrToFloat(Tekst) * Mult * MultBPM; + Tekst := ''; + Done := Done or 8; + end + + else if UpperCase(Copy(Tekst, 1, 4)) = 'GAP:' then begin + Delete(Tekst, 1, 4); + Song.GAP := StrToFloat(Tekst); + Tekst := ''; +// Muzyka.GAP := StrToFloat(Tekst); +// Done := Done or 16; + end; + + //Header Improvements Patch Ende + + Read(Plik, PlikC); + end; + + //Editor Error Reporting Hack + except //An Error happened<- bad english :P + Log.LogError('An Error occured reading Line ' + inttostr(LineNo) + ' from SongHeader: ' + Song.FileName); + Halt; + end; + //Editor Error Reporting Hack End + + if Song.Background = '' then begin + Song.Background := Songs.FindSongFile(Song.Path, '*[BG].jpg'); + end; + + if (Done and 15) = 15 then Result := true + else Result := false; +end; + +function SkanujPlik(var Song: TSong): boolean; +var + Done: integer; + Tekst: string; + C: integer; // category + P: integer; // position +begin +// try + AssignFile(Plik, Song.Path + Song.FileName); + Reset(Plik); + + Result := ReadHeader(Song); + +{ ReadLn(Plik, Tekst); + while (Copy(Tekst, 1, 1) = '#') do begin + if Copy(Tekst, 1, 10) = '#CATEGORY:' then begin + Delete(Tekst, 1, 10); + + Trim(Tekst); + while (Length(Tekst) > 0) do begin + C := Length(Song.Category); + SetLength(Song.Category, C+1); + + P := Pos(',', Tekst); + if P = 0 then P := Length(Tekst); + Song.Category[C] := Copy(Tekst, 1, P); + + Delete(Tekst, 1, P); + Trim(Tekst); + end; + + end;} + + +end; + +procedure CzyscNuty; +var + Pet: integer; +begin + SetLength(Czesci, Length(Player)); + SetLength(AktSong.BPM, 0); + for Pet := 0 to High(Player) do begin + SetLength(Czesci[Pet].Czesc, 1); + SetLength(Czesci[Pet].Czesc[0].Nuta, 0); + Czesci[Pet].Czesc[0].Lyric := ''; + Czesci[Pet].Czesc[0].LyricWidth := 0; + Player[pet].Score := 0; + Player[pet].IlNut := 0; + Player[pet].HighNut := -1; + end; +end; + +procedure DodajNute(NrCzesci: integer; TypeP: char; StartP, DurationP, NoteP: integer; LyricS: string); +var + Space: boolean; +begin + case Ini.Solmization of + 1: // european + begin + case (NoteP mod 12) of + 0..1: LyricS := ' do '; + 2..3: LyricS := ' re '; + 4: LyricS := ' mi '; + 5..6: LyricS := ' fa '; + 7..8: LyricS := ' sol '; + 9..10: LyricS := ' la '; + 11: LyricS := ' si '; + end; + end; + 2: // japanese + begin + case (NoteP mod 12) of + 0..1: LyricS := ' do '; + 2..3: LyricS := ' re '; + 4: LyricS := ' mi '; + 5..6: LyricS := ' fa '; + 7..8: LyricS := ' so '; + 9..10: LyricS := ' la '; + 11: LyricS := ' shi '; + end; + end; + 3: // american + begin + case (NoteP mod 12) of + 0..1: LyricS := ' do '; + 2..3: LyricS := ' re '; + 4: LyricS := ' mi '; + 5..6: LyricS := ' fa '; + 7..8: LyricS := ' sol '; + 9..10: LyricS := ' la '; + 11: LyricS := ' ti '; + end; + end; + end; // case + +// Log.LogStatus('Czesc: ' + IntToStr(Czesci[NrCzesci].High), 'DodajNute'); +// Log.LogStatus('Dodano: [' + IntToStr(NrCzesci) + '] ' + IntToStr(StartP) + ' ' +// + IntToStr(DurationP) + ' '+ IntToStr(NoteP) + ' ' + LyricS, 'DodajNute'); + +{ Delete(LyricS, 1, 1); + Space := false; + if Copy(LyricS, Length(LyricS), 1) = ' ' then begin + Space := true; + Delete(LyricS, Length(LyricS), 1); + end; + if LyricS = 'a' then LyricS := chr($B1); + if LyricS = 'i' then LyricS := chr($B2); + if LyricS = 'u' then LyricS := chr($B3); + if LyricS = 'e' then LyricS := chr($B4); + if LyricS = 'o' then LyricS := chr($B5); + + if LyricS = 'ka' then LyricS := chr($B6); + if LyricS = 'ki' then LyricS := chr($B7); + if LyricS = 'ku' then LyricS := chr($B8); + if LyricS = 'ke' then LyricS := chr($B9); + if LyricS = 'ko' then LyricS := chr($BA); + + if LyricS = 'ga' then LyricS := chr($B6) + chr($DE); + if LyricS = 'gi' then LyricS := chr($B7) + chr($DE); + if LyricS = 'gu' then LyricS := chr($B8) + chr($DE); + if LyricS = 'ge' then LyricS := chr($B9) + chr($DE); + if LyricS = 'go' then LyricS := chr($BA) + chr($DE); + + if LyricS = 'sa' then LyricS := chr($BB); + if LyricS = 'shi' then LyricS := chr($BC); + if LyricS = 'su' then LyricS := chr($BD); + if LyricS = 'se' then LyricS := chr($BE); + if LyricS = 'so' then LyricS := chr($BF); + + if LyricS = 'za' then LyricS := chr($BB) + chr($DE); + if LyricS = 'ji' then LyricS := chr($BC) + chr($DE); + if LyricS = 'zu' then LyricS := chr($BD) + chr($DE); + if LyricS = 'ze' then LyricS := chr($BE) + chr($DE); + if LyricS = 'zo' then LyricS := chr($BF) + chr($DE); + + if LyricS = 'ta' then LyricS := chr($C0); + if LyricS = 'chi' then LyricS := chr($C1); + if LyricS = 'tsu' then LyricS := chr($C2); + if LyricS = 'te' then LyricS := chr($C3); + if LyricS = 'to' then LyricS := chr($C4); + + if LyricS = 'da' then LyricS := chr($C0) + chr($DE); +// if LyricS = 'ji' then LyricS := chr($C1) + chr($DE); +// if LyricS = 'zu' then LyricS := chr($C2) + chr($DE); + if LyricS = 'de' then LyricS := chr($C3) + chr($DE); + if LyricS = 'do' then LyricS := chr($C4) + chr($DE); + + if LyricS = 'na' then LyricS := chr($C5); + if LyricS = 'ni' then LyricS := chr($C6); + if LyricS = 'nu' then LyricS := chr($C7); + if LyricS = 'ne' then LyricS := chr($C8); + if LyricS = 'no' then LyricS := chr($C9); + + if LyricS = 'ha' then LyricS := chr($CA); + if LyricS = 'hi' then LyricS := chr($CB); + if LyricS = 'hu' then LyricS := chr($CC); + if LyricS = 'he' then LyricS := chr($CD); + if LyricS = 'ho' then LyricS := chr($CE); + + if LyricS = 'ba' then LyricS := chr($CA) + chr($DE); + if LyricS = 'bi' then LyricS := chr($CB) + chr($DE); + if LyricS = 'bu' then LyricS := chr($CC) + chr($DE); + if LyricS = 'be' then LyricS := chr($CD) + chr($DE); + if LyricS = 'bo' then LyricS := chr($CE) + chr($DE); + + if LyricS = 'pa' then LyricS := chr($CA) + chr($DF); + if LyricS = 'pi' then LyricS := chr($CB) + chr($DF); + if LyricS = 'pu' then LyricS := chr($CC) + chr($DF); + if LyricS = 'pe' then LyricS := chr($CD) + chr($DF); + if LyricS = 'po' then LyricS := chr($CE) + chr($DF); + + if LyricS = 'ma' then LyricS := chr($CF); + if LyricS = 'mi' then LyricS := chr($D0); + if LyricS = 'mu' then LyricS := chr($D1); + if LyricS = 'me' then LyricS := chr($D2); + if LyricS = 'mo' then LyricS := chr($D3); + + if LyricS = 'ya' then LyricS := chr($D4); + if LyricS = 'yu' then LyricS := chr($D5); + if LyricS = 'yo' then LyricS := chr($D6); + + if LyricS = 'ra' then LyricS := chr($D7); + if LyricS = 'ri' then LyricS := chr($D8); + if LyricS = 'ru' then LyricS := chr($D9); + if LyricS = 're' then LyricS := chr($DA); + if LyricS = 'ro' then LyricS := chr($DB); + + if LyricS = 'wa' then LyricS := chr($DC); + if LyricS = 'n' then LyricS := chr($DD); + + LyricS := ' ' + LyricS; + if Space then LyricS := LyricS + ' ';} + + + + with Czesci[NrCzesci].Czesc[Czesci[NrCzesci].High] do begin + SetLength(Nuta, Length(Nuta) + 1); + IlNut := IlNut + 1; + HighNut := HighNut + 1; + Muzyka.IlNut := Muzyka.IlNut + 1; + + Nuta[HighNut].Start := StartP; + if IlNut = 1 then begin + StartNote := Nuta[HighNut].Start; + if Czesci[NrCzesci].Ilosc = 1 then + Start := -100; +// Start := Nuta[HighNut].Start; + end; + + Nuta[HighNut].Dlugosc := DurationP; + Muzyka.DlugoscNut := Muzyka.DlugoscNut + Nuta[HighNut].Dlugosc; + + // back to the normal system with normal, golden and now freestyle notes + case TypeP of + 'F': Nuta[HighNut].Wartosc := 0; + ':': Nuta[HighNut].Wartosc := 1; + '*': Nuta[HighNut].Wartosc := 2; + end; + Czesci[NrCzesci].Wartosc := Czesci[NrCzesci].Wartosc + Nuta[HighNut].Dlugosc * Nuta[HighNut].Wartosc; + + Nuta[HighNut].Ton := NoteP; + if Nuta[HighNut].Ton < Base[NrCzesci] then Base[NrCzesci] := Nuta[HighNut].Ton; + Nuta[HighNut].TonGamy := Nuta[HighNut].TonGamy mod 12; + + Nuta[HighNut].Tekst := Copy(LyricS, 2, 100); + Lyric := Lyric + Nuta[HighNut].Tekst; + + if TypeP = 'F' then + Nuta[HighNut].FreeStyle := true; + + Koniec := Nuta[HighNut].Start + Nuta[HighNut].Dlugosc; + end; // with +end; + +procedure NewSentence(NrCzesciP: integer; Param1, Param2: integer); +var +I: Integer; +begin +// Log.LogStatus('IlCzesci: ' + IntToStr(Czesci[NrCzesciP].Ilosc), 'NewSentece'); +// Log.LogStatus('Dane: ' + IntToStr(NrCzesciP) + ' ' + IntToStr(Param1) + ' ' + IntToStr(Param2) , 'NewSentece'); + + // stara czesc //Alter Satz //Update Old Part + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].BaseNote := Base[NrCzesciP]; + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].LyricWidth := glTextWidth(PChar(Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Lyric)); + + //Total Notes Patch + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].TotalNotes := 0; + for I := low(Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Nuta) to high(Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Nuta) do + begin + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].TotalNotes := Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].TotalNotes + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Nuta[I].Dlugosc * Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Nuta[I].Wartosc; + end; + //Log.LogError('Total Notes(' + inttostr(Czesci[NrCzesciP].High) +'): ' + inttostr(Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].TotalNotes)); + //Total Notes Patch End + + + // nowa czesc //Neuer Satz //Update New Part + SetLength(Czesci[NrCzesciP].Czesc, Czesci[NrCzesciP].Ilosc + 1); + Czesci[NrCzesciP].High := Czesci[NrCzesciP].High + 1; + Czesci[NrCzesciP].Ilosc := Czesci[NrCzesciP].Ilosc + 1; + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].HighNut := -1; + + if not AktSong.Relative then + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Start := Param1; + + if AktSong.Relative then begin + Czesci[NrCzesciP].Czesc[Czesci[NrCzesciP].High].Start := Param1; + Rel[NrCzesciP] := Rel[NrCzesciP] + Param2; + end; + + Base[NrCzesciP] := 100; // high number +end; + +function WczytajCzesci(Name: string): boolean; +var + TempC: char; + Tekst: string; + CP: integer; // Current Player (0 or 1) + Pet: integer; + Both: boolean; + Param1: integer; + Param2: integer; + Param3: integer; + ParamS: string; + I: Integer; +begin + Result := false; + + if not FileExists(Name) then begin + Log.LogError('File not found: "' + Name + '"', 'WczytajCzesci'); + exit; + end; + + try + MultBPM := 4; // 4 - mnoznik dla czasu nut + Mult := 1; // 4 - dokladnosc pomiaru nut + Base[0] := 100; // high number +// Base[1] := 100; // high number + Czesci[0].Wartosc := 0; +// Czesci[1].Wartosc := 0; // here was the error in 0.3.2 + AktSong.Relative := false; + + Rel[0] := 0; +// Rel[1] := 0; + CP := 0; + Both := false; + if Length(Player) = 2 then Both := true; + + FileMode := fmOpenRead; + AssignFile(Plik, Name); + Reset(Plik); + + ReadHeader(AktSong); +(* if AktSong.Title = 'Hubba Hubba Zoot Zoot' then begin + Mult := 2; + AktSong.BPM[0].BPM := AktSong.BPM[0].BPM * 2; + end;*) + + SetLength(Czesci, 2); + for Pet := 0 to High(Czesci) do begin + SetLength(Czesci[Pet].Czesc, 1); + Czesci[Pet].High := 0; + Czesci[Pet].Ilosc := 1; + Czesci[Pet].Akt := 0; + Czesci[Pet].Resolution := AktSong.Resolution; + Czesci[Pet].NotesGAP := AktSong.NotesGAP; + Czesci[Pet].Czesc[0].IlNut := 0; + Czesci[Pet].Czesc[0].HighNut := -1; + end; + +// TempC := ':'; + TempC := PlikC; // read from backup variable, don't use default ':' value + + while (TempC <> 'E') do begin + Inc(LineNo); + if (TempC = ':') or (TempC = '*') or (TempC = 'F') then begin + // wczytuje nute + Read(Plik, Param1); + Read(Plik, Param2); + Read(Plik, Param3); + Read(Plik, ParamS); + + // dodaje nute + if not Both then + // P1 + DodajNute(0, TempC, (Param1+Rel[0]) * Mult, Param2 * Mult, Param3, ParamS) + else begin + // P1 + P2 + DodajNute(0, TempC, (Param1+Rel[0]) * Mult, Param2 * Mult, Param3, ParamS); + DodajNute(1, TempC, (Param1+Rel[1]) * Mult, Param2 * Mult, Param3, ParamS); + end; + end; // if + if TempC = '-' then begin + // reads sentence + Read(Plik, Param1); + if AktSong.Relative then Read(Plik, Param2); // read one more data for relative system + + // new sentence + if not Both then + // P1 + NewSentence(0, (Param1 + Rel[0]) * Mult, Param2) + else begin + // P1 + P2 + NewSentence(0, (Param1 + Rel[0]) * Mult, Param2); + NewSentence(1, (Param1 + Rel[1]) * Mult, Param2); + end; + + end; // if + + if TempC = 'B' then begin + SetLength(AktSong.BPM, Length(AktSong.BPM) + 1); + Read(Plik, AktSong.BPM[High(AktSong.BPM)].StartBeat); + AktSong.BPM[High(AktSong.BPM)].StartBeat := AktSong.BPM[High(AktSong.BPM)].StartBeat + Rel[0]; + + Read(Plik, Tekst); + AktSong.BPM[High(AktSong.BPM)].BPM := StrToFloat(Tekst); + AktSong.BPM[High(AktSong.BPM)].BPM := AktSong.BPM[High(AktSong.BPM)].BPM * Mult * MultBPM; + end; + + + if not Both then begin + Czesci[CP].Czesc[Czesci[CP].High].BaseNote := Base[CP]; + Czesci[CP].Czesc[Czesci[CP].High].LyricWidth := glTextWidth(PChar(Czesci[CP].Czesc[Czesci[CP].High].Lyric)); + //Total Notes Patch + Czesci[CP].Czesc[Czesci[CP].High].TotalNotes := 0; + for I := low(Czesci[CP].Czesc[Czesci[CP].High].Nuta) to high(Czesci[CP].Czesc[Czesci[CP].High].Nuta) do + begin + Czesci[CP].Czesc[Czesci[CP].High].TotalNotes := Czesci[CP].Czesc[Czesci[CP].High].TotalNotes + Czesci[CP].Czesc[Czesci[CP].High].Nuta[I].Dlugosc * Czesci[CP].Czesc[Czesci[CP].High].Nuta[I].Wartosc; + end; + //Total Notes Patch End + end else begin + for Pet := 0 to High(Czesci) do begin + Czesci[Pet].Czesc[Czesci[Pet].High].BaseNote := Base[Pet]; + Czesci[Pet].Czesc[Czesci[Pet].High].LyricWidth := glTextWidth(PChar(Czesci[Pet].Czesc[Czesci[Pet].High].Lyric)); + //Total Notes Patch + Czesci[Pet].Czesc[Czesci[Pet].High].TotalNotes := 0; + for I := low(Czesci[Pet].Czesc[Czesci[Pet].High].Nuta) to high(Czesci[Pet].Czesc[Czesci[Pet].High].Nuta) do + begin + Czesci[Pet].Czesc[Czesci[Pet].High].TotalNotes := Czesci[Pet].Czesc[Czesci[Pet].High].TotalNotes + Czesci[Pet].Czesc[Czesci[Pet].High].Nuta[I].Dlugosc * Czesci[Pet].Czesc[Czesci[Pet].High].Nuta[I].Wartosc; + end; + //Total Notes Patch End + end; + end; + + Read(Plik, TempC); + end; // while} + + CloseFile(Plik); + except + Log.LogError('Error Loading File: "' + Name + '" in Line ' + inttostr(LineNo)); + exit; + end; + + Result := true; +end; + +function SaveSong(Song: TSong; Czesc: TCzesci; Name: string; Relative: boolean): boolean; +var + C: integer; + N: integer; + S: string; + B: integer; + RelativeSubTime: integer; + NoteState: String; + +begin +// Relative := true; // override (idea - use shift+S to save with relative) + AssignFile(Plik, Name); + Rewrite(Plik); + + WriteLn(Plik, '#TITLE:' + Song.Title + ''); + WriteLn(Plik, '#ARTIST:' + Song.Artist); + + if Song.Creator <> '' then WriteLn(Plik, '#CREATOR:' + Song.Creator); + if Song.Edition <> 'Unknown' then WriteLn(Plik, '#EDITION:' + Song.Edition); + if Song.Genre <> 'Unknown' then WriteLn(Plik, '#GENRE:' + Song.Genre); + if Song.Language <> 'Unknown' then WriteLn(Plik, '#LANGUAGE:' + Song.Language); + if Song.Cover <> '' then WriteLn(Plik, '#COVER:' + Song.Cover); + + WriteLn(Plik, '#MP3:' + Song.Mp3); + + if Song.Background <> '' then WriteLn(Plik, '#BACKGROUND:' + Song.Background); + if Song.Video <> '' then WriteLn(Plik, '#VIDEO:' + Song.Video); + if Song.VideoGAP <> 0 then WriteLn(Plik, '#VIDEOGAP:' + FloatToStr(Song.VideoGAP)); + if Song.Resolution <> 4 then WriteLn(Plik, '#RESOLUTION:' + IntToStr(Song.Resolution)); + if Song.NotesGAP <> 0 then WriteLn(Plik, '#NOTESGAP:' + IntToStr(Song.NotesGAP)); + if Song.Start <> 0 then WriteLn(Plik, '#START:' + FloatToStr(Song.Start)); + if Song.Finish <> 0 then WriteLn(Plik, '#END:' + IntToStr(Song.Finish)); + if Relative then WriteLn(Plik, '#RELATIVE:yes'); + + WriteLn(Plik, '#BPM:' + FloatToStr(Song.BPM[0].BPM / 4)); + WriteLn(Plik, '#GAP:' + FloatToStr(Song.GAP)); + + RelativeSubTime := 0; + for B := 1 to High(AktSong.BPM) do + WriteLn(Plik, 'B ' + FloatToStr(AktSong.BPM[B].StartBeat) + ' ' + FloatToStr(AktSong.BPM[B].BPM/4)); + + for C := 0 to Czesc.High do begin + for N := 0 to Czesc.Czesc[C].HighNut do begin + with Czesc.Czesc[C].Nuta[N] do begin + + + //Golden + Freestyle Note Patch + case Czesc.Czesc[C].Nuta[N].Wartosc of + 0: NoteState := 'F '; + 1: NoteState := ': '; + 2: NoteState := '* '; + end; // case + S := NoteState + IntToStr(Start-RelativeSubTime) + ' ' + IntToStr(Dlugosc) + ' ' + IntToStr(Ton) + ' ' + Tekst; + + + WriteLn(Plik, S); + end; // with + end; // N + + if C < Czesc.High then begin // don't write end of last sentence + if not Relative then + S := '- ' + IntToStr(Czesc.Czesc[C+1].Start) + else begin + S := '- ' + IntToStr(Czesc.Czesc[C+1].Start - RelativeSubTime) + + ' ' + IntToStr(Czesc.Czesc[C+1].Start - RelativeSubTime); + RelativeSubTime := Czesc.Czesc[C+1].Start; + end; + WriteLn(Plik, S); + end; + + end; // C + + + WriteLn(Plik, 'E'); + CloseFile(Plik); +end; + +function SaveSongDebug(Song: TSong; Czesc: TCzesci; Name: string; Relative: boolean): boolean; +var + C: integer; + N: integer; + S: string; + STon: integer; + SLen: integer; + NTot: integer; + PlikB: TextFile; + LastTime: integer; +begin + AssignFile(Plik, Name); + Rewrite(Plik); + + AssignFile(PlikB, 'C:\song db.asm'); + Rewrite(PlikB); + + NTot := 0; + LastTime := 0; + + for C := 0 to Czesc.High do begin + WriteLn(Plik, '; ' + IntToStr(C)); + + for N := 0 to Czesc.Czesc[C].HighNut do begin + with Czesc.Czesc[C].Nuta[N] do begin + + // timespace + if LastTime < Start then begin + STon := 0; + SLen := Round((Start - LastTime) * 16320 / 255 / 12); + WriteLn(PlikB, ' .dw ' + IntToStr(STon + SLen*256) + ' ; timespace (0, ' + IntToStr(SLen) + ')'); + + end; + + + + // ton + STon := Round(98940/(2*261.62*Power(1.05946309436, Ton))); + S := ' ldi R18, ' + IntToStr(STon); + if STon > 255 then begin + beep; + S := '!!!!' + S; + end; + WriteLn(Plik, S); + + // length + //ldi R19, 43 + SLen := Round(Dlugosc * 16320 / STon / 12); + S := ' ldi R19, ' + IntToStr(SLen); + if SLen > 255 then begin + beep; + S := '!!!!' + S; + end; + WriteLn(Plik, S); + + // function + S := ' rcall playtone'; + WriteLn(Plik, S); + + // song dw + WriteLn(PlikB, ' .dw ' + IntToStr(STon + SLen*256)); + + + LastTime := Start + Dlugosc; + Inc(NTot); + + end; // with + end; // N + WriteLn(Plik, ''); + WriteLn(PlikB, ''); + end; // C + + WriteLn(Plik, '; nut ' + IntToStr(NTot)); + WriteLn(Plik, '; bajtów ' + IntToStr(8*NTot)); + + WriteLn(PlikB, ' .dw 0'); + WriteLn(PlikB, '; nut ' + IntToStr(NTot)); + WriteLn(PlikB, '; bajtów ' + IntToStr(2*NTot)); + + + CloseFile(Plik); + CloseFile(PlikB); +end; + +end. diff --git a/Game/Code/Classes/URecord.pas b/Game/Code/Classes/URecord.pas new file mode 100644 index 00000000..2ec5439a --- /dev/null +++ b/Game/Code/Classes/URecord.pas @@ -0,0 +1,371 @@ +unit URecord; + +interface +uses Classes, Math, SysUtils, {DXSounds, Wave, }UMusic, UIni, BASS; + +type + TSound = class + BufferNew: TMemoryStream; // buffer for newest sample + BufferArray: array[1..4096] of smallint; // (Signal) newest 4096 samples + BufferLong: array of TMemoryStream; // full buffer + + Num: integer; + n: integer; // length of Signal to analyze +// Spectrum: array[1..8192] of single; // sound buffer from above as FFT +// Spektogram: array[0..100] of TSpekt; // FFT(t) + + // pitch detection + SzczytJest: boolean; // czy jest szczyt + Szczyt: integer; // pozycja szczytu na osi poziomej + TonDokl: real; // ton aktualnego szczytu + Ton: integer; // ton bez ulamka + TonGamy: integer; // ton w gamie. wartosci: 0-11 + Skala: real; // skala FFT + + // procedures + procedure ProcessNewBuffer; + procedure AnalizujBufor; // use to analyze sound from buffers to get new pitch + procedure AnalizujByAutocorrelation; // we call it to analyze sound by checking Autocorrelation + function AnalyzeAutocorrelationFreq(Freq: real): real; // use this to check one frequency by Autocorrelation + end; + + TSoundCardInput = record + Name: string; + end; + + TSoundCard = record + // here can be the soundcard information - whole database from which user will select recording source + Description: string; + Input: array of TSoundCardInput; + InputSeleceted: integer; + + // bass record + BassRecordStream: hStream; + end; + + TRecord = class + SoundCard: array of TSoundCard; + constructor Create; + end; + + smallintarray = array [0..maxInt shr 1-1] of smallInt; + psmallintarray = ^smallintarray; + + // procedures - bass record + function GetMicrophone(handle: HSTREAM; buffer: Pointer; len: DWORD; user: DWORD): boolean; stdcall; + + +var + Sound: array of TSound; + SoundCard: array of TSoundCard; + Poz: integer; + Recording: TRecord; + +implementation +uses UMain, ULog; + +procedure TSound.ProcessNewBuffer; +var + S: integer; + L: integer; + A: integer; +begin + // process BufferArray + S := 0; + L := BufferNew.Size div 2; + if L > n then begin + S := L - n; + L := n; + end; + + // copy to array + for A := L+1 to n do + BufferArray[A-L] := BufferArray[A]; + + BufferNew.Seek(2*S, soBeginning); + BufferNew.ReadBuffer(BufferArray[1+n-L], 2*L); + + // process BufferLong + if Ini.SavePlayback = 1 then begin + BufferNew.Seek(0, soBeginning); + BufferLong[0].CopyFrom(BufferNew, BufferNew.Size); + end; +end; + +procedure TSound.AnalizujBufor; +begin + AnalizujByAutocorrelation; +end; + +procedure TSound.AnalizujByAutocorrelation; +var + T: integer; // tone + F: real; // freq + Wages: array[0..35] of real; // wages + MaxT: integer; // max tone + MaxW: real; // max wage + V: real; // volume + MaxV: real; // max volume + S: integer; // Signal + Threshold: real; // threshold +begin +// Log.LogAnalyze('[Analyze by Autocorrelation]'); + SzczytJest := false; + + // find maximum volume of first 1024 words of signal + MaxV := 0; + for S := 1 to 1024 do begin // 0.5.2: fix. was from 0 to 1023 +// Log.LogDebug('1'); +// Log.LogDebug(IntTostr(S)); + V := Abs(BufferArray[S]) / $10000; +// Log.LogDebug('2'); +// Log.LogDebug(IntTostr(S) + ': ' + FloatToStr(V) + ', MaxV='+floattostr(maxv)+', buf='+inttostr(length(BufferArray))); + if V > MaxV then MaxV := V; +// Log.LogDebug('3'); +// Log.LogDebug(IntTostr(S) + ': ' + FloatToStr(V) + ', MaxV='+floattostr(maxv)+', buf='+inttostr(length(BufferArray))); + end; + + + // prepare to analyze + MaxW := 0; + + // analyze all 12 halftones + for T := 0 to 35 do begin // to 11, then 23, now 35 (for Whitney and my high voice) + F := 130.81*Power(1.05946309436, T)/2; // let's analyze below 130.81 + Wages[T] := AnalyzeAutocorrelationFreq(F); + + if Wages[T] > MaxW then begin // this frequency has better wage + MaxW := Wages[T]; + MaxT := T; + end; + end; // for T + + Threshold := 0.1; + case Ini.Threshold of + 0: Threshold := 0.05; + 1: Threshold := 0.1; + 2: Threshold := 0.15; + 3: Threshold := 0.2; + end; + + //Log.LogDebug('Sound -> AnalyzeByAutocorrelation: MaxV='+floattostr(maxv)+', Threshold='+floattostr(threshold)); + if MaxV >= Threshold then begin // found acceptable volume // 0.1 + SzczytJest := true; + TonGamy := MaxT mod 12; + Ton := MaxT mod 12; + end; + +// Log.LogAnalyze('--> Weight: ') +// Log.LogAnalyze('--> Selected: ' + BoolToStr(SzczytJest, true) + +// ', TonGamy: ' + IntToStr(Ton) + +// ', MaxV: ' + FloatToStr(MaxV)); +// Log.LogAnalyze(''); + + +end; + +function TSound.AnalyzeAutocorrelationFreq(Freq: real): real; // result medium difference +var + Count: real; + Src: integer; + Dst: integer; + Move: integer; + Il: integer; // how many counts were done +begin + // we use Signal as source + Count := 0; + Il := 0; + Src := 1; + Move := Round(44100/Freq); + Dst := Src + Move; + + // ver 1 - sample 1 and compare n-times +{ while (Src <= Move) do begin // process by moving Src by one + while (Dst < n) do begin // process up to n (4KB) of Signal + Count := Count + Abs(Signal[Src] - Signal[Dst]) / $10000; + Inc(Dst, Move); + Inc(Il); + end; + + Inc(Src); + Dst := Src + Move; + end;} + + // ver 2 - compare in vertical + while (Dst < n) do begin // process up to n (4KB) of Signal + Count := Count + Abs(BufferArray[Src] - BufferArray[Dst]) / $10000; + Inc(Src); + Inc(Dst); + Inc(Il); + end; + + Result := 1 - Count / Il; +end; + +function GetMicrophone(handle: HSTREAM; buffer: Pointer; len: DWORD; user: DWORD): boolean; stdcall; +var + L: integer; + S: integer; + PB: pbytearray; + PW: pwordarray; + SI: smallintarray; + PSI: psmallintarray; + I: integer; + Skip: integer; + P1: integer; + P2: integer; + Boost: byte; +begin +// Log.LogDebug('Record -> GetMicrophone: len='+inttstr(len)); + + // set boost + case Ini.MicBoost of + 0: Boost := 1; + 1: Boost := 2; + 2: Boost := 4; + 3: Boost := 8; + end; + + // boost buffer + L := Len div 2; // number of samples + PSI := Buffer; + for S := 0 to L-1 do begin + I := PSI^[S] * Boost; + if I > 32767 then I := 32767; // 0.5.0: limit + if I < -32768 then I := -32768; // 0.5.0: limit + PSI^[S] := I; + end; + + // decode user + P1 := (user and 255) - 1; + P2 := (user div 256) - 1; + +// Log.LogDebug('Record -> GetMicrophone: P1='+inttostr(p1)+', P2='+inttostr(p2)); + + // 2 players USB mic, left channel + if P1 >= 0 then begin + L := Len div 4; // number of samples + PB := Buffer; +// Log.LogDebug('Record -> GetMicrophone -> Sound[P1].BufferNew.Clear'); + Sound[P1].BufferNew.Clear; // 0.5.2: problem on exiting + for S := 1 to L do begin + Sound[P1].BufferNew.Write(PB[(S-1)*4], 2); + end; + Sound[P1].ProcessNewBuffer; + end; + + // 2 players USB mic, right channel +// if Ini.Debug = 0 then Skip := 2 +// else Skip := 0; + Skip := 2; + + if P2 >= 0 then begin + L := Len div 4; // number of samples + PB := Buffer; + Sound[P2].BufferNew.Clear; + for S := 1 to L do begin + Sound[P2].BufferNew.Write(PB[Skip + (S-1)*4], 2); + end; + Sound[P2].ProcessNewBuffer; + end; + +// Log.LogDebug('Record -> GetMicrophone -> Finish'); + + Result := true; +end; + +constructor TRecord.Create; +var + SC: integer; // soundcard + SCI: integer; // soundcard input + Descr: string; + InputName: string; + Flags: integer; + No: integer; + function isDuplicate(Desc: String): Boolean; + var + I: Integer; + begin + Result := False; + //Check for Soundcard with same Description + For I := 0 to SC-1 do + begin + if (SoundCard[I].Description = Desc) then + begin + Result := True; + Break; + end; + end; + end; + +// mic: array[0..15] of integer; +begin + // checks for recording devices and puts them into array; + SetLength(SoundCard, 0); + + SC := 0; + Descr := BASS_RecordGetDeviceDescription(SC); + + while (Descr <> '') do begin + + //If there is another SoundCard with the Same ID, Search an available Name + if (IsDuplicate(Descr)) then + begin + No:= 1; //Count of SoundCards with same Name + Repeat + Inc(No) + Until not IsDuplicate(Descr + ' (' + InttoStr(No) + ')'); + //Set Description + Descr := Descr + ' (' + InttoStr(No) + ')'; + end; + + SetLength(SoundCard, SC+1); +// Log.LogError('Device #' + IntToStr(SC+1) + ': ' + Descr); + SoundCard[SC].Description := Descr; + + // check for recording inputs +// mic[device] := -1; // default to no change + SCI := 0; + BASS_RecordInit(SC); + Flags := BASS_RecordGetInput(SCI); + InputName := BASS_RecordGetInputName(SCI); +// Log.LogError('Input #' + IntToStr(SCI) + ' (' + IntToStr(Flags) + '): ' + InputName); + + SetLength(SoundCard[SC].Input, 1); + SoundCard[SC].Input[SCI].Name := InputName; + + // process each input + while (Flags <> -1) do begin + if SCI >= 1 then begin + SetLength(SoundCard[SC].Input, SCI+1); + InputName := BASS_RecordGetInputName(SCI); + SoundCard[SC].Input[SCI].Name := InputName; +// Log.LogError('Input #' + IntToStr(SCI) + ' (' + IntToStr(Flags) + '): ' + InputName); + end; + +{ if (flags and BASS_INPUT_TYPE_MASK) = BASS_INPUT_TYPE_MIC then begin + mic[device] := input; // auto set microphone + end;} + + Inc(SCI); + Flags := BASS_RecordGetInput(SCI); + end; + +{ if mic[device] <> -1 then begin + Log.LogAnalyze('Found the mic at input ' + IntToStr(Mic[device])) + end else begin + Log.LogAnalyze('Mic not found'); + mic[device] := 0; // setting to the first one (for kxproject) + end; + SoundCard[SC].InputSeleceted := Mic[Device];} + + + BASS_RecordFree; + + Inc(SC); + Descr := BASS_RecordGetDeviceDescription(SC); + end; // while +end; +end. + + diff --git a/Game/Code/Classes/USkins.pas b/Game/Code/Classes/USkins.pas new file mode 100644 index 00000000..547f4c2c --- /dev/null +++ b/Game/Code/Classes/USkins.pas @@ -0,0 +1,162 @@ +unit USkins; + +interface + +type + TSkinTexture = record + Name: string; + FileName: string; + end; + + TSkinEntry = record + Theme: string; + Name: string; + Path: string; + FileName: string; + Creator: string; // not used yet + end; + + TSkin = class + Skin: array of TSkinEntry; + SkinTexture: array of TSkinTexture; + SkinPath: string; + Color: integer; + constructor Create; + procedure LoadList; + procedure ParseDir(Dir: string); + procedure LoadHeader(FileName: string); + procedure LoadSkin(Name: string); + function GetTextureFileName(TextureName: string): string; + function GetSkinNumber(Name: string): integer; + procedure onThemeChange; + end; + +var + Skin: TSkin; + +implementation + +uses IniFiles, + Classes, + SysUtils, + ULog, + UIni; + +constructor TSkin.Create; +begin + LoadList; +// LoadSkin('Lisek'); +// SkinColor := Color; +end; + +procedure TSkin.LoadList; +var + SR: TSearchRec; + SR2: TSearchRec; + SLen: integer; +begin + if FindFirst('Skins\*', faDirectory, SR) = 0 then begin + repeat + if (SR.Name <> '.') and (SR.Name <> '..') then + ParseDir('Skins\' + SR.Name + '\'); + until FindNext(SR) <> 0; + end; // if + FindClose(SR); +end; + +procedure TSkin.ParseDir(Dir: string); +var + SR: TSearchRec; + SLen: integer; +begin + if FindFirst(Dir + '*.ini', faAnyFile, SR) = 0 then begin + repeat + if (SR.Name <> '.') and (SR.Name <> '..') then + LoadHeader(Dir + SR.Name); + //Log.LogError(SR.Name); + until FindNext(SR) <> 0; + end; +end; + +procedure TSkin.LoadHeader(FileName: string); +var + SkinIni: TMemIniFile; + S: integer; +begin + SkinIni := TMemIniFile.Create(FileName); + + S := Length(Skin); + SetLength(Skin, S+1); + Skin[S].Path := IncludeTrailingBackslash(ExtractFileDir(FileName)); + Skin[S].FileName := ExtractFileName(FileName); + Skin[S].Theme := SkinIni.ReadString('Skin', 'Theme', ''); + Skin[S].Name := SkinIni.ReadString('Skin', 'Name', ''); + Skin[S].Creator := SkinIni.ReadString('Skin', 'Creator', ''); + + SkinIni.Free; +end; + +procedure TSkin.LoadSkin(Name: string); +var + SkinIni: TMemIniFile; + SL: TStringList; + T: integer; + S: integer; +begin + S := GetSkinNumber(Name); + SkinPath := Skin[S].Path; + + SkinIni := TMemIniFile.Create(SkinPath + Skin[S].FileName); + + SL := TStringList.Create; + SkinIni.ReadSection('Textures', SL); + + SetLength(SkinTexture, SL.Count); + for T := 0 to SL.Count-1 do begin + SkinTexture[T].Name := SL.Strings[T]; + SkinTexture[T].FileName := SkinIni.ReadString('Textures', SL.Strings[T], ''); + end; + + SL.Free; + SkinIni.Free; +end; + +function TSkin.GetTextureFileName(TextureName: string): string; +var + T: integer; +begin + Result := ''; + for T := 0 to High(SkinTexture) do + if SkinTexture[T].Name = TextureName then Result := SkinPath + SkinTexture[T].FileName; + +{ Result := SkinPath + 'Bar.jpg'; + if TextureName = 'Ball' then Result := SkinPath + 'Ball.bmp'; + if Copy(TextureName, 1, 4) = 'Gray' then Result := SkinPath + 'Ball.bmp'; + if Copy(TextureName, 1, 6) = 'NoteBG' then Result := SkinPath + 'Ball.bmp';} +end; + +function TSkin.GetSkinNumber(Name: string): integer; +var + S: integer; +begin + Result := 0; // set default to the first available skin + for S := 0 to High(Skin) do + if Skin[S].Name = Name then Result := S; +end; + +procedure TSkin.onThemeChange; +var + S: integer; + Name: String; +begin + Ini.SkinNo:=0; + SetLength(ISkin, 0); + Name := Uppercase(ITheme[Ini.Theme]); + for S := 0 to High(Skin) do + if Name = Uppercase(Skin[S].Theme) then begin + SetLength(ISkin, Length(ISkin)+1); + ISkin[High(ISkin)] := Skin[S].Name; + end; +end; + +end. diff --git a/Game/Code/Classes/USongs.pas b/Game/Code/Classes/USongs.pas new file mode 100644 index 00000000..edf5b6df --- /dev/null +++ b/Game/Code/Classes/USongs.pas @@ -0,0 +1,743 @@ +unit USongs; + +interface +uses SysUtils, ULog, UTexture, UCatCovers; + +type + TBPM = record + BPM: real; + StartBeat: real; + end; + + TScore = record + Name: string; + Score: integer; + Length: string; + end; + + TSong = record + Path: string; + Folder: string; // for sorting by folder + FileName: string; + + // sorting methods + Category: array of string; // I think I won't need this + Genre: string; + Edition: string; + Language: string; // 0.5.0: new + + Title: string; + Artist: string; + + Text: string; + Creator: string; + + Cover: string; + CoverTex: TTexture; + Mp3: string; + Background: string; + Video: string; + VideoGAP: real; + VideoLoaded: boolean; // 0.5.0: true if the video has been loaded + NotesGAP: integer; + Start: real; // in seconds + Finish: integer; // in miliseconds + Relative: boolean; + Resolution: integer; + BPM: array of TBPM; + GAP: real; // in miliseconds + + Score: array[0..2] of array of TScore; + + // these are used when sorting is enabled + Visible: boolean; // false if hidden, true if visible + Main: boolean; // false for songs, true for category buttons + OrderNum: integer; // has a number of category for category buttons and songs + OrderTyp: integer; // type of sorting for this button (0=name) + CatNumber: integer; // Count of Songs in Category for Cats and Number of Song in Category for Songs + end; + + TSongs = class + private + BrowsePos: Cardinal; //Actual Pos in Song Array + public + Song: array of TSong; // array of songs + Selected: integer; // selected song index + procedure LoadSongList; // load all songs + procedure BrowseDir(Dir: string); // should return number of songs in the future + procedure Sort(Order: integer); + function FindSongFile(Dir, Mask: string): string; + end; + + TCatSongs = class + Song: array of TSong; // array of categories with songs + Selected: integer; // selected song index + Order: integer; // order type (0=title) + CatNumShow: integer; // Category Number being seen + CatCount: integer; //Number of Categorys + + procedure Refresh; // refreshes arrays by recreating them from Songs array +// procedure Sort(Order: integer); + procedure ShowCategory(Index: integer); // expands all songs in category + procedure HideCategory(Index: integer); // hides all songs in category + procedure ClickCategoryButton(Index: integer); // uses ShowCategory and HideCategory when needed + procedure ShowCategoryList; //Hides all Songs And Show the List of all Categorys + function FindNextVisible(SearchFrom:integer): integer; //Find Next visible Song + function VisibleSongs: integer; // returns number of visible songs (for tabs) + function VisibleIndex(Index: integer): integer; // returns visible song index (skips invisible) + + function SetFilter(FilterStr: String; const fType: Byte): Cardinal; + end; + +var + Songs: TSongs; // all songs + CatSongs: TCatSongs; // categorized songs + AktSong: TSong; // one song *unknown use) + +implementation + +uses UFiles, UIni, StrUtils; + +procedure TSongs.LoadSongList; +begin + Log.LogStatus('Initializing', 'LoadSongList'); + + // clear + Setlength(Song, 50); + + BrowsePos := 0; + // browse directories + BrowseDir(SongPath); + + //Set Correct SongArray Length + SetLength(Song, BrowsePos); +// if Ini.Debug = 1 then BrowseDir('D:\Extract\Songs\'); +end; + +procedure TSongs.BrowseDir(Dir: string); +var + SR: TSearchRec; // for parsing Songs Directory + SLen: integer; +begin + if FindFirst(Dir + '*', faDirectory, SR) = 0 then begin + repeat + if (SR.Name <> '.') and (SR.Name <> '..') then + BrowseDir(Dir + Sr.Name + '\'); + until FindNext(SR) <> 0; + end; // if + FindClose(SR); + +// Log.LogStatus('Parsing directory: ' + Dir + SR.Name, 'LoadSongList'); + + if FindFirst(Dir + '*.txt', 0, SR) = 0 then begin +// Log.LogStatus('Parsing file: ' + Dir + SR.Name + '\' + SRD.Name, 'LoadSongList'); + repeat + //New Mod for better Memory Management + + SLen := BrowsePos; + {//Old + SLen := Length(Song); + SetLength(Song, SLen + 1);//} + + Song[SLen].Path := Dir; + Song[SLen].Folder := Copy(Dir, Length(SongPath)+1, 10000); + Song[SLen].Folder := Copy(Song[SLen].Folder, 1, Pos('\', Song[SLen].Folder)-1); + Song[SLen].FileName := SR.Name; + + if (AnalyseFile(Song[SLen]) = false) then Dec(BrowsePos) + else begin + // scanning complete, file is good + // if there is no cover then try to find it + if Song[SLen].Cover = '' then Song[SLen].Cover := FindSongFile(Dir, '*[CO].jpg'); +// if Song[SLen].Background = '' then begin +// Song[SLen].Background := FindSongFile(Dir, '*[BG].jpg'); +// end; // no needed here} + + // fix by adding path. no, don't fix it. +// if Song[SLen].Cover <> '' then +// Song[SLen].Cover := Song[SLen].Path + Song[SLen].Cover; + end; + + //Change Length Only every 50 Entrys + Inc(BrowsePos); + + if (BrowsePos mod 50 = 0) AND (BrowsePos <> 0) then + begin + SetLength(Song, Length(Song) + 50); + end; + + until FindNext(SR) <> 0; + end; // if FindFirst + FindClose(SR); +end; + +procedure TSongs.Sort(Order: integer); +var + S: integer; + S2: integer; + TempSong: TSong; +begin + case Order of + sEdition: // by edition + begin + for S2 := 0 to Length(Song)-1 do + for S := 1 to Length(Song)-1 do + if CompareText(Song[S].Edition, Song[S-1].Edition) < 0 then begin + // zamiana miejscami + TempSong := Song[S-1]; + Song[S-1] := Song[S]; + Song[S] := TempSong; + end; + end; + sGenre: // by genre + begin + for S2 := 0 to Length(Song)-1 do + for S := 1 to Length(Song)-1 do + if CompareText(Song[S].Genre, Song[S-1].Genre) < 0 then begin + // zamiana miejscami + TempSong := Song[S-1]; + Song[S-1] := Song[S]; + Song[S] := TempSong; + end; + end; + sTitle: // by title + begin + for S2 := 0 to Length(Song)-1 do + for S := 1 to Length(Song)-1 do + if CompareText(Song[S].Title, Song[S-1].Title) < 0 then begin + // zamiana miejscami + TempSong := Song[S-1]; + Song[S-1] := Song[S]; + Song[S] := TempSong; + end; + + end; + sArtist: // by artist + begin + for S2 := 0 to Length(Song)-1 do + for S := 1 to Length(Song)-1 do + if CompareText(Song[S].Artist, Song[S-1].Artist) < 0 then begin + // zamiana miejscami + TempSong := Song[S-1]; + Song[S-1] := Song[S]; + Song[S] := TempSong; + end; + end; + sFolder: // by folder + begin + for S2 := 0 to Length(Song)-1 do + for S := 1 to Length(Song)-1 do + if CompareText(Song[S].Folder, Song[S-1].Folder) < 0 then begin + // zamiana miejscami + TempSong := Song[S-1]; + Song[S-1] := Song[S]; + Song[S] := TempSong; + end; + end; + sTitle2: // by title2 + begin + for S2 := 0 to Length(Song)-1 do + for S := 1 to Length(Song)-1 do + if CompareText(Song[S].Title, Song[S-1].Title) < 0 then begin + // zamiana miejscami + TempSong := Song[S-1]; + Song[S-1] := Song[S]; + Song[S] := TempSong; + end; + + end; + sArtist2: // by artist2 + begin + for S2 := 0 to Length(Song)-1 do + for S := 1 to Length(Song)-1 do + if CompareText(Song[S].Artist, Song[S-1].Artist) < 0 then begin + // zamiana miejscami + TempSong := Song[S-1]; + Song[S-1] := Song[S]; + Song[S] := TempSong; + end; + end; + sLanguage: // by Language + begin + for S2 := 0 to Length(Song)-1 do + for S := 1 to Length(Song)-1 do + if CompareText(Song[S].Language, Song[S-1].Language) < 0 then begin + TempSong := Song[S-1]; + Song[S-1] := Song[S]; + Song[S] := TempSong; + end; + end; + + end; // case +end; + +function TSongs.FindSongFile(Dir, Mask: string): string; +var + SR: TSearchRec; // for parsing song directory +begin + Result := ''; + if FindFirst(Dir + Mask, faDirectory, SR) = 0 then begin + Result := SR.Name; + end; // if + FindClose(SR); +end; + +procedure TCatSongs.Refresh; +var + S: integer; // temporary song index + CatLen: integer; // length of CatSongs.Song + Letter: char; // current letter for sorting using letter + SS: string; // current edition for sorting using edition, genre etc. + Order: integer; // number used for ordernum + Letter2: char; // + CatNumber:integer; // Number of Song in Category +begin + CatNumShow := -1; +// Songs.Sort(0); // by title + +case Ini.Sorting of + sEdition: begin + Songs.Sort(sArtist); + Songs.Sort(sEdition); + end; + sGenre: begin + Songs.Sort(sArtist); + Songs.Sort(sGenre); + end; + sLanguage: begin + Songs.Sort(sArtist); + Songs.Sort(sLanguage); + end; + sFolder: begin + Songs.Sort(sArtist); + Songs.Sort(sFolder); + end; + sTitle: Songs.Sort(sTitle); + sArtist: Songs.Sort(sArtist); + sTitle2: Songs.Sort(sTitle2); // by title2 + sArtist2: Songs.Sort(sArtist2); // by artist2 + + end; // case + + + Letter := ' '; + SS := ''; + Order := 0; + CatNumber := 0; + + //Songs leeren + SetLength (Song, 0); + + for S := Low(Songs.Song) to High(Songs.Song) do begin + if (Ini.Tabs = 1) then + if (Ini.Sorting = sEdition) and (CompareText(SS, Songs.Song[S].Edition) <> 0) then begin + // add Category Button + Inc(Order); + SS := Songs.Song[S].Edition; + CatLen := Length(CatSongs.Song); + SetLength(CatSongs.Song, CatLen+1); + CatSongs.Song[CatLen].Artist := '[' + SS + ']'; + CatSongs.Song[CatLen].Main := true; + CatSongs.Song[CatLen].OrderTyp := 0; + CatSongs.Song[CatLen].OrderNum := Order; + + + + // 0.4.3 + // if SS = 'Singstar' then CatSongs.Song[CatLen].Cover := CoversPath + 'Singstar.jpg'; + // if SS = 'Singstar Part 2' then CatSongs.Song[CatLen].Cover := CoversPath + 'Singstar.jpg'; + // if SS = 'Singstar German' then CatSongs.Song[CatLen].Cover := CoversPath + 'Singstar.jpg'; + // if SS = 'Singstar Spanish' then CatSongs.Song[CatLen].Cover := CoversPath + 'Singstar.jpg'; + // if SS = 'Singstar Italian' then CatSongs.Song[CatLen].Cover := CoversPath + 'Singstar.jpg'; + // if SS = 'Singstar French' then CatSongs.Song[CatLen].Cover := CoversPath + 'Singstar.jpg'; + // if SS = 'Singstar Party' then CatSongs.Song[CatLen].Cover := CoversPath + 'Singstar Party.jpg'; + // if SS = 'Singstar Popworld' then CatSongs.Song[CatLen].Cover := CoversPath + 'Singstar Popworld.jpg'; + // if SS = 'Singstar 80s' then CatSongs.Song[CatLen].Cover := CoversPath + 'Singstar 80s.jpg'; + // if SS = 'Singstar 80s Polish' then CatSongs.Song[CatLen].Cover := CoversPath + 'Singstar 80s.jpg'; + // if SS = 'Singstar Rocks' then CatSongs.Song[CatLen].Cover := CoversPath + 'Singstar Rocks.jpg'; + // if SS = 'Singstar Anthems' then CatSongs.Song[CatLen].Cover := CoversPath + 'Singstar Anthems.jpg'; + + {// cover-patch + if FileExists(CoversPath + SS + '.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + SS + '.jpg' + else if FileExists(CoversPath + 'NoCover.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + 'NoCover.jpg';//} + + CatSongs.Song[CatLen].Cover := CatCovers.GetCover(Ini.Sorting, SS); + + //CatNumber Patch + if (SS <> '') then + begin + Song[CatLen - CatNumber - 1].CatNumber := CatNumber;//Set CatNumber of Categroy + CatNumber := 0; + end; + + CatSongs.Song[CatLen].Visible := true; + end + + else if (Ini.Sorting = sGenre) and (CompareText(SS, Songs.Song[S].Genre) <> 0) then begin + // add Genre Button + Inc(Order); + SS := Songs.Song[S].Genre; + CatLen := Length(CatSongs.Song); + SetLength(CatSongs.Song, CatLen+1); + CatSongs.Song[CatLen].Artist := SS; + CatSongs.Song[CatLen].Main := true; + CatSongs.Song[CatLen].OrderTyp := 0; + CatSongs.Song[CatLen].OrderNum := Order; + + {// cover-patch + if FileExists(CoversPath + SS + '.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + SS + '.jpg' + else if FileExists(CoversPath + 'NoCover.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + 'NoCover.jpg';} + CatSongs.Song[CatLen].Cover := CatCovers.GetCover(Ini.Sorting, SS); + + //CatNumber Patch + if (SS <> '') then + begin + Song[CatLen - CatNumber - 1].CatNumber := CatNumber;//Set CatNumber of Categroy + CatNumber := 0; + end; + + CatSongs.Song[CatLen].Visible := true; + end + + else if (Ini.Sorting = sLanguage) and (CompareText(SS, Songs.Song[S].Language) <> 0) then begin + // add Language Button + Inc(Order); + SS := Songs.Song[S].Language; + CatLen := Length(CatSongs.Song); + SetLength(CatSongs.Song, CatLen+1); + CatSongs.Song[CatLen].Artist := SS; + CatSongs.Song[CatLen].Main := true; + CatSongs.Song[CatLen].OrderTyp := 0; + CatSongs.Song[CatLen].OrderNum := Order; + + {// cover-patch + if FileExists(CoversPath + SS + '.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + SS + '.jpg' + else if FileExists(CoversPath + 'NoCover.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + 'NoCover.jpg';} + CatSongs.Song[CatLen].Cover := CatCovers.GetCover(Ini.Sorting, SS); + + //CatNumber Patch + if (SS <> '') then + begin + Song[CatLen - CatNumber - 1].CatNumber := CatNumber;//Set CatNumber of Categroy + CatNumber := 0; + end; + + CatSongs.Song[CatLen].Visible := true; + end + + else if (Ini.Sorting = sTitle) and (Length(Songs.Song[S].Title)>=1) and (Letter <> UpCase(Songs.Song[S].Title[1])) then begin + // add a letter Category Button + Inc(Order); + Letter := UpCase(Songs.Song[S].Title[1]); + CatLen := Length(CatSongs.Song); + SetLength(CatSongs.Song, CatLen+1); + CatSongs.Song[CatLen].Artist := '[' + Letter + ']'; + CatSongs.Song[CatLen].Main := true; + CatSongs.Song[CatLen].OrderTyp := 0; +// Order := ord(Letter); + CatSongs.Song[CatLen].OrderNum := Order; + + + {// cover-patch + if FileExists(CoversPath + 'Title' + Letter + '.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + 'Title' + Letter + '.jpg' + else if FileExists(CoversPath + 'NoCover.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + 'NoCover.jpg';} + CatSongs.Song[CatLen].Cover := CatCovers.GetCover(Ini.Sorting, Letter); + + //CatNumber Patch + if (Letter <> ' ') then + begin + Song[CatLen - CatNumber - 1].CatNumber := CatNumber;//Set CatNumber of Categroy + CatNumber := 0; + end; + + CatSongs.Song[CatLen].Visible := true; + end + + else if (Ini.Sorting = sArtist) and (Length(Songs.Song[S].Artist)>=1) and (Letter <> UpCase(Songs.Song[S].Artist[1])) then begin + // add a letter Category Button + Inc(Order); + Letter := UpCase(Songs.Song[S].Artist[1]); + CatLen := Length(CatSongs.Song); + SetLength(CatSongs.Song, CatLen+1); + CatSongs.Song[CatLen].Artist := '[' + Letter + ']'; + CatSongs.Song[CatLen].Main := true; + CatSongs.Song[CatLen].OrderTyp := 0; +// Order := ord(Letter); + CatSongs.Song[CatLen].OrderNum := Order; + + {// cover-patch + if FileExists(CoversPath + 'Artist' + Letter + '.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + 'Artist' + Letter + '.jpg' + else if FileExists(CoversPath + 'NoCover.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + 'NoCover.jpg';} + CatSongs.Song[CatLen].Cover := CatCovers.GetCover(Ini.Sorting, Letter); + + //CatNumber Patch + if (Letter <> ' ') then + begin + Song[CatLen - CatNumber - 1].CatNumber := CatNumber;//Set CatNumber of Categroy + CatNumber := 0; + end; + + CatSongs.Song[CatLen].Visible := true; + end + + else if (Ini.Sorting = sFolder) and (CompareText(SS, Songs.Song[S].Folder) <> 0) then begin + // 0.5.0: add folder tab + Inc(Order); + SS := Songs.Song[S].Folder; + CatLen := Length(CatSongs.Song); + SetLength(CatSongs.Song, CatLen+1); + CatSongs.Song[CatLen].Artist := SS; + CatSongs.Song[CatLen].Main := true; + CatSongs.Song[CatLen].OrderTyp := 0; + CatSongs.Song[CatLen].OrderNum := Order; + + {// cover-patch + if FileExists(CoversPath + SS + '.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + SS + '.jpg' + else if FileExists(CoversPath + 'NoCover.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + 'NoCover.jpg';} + CatSongs.Song[CatLen].Cover := CatCovers.GetCover(Ini.Sorting, SS); + + //CatNumber Patch + if (SS <> '') then + begin + Song[CatLen - CatNumber - 1].CatNumber := CatNumber;//Set CatNumber of Categroy + CatNumber := 0; + end; + + CatSongs.Song[CatLen].Visible := true; + end + + else if (Ini.Sorting = sTitle2) AND (Length(Songs.Song[S].Title)>=1) then begin + if (ord(Songs.Song[S].Title[1]) > 47) and (ord(Songs.Song[S].Title[1]) < 58) then Letter2 := '#' else Letter2 := UpCase(Songs.Song[S].Title[1]); + if (Letter <> Letter2) then begin + // add a letter Category Button + Inc(Order); + Letter := Letter2; + CatLen := Length(CatSongs.Song); + SetLength(CatSongs.Song, CatLen+1); + CatSongs.Song[CatLen].Artist := '[' + Letter + ']'; + CatSongs.Song[CatLen].Main := true; + CatSongs.Song[CatLen].OrderTyp := 0; +// Order := ord(Letter); + CatSongs.Song[CatLen].OrderNum := Order; + + {// cover-patch + if FileExists(CoversPath + 'Title' + Letter + '.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + 'Title' + Letter + '.jpg' + else if FileExists(CoversPath + 'NoCover.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + 'NoCover.jpg';} + CatSongs.Song[CatLen].Cover := CatCovers.GetCover(Ini.Sorting, Letter); + + //CatNumber Patch + if (Letter <> ' ') then + begin + Song[CatLen - CatNumber - 1].CatNumber := CatNumber;//Set CatNumber of Categroy + CatNumber := 0; + end; + + CatSongs.Song[CatLen].Visible := true; + end; + end + + else if (Ini.Sorting = sArtist2) AND (Length(Songs.Song[S].Artist)>=1) then begin + if (ord(Songs.Song[S].Artist[1]) > 47) and (ord(Songs.Song[S].Artist[1]) < 58) then Letter2 := '#' else Letter2 := UpCase(Songs.Song[S].Artist[1]); + if (Letter <> Letter2) then begin + // add a letter Category Button + Inc(Order); + Letter := Letter2; + CatLen := Length(CatSongs.Song); + SetLength(CatSongs.Song, CatLen+1); + CatSongs.Song[CatLen].Artist := '[' + Letter + ']'; + CatSongs.Song[CatLen].Main := true; + CatSongs.Song[CatLen].OrderTyp := 0; +// Order := ord(Letter); + CatSongs.Song[CatLen].OrderNum := Order; + + {// cover-patch + if FileExists(CoversPath + 'Artist' + Letter + '.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + 'Artist' + Letter + '.jpg' + else if FileExists(CoversPath + 'NoCover.jpg') then CatSongs.Song[CatLen].Cover := CoversPath + 'NoCover.jpg';} + CatSongs.Song[CatLen].Cover := CatCovers.GetCover(Ini.Sorting, Letter); + + //CatNumber Patch + if (Letter <> ' ') then + begin + Song[CatLen - CatNumber - 1].CatNumber := CatNumber;//Set CatNumber of Categroy + CatNumber := 0; + end; + + CatSongs.Song[CatLen].Visible := true; + end; + end; + + + CatLen := Length(CatSongs.Song); + SetLength(CatSongs.Song, CatLen+1); + + Inc (CatNumber); //Increase Number in Cat + + CatSongs.Song[CatLen] := Songs.Song[S]; + CatSongs.Song[CatLen].OrderNum := Order; // assigns category + CatSongs.Song[CatLen].CatNumber := CatNumber; + + if (Ini.Tabs = 0) then CatSongs.Song[CatLen].Visible := true + else if (Ini.Tabs = 1) then CatSongs.Song[CatLen].Visible := false; +// if (Ini.Tabs = 1) and (Order = 1) then CatSongs.Song[CatLen].Visible := true; // open first tab +//CatSongs.Song[CatLen].Visible := true; + + end; +//CatNumber Patch - Set CatNumber of Last Category +if (ini.Tabs_at_startup = 1) And (high(Song) >=1) then + Song[CatLen - CatNumber].CatNumber := CatNumber;//Set CatNumber of Categroy +//CatCount Patch +CatCount := Order; +end; + +procedure TCatSongs.ShowCategory(Index: integer); +var + S: integer; // song +begin + CatNumShow := Index; + for S := 0 to high(CatSongs.Song) do + begin + if (CatSongs.Song[S].OrderNum = Index) AND (Not CatSongs.Song[S].Main) then + CatSongs.Song[S].Visible := true + else + CatSongs.Song[S].Visible := false; + end; +end; + +procedure TCatSongs.HideCategory(Index: integer); // hides all songs in category +var + S: integer; // song +begin + for S := 0 to high(CatSongs.Song) do begin + if not CatSongs.Song[S].Main then + CatSongs.Song[S].Visible := false // hides all at now + end; +end; + +procedure TCatSongs.ClickCategoryButton(Index: integer); +var + Num, S: integer; +begin + Num := CatSongs.Song[Index].OrderNum; + if Num <> CatNumShow then + begin + ShowCategory(Num); + end + else begin + ShowCategoryList; + end; +end; + +//Hide Categorys when in Category Hack +procedure TCatSongs.ShowCategoryList; +var + Num, S: integer; +begin + //Hide All Songs Show All Cats + for S := 0 to high(CatSongs.Song) do begin + if CatSongs.Song[S].Main then + CatSongs.Song[S].Visible := true + else + CatSongs.Song[S].Visible := false + end; + CatSongs.Selected := CatNumShow; //Show last shown Category + CatNumShow := -1; +end; +//Hide Categorys when in Category Hack End + +//Wrong song selected when tabs on bug +function TCatSongs.FindNextVisible(SearchFrom:integer): integer;//Find next Visible Song +var + I: Integer; + begin + Result := -1; + I := SearchFrom + 1; + while not CatSongs.Song[I].Visible do + begin + Inc (I); + if (I>high(CatSongs.Song)) then + I := low(CatSongs.Song); + if (I = SearchFrom) then //Make One Round and no song found->quit + break; + end; + end; +//Wrong song selected when tabs on bug End + +function TCatSongs.VisibleSongs: integer; +var + S: integer; // song +begin + Result := 0; + for S := 0 to high(CatSongs.Song) do + if CatSongs.Song[S].Visible = true then Inc(Result); +end; + +function TCatSongs.VisibleIndex(Index: integer): integer; +var + S: integer; // song +begin + Result := 0; + for S := 0 to Index-1 do + if CatSongs.Song[S].Visible = true then Inc(Result); +end; + +function TCatSongs.SetFilter(FilterStr: String; const fType: Byte): Cardinal; +var + I, J: Integer; + cString: String; + SearchStr: Array of String; +begin + {fType: 0: All + 1: Title + 2: Artist} + FilterStr := Trim(FilterStr); + if FilterStr<>'' then begin + Result := 0; + //Create Search Array + SetLength(SearchStr, 1); + I := Pos (' ', FilterStr); + While (I <> 0) do + begin + SetLength (SearchStr, Length(SearchStr) + 1); + cString := Copy(FilterStr, 1, I-1); + if (cString <> ' ') AND (cString <> '') then + SearchStr[High(SearchStr)-1] := cString; + Delete (FilterStr, 1, I); + + I := Pos (' ', FilterStr); + end; + //Copy last Word + if (FilterStr <> ' ') AND (FilterStr <> '') then + SearchStr[High(SearchStr)] := FilterStr; + + for I:=0 to High(Song) do begin + if not Song[i].Main then + begin + case fType of + 0: cString := Song[I].Artist + ' ' + Song[i].Title + ' ' + Song[i].Folder; + 1: cString := Song[I].Title; + 2: cString := Song[I].Artist; + end; + Song[i].Visible:=True; + //Look for every Searched Word + For J := 0 to High(SearchStr) do + begin + Song[i].Visible := Song[i].Visible AND AnsiContainsText(cString, SearchStr[J]) + end; + if Song[i].Visible then + Inc(Result); + end + else + Song[i].Visible:=False; + end; + CatNumShow := -2; + end + else begin + for i:=0 to High(Song) do begin + Song[i].Visible:=(Ini.Tabs=1)=Song[i].Main; + CatNumShow := -1; + end; + Result := 0; + end; +end; + +end. diff --git a/Game/Code/Classes/UTexture.pas b/Game/Code/Classes/UTexture.pas new file mode 100644 index 00000000..275f0748 --- /dev/null +++ b/Game/Code/Classes/UTexture.pas @@ -0,0 +1,867 @@ +unit UTexture; + +// Plain (alpha = 1) +// Transparent +// Transparent Range +// Font (white is drawn, black is transparent) +// Font Outline (Font with darker outline) +// Font Outline 2 (Font with darker outline) +// Font Black (black is drawn, white is transparent) +// Font Gray (gray is drawn, white is transparent) +// Arrow (for arrows, white is white, gray has color, black is transparent); + +interface +uses OpenGL12, Windows, Math, Classes, SysUtils, Graphics, JPEG, UThemes, PNGImage; + +procedure glGenTextures(n: GLsizei; var textures: GLuint); stdcall; external opengl32; +//procedure glBindTexture(target: GLenum; texture: GLuint); stdcall; external opengl32; +//function gluBuild2DMipmaps (target: GLenum; components, width, height: GLint; +// format, atype: GLenum; data: Pointer): Integer; stdcall; external glu32; +//procedure glCopyTexImage2D(target: GLenum; level: GLint; internalFormat: GLenum; x, y: GLint; width, height: GLsizei; border: GLint); stdcall; external opengl32; + + +type + TTexture = record + TexNum: integer; + X: real; + Y: real; + Z: real; // new + W: real; + H: real; + ScaleW: real; // for dynamic scalling while leaving width constant + ScaleH: real; // for dynamic scalling while leaving height constant + Rot: real; // 0 - 2*pi + Int: real; // intensity + ColR: real; + ColG: real; + ColB: real; + TexW: real; // used? + TexH: real; // used? + TexX1: real; + TexY1: real; + TexX2: real; + TexY2: real; + Alpha: real; + Name: string; // 0.5.0: experimental for handling cache images. maybe it's useful for dynamic skins + end; + + TTextureEntry = record + Name: string; + Typ: string; + + // we use normal TTexture, it's easier to implement and if needed - we copy ready data + Texture: TTexture; + TextureCache: TTexture; // 0.5.0 + end; + + TTextureDatabase = record + Texture: array of TTextureEntry; + end; + + TTextureUnit = class + Limit: integer; + CreateCacheMipmap: boolean; + +// function GetNumberFor + function GetTexture(Name, Typ: string): TTexture; overload; + function GetTexture(Name, Typ: string; FromCache: boolean): TTexture; overload; + function FindTexture(Name: string): integer; + function LoadTexture(FromRegistry: boolean; Nazwa, Format, Typ: PChar; Col: LongWord): TTexture; overload; + function LoadTexture(Nazwa, Format, Typ: PChar; Col: LongWord): TTexture; overload; + function LoadTexture(Nazwa: string): TTexture; overload; + function CreateTexture(var Data: array of byte; Name: string; W, H: word; Bits: byte): TTexture; + procedure UnloadTexture(Name: string; FromCache: boolean); + end; + +var + Texture: TTextureUnit; + TextureDatabase: TTextureDatabase; + + + // for print screens +// PrintScreenTex: GLuint; +// PrintScreenData: array[0..480-1, 0..640-1] of longword; + PrintScreenData: array[0..1024*768-1] of longword; + +// Tekstur: Gluint; + ActTex: GLuint;//integer; + +{ Tekstura: array[1..32] of TTekstura; + Mipmapping: boolean = true;} + + TexOrygW: integer; + TexOrygH: integer; + TexNewW: integer; + TexNewH: integer; +{ RLE: array[1..128*128] of byte; + RLE2: array[1..128*128] of byte;} + + TexFitW: integer; + TexFitH: integer; // new for limit + + TextureD8: array[1..1024*1024] of byte; // 1MB + TextureD16: array[1..1024*1024, 1..2] of byte; // luminance/alpha tex (2MB) + TextureD24: array[1..1024*1024, 1..3] of byte; // normal 24-bit tex (3MB) + TextureD242: array[1..512*512, 1..3] of byte; // normal 24-bit tex (0,75MB) + TextureD32: array[1..1024*1024, 1..4] of byte; // transparent 32-bit tex (4MB) + // total 40MB at 2048*2048 + // total 10MB at 1024*1024 + +{ Paleta: array[0..255, 1..4] of byte; + Len: integer;} + Mipmapping: Boolean; + + CacheMipmap: array[0..256*256*3-1] of byte; // 3KB + + +implementation +uses ULog, DateUtils, UCovers; + +function TTextureUnit.GetTexture(Name, Typ: string): TTexture; +begin + Result := GetTexture(Name, Typ, true); +end; + +function TTextureUnit.GetTexture(Name, Typ: string; FromCache: boolean): TTexture; +var + T: integer; // texture + C: integer; // cover + Data: array of byte; +begin + // find texture entry + T := FindTexture(Name); + + if T = -1 then begin + // create texture entry + T := Length(TextureDatabase.Texture); + SetLength(TextureDatabase.Texture, T+1); + TextureDatabase.Texture[T].Name := Name; + TextureDatabase.Texture[T].Typ := Typ; + + // inform database that not textures has been loaded into memory + TextureDatabase.Texture[T].Texture.TexNum := -1; + TextureDatabase.Texture[T].TextureCache.TexNum := -1; + end; + + // use preloaded texture + if (not FromCache) or (FromCache and not Covers.CoverExists(Name)) then begin + // use full texture + if TextureDatabase.Texture[T].Texture.TexNum = -1 then begin + // load texture + TextureDatabase.Texture[T].Texture := LoadTexture(false, pchar(Name), 'JPG', pchar(Typ), $0); + end; + + // use texture + Result := TextureDatabase.Texture[T].Texture; + + end; + + if FromCache and Covers.CoverExists(Name) then begin + // use cache texture + C := Covers.CoverNumber(Name); + + if TextureDatabase.Texture[T].TextureCache.TexNum = -1 then begin + // load texture + Covers.PrepareData(Name); +{ Covers.Data[0] := 0; + Covers.Data[1] := 0; + Covers.Data[2] := 0; + Covers.Data[3] := 255; + Covers.Data[4] := 255; + Covers.Data[5] := 255;} + TextureDatabase.Texture[T].TextureCache := CreateTexture(Covers.Data, Name, Covers.Cover[C].W, Covers.Cover[C].H, 24); + end; + + // use texture + Result := TextureDatabase.Texture[T].TextureCache; + end; +end; + +function TTextureUnit.FindTexture(Name: string): integer; +var + T: integer; // texture +begin + Result := -1; + for T := 0 to high(TextureDatabase.Texture) do + if TextureDatabase.Texture[T].Name = Name then + Result := T; +end; + +function TTextureUnit.LoadTexture(FromRegistry: boolean; Nazwa, Format, Typ: PChar; Col: LongWord): TTexture; +var + Res: TResourceStream; + TextureB: TBitmap; + TextureJ: TJPEGImage; + TexturePNG: TPNGObject; + TextureAlpha: array of byte; + AlphaPtr: PByte; + TransparentColor: TColor; + PixelColor: TColor; + + Pet: integer; + Pet2: integer; + Pix: integer; + ColInt: real; + PPix: PByteArray; + TempA: integer; + Error: integer; + SkipX: integer; + myAlpha: Real; +begin + Log.BenchmarkStart(4); + Mipmapping := true; + + if FromRegistry then begin + try + Res := TResourceStream.Create(HInstance, Nazwa, Format); + except + beep; + Exit; + end; + end; + + if FromRegistry or ((not FromRegistry) and FileExists(Nazwa)) then begin + TextureB := TBitmap.Create; + + if Format = 'BMP' then begin + if FromRegistry then TextureB.LoadFromStream(Res) + else TextureB.LoadFromFile(Nazwa); + end + + else if Format = 'JPG' then begin + TextureJ := TJPEGImage.Create; + if FromRegistry then TextureJ.LoadFromStream(Res) + else begin + if FileExists(Nazwa) then + TextureJ.LoadFromFile(Nazwa) + else + Exit; + end; + TextureB.Assign(TextureJ); + TextureJ.Free; + end + + else if Format = 'PNG' then begin + TexturePNG := TPNGObject.Create; + if FromRegistry then TexturePNG.LoadFromStream(Res) + else begin + if FileExists(Nazwa) then + TexturePNG.LoadFromFile(Nazwa) + else + Exit; + end; + TextureB.Assign(TexturePNG); + // transparent png hack start (part 1 of 2) + if (Typ = 'Transparent') and (TexturePNG.TransparencyMode = ptmPartial) then + begin + setlength(TextureAlpha, TextureB.Width*TextureB.Height); + if (TexturePNG.Header.ColorType = COLOR_GRAYSCALEALPHA) or + (TexturePNG.Header.ColorType = COLOR_RGBALPHA) then + begin + // i would have preferred english variables here but i use Pet because i'm lazy + for Pet := 0 to TextureB.Height - 1 do + begin + AlphaPtr := PByte(TexturePNG.AlphaScanline[Pet]); + for Pet2 := 0 to TextureB.Width - 1 do + begin + TextureAlpha[Pet*TextureB.Width+Pet2]:= AlphaPtr^; + Inc(AlphaPtr); + end; + end; + end; + end else + setlength(TextureAlpha,0); // just no special transparency for unimplemented transparency types (ptmBit) + // transparent png hack end + TexturePNG.Free; + end; + + if FromRegistry then Res.Free; + + if (TextureB.Width > 1024) or (TextureB.Height > 1024) then begin // will be fixed in 0.5.1 and dynamically extended to 8192x8192 depending on the driver + Log.LogError('Image ' + Nazwa + ' is too big (' + IntToStr(TextureB.Width) + 'x' + IntToStr(TextureB.Height) + ')'); + Result.TexNum := -1; + end else begin + + glGenTextures(1, ActTex); + glBindTexture(GL_TEXTURE_2D, ActTex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + if Typ = 'Plain' then begin + // wymiary + TexOrygW := TextureB.Width; + TexOrygH := TextureB.Height; + TexNewW := Round(Power(2, Ceil(Log2(TexOrygW)))); + TexNewH := Round(Power(2, Ceil(Log2(TexOrygH)))); + + // kopiowanie + TextureB.PixelFormat := pf24bit; +{ if (TextureB.PixelFormat = pf8bit) then begin + for Pet := 0 to TexOrygH-1 do begin + for Pet2 := 0 to TexOrygW-1 do begin + Pix := TextureB.Canvas.Pixels[Pet2, Pet]; + TextureD24[Pet*TexNewW + Pet2+1, 1] := Pix; + TextureD24[Pet*TexNewW + Pet2+1, 2] := Pix div 256; + TextureD24[Pet*TexNewW + Pet2+1, 3] := Pix div (256*256); + end; + end; + end;} + if (TexOrygW <= Limit) and (TexOrygW <= Limit) then begin + if (TextureB.PixelFormat = pf24bit) then begin + for Pet := 0 to TexOrygH-1 do begin + PPix := TextureB.ScanLine[Pet]; + for Pet2 := 0 to TexOrygW-1 do begin + TextureD24[Pet*TexNewW + Pet2+1, 1] := PPix[Pet2*3+2]; + TextureD24[Pet*TexNewW + Pet2+1, 2] := PPix[Pet2*3+1]; + TextureD24[Pet*TexNewW + Pet2+1, 3] := PPix[Pet2*3]; + end; + end; + end; + end else begin + // limit + TexFitW := 4 * (TexOrygW div 4); // fix for bug in gluScaleImage + TexFitH := TexOrygH; + if (TextureB.PixelFormat = pf24bit) then begin + for Pet := 0 to TexOrygH-1 do begin + PPix := TextureB.ScanLine[Pet]; + for Pet2 := 0 to TexOrygW-1 do begin + TextureD24[Pet*TexFitW + Pet2+1, 1] := PPix[Pet2*3+2]; + TextureD24[Pet*TexFitW + Pet2+1, 2] := PPix[Pet2*3+1]; + TextureD24[Pet*TexFitW + Pet2+1, 3] := PPix[Pet2*3]; + end; + end; + end; + gluScaleImage(GL_RGB, TexFitW, TexFitH, GL_UNSIGNED_BYTE, @TextureD24, + Limit, Limit, GL_UNSIGNED_BYTE, @TextureD24); // takes some time + + TexNewW := Limit; + TexNewH := Limit; + TexOrygW := Limit; + TexOrygH := Limit; + end; + + // creating cache mipmap + if CreateCacheMipmap then begin + if (TexOrygW <> TexNewW) or (TexOrygH <> TexNewH) then begin + // texture only uses some of it's space. there's a need for resize to fit full size + // and get best quality + TexFitW := 4 * (TexOrygW div 4); // 0.5.0: fix for bug in gluScaleImage + SkipX := (TexOrygW div 2) mod 2; // 0.5.0: try to center image + + TexFitH := TexOrygH; + for Pet := 0 to TexOrygH-1 do begin + PPix := TextureB.ScanLine[Pet]; + for Pet2 := 0 to TexOrygW-1 do begin + TextureD242[Pet*TexFitW + Pet2+1, 1] := PPix[(Pet2+SkipX)*3+2]; + TextureD242[Pet*TexFitW + Pet2+1, 2] := PPix[(Pet2+SkipX)*3+1]; + TextureD242[Pet*TexFitW + Pet2+1, 3] := PPix[(Pet2+SkipX)*3]; + end; + end; + gluScaleImage(GL_RGB, TexFitW, TexFitH, GL_UNSIGNED_BYTE, @TextureD242, + Covers.W, Covers.H, GL_UNSIGNED_BYTE, @CacheMipmap[0]); // takes some time + + end else begin + // texture fits perfectly + gluScaleImage(GL_RGB, TexOrygW, TexOrygH, GL_UNSIGNED_BYTE, @TextureD24, + Covers.W, Covers.H, GL_UNSIGNED_BYTE, @CacheMipmap[0]); // takes some time + end; + end; + + glTexImage2D(GL_TEXTURE_2D, 0, 3, TexNewW, TexNewH, 0, GL_RGB, GL_UNSIGNED_BYTE, @TextureD24); + if Mipmapping then begin + Error := gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TexNewW, TexNewH, GL_RGB, GL_UNSIGNED_BYTE, @TextureD24); + if Error > 0 then beep; + end + end; + + if Typ = 'Transparent' then begin + // wymiary + TexOrygW := TextureB.Width; + TexOrygH := TextureB.Height; + TexNewW := Round(Power(2, Ceil(Log2(TexOrygW)))); + TexNewH := Round(Power(2, Ceil(Log2(TexOrygH)))); + TextureB.Width := TexNewW; + TextureB.Height := TexNewH; + + // kopiowanie + for Pet := 0 to TexOrygH-1 do begin + for Pet2 := 0 to TexOrygW-1 do begin + Pix := TextureB.Canvas.Pixels[Pet2, Pet]; + // ,- part of transparent png hack + if ((Pix = $fefefe) or (Pix = Col)) and (length(TextureAlpha)=0) then begin //Small fix, that caused artefacts to be drawn (#fe == dec254) + TextureD32[Pet*TexNewW + Pet2 + 1, 1] := 0; + TextureD32[Pet*TexNewW + Pet2 + 1, 2] := 0; + TextureD32[Pet*TexNewW + Pet2 + 1, 3] := 0; + TextureD32[Pet*TexNewW + Pet2 + 1, 4] := 0; + end else begin + TextureD32[Pet*TexNewW + Pet2+1, 1] := Pix; + TextureD32[Pet*TexNewW + Pet2+1, 2] := Pix div 256; + TextureD32[Pet*TexNewW + Pet2+1, 3] := Pix div (256*256); + // transparent png hack start (part 2 of 2) + if (Format = 'PNG') and (length(TextureAlpha) <> 0) then begin + myAlpha:=TextureAlpha[Pet*TexOrygW+Pet2]; + + // the following calculations tweak transparency so that it really looks transparent + myAlpha:=myAlpha-75; + if myAlpha < 0 then myAlpha:=0; + myAlpha:=myAlpha/180; + myAlpha:=myAlpha*myAlpha*myAlpha; + myAlpha:=myAlpha*255; + + TextureD32[Pet*TexNewW+Pet2+1,4]:=floor(myAlpha); + end else + // transparent png hack end + TextureD32[Pet*TexNewW + Pet2+1, 4] := 255; + end; + end; + end; + glTexImage2D(GL_TEXTURE_2D, 0, 4, TexNewW, TexNewH, 0, GL_RGBA, GL_UNSIGNED_BYTE, @TextureD32); +{ if Mipmapping then begin + Error := gluBuild2DMipmaps(GL_TEXTURE_2D, 4, TextureB.Width, TextureB.Height, GL_RGBA, GL_UNSIGNED_BYTE, @TextureD32); + if Error > 0 then beep; + end;} + end; + + if Typ = 'Transparent Range' then begin + // wymiary + TexOrygW := TextureB.Width; + TexOrygH := TextureB.Height; + TexNewW := Round(Power(2, Ceil(Log2(TexOrygW)))); + TexNewH := Round(Power(2, Ceil(Log2(TexOrygH)))); + TextureB.Width := TexNewW; + TextureB.Height := TexNewH; + // kopiowanie + for Pet := 0 to TexOrygH-1 do begin + for Pet2 := 0 to TexOrygW-1 do begin + Pix := TextureB.Canvas.Pixels[Pet2, Pet]; + TextureD32[Pet*TexNewW + Pet2+1, 1] := Pix; + TextureD32[Pet*TexNewW + Pet2+1, 2] := Pix div 256; + TextureD32[Pet*TexNewW + Pet2+1, 3] := Pix div (256*256); + TextureD32[Pet*TexNewW + Pet2+1, 4] := 256 - Pix div 256; + end; + end; + glTexImage2D(GL_TEXTURE_2D, 0, 4, TexNewW, TexNewH, 0, GL_RGBA, GL_UNSIGNED_BYTE, @TextureD32); +{ if Mipmapping then begin + Error := gluBuild2DMipmaps(GL_TEXTURE_2D, 4, TextureB.Width, TextureB.Height, GL_RGBA, GL_UNSIGNED_BYTE, @TextureD32); + if Error > 0 then beep; + end;} + end; + + if Typ = 'Font' then begin + TextureB.PixelFormat := pf24bit; + for Pet := 0 to TextureB.Height-1 do begin + PPix := TextureB.ScanLine[Pet]; + for Pet2 := 0 to TextureB.Width-1 do begin + Pix := PPix[Pet2 * 3]; + TextureD16[Pet*TextureB.Width + Pet2 + 1, 1] := 255; + TextureD16[Pet*TextureB.Width + Pet2 + 1, 2] := Pix; + end; + end; + glTexImage2D(GL_TEXTURE_2D, 0, 2, TextureB.Width, TextureB.Height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, @TextureD16); + + if Mipmapping then glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + if Mipmapping then begin + Error := gluBuild2DMipmaps(GL_TEXTURE_2D, 2, TextureB.Width, TextureB.Height, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, @TextureD16); + if Error > 0 then beep; + end; + end; + + if Typ = 'Font Outline' then begin + TextureB.PixelFormat := pf24bit; + for Pet := 0 to TextureB.Height-1 do begin + PPix := TextureB.ScanLine[Pet]; + for Pet2 := 0 to TextureB.Width-1 do begin + Pix := PPix[Pet2 * 3]; + + Col := Pix; + if Col < 127 then Col := 127; + + TempA := Pix; + if TempA >= 95 then TempA := 255; + if TempA >= 31 then TempA := 255; + if Pix < 95 then TempA := (Pix * 256) div 96; + + + TextureD16[Pet*TextureB.Width + Pet2 + 1, 1] := Col; + TextureD16[Pet*TextureB.Width + Pet2 + 1, 2] := TempA; + end; + end; + glTexImage2D(GL_TEXTURE_2D, 0, 2, TextureB.Width, TextureB.Height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, @TextureD16); + + if Mipmapping then glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + if Mipmapping then begin + Error := gluBuild2DMipmaps(GL_TEXTURE_2D, 2, TextureB.Width, TextureB.Height, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, @TextureD16); + if Error > 0 then beep; + end; + end; + + if Typ = 'Font Outline 2' then begin + TextureB.PixelFormat := pf24bit; + for Pet := 0 to TextureB.Height-1 do begin + PPix := TextureB.ScanLine[Pet]; + for Pet2 := 0 to TextureB.Width-1 do begin + Pix := PPix[Pet2 * 3]; + + Col := Pix; + if Col < 31 then Col := 31; + + TempA := Pix; + if TempA >= 31 then TempA := 255; + if Pix < 31 then TempA := Pix * (256 div 32); + + TextureD16[Pet*TextureB.Width + Pet2 + 1, 1] := Col; + TextureD16[Pet*TextureB.Width + Pet2 + 1, 2] := TempA; + end; + end; + glTexImage2D(GL_TEXTURE_2D, 0, 2, TextureB.Width, TextureB.Height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, @TextureD16); + + if Mipmapping then glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + if Mipmapping then begin + Error := gluBuild2DMipmaps(GL_TEXTURE_2D, 2, TextureB.Width, TextureB.Height, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, @TextureD16); + if Error > 0 then beep; + end; + end; + + if Typ = 'Font Black' then begin + // normalnie 0,125s bez niczego 0,015s - 0,030s z pix 0,125s + // wymiary + TextureB.PixelFormat := pf24bit; + TexOrygW := TextureB.Width; + TexOrygH := TextureB.Height; + TexNewW := Round(Power(2, Ceil(Log2(TexOrygW)))); + TexNewH := Round(Power(2, Ceil(Log2(TexOrygH)))); + TextureB.Width := TexNewW; + TextureB.Height := TexNewH; + // kopiowanie + for Pet := 0 to TextureB.Height-1 do begin + PPix := TextureB.ScanLine[Pet]; + for Pet2 := 0 to TextureB.Width-1 do begin + Pix := PPix[Pet2*3]; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 1] := 255; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 2] := 255; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 3] := 255; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 4] := 255 - (Pix mod 256); + end; + end; + glTexImage2D(GL_TEXTURE_2D, 0, 4, TextureB.Width, TextureB.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, @TextureD32); + end; + + if Typ = 'Alpha Black Colored' then begin + TextureB.PixelFormat := pf24bit; + TexOrygW := TextureB.Width; + TexOrygH := TextureB.Height; + TexNewW := Round(Power(2, Ceil(Log2(TexOrygW)))); + TexNewH := Round(Power(2, Ceil(Log2(TexOrygH)))); + TextureB.Width := TexNewW; + TextureB.Height := TexNewH; + // kopiowanie + for Pet := 0 to TextureB.Height-1 do begin + PPix := TextureB.ScanLine[Pet]; + for Pet2 := 0 to TextureB.Width-1 do begin + Pix := PPix[Pet2*3]; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 1] := (Col div $10000) and $FF; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 2] := (Col div $100) and $FF; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 3] := Col and $FF; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 4] := 255 - (Pix mod 256); + end; + end; + glTexImage2D(GL_TEXTURE_2D, 0, 4, TextureB.Width, TextureB.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, @TextureD32); + end; + + if Typ = 'Font Gray' then begin + // wymiary + TexOrygW := TextureB.Width; + TexOrygH := TextureB.Height; + TexNewW := Round(Power(2, Ceil(Log2(TexOrygW)))); + TexNewH := Round(Power(2, Ceil(Log2(TexOrygH)))); + TextureB.Width := TexNewW; + TextureB.Height := TexNewH; + // kopiowanie + for Pet := 0 to TextureB.Height-1 do begin + for Pet2 := 0 to TextureB.Width-1 do begin + Pix := TextureB.Canvas.Pixels[Pet2, Pet]; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 1] := 127; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 2] := 127; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 3] := 127; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 4] := 255 - (Pix mod 256); + end; + end; + glTexImage2D(GL_TEXTURE_2D, 0, 4, TextureB.Width, TextureB.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, @TextureD32); +{ if Mipmapping then begin + Error := gluBuild2DMipmaps(GL_TEXTURE_2D, 4, TextureB.Width, TextureB.Height, GL_RGBA, GL_UNSIGNED_BYTE, @TextureD32); + if Error > 0 then beep; + end;} + end; + + if Typ = 'Arrow' then begin + TextureB.PixelFormat := pf24bit; + for Pet := 0 to TextureB.Height-1 do begin + PPix := TextureB.ScanLine[Pet]; + for Pet2 := 0 to TextureB.Width-1 do begin + Pix := PPix[Pet2 * 3]; + + // transparency + if Pix >= 127 then TempA := 255; + if Pix < 127 then TempA := Pix * 2; + + // ColInt = color intensity + if Pix < 127 then ColInt := 1; + if Pix >= 127 then ColInt := 2 - Pix / 128; + //0.75, 0.6, 0.25 + + TextureD32[Pet*TextureB.Width + Pet2 + 1, 1] := Round(ColInt * 0.75 * 255 + (1 - ColInt) * 255); + TextureD32[Pet*TextureB.Width + Pet2 + 1, 2] := Round(ColInt * 0.6 * 255 + (1 - ColInt) * 255); + TextureD32[Pet*TextureB.Width + Pet2 + 1, 3] := Round(ColInt * 0.25 * 255 + (1 - ColInt) * 255); + TextureD32[Pet*TextureB.Width + Pet2 + 1, 4] := TempA; + end; + end; + glTexImage2D(GL_TEXTURE_2D, 0, 4, TextureB.Width, TextureB.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, @TextureD32); + + if Mipmapping then glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + if Mipmapping then begin + Error := gluBuild2DMipmaps(GL_TEXTURE_2D, 4, TextureB.Width, TextureB.Height, GL_RGBA, GL_UNSIGNED_BYTE, @TextureD32); + if Error > 0 then beep; + end; + end; + + if Typ = 'Note Plain' then begin + for Pet := 0 to TextureB.Height-1 do begin + PPix := TextureB.ScanLine[Pet]; + for Pet2 := 0 to TextureB.Width-1 do begin + + + + // Skin Patch + // 0-191= Fade Black to Col, 192= Col, 193-254 Fade Col to White, 255= White + case PPix[Pet2*3] of + 0..191: Pix := $10000 * ((((Col div $10000) and $FF) * PPix[Pet2*3]) div $Bf) + $100 * ((((Col div $100) and $FF) * PPix[Pet2*3]) div $Bf) + (((Col and $FF) * PPix[Pet2*3]) div $Bf); + 192: Pix := Col; + 193..254: Pix := Col + ($10000 * ((($FF - ((Col div $10000) and $FF)) * ((PPix[Pet2*3] - $C0) * 4) ) div $FF) + $100 * ((($FF - ((Col div $100) and $FF)) * ((PPix[Pet2*3] - $C0) * 4)) div $FF) + ((($FF - (Col and $FF)) * ((PPix[Pet2*3] - $C0) * 4)) div $FF)); + 255: Pix := $FFFFFF; + end; +// 0.5.0. Original +// case PPix[Pet2*3] of +// 128: Pix := $10000 * ((Col div $10000) div 2) + $100 * (((Col div $100) and $FF) div 2) + (Col and $FF) div 2; +// 192: Pix := Col; +// 255: Pix := $FFFFFF; +// end; + + + + + + TextureD24[Pet*TextureB.Width + Pet2 + 1, 1] := Pix div $10000; + TextureD24[Pet*TextureB.Width + Pet2 + 1, 2] := (Pix div $100) and $FF; + TextureD24[Pet*TextureB.Width + Pet2 + 1, 3] := Pix and $FF; + end; + end; + glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureB.Width, TextureB.Height, 0, GL_RGB, GL_UNSIGNED_BYTE, @TextureD24); + end; + + if Typ = 'Note Transparent' then begin + for Pet := 0 to TextureB.Height-1 do begin + PPix := TextureB.ScanLine[Pet]; + for Pet2 := 0 to TextureB.Width-1 do begin + TempA := 255; + + + + //Skin Patch + // 0= Transparent, 1-191= Fade Black to Col, 192= Col, 193-254 Fade Col to White, 255= White + case PPix[Pet2*3] of + 0: TempA := 0; + 1..191: Pix := $10000 * ((((Col div $10000) and $FF) * PPix[Pet2*3]) div $Bf) + $100 * ((((Col div $100) and $FF) * PPix[Pet2*3]) div $Bf) + (((Col and $FF) * PPix[Pet2*3]) div $Bf); + 192: Pix := Col; + 193..254: Pix := Col + ($10000 * ((($FF - ((Col div $10000) and $FF)) * ((PPix[Pet2*3] - $C0) * 4) ) div $FF) + $100 * ((($FF - ((Col div $100) and $FF)) * ((PPix[Pet2*3] - $C0) * 4)) div $FF) + ((($FF - (Col and $FF)) * ((PPix[Pet2*3] - $C0) * 4)) div $FF)); + 255: Pix := $FFFFFF; + end; +// 0.5.0 Original +// case PPix[Pet2*3] of +// 0: TempA := 0; +// 128: Pix := $10000 * ((Col div $10000) div 2) + $100 * (((Col div $100) and $FF) div 2) + (Col and $FF) div 2; +// 192: Pix := Col; +// 255: Pix := $FFFFFF; +// end; + + + + + TextureD32[Pet*TextureB.Width + Pet2 + 1, 1] := Pix div $10000; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 2] := (Pix div $100) and $FF; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 3] := Pix and $FF; + TextureD32[Pet*TextureB.Width + Pet2 + 1, 4] := TempA; + end; + end; + glTexImage2D(GL_TEXTURE_2D, 0, 4, TextureB.Width, TextureB.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, @TextureD32); + end; + + + + + TextureB.Free; +// Inc(ActTex); +{ Tekst.Tekstura := ActTex; + Tekst.W := TexOrygW; + Tekst.H := TexOrygH; + Tekst.X2 := TexOrygW/TexNewW; + Tekst.Y2 := TexOrygH/TexNewH;} + Result.X := 0; + Result.Y := 0; + Result.W := 0; + Result.H := 0; + Result.ScaleW := 1; + Result.ScaleH := 1; + Result.Rot := 0; + Result.TexNum := ActTex; + Result.TexW := TexOrygW / TexNewW; + Result.TexH := TexOrygH / TexNewH; + + Result.Int := 1; + Result.ColR := 1; + Result.ColG := 1; + Result.ColB := 1; + Result.Alpha := 1; + + // 0.4.2 new test - default use whole texure, taking TexW and TexH as const and changing these + Result.TexX1 := 0; + Result.TexY1 := 0; + Result.TexX2 := 1; + Result.TexY2 := 1; + + // 0.5.0 + Result.Name := Nazwa; + + end; + + Log.BenchmarkEnd(4); + if Log.BenchmarkTimeLength[4] >= 1 then + Log.LogBenchmark('**********> Texture Load Time Warning - ' + Format + '/' + Nazwa + '/' + Typ, 4); + + end; // logerror +end; + +{procedure ResizeTexture(s: pbytearray; d: pbytearray); +var + Pet: integer; + Pet2: integer; +begin + for Pet := 0 to TexNewH*4-1 do + for Pet2 := 0 to TexNewW-1 do + d[Pet*TexNewW + Pet2] := 0; + + for Pet := 0 to TexOrygH-1 do begin + for Pet2 := 0 to TexOrygW-1 do begin + d[(Pet*TexNewW + Pet2)*4] := Paleta[s[Pet*TexOrygW + Pet2], 1]; + d[(Pet*TexNewW + Pet2)*4+1] := Paleta[s[Pet*TexOrygW + Pet2], 2]; + d[(Pet*TexNewW + Pet2)*4+2] := Paleta[s[Pet*TexOrygW + Pet2], 3]; + d[(Pet*TexNewW + Pet2)*4+3] := Paleta[s[Pet*TexOrygW + Pet2], 4]; + end; + end; +end;} + +{procedure SetTexture(p: pointer); +begin + glGenTextures(1, Tekstur); + glBindTexture(GL_TEXTURE_2D, Tekstur); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexImage2D(GL_TEXTURE_2D, 0, 4, TexNewW, TexNewH, 0, GL_RGBA, GL_UNSIGNED_BYTE, p); +end;} + +function TTextureUnit.LoadTexture(Nazwa, Format, Typ: PChar; Col: LongWord): TTexture; +begin + Result := LoadTexture(false, Nazwa, Format, Typ, Col); +// Result := LoadTexture(SkinReg, Nazwa, Format, Typ, Col); // default to SkinReg + +end; + +function TTextureUnit.LoadTexture(Nazwa: string): TTexture; +begin + Result := LoadTexture(false, pchar(Nazwa), 'JPG', 'Plain', 0); +end; + +function TTextureUnit.CreateTexture(var Data: array of byte; Name: string; W, H: word; Bits: byte): TTexture; +var + Pet: integer; + Pet2: integer; + Pix: integer; + ColInt: real; + PPix: PByteArray; + TempA: integer; + Error: integer; +begin + Mipmapping := false; + + glGenTextures(1, ActTex); // ActText = new texture number + glBindTexture(GL_TEXTURE_2D, ActTex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glTexImage2D(GL_TEXTURE_2D, 0, 3, W, H, 0, GL_RGB, GL_UNSIGNED_BYTE, @Data[0]); + if Mipmapping then begin + Error := gluBuild2DMipmaps(GL_TEXTURE_2D, 3, W, H, GL_RGB, GL_UNSIGNED_BYTE, @Data[0]); + if Error > 0 then beep; + end; + + +// Inc(ActTex); +{ Tekst.Tekstura := ActTex; + Tekst.W := TexOrygW; + Tekst.H := TexOrygH; + Tekst.X2 := TexOrygW/TexNewW; + Tekst.Y2 := TexOrygH/TexNewH;} + Result.X := 0; + Result.Y := 0; + Result.W := 0; + Result.H := 0; + Result.ScaleW := 1; + Result.ScaleH := 1; + Result.Rot := 0; + Result.TexNum := ActTex; + Result.TexW := 1; + Result.TexH := 1; + + Result.Int := 1; + Result.ColR := 1; + Result.ColG := 1; + Result.ColB := 1; + Result.Alpha := 1; + + // 0.4.2 new test - default use whole texure, taking TexW and TexH as const and changing these + Result.TexX1 := 0; + Result.TexY1 := 0; + Result.TexX2 := 1; + Result.TexY2 := 1; + + // 0.5.0 + Result.Name := Name; +end; + +procedure TTextureUnit.UnloadTexture(Name: string; FromCache: boolean); +var + T: integer; + TexNum: GLuint; +begin + T := FindTexture(Name); + + if not FromCache then begin + TexNum := TextureDatabase.Texture[T].Texture.TexNum; + if TexNum >= 0 then begin + glDeleteTextures(1, @TexNum); + TextureDatabase.Texture[T].Texture.TexNum := -1; +// Log.LogError('Unload texture no '+IntToStr(TexNum)); + end; + end else begin + TexNum := TextureDatabase.Texture[T].TextureCache.TexNum; + if TexNum >= 0 then begin + glDeleteTextures(1, @TexNum); + TextureDatabase.Texture[T].TextureCache.TexNum := -1; +// Log.LogError('Unload texture cache no '+IntToStr(TexNum)); + end; + end; +end; + +end. \ No newline at end of file diff --git a/Game/Code/Classes/UThemes.pas b/Game/Code/Classes/UThemes.pas new file mode 100644 index 00000000..b55a84dc --- /dev/null +++ b/Game/Code/Classes/UThemes.pas @@ -0,0 +1,2317 @@ +unit UThemes; + +interface + +uses +IniFiles, SysUtils, Classes; + +type + TRGB = record + R: single; + G: single; + B: single; + end; + + {TSkin = record + GrayLeft: string; + GrayMid: string; + GrayRight: string; + + NoteBGLeft: string; + NoteBGMid: string; + NoteBGRight: string; + + NoteStar: string; + + Ball: string; + + + + //SingBar Mod + SingBarBack: string; + SingBarBar: string; + SingBarFront: string; + //end Singbar Mod + + //PhrasenBonus - Line Bonus Mod + SingLineBonusBack: string; + //PhrasenBonus - Line Bonus Mod + + + + WelcomeBG: string; + + Background: string; + ScoreBG: string; + MainStart: string; + MainEditor: string; + MainOptions: string; + MainExit: string; + MainBar: string; + Cursor: string; + + SongFade: string; + SongCover: string; + SongSelection: string; + + SelectSong: string; + Button: string; + Bar: string; + P: string; + Arrow: string; + Arrow2: string; + ButtonF: string; + Star: string; + Line: string; + +// ThemePath: string; + SkinReg: boolean; + SkinName: string; + SkinPath: string; + SkinColor: integer; + end;} + + TThemeBackground = record + Tex: string; + end; + + TThemeStatic = record + X: integer; + Y: integer; + Z: real; + W: integer; + H: integer; + Color: string; + ColR: real; + ColG: real; + ColB: real; + Tex: string; + Typ: string; + TexX1: real; + TexY1: real; + TexX2: real; + TexY2: real; + //Reflection Mod + Reflection: boolean; + Reflectionspacing: Real; + end; + AThemeStatic = array of TThemeStatic; + + TThemeText = record + X: integer; + Y: integer; + W: integer; + Color: string; + ColR: real; + ColG: real; + ColB: real; + Font: integer; + Size: integer; + Align: integer; + Text: string; + end; + AThemeText = array of TThemeText; + + TThemeButton = record + Text: AThemeText; + X: integer; + Y: integer; + Z: Real; + W: integer; + H: integer; + Color: string; + ColR: real; + ColG: real; + ColB: real; + Int: real; + DColor: string; + DColR: real; + DColG: real; + DColB: real; + DInt: real; + Tex: string; + Typ: string; + + Visible: Boolean; + + //Reflection Mod + Reflection: boolean; + Reflectionspacing: Real; + //Fade Mod + SelectH: integer; + SelectW: integer; + Fade: boolean; + FadeText: boolean; + DeSelectReflectionspacing : Real; + FadeTex: string; + FadeTexPos: integer; + + //Button Collection Mod + Parent: Byte; //Number of the Button Collection this Button is assigned to. IF 0: No Assignement + end; + + //Button Collection Mod + TThemeButtonCollection = record + Style: TThemeButton; + ChildCount: Byte; //No of assigned Childs + FirstChild: Byte; //No of Child on whose Interaction Position the Button should be + end; + + AThemeButtonCollection = array of TThemeButtonCollection; + PAThemeButtonCollection = ^AThemeButtonCollection; + + TThemeSelect = record + Tex: string; + TexSBG: string; + X: integer; + Y: integer; + W: integer; + H: integer; + Text: string; + ColR, ColG, ColB, Int: real; + DColR, DColG, DColB, DInt: real; + TColR, TColG, TColB, TInt: real; + TDColR, TDColG, TDColB, TDInt: real; + SBGColR, SBGColG, SBGColB, SBGInt: real; + SBGDColR, SBGDColG, SBGDColB, SBGDInt: real; + STColR, STColG, STColB, STInt: real; + STDColR, STDColG, STDColB, STDInt: real; + SkipX: integer; + end; + + TThemeSelectSlide = record + Tex: string; + TexSBG: string; + X: integer; + Y: integer; + W: integer; + H: integer; + Z: real; + + TextSize: integer; + + //SBGW Mod + SBGW: integer; + + Text: string; + ColR, ColG, ColB, Int: real; + DColR, DColG, DColB, DInt: real; + TColR, TColG, TColB, TInt: real; + TDColR, TDColG, TDColB, TDInt: real; + SBGColR, SBGColG, SBGColB, SBGInt: real; + SBGDColR, SBGDColG, SBGDColB, SBGDInt: real; + STColR, STColG, STColB, STInt: real; + STDColR, STDColG, STDColB, STDInt: real; + SkipX: integer; + end; + + PThemeBasic = ^TThemeBasic; + TThemeBasic = class + Background: TThemeBackground; + Text: AThemeText; + Static: AThemeStatic; + + //Button Collection Mod + ButtonCollection: AThemeButtonCollection; + end; + + TThemeLoading = class(TThemeBasic) + StaticAnimation: TThemeStatic; + TextLoading: TThemeText; + end; + + TThemeMain = class(TThemeBasic) + ButtonSolo: TThemeButton; + ButtonMulti: TThemeButton; + ButtonStat: TThemeButton; + ButtonEditor: TThemeButton; + ButtonOptions: TThemeButton; + ButtonExit: TThemeButton; + + TextDescription: TThemeText; + TextDescriptionLong: TThemeText; + Description: array[0..5] of string; + DescriptionLong: array[0..5] of string; + end; + + TThemeName = class(TThemeBasic) + ButtonPlayer: array[1..6] of TThemeButton; + end; + + TThemeLevel = class(TThemeBasic) + ButtonEasy: TThemeButton; + ButtonMedium: TThemeButton; + ButtonHard: TThemeButton; + end; + + TThemeSong = class(TThemeBasic) + TextArtist: TThemeText; + TextTitle: TThemeText; + TextNumber: TThemeText; + + //Video Icon Mod + VideoIcon: TThemeStatic; + + //Show Cat in TopLeft Mod + TextCat: TThemeText; + StaticCat: TThemeStatic; + + //Cover Mod + Cover: record + Reflections: Boolean; + X: Integer; + Y: Integer; + Z: Integer; + W: Integer; + H: Integer; + Style: Integer; + end; + + //Equalizer Mod + Equalizer: record + Visible: Boolean; + Direction: Boolean; + Alpha: real; + X: Integer; + Y: Integer; + Z: Real; + W: Integer; + H: Integer; + Space: Integer; + Bands: Integer; + Length: Integer; + ColR, ColG, ColB: Real; + end; + + + //Party and Non Party specific Statics and Texts + StaticParty: AThemeStatic; + TextParty: AThemeText; + + StaticNonParty: AThemeStatic; + TextNonParty: AThemeText; + + //Party Mode + StaticTeam1Joker1: TThemeStatic; + StaticTeam1Joker2: TThemeStatic; + StaticTeam1Joker3: TThemeStatic; + StaticTeam1Joker4: TThemeStatic; + StaticTeam1Joker5: TThemeStatic; + StaticTeam2Joker1: TThemeStatic; + StaticTeam2Joker2: TThemeStatic; + StaticTeam2Joker3: TThemeStatic; + StaticTeam2Joker4: TThemeStatic; + StaticTeam2Joker5: TThemeStatic; + StaticTeam3Joker1: TThemeStatic; + StaticTeam3Joker2: TThemeStatic; + StaticTeam3Joker3: TThemeStatic; + StaticTeam3Joker4: TThemeStatic; + StaticTeam3Joker5: TThemeStatic; + + + end; + + TThemeSing = class(TThemeBasic) + + //TimeBar mod + StaticTimeProgress: TThemeStatic; + TextTimeText : TThemeText; + //eoa TimeBar mod + + StaticP1: TThemeStatic; + TextP1: TThemeText; + StaticP1ScoreBG: TThemeStatic; //Static for ScoreBG + TextP1Score: TThemeText; + + //moveable singbar mod + StaticP1SingBar: TThemeStatic; + StaticP1ThreePSingBar: TThemeStatic; + StaticP1TwoPSingBar: TThemeStatic; + StaticP2RSingBar: TThemeStatic; + StaticP2MSingBar: TThemeStatic; + StaticP3SingBar: TThemeStatic; + //eoa moveable singbar + + //added for ps3 skin + //game in 2/4 player modi + StaticP1TwoP: TThemeStatic; + StaticP1TwoPScoreBG: TThemeStatic; //Static for ScoreBG + TextP1TwoP: TThemeText; + TextP1TwoPScore: TThemeText; + //game in 3/6 player modi + StaticP1ThreeP: TThemeStatic; + StaticP1ThreePScoreBG: TThemeStatic; //Static for ScoreBG + TextP1ThreeP: TThemeText; + TextP1ThreePScore: TThemeText; + //eoa + + StaticP2R: TThemeStatic; + StaticP2RScoreBG: TThemeStatic; //Static for ScoreBG + TextP2R: TThemeText; + TextP2RScore: TThemeText; + + StaticP2M: TThemeStatic; + StaticP2MScoreBG: TThemeStatic; //Static for ScoreBG + TextP2M: TThemeText; + TextP2MScore: TThemeText; + + StaticP3R: TThemeStatic; + StaticP3RScoreBG: TThemeStatic; //Static for ScoreBG + TextP3R: TThemeText; + TextP3RScore: TThemeText; + + //Linebonus Translations + LineBonusText: Array [0..8] of String; + end; + + TThemeScore = class(TThemeBasic) + TextArtist: TThemeText; + TextTitle: TThemeText; + + TextArtistTitle: TThemeText; + + PlayerStatic: array[1..6] of AThemeStatic; + PlayerTexts: array[1..6] of AThemeText; + + TextName: array[1..6] of TThemeText; + TextScore: array[1..6] of TThemeText; + + TextNotes: array[1..6] of TThemeText; + TextNotesScore: array[1..6] of TThemeText; + TextLineBonus: array[1..6] of TThemeText; + TextLineBonusScore: array[1..6] of TThemeText; + TextGoldenNotes: array[1..6] of TThemeText; + TextGoldenNotesScore: array[1..6] of TThemeText; + TextTotal: array[1..6] of TThemeText; + TextTotalScore: array[1..6] of TThemeText; + + StaticBoxLightest: array[1..6] of TThemeStatic; + StaticBoxLight: array[1..6] of TThemeStatic; + StaticBoxDark: array[1..6] of TThemeStatic; + + StaticBackLevel: array[1..6] of TThemeStatic; + StaticBackLevelRound: array[1..6] of TThemeStatic; + StaticLevel: array[1..6] of TThemeStatic; + StaticLevelRound: array[1..6] of TThemeStatic; + +// Description: array[0..5] of string;} + end; + + TThemeTop5 = class(TThemeBasic) + TextLevel: TThemeText; + TextArtistTitle: TThemeText; + + StaticNumber: AThemeStatic; + TextNumber: AThemeText; + TextName: AThemeText; + TextScore: AThemeText; + end; + + TThemeOptions = class(TThemeBasic) + ButtonGame: TThemeButton; + ButtonGraphics: TThemeButton; + ButtonSound: TThemeButton; + ButtonLyrics: TThemeButton; + ButtonThemes: TThemeButton; + ButtonRecord: TThemeButton; + ButtonAdvanced: TThemeButton; + ButtonExit: TThemeButton; + + TextDescription: TThemeText; + Description: array[0..7] of string; + end; + + TThemeOptionsGame = class(TThemeBasic) + SelectPlayers: TThemeSelect; + SelectDifficulty: TThemeSelect; + SelectLanguage: TThemeSelectSlide; + SelectTabs: TThemeSelect; + SelectSorting: TThemeSelectSlide; + SelectDebug: TThemeSelect; + ButtonExit: TThemeButton; + end; + + TThemeOptionsGraphics = class(TThemeBasic) + SelectFullscreen: TThemeSelect; + SelectSlideResolution: TThemeSelectSlide; + SelectDepth: TThemeSelect; + SelectOscilloscope: TThemeSelect; + SelectLineBonus: TThemeSelect; + SelectMovieSize: TThemeSelect; + ButtonExit: TThemeButton; + end; + + TThemeOptionsSound = class(TThemeBasic) + SelectMicBoost: TThemeSelect; + SelectClickAssist: TThemeSelect; + SelectBeatClick: TThemeSelect; + SelectThreshold: TThemeSelect; + //Song Preview + SelectSlidePreviewVolume: TThemeSelectSlide; + SelectSlidePreviewFading: TThemeSelectSlide; + ButtonExit: TThemeButton; + end; + + TThemeOptionsLyrics = class(TThemeBasic) + SelectLyricsFont: TThemeSelect; + SelectLyricsEffect: TThemeSelect; + SelectSolmization: TThemeSelect; + ButtonExit: TThemeButton; + end; + + TThemeOptionsThemes = class(TThemeBasic) + SelectTheme: TThemeSelectSlide; + SelectSkin: TThemeSelectSlide; + SelectColor: TThemeSelectSlide; + ButtonExit: TThemeButton; + end; + + TThemeOptionsRecord = class(TThemeBasic) + SelectSlideCard: TThemeSelectSlide; + SelectSlideInput: TThemeSelectSlide; + SelectSlideChannelL: TThemeSelectSlide; + SelectSlideChannelR: TThemeSelectSlide; + ButtonExit: TThemeButton; + end; + + TThemeOptionsAdvanced = class(TThemeBasic) + SelectLoadAnimation: TThemeSelect; + SelectEffectSing: TThemeSelect; + SelectScreenFade: TThemeSelect; + SelectLineBonus: TThemeSelect; + SelectAskbeforeDel: TThemeSelect; + SelectOnSongClick: TThemeSelectSlide; + SelectPartyPopup: TThemeSelect; + ButtonExit: TThemeButton; + end; + + //Error- and Check-Popup + TThemeError = class(TThemeBasic) + Button1: TThemeButton; + TextError: TThemeText; + end; + + TThemeCheck = class(TThemeBasic) + Button1: TThemeButton; + Button2: TThemeButton; + TextCheck: TThemeText; + end; + + + //ScreenSong Menue + TThemeSongMenu = class(TThemeBasic) + Button1: TThemeButton; + Button2: TThemeButton; + Button3: TThemeButton; + Button4: TThemeButton; + + SelectSlide3: TThemeSelectSlide; + + TextMenu: TThemeText; + end; + + TThemeSongJumpTo = class(TThemeBasic) + ButtonSearchText: TThemeButton; + SelectSlideType: TThemeSelectSlide; + TextFound: TThemeText; + + //Translated Texts + Songsfound: String; + NoSongsfound: String; + CatText: String; + IType: array [0..2] of String; + end; + + //Party Screens + TThemePartyNewRound = class(TThemeBasic) + TextRound1: TThemeText; + TextRound2: TThemeText; + TextRound3: TThemeText; + TextRound4: TThemeText; + TextRound5: TThemeText; + TextRound6: TThemeText; + TextRound7: TThemeText; + TextWinner1: TThemeText; + TextWinner2: TThemeText; + TextWinner3: TThemeText; + TextWinner4: TThemeText; + TextWinner5: TThemeText; + TextWinner6: TThemeText; + TextWinner7: TThemeText; + TextNextRound: TThemeText; + TextNextRoundNo: TThemeText; + TextNextPlayer1: TThemeText; + TextNextPlayer2: TThemeText; + TextNextPlayer3: TThemeText; + + StaticRound1: TThemeStatic; + StaticRound2: TThemeStatic; + StaticRound3: TThemeStatic; + StaticRound4: TThemeStatic; + StaticRound5: TThemeStatic; + StaticRound6: TThemeStatic; + StaticRound7: TThemeStatic; + + TextScoreTeam1: TThemeText; + TextScoreTeam2: TThemeText; + TextScoreTeam3: TThemeText; + TextNameTeam1: TThemeText; + TextNameTeam2: TThemeText; + TextNameTeam3: TThemeText; + TextTeam1Players: TThemeText; + TextTeam2Players: TThemeText; + TextTeam3Players: TThemeText; + + StaticTeam1: TThemeStatic; + StaticTeam2: TThemeStatic; + StaticTeam3: TThemeStatic; + StaticNextPlayer1: TThemeStatic; + StaticNextPlayer2: TThemeStatic; + StaticNextPlayer3: TThemeStatic; + end; + + TThemePartyScore = class(TThemeBasic) + TextScoreTeam1: TThemeText; + TextScoreTeam2: TThemeText; + TextScoreTeam3: TThemeText; + TextNameTeam1: TThemeText; + TextNameTeam2: TThemeText; + TextNameTeam3: TThemeText; + StaticTeam1: TThemeStatic; + StaticTeam1BG: TThemeStatic; + StaticTeam1Deco: TThemeStatic; + StaticTeam2: TThemeStatic; + StaticTeam2BG: TThemeStatic; + StaticTeam2Deco: TThemeStatic; + StaticTeam3: TThemeStatic; + StaticTeam3BG: TThemeStatic; + StaticTeam3Deco: TThemeStatic; + + DecoTextures: record + ChangeTextures: Boolean; + + FirstTexture: String; + FirstTyp: String; + FirstColor: String; + + SecondTexture: String; + SecondTyp: String; + SecondColor: String; + + ThirdTexture: String; + ThirdTyp: String; + ThirdColor: String; + end; + + + TextWinner: TThemeText; + end; + + TThemePartyWin = class(TThemeBasic) + TextScoreTeam1: TThemeText; + TextScoreTeam2: TThemeText; + TextScoreTeam3: TThemeText; + TextNameTeam1: TThemeText; + TextNameTeam2: TThemeText; + TextNameTeam3: TThemeText; + StaticTeam1: TThemeStatic; + StaticTeam1BG: TThemeStatic; + StaticTeam1Deco: TThemeStatic; + StaticTeam2: TThemeStatic; + StaticTeam2BG: TThemeStatic; + StaticTeam2Deco: TThemeStatic; + StaticTeam3: TThemeStatic; + StaticTeam3BG: TThemeStatic; + StaticTeam3Deco: TThemeStatic; + + TextWinner: TThemeText; + end; + + TThemePartyOptions = class(TThemeBasic) + SelectLevel: TThemeSelectSlide; + SelectPlayList: TThemeSelectSlide; + SelectPlayList2: TThemeSelectSlide; + SelectRounds: TThemeSelectSlide; + SelectTeams: TThemeSelectSlide; + SelectPlayers1: TThemeSelectSlide; + SelectPlayers2: TThemeSelectSlide; + SelectPlayers3: TThemeSelectSlide; + + {ButtonNext: TThemeButton; + ButtonPrev: TThemeButton;} + end; + + TThemePartyPlayer = class(TThemeBasic) + Team1Name: TThemeButton; + Player1Name: TThemeButton; + Player2Name: TThemeButton; + Player3Name: TThemeButton; + Player4Name: TThemeButton; + + Team2Name: TThemeButton; + Player5Name: TThemeButton; + Player6Name: TThemeButton; + Player7Name: TThemeButton; + Player8Name: TThemeButton; + + Team3Name: TThemeButton; + Player9Name: TThemeButton; + Player10Name: TThemeButton; + Player11Name: TThemeButton; + Player12Name: TThemeButton; + + {ButtonNext: TThemeButton; + ButtonPrev: TThemeButton;} + end; + + //Stats Screens + TThemeStatMain = class(TThemeBasic) + ButtonScores: TThemeButton; + ButtonSingers: TThemeButton; + ButtonSongs: TThemeButton; + ButtonBands: TThemeButton; + ButtonExit: TThemeButton; + + TextOverview: TThemeText; + end; + + TThemeStatDetail = class(TThemeBasic) + ButtonNext: TThemeButton; + ButtonPrev: TThemeButton; + ButtonReverse: TThemeButton; + ButtonExit: TThemeButton; + + TextDescription: TThemeText; + TextPage: TThemeText; + TextList: AThemeText; + + Description: array[0..3] of string; + DescriptionR: array[0..3] of string; + FormatStr: array[0..3] of string; + PageStr: String; + end; + + //Playlist Translations + TThemePlaylist = record + CatText: string; + end; + + TTheme = class + private + {$IFDEF THEMESAVE} + ThemeIni: TIniFile; + {$ELSE} + ThemeIni: TMemIniFile; + {$ENDIF} + + LastThemeBasic: TThemeBasic; + public + + Loading: TThemeLoading; + Main: TThemeMain; + Name: TThemeName; + Level: TThemeLevel; + Song: TThemeSong; + Sing: TThemeSing; + Score: TThemeScore; + Top5: TThemeTop5; + Options: TThemeOptions; + OptionsGame: TThemeOptionsGame; + OptionsGraphics: TThemeOptionsGraphics; + OptionsSound: TThemeOptionsSound; + OptionsLyrics: TThemeOptionsLyrics; + OptionsThemes: TThemeOptionsThemes; + OptionsRecord: TThemeOptionsRecord; + OptionsAdvanced: TThemeOptionsAdvanced; + //error and check popup + ErrorPopup: TThemeError; + CheckPopup: TThemeCheck; + //ScreenSong extensions + SongMenu: TThemeSongMenu; + SongJumpto: TThemeSongJumpTo; + //Party Screens: + PartyNewRound: TThemePartyNewRound; + PartyScore: TThemePartyScore; + PartyWin: TThemePartyWin; + PartyOptions: TThemePartyOptions; + PartyPlayer: TThemePartyPlayer; + + //Stats Screens: + StatMain: TThemeStatMain; + StatDetail: TThemeStatDetail; + + Playlist: TThemePlaylist; + + ILevel: array[0..2] of String; + + constructor Create(FileName: string); overload; // Initialize theme system + constructor Create(FileName: string; Color: integer); overload; // Initialize theme system with color + function LoadTheme(FileName: string; sColor: integer): boolean; // Load some theme settings from file + + procedure LoadColors; + + procedure ThemeLoadBasic(Theme: TThemeBasic; Name: string); + procedure ThemeLoadBackground(var ThemeBackground: TThemeBackground; Name: string); + procedure ThemeLoadText(var ThemeText: TThemeText; Name: string); + procedure ThemeLoadTexts(var ThemeText: AThemeText; Name: string); + procedure ThemeLoadStatic(var ThemeStatic: TThemeStatic; Name: string); + procedure ThemeLoadStatics(var ThemeStatic: AThemeStatic; Name: string); + procedure ThemeLoadButton(var ThemeButton: TThemeButton; Name: string; const Collections: PAThemeButtonCollection = nil); + procedure ThemeLoadButtonCollection(var Collection: TThemeButtonCollection; Name: string); + procedure ThemeLoadButtonCollections(var Collections: AThemeButtonCollection; Name: string); + procedure ThemeLoadSelect(var ThemeSelect: TThemeSelect; Name: string); + procedure ThemeLoadSelectSlide(var ThemeSelectS: TThemeSelectSlide; Name: string); + + procedure ThemeSave(FileName: string); + procedure ThemeSaveBasic(Theme: TThemeBasic; Name: string); + procedure ThemeSaveBackground(ThemeBackground: TThemeBackground; Name: string); + procedure ThemeSaveStatic(ThemeStatic: TThemeStatic; Name: string); + procedure ThemeSaveStatics(ThemeStatic: AThemeStatic; Name: string); + procedure ThemeSaveText(ThemeText: TThemeText; Name: string); + procedure ThemeSaveTexts(ThemeText: AThemeText; Name: string); + procedure ThemeSaveButton(ThemeButton: TThemeButton; Name: string); + + end; + + TColor = record + Name: string; + RGB: TRGB; + end; + +function ColorExists(Name: string): integer; +procedure LoadColor(var R, G, B: real; ColorName: string); +function GetSystemColor(Color: integer): TRGB; +function ColorSqrt(RGB: TRGB): TRGB; + +var + //Skin: TSkin; + Theme: TTheme; + Color: array of TColor; + +implementation + +uses +{{$IFDEF TRANSLATE} + ULanguage, +{{$ENDIF} +USkins, UIni, Dialogs; + +constructor TTheme.Create(FileName: string); +begin + Create(FileName, 0); +end; + +constructor TTheme.Create(FileName: string; Color: integer); +begin + Loading := TThemeLoading.Create; + Main := TThemeMain.Create; + Name := TThemeName.Create; + Level := TThemeLevel.Create; + Song := TThemeSong.Create; + Sing := TThemeSing.Create; + Score := TThemeScore.Create; + Top5 := TThemeTop5.Create; + Options := TThemeOptions.Create; + OptionsGame := TThemeOptionsGame.Create; + OptionsGraphics := TThemeOptionsGraphics.Create; + OptionsSound := TThemeOptionsSound.Create; + OptionsLyrics := TThemeOptionsLyrics.Create; + OptionsThemes := TThemeOptionsThemes.Create; + OptionsRecord := TThemeOptionsRecord.Create; + OptionsAdvanced := TThemeOptionsAdvanced.Create; + + ErrorPopup := TThemeError.Create; + CheckPopup := TThemeCheck.Create; + + SongMenu := TThemeSongMenu.Create; + SongJumpto := TThemeSongJumpto.Create; + //Party Screens + PartyNewRound := TThemePartyNewRound.Create; + PartyWin := TThemePartyWin.Create; + PartyScore := TThemePartyScore.Create; + PartyOptions := TThemePartyOptions.Create; + PartyPlayer := TThemePartyPlayer.Create; + + //Stats Screens: + StatMain := TThemeStatMain.Create; + StatDetail := TThemeStatDetail.Create; + + LoadTheme(FileName, Color); + + + {Skin.GrayLeft := 'Left Gray.bmp'; + Skin.GrayMid := 'Mid Gray.bmp'; + Skin.GrayRight := 'Right Gray.bmp'; + + Skin.NoteBGLeft := 'Note BG Left.bmp'; + Skin.NoteBGMid := 'Note BG Mid.bmp'; + Skin.NoteBGRight := 'Note BG Right.bmp'; + + Skin.NoteStar := 'Note Star.jpg'; + + + + //SingBar Mod + Skin.SingBarBack := 'Sing Bar Back.jpg'; + Skin.SingBarBar := 'Sing Bar Bar.jpg'; + Skin.SingBarFront := 'Sing Bar Front.jpg'; + //end Singbar Mod + + //PhrasenBonus - Line Bonus Mod + Skin.SingLineBonusBack := 'Line Bonus PopUp.jpg'; + + + + +{ Skin.WelcomeBG := SkinPath + 'Welcome BG.jpg'; +// Skin.Background := SkinPath + 'Background.jpg'; + Skin.ScoreBG := SkinPath + 'Score BG.jpg'; +// Skin.GameStart := SkinPath + 'Game Start.jpg'; +// Skin.Editor := SkinPath + 'Editor.jpg'; +// Skin.Options := SkinPath + 'Options.jpg'; +// Skin.Exit := SkinPath + 'Exit.jpg'; + + Skin.MainStart := SkinPath + 'Main Solo.jpg'; + Skin.MainEditor := SkinPath + 'Main Multi.jpg'; + Skin.MainOptions := SkinPath + 'Main Options.jpg'; + Skin.MainExit := SkinPath + 'Main Exit.jpg'; + Skin.MainBar := SkinPath + 'Main Bar.jpg'; + Skin.Cursor := SkinPath + 'Main Cursor.jpg'; + + Skin.SongFade := SkinPath + 'Song Fade.jpg';}{ + Skin.SongCover := 'Song Cover.jpg'; + {Skin.SongSelection := SkinPath + 'Song Selection.jpg'; + + Skin.SelectSong := SkinPath + 'Select Song.jpg';}{ +// Skin.Button := SkinPath + 'MusicWheelItem song.jpg'; + Skin.Bar := 'Bar.jpg'; +{ Skin.P := SkinPath + 'P.jpg'; + Skin.Arrow := SkinPath + 'Arrow.jpg'; + Skin.Arrow2 := SkinPath + 'Arrow 2.jpg';}{ + Skin.ButtonF := 'Button.jpg'; + Skin.Ball := 'Ball3.bmp'; +{ Skin.Star := SkinPath + 'Star.bmp'; + Skin.Line := SkinPath + 'Line.jpg';} +end; + + +function TTheme.LoadTheme(FileName: string; sColor: integer): boolean; +var + I: integer; + Path: string; +begin + Result := false; + if FileExists(FileName) then begin + Result := true; + + {$IFDEF THEMESAVE} + ThemeIni := TIniFile.Create(FileName); + {$ELSE} + ThemeIni := TMemIniFile.Create(FileName); + {$ENDIF} + + if ThemeIni.ReadString('Theme', 'Name', '') <> '' then begin + + {Skin.SkinName := ThemeIni.ReadString('Theme', 'Name', 'Singstar'); + Skin.SkinPath := 'Skins\' + Skin.SkinName + '\'; + Skin.SkinReg := false; } + Skin.Color := sColor; + + Skin.LoadSkin(ISkin[Ini.SkinNo]); + + LoadColors; + +// ThemeIni.Free; +// ThemeIni := TIniFile.Create('Themes\Singstar\Main.ini'); + + // Loading + ThemeLoadBasic(Loading, 'Loading'); + ThemeLoadText(Loading.TextLoading, 'LoadingTextLoading'); + ThemeLoadStatic(Loading.StaticAnimation, 'LoadingStaticAnimation'); + + // Main + ThemeLoadBasic(Main, 'Main'); + + ThemeLoadText(Main.TextDescription, 'MainTextDescription'); + ThemeLoadText(Main.TextDescriptionLong, 'MainTextDescriptionLong'); + ThemeLoadButton(Main.ButtonSolo, 'MainButtonSolo'); + ThemeLoadButton(Main.ButtonMulti, 'MainButtonMulti'); + ThemeLoadButton(Main.ButtonStat, 'MainButtonStats'); + ThemeLoadButton(Main.ButtonEditor, 'MainButtonEditor'); + ThemeLoadButton(Main.ButtonOptions, 'MainButtonOptions'); + ThemeLoadButton(Main.ButtonExit, 'MainButtonExit'); + + //Main Desc Text Translation Start + + {{$IFDEF TRANSLATE} + Main.Description[0] := Language.Translate('SING_SING'); + Main.DescriptionLong[0] := Language.Translate('SING_SING_DESC'); + Main.Description[1] := Language.Translate('SING_MULTI'); + Main.DescriptionLong[1] := Language.Translate('SING_MULTI_DESC'); + Main.Description[2] := Language.Translate('SING_STATS'); + Main.DescriptionLong[2] := Language.Translate('SING_STATS_DESC'); + Main.Description[3] := Language.Translate('SING_EDITOR'); + Main.DescriptionLong[3] := Language.Translate('SING_EDITOR_DESC'); + Main.Description[4] := Language.Translate('SING_GAME_OPTIONS'); + Main.DescriptionLong[4] := Language.Translate('SING_GAME_OPTIONS_DESC'); + Main.Description[5] := Language.Translate('SING_EXIT'); + Main.DescriptionLong[5] := Language.Translate('SING_EXIT_DESC'); + {{$ENDIF} + + //Main Desc Text Translation End + + Main.TextDescription.Text := Main.Description[0]; + Main.TextDescriptionLong.Text := Main.DescriptionLong[0]; + + // Name + ThemeLoadBasic(Name, 'Name'); + + for I := 1 to 6 do + ThemeLoadButton(Name.ButtonPlayer[I], 'NameButtonPlayer'+IntToStr(I)); + + // Level + ThemeLoadBasic(Level, 'Level'); + + ThemeLoadButton(Level.ButtonEasy, 'LevelButtonEasy'); + ThemeLoadButton(Level.ButtonMedium, 'LevelButtonMedium'); + ThemeLoadButton(Level.ButtonHard, 'LevelButtonHard'); + + + // Song + ThemeLoadBasic(Song, 'Song'); + + ThemeLoadText(Song.TextArtist, 'SongTextArtist'); + ThemeLoadText(Song.TextTitle, 'SongTextTitle'); + ThemeLoadText(Song.TextNumber, 'SongTextNumber'); + + //Video Icon Mod + ThemeLoadStatic(Song.VideoIcon, 'SongVideoIcon'); + + //Show Cat in TopLeft Mod + ThemeLoadStatic(Song.StaticCat, 'SongStaticCat'); + ThemeLoadText(Song.TextCat, 'SongTextCat'); + + //Load Cover Pos and Size from Theme Mod + Song.Cover.X := ThemeIni.ReadInteger('SongCover', 'X', 300); + Song.Cover.Y := ThemeIni.ReadInteger('SongCover', 'Y', 190); + Song.Cover.W := ThemeIni.ReadInteger('SongCover', 'W', 300); + Song.Cover.H := ThemeIni.ReadInteger('SongCover', 'H', 200); + Song.Cover.Style := ThemeIni.ReadInteger('SongCover', 'Style', 4); + Song.Cover.Reflections := (ThemeIni.ReadInteger('SongCover', 'Reflections', 0) = 1); + //Load Cover Pos and Size from Theme Mod End + + //Load Equalizer Pos and Size from Theme Mod + Song.Equalizer.Visible := (ThemeIni.ReadInteger('SongEqualizer', 'Visible', 0) = 1); + Song.Equalizer.Direction := (ThemeIni.ReadInteger('SongEqualizer', 'Direction', 0) = 1); + Song.Equalizer.Alpha := ThemeIni.ReadInteger('SongEqualizer', 'Alpha', 1); + Song.Equalizer.Space := ThemeIni.ReadInteger('SongEqualizer', 'Space', 1); + Song.Equalizer.X := ThemeIni.ReadInteger('SongEqualizer', 'X', 0); + Song.Equalizer.Y := ThemeIni.ReadInteger('SongEqualizer', 'Y', 0); + Song.Equalizer.Z := ThemeIni.ReadInteger('SongEqualizer', 'Z', 1); + Song.Equalizer.W := ThemeIni.ReadInteger('SongEqualizer', 'PieceW', 8); + Song.Equalizer.H := ThemeIni.ReadInteger('SongEqualizer', 'PieceH', 8); + Song.Equalizer.Bands := ThemeIni.ReadInteger('SongEqualizer', 'Bands', 5); + Song.Equalizer.Length := ThemeIni.ReadInteger('SongEqualizer', 'Length', 12); + + //Color + I := ColorExists(ThemeIni.ReadString('SongEqualizer', 'Color', 'Black')); + if I >= 0 then begin + Song.Equalizer.ColR := Color[I].RGB.R; + Song.Equalizer.ColG := Color[I].RGB.G; + Song.Equalizer.ColB := Color[I].RGB.B; + end + else begin + Song.Equalizer.ColR := 0; + Song.Equalizer.ColG := 0; + Song.Equalizer.ColB := 0; + end; + //Load Equalizer Pos and Size from Theme Mod End + + //Party and Non Party specific Statics and Texts + ThemeLoadStatics (Song.StaticParty, 'SongStaticParty'); + ThemeLoadTexts (Song.TextParty, 'SongTextParty'); + + ThemeLoadStatics (Song.StaticNonParty, 'SongStaticNonParty'); + ThemeLoadTexts (Song.TextNonParty, 'SongTextNonParty'); + + //Party Mode + ThemeLoadStatic(Song.StaticTeam1Joker1, 'SongStaticTeam1Joker1'); + ThemeLoadStatic(Song.StaticTeam1Joker2, 'SongStaticTeam1Joker2'); + ThemeLoadStatic(Song.StaticTeam1Joker3, 'SongStaticTeam1Joker3'); + ThemeLoadStatic(Song.StaticTeam1Joker4, 'SongStaticTeam1Joker4'); + ThemeLoadStatic(Song.StaticTeam1Joker5, 'SongStaticTeam1Joker5'); + + ThemeLoadStatic(Song.StaticTeam2Joker1, 'SongStaticTeam2Joker1'); + ThemeLoadStatic(Song.StaticTeam2Joker2, 'SongStaticTeam2Joker2'); + ThemeLoadStatic(Song.StaticTeam2Joker3, 'SongStaticTeam2Joker3'); + ThemeLoadStatic(Song.StaticTeam2Joker4, 'SongStaticTeam2Joker4'); + ThemeLoadStatic(Song.StaticTeam2Joker5, 'SongStaticTeam2Joker5'); + + ThemeLoadStatic(Song.StaticTeam3Joker1, 'SongStaticTeam3Joker1'); + ThemeLoadStatic(Song.StaticTeam3Joker2, 'SongStaticTeam3Joker2'); + ThemeLoadStatic(Song.StaticTeam3Joker3, 'SongStaticTeam3Joker3'); + ThemeLoadStatic(Song.StaticTeam3Joker4, 'SongStaticTeam3Joker4'); + ThemeLoadStatic(Song.StaticTeam3Joker5, 'SongStaticTeam3Joker5'); + + + // Sing + ThemeLoadBasic(Sing, 'Sing'); + + //TimeBar mod + ThemeLoadStatic(Sing.StaticTimeProgress, 'SingTimeProgress'); + ThemeLoadText(Sing.TextTimeText, 'SingTimeText'); + //eoa TimeBar mod + + //moveable singbar mod + ThemeLoadStatic(Sing.StaticP1SingBar, 'SingP1SingBar'); + ThemeLoadStatic(Sing.StaticP1TwoPSingBar, 'SingP1TwoPSingBar'); + ThemeLoadStatic(Sing.StaticP1ThreePSingBar, 'SingP1ThreePSingBar'); + ThemeLoadStatic(Sing.StaticP2RSingBar, 'SingP2RSingBar'); + ThemeLoadStatic(Sing.StaticP2MSingBar, 'SingP2MSingBar'); + ThemeLoadStatic(Sing.StaticP3SingBar, 'SingP3SingBar'); + //eoa moveable singbar + + ThemeLoadStatic(Sing.StaticP1, 'SingP1Static'); + ThemeLoadText(Sing.TextP1, 'SingP1Text'); + ThemeLoadStatic(Sing.StaticP1ScoreBG, 'SingP1Static2'); + ThemeLoadText(Sing.TextP1Score, 'SingP1TextScore'); + //Added for ps3 skin + //This one is shown in 2/4P mode + //if it exists, otherwise the one Player equivaltents are used + if (ThemeIni.SectionExists('SingP1TwoPTextScore')) then + begin + ThemeLoadStatic(Sing.StaticP1TwoP, 'SingP1TwoPStatic'); + ThemeLoadText(Sing.TextP1TwoP, 'SingP1TwoPText'); + ThemeLoadStatic(Sing.StaticP1TwoPScoreBG, 'SingP1TwoPStatic2'); + ThemeLoadText(Sing.TextP1TwoPScore, 'SingP1TwoPTextScore'); + end + else + begin + Sing.StaticP1TwoP := Sing.StaticP1; + Sing.TextP1TwoP := Sing.TextP1; + Sing.StaticP1TwoPScoreBG := Sing.StaticP1ScoreBG; + Sing.TextP1TwoPScore := Sing.TextP1Score; + end; + + //This one is shown in 3/6P mode + //if it exists, otherwise the one Player equivaltents are used + if (ThemeIni.SectionExists('SingP1TwoPTextScore')) then + begin + ThemeLoadStatic(Sing.StaticP1ThreeP, 'SingP1ThreePStatic'); + ThemeLoadText(Sing.TextP1ThreeP, 'SingP1ThreePText'); + ThemeLoadStatic(Sing.StaticP1ThreePScoreBG, 'SingP1ThreePStatic2'); + ThemeLoadText(Sing.TextP1ThreePScore, 'SingP1ThreePTextScore'); + end + else + begin + Sing.StaticP1ThreeP := Sing.StaticP1; + Sing.TextP1ThreeP := Sing.TextP1; + Sing.StaticP1ThreePScoreBG := Sing.StaticP1ScoreBG; + Sing.TextP1ThreePScore := Sing.TextP1Score; + end; + //eoa + ThemeLoadStatic(Sing.StaticP2R, 'SingP2RStatic'); + ThemeLoadText(Sing.TextP2R, 'SingP2RText'); + ThemeLoadStatic(Sing.StaticP2RScoreBG, 'SingP2RStatic2'); + ThemeLoadText(Sing.TextP2RScore, 'SingP2RTextScore'); + + ThemeLoadStatic(Sing.StaticP2M, 'SingP2MStatic'); + ThemeLoadText(Sing.TextP2M, 'SingP2MText'); + ThemeLoadStatic(Sing.StaticP2MScoreBG, 'SingP2MStatic2'); + ThemeLoadText(Sing.TextP2MScore, 'SingP2MTextScore'); + + ThemeLoadStatic(Sing.StaticP3R, 'SingP3RStatic'); + ThemeLoadText(Sing.TextP3R, 'SingP3RText'); + ThemeLoadStatic(Sing.StaticP3RScoreBG, 'SingP3RStatic2'); + ThemeLoadText(Sing.TextP3RScore, 'SingP3RTextScore'); + + //Line Bonus Texts + Sing.LineBonusText[0] := Language.Translate('POPUP_AWFUL'); + Sing.LineBonusText[1] := Sing.LineBonusText[0]; + Sing.LineBonusText[2] := Language.Translate('POPUP_POOR'); + Sing.LineBonusText[3] := Language.Translate('POPUP_BAD'); + Sing.LineBonusText[4] := Language.Translate('POPUP_NOTBAD'); + Sing.LineBonusText[5] := Language.Translate('POPUP_GOOD'); + Sing.LineBonusText[6] := Language.Translate('POPUP_GREAT'); + Sing.LineBonusText[7] := Language.Translate('POPUP_AWESOME'); + Sing.LineBonusText[8] := Language.Translate('POPUP_PERFECT'); + + // Score + ThemeLoadBasic(Score, 'Score'); + + ThemeLoadText(Score.TextArtist, 'ScoreTextArtist'); + ThemeLoadText(Score.TextTitle, 'ScoreTextTitle'); + ThemeLoadText(Score.TextArtistTitle, 'ScoreTextArtistTitle'); + + for I := 1 to 6 do begin + ThemeLoadStatics(Score.PlayerStatic[I], 'ScorePlayer' + IntToStr(I) + 'Static'); + ThemeLoadTexts(Score.PlayerTexts[I], 'ScorePlayer' + IntToStr(I) + 'Text'); + + ThemeLoadText(Score.TextName[I], 'ScoreTextName' + IntToStr(I)); + ThemeLoadText(Score.TextScore[I], 'ScoreTextScore' + IntToStr(I)); + ThemeLoadText(Score.TextNotes[I], 'ScoreTextNotes' + IntToStr(I)); + ThemeLoadText(Score.TextNotesScore[I], 'ScoreTextNotesScore' + IntToStr(I)); + ThemeLoadText(Score.TextLineBonus[I], 'ScoreTextLineBonus' + IntToStr(I)); + ThemeLoadText(Score.TextLineBonusScore[I], 'ScoreTextLineBonusScore' + IntToStr(I)); + ThemeLoadText(Score.TextGoldenNotes[I], 'ScoreTextGoldenNotes' + IntToStr(I)); + ThemeLoadText(Score.TextGoldenNotesScore[I], 'ScoreTextGoldenNotesScore' + IntToStr(I)); + ThemeLoadText(Score.TextTotal[I], 'ScoreTextTotal' + IntToStr(I)); + ThemeLoadText(Score.TextTotalScore[I], 'ScoreTextTotalScore' + IntToStr(I)); + + ThemeLoadStatic(Score.StaticBoxLightest[I], 'ScoreStaticBoxLightest' + IntToStr(I)); + ThemeLoadStatic(Score.StaticBoxLight[I], 'ScoreStaticBoxLight' + IntToStr(I)); + ThemeLoadStatic(Score.StaticBoxDark[I], 'ScoreStaticBoxDark' + IntToStr(I)); + + ThemeLoadStatic(Score.StaticBackLevel[I], 'ScoreStaticBackLevel' + IntToStr(I)); + ThemeLoadStatic(Score.StaticBackLevelRound[I], 'ScoreStaticBackLevelRound' + IntToStr(I)); + ThemeLoadStatic(Score.StaticLevel[I], 'ScoreStaticLevel' + IntToStr(I)); + ThemeLoadStatic(Score.StaticLevelRound[I], 'ScoreStaticLevelRound' + IntToStr(I)); + end; + + // Top5 + ThemeLoadBasic(Top5, 'Top5'); + + ThemeLoadText(Top5.TextLevel, 'Top5TextLevel'); + ThemeLoadText(Top5.TextArtistTitle, 'Top5TextArtistTitle'); + ThemeLoadStatics(Top5.StaticNumber, 'Top5StaticNumber'); + ThemeLoadTexts(Top5.TextNumber, 'Top5TextNumber'); + ThemeLoadTexts(Top5.TextName, 'Top5TextName'); + ThemeLoadTexts(Top5.TextScore, 'Top5TextScore'); + + // Options + ThemeLoadBasic(Options, 'Options'); + + ThemeLoadButton(Options.ButtonGame, 'OptionsButtonGame'); + ThemeLoadButton(Options.ButtonGraphics, 'OptionsButtonGraphics'); + ThemeLoadButton(Options.ButtonSound, 'OptionsButtonSound'); + ThemeLoadButton(Options.ButtonLyrics, 'OptionsButtonLyrics'); + ThemeLoadButton(Options.ButtonThemes, 'OptionsButtonThemes'); + ThemeLoadButton(Options.ButtonRecord, 'OptionsButtonRecord'); + ThemeLoadButton(Options.ButtonAdvanced, 'OptionsButtonAdvanced'); + ThemeLoadButton(Options.ButtonExit, 'OptionsButtonExit'); + + {{$IFDEF TRANSLATE} + Options.Description[0] := Language.Translate('SING_OPTIONS_GAME'); + Options.Description[1] := Language.Translate('SING_OPTIONS_GRAPHICS'); + Options.Description[2] := Language.Translate('SING_OPTIONS_SOUND'); + Options.Description[3] := Language.Translate('SING_OPTIONS_LYRICS'); + Options.Description[4] := Language.Translate('SING_OPTIONS_THEMES'); + Options.Description[5] := Language.Translate('SING_OPTIONS_RECORD'); + Options.Description[6] := Language.Translate('SING_OPTIONS_ADVANCED'); + Options.Description[7] := Language.Translate('SING_OPTIONS_EXIT'); + {{$ENDIF} + + ThemeLoadText(Options.TextDescription, 'OptionsTextDescription'); + Options.TextDescription.Text := Options.Description[0]; + + // Options Game + ThemeLoadBasic(OptionsGame, 'OptionsGame'); + + ThemeLoadSelect(OptionsGame.SelectPlayers, 'OptionsGameSelectPlayers'); + ThemeLoadSelect(OptionsGame.SelectDifficulty, 'OptionsGameSelectDifficulty'); + ThemeLoadSelectSlide(OptionsGame.SelectLanguage, 'OptionsGameSelectSlideLanguage'); + ThemeLoadSelect(OptionsGame.SelectTabs, 'OptionsGameSelectTabs'); + ThemeLoadSelectSlide(OptionsGame.SelectSorting, 'OptionsGameSelectSlideSorting'); + ThemeLoadSelect(OptionsGame.SelectDebug, 'OptionsGameSelectDebug'); + ThemeLoadButton(OptionsGame.ButtonExit, 'OptionsGameButtonExit'); + + // Options Graphics + ThemeLoadBasic(OptionsGraphics, 'OptionsGraphics'); + + ThemeLoadSelect(OptionsGraphics.SelectFullscreen, 'OptionsGraphicsSelectFullscreen'); + ThemeLoadSelectSlide(OptionsGraphics.SelectSlideResolution, 'OptionsGraphicsSelectSlideResolution'); + ThemeLoadSelect(OptionsGraphics.SelectDepth, 'OptionsGraphicsSelectDepth'); + ThemeLoadSelect(OptionsGraphics.SelectOscilloscope, 'OptionsGraphicsSelectOscilloscope'); + ThemeLoadSelect(OptionsGraphics.SelectLineBonus, 'OptionsGraphicsSelectLineBonus'); + ThemeLoadSelect(OptionsGraphics.SelectMovieSize, 'OptionsGraphicsSelectMovieSize'); + ThemeLoadButton(OptionsGraphics.ButtonExit, 'OptionsGraphicsButtonExit'); + + // Options Sound + ThemeLoadBasic(OptionsSound, 'OptionsSound'); + + ThemeLoadSelect(OptionsSound.SelectMicBoost, 'OptionsSoundSelectMicBoost'); + ThemeLoadSelect(OptionsSound.SelectClickAssist, 'OptionsSoundSelectClickAssist'); + ThemeLoadSelect(OptionsSound.SelectBeatClick, 'OptionsSoundSelectBeatClick'); + ThemeLoadSelect(OptionsSound.SelectThreshold, 'OptionsSoundSelectThreshold'); + //Song Preview + ThemeLoadSelectSlide(OptionsSound.SelectSlidePreviewVolume, 'OptionsSoundSelectSlidePreviewVolume'); + ThemeLoadSelectSlide(OptionsSound.SelectSlidePreviewFading, 'OptionsSoundSelectSlidePreviewFading'); + + ThemeLoadButton(OptionsSound.ButtonExit, 'OptionsSoundButtonExit'); + + // Options Lyrics + ThemeLoadBasic(OptionsLyrics, 'OptionsLyrics'); + + ThemeLoadSelect(OptionsLyrics.SelectLyricsFont, 'OptionsLyricsSelectLyricsFont'); + ThemeLoadSelect(OptionsLyrics.SelectLyricsEffect, 'OptionsLyricsSelectLyricsEffect'); + ThemeLoadSelect(OptionsLyrics.SelectSolmization, 'OptionsLyricsSelectSolmization'); + ThemeLoadButton(OptionsLyrics.ButtonExit, 'OptionsLyricsButtonExit'); + + // Options Themes + ThemeLoadBasic(OptionsThemes, 'OptionsThemes'); + + ThemeLoadSelectSlide(OptionsThemes.SelectTheme, 'OptionsThemesSelectTheme'); + ThemeLoadSelectSlide(OptionsThemes.SelectSkin, 'OptionsThemesSelectSkin'); + ThemeLoadSelectSlide(OptionsThemes.SelectColor, 'OptionsThemesSelectColor'); + ThemeLoadButton(OptionsThemes.ButtonExit, 'OptionsThemesButtonExit'); + + // Options Record + ThemeLoadBasic(OptionsRecord, 'OptionsRecord'); + + ThemeLoadSelectSlide(OptionsRecord.SelectSlideCard, 'OptionsRecordSelectSlideCard'); + ThemeLoadSelectSlide(OptionsRecord.SelectSlideInput, 'OptionsRecordSelectSlideInput'); + ThemeLoadSelectSlide(OptionsRecord.SelectSlideChannelL, 'OptionsRecordSelectSlideChannelL'); + ThemeLoadSelectSlide(OptionsRecord.SelectSlideChannelR, 'OptionsRecordSelectSlideChannelR'); + ThemeLoadButton(OptionsRecord.ButtonExit, 'OptionsRecordButtonExit'); + + //Options Advanced + ThemeLoadBasic(OptionsAdvanced, 'OptionsAdvanced'); + + ThemeLoadSelect (OptionsAdvanced.SelectLoadAnimation, 'OptionsAdvancedSelectLoadAnimation'); + ThemeLoadSelect (OptionsAdvanced.SelectScreenFade, 'OptionsAdvancedSelectScreenFade'); + ThemeLoadSelect (OptionsAdvanced.SelectEffectSing, 'OptionsAdvancedSelectEffectSing'); + ThemeLoadSelect (OptionsAdvanced.SelectLineBonus, 'OptionsAdvancedSelectLineBonus'); + ThemeLoadSelectSlide (OptionsAdvanced.SelectOnSongClick, 'OptionsAdvancedSelectSlideOnSongClick'); + ThemeLoadSelect (OptionsAdvanced.SelectAskbeforeDel, 'OptionsAdvancedSelectAskbeforeDel'); + ThemeLoadSelect (OptionsAdvanced.SelectPartyPopup, 'OptionsAdvancedSelectPartyPopup'); + ThemeLoadButton (OptionsAdvanced.ButtonExit, 'OptionsAdvancedButtonExit'); + + //error and check popup + ThemeLoadBasic (ErrorPopup, 'ErrorPopup'); + ThemeLoadButton(ErrorPopup.Button1, 'ErrorPopupButton1'); + ThemeLoadText (ErrorPopup.TextError,'ErrorPopupText'); + ThemeLoadBasic (CheckPopup, 'CheckPopup'); + ThemeLoadButton(CheckPopup.Button1, 'CheckPopupButton1'); + ThemeLoadButton(CheckPopup.Button2, 'CheckPopupButton2'); + ThemeLoadText(CheckPopup.TextCheck , 'CheckPopupText'); + + //Song Menu + ThemeLoadBasic (SongMenu, 'SongMenu'); + ThemeLoadButton(SongMenu.Button1, 'SongMenuButton1'); + ThemeLoadButton(SongMenu.Button2, 'SongMenuButton2'); + ThemeLoadButton(SongMenu.Button3, 'SongMenuButton3'); + ThemeLoadButton(SongMenu.Button4, 'SongMenuButton4'); + ThemeLoadSelectSlide(SongMenu.SelectSlide3, 'SongMenuSelectSlide3'); + + ThemeLoadText(SongMenu.TextMenu, 'SongMenuTextMenu'); + + //Song Jumpto + ThemeLoadBasic (SongJumpto, 'SongJumpto'); + ThemeLoadButton(SongJumpto.ButtonSearchText, 'SongJumptoButtonSearchText'); + ThemeLoadSelectSlide(SongJumpto.SelectSlideType, 'SongJumptoSelectSlideType'); + ThemeLoadText(SongJumpto.TextFound, 'SongJumptoTextFound'); + //Translations + SongJumpto.IType[0] := Language.Translate('SONG_JUMPTO_TYPE1'); + SongJumpto.IType[1] := Language.Translate('SONG_JUMPTO_TYPE2'); + SongJumpto.IType[2] := Language.Translate('SONG_JUMPTO_TYPE3'); + SongJumpto.SongsFound := Language.Translate('SONG_JUMPTO_SONGSFOUND'); + SongJumpto.NoSongsFound := Language.Translate('SONG_JUMPTO_NOSONGSFOUND'); + SongJumpto.CatText := Language.Translate('SONG_JUMPTO_CATTEXT'); + + //Party Screens: + //Party NewRound + ThemeLoadBasic(PartyNewRound, 'PartyNewRound'); + + ThemeLoadText (PartyNewRound.TextRound1, 'PartyNewRoundTextRound1'); + ThemeLoadText (PartyNewRound.TextRound2, 'PartyNewRoundTextRound2'); + ThemeLoadText (PartyNewRound.TextRound3, 'PartyNewRoundTextRound3'); + ThemeLoadText (PartyNewRound.TextRound4, 'PartyNewRoundTextRound4'); + ThemeLoadText (PartyNewRound.TextRound5, 'PartyNewRoundTextRound5'); + ThemeLoadText (PartyNewRound.TextRound6, 'PartyNewRoundTextRound6'); + ThemeLoadText (PartyNewRound.TextRound7, 'PartyNewRoundTextRound7'); + ThemeLoadText (PartyNewRound.TextWinner1, 'PartyNewRoundTextWinner1'); + ThemeLoadText (PartyNewRound.TextWinner2, 'PartyNewRoundTextWinner2'); + ThemeLoadText (PartyNewRound.TextWinner3, 'PartyNewRoundTextWinner3'); + ThemeLoadText (PartyNewRound.TextWinner4, 'PartyNewRoundTextWinner4'); + ThemeLoadText (PartyNewRound.TextWinner5, 'PartyNewRoundTextWinner5'); + ThemeLoadText (PartyNewRound.TextWinner6, 'PartyNewRoundTextWinner6'); + ThemeLoadText (PartyNewRound.TextWinner7, 'PartyNewRoundTextWinner7'); + ThemeLoadText (PartyNewRound.TextNextRound, 'PartyNewRoundTextNextRound'); + ThemeLoadText (PartyNewRound.TextNextRoundNo, 'PartyNewRoundTextNextRoundNo'); + ThemeLoadText (PartyNewRound.TextNextPlayer1, 'PartyNewRoundTextNextPlayer1'); + ThemeLoadText (PartyNewRound.TextNextPlayer2, 'PartyNewRoundTextNextPlayer2'); + ThemeLoadText (PartyNewRound.TextNextPlayer3, 'PartyNewRoundTextNextPlayer3'); + + ThemeLoadStatic (PartyNewRound.StaticRound1, 'PartyNewRoundStaticRound1'); + ThemeLoadStatic (PartyNewRound.StaticRound2, 'PartyNewRoundStaticRound2'); + ThemeLoadStatic (PartyNewRound.StaticRound3, 'PartyNewRoundStaticRound3'); + ThemeLoadStatic (PartyNewRound.StaticRound4, 'PartyNewRoundStaticRound4'); + ThemeLoadStatic (PartyNewRound.StaticRound5, 'PartyNewRoundStaticRound5'); + ThemeLoadStatic (PartyNewRound.StaticRound6, 'PartyNewRoundStaticRound6'); + ThemeLoadStatic (PartyNewRound.StaticRound7, 'PartyNewRoundStaticRound7'); + + ThemeLoadText (PartyNewRound.TextScoreTeam1, 'PartyNewRoundTextScoreTeam1'); + ThemeLoadText (PartyNewRound.TextScoreTeam2, 'PartyNewRoundTextScoreTeam2'); + ThemeLoadText (PartyNewRound.TextScoreTeam3, 'PartyNewRoundTextScoreTeam3'); + ThemeLoadText (PartyNewRound.TextNameTeam1, 'PartyNewRoundTextNameTeam1'); + ThemeLoadText (PartyNewRound.TextNameTeam2, 'PartyNewRoundTextNameTeam2'); + ThemeLoadText (PartyNewRound.TextNameTeam3, 'PartyNewRoundTextNameTeam3'); + + ThemeLoadText (PartyNewRound.TextTeam1Players, 'PartyNewRoundTextTeam1Players'); + ThemeLoadText (PartyNewRound.TextTeam2Players, 'PartyNewRoundTextTeam2Players'); + ThemeLoadText (PartyNewRound.TextTeam3Players, 'PartyNewRoundTextTeam3Players'); + + ThemeLoadStatic (PartyNewRound.StaticTeam1, 'PartyNewRoundStaticTeam1'); + ThemeLoadStatic (PartyNewRound.StaticTeam2, 'PartyNewRoundStaticTeam2'); + ThemeLoadStatic (PartyNewRound.StaticTeam3, 'PartyNewRoundStaticTeam3'); + ThemeLoadStatic (PartyNewRound.StaticNextPlayer1, 'PartyNewRoundStaticNextPlayer1'); + ThemeLoadStatic (PartyNewRound.StaticNextPlayer2, 'PartyNewRoundStaticNextPlayer2'); + ThemeLoadStatic (PartyNewRound.StaticNextPlayer3, 'PartyNewRoundStaticNextPlayer3'); + + //Party Score + ThemeLoadBasic(PartyScore, 'PartyScore'); + + ThemeLoadText (PartyScore.TextScoreTeam1, 'PartyScoreTextScoreTeam1'); + ThemeLoadText (PartyScore.TextScoreTeam2, 'PartyScoreTextScoreTeam2'); + ThemeLoadText (PartyScore.TextScoreTeam3, 'PartyScoreTextScoreTeam3'); + ThemeLoadText (PartyScore.TextNameTeam1, 'PartyScoreTextNameTeam1'); + ThemeLoadText (PartyScore.TextNameTeam2, 'PartyScoreTextNameTeam2'); + ThemeLoadText (PartyScore.TextNameTeam3, 'PartyScoreTextNameTeam3'); + + ThemeLoadStatic (PartyScore.StaticTeam1, 'PartyScoreStaticTeam1'); + ThemeLoadStatic (PartyScore.StaticTeam1BG, 'PartyScoreStaticTeam1BG'); + ThemeLoadStatic (PartyScore.StaticTeam1Deco, 'PartyScoreStaticTeam1Deco'); + ThemeLoadStatic (PartyScore.StaticTeam2, 'PartyScoreStaticTeam2'); + ThemeLoadStatic (PartyScore.StaticTeam2BG, 'PartyScoreStaticTeam2BG'); + ThemeLoadStatic (PartyScore.StaticTeam2Deco, 'PartyScoreStaticTeam2Deco'); + ThemeLoadStatic (PartyScore.StaticTeam3, 'PartyScoreStaticTeam3'); + ThemeLoadStatic (PartyScore.StaticTeam3BG, 'PartyScoreStaticTeam3BG'); + ThemeLoadStatic (PartyScore.StaticTeam3Deco, 'PartyScoreStaticTeam3Deco'); + + //Load Party Score DecoTextures Object + PartyScore.DecoTextures.ChangeTextures := (ThemeIni.ReadInteger('PartyScoreDecoTextures', 'ChangeTextures', 0) = 1); + + PartyScore.DecoTextures.FirstTexture := ThemeIni.ReadString('PartyScoreDecoTextures', 'FirstTexture', ''); + PartyScore.DecoTextures.FirstTyp := ThemeIni.ReadString('PartyScoreDecoTextures', 'FirstTyp', 'Note Black'); + PartyScore.DecoTextures.FirstColor := ThemeIni.ReadString('PartyScoreDecoTextures', 'FirstColor', 'Black'); + + PartyScore.DecoTextures.SecondTexture := ThemeIni.ReadString('PartyScoreDecoTextures', 'SecondTexture', ''); + PartyScore.DecoTextures.SecondTyp := ThemeIni.ReadString('PartyScoreDecoTextures', 'SecondTyp', 'Note Black'); + PartyScore.DecoTextures.SecondColor := ThemeIni.ReadString('PartyScoreDecoTextures', 'SecondColor', 'Black'); + + PartyScore.DecoTextures.ThirdTexture := ThemeIni.ReadString('PartyScoreDecoTextures', 'ThirdTexture', ''); + PartyScore.DecoTextures.ThirdTyp := ThemeIni.ReadString('PartyScoreDecoTextures', 'ThirdTyp', 'Note Black'); + PartyScore.DecoTextures.ThirdColor := ThemeIni.ReadString('PartyScoreDecoTextures', 'ThirdColor', 'Black'); + + ThemeLoadText (PartyScore.TextWinner, 'PartyScoreTextWinner'); + + //Party Win + ThemeLoadBasic(PartyWin, 'PartyWin'); + + ThemeLoadText (PartyWin.TextScoreTeam1, 'PartyWinTextScoreTeam1'); + ThemeLoadText (PartyWin.TextScoreTeam2, 'PartyWinTextScoreTeam2'); + ThemeLoadText (PartyWin.TextScoreTeam3, 'PartyWinTextScoreTeam3'); + ThemeLoadText (PartyWin.TextNameTeam1, 'PartyWinTextNameTeam1'); + ThemeLoadText (PartyWin.TextNameTeam2, 'PartyWinTextNameTeam2'); + ThemeLoadText (PartyWin.TextNameTeam3, 'PartyWinTextNameTeam3'); + + ThemeLoadStatic (PartyWin.StaticTeam1, 'PartyWinStaticTeam1'); + ThemeLoadStatic (PartyWin.StaticTeam1BG, 'PartyWinStaticTeam1BG'); + ThemeLoadStatic (PartyWin.StaticTeam1Deco, 'PartyWinStaticTeam1Deco'); + ThemeLoadStatic (PartyWin.StaticTeam2, 'PartyWinStaticTeam2'); + ThemeLoadStatic (PartyWin.StaticTeam2BG, 'PartyWinStaticTeam2BG'); + ThemeLoadStatic (PartyWin.StaticTeam2Deco, 'PartyWinStaticTeam2Deco'); + ThemeLoadStatic (PartyWin.StaticTeam3, 'PartyWinStaticTeam3'); + ThemeLoadStatic (PartyWin.StaticTeam3BG, 'PartyWinStaticTeam3BG'); + ThemeLoadStatic (PartyWin.StaticTeam3Deco, 'PartyWinStaticTeam3Deco'); + + ThemeLoadText (PartyWin.TextWinner, 'PartyWinTextWinner'); + + //Party Options + ThemeLoadBasic(PartyOptions, 'PartyOptions'); + ThemeLoadSelectSlide(PartyOptions.SelectLevel, 'PartyOptionsSelectLevel'); + ThemeLoadSelectSlide(PartyOptions.SelectPlayList, 'PartyOptionsSelectPlayList'); + ThemeLoadSelectSlide(PartyOptions.SelectPlayList2, 'PartyOptionsSelectPlayList2'); + ThemeLoadSelectSlide(PartyOptions.SelectRounds, 'PartyOptionsSelectRounds'); + ThemeLoadSelectSlide(PartyOptions.SelectTeams, 'PartyOptionsSelectTeams'); + ThemeLoadSelectSlide(PartyOptions.SelectPlayers1, 'PartyOptionsSelectPlayers1'); + ThemeLoadSelectSlide(PartyOptions.SelectPlayers2, 'PartyOptionsSelectPlayers2'); + ThemeLoadSelectSlide(PartyOptions.SelectPlayers3, 'PartyOptionsSelectPlayers3'); + + {ThemeLoadButton (ButtonNext, 'ButtonNext'); + ThemeLoadButton (ButtonPrev, 'ButtonPrev');} + + //Party Player + ThemeLoadBasic(PartyPlayer, 'PartyPlayer'); + ThemeLoadButton(PartyPlayer.Team1Name, 'PartyPlayerTeam1Name'); + ThemeLoadButton(PartyPlayer.Player1Name, 'PartyPlayerPlayer1Name'); + ThemeLoadButton(PartyPlayer.Player2Name, 'PartyPlayerPlayer2Name'); + ThemeLoadButton(PartyPlayer.Player3Name, 'PartyPlayerPlayer3Name'); + ThemeLoadButton(PartyPlayer.Player4Name, 'PartyPlayerPlayer4Name'); + + ThemeLoadButton(PartyPlayer.Team2Name, 'PartyPlayerTeam2Name'); + ThemeLoadButton(PartyPlayer.Player5Name, 'PartyPlayerPlayer5Name'); + ThemeLoadButton(PartyPlayer.Player6Name, 'PartyPlayerPlayer6Name'); + ThemeLoadButton(PartyPlayer.Player7Name, 'PartyPlayerPlayer7Name'); + ThemeLoadButton(PartyPlayer.Player8Name, 'PartyPlayerPlayer8Name'); + + ThemeLoadButton(PartyPlayer.Team3Name, 'PartyPlayerTeam3Name'); + ThemeLoadButton(PartyPlayer.Player9Name, 'PartyPlayerPlayer9Name'); + ThemeLoadButton(PartyPlayer.Player10Name, 'PartyPlayerPlayer10Name'); + ThemeLoadButton(PartyPlayer.Player11Name, 'PartyPlayerPlayer11Name'); + ThemeLoadButton(PartyPlayer.Player12Name, 'PartyPlayerPlayer12Name'); + + {ThemeLoadButton(ButtonNext, 'PartyPlayerButtonNext'); + ThemeLoadButton(ButtonPrev, 'PartyPlayerButtonPrev');} + + ThemeLoadBasic(StatMain, 'StatMain'); + + ThemeLoadButton(StatMain.ButtonScores, 'StatMainButtonScores'); + ThemeLoadButton(StatMain.ButtonSingers, 'StatMainButtonSingers'); + ThemeLoadButton(StatMain.ButtonSongs, 'StatMainButtonSongs'); + ThemeLoadButton(StatMain.ButtonBands, 'StatMainButtonBands'); + ThemeLoadButton(StatMain.ButtonExit, 'StatMainButtonExit'); + + ThemeLoadText (StatMain.TextOverview, 'StatMainTextOverview'); + + + ThemeLoadBasic(StatDetail, 'StatDetail'); + + ThemeLoadButton(StatDetail.ButtonNext, 'StatDetailButtonNext'); + ThemeLoadButton(StatDetail.ButtonPrev, 'StatDetailButtonPrev'); + ThemeLoadButton(StatDetail.ButtonReverse, 'StatDetailButtonReverse'); + ThemeLoadButton(StatDetail.ButtonExit, 'StatDetailButtonExit'); + + ThemeLoadText (StatDetail.TextDescription, 'StatDetailTextDescription'); + ThemeLoadText (StatDetail.TextPage, 'StatDetailTextPage'); + ThemeLoadTexts(StatDetail.TextList, 'StatDetailTextList'); + + //Translate Texts + StatDetail.Description[0] := Language.Translate('STAT_DESC_SCORES'); + StatDetail.Description[1] := Language.Translate('STAT_DESC_SINGERS'); + StatDetail.Description[2] := Language.Translate('STAT_DESC_SONGS'); + StatDetail.Description[3] := Language.Translate('STAT_DESC_BANDS'); + + StatDetail.DescriptionR[0] := Language.Translate('STAT_DESC_SCORES_REVERSED'); + StatDetail.DescriptionR[1] := Language.Translate('STAT_DESC_SINGERS_REVERSED'); + StatDetail.DescriptionR[2] := Language.Translate('STAT_DESC_SONGS_REVERSED'); + StatDetail.DescriptionR[3] := Language.Translate('STAT_DESC_BANDS_REVERSED'); + + StatDetail.FormatStr[0] := Language.Translate('STAT_FORMAT_SCORES'); + StatDetail.FormatStr[1] := Language.Translate('STAT_FORMAT_SINGERS'); + StatDetail.FormatStr[2] := Language.Translate('STAT_FORMAT_SONGS'); + StatDetail.FormatStr[3] := Language.Translate('STAT_FORMAT_BANDS'); + + StatDetail.PageStr := Language.Translate('STAT_PAGE'); + + //Playlist Translations + Playlist.CatText := Language.Translate('PLAYLIST_CATTEXT'); + + //Level Translations + //Fill ILevel + ILevel[0] := Language.Translate('SING_EASY'); + ILevel[1] := Language.Translate('SING_MEDIUM'); + ILevel[2] := Language.Translate('SING_HARD'); + end; + + ThemeIni.Free; + end; +end; + +procedure TTheme.ThemeLoadBasic(Theme: TThemeBasic; Name: string); +begin + ThemeLoadBackground(Theme.Background, Name); + ThemeLoadTexts(Theme.Text, Name + 'Text'); + ThemeLoadStatics(Theme.Static, Name + 'Static'); + ThemeLoadButtonCollections(Theme.ButtonCollection, Name + 'ButtonCollection'); + + LastThemeBasic := Theme; +end; + +procedure TTheme.ThemeLoadBackground(var ThemeBackground: TThemeBackground; Name: string); +begin + ThemeBackground.Tex := ThemeIni.ReadString(Name + 'Background', 'Tex', ''); +end; + +procedure TTheme.ThemeLoadText(var ThemeText: TThemeText; Name: string); +var + C: integer; +begin + DecimalSeparator := '.'; + ThemeText.X := ThemeIni.ReadInteger(Name, 'X', 0); + ThemeText.Y := ThemeIni.ReadInteger(Name, 'Y', 0); + ThemeText.W := ThemeIni.ReadInteger(Name, 'W', 0); + + ThemeText.ColR := ThemeIni.ReadFloat(Name, 'ColR', 0); + ThemeText.ColG := ThemeIni.ReadFloat(Name, 'ColG', 0); + ThemeText.ColB := ThemeIni.ReadFloat(Name, 'ColB', 0); + + ThemeText.Font := ThemeIni.ReadInteger(Name, 'Font', 0); + ThemeText.Size := ThemeIni.ReadInteger(Name, 'Size', 0); + ThemeText.Align := ThemeIni.ReadInteger(Name, 'Align', 0); + + {{$IFDEF TRANSLATE} + ThemeText.Text := Language.Translate(ThemeIni.ReadString(Name, 'Text', '')); + {{$ELSE}{ + ThemeText.Text := ThemeIni.ReadString(Name, 'Text', ''); + {$ENDIF} + + ThemeText.Color := ThemeIni.ReadString(Name, 'Color', ''); + + C := ColorExists(ThemeText.Color); + if C >= 0 then begin + ThemeText.ColR := Color[C].RGB.R; + ThemeText.ColG := Color[C].RGB.G; + ThemeText.ColB := Color[C].RGB.B; + end; + + DecimalSeparator := ','; +end; + +procedure TTheme.ThemeLoadTexts(var ThemeText: AThemeText; Name: string); +var + T: integer; +begin + T := 1; + while ThemeIni.SectionExists(Name + IntToStr(T)) do begin + SetLength(ThemeText, T); + ThemeLoadText(ThemeText[T-1], Name + IntToStr(T)); + Inc(T); + end; +end; + +procedure TTheme.ThemeLoadStatic(var ThemeStatic: TThemeStatic; Name: string); +var + C: integer; +begin + DecimalSeparator := '.'; + + ThemeStatic.Tex := ThemeIni.ReadString(Name, 'Tex', ''); + + ThemeStatic.X := ThemeIni.ReadInteger(Name, 'X', 0); + ThemeStatic.Y := ThemeIni.ReadInteger(Name, 'Y', 0); + ThemeStatic.Z := ThemeIni.ReadFloat(Name, 'Z', 0); + ThemeStatic.W := ThemeIni.ReadInteger(Name, 'W', 0); + ThemeStatic.H := ThemeIni.ReadInteger(Name, 'H', 0); + + ThemeStatic.Typ := ThemeIni.ReadString(Name, 'Type', ''); + ThemeStatic.Color := ThemeIni.ReadString(Name, 'Color', ''); + + C := ColorExists(ThemeStatic.Color); + if C >= 0 then begin + ThemeStatic.ColR := Color[C].RGB.R; + ThemeStatic.ColG := Color[C].RGB.G; + ThemeStatic.ColB := Color[C].RGB.B; + end; + + ThemeStatic.TexX1 := ThemeIni.ReadFloat(Name, 'TexX1', 0); + ThemeStatic.TexY1 := ThemeIni.ReadFloat(Name, 'TexY1', 0); + ThemeStatic.TexX2 := ThemeIni.ReadFloat(Name, 'TexX2', 1); + ThemeStatic.TexY2 := ThemeIni.ReadFloat(Name, 'TexY2', 1); + + //Reflection Mod + ThemeStatic.Reflection := (ThemeIni.ReadInteger(Name, 'Reflection', 0) = 1); + ThemeStatic.ReflectionSpacing := ThemeIni.ReadFloat(Name, 'ReflectionSpacing', 15); + + DecimalSeparator := ','; +end; + +procedure TTheme.ThemeLoadStatics(var ThemeStatic: AThemeStatic; Name: string); +var + S: integer; +begin + S := 1; + while ThemeIni.SectionExists(Name + IntToStr(S)) do begin + SetLength(ThemeStatic, S); + ThemeLoadStatic(ThemeStatic[S-1], Name + IntToStr(S)); + Inc(S); + end; +end; + +//Button Collection Mod +procedure TTheme.ThemeLoadButtonCollection(var Collection: TThemeButtonCollection; Name: string); +var T: Integer; +begin + //Load Collection Style + ThemeLoadButton(Collection.Style, Name); + + //Load Other Attributes + T := ThemeIni.ReadInteger (Name, 'FirstChild', 0); + if (T > 0) And (T < 256) then + Collection.FirstChild := T + else + Collection.FirstChild := 0; +end; + +procedure TTheme.ThemeLoadButtonCollections(var Collections: AThemeButtonCollection; Name: string); +var + I: integer; +begin + I := 1; + while ThemeIni.SectionExists(Name + IntToStr(I)) do begin + SetLength(Collections, I); + ThemeLoadButtonCollection(Collections[I-1], Name + IntToStr(I)); + Inc(I); + end; +end; +//End Button Collection Mod + +procedure TTheme.ThemeLoadButton(var ThemeButton: TThemeButton; Name: string; const Collections: PAThemeButtonCollection); +var + C: integer; + TLen: integer; + T: integer; + Collections2: PAThemeButtonCollection; +begin + if not ThemeIni.SectionExists(Name) then + begin + ThemeButton.Visible := False; + exit; + end; + DecimalSeparator := '.'; + ThemeButton.Tex := ThemeIni.ReadString(Name, 'Tex', ''); + ThemeButton.X := ThemeIni.ReadInteger (Name, 'X', 0); + ThemeButton.Y := ThemeIni.ReadInteger (Name, 'Y', 0); + ThemeButton.Z := ThemeIni.ReadFloat (Name, 'Z', 0); + ThemeButton.W := ThemeIni.ReadInteger (Name, 'W', 0); + ThemeButton.H := ThemeIni.ReadInteger (Name, 'H', 0); + + ThemeButton.Typ := ThemeIni.ReadString(Name, 'Type', ''); + + //Reflection Mod + ThemeButton.Reflection := (ThemeIni.ReadInteger(Name, 'Reflection', 0) = 1); + ThemeButton.ReflectionSpacing := ThemeIni.ReadFloat(Name, 'ReflectionSpacing', 15); + + ThemeButton.ColR := ThemeIni.ReadFloat(Name, 'ColR', 1); + ThemeButton.ColG := ThemeIni.ReadFloat(Name, 'ColG', 1); + ThemeButton.ColB := ThemeIni.ReadFloat(Name, 'ColB', 1); + ThemeButton.Int := ThemeIni.ReadFloat(Name, 'Int', 1); + ThemeButton.DColR := ThemeIni.ReadFloat(Name, 'DColR', 1); + ThemeButton.DColG := ThemeIni.ReadFloat(Name, 'DColG', 1); + ThemeButton.DColB := ThemeIni.ReadFloat(Name, 'DColB', 1); + ThemeButton.DInt := ThemeIni.ReadFloat(Name, 'DInt', 1); + + ThemeButton.Color := ThemeIni.ReadString(Name, 'Color', ''); + C := ColorExists(ThemeButton.Color); + if C >= 0 then begin + ThemeButton.ColR := Color[C].RGB.R; + ThemeButton.ColG := Color[C].RGB.G; + ThemeButton.ColB := Color[C].RGB.B; + end; + + ThemeButton.DColor := ThemeIni.ReadString(Name, 'DColor', ''); + C := ColorExists(ThemeButton.DColor); + if C >= 0 then begin + ThemeButton.DColR := Color[C].RGB.R; + ThemeButton.DColG := Color[C].RGB.G; + ThemeButton.DColB := Color[C].RGB.B; + end; + + ThemeButton.Visible := (ThemeIni.ReadInteger(Name, 'Visible', 1) = 1); + + //Fade Mod + ThemeButton.SelectH := ThemeIni.ReadInteger (Name, 'SelectH', ThemeButton.H); + ThemeButton.SelectW := ThemeIni.ReadInteger (Name, 'SelectW', ThemeButton.W); + + ThemeButton.DeSelectReflectionspacing := ThemeIni.ReadFloat(Name, 'DeSelectReflectionSpacing', ThemeButton.Reflectionspacing); + + ThemeButton.Fade := (ThemeIni.ReadInteger(Name, 'Fade', 0) = 1); + ThemeButton.FadeText := (ThemeIni.ReadInteger(Name, 'FadeText', 0) = 1); + + + ThemeButton.FadeTex := ThemeIni.ReadString(Name, 'FadeTex', ''); + ThemeButton.FadeTexPos:= ThemeIni.ReadInteger(Name, 'FadeTexPos', 0); + if (ThemeButton.FadeTexPos > 4) Or (ThemeButton.FadeTexPos < 0) then + ThemeButton.FadeTexPos := 0; + + //Button Collection Mod + T := ThemeIni.ReadInteger(Name, 'Parent', 0); + + //Set Collections to Last Basic Collections if no valid Value + if (Collections = nil) then + Collections2 := @LastThemeBasic.ButtonCollection + else + Collections2 := Collections; + //Test for valid Value + if (Collections2 <> nil) AND (T > 0) AND (T <= Length(Collections2^)) then + begin + Inc(Collections2^[T-1].ChildCount); + ThemeButton.Parent := T; + end + else + ThemeButton.Parent := 0; + + //Read ButtonTexts + TLen := ThemeIni.ReadInteger(Name, 'Texts', 0); + SetLength(ThemeButton.Text, TLen); + for T := 1 to TLen do + ThemeLoadText(ThemeButton.Text[T-1], Name + 'Text' + IntToStr(T)); + + DecimalSeparator := ','; +end; + +procedure TTheme.ThemeLoadSelect(var ThemeSelect: TThemeSelect; Name: string); +var + C: integer; +begin + DecimalSeparator := '.'; + + {{$IFDEF TRANSLATE} + ThemeSelect.Text := Language.Translate(ThemeIni.ReadString(Name, 'Text', '')); + {{$ELSE}{ + ThemeSelect.Text := ThemeIni.ReadString(Name, 'Text', ''); + {$ENDIF} + + ThemeSelect.Tex := {Skin.SkinPath + }ThemeIni.ReadString(Name, 'Tex', ''); + ThemeSelect.TexSBG := {Skin.SkinPath + }ThemeIni.ReadString(Name, 'TexSBG', ''); + + ThemeSelect.X := ThemeIni.ReadInteger(Name, 'X', 0); + ThemeSelect.Y := ThemeIni.ReadInteger(Name, 'Y', 0); + ThemeSelect.W := ThemeIni.ReadInteger(Name, 'W', 0); + ThemeSelect.H := ThemeIni.ReadInteger(Name, 'H', 0); + ThemeSelect.SkipX := ThemeIni.ReadInteger(Name, 'SkipX', 0); + + + LoadColor(ThemeSelect.ColR, ThemeSelect.ColG, ThemeSelect.ColB, ThemeIni.ReadString(Name, 'Color', '')); + ThemeSelect.Int := ThemeIni.ReadFloat(Name, 'Int', 1); + LoadColor(ThemeSelect.DColR, ThemeSelect.DColG, ThemeSelect.DColB, ThemeIni.ReadString(Name, 'DColor', '')); + ThemeSelect.DInt := ThemeIni.ReadFloat(Name, 'DInt', 1); + + LoadColor(ThemeSelect.TColR, ThemeSelect.TColG, ThemeSelect.TColB, ThemeIni.ReadString(Name, 'TColor', '')); + ThemeSelect.TInt := ThemeIni.ReadFloat(Name, 'TInt', 1); + LoadColor(ThemeSelect.TDColR, ThemeSelect.TDColG, ThemeSelect.TDColB, ThemeIni.ReadString(Name, 'TDColor', '')); + ThemeSelect.TDInt := ThemeIni.ReadFloat(Name, 'TDInt', 1); + + LoadColor(ThemeSelect.SBGColR, ThemeSelect.SBGColG, ThemeSelect.SBGColB, ThemeIni.ReadString(Name, 'SBGColor', '')); + ThemeSelect.SBGInt := ThemeIni.ReadFloat(Name, 'SBGInt', 1); + LoadColor(ThemeSelect.SBGDColR, ThemeSelect.SBGDColG, ThemeSelect.SBGDColB, ThemeIni.ReadString(Name, 'SBGDColor', '')); + ThemeSelect.SBGDInt := ThemeIni.ReadFloat(Name, 'SBGDInt', 1); + + LoadColor(ThemeSelect.STColR, ThemeSelect.STColG, ThemeSelect.STColB, ThemeIni.ReadString(Name, 'STColor', '')); + ThemeSelect.STInt := ThemeIni.ReadFloat(Name, 'STInt', 1); + LoadColor(ThemeSelect.STDColR, ThemeSelect.STDColG, ThemeSelect.STDColB, ThemeIni.ReadString(Name, 'STDColor', '')); + ThemeSelect.STDInt := ThemeIni.ReadFloat(Name, 'STDInt', 1); + + + DecimalSeparator := ','; +end; + +procedure TTheme.ThemeLoadSelectSlide(var ThemeSelectS: TThemeSelectSlide; Name: string); +var + C: integer; +begin + DecimalSeparator := '.'; + + {{$IFDEF TRANSLATE} + ThemeSelectS.Text := Language.Translate(ThemeIni.ReadString(Name, 'Text', '')); + {{$ELSE}{ + ThemeSelectS.Text := ThemeIni.ReadString(Name, 'Text', ''); + {$ENDIF} + + ThemeSelectS.Tex := {Skin.SkinPath + }ThemeIni.ReadString(Name, 'Tex', ''); + ThemeSelectS.TexSBG := {Skin.SkinPath + }ThemeIni.ReadString(Name, 'TexSBG', ''); + + ThemeSelectS.X := ThemeIni.ReadInteger(Name, 'X', 0); + ThemeSelectS.Y := ThemeIni.ReadInteger(Name, 'Y', 0); + ThemeSelectS.W := ThemeIni.ReadInteger(Name, 'W', 0); + ThemeSelectS.H := ThemeIni.ReadInteger(Name, 'H', 0); + + ThemeSelectS.Z := ThemeIni.ReadFloat(Name, 'Z', 0); + + ThemeSelectS.TextSize := ThemeIni.ReadInteger(Name, 'TextSize', 10); + + ThemeSelectS.SkipX := ThemeIni.ReadInteger(Name, 'SkipX', 0); + + ThemeSelectS.SBGW := ThemeIni.ReadInteger(Name, 'SBGW', 450); + + LoadColor(ThemeSelectS.ColR, ThemeSelectS.ColG, ThemeSelectS.ColB, ThemeIni.ReadString(Name, 'Color', '')); + ThemeSelectS.Int := ThemeIni.ReadFloat(Name, 'Int', 1); + LoadColor(ThemeSelectS.DColR, ThemeSelectS.DColG, ThemeSelectS.DColB, ThemeIni.ReadString(Name, 'DColor', '')); + ThemeSelectS.DInt := ThemeIni.ReadFloat(Name, 'DInt', 1); + + LoadColor(ThemeSelectS.TColR, ThemeSelectS.TColG, ThemeSelectS.TColB, ThemeIni.ReadString(Name, 'TColor', '')); + ThemeSelectS.TInt := ThemeIni.ReadFloat(Name, 'TInt', 1); + LoadColor(ThemeSelectS.TDColR, ThemeSelectS.TDColG, ThemeSelectS.TDColB, ThemeIni.ReadString(Name, 'TDColor', '')); + ThemeSelectS.TDInt := ThemeIni.ReadFloat(Name, 'TDInt', 1); + + LoadColor(ThemeSelectS.SBGColR, ThemeSelectS.SBGColG, ThemeSelectS.SBGColB, ThemeIni.ReadString(Name, 'SBGColor', '')); + ThemeSelectS.SBGInt := ThemeIni.ReadFloat(Name, 'SBGInt', 1); + LoadColor(ThemeSelectS.SBGDColR, ThemeSelectS.SBGDColG, ThemeSelectS.SBGDColB, ThemeIni.ReadString(Name, 'SBGDColor', '')); + ThemeSelectS.SBGDInt := ThemeIni.ReadFloat(Name, 'SBGDInt', 1); + + LoadColor(ThemeSelectS.STColR, ThemeSelectS.STColG, ThemeSelectS.STColB, ThemeIni.ReadString(Name, 'STColor', '')); + ThemeSelectS.STInt := ThemeIni.ReadFloat(Name, 'STInt', 1); + LoadColor(ThemeSelectS.STDColR, ThemeSelectS.STDColG, ThemeSelectS.STDColB, ThemeIni.ReadString(Name, 'STDColor', '')); + ThemeSelectS.STDInt := ThemeIni.ReadFloat(Name, 'STDInt', 1); + + + DecimalSeparator := ','; +end; + +procedure TTheme.LoadColors; +var + SL: TStringList; + C: integer; + S: string; + Col: integer; + RGB: TRGB; +begin + SL := TStringList.Create; + ThemeIni.ReadSection('Colors', SL); + + // normal colors + SetLength(Color, SL.Count); + for C := 0 to SL.Count-1 do begin + Color[C].Name := SL.Strings[C]; + + S := ThemeIni.ReadString('Colors', SL.Strings[C], ''); + + Color[C].RGB.R := StrToInt(Copy(S, 1, Pos(' ' , S)-1))/255; + Delete(S, 1, Pos(' ', S)); + + Color[C].RGB.G := StrToInt(Copy(S, 1, Pos(' ' , S)-1))/255; + Delete(S, 1, Pos(' ', S)); + + Color[C].RGB.B := StrToInt(S)/255; + end; + + // skin color + SetLength(Color, SL.Count + 3); + C := SL.Count; + Color[C].Name := 'ColorDark'; + Color[C].RGB := GetSystemColor(Skin.Color); //Ini.Color); + + C := C+1; + Color[C].Name := 'ColorLight'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + C := C+1; + Color[C].Name := 'ColorLightest'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + // players colors + SetLength(Color, Length(Color)+18); + + // P1 + C := C+1; + Color[C].Name := 'P1Dark'; + Color[C].RGB := GetSystemColor(0); // 0 - blue + + C := C+1; + Color[C].Name := 'P1Light'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + C := C+1; + Color[C].Name := 'P1Lightest'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + // P2 + C := C+1; + Color[C].Name := 'P2Dark'; + Color[C].RGB := GetSystemColor(3); // 3 - red + + C := C+1; + Color[C].Name := 'P2Light'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + C := C+1; + Color[C].Name := 'P2Lightest'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + // P3 + C := C+1; + Color[C].Name := 'P3Dark'; + Color[C].RGB := GetSystemColor(1); // 1 - green + + C := C+1; + Color[C].Name := 'P3Light'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + C := C+1; + Color[C].Name := 'P3Lightest'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + // P4 + C := C+1; + Color[C].Name := 'P4Dark'; + Color[C].RGB := GetSystemColor(4); // 4 - brown + + C := C+1; + Color[C].Name := 'P4Light'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + C := C+1; + Color[C].Name := 'P4Lightest'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + // P5 + C := C+1; + Color[C].Name := 'P5Dark'; + Color[C].RGB := GetSystemColor(5); // 5 - yellow + + C := C+1; + Color[C].Name := 'P5Light'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + C := C+1; + Color[C].Name := 'P5Lightest'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + // P6 + C := C+1; + Color[C].Name := 'P6Dark'; + Color[C].RGB := GetSystemColor(6); // 6 - violet + + C := C+1; + Color[C].Name := 'P6Light'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + C := C+1; + Color[C].Name := 'P6Lightest'; + Color[C].RGB := ColorSqrt(Color[C-1].RGB); + + + SL.Free; +end; + +function ColorExists(Name: string): integer; +var + C: integer; +begin + Result := -1; + for C := 0 to High(Color) do + if Color[C].Name = Name then Result := C; +end; + +procedure LoadColor(var R, G, B: real; ColorName: string); +var + C: integer; +begin + C := ColorExists(ColorName); + if C >= 0 then begin + R := Color[C].RGB.R; + G := Color[C].RGB.G; + B := Color[C].RGB.B; + end; +end; + +function GetSystemColor(Color: integer): TRGB; +begin + case Color of + 0: begin + // blue + Result.R := 71/255; + Result.G := 175/255; + Result.B := 247/255; + end; + 1: begin + // green + Result.R := 63/255; + Result.G := 191/255; + Result.B := 63/255; + end; + 2: begin + // pink + Result.R := 255/255; +{ Result.G := 63/255; + Result.B := 192/255;} + Result.G := 175/255; + Result.B := 247/255; + end; + 3: begin + // red + Result.R := 247/255; + Result.G := 71/255; + Result.B := 71/255; + end; + //'Violet', 'Orange', 'Yellow', 'Brown', 'Black' + //New Theme-Color Patch + 4: begin + // violet + Result.R := 230/255; + Result.G := 63/255; + Result.B := 230/255; + end; + 5: begin + // orange + Result.R := 255/255; + Result.G := 144/255; + Result.B := 0; + end; + 6: begin + // yellow + Result.R := 230/255; + Result.G := 230/255; + Result.B := 95/255; + end; + 7: begin + // brown + Result.R := 192/255; + Result.G := 127/255; + Result.B := 31/255; + end; + 8: begin + // black + Result.R := 0; + Result.G := 0; + Result.B := 0; + end; + //New Theme-Color Patch End + + end; + + // pink +// Col := clRed; +// Color[C].ColR := (32 + Col and $FF) / (255 + 32); +// Color[C].ColG := (32 + Col div 256 and $FF) / (255 + 32); +// Color[C].ColB := (32 + Col div (256*256) and $FF) / (255 + 32); + + // purple +// Color[C].ColR := 220/255; +// Color[C].ColG := 95/255; +// Color[C].ColB := 220/255;} + +end; + +function ColorSqrt(RGB: TRGB): TRGB; +begin + Result.R := sqrt(RGB.R); + Result.G := sqrt(RGB.G); + Result.B := sqrt(RGB.B); +end; + +procedure TTheme.ThemeSave(FileName: string); +var + I: integer; +begin + {$IFDEF THEMESAVE} + ThemeIni := TIniFile.Create(FileName); + {$ELSE} + ThemeIni := TMemIniFile.Create(FileName); + {$ENDIF} + + ThemeSaveBasic(Loading, 'Loading'); + + ThemeSaveBasic(Main, 'Main'); + ThemeSaveText(Main.TextDescription, 'MainTextDescription'); + ThemeSaveText(Main.TextDescriptionLong, 'MainTextDescriptionLong'); + ThemeSaveButton(Main.ButtonSolo, 'MainButtonSolo'); + ThemeSaveButton(Main.ButtonEditor, 'MainButtonEditor'); + ThemeSaveButton(Main.ButtonOptions, 'MainButtonOptions'); + ThemeSaveButton(Main.ButtonExit, 'MainButtonExit'); + + ThemeSaveBasic(Name, 'Name'); + for I := 1 to 6 do + ThemeSaveButton(Name.ButtonPlayer[I], 'NameButtonPlayer' + IntToStr(I)); + + ThemeSaveBasic(Level, 'Level'); + ThemeSaveButton(Level.ButtonEasy, 'LevelButtonEasy'); + ThemeSaveButton(Level.ButtonMedium, 'LevelButtonMedium'); + ThemeSaveButton(Level.ButtonHard, 'LevelButtonHard'); + + ThemeSaveBasic(Song, 'Song'); + ThemeSaveText(Song.TextArtist, 'SongTextArtist'); + ThemeSaveText(Song.TextTitle, 'SongTextTitle'); + ThemeSaveText(Song.TextNumber, 'SongTextNumber'); + + //Show CAt in Top Left Mod + ThemeSaveText(Song.TextCat, 'SongTextCat'); + ThemeSaveStatic(Song.StaticCat, 'SongStaticCat'); + + ThemeSaveBasic(Sing, 'Sing'); + + //TimeBar mod + ThemeSaveStatic(Sing.StaticTimeProgress, 'SingTimeProgress'); + ThemeSaveText(Sing.TextTimeText, 'SingTimeText'); + //eoa TimeBar mod + + ThemeSaveStatic(Sing.StaticP1, 'SingP1Static'); + ThemeSaveText(Sing.TextP1, 'SingP1Text'); + ThemeSaveStatic(Sing.StaticP1ScoreBG, 'SingP1Static2'); + ThemeSaveText(Sing.TextP1Score, 'SingP1TextScore'); + + //moveable singbar mod + ThemeSaveStatic(Sing.StaticP1SingBar, 'SingP1SingBar'); + ThemeSaveStatic(Sing.StaticP1TwoPSingBar, 'SingP1TwoPSingBar'); + ThemeSaveStatic(Sing.StaticP1ThreePSingBar, 'SingP1ThreePSingBar'); + ThemeSaveStatic(Sing.StaticP2RSingBar, 'SingP2RSingBar'); + ThemeSaveStatic(Sing.StaticP2MSingBar, 'SingP2MSingBar'); + ThemeSaveStatic(Sing.StaticP3SingBar, 'SingP3SingBar'); + //eoa moveable singbar + + //Added for ps3 skin + //This one is shown in 2/4P mode + ThemeSaveStatic(Sing.StaticP1TwoP, 'SingP1TwoPStatic'); + ThemeSaveText(Sing.TextP1TwoP, 'SingP1TwoPText'); + ThemeSaveStatic(Sing.StaticP1TwoPScoreBG, 'SingP1TwoPStatic2'); + ThemeSaveText(Sing.TextP1TwoPScore, 'SingP1TwoPTextScore'); + + //This one is shown in 3/6P mode + ThemeSaveStatic(Sing.StaticP1ThreeP, 'SingP1ThreePStatic'); + ThemeSaveText(Sing.TextP1ThreeP, 'SingP1ThreePText'); + ThemeSaveStatic(Sing.StaticP1ThreePScoreBG, 'SingP1ThreePStatic2'); + ThemeSaveText(Sing.TextP1ThreePScore, 'SingP1ThreePTextScore'); + //eoa + + ThemeSaveStatic(Sing.StaticP2R, 'SingP2RStatic'); + ThemeSaveText(Sing.TextP2R, 'SingP2RText'); + ThemeSaveStatic(Sing.StaticP2RScoreBG, 'SingP2RStatic2'); + ThemeSaveText(Sing.TextP2RScore, 'SingP2RTextScore'); + + ThemeSaveStatic(Sing.StaticP2M, 'SingP2MStatic'); + ThemeSaveText(Sing.TextP2M, 'SingP2MText'); + ThemeSaveStatic(Sing.StaticP2MScoreBG, 'SingP2MStatic2'); + ThemeSaveText(Sing.TextP2MScore, 'SingP2MTextScore'); + + ThemeSaveStatic(Sing.StaticP3R, 'SingP3RStatic'); + ThemeSaveText(Sing.TextP3R, 'SingP3RText'); + ThemeSaveStatic(Sing.StaticP3RScoreBG, 'SingP3RStatic2'); + ThemeSaveText(Sing.TextP3RScore, 'SingP3RTextScore'); + + ThemeSaveBasic(Score, 'Score'); + ThemeSaveText(Score.TextArtist, 'ScoreTextArtist'); + ThemeSaveText(Score.TextTitle, 'ScoreTextTitle'); + + for I := 1 to 6 do begin + ThemeSaveStatics(Score.PlayerStatic[I], 'ScorePlayer' + IntToStr(I) + 'Static'); + + ThemeSaveText(Score.TextName[I], 'ScoreTextName' + IntToStr(I)); + ThemeSaveText(Score.TextScore[I], 'ScoreTextScore' + IntToStr(I)); + ThemeSaveText(Score.TextNotes[I], 'ScoreTextNotes' + IntToStr(I)); + ThemeSaveText(Score.TextNotesScore[I], 'ScoreTextNotesScore' + IntToStr(I)); + ThemeSaveText(Score.TextLineBonus[I], 'ScoreTextLineBonus' + IntToStr(I)); + ThemeSaveText(Score.TextLineBonusScore[I], 'ScoreTextLineBonusScore' + IntToStr(I)); + ThemeSaveText(Score.TextGoldenNotes[I], 'ScoreTextGoldenNotes' + IntToStr(I)); + ThemeSaveText(Score.TextGoldenNotesScore[I], 'ScoreTextGoldenNotesScore' + IntToStr(I)); + ThemeSaveText(Score.TextTotal[I], 'ScoreTextTotal' + IntToStr(I)); + ThemeSaveText(Score.TextTotalScore[I], 'ScoreTextTotalScore' + IntToStr(I)); + + ThemeSaveStatic(Score.StaticBackLevel[I], 'ScoreStaticBackLevel' + IntToStr(I)); + ThemeSaveStatic(Score.StaticBackLevelRound[I], 'ScoreStaticBackLevelRound' + IntToStr(I)); + ThemeSaveStatic(Score.StaticLevel[I], 'ScoreStaticLevel' + IntToStr(I)); + ThemeSaveStatic(Score.StaticLevelRound[I], 'ScoreStaticLevelRound' + IntToStr(I)); + end; + + ThemeSaveBasic(Top5, 'Top5'); + ThemeSaveText(Top5.TextLevel, 'Top5TextLevel'); + ThemeSaveText(Top5.TextArtistTitle, 'Top5TextArtistTitle'); + ThemeSaveStatics(Top5.StaticNumber, 'Top5StaticNumber'); + ThemeSaveTexts(Top5.TextNumber, 'Top5TextNumber'); + ThemeSaveTexts(Top5.TextName, 'Top5TextName'); + ThemeSaveTexts(Top5.TextScore, 'Top5TextScore'); + + + ThemeIni.Free; +end; + +procedure TTheme.ThemeSaveBasic(Theme: TThemeBasic; Name: string); +begin + ThemeIni.WriteInteger(Name, 'Texts', Length(Theme.Text)); + + ThemeSaveBackground(Theme.Background, Name + 'Background'); + ThemeSaveStatics(Theme.Static, Name + 'Static'); + ThemeSaveTexts(Theme.Text, Name + 'Text'); +end; + +procedure TTheme.ThemeSaveBackground(ThemeBackground: TThemeBackground; Name: string); +begin + if ThemeBackground.Tex <> '' then + ThemeIni.WriteString(Name, 'Tex', ThemeBackground.Tex) + else begin + ThemeIni.EraseSection(Name); + end; +end; + +procedure TTheme.ThemeSaveStatic(ThemeStatic: TThemeStatic; Name: string); +begin + DecimalSeparator := '.'; + ThemeIni.WriteInteger(Name, 'X', ThemeStatic.X); + ThemeIni.WriteInteger(Name, 'Y', ThemeStatic.Y); + ThemeIni.WriteInteger(Name, 'W', ThemeStatic.W); + ThemeIni.WriteInteger(Name, 'H', ThemeStatic.H); + + ThemeIni.WriteString(Name, 'Tex', ThemeStatic.Tex); + ThemeIni.WriteString(Name, 'Type', ThemeStatic.Typ); + ThemeIni.WriteString(Name, 'Color', ThemeStatic.Color); + + ThemeIni.WriteFloat(Name, 'TexX1', ThemeStatic.TexX1); + ThemeIni.WriteFloat(Name, 'TexY1', ThemeStatic.TexY1); + ThemeIni.WriteFloat(Name, 'TexX2', ThemeStatic.TexX2); + ThemeIni.WriteFloat(Name, 'TexY2', ThemeStatic.TexY2); + + DecimalSeparator := ','; +end; + +procedure TTheme.ThemeSaveStatics(ThemeStatic: AThemeStatic; Name: string); +var + S: integer; +begin + for S := 0 to Length(ThemeStatic)-1 do + ThemeSaveStatic(ThemeStatic[S], Name + {'Static' +} IntToStr(S+1)); + + ThemeIni.EraseSection(Name + {'Static' + }IntToStr(S+1)); +end; + +procedure TTheme.ThemeSaveText(ThemeText: TThemeText; Name: string); +begin + DecimalSeparator := '.'; + ThemeIni.WriteInteger(Name, 'X', ThemeText.X); + ThemeIni.WriteInteger(Name, 'Y', ThemeText.Y); + + ThemeIni.WriteInteger(Name, 'Font', ThemeText.Font); + ThemeIni.WriteInteger(Name, 'Size', ThemeText.Size); + ThemeIni.WriteInteger(Name, 'Align', ThemeText.Align); + + ThemeIni.WriteString(Name, 'Text', ThemeText.Text); + ThemeIni.WriteString(Name, 'Color', ThemeText.Color); + + DecimalSeparator := ','; +end; + +procedure TTheme.ThemeSaveTexts(ThemeText: AThemeText; Name: string); +var + T: integer; +begin + for T := 0 to Length(ThemeText)-1 do + ThemeSaveText(ThemeText[T], Name + {'Text' + }IntToStr(T+1)); + + ThemeIni.EraseSection(Name + {'Text' + }IntToStr(T+1)); +end; + +procedure TTheme.ThemeSaveButton(ThemeButton: TThemeButton; Name: string); +var + T: integer; +begin + DecimalSeparator := '.'; + ThemeIni.WriteString(Name, 'Tex', ThemeButton.Tex); + ThemeIni.WriteInteger(Name, 'X', ThemeButton.X); + ThemeIni.WriteInteger(Name, 'Y', ThemeButton.Y); + ThemeIni.WriteInteger(Name, 'W', ThemeButton.W); + ThemeIni.WriteInteger(Name, 'H', ThemeButton.H); + + ThemeIni.WriteString(Name, 'Type', ThemeButton.Typ); + ThemeIni.WriteInteger(Name, 'Texts', Length(ThemeButton.Text)); + + ThemeIni.WriteString(Name, 'Color', ThemeButton.Color); + +{ ThemeButton.ColR := ThemeIni.ReadFloat(Name, 'ColR', 1); + ThemeButton.ColG := ThemeIni.ReadFloat(Name, 'ColG', 1); + ThemeButton.ColB := ThemeIni.ReadFloat(Name, 'ColB', 1); + ThemeButton.Int := ThemeIni.ReadFloat(Name, 'Int', 1); + ThemeButton.DColR := ThemeIni.ReadFloat(Name, 'DColR', 1); + ThemeButton.DColG := ThemeIni.ReadFloat(Name, 'DColG', 1); + ThemeButton.DColB := ThemeIni.ReadFloat(Name, 'DColB', 1); + ThemeButton.DInt := ThemeIni.ReadFloat(Name, 'DInt', 1);} + +{ C := ColorExists(ThemeIni.ReadString(Name, 'Color', '')); + if C >= 0 then begin + ThemeButton.ColR := Color[C].RGB.R; + ThemeButton.ColG := Color[C].RGB.G; + ThemeButton.ColB := Color[C].RGB.B; + end; + + C := ColorExists(ThemeIni.ReadString(Name, 'DColor', '')); + if C >= 0 then begin + ThemeButton.DColR := Color[C].RGB.R; + ThemeButton.DColG := Color[C].RGB.G; + ThemeButton.DColB := Color[C].RGB.B; + end;} + + for T := 0 to High(ThemeButton.Text) do + ThemeSaveText(ThemeButton.Text[T], Name + 'Text' + IntToStr(T+1)); + + DecimalSeparator := ','; +end; + + +end. diff --git a/Game/Code/Classes/UTime.pas b/Game/Code/Classes/UTime.pas new file mode 100644 index 00000000..29e972ae --- /dev/null +++ b/Game/Code/Classes/UTime.pas @@ -0,0 +1,81 @@ +unit UTime; + +interface + +type + TTime = class + constructor Create; + function GetTime: real; + end; + +procedure CountSkipTimeSet; +procedure CountSkipTime; +procedure CountMidTime; +procedure TimeSleep(ms: real); + +var + USTime: TTime; + + TimeFreq: int64; + TimeNew: int64; + TimeOld: int64; + TimeSkip: real; + TimeMid: real; + TimeMidTemp: int64; + +implementation + +uses Windows; + +constructor TTime.Create; +begin + CountSkipTimeSet; +end; + +procedure CountSkipTimeSet; +begin + QueryPerformanceFrequency(TimeFreq); + QueryPerformanceCounter(TimeNew); +end; + +procedure CountSkipTime; +begin + TimeOld := TimeNew; + QueryPerformanceCounter(TimeNew); + TimeSkip := (TimeNew-TimeOld)/TimeFreq; +end; + +procedure CountMidTime; +begin + QueryPerformanceCounter(TimeMidTemp); + TimeMid := (TimeMidTemp-TimeNew)/TimeFreq; +end; + +procedure TimeSleep(ms: real); +var + TimeStart: int64; + TimeHalf: int64; + Time: real; + Stop: boolean; +begin + QueryPerformanceCounter(TimeStart); + + Stop := false; + while (not Stop) do begin + QueryPerformanceCounter(TimeHalf); + Time := 1000 * (TimeHalf-TimeStart)/TimeFreq; + if Time > ms then Stop := true; + end; + +end; + +function TTime.GetTime: real; +var + TimeTemp: int64; +begin + QueryPerformanceCounter(TimeTemp); + Result := TimeTemp/TimeFreq; +end; + + +end. diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas new file mode 100644 index 00000000..29450c1d --- /dev/null +++ b/Game/Code/Menu/UDisplay.pas @@ -0,0 +1,438 @@ +unit UDisplay; + +interface + +uses Windows, SDL, UMenu, OpenGL12, SysUtils; + +type + TDisplay = class + ActualScreen: PMenu; + NextScreen: PMenu; + + //fade-to-black-hack + BlackScreen: Boolean; + //popup hack + NextScreenWithCheck: Pmenu; + CheckOK: Boolean; + + h_DC: HDC; + h_RC: HGLRC; + + Fade: Real; + // fade-mod + doFade: Boolean; + canFade: Boolean; + myFade: integer; + lastTime: Cardinal; + pTexData : Pointer; + pTex : array[1..2] of glUInt; + // end + + //FPS Counter + FPSCounter: Cardinal; + LastFPS: Cardinal; + NextFPSSwap:Cardinal; + + //For Debug OSD + OSD_LastError: String; + + function Draw: Boolean; + procedure PrintScreen; + constructor Create; + // fade mod + destructor Destroy; + // end + procedure ScreenShot; + + procedure DrawDebugInformation; + end; + +var + Display: TDisplay; + +implementation + +uses UGraphic, UTime, Graphics, Jpeg, UFiles, UTexture, UIni, TextGL, UCommandLine; + +constructor TDisplay.Create; +var i: integer; +begin + inherited Create; + + //popup hack + CheckOK:=False; + NextScreen:=NIL; + NextScreenWithCheck:=NIL; + BlackScreen:=False; + + // fade mod + myfade:=0; + + if Ini.ScreenFade=1 then + doFade:=True + else + doFade:=False; + + canFade:=True; + // generate texture for fading between screens + GetMem(pTexData, 512*512*3); + if pTexData <> NIL then + for i:= 1 to 2 do + begin + glGenTextures(1, pTex[i]); + if glGetError <> GL_NO_ERROR then canFade := False; + glBindTexture(GL_TEXTURE_2D, pTex[i]); + if glGetError <> GL_NO_ERROR then canFade := False; + glTexImage2D(GL_TEXTURE_2D, 0, 3, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, pTexData); + if glGetError <> GL_NO_ERROR then canFade := False; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + if glGetError <> GL_NO_ERROR then canFade := False; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + if glGetError <> GL_NO_ERROR then canFade := False; + end + else + begin + canFade:=False; + end; + FreeMem(pTexData); + // end + + //Set LastError for OSD to No Error + OSD_LastError := 'No Errors'; +end; + +// fade mod +destructor TDisplay.Destroy; +begin + if canFade then + glDeleteTextures(1,@pTex); + inherited Destroy; +end; +// end + +function TDisplay.Draw: Boolean; +var + S: integer; + Col: Real; + // fade mod + myFade2: Real; + currentTime: Cardinal; + glError: glEnum; + glErrorStr: String; + // end +begin + Result := True; + + Col := 1; + {if (ParamStr(1) = '-black') or (ParamStr(1) = '-fsblack') then + Col := 0; } + + glClearColor(Col, Col, Col , 0); + glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); + + for S := 1 to Screens do begin + ScreenAct := S; + +// if Screens = 1 then ScreenX := 0; +// if (Screens = 2) and (S = 1) then ScreenX := -1; +// if (Screens = 2) and (S = 2) then ScreenX := 1; + ScreenX := 0; + + if S = 2 then TimeSkip := 0 else; + glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); + + //popup hack + // check was successful... move on + if CheckOK then + if assigned (NextScreenWithCheck)then + begin + NextScreen:=NextScreenWithCheck; + NextScreenWithCheck := NIL; + CheckOk:=False; + end + else + BlackScreen:=True; // end of game - fade to black before exit + //end popup hack + +// ActualScreen.SetAnimationProgress(1); + if (not assigned (NextScreen)) and (not BlackScreen) then begin + ActualScreen.Draw; + //popup mod + if ScreenPopupError <> NIL then if ScreenPopupError.Visible then ScreenPopupError.Draw else + if ScreenPopupCheck <> NIL then if ScreenPopupCheck.Visible then ScreenPopupCheck.Draw; + //popup end + // fade mod + myfade:=0; + if (Ini.ScreenFade=1) and canFade then + doFade:=True + else if Ini.ScreenFade=0 then + doFade:=False; + // end + end + else + begin + // check if we had an initialization error (canfade=false, dofade=true) + if doFade and not canFade then begin + doFade:=False; //disable fading + ScreenPopupError.ShowPopup('Error initializing\nfade texture\n\nfading\ndisabled'); //show error message + end; + if doFade and canFade then + begin + // fade mod + //Create Fading texture if we're just starting + if myfade = 0 then + begin + glViewPort(0, 0, 512, 512); + ActualScreen.Draw; + glBindTexture(GL_TEXTURE_2D, pTex[S]); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 512, 512, 0); + glError:=glGetError; + if glError <> GL_NO_ERROR then + begin + canFade := False; + case glError of + GL_INVALID_ENUM: glErrorStr:='INVALID_ENUM'; + GL_INVALID_VALUE: glErrorStr:='INVALID_VALUE'; + GL_INVALID_OPERATION: glErrorStr:='INVALID_OPERATION'; + GL_STACK_OVERFLOW: glErrorStr:='STACK_OVERFLOW'; + GL_STACK_UNDERFLOW: glErrorStr:='STACK_UNDERFLOW'; + GL_OUT_OF_MEMORY: glErrorStr:='OUT_OF_MEMORY'; + else glErrorStr:='unknown error'; + end; + ScreenPopupError.ShowPopup('Error copying\nfade texture\n('+glErrorStr+')\nfading\ndisabled'); //show error message + end; + glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); + // blackscreen-hack + if (not BlackScreen) AND (S = 1) then + NextScreen.onShow; + lastTime:=GetTickCount; + if (S=2) or (Screens = 1) then + myfade:=myfade+1; + end; // end texture creation in first fading step + + //do some time-based fading + currentTime:=GetTickCount; + if (currentTime > lastTime+30) and (S=1) then + begin + myfade:=myfade+4; + lastTime:=currentTime; + end; + +// LastFade := Fade; // whatever +// Fade := Fade -0.999; // start fading out + + +// ActualScreen.ShowFinish := false; // no purpose? + +// ActualScreen.SetAnimationProgress(Fade-1); // nop? + + // blackscreen-hack + if not BlackScreen then + NextScreen.Draw // draw next screen + else begin + glClearColor(0, 0, 0 , 0); + glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); + end; + + // and draw old screen over it... slowly fading out + myfade2:=(myfade*myfade)/10000; + glBindTexture(GL_TEXTURE_2D, pTex[S]); + glColor4f(1, 1, 1, (1000-myfade*myfade)/1000); // strange calculation - alpha gets negative... but looks good this way + glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glBegin(GL_QUADS); + glTexCoord2f(0+myfade2,0+myfade2);glVertex2f(0, 600); + glTexCoord2f(0+myfade2,1-myfade2);glVertex2f(0, 0); + glTexCoord2f(1-myfade2,1-myfade2);glVertex2f(800, 0); + glTexCoord2f(1-myfade2,0+myfade2);glVertex2f(800, 600); + glEnd; + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + end + else + // blackscreen hack + if (not BlackScreen) AND (S = 1) then + NextScreen.OnShow; + + + if ((myfade > 40) or (not doFade) or (not canFade)) And (S = 1) then begin // fade out complete... + myFade:=0; + ActualScreen.onHide; + ActualScreen.ShowFinish:=False; + ActualScreen:=NextScreen; + NextScreen := nil; + if not blackscreen then + begin + ActualScreen.onShowFinish; + ActualScreen.ShowFinish := true; + end + else + begin + Result:=False; + Break; + end; + // end of fade mod + end; + end; // if + + //Draw OSD only on first Screen if Debug Mode is enabled + if ((Ini.Debug = 1) OR (Params.Debug)) AND (S=1) then + DrawDebugInformation; + + end; // for +// SwapBuffers(h_DC); +end; + +{function TDisplay.Fade(FadeIn : Boolean; Steps : UInt8): UInt8; +begin + Self.FadeIn := FadeIn; + FadeStep := (SizeOf(FadeStep) * $FF) div Steps; + ActualStep := $FF; + Result := $FF div FadeStep; +end;} + +procedure TDisplay.PrintScreen; +var + Bitmap: TBitmap; + Jpeg: TJpegImage; + X, Y: integer; + Num: integer; + FileName: string; +begin + for Num := 1 to 9999 do begin + FileName := IntToStr(Num); + while Length(FileName) < 4 do FileName := '0' + FileName; + FileName := ScreenshotsPath + 'screenshot' + FileName + '.jpg'; + if not FileExists(FileName) then break + end; + + glReadPixels(0, 0, ScreenW, ScreenH, GL_RGBA, GL_UNSIGNED_BYTE, @PrintScreenData[0]); + Bitmap := TBitmap.Create; + Bitmap.Width := ScreenW; + Bitmap.Height := ScreenH; + + for Y := 0 to ScreenH-1 do + for X := 0 to ScreenW-1 do + Bitmap.Canvas.Pixels[X, Y] := PrintScreenData[(ScreenH-1-Y) * ScreenW + X] and $00FFFFFF; + + Jpeg := TJpegImage.Create; + Jpeg.Assign(Bitmap); + Bitmap.Free; + Jpeg.CompressionQuality := 95;//90; + Jpeg.SaveToFile(FileName); + Jpeg.Free; +end; + +procedure TDisplay.ScreenShot; + var F : file; + FileInfo: BITMAPINFOHEADER; + FileHeader : BITMAPFILEHEADER; + pPicData:Pointer; + FileName: String; + Num: Integer; +begin + //bilddatei Suchen + for Num := 1 to 9999 do begin + FileName := IntToStr(Num); + while Length(FileName) < 4 do FileName := '0' + FileName; + FileName := ScreenshotsPath + FileName + '.BMP'; + if not FileExists(FileName) then break + end; + + //Speicher für die Speicherung der Header-Informationen vorbereiten + ZeroMemory(@FileHeader, SizeOf(BITMAPFILEHEADER)); + ZeroMemory(@FileInfo, SizeOf(BITMAPINFOHEADER)); + + //Initialisieren der Daten des Headers + FileHeader.bfType := 19778; //$4D42 = 'BM' + FileHeader.bfOffBits := SizeOf(BITMAPINFOHEADER)+SizeOf(BITMAPFILEHEADER); + + //Schreiben der Bitmap-Informationen + FileInfo.biSize := SizeOf(BITMAPINFOHEADER); + FileInfo.biWidth := ScreenW; + FileInfo.biHeight := ScreenH; + FileInfo.biPlanes := 1; + FileInfo.biBitCount := 32; + FileInfo.biSizeImage := FileInfo.biWidth*FileInfo.biHeight*(FileInfo.biBitCount div 8); + + //Größenangabe auch in den Header übernehmen + FileHeader.bfSize := FileHeader.bfOffBits + FileInfo.biSizeImage; + + //Speicher für die Bilddaten reservieren + GetMem(pPicData, FileInfo.biSizeImage); + try + //Bilddaten von OpenGL anfordern (siehe oben) + glReadPixels(0, 0, ScreenW, ScreenH, GL_BGRA, GL_UNSIGNED_BYTE, pPicData); + + //Und den ganzen Müll in die Datei schieben ;-) + //Moderne Leute nehmen dafür auch Streams ... + AssignFile(f, Filename); + Rewrite( f,1 ); + try + BlockWrite(F, FileHeader, SizeOf(BITMAPFILEHEADER)); + BlockWrite(F, FileInfo, SizeOf(BITMAPINFOHEADER)); + BlockWrite(F, pPicData^, FileInfo.biSizeImage ); + finally + CloseFile(f); + end; + finally + //Und den angeforderten Speicher wieder freigeben ... + FreeMem(pPicData, FileInfo.biSizeImage); + end; +end; + +//------------ +// DrawDebugInformation - Procedure draw FPS and some other Informations on Screen +//------------ +procedure TDisplay.DrawDebugInformation; +var Ticks: Cardinal; +begin + //Some White Background for information + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glColor4f(1, 1, 1, 0.5); + glBegin(GL_QUADS); + glVertex2f(690, 44); + glVertex2f(690, 0); + glVertex2f(800, 0); + glVertex2f(800, 44); + glEnd; + glDisable(GL_BLEND); + + //Set Font Specs + SetFontStyle(0); + SetFontSize(7); + SetFontItalic(False); + glColor4f(0, 0, 0, 1); + + //Calculate FPS + Ticks := GetTickCount; + if (Ticks >= NextFPSSwap) then + begin + LastFPS := FPSCounter * 4; + FPSCounter := 0; + NextFPSSwap := Ticks + 250; + end; + + Inc(FPSCounter); + + //Draw Text + + //FPS + SetFontPos(695, 0); + glPrint (PChar('FPS: ' + InttoStr(LastFPS))); + + //RSpeed + SetFontPos(695, 13); + glPrint (PChar('RSpeed: ' + InttoStr(Round(1000 * TimeMid)))); + + //LastError + SetFontPos(695, 26); + glColor4f(1, 0, 0, 1); + glPrint (PChar(OSD_LastError)); + + glColor4f(1, 1, 1, 1); +end; + +end. diff --git a/Game/Code/Menu/UDrawTexture.pas b/Game/Code/Menu/UDrawTexture.pas new file mode 100644 index 00000000..5a543f33 --- /dev/null +++ b/Game/Code/Menu/UDrawTexture.pas @@ -0,0 +1,101 @@ +unit UDrawTexture; + +interface +uses UTexture; + +procedure DrawLine(X1, Y1, X2, Y2, ColR, ColG, ColB: real); +procedure DrawQuad(X, Y, W, H, ColR, ColG, ColB: real); +procedure DrawTexture(Texture: TTexture); + +implementation +uses OpenGL12; + +procedure DrawLine(X1, Y1, X2, Y2, ColR, ColG, ColB: real); +begin + glColor3f(ColR, ColG, ColB); + glBegin(GL_LINES); + glVertex2f(x1, y1); + glVertex2f(x2, y2); + glEnd; +end; + +procedure DrawQuad(X, Y, W, H, ColR, ColG, ColB: real); +begin + glColor3f(ColR, ColG, ColB); + glBegin(GL_QUADS); + glVertex2f(x, y); + glVertex2f(x, y+h); + glVertex2f(x+w, y+h); + glVertex2f(x+w, y); + glEnd; +end; + +procedure DrawTexture(Texture: TTexture); +var + x1, x2, x3, x4: real; + y1, y2, y3, y4: real; + xt1, xt2, xt3, xt4: real; + yt1, yt2, yt3, yt4: real; +begin + with Texture do begin + // rysuje paski gracza + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glDepthRange(0, 10); + glDepthFunc(GL_LEQUAL); +// glDepthFunc(GL_GEQUAL); + glEnable(GL_DEPTH_TEST); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +// glBlendFunc(GL_SRC_COLOR, GL_ZERO); + glBindTexture(GL_TEXTURE_2D, TexNum); + + x1 := x; + x2 := x; + x3 := x+w*scaleW; + x4 := x+w*scaleW; + y1 := y; + y2 := y+h*scaleH; + y3 := y+h*scaleH; + y4 := y; + if Rot <> 0 then begin + xt1 := x1 - (x + w/2); + xt2 := x2 - (x + w/2); + xt3 := x3 - (x + w/2); + xt4 := x4 - (x + w/2); + yt1 := y1 - (y + h/2); + yt2 := y2 - (y + h/2); + yt3 := y3 - (y + h/2); + yt4 := y4 - (y + h/2); + + x1 := (x + w/2) + xt1 * cos(Rot) - yt1 * sin(Rot); + x2 := (x + w/2) + xt2 * cos(Rot) - yt2 * sin(Rot); + x3 := (x + w/2) + xt3 * cos(Rot) - yt3 * sin(Rot); + x4 := (x + w/2) + xt4 * cos(Rot) - yt4 * sin(Rot); + + y1 := (y + h/2) + yt1 * cos(Rot) + xt1 * sin(Rot); + y2 := (y + h/2) + yt2 * cos(Rot) + xt2 * sin(Rot); + y3 := (y + h/2) + yt3 * cos(Rot) + xt3 * sin(Rot); + y4 := (y + h/2) + yt4 * cos(Rot) + xt4 * sin(Rot); + + end; + +{ glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex3f(x1, y1, z); + glTexCoord2f(0, TexH); glVertex3f(x2, y2, z); + glTexCoord2f(TexW, TexH); glVertex3f(x3, y3, z); + glTexCoord2f(TexW, 0); glVertex3f(x4, y4, z); + glEnd;} + + glBegin(GL_QUADS); + glTexCoord2f(TexX1*TexW, TexY1*TexH); glVertex3f(x1, y1, z); + glTexCoord2f(TexX1*TexW, TexY2*TexH); glVertex3f(x2, y2, z); + glTexCoord2f(TexX2*TexW, TexY2*TexH); glVertex3f(x3, y3, z); + glTexCoord2f(TexX2*TexW, TexY1*TexH); glVertex3f(x4, y4, z); + glEnd; + end; + glDisable(GL_DEPTH_TEST); + glDisable(GL_TEXTURE_2D); +end; + +end. diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas new file mode 100644 index 00000000..309e199a --- /dev/null +++ b/Game/Code/Menu/UMenu.pas @@ -0,0 +1,1448 @@ +unit UMenu; + +interface + +uses OpenGL12, SysUtils, UTexture, UMenuStatic, UMenuText, UMenuButton, UMenuSelect, UMenuSelectSlide, + UMenuInteract, UThemes, UMenuButtonCollection; + +type +{ Int16 = SmallInt;} + + PMenu = ^TMenu; + TMenu = class + protected + ButtonPos: Integer; + + Interactions: array of TInteract; + SelInteraction: integer; + Button: array of TButton; + Selects: array of TSelect; + SelectsS: array of TSelectSlide; + ButtonCollection: Array of TButtonCollection; + BackImg: TTexture; + BackW: integer; + BackH: integer; + public + Text: array of TText; + Static: array of TStatic; + mX: integer; // mouse X + mY: integer; // mouse Y + + Fade: integer; // fade type + ShowFinish: boolean; // true if there is no fade + + + destructor Destroy; override; + constructor Create; overload; virtual; + //constructor Create(Back: string); overload; virtual; // Back is a JPG resource name for background + //constructor Create(Back: string; W, H: integer); overload; virtual; // W and H are the number of overlaps + + // interaction + procedure AddInteraction(Typ, Num: integer); + procedure SetInteraction(Num: integer); + property Interaction: integer read SelInteraction write SetInteraction; + + //Procedure Load BG, Texts, Statics and Button Collections from ThemeBasic + procedure LoadFromTheme(const ThemeBasic: TThemeBasic); + + procedure PrepareButtonCollections(const Collections: AThemeButtonCollection); + procedure AddButtonCollection(const ThemeCollection: TThemeButtonCollection; Const Num: Byte); + + // background + procedure AddBackground(Name: string); + + // static + function AddStatic(ThemeStatic: TThemeStatic): integer; overload; + function AddStatic(X, Y, W, H: real; Name: string): integer; overload; + function AddStatic(X, Y, W, H: real; Name, Format, Typ: string): integer; overload; + function AddStatic(X, Y, W, H: real; ColR, ColG, ColB: real; Name, Format, Typ: string): integer; overload; + function AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; Name, Format, Typ: string): integer; overload; + function AddStatic(X, Y, W, H: real; ColR, ColG, ColB: real; Name, Format, Typ: string; Color: integer): integer; overload; + function AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; Name, Format, Typ: string; Color: integer): integer; overload; + function AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; TexX1, TexY1, TexX2, TexY2: real; Name, Format, Typ: string; Color: integer; Reflection: Boolean; ReflectionSpacing: Real): integer; overload; + + // text + function AddText(ThemeText: TThemeText): integer; overload; + function AddText(X, Y: real; Tekst: string): integer; overload; + function AddText(X, Y: real; Style: integer; Size, ColR, ColG, ColB: real; Tekst: string): integer; overload; + function AddText(X, Y, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; Tekst: string): integer; overload; + + // button + Procedure SetButtonLength(Length: Cardinal); //Function that Set Length of Button Array in one Step instead of register new Memory for every Button + function AddButton(ThemeButton: TThemeButton): integer; overload; + function AddButton(X, Y, W, H: real; Name: String): integer; overload; + function AddButton(X, Y, W, H: real; Name, Format, Typ: String; Reflection: Boolean): integer; overload; + function AddButton(X, Y, W, H, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt: real; Name, Format, Typ: String; Reflection: Boolean; ReflectionSpacing, DeSelectReflectionSpacing: Real): integer; overload; + procedure ClearButtons; + procedure AddButtonText(AddX, AddY: real; AddText: string); overload; + procedure AddButtonText(AddX, AddY: real; ColR, ColG, ColB: real; AddText: string); overload; + procedure AddButtonText(AddX, AddY: real; ColR, ColG, ColB: real; Font: integer; Size: integer; Align: integer; AddText: string); overload; + procedure AddButtonText(CustomButton: TButton; AddX, AddY: real; ColR, ColG, ColB: real; Font: integer; Size: integer; Align: integer; AddText: string); overload; + + // select + function AddSelect(ThemeSelect: TThemeSelect; var Data: integer; Values: array of string): integer; overload; + function AddSelect(X, Y, W, H, SkipX, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt, + TColR, TColG, TColB, TInt, TDColR, TDColG, TDColB, TDInt, + SBGColR, SBGColG, SBGColB, SBGInt, SBGDColR, SBGDColG, SBGDColB, SBGDInt, + STColR, STColG, STColB, STInt, STDColR, STDColG, STDColB, STDInt: real; + Name, Typ: String; SBGName, SBGTyp: String; + Caption: string; var Data: integer): integer; overload; + procedure AddSelectOption(AddX, AddY: real; AddText: string); overload; + procedure AddSelectOption(SelectNo: Cardinal; AddX, AddY: real; AddText: string); overload; + procedure UpdateSelectOptions(ThemeSelect: TThemeSelect; SelectNum: integer; Values: array of string; var Data: integer); + + // select slide + function AddSelectSlide(ThemeSelectS: TThemeSelectSlide; var Data: integer; Values: array of string): integer; overload; + function AddSelectSlide(X, Y, W, H, SkipX, SBGW, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt, + TColR, TColG, TColB, TInt, TDColR, TDColG, TDColB, TDInt, + SBGColR, SBGColG, SBGColB, SBGInt, SBGDColR, SBGDColG, SBGDColB, SBGDInt, + STColR, STColG, STColB, STInt, STDColR, STDColG, STDColB, STDInt: real; + Name, Typ: String; SBGName, SBGTyp: String; + Caption: string; var Data: integer): integer; overload; + procedure AddSelectSlideOption(AddText: string); overload; + procedure AddSelectSlideOption(SelectNo: Cardinal; AddText: string); overload; + procedure UpdateSelectSlideOptions(ThemeSelectSlide: TThemeSelectSlide; SelectNum: integer; Values: array of string; var Data: integer); + + +// function AddWidget(X, Y : UInt16; WidgetSrc : PSDL_Surface): Int16; +// procedure ClearWidgets(MinNumber : Int16); + procedure FadeTo(Screen: PMenu); + //popup hack + procedure CheckFadeTo(Screen: PMenu; msg: String); + + function DrawBG: boolean; virtual; + function DrawFG: boolean; virtual; + function Draw: boolean; virtual; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown : Boolean): Boolean; virtual; + function ParseMouse(Typ: integer; X: integer; Y: integer): Boolean; virtual; abstract; + function InRegion(X1, Y1, X2, Y2, X, Y: real): Boolean; + function InStaticRegion(StaticNr: integer; X, Y: integer): Boolean; + procedure onShow; virtual; + procedure onShowFinish; virtual; + procedure onHide; virtual; + + procedure SetAnimationProgress(Progress: real); virtual; + + function IsSelectable(Int: Cardinal): Boolean; + + procedure InteractNext; virtual; + procedure InteractCustom(CustomSwitch: integer); virtual; + procedure InteractPrev; virtual; + procedure InteractInc; virtual; + procedure InteractDec; virtual; + + procedure AddBox(X, Y, W, H: real); + end; + +const + pmMove = 1; + pmClick = 2; + pmUnClick = 3; + + iButton = 0; // interaction type + iSelect = 1; + iText = 2; + iSelectS = 3; + iBCollectionChild = 5; + +// fBlack = 0; // fade type +// fWhite = 1; + +implementation + +uses UMain, UDrawTexture, UGraphic, UDisplay, UCovers, USkins, Dialogs; + +destructor TMenu.Destroy; +begin + inherited; +end; + +constructor TMenu.Create; +begin + Fade := 0;//fWhite; + + SetLength(Static, 0); + SetLength(Button, 0); + + BackImg.TexNum := -1; + + //Set ButtonPos to Autoset Length + ButtonPos := -1; +end; +{ +constructor TMenu.Create(Back: String); +begin + inherited Create; + + if Back <> '' then begin +// BackImg := Texture.LoadTexture(true, PChar(Back), 'JPG', 'Plain', 0); + BackImg := Texture.LoadTexture(PChar(Back), 'JPG', 'Plain', 0); // new theme system + BackImg.W := 800;//640; + BackImg.H := 600;//480; + BackW := 1; + BackH := 1; + end else + BackImg.TexNum := -1; + + //Set ButtonPos to Autoset Length + ButtonPos := -1; +end; + +constructor TMenu.Create(Back: string; W, H: integer); +begin + Create(Back); + BackImg.W := BackImg.W / W; + BackImg.H := BackImg.H / H; + BackW := W; + BackH := H; +end; } + +procedure TMenu.AddInteraction(Typ, Num: integer); +var + IntNum: integer; +begin + IntNum := Length(Interactions); + SetLength(Interactions, IntNum+1); + Interactions[IntNum].Typ := Typ; + Interactions[IntNum].Num := Num; + Interaction := 0; +end; + +procedure TMenu.SetInteraction(Num: integer); +var + OldNum, OldTyp: integer; + NewNum, NewTyp: integer; +begin + // set inactive + OldNum := Interactions[Interaction].Num; + OldTyp := Interactions[Interaction].Typ; + + NewNum := Interactions[Num].Num; + NewTyp := Interactions[Num].Typ; + + case OldTyp of + iButton: Button[OldNum].Selected := False; + iSelect: Selects[OldNum].Selected := False; + iText: Text[OldNum].Selected := False; + iSelectS: SelectsS[OldNum].Selected := False; + //Button Collection Mod + iBCollectionChild: + begin + Button[OldNum].Selected := False; + + //Deselect Collection if Next Button is Not from Collection + if (NewTyp <> iButton) Or (Button[NewNum].Parent <> Button[OldNum].Parent) then + ButtonCollection[Button[OldNum].Parent-1].Selected := False; + end; + end; + + // set active + SelInteraction := Num; + case NewTyp of + iButton: Button[NewNum].Selected := True; + iSelect: Selects[NewNum].Selected := True; + iText: Text[NewNum].Selected := True; + iSelectS: SelectsS[NewNum].Selected := True; + + //Button Collection Mod + iBCollectionChild: + begin + Button[NewNum].Selected := True; + ButtonCollection[Button[NewNum].Parent-1].Selected := True; + end; + end; +end; + +//---------------------- +//LoadFromTheme - Load BG, Texts, Statics and +//Button Collections from ThemeBasic +//---------------------- +procedure TMenu.LoadFromTheme(const ThemeBasic: TThemeBasic); +var + I: Integer; +begin + //Add Button Collections (Set Button CollectionsLength) + //Button Collections are Created when the first ChildButton is Created + PrepareButtonCollections(ThemeBasic.ButtonCollection); + + + //Add Background + AddBackground(ThemeBasic.Background.Tex); + + //Add Statics and Texts + for I := 0 to High(ThemeBasic.Static) do + AddStatic(ThemeBasic.Static[I]); + + for I := 0 to High(ThemeBasic.Text) do + AddText(ThemeBasic.Text[I]); +end; + +procedure TMenu.AddBackground(Name: string); +begin + if Name <> '' then begin +// BackImg := Texture.LoadTexture(false, PChar(Skin.SkinPath + FileName), 'JPG', 'Plain', 0); // new theme system + BackImg := Texture.GetTexture(Skin.GetTextureFileName(Name), 'Plain'); + BackImg.W := 800; + BackImg.H := 600; + BackW := 1; + BackH := 1; + end; +end; + +//---------------------- +//PrepareButtonCollections: +//Add Button Collections (Set Button CollectionsLength) +//---------------------- +procedure TMenu.PrepareButtonCollections(const Collections: AThemeButtonCollection); +var + I: Integer; +begin + SetLength(ButtonCollection, Length(Collections)); + For I := 0 to High(ButtonCollection) do + AddButtonCollection(Collections[I], I); +end; + +//---------------------- +//AddButtonCollection: +//Create a Button Collection; +//---------------------- +procedure TMenu.AddButtonCollection(const ThemeCollection: TThemeButtonCollection; Const Num: Byte); +var + BT, BTLen: Integer; +begin + if (Num > High(ButtonCollection)) then + exit; + + ButtonCollection[Num] := TButtonCollection.Create(Texture.GetTexture(Skin.GetTextureFileName(ThemeCollection.Style.Tex), ThemeCollection.Style.Typ, true)); // use cache texture + + //Set Parent menu + ButtonCollection[Num].ScreenButton := @Self.Button; + + //Set Attributes + ButtonCollection[Num].FirstChild := ThemeCollection.FirstChild; + ButtonCollection[Num].CountChilds := ThemeCollection.ChildCount; + ButtonCollection[Num].Parent := Num + 1; + + //Set Style + ButtonCollection[Num].X := ThemeCollection.Style.X; + ButtonCollection[Num].Y := ThemeCollection.Style.Y; + ButtonCollection[Num].W := ThemeCollection.Style.W; + ButtonCollection[Num].H := ThemeCollection.Style.H; + ButtonCollection[Num].SelectColR := ThemeCollection.Style.ColR; + ButtonCollection[Num].SelectColG := ThemeCollection.Style.ColG; + ButtonCollection[Num].SelectColB := ThemeCollection.Style.ColB; + ButtonCollection[Num].SelectInt := ThemeCollection.Style.Int; + ButtonCollection[Num].DeselectColR := ThemeCollection.Style.DColR; + ButtonCollection[Num].DeselectColG := ThemeCollection.Style.DColG; + ButtonCollection[Num].DeselectColB := ThemeCollection.Style.DColB; + ButtonCollection[Num].DeselectInt := ThemeCollection.Style.DInt; + ButtonCollection[Num].Texture.TexX1 := 0; + ButtonCollection[Num].Texture.TexY1 := 0; + ButtonCollection[Num].Texture.TexX2 := 1; + ButtonCollection[Num].Texture.TexY2 := 1; + ButtonCollection[Num].SetSelect(false); + + ButtonCollection[Num].Reflection := ThemeCollection.Style.Reflection; + ButtonCollection[Num].Reflectionspacing := ThemeCollection.Style.ReflectionSpacing; + ButtonCollection[Num].DeSelectReflectionspacing := ThemeCollection.Style.DeSelectReflectionSpacing; + + ButtonCollection[Num].Z := ThemeCollection.Style.Z; + + //Some Things from ButtonFading + ButtonCollection[Num].SelectH := ThemeCollection.Style.SelectH; + ButtonCollection[Num].SelectW := ThemeCollection.Style.SelectW; + + ButtonCollection[Num].Fade := ThemeCollection.Style.Fade; + ButtonCollection[Num].FadeText := ThemeCollection.Style.FadeText; + ButtonCollection[Num].FadeTex := Texture.GetTexture(Skin.GetTextureFileName(ThemeCollection.Style.FadeTex), ThemeCollection.Style.Typ, true); + ButtonCollection[Num].FadeTexPos := ThemeCollection.Style.FadeTexPos; + + + BTLen := Length(ThemeCollection.Style.Text); + for BT := 0 to BTLen-1 do begin + AddButtonText(ButtonCollection[Num], ThemeCollection.Style.Text[BT].X, ThemeCollection.Style.Text[BT].Y, + ThemeCollection.Style.Text[BT].ColR, ThemeCollection.Style.Text[BT].ColG, ThemeCollection.Style.Text[BT].ColB, + ThemeCollection.Style.Text[BT].Font, ThemeCollection.Style.Text[BT].Size, ThemeCollection.Style.Text[BT].Align, + ThemeCollection.Style.Text[BT].Text); + end; +end; + +function TMenu.AddStatic(ThemeStatic: TThemeStatic): integer; +begin + Result := AddStatic(ThemeStatic.X, ThemeStatic.Y, ThemeStatic.W, ThemeStatic.H, ThemeStatic.Z, + ThemeStatic.ColR, ThemeStatic.ColG, ThemeStatic.ColB, + ThemeStatic.TexX1, ThemeStatic.TexY1, ThemeStatic.TexX2, ThemeStatic.TexY2, + {<0.5.1: Skin.SkinPath + ThemeStatic.Tex, 0.5.1:} Skin.GetTextureFileName(ThemeStatic.Tex), + 'JPG', ThemeStatic.Typ, $FFFFFF, ThemeStatic.Reflection, ThemeStatic.Reflectionspacing); + //'Font Black'); +end; + +function TMenu.AddStatic(X, Y, W, H: real; Name: string): integer; +begin + Result := AddStatic(X, Y, W, H, Name, 'JPG', 'Plain'); +end; + +function TMenu.AddStatic(X, Y, W, H: real; ColR, ColG, ColB: real; Name, Format, Typ: string): integer; +var + StatNum: integer; +begin + Result := AddStatic(X, Y, W, H, ColR, ColG, ColB, Name, Format, Typ, $FFFFFF); +end; + +function TMenu.AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; Name, Format, Typ: string): integer; +var + StatNum: integer; +begin + Result := AddStatic(X, Y, W, H, Z, ColR, ColG, ColB, Name, Format, Typ, $FFFFFF); +end; + +function TMenu.AddStatic(X, Y, W, H: real; Name, Format, Typ: string): integer; +var + StatNum: integer; +begin + // adds static + StatNum := Length(Static); + SetLength(Static, StatNum + 1); +// Static[StatNum] := TStatic.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), $FF00FF)); // $FFFFFF +// Static[StatNum] := TStatic.Create(Texture.LoadTexture(Skin.SkinReg, PChar(Name), PChar(Format), PChar(Typ), $FF00FF)); // new skin system + Static[StatNum] := TStatic.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), $FF00FF)); // new skin + + // configures static + Static[StatNum].Texture.X := X; + Static[StatNum].Texture.Y := Y; + Static[StatNum].Texture.W := W; + Static[StatNum].Texture.H := H; + Static[StatNum].Visible := true; + Result := StatNum; +end; + +function TMenu.AddStatic(X, Y, W, H: real; ColR, ColG, ColB: real; Name, Format, Typ: string; Color: integer): integer; +var + StatNum: integer; +begin + Result := AddStatic(X, Y, W, H, 0, ColR, ColG, ColB, Name, Format, Typ, Color); +end; + +function TMenu.AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; Name, Format, Typ: string; Color: integer): integer; +begin + Result := AddStatic(X, Y, W, H, Z, ColR, ColG, ColB, 0, 0, 1, 1, Name, Format, Typ, Color, False, 0); +// +end; + +function TMenu.AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; TexX1, TexY1, TexX2, TexY2: real; Name, Format, Typ: string; Color: integer; Reflection: Boolean; ReflectionSpacing: Real): integer; +var + StatNum: integer; +begin + // adds static + StatNum := Length(Static); + SetLength(Static, StatNum + 1); +// Static[StatNum] := TStatic.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), Color)); +// Static[StatNum] := TStatic.Create(Texture.LoadTexture(Skin.SkinReg, PChar(Name), PChar(Format), PChar(Typ), Color)); // new skin system +Static[StatNum] := TStatic.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), Color)); // new skin +// Static[StatNum] := TStatic.Create(Texture.GetTexture(Name, Typ)); + + // configures static + Static[StatNum].Texture.X := X; + Static[StatNum].Texture.Y := Y; + Static[StatNum].Texture.W := W; + Static[StatNum].Texture.H := H; + Static[StatNum].Texture.Z := Z; + Static[StatNum].Texture.ColR := ColR; + Static[StatNum].Texture.ColG := ColG; + Static[StatNum].Texture.ColB := ColB; + Static[StatNum].Texture.TexX1 := TexX1; + Static[StatNum].Texture.TexY1 := TexY1; + Static[StatNum].Texture.TexX2 := TexX2; + Static[StatNum].Texture.TexY2 := TexY2; + Static[StatNum].Texture.Alpha := 1; + Static[StatNum].Visible := true; + + //ReflectionMod + Static[StatNum].Reflection := Reflection; + Static[StatNum].ReflectionSpacing := ReflectionSpacing; + + Result := StatNum; +end; + +function TMenu.AddText(ThemeText: TThemeText): integer; +begin + Result := AddText(ThemeText.X, ThemeText.Y, ThemeText.W, ThemeText.Font, ThemeText.Size, + ThemeText.ColR, ThemeText.ColG, ThemeText.ColB, ThemeText.Align, ThemeText.Text); +end; + +function TMenu.AddText(X, Y: real; Tekst: string): integer; +var + TextNum: integer; +begin + // adds text + TextNum := Length(Text); + SetLength(Text, TextNum + 1); + Text[TextNum] := TText.Create(X, Y, Tekst); + Result := TextNum; +end; + +function TMenu.AddText(X, Y: real; Style: integer; Size, ColR, ColG, ColB: real; Tekst: string): integer; +begin + Result := AddText(X, Y, 0, Style, Size, ColR, ColG, ColB, 0, Tekst); +end; + +function TMenu.AddText(X, Y, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; Tekst: string): integer; +var + TextNum: integer; +begin + // adds text + TextNum := Length(Text); + SetLength(Text, TextNum + 1); + Text[TextNum] := TText.Create(X, Y, W, Style, Size, ColR, ColG, ColB, Align, Tekst); + Result := TextNum; +end; + +//Function that Set Length of Button Array in one Step instead of register new Memory for every Button +Procedure TMenu.SetButtonLength(Length: Cardinal); +begin + if (ButtonPos = -1) AND (Length > 0) then + begin + //Set Length of Button + SetLength(Button, Length); + + //Set ButtonPos to start with 0 + ButtonPos := 0; + end; +end; + + +// Method to add a button in our TMenu. It returns the assigned ButtonNumber +function TMenu.AddButton(ThemeButton: TThemeButton): integer; +var + BT: integer; + BTLen: integer; + temp: integer; +begin +{ Result := AddButton(ThemeButton.X, ThemeButton.Y, ThemeButton.W, ThemeButton.H, + ThemeButton.ColR, ThemeButton.ColG, ThemeButton.ColB, ThemeButton.Int, + ThemeButton.DColR, ThemeButton.DColG, ThemeButton.DColB, ThemeButton.DInt, + ThemeButton.Tex, 'JPG', 'Font Black');} + + Result := AddButton(ThemeButton.X, ThemeButton.Y, ThemeButton.W, ThemeButton.H, + ThemeButton.ColR, ThemeButton.ColG, ThemeButton.ColB, ThemeButton.Int, + ThemeButton.DColR, ThemeButton.DColG, ThemeButton.DColB, ThemeButton.DInt, + Skin.GetTextureFileName(ThemeButton.Tex), 'JPG', ThemeButton.Typ, ThemeButton.Reflection, ThemeButton.Reflectionspacing, ThemeButton.DeSelectReflectionspacing); + + Button[Result].Z := ThemeButton.Z; + + //Button Visibility + Button[Result].Visible := ThemeButton.Visible; + + //Some Things from ButtonFading + Button[Result].SelectH := ThemeButton.SelectH; + Button[Result].SelectW := ThemeButton.SelectW; + + Button[Result].Fade := ThemeButton.Fade; + Button[Result].FadeText := ThemeButton.FadeText; + Button[Result].FadeTex := Texture.GetTexture(Skin.GetTextureFileName(ThemeButton.FadeTex), ThemeButton.Typ, true); + Button[Result].FadeTexPos := ThemeButton.FadeTexPos; + + + BTLen := Length(ThemeButton.Text); + for BT := 0 to BTLen-1 do begin + AddButtonText(ThemeButton.Text[BT].X, ThemeButton.Text[BT].Y, + ThemeButton.Text[BT].ColR, ThemeButton.Text[BT].ColG, ThemeButton.Text[BT].ColB, + ThemeButton.Text[BT].Font, ThemeButton.Text[BT].Size, ThemeButton.Text[BT].Align, + ThemeButton.Text[BT].Text); + end; + + //BAutton Collection Mod + if (ThemeButton.Parent <> 0) then + begin + //If Collection Exists then Change Interaction to Child Button + if (@ButtonCollection[ThemeButton.Parent-1] <> nil) then + begin + Interactions[High(Interactions)].Typ := iBCollectionChild; + Button[Result].Visible := False; + + for BT := 0 to BTLen-1 do + Button[Result].Text[BT].Alpha := 0; + + Button[Result].Parent := ThemeButton.Parent; + if (ButtonCollection[ThemeButton.Parent-1].Fade) then + Button[Result].Texture.Alpha := 0; + end; + end; +end; + +function TMenu.AddButton(X, Y, W, H: real; Name: String): integer; +begin + Result := AddButton(X, Y, W, H, Name, 'JPG', 'Plain', False); +end; + +function TMenu.AddButton(X, Y, W, H: real; Name, Format, Typ: String; Reflection: Boolean): integer; +begin + Result := AddButton(X, Y, W, H, 1, 1, 1, 1, 1, 1, 1, 0.5, Name, 'JPG', 'Plain', Reflection, 15, 15); +end; + +function TMenu.AddButton(X, Y, W, H, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt: real; Name, Format, Typ: String; Reflection: Boolean; ReflectionSpacing, DeSelectReflectionSpacing: Real): integer; +begin + // adds button + //SetLength is used once to reduce Memory usement + if (ButtonPos <> -1) then + begin + Result := ButtonPos; + Inc(ButtonPos) + end + else //Old Method -> Reserve new Memory for every Button + begin + Result := Length(Button); + SetLength(Button, Result + 1); + end; +// Button[Result] := TButton.Create(Texture.GetTexture(Name, Typ)); + + // check here for cache +// Texture.GetTexture(Name, Typ, false); // preloads textures and creates cahce mipmap when needed +// if Covers.CoverExists(Name) then + Button[Result] := TButton.Create(Texture.GetTexture(Name, Typ, true)); // use cache texture +// else +// Button[Result] := TButton.Create(Texture.GetTexture(Name, Typ, false)); // don't use cache texture} + + // configures button + Button[Result].X := X; + Button[Result].Y := Y; + Button[Result].W := W; + Button[Result].H := H; + Button[Result].SelectColR := ColR; + Button[Result].SelectColG := ColG; + Button[Result].SelectColB := ColB; + Button[Result].SelectInt := Int; + Button[Result].DeselectColR := DColR; + Button[Result].DeselectColG := DColG; + Button[Result].DeselectColB := DColB; + Button[Result].DeselectInt := DInt; + Button[Result].Texture.TexX1 := 0; + Button[Result].Texture.TexY1 := 0; + Button[Result].Texture.TexX2 := 1; + Button[Result].Texture.TexY2 := 1; + Button[Result].SetSelect(false); + + Button[Result].Reflection := Reflection; + Button[Result].Reflectionspacing := ReflectionSpacing; + Button[Result].DeSelectReflectionspacing := DeSelectReflectionSpacing; + + //Button Collection Mod + Button[Result].Parent := 0; + + + // adds interaction + AddInteraction(iButton, Result); + Interaction := 0; +end; + +procedure TMenu.ClearButtons; +begin + Setlength(Button, 0); +end; + +// Method to draw our TMenu and all his child buttons +function TMenu.DrawBG: boolean; +var + PetX: integer; + PetY: integer; +begin +// glClearColor(1, 1, 1, 1); +// glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity; + glOrtho(0, RenderW, RenderH, 0, -1, 100); + glMatrixMode(GL_MODELVIEW); + + BackImg.ColR := 1; + BackImg.ColG := 1; + BackImg.ColB := 1; + BackImg.TexX1 := 0; + BackImg.TexY1 := 0; + BackImg.TexX2 := 1; + BackImg.TexY2 := 1; + if (BackImg.TexNum <> -1) then begin + // draw texture with overlapping + for PetY := 1 to BackH do + for PetX := 1 to BackW do begin + BackImg.X := (PetX-1)/BackW * 800; //640 + BackImg.Y := (PetY-1)/BackH * 600; //480 + DrawTexture(BackImg); + end; // for PetX + end; // if +end; + +function TMenu.DrawFG: boolean; +var + J: Integer; +begin + // We don't forget about newly implemented static for nice skin ... + for J := 0 to Length(Static) - 1 do + Static[J].Draw; + + // ... and slightly implemented menutext unit + for J := 0 to Length(Text) - 1 do + Text[J].Draw; + + // Draw all ButtonCollections + For J := 0 to High(ButtonCollection) do + ButtonCollection[J].Draw; + + // Second, we draw all of our buttons + for J := 0 to Length(Button) - 1 do + Button[J].Draw; + + // Third, we draw all of our selects + for J := 0 to Length(Selects) - 1 do + Selects[J].Draw(1); + + for J := 0 to Length(SelectsS) - 1 do + SelectsS[J].Draw; + + // Third, we draw all our widgets +// for J := 0 to Length(WidgetsSrc) - 1 do +// SDL_BlitSurface(WidgetsSrc[J], nil, ParentBackBuf, WidgetsRect[J]); + Result := True; +end; + +function TMenu.Draw: boolean; +begin + DrawBG; + DrawFG; + Result := True; +end; + +{function TMenu.GetNextScreen(): PMenu; +begin + Result := NextScreen; +end;} + +{function TMenu.AddWidget(X, Y : UInt16; WidgetSrc : PSDL_Surface): Int16; +var + WidgetNum : Int16; + +begin + If (Assigned(WidgetSrc)) Then + begin + WidgetNum := Length(WidgetsSrc); + + SetLength(WidgetsSrc, WidgetNum + 1); + SetLength(WidgetsRect, WidgetNum + 1); + + WidgetsSrc[WidgetNum] := WidgetSrc; + WidgetsRect[WidgetNum] := new(PSDL_Rect); + WidgetsRect[WidgetNum]^.x := X; + WidgetsRect[WidgetNum]^.y := Y; + WidgetsRect[WidgetNum]^.w := WidgetSrc^.w; + WidgetsRect[WidgetNum]^.h := WidgetSrc^.h; + + Result := WidgetNum; + end + else + Result := -1; +end;} + +{procedure TMenu.ClearWidgets(MinNumber : Int16); +var + J : Int16; +begin + For J := MinNumber to (Length(WidgetsSrc) - 1) do + begin + SDL_FreeSurface(WidgetsSrc[J]); + dispose(WidgetsRect[J]); + end; + + SetLength(WidgetsSrc, MinNumber); + SetLength(WidgetsRect, MinNumber); +end;} + +function TMenu.IsSelectable(Int: Cardinal): Boolean; +begin + Result := True; + Case Interactions[Int].Typ of + //Button + iButton: Result := Button[Interactions[Int].Num].Visible and Button[Interactions[Int].Num].Selectable; + //Select + iSelect: Result := True; + //Select Slide + iSelectS: Result := SelectsS[Interactions[Int].Num].Visible; + + //ButtonCollection Child + iBCollectionChild: + Result := (ButtonCollection[Button[Interactions[Int].Num].Parent - 1].FirstChild - 1 = Int) AND ((Interactions[Interaction].Typ <> iBCollectionChild) OR (Button[Interactions[Interaction].Num].Parent <> Button[Interactions[Int].Num].Parent)); + end; +end; + +procedure TMenu.InteractNext; +var + Int: Integer; +begin + Int := Interaction; + + // change interaction as long as it's needed + repeat + Int := (Int + 1) Mod Length(Interactions); + + //If no Interaction is Selectable Simply Select Next + if (Int = Interaction) then + begin + Int := (Int + 1) Mod Length(Interactions); + Break; + end; + Until IsSelectable(Int); + + //Set Interaction + Interaction := Int; +end; + + +procedure TMenu.InteractPrev; +var + Int: Integer; +begin + Int := Interaction; + + // change interaction as long as it's needed + repeat + Int := Int - 1; + if Int = -1 then Int := High(Interactions); + + //If no Interaction is Selectable Simply Select Next + if (Int = Interaction) then + begin + Int := SelInteraction - 1; + if Int = -1 then Int := High(Interactions); + Break; + end; + Until IsSelectable(Int); + + //Set Interaction + Interaction := Int +end; + + +procedure TMenu.InteractCustom(CustomSwitch: integer); +var + Num: integer; + Typ: integer; + Again: boolean; +begin + //Code Commented atm, because it needs to be Rewritten + //it doesn't work with Button Collections + {then begin + CustomSwitch:= CustomSwitch*(-1); + Again := true; + // change interaction as long as it's needed + while (Again = true) do begin + Num := SelInteraction - CustomSwitch; + if Num = -1 then Num := High(Interactions); + Interaction := Num; + Again := false; // reset, default to accept changing interaction + + // checking newly interacted element + Num := Interactions[Interaction].Num; + Typ := Interactions[Interaction].Typ; + case Typ of + iButton: + begin + if Button[Num].Selectable = false then Again := True; + end; + end; // case + end; // while + end + else if num>0 then begin + Again := true; + // change interaction as long as it's needed + while (Again = true) do begin + Num := (Interaction + CustomSwitch) Mod Length(Interactions); + Interaction := Num; + Again := false; // reset, default to accept changing interaction + + + // checking newly interacted element + Num := Interactions[Interaction].Num; + Typ := Interactions[Interaction].Typ; + case Typ of + iButton: + begin + if Button[Num].Selectable = false then Again := True; + end; + end; // case + end; // while + end } +end; + + +procedure TMenu.FadeTo(Screen: PMenu); +begin + Display.Fade := 0; + Display.NextScreen := Screen; +end; + +//popup hack +procedure TMenu.CheckFadeTo(Screen: PMenu; msg: String); +begin + Display.Fade := 0; + Display.NextScreenWithCheck := Screen; + Display.CheckOK:=False; + ScreenPopupCheck.ShowPopup(msg); +end; + +procedure TMenu.AddButtonText(AddX, AddY: real; AddText: string); +begin + AddButtonText(AddX, AddY, 1, 1, 1, AddText); +end; + +procedure TMenu.AddButtonText(AddX, AddY: real; ColR, ColG, ColB: real; AddText: string); +var + Il: integer; +begin + with Button[High(Button)] do begin + Il := Length(Text); + SetLength(Text, Il+1); + Text[Il] := TText.Create(X + AddX, Y + AddY, AddText); + Text[Il].ColR := ColR; + Text[Il].ColG := ColG; + Text[Il].ColB := ColB; + Text[Il].Int := 1;//0.5; + end; +end; + +procedure TMenu.AddButtonText(AddX, AddY: real; ColR, ColG, ColB: real; Font: integer; Size: integer; Align: integer; AddText: string); +var + Il: integer; +begin + with Button[High(Button)] do begin + Il := Length(Text); + SetLength(Text, Il+1); + Text[Il] := TText.Create(X + AddX, Y + AddY, AddText); + Text[Il].ColR := ColR; + Text[Il].ColG := ColG; + Text[Il].ColB := ColB; + Text[Il].Int := 1;//0.5; + Text[Il].Style := Font; + Text[Il].Size := Size; + Text[Il].Align := Align; + end; +end; + +procedure TMenu.AddButtonText(CustomButton: TButton; AddX, AddY: real; ColR, ColG, ColB: real; Font: integer; Size: integer; Align: integer; AddText: string); +var + Il: integer; +begin + with CustomButton do begin + Il := Length(Text); + SetLength(Text, Il+1); + Text[Il] := TText.Create(X + AddX, Y + AddY, AddText); + Text[Il].ColR := ColR; + Text[Il].ColG := ColG; + Text[Il].ColB := ColB; + Text[Il].Int := 1;//0.5; + Text[Il].Style := Font; + Text[Il].Size := Size; + Text[Il].Align := Align; + end; +end; + +function TMenu.AddSelect(ThemeSelect: TThemeSelect; var Data: integer; Values: array of string): integer; +var + SO: integer; +begin + Result := AddSelect(ThemeSelect.X, ThemeSelect.Y, ThemeSelect.W, ThemeSelect.H, ThemeSelect.SkipX, + ThemeSelect.ColR, ThemeSelect.ColG, ThemeSelect.ColB, ThemeSelect.Int, + ThemeSelect.DColR, ThemeSelect.DColG, ThemeSelect.DColB, ThemeSelect.DInt, + ThemeSelect.TColR, ThemeSelect.TColG, ThemeSelect.TColB, ThemeSelect.TInt, + ThemeSelect.TDColR, ThemeSelect.TDColG, ThemeSelect.TDColB, ThemeSelect.TDInt, + ThemeSelect.SBGColR, ThemeSelect.SBGColG, ThemeSelect.SBGColB, ThemeSelect.SBGInt, + ThemeSelect.SBGDColR, ThemeSelect.SBGDColG, ThemeSelect.SBGDColB, ThemeSelect.SBGDInt, + ThemeSelect.STColR, ThemeSelect.STColG, ThemeSelect.STColB, ThemeSelect.STInt, + ThemeSelect.STDColR, ThemeSelect.STDColG, ThemeSelect.STDColB, ThemeSelect.STDInt, + Skin.GetTextureFileName(ThemeSelect.Tex), 'Font Black', + Skin.GetTextureFileName(ThemeSelect.TexSBG), 'Font Black', + ThemeSelect.Text, Data); + for SO := 0 to High(Values) do + AddSelectOption(ThemeSelect.X + ThemeSelect.W + ThemeSelect.SkipX + SO * 100 + 20, ThemeSelect.Y + 20, Values[SO]); +end; + +function TMenu.AddSelect(X, Y, W, H, SkipX, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt, + TColR, TColG, TColB, TInt, TDColR, TDColG, TDColB, TDInt, + SBGColR, SBGColG, SBGColB, SBGInt, SBGDColR, SBGDColG, SBGDColB, SBGDInt, + STColR, STColG, STColB, STInt, STDColR, STDColG, STDColB, STDInt: real; + Name, Typ: String; SBGName, SBGTyp: String; + Caption: string; var Data: integer): integer; +var + S: integer; +begin + S := Length(Selects); + SetLength(Selects, S + 1); + Selects[S] := TSelect.Create; + + Selects[S].Texture := Texture.GetTexture(Name, Typ); + Selects[S].X := X; + Selects[S].Y := Y; + Selects[S].W := W; + Selects[S].H := H; + Selects[S].ColR := ColR; + Selects[S].ColG := ColG; + Selects[S].ColB := ColB; + Selects[S].Int := Int; + Selects[S].DColR := DColR; + Selects[S].DColG := DColG; + Selects[S].DColB := DColB; + Selects[S].DInt := DInt; + + Selects[S].TextureSBG := Texture.GetTexture(SBGName, SBGTyp); + Selects[S].TextureSBG.X := X + W + SkipX; + Selects[S].TextureSBG.Y := Y; + Selects[S].TextureSBG.W := 450; + Selects[S].TextureSBG.H := H; + Selects[S].SBGColR := SBGColR; + Selects[S].SBGColG := SBGColG; + Selects[S].SBGColB := SBGColB; + Selects[S].SBGInt := SBGInt; + Selects[S].SBGDColR := SBGDColR; + Selects[S].SBGDColG := SBGDColG; + Selects[S].SBGDColB := SBGDColB; + Selects[S].SBGDInt := SBGDInt; + + Selects[S].Text.X := X + 20; + Selects[S].Text.Y := Y + 20; + Selects[S].Text.Text := Caption; + Selects[S].Text.Size := 10; + Selects[S].Text.Visible := true; + Selects[S].TColR := TColR; + Selects[S].TColG := TColG; + Selects[S].TColB := TColB; + Selects[S].TInt := TInt; + Selects[S].TDColR := TDColR; + Selects[S].TDColG := TDColG; + Selects[S].TDColB := TDColB; + Selects[S].TDInt := TDInt; + + Selects[S].STColR := STColR; + Selects[S].STColG := STColG; + Selects[S].STColB := STColB; + Selects[S].STInt := STInt; + Selects[S].STDColR := STDColR; + Selects[S].STDColG := STDColG; + Selects[S].STDColB := STDColB; + Selects[S].STDInt := STDInt; + + // new + Selects[S].Texture.TexX1 := 0; + Selects[S].Texture.TexY1 := 0; + Selects[S].Texture.TexX2 := 1; + Selects[S].Texture.TexY2 := 1; + Selects[S].TextureSBG.TexX1 := 0; + Selects[S].TextureSBG.TexY1 := 0; + Selects[S].TextureSBG.TexX2 := 1; + Selects[S].TextureSBG.TexY2 := 1; + + // Sets Data to copy the value of selectops to global value; + Selects[S].PData := @Data; + + // Sets default value of selectopt from Data; + Selects[S].SelectedOption := Data; + + // Disables default selection + Selects[S].SetSelect(false); + + // adds interaction + AddInteraction(iSelect, S); +end; + +procedure TMenu.AddSelectOption(AddX, AddY: real; AddText: string); +begin + AddSelectOption (High(Selects), AddX, AddY, AddText); +end; + +procedure TMenu.AddSelectOption(SelectNo: Cardinal; AddX, AddY: real; AddText: string); +var + SO: integer; +begin + SO := Length(Selects[SelectNo].TextOpt); + SetLength(Selects[SelectNo].TextOpt, SO + 1); + + Selects[SelectNo].TextOpt[SO] := TText.Create; + + Selects[SelectNo].TextOpt[SO].X := AddX; + Selects[SelectNo].TextOpt[SO].Y := AddY; + Selects[SelectNo].TextOpt[SO].Text := AddText; + Selects[SelectNo].TextOpt[SO].Size := 10; + Selects[SelectNo].TextOpt[SO].ColR := Selects[SelectNo].STDColR; + Selects[SelectNo].TextOpt[SO].ColG := Selects[SelectNo].STDColG; + Selects[SelectNo].TextOpt[SO].ColB := Selects[SelectNo].STDColB; + Selects[SelectNo].TextOpt[SO].Int := Selects[SelectNo].STDInt; + Selects[SelectNo].TextOpt[SO].Visible := true; + + if SO = Selects[SelectNo].PData^ then Selects[SelectNo].SelectedOption := SO; +end; + +procedure TMenu.UpdateSelectOptions(ThemeSelect: TThemeSelect; SelectNum: integer; Values: array of string; var Data: integer); +var + SO: integer; +begin + SetLength(Selects[SelectNum].TextOpt, 0); + for SO := 0 to High(Values) do + AddSelectOption(SelectNum, ThemeSelect.X + ThemeSelect.W + ThemeSelect.SkipX + SO * 100 + 20, ThemeSelect.Y + 20, Values[SO]); +end; + +function TMenu.AddSelectSlide(ThemeSelectS: TThemeSelectSlide; var Data: integer; Values: array of string): integer; +var + SO: integer; +begin + Result := AddSelectSlide(ThemeSelectS.X, ThemeSelectS.Y, ThemeSelectS.W, ThemeSelectS.H, ThemeSelectS.SkipX, ThemeSelectS.SBGW, + ThemeSelectS.ColR, ThemeSelectS.ColG, ThemeSelectS.ColB, ThemeSelectS.Int, + ThemeSelectS.DColR, ThemeSelectS.DColG, ThemeSelectS.DColB, ThemeSelectS.DInt, + ThemeSelectS.TColR, ThemeSelectS.TColG, ThemeSelectS.TColB, ThemeSelectS.TInt, + ThemeSelectS.TDColR, ThemeSelectS.TDColG, ThemeSelectS.TDColB, ThemeSelectS.TDInt, + ThemeSelectS.SBGColR, ThemeSelectS.SBGColG, ThemeSelectS.SBGColB, ThemeSelectS.SBGInt, + ThemeSelectS.SBGDColR, ThemeSelectS.SBGDColG, ThemeSelectS.SBGDColB, ThemeSelectS.SBGDInt, + ThemeSelectS.STColR, ThemeSelectS.STColG, ThemeSelectS.STColB, ThemeSelectS.STInt, + ThemeSelectS.STDColR, ThemeSelectS.STDColG, ThemeSelectS.STDColB, ThemeSelectS.STDInt, + Skin.GetTextureFileName(ThemeSelectS.Tex), 'Font Black', + Skin.GetTextureFileName(ThemeSelectS.TexSBG), 'Font Black', + ThemeSelectS.Text, Data); + for SO := 0 to High(Values) do + AddSelectSlideOption(Values[SO]); + + SelectsS[High(SelectsS)].Text.Size := ThemeSelectS.TextSize; + + SelectsS[High(SelectsS)].Texture.Z := ThemeSelectS.Z; + SelectsS[High(SelectsS)].TextureSBG.Z := ThemeSelectS.Z; + + //Generate Lines + SelectsS[High(SelectsS)].GenLines; + + SelectsS[High(SelectsS)].SelectedOption := SelectsS[High(SelectsS)].SelectOptInt; // refresh +end; + +function TMenu.AddSelectSlide(X, Y, W, H, SkipX, SBGW, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt, + TColR, TColG, TColB, TInt, TDColR, TDColG, TDColB, TDInt, + SBGColR, SBGColG, SBGColB, SBGInt, SBGDColR, SBGDColG, SBGDColB, SBGDInt, + STColR, STColG, STColB, STInt, STDColR, STDColG, STDColB, STDInt: real; + Name, Typ: String; SBGName, SBGTyp: String; + Caption: string; var Data: integer): integer; +var + S: integer; + I: integer; +begin + S := Length(SelectsS); + SetLength(SelectsS, S + 1); + SelectsS[S] := TSelectSlide.Create; + + SelectsS[S].Texture := Texture.GetTexture(Name, Typ); + SelectsS[S].X := X; + SelectsS[S].Y := Y; + SelectsS[S].W := W; + SelectsS[S].H := H; + + SelectsS[S].ColR := ColR; + SelectsS[S].ColG := ColG; + SelectsS[S].ColB := ColB; + SelectsS[S].Int := Int; + SelectsS[S].DColR := DColR; + SelectsS[S].DColG := DColG; + SelectsS[S].DColB := DColB; + SelectsS[S].DInt := DInt; + + SelectsS[S].TextureSBG := Texture.GetTexture(SBGName, SBGTyp); + SelectsS[S].TextureSBG.X := X + W + SkipX; + SelectsS[S].TextureSBG.Y := Y; + //SelectsS[S].TextureSBG.W := 450; + SelectsS[S].SBGW := SBGW; + SelectsS[S].TextureSBG.H := H; + SelectsS[S].SBGColR := SBGColR; + SelectsS[S].SBGColG := SBGColG; + SelectsS[S].SBGColB := SBGColB; + SelectsS[S].SBGInt := SBGInt; + SelectsS[S].SBGDColR := SBGDColR; + SelectsS[S].SBGDColG := SBGDColG; + SelectsS[S].SBGDColB := SBGDColB; + SelectsS[S].SBGDInt := SBGDInt; + + SelectsS[S].Text.X := X + 20; + SelectsS[S].Text.Y := Y + (SelectsS[S].TextureSBG.H / 2) - 15; + SelectsS[S].Text.Text := Caption; + SelectsS[S].Text.Size := 10; + SelectsS[S].Text.Visible := true; + SelectsS[S].TColR := TColR; + SelectsS[S].TColG := TColG; + SelectsS[S].TColB := TColB; + SelectsS[S].TInt := TInt; + SelectsS[S].TDColR := TDColR; + SelectsS[S].TDColG := TDColG; + SelectsS[S].TDColB := TDColB; + SelectsS[S].TDInt := TDInt; + + SelectsS[S].STColR := STColR; + SelectsS[S].STColG := STColG; + SelectsS[S].STColB := STColB; + SelectsS[S].STInt := STInt; + SelectsS[S].STDColR := STDColR; + SelectsS[S].STDColG := STDColG; + SelectsS[S].STDColB := STDColB; + SelectsS[S].STDInt := STDInt; + + // new + SelectsS[S].Texture.TexX1 := 0; + SelectsS[S].Texture.TexY1 := 0; + SelectsS[S].Texture.TexX2 := 1; + SelectsS[S].Texture.TexY2 := 1; + SelectsS[S].TextureSBG.TexX1 := 0; + SelectsS[S].TextureSBG.TexY1 := 0; + SelectsS[S].TextureSBG.TexX2 := 1; + SelectsS[S].TextureSBG.TexY2 := 1; + + // Sets Data to copy the value of selectops to global value; + SelectsS[S].PData := @Data; + // Configures Select options + {//SelectsS[S].TextOpt[0].Text := IntToStr(I+1); + SelectsS[S].TextOpt[0].Size := 10; + SelectsS[S].TextOpt[0].Align := 1; + + SelectsS[S].TextOpt[0].ColR := SelectsS[S].STDColR; + SelectsS[S].TextOpt[0].ColG := SelectsS[S].STDColG; + SelectsS[S].TextOpt[0].ColB := SelectsS[S].STDColB; + SelectsS[S].TextOpt[0].Int := SelectsS[S].STDInt; + SelectsS[S].TextOpt[0].Visible := true; } + + // Sets default value of selectopt from Data; + SelectsS[S].SelectedOption := Data; + + // Disables default selection + SelectsS[S].SetSelect(false); + + {// Configures 3 select options + for I := 0 to 2 do begin + SelectsS[S].TextOpt[I].X := SelectsS[S].TextureSBG.X + 20 + (50 + 20) + (150 - 20) * I; + SelectsS[S].TextOpt[I].Y := SelectsS[S].TextureSBG.Y + 20; + SelectsS[S].TextOpt[I].Text := IntToStr(I+1); + SelectsS[S].TextOpt[I].Size := 10; + SelectsS[S].TextOpt[I].Align := 1; + + + SelectsS[S].TextOpt[I].ColR := SelectsS[S].STDColR; + SelectsS[S].TextOpt[I].ColG := SelectsS[S].STDColG; + SelectsS[S].TextOpt[I].ColB := SelectsS[S].STDColB; + SelectsS[S].TextOpt[I].Int := SelectsS[S].STDInt; + SelectsS[S].TextOpt[I].Visible := true; + end;} + + + // adds interaction + AddInteraction(iSelectS, S); + Result := S; +end; + +procedure TMenu.AddSelectSlideOption(AddText: string); +begin + AddSelectSlideOption(High(SelectsS), AddText); +end; + +procedure TMenu.AddSelectSlideOption(SelectNo: Cardinal; AddText: string); +var + SO: integer; +begin + SO := Length(SelectsS[SelectNo].TextOptT); + + SetLength(SelectsS[SelectNo].TextOptT, SO + 1); + SelectsS[SelectNo].TextOptT[SO] := AddText; + + //SelectsS[S].SelectedOption := SelectsS[S].SelectOptInt; // refresh + + //if SO = Selects[S].PData^ then Selects[S].SelectedOption := SO; +end; + +procedure TMenu.UpdateSelectSlideOptions(ThemeSelectSlide: TThemeSelectSlide; SelectNum: integer; Values: array of string; var Data: integer); +var + SO: integer; +begin + SetLength(SelectsS[SelectNum].TextOptT, 0); + for SO := 0 to High(Values) do + AddSelectSlideOption(SelectNum, Values[SO]); + + SelectsS[SelectNum].GenLines; + +// SelectsS[SelectNum].SelectedOption := SelectsS[SelectNum].SelectOptInt; // refresh +// SelectS[SelectNum].SetSelectOpt(Data); +// SelectS[SelectNum].SelectedOption := 0;//Data; + +// Log.LogError(IntToStr(High(SelectsS[SelectNum].TextOptT))); +// if 0 <= High(SelectsS[SelectNum].TextOptT) then + + SelectsS[SelectNum].PData := @Data; + SelectsS[SelectNum].SelectedOption := Data; +end; + +function TMenu.InRegion(X1, Y1, X2, Y2, X, Y: real): Boolean; +begin + Result := false; + X1 := X1 * RenderW/640; + X2 := X2 * RenderW/640; + Y1 := Y1 * RenderH/480; + Y2 := Y2 * RenderH/480; + if (X >= X1) and (X <= X2) and (Y >= Y1) and (Y <= Y2) then + Result := true; +end; + +function TMenu.InStaticRegion(StaticNr: integer; X, Y: integer): Boolean; +begin + Result := InRegion(Static[StaticNr].Texture.X, + Static[StaticNr].Texture.Y, + Static[StaticNr].Texture.X + Static[StaticNr].Texture.W - 1, + Static[StaticNr].Texture.Y + Static[StaticNr].Texture.H - 1, + X, Y); +end; + +procedure TMenu.InteractInc; +var + Num: integer; + Value: integer; +begin + case Interactions[Interaction].Typ of + iSelect: begin + Num := Interactions[Interaction].Num; + Value := Selects[Num].SelectedOption; + Value := (Value + 1) Mod (Length(Selects[Num].TextOpt)); + Selects[Num].SelectedOption := Value; + end; + iSelectS: begin + Num := Interactions[Interaction].Num; + Value := SelectsS[Num].SelectedOption; +// Value := (Value + 1) Mod (Length(SelectsS[Num].TextOptT)); + + // limit + Value := Value + 1; + if Value <= High(SelectsS[Num].TextOptT) then + SelectsS[Num].SelectedOption := Value; + end; + //Button Collection Mod + iBCollectionChild: + begin + + //Select Next Button in Collection + For Num := 1 to High(Button) do + begin + Value := (Interaction + Num) Mod Length(Button); + if Value = 0 then + begin + InteractNext; + Break; + end; + if (Button[Value].Parent = Button[Interaction].Parent) then + begin + Interaction := Value; + Break; + end; + end; + end; + //interact Next if there is Nothing to Change + else InteractNext; + end; +end; + +procedure TMenu.InteractDec; +var + Num: integer; + Value: integer; +begin + case Interactions[Interaction].Typ of + iSelect: begin + Num := Interactions[Interaction].Num; + Value := Selects[Num].SelectedOption; + Value := Value - 1; + if Value = -1 then + Value := High(Selects[Num].TextOpt); + Selects[Num].SelectedOption := Value; + end; + iSelectS: begin + Num := Interactions[Interaction].Num; + Value := SelectsS[Num].SelectedOption; + Value := Value - 1; +// if Value = -1 then +// Value := High(SelectsS[Num].TextOptT); + + if Value >= 0 then + SelectsS[Num].SelectedOption := Value; + end; + //Button Collection Mod + iBCollectionChild: + begin + //Select Prev Button in Collection + For Num := High(Button) downto 1 do + begin + Value := (Interaction + Num) Mod Length(Button); + if Value = High(Button) then + begin + InteractPrev; + Break; + end; + if (Button[Value].Parent = Button[Interaction].Parent) then + begin + Interaction := Value; + Break; + end; + end; + end; + //interact Prev if there is Nothing to Change + else + begin + InteractPrev; + //If ButtonCollection with more than 1 Entry then Select Last Entry + if (Button[Interactions[Interaction].Num].Parent <> 0) AND (ButtonCollection[Button[Interactions[Interaction].Num].Parent-1].CountChilds > 1) then + begin + //Select Last Child + For Num := High(Button) downto 1 do + begin + Value := (Interaction + Num) Mod Length(Button); + if (Button[Value].Parent = Button[Interaction].Parent) then + begin + Interaction := Value; + Break; + end; + end; + end; + end; + end; +end; + +procedure TMenu.AddBox(X, Y, W, H: real); +begin + AddStatic(X, Y, W, H, 0, 0, 0, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black'); + AddStatic(X+2, Y+2, W-4, H-4, 1, 1, 1, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black'); +end; + +procedure TMenu.onShow; +begin +// nothing +// beep; +end; + +procedure TMenu.onShowFinish; +begin +// nothing +// beep; +end; + +procedure TMenu.onHide; +begin +// nothing +// beep; +end; + +function TMenu.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin +// nothing +// Beep; + Result := true; +end; + +procedure TMenu.SetAnimationProgress(Progress: real); +begin +// nothing +//beep; +end; + +end. + diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas new file mode 100644 index 00000000..919a18c9 --- /dev/null +++ b/Game/Code/Menu/UMenuButton.pas @@ -0,0 +1,488 @@ +unit UMenuButton; + +interface +uses TextGL, UTexture, OpenGL12, UMenuText; + +type + CButton = class of TButton; + TButton = class + protected + SelectBool: Boolean; + + FadeProgress: Real; + FadeLastTick: Cardinal; + + DeSelectW: Real; + DeSelectH: Real; + PosX: Real; + PosY: Real; + + constructor Create(); overload; + + public + Text: Array of TText; + Texture: TTexture; // Button Screen position and size + Texture2: TTexture; // second texture only used for fading full resolution covers + + FadeTex: TTexture; //Texture for beautiful fading + FadeTexPos: byte; //Pos of the FadeTexture (0: Top, 1: Left, 2: Bottom, 3: Right) +// Texture2Blend: real; // blending factor for second texture (0=invisible, 1=visible) + // now uses alpha + + DeselectType: integer; // not used yet + Visible: boolean; + //Reflection Mod + Reflection: boolean; + Reflectionspacing: Real; + DeSelectReflectionspacing: Real; + + //Fade Mod + Fade: Boolean; + FadeText: Boolean; + + Selectable: boolean; + + //No of the Parent Collection, 0 if in no Collection + Parent: Byte; + + SelectColR: real; + SelectColG: real; + SelectColB: real; + SelectInt: real; + SelectTInt: real; + //Fade Mod + SelectW: real; + SelectH: real; + + DeselectColR: real; + DeselectColG: real; + DeselectColB: real; + DeselectInt: real; + DeselectTInt: real; + + procedure SetY(Value: real); + procedure SetX(Value: real); + procedure SetW(Value: real); + procedure SetH(Value: real); + + procedure SetSelect(Value: Boolean); virtual; + property X: real read PosX write SetX; + property Y: real read PosY write SetY; + property Z: real read Texture.z write Texture.z; + property W: real read DeSelectW write SetW; + property H: real read DeSelectH write SetH; + property Selected: Boolean read SelectBool write SetSelect; + + procedure Draw; virtual; + + constructor Create(Textura: TTexture); overload; + destructor Destroy; override; + end; + +implementation +uses UDrawTexture, SysUtils, windows; + +procedure TButton.SetX(Value: real); +var + dx: real; + T: integer; // text +begin + {dY := Value - Texture.y; + + Texture.X := Value; + + for T := 0 to High(Text) do + Text[T].X := Text[T].X + dY;} + + PosX := Value; + if (FadeTex.TexNum = -1) then + Texture.X := Value; + +end; + +procedure TButton.SetY(Value: real); +var + dY: real; + T: integer; // text +begin + {dY := Value - PosY; + + + for T := 0 to High(Text) do + Text[T].Y := Text[T].Y + dY;} + + PosY := Value; + if (FadeTex.TexNum = -1) then + Texture.y := Value; +end; + +procedure TButton.SetW(Value: real); +begin + if SelectW = DeSelectW then + SelectW := Value; + + DeSelectW := Value; + + if Not Fade then + begin + if SelectBool then + Texture.W := SelectW + else + Texture.W := DeSelectW; + end; +end; + +procedure TButton.SetH(Value: real); +begin + if SelectH = DeSelectH then + SelectH := Value; + + DeSelectH := Value; + + if Not Fade then + begin + if SelectBool then + Texture.H := SelectH + else + Texture.H := DeSelectH; + end; +end; + +procedure TButton.SetSelect(Value : Boolean); +var + T: integer; +begin + SelectBool := Value; + if (Value) then begin + Texture.ColR := SelectColR; + Texture.ColG := SelectColG; + Texture.ColB := SelectColB; + Texture.Int := SelectInt; + + Texture2.ColR := SelectColR; + Texture2.ColG := SelectColG; + Texture2.ColB := SelectColB; + Texture2.Int := SelectInt; + + for T := 0 to High(Text) do + Text[T].Int := SelectTInt; + + //Fade Mod + if Fade then + begin + if (FadeProgress <= 0) then + FadeProgress := 0.125; + end + else + begin + Texture.W := SelectW; + Texture.H := SelectH; + end; + end else begin + Texture.ColR := DeselectColR; + Texture.ColG := DeselectColG; + Texture.ColB := DeselectColB; + Texture.Int := DeselectInt; + + Texture2.ColR := DeselectColR; + Texture2.ColG := DeselectColG; + Texture2.ColB := DeselectColB; + Texture2.Int := DeselectInt; + + for T := 0 to High(Text) do + Text[T].Int := DeselectTInt; + + //Fade Mod + if Fade then + begin + if (FadeProgress >= 1) then + FadeProgress := 0.875; + end + else + begin + Texture.W := DeSelectW; + Texture.H := DeSelectH; + end; + end; +end; + +constructor TButton.Create(); +begin + inherited Create; + // We initialize all to 0, nil or false + Visible := true; + SelectBool := false; + DeselectType := 0; + Selectable := true; + //Reflection Mod + Reflection := true; + + // Default +// SelectInt := 1; +// DeselectInt := 0.5; + +{ SelectColR := 0.5; + SelectColG := 0.75; + SelectColB := 0; + SelectInt := 1; + SelectTInt := 1; + + DeselectColR := 1; + DeselectColG := 1; + DeselectColB := 1; + DeselectInt := 0.5; + DeselectTInt := 1;} + + SelectColR := 1; + SelectColG := 1; + SelectColB := 1; + SelectInt := 1; + SelectTInt := 1; + + DeselectColR := 1; + DeselectColG := 1; + DeselectColB := 1; + DeselectInt := 0.5; + DeselectTInt := 1; + + FadeTex.TexNum := -1; + + FadeProgress := 0; + Fade := False; + FadeText := False; + SelectW := DeSelectW; + SelectH := DeSelectH; + + PosX := 0; + PosY := 0; + + Parent := 0; +end; + +// ***** Public methods ****** // + +procedure TButton.Draw; +var + T: integer; + Tick: Cardinal; + Spacing: Real; +begin + if Visible then begin + //Fade Mod + if Fade then + begin + if (FadeProgress < 1) and (FadeProgress > 0) then + begin + Tick := GetTickCount div 16; + if (Tick <> FadeLastTick) then + begin + FadeLastTick := Tick; + if SelectBool then + FadeProgress := FadeProgress + 0.125 + else + FadeProgress := FadeProgress - 0.125; + + if (FadeText) then + begin + For T := 0 to high(Text) do + begin + Text[T].MoveX := (SelectW - DeSelectW) * FadeProgress; + Text[T].MoveY := (SelectH - DeSelectH) * FadeProgress; + end; + end; + end; + end; + //Method without Fade Texture + if (FadeTex.TexNum = -1) then + begin + Texture.W := DeSelectW + (SelectW - DeSelectW) * FadeProgress; + Texture.H := DeSelectH + (SelectH - DeSelectH) * FadeProgress; + end + else //method with Fade Texture + begin + Texture.W := DeSelectW; + Texture.H := DeSelectH; + + FadeTex.ColR := Texture.ColR; + FadeTex.ColG := Texture.ColG; + FadeTex.ColB := Texture.ColB; + FadeTex.Int := Texture.Int; + + FadeTex.Z := Texture.Z; + + FadeTex.Alpha := Texture.Alpha; + FadeTex.TexX1 := 0; + FadeTex.TexX2 := 1; + FadeTex.TexY1 := 0; + FadeTex.TexY2 := 1; + + Case FadeTexPos of + 0: //FadeTex on Top + begin + //Standard Texture + Texture.X := PosX; + Texture.Y := PosY + (SelectH - DeSelectH) * FadeProgress; + //Fade Tex + FadeTex.X := PosX; + FadeTex.Y := PosY; + FadeTex.W := Texture.W; + FadeTex.H := (SelectH - DeSelectH) * FadeProgress; + FadeTex.ScaleW := Texture.ScaleW; + //Some Hack that Fixes a little Space between both Textures + FadeTex.TexY2 := 0.9; + end; + 1: //FadeTex on Left + begin + //Standard Texture + Texture.X := PosX + (SelectW - DeSelectW) * FadeProgress; + Texture.Y := PosY; + //Fade Tex + FadeTex.X := PosX; + FadeTex.Y := PosY; + FadeTex.H := Texture.H; + FadeTex.W := (SelectW - DeSelectW) * FadeProgress; + FadeTex.ScaleH := Texture.ScaleH; + //Some Hack that Fixes a little Space between both Textures + FadeTex.TexX2 := 0.9; + end; + 2: //FadeTex on Bottom + begin + //Standard Texture + Texture.X := PosX; + Texture.Y := PosY; + //Fade Tex + FadeTex.X := PosX; + FadeTex.Y := PosY + (SelectH - DeSelectH) * FadeProgress;; + FadeTex.W := Texture.W; + FadeTex.H := (SelectH - DeSelectH) * FadeProgress; + FadeTex.ScaleW := Texture.ScaleW; + //Some Hack that Fixes a little Space between both Textures + FadeTex.TexY1 := 0.1; + end; + 3: //FadeTex on Right + begin + //Standard Texture + Texture.X := PosX; + Texture.Y := PosY; + //Fade Tex + FadeTex.X := PosX + (SelectW - DeSelectW) * FadeProgress; + FadeTex.Y := PosY; + FadeTex.H := Texture.H; + FadeTex.W := (SelectW - DeSelectW) * FadeProgress; + FadeTex.ScaleH := Texture.ScaleH; + //Some Hack that Fixes a little Space between both Textures + FadeTex.TexX1 := 0.1; + end; + end; + end; + end + else if (FadeText) then + begin + Text[T].MoveX := (SelectW - DeSelectW); + Text[T].MoveY := (SelectH - DeSelectH); + end; + + DrawTexture(Texture); + + //Draw FadeTex + if (FadeTex.TexNum <> -1) then + DrawTexture(FadeTex); + + if Texture2.Alpha > 0 then begin + Texture2.ScaleW := Texture.ScaleW; + Texture2.ScaleH := Texture.ScaleH; + + Texture2.X := Texture.X; + Texture2.Y := Texture.Y; + Texture2.W := Texture.W; + Texture2.H := Texture.H; + + Texture2.ColR := Texture.ColR; + Texture2.ColG := Texture.ColG; + Texture2.ColB := Texture.ColB; + Texture2.Int := Texture.Int; + + Texture2.Z := Texture.Z; + + DrawTexture(Texture2); + end; + + //Reflection Mod + if (Reflection) then // Draw Reflections + begin + if (FadeProgress <> 0) AND (FadeProgress <> 1) then + begin + Spacing := DeSelectReflectionspacing - (DeSelectReflectionspacing - Reflectionspacing) * FadeProgress; + end + else if SelectBool then + Spacing := Reflectionspacing + else + Spacing := DeSelectReflectionspacing; + + with Texture do + begin + //Bind Tex and GL Attributes + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + glDepthRange(0, 10); + glDepthFunc(GL_LEQUAL); + glEnable(GL_DEPTH_TEST); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, TexNum); + + //Draw + glBegin(GL_QUADS);//Top Left + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); + glTexCoord2f(TexX1*TexW, TexY2*TexH); + glVertex3f(x, y+h*scaleH+ Spacing, z); + + //Bottom Left + glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); + glTexCoord2f(TexX1*TexW, TexY1+TexH*0.5); + glVertex3f(x, y+h*scaleH + h*scaleH/2 + Spacing, z); + + + //Bottom Right + glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); + glTexCoord2f(TexX2*TexW, TexY1+TexH*0.5); + glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Spacing, z); + + //Top Right + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); + glTexCoord2f(TexX2*TexW, TexY2*TexH); + glVertex3f(x+w*scaleW, y+h*scaleH + Spacing, z); + glEnd; + + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + end; + end; + + for T := 0 to High(Text) do begin + Text[T].Draw; + end; + end; +end; + +// ***** ****** // + +destructor TButton.Destroy; +begin + inherited; +end; + +constructor TButton.Create(Textura: TTexture); +begin + Create(); + Texture := Textura; + Texture.ColR := 0; + Texture.ColG := 0.5; + Texture.ColB := 0; + Texture.Int := 1; +end; + + +end. diff --git a/Game/Code/Menu/UMenuButtonCollection.pas b/Game/Code/Menu/UMenuButtonCollection.pas new file mode 100644 index 00000000..5c9045a7 --- /dev/null +++ b/Game/Code/Menu/UMenuButtonCollection.pas @@ -0,0 +1,68 @@ +unit UMenuButtonCollection; + +interface +uses UMenuButton; + +type + //---------------- + //TButtonCollection + //No Extra Attributes or Functions ATM + //---------------- + AButton = Array of TButton; + PAButton = ^AButton; + TButtonCollection = class(TButton) + //num of the First Button, that can be Selected + FirstChild: Byte; + CountChilds: Byte; + + ScreenButton: PAButton; + + procedure SetSelect(Value : Boolean); override; + procedure Draw; override; + end; + +implementation + +procedure TButtonCollection.SetSelect(Value : Boolean); +var I: Integer; +begin + inherited; + + //Set Visible for Every Button that is a Child of this ButtonCollection + if (Not Fade) then + For I := 0 to High(ScreenButton^) do + if (ScreenButton^[I].Parent = Parent) then + ScreenButton^[I].Visible := Value; +end; + +procedure TButtonCollection.Draw; +var I, J: Integer; +begin + inherited; + //If fading is activated, Fade Child Buttons + if (Fade) then + begin + For I := 0 to High(ScreenButton^) do + if (ScreenButton^[I].Parent = Parent) then + begin + if (FadeProgress < 0.5) then + begin + ScreenButton^[I].Visible := SelectBool; + + For J := 0 to High(ScreenButton^[I].Text) do + ScreenButton^[I].Text[J].Visible := SelectBool; + end + else + begin + ScreenButton^[I].Texture.Alpha := (FadeProgress-0.666)*3; + + For J := 0 to High(ScreenButton^[I].Text) do + ScreenButton^[I].Text[J].Alpha := (FadeProgress-0.666)*3; + end; + end; + end; +end; + + + +end. diff --git a/Game/Code/Menu/UMenuInteract.pas b/Game/Code/Menu/UMenuInteract.pas new file mode 100644 index 00000000..43249e3e --- /dev/null +++ b/Game/Code/Menu/UMenuInteract.pas @@ -0,0 +1,14 @@ +unit UMenuInteract; + +interface + +type + TInteract = record // for moving thru menu + Typ: integer; // 0 - button, 1 - select, 2 - Text, 3 - Select SLide, 5 - ButtonCollection Child + Num: integer; // number of this item in proper list like buttons, selects + end; + +implementation + +end. + \ No newline at end of file diff --git a/Game/Code/Menu/UMenuSelect.pas b/Game/Code/Menu/UMenuSelect.pas new file mode 100644 index 00000000..f7bb871f --- /dev/null +++ b/Game/Code/Menu/UMenuSelect.pas @@ -0,0 +1,198 @@ +unit UMenuSelect; + +interface +uses TextGL, UTexture, OpenGL12, UMenuText; + +type + PSelect = ^TSelect; + TSelect = class + private + SelectBool: boolean; + public + // objects + Text: TText; // Main Text + TextOpt: array of TText; // Options Text + Texture: TTexture; // Select Texture + TextureSBG: TTexture; // Background Selections Texture + TextureS: array of TTexture; // Selections Texture + SelectOptInt: integer; + PData: ^integer; + + // for selection and deselection + // main static + ColR: real; + ColG: real; + ColB: real; + Int: real; + DColR: real; + DColG: real; + DColB: real; + DInt: real; + + // main text + TColR: real; + TColG: real; + TColB: real; + TInt: real; + TDColR: real; + TDColG: real; + TDColB: real; + TDInt: real; + + // selection background static + SBGColR: real; + SBGColG: real; + SBGColB: real; + SBGInt: real; + SBGDColR: real; + SBGDColG: real; + SBGDColB: real; + SBGDInt: real; + + // selection statics + SColR: real; + SColG: real; + SColB: real; + SInt: real; + SDColR: real; + SDColG: real; + SDColB: real; + SDInt: real; + + // selection text + STColR: real; + STColG: real; + STColB: real; + STInt: real; + STDColR: real; + STDColG: real; + STDColB: real; + STDInt: real; + + // position and size + property X: real read Texture.x write Texture.x; + property Y: real read Texture.y write Texture.y; + property W: real read Texture.w write Texture.w; + property H: real read Texture.h write Texture.h; +// property X2: real read Texture2.x write Texture2.x; +// property Y2: real read Texture2.y write Texture2.y; +// property W2: real read Texture2.w write Texture2.w; +// property H2: real read Texture2.h write Texture2.h; + + // procedures + procedure SetSelect(Value: boolean); + property Selected: Boolean read SelectBool write SetSelect; + procedure SetSelectOpt(Value: integer); + property SelectedOption: integer read SelectOptInt write SetSelectOpt; + procedure Draw(ButtonAlpha: real); + constructor Create; + end; + +implementation +uses UDrawTexture; + +// ------------ Select +constructor TSelect.Create; +begin + inherited Create; + Text := TText.Create; +end; + +procedure TSelect.SetSelect(Value: boolean); +var + SO: integer; +begin // default 1, 0.4 + SelectBool := Value; + if Value then begin + Texture.ColR := ColR; + Texture.ColG := ColG; + Texture.ColB := ColB; + Texture.Int := Int; + + Text.ColR := TColR; + Text.ColG := TColG; + Text.ColB := TColB; + Text.Int := TInt; + + TextureSBG.ColR := SBGColR; + TextureSBG.ColG := SBGColG; + TextureSBG.ColB := SBGColB; + TextureSBG.Int := SBGInt; + +{ for SO := 0 to High(TextOpt) do begin + if SelectOptInt = SO then begin + TextOpt[SO].ColR := STColR; + TextOpt[SO].ColG := STColG; + TextOpt[SO].ColB := STColB; + TextOpt[SO].Int := STInt; + end else begin + TextOpt[SO].ColR := STDColR; + TextOpt[SO].ColG := STDColG; + TextOpt[SO].ColB := STDColB; + TextOpt[SO].Int := STDInt; + end; + end;} + + end else begin + Texture.ColR := DColR; + Texture.ColG := DColG; + Texture.ColB := DColB; + Texture.Int := DInt; + + Text.ColR := TDColR; + Text.ColG := TDColG; + Text.ColB := TDColB; + Text.Int := TDInt; + + TextureSBG.ColR := SBGDColR; + TextureSBG.ColG := SBGDColG; + TextureSBG.ColB := SBGDColB; + TextureSBG.Int := SBGDInt; + +{ for SO := 0 to High(TextOpt) do begin + TextOpt[SO].ColR := STDColR; + TextOpt[SO].ColG := STDColG; + TextOpt[SO].ColB := STDColB; + TextOpt[SO].Int := STDInt; + end;} + end; +end; + +procedure TSelect.SetSelectOpt(Value: integer); +var + SO: integer; +begin + SelectOptInt := Value; + PData^ := Value; +// SetSelect(true); // reset all colors + + for SO := 0 to High(TextOpt) do begin + if SelectOptInt = SO then begin + TextOpt[SO].ColR := STColR; + TextOpt[SO].ColG := STColG; + TextOpt[SO].ColB := STColB; + TextOpt[SO].Int := STInt; + end else begin + TextOpt[SO].ColR := STDColR; + TextOpt[SO].ColG := STDColG; + TextOpt[SO].ColB := STDColB; + TextOpt[SO].Int := STDInt; + end; + end; +end; + +procedure TSelect.Draw(ButtonAlpha: real); +var + SO: integer; +begin + DrawTexture(Texture); + DrawTexture(TextureSBG); + + Text.Draw; + + for SO := 0 to High(TextOpt) do begin + TextOpt[SO].Draw; + end; +end; + +end. diff --git a/Game/Code/Menu/UMenuSelectSlide.pas b/Game/Code/Menu/UMenuSelectSlide.pas new file mode 100644 index 00000000..c1ccad6d --- /dev/null +++ b/Game/Code/Menu/UMenuSelectSlide.pas @@ -0,0 +1,345 @@ +unit UMenuSelectSlide; + +interface +uses TextGL, UTexture, OpenGL12, UMenuText; + +type + PSelectSlide = ^TSelectSlide; + TSelectSlide = class + private + SelectBool: boolean; + public + // objects + Text: TText; // Main text describing option + TextOpt: array of TText; // 3 texts in the position of possible options + TextOptT: array of string; // array of names for possible options + + Texture: TTexture; // Select Texture + TextureSBG: TTexture; // Background Selections Texture +// TextureS: array of TTexture; // Selections Texture (not used) + +// TextureArrowL: TTexture; // Texture for left arrow (not used yet) +// TextureArrowR: TTexture; // Texture for right arrow (not used yet) + + SelectOptInt: integer; + PData: ^integer; + + //For automatically Setting LineCount + Lines: Byte; + + //Visibility + Visible: Boolean; + + // for selection and deselection + // main static + ColR: real; + ColG: real; + ColB: real; + Int: real; + DColR: real; + DColG: real; + DColB: real; + DInt: real; + + // main text + TColR: real; + TColG: real; + TColB: real; + TInt: real; + TDColR: real; + TDColG: real; + TDColB: real; + TDInt: real; + + // selection background static + SBGColR: real; + SBGColG: real; + SBGColB: real; + SBGInt: real; + SBGDColR: real; + SBGDColG: real; + SBGDColB: real; + SBGDInt: real; + + // selection text + STColR: real; + STColG: real; + STColB: real; + STInt: real; + STDColR: real; + STDColG: real; + STDColB: real; + STDInt: real; + + // position and size + property X: real read Texture.x write Texture.x; + property Y: real read Texture.y write Texture.y; + property W: real read Texture.w write Texture.w; + property H: real read Texture.h write Texture.h; +// property X2: real read Texture2.x write Texture2.x; +// property Y2: real read Texture2.y write Texture2.y; +// property W2: real read Texture2.w write Texture2.w; +// property H2: real read Texture2.h write Texture2.h; + + property SBGW: real read TextureSBG.w write TextureSBG.w; + + // procedures + procedure SetSelect(Value: boolean); + property Selected: Boolean read SelectBool write SetSelect; + procedure SetSelectOpt(Value: integer); + property SelectedOption: integer read SelectOptInt write SetSelectOpt; + procedure Draw; + constructor Create; + + //Automatically Generate Lines (Texts) + procedure genLines; + end; + +implementation +uses UDrawTexture, math, ULog, SysUtils; + +// ------------ Select +constructor TSelectSlide.Create; +begin + inherited Create; + Text := TText.Create; + SetLength(TextOpt, 1); + TextOpt[0] := TText.Create; + + //Set Standard Width for Selections Background + SBGW := 450; + + Visible := True; + {SetLength(TextOpt, 3); + TextOpt[0] := TText.Create; + TextOpt[1] := TText.Create; + TextOpt[2] := TText.Create;} +end; + +procedure TSelectSlide.SetSelect(Value: boolean); +var + SO: integer; + I: integer; +begin + SelectBool := Value; + if Value then begin + Texture.ColR := ColR; + Texture.ColG := ColG; + Texture.ColB := ColB; + Texture.Int := Int; + + Text.ColR := TColR; + Text.ColG := TColG; + Text.ColB := TColB; + Text.Int := TInt; + + TextureSBG.ColR := SBGColR; + TextureSBG.ColG := SBGColG; + TextureSBG.ColB := SBGColB; + TextureSBG.Int := SBGInt; + +{ for I := 0 to High(TextOpt) do begin + TextOpt[I].ColR := STColR; + TextOpt[I].ColG := STColG; + TextOpt[I].ColB := STColB; + TextOpt[I].Int := STInt; + end;} + + end else begin + Texture.ColR := DColR; + Texture.ColG := DColG; + Texture.ColB := DColB; + Texture.Int := DInt; + + Text.ColR := TDColR; + Text.ColG := TDColG; + Text.ColB := TDColB; + Text.Int := TDInt; + + TextureSBG.ColR := SBGDColR; + TextureSBG.ColG := SBGDColG; + TextureSBG.ColB := SBGDColB; + TextureSBG.Int := SBGDInt; + +{ for I := 0 to High(TextOpt) do begin + TextOpt[I].ColR := STDColR; + TextOpt[I].ColG := STDColG; + TextOpt[I].ColB := STDColB; + TextOpt[I].Int := STDInt; + end;} + end; +end; + +procedure TSelectSlide.SetSelectOpt(Value: integer); +var + SO: integer; + Sel: integer; + HalfL: integer; + HalfR: integer; + +procedure DoSelection(Sel: Cardinal); + var I: Integer; + begin + for I := low(TextOpt) to high(TextOpt) do + begin + TextOpt[I].ColR := STDColR; + TextOpt[I].ColG := STDColG; + TextOpt[I].ColB := STDColB; + TextOpt[I].Int := STDInt; + end; + if (Sel <= high(TextOpt)) then + begin + TextOpt[Sel].ColR := STColR; + TextOpt[Sel].ColG := STColG; + TextOpt[Sel].ColB := STColB; + TextOpt[Sel].Int := STInt; + end; + end; +begin + SelectOptInt := Value; + PData^ := Value; +// SetSelect(true); // reset all colors + + if (Length(TextOpt)>0) AND (Length(TextOptT)>0) then + begin + + if (Value <= 0) then + begin //First Option Selected + Value := 0; + + for SO := low (TextOpt) to high(TextOpt) do + begin + TextOpt[SO].Text := TextOptT[SO]; + end; + + DoSelection(0); + end + else if (Value >= high(TextOptT)) then + begin //Last Option Selected + Value := high(TextOptT); + + for SO := high(TextOpt) downto low (TextOpt) do + begin + TextOpt[SO].Text := TextOptT[high(TextOptT)-(Lines-SO-1)]; + end; + DoSelection(Lines-1); + end + else + begin + HalfL := Ceil((Lines-1)/2); + HalfR := Lines-1-HalfL; + + if (Value <= HalfL) then + begin //Selected Option is near to the left side + {HalfL := Value; + HalfR := Lines-1-HalfL;} + //Change Texts + for SO := low (TextOpt) to high(TextOpt) do + begin + TextOpt[SO].Text := TextOptT[SO]; + end; + + DoSelection(Value); + end + else if (Value > High(TextOptT)-HalfR) then + begin //Selected is too near to the right border + HalfR := high(TextOptT) - Value; + HalfL := Lines-1-HalfR; + //Change Texts + for SO := high(TextOpt) downto low (TextOpt) do + begin + TextOpt[SO].Text := TextOptT[high(TextOptT)-(Lines-SO-1)]; + end; + + DoSelection (HalfL); + end + else + begin + //Change Texts + for SO := low (TextOpt) to high(TextOpt) do + begin + TextOpt[SO].Text := TextOptT[Value - HalfL + SO]; + end; + + DoSelection(HalfL); + end; + + end; + + end; + +end; + +procedure TSelectSlide.Draw; +var + SO: integer; +begin + if Visible then + begin + DrawTexture(Texture); + DrawTexture(TextureSBG); + + Text.Draw; + + for SO := low(TextOpt) to high(TextOpt) do + TextOpt[SO].Draw; + end; +end; + +procedure TSelectSlide.GenLines; +var +maxlength: Real; +I: Integer; +begin + SetFontStyle(0{Text.Style}); + SetFontSize(Text.Size); + maxlength := 0; + + for I := low(TextOptT) to high (TextOptT) do + begin + if (glTextWidth(PChar(TextOptT[I])) > maxlength) then + maxlength := glTextWidth(PChar(TextOptT[I])); + end; + + Lines := floor((TextureSBG.W-40) / (maxlength+7)); + if (Lines > Length(TextOptT)) then + Lines := Length(TextOptT); + + if (Lines <= 0) then + Lines := 1; + + //Free old Space used by Texts + For I := low(TextOpt) to high(TextOpt) do + TextOpt[I].Free; + + setLength (TextOpt, Lines); + + for I := low(TextOpt) to high(TextOpt) do + begin + TextOpt[I] := TText.Create; + TextOpt[I].Size := Text.Size; + //TextOpt[I].Align := 1; + TextOpt[I].Align := 0; + TextOpt[I].Visible := True; + + TextOpt[I].ColR := STDColR; + TextOpt[I].ColG := STDColG; + TextOpt[I].ColB := STDColB; + TextOpt[I].Int := STDInt; + + //Generate Positions + //TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W / Lines) * (I + 0.5); + if (I <> High(TextOpt)) OR (High(TextOpt) = 0) OR (Length(TextOptT) = Lines) then + TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W / Lines) * I + else + TextOpt[I].X := TextureSBG.X + TextureSBG.W - maxlength; + + TextOpt[I].Y := TextureSBG.Y + (TextureSBG.H / 2) - 1.5 * Text.Size{20}; + + //Better Look with 2 Options + if (Lines=2) AND (Length(TextOptT)= 2) then + TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W -40 - glTextWidth(PChar(TextOptT[1]))) * I; + end; +end; + +end. diff --git a/Game/Code/Menu/UMenuStatic.pas b/Game/Code/Menu/UMenuStatic.pas new file mode 100644 index 00000000..5f19fbf3 --- /dev/null +++ b/Game/Code/Menu/UMenuStatic.pas @@ -0,0 +1,84 @@ +unit UMenuStatic; + +interface +uses UTexture, OpenGL12; + +type + TStatic = class + public + Texture: TTexture; // Button Screen position and size + Visible: boolean; + + //Reflection Mod + Reflection: boolean; + Reflectionspacing: Real; + + procedure Draw; + constructor Create(Textura: TTexture); overload; + end; + +implementation +uses UDrawTexture; + +procedure TStatic.Draw; +var + Pet: integer; +begin + if Visible then + begin + DrawTexture(Texture); + + //Reflection Mod + if (Reflection) then // Draw Reflections + begin + with Texture do + begin + //Bind Tex and GL Attributes + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + glDepthRange(0, 10); + glDepthFunc(GL_LEQUAL); + glEnable(GL_DEPTH_TEST); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, TexNum); + + //Draw + glBegin(GL_QUADS);//Top Left + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); + glTexCoord2f(TexX1*TexW, TexY2*TexH); + glVertex3f(x, y+h*scaleH+ Reflectionspacing, z); + + //Bottom Left + glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); + glTexCoord2f(TexX1*TexW, 0.5*TexH+TexY1); + glVertex3f(x, y+h*scaleH + h*scaleH/2 + Reflectionspacing, z); + + + //Bottom Right + glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); + glTexCoord2f(TexX2*TexW, 0.5*TexH+TexY1); + glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Reflectionspacing, z); + + //Top Right + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); + glTexCoord2f(TexX2*TexW, TexY2*TexH); + glVertex3f(x+w*scaleW, y+h*scaleH + Reflectionspacing, z); + glEnd; + + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + end; + end; + end; +end; + +constructor TStatic.Create(Textura: TTexture); +begin + inherited Create; + Texture := Textura; +end; + +end. diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas new file mode 100644 index 00000000..4713962e --- /dev/null +++ b/Game/Code/Menu/UMenuText.pas @@ -0,0 +1,324 @@ +unit UMenuText; + +interface +uses TextGL, UTexture, OpenGL12, SysUtils; + +type + TText = class + private + SelectBool: boolean; + TextString: String; + TextTiles: Array of String; + + STicks: Cardinal; + SelectBlink: Boolean; + public + X: real; + Y: real; + MoveX: real; //Some Modifier for X - Position that don't Affect the Real Y + MoveY: real; //Some Modifier for Y - Position that don't Affect the Real Y + W: real; // if text is wider than W then it is breaked +// H: real; + Size: real; + ColR: real; + ColG: real; + ColB: real; + Alpha: real; + Int: real; + Style: integer; + Visible: boolean; + Align: integer; // 0 = left, 1 = center, 2 = right + + procedure SetSelect(Value: Boolean); + property Selected: Boolean read SelectBool write SetSelect; + + procedure SetText(Value: String); + property Text: String read TextString write SetText; + + procedure DeleteLastL; //Procedure to Delete Last Letter + + procedure Draw; + constructor Create; overload; + constructor Create(X, Y: real; Tekst: string); overload; + constructor Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string); overload; + end; + +implementation +uses UGraphic, StrUtils, Windows; + +procedure TText.SetSelect(Value: Boolean); +begin + SelectBool := Value; + + //Set Cursor Visible + SelectBlink := True; + STicks := GettickCount div 550; +end; + +procedure TText.SetText(Value: String); +var + NextPos: Cardinal; //NextPos of a Space etc. + LastPos: Cardinal; //LastPos " + LastBreak: Cardinal; //Last Break + isBreak: Boolean; //True if the Break is not Caused because the Text is out of the area + FirstWord: Word; //Is First Word after Break? + Len: Word; //Length of the Tiles Array + Function Smallest(const A, B: Cardinal):Cardinal; + begin + if (A < B) then + Result := A + else + Result := B; + end; + + Function GetNextPos: Boolean; + var + T1, T2, T3: Cardinal; + begin + LastPos := NextPos; + + //Next Space (If Width is given) + if (W > 0) then + T1 := PosEx(' ', Value, LastPos + 1) + else T1 := Length(Value); + + {//Next - + T2 := PosEx('-', Value, LastPos + 1);} + + //Next Break + T3 := PosEx('\n', Value, LastPos + 1); + + if T1 = 0 then + T1 := Length(Value); + {if T2 = 0 then + T2 := Length(Value); } + if T3 = 0 then + T3 := Length(Value); + + //Get Nearest Pos + NextPos := Smallest(T1, T3{Smallest(T2, T3)}); + + if (LastPos = Length(Value)) then + NextPos := 0; + + isBreak := (NextPos = T3) AND (NextPos <> Length(Value)); + Result := (NextPos <> 0); + end; + procedure AddBreak(const From, bTo: Cardinal); + begin + if (isBreak) OR (bTo - From >= 1) then + begin + Inc(Len); + SetLength (TextTiles, Len); + TextTiles[Len-1] := Trim(Copy(Value, From, bTo - From)); + + if isBreak then + LastBreak := bTo + 2 + else + LastBreak := bTo + 1; + FirstWord := 0; + end; + end; +begin + //Set TExtstring + TextString := Value; + + //Set Cursor Visible + SelectBlink := True; + STicks := GettickCount div 550; + + //Exit if there is no Need to Create Tiles + If (W <= 0) and (Pos('\n', Value) = 0) then + begin + SetLength (TextTiles, 1); + TextTiles[0] := Value; + Exit; + end; + + //Create Tiles + //Reset Text Array + SetLength (TextTiles, 0); + Len := 0; + + //Reset Counter Vars + LastPos := 1; + NextPos := 1; + LastBreak := 1; + FirstWord := 1; + + + if (W > 0) then + begin + //Set Font Propertys + SetFontStyle(Style); + SetFontSize(Size); + end; + + //go Through Text + While (GetNextPos) do + begin + //Break in Text + if isBreak then + begin + //Look for Break before the Break + if (glTextWidth(PChar(Copy(Value, LastBreak, NextPos - LastBreak + 1))) > W) AND (NextPos-LastPos > 1) then + begin + isBreak := False; + //Not the First word after Break, so we don't have to break within a word + if (FirstWord > 1) then + begin + //Add Break before actual Position, because there the Text fits the Area + AddBreak(LastBreak, LastPos); + end + else //First Word after Break Break within the Word + begin + //ToDo + //AddBreak(LastBreak, LastBreak + 155); + end; + end; + + isBreak := True; + //Add Break from Text + AddBreak(LastBreak, NextPos); + end + //Text comes out of the Text Area -> CreateBreak + else if (glTextWidth(PChar(Copy(Value, LastBreak, NextPos - LastBreak + 1))) > W) then + begin + //Not the First word after Break, so we don't have to break within a word + if (FirstWord > 1) then + begin + //Add Break before actual Position, because there the Text fits the Area + AddBreak(LastBreak, LastPos); + end + else //First Word after Break -> Break within the Word + begin + //ToDo + //AddBreak(LastBreak, LastBreak + 155); + end; + end; + //end; + Inc(FirstWord) + end; + //Add Ending + AddBreak(LastBreak, Length(Value)+1); +end; + +Procedure TText.DeleteLastL; +var + S: String; + L: Integer; +begin + S := TextString; + L := Length(S); + if (L > 0) then + SetLength(S, L-1); + + SetText(S); +end; + +procedure TText.Draw; +var + X2, Y2: real; + Text2: string; + I: Integer; +begin + if Visible then begin + SetFontStyle(Style); + SetFontSize(Size); + SetFontItalic(False); + glColor4f(ColR*Int, ColG*Int, ColB*Int, Alpha); + + //If Selected Set Blink... + if SelectBool then + begin + I := Gettickcount div 550; + if I <> STicks then + begin //Change Visability + STicks := I; + SelectBlink := Not SelectBlink; + end; + end; + + {if (False) then //No Width set Draw as one Long String + begin + if not (SelectBool AND SelectBlink) then + Text2 := Text + else + Text2 := Text + '|'; + + case Align of + 0: X2 := X; + 1: X2 := X - glTextWidth(pchar(Text2))/2; + 2: X2 := X - glTextWidth(pchar(Text2)); + end; + + SetFontPos(X2, Y); + glPrint(PChar(Text2)); + SetFontStyle(0); // reset to default + end + else + begin} + //Now Use allways: + //Draw Text as Many Strings + Y2 := Y + MoveY; + for I := 0 to high(TextTiles) do + begin + if (not (SelectBool AND SelectBlink)) OR (I <> high(TextTiles)) then + Text2 := TextTiles[I] + else + Text2 := TextTiles[I] + '|'; + + case Align of + 0: X2 := X + MoveX; + 1: X2 := X + MoveX - glTextWidth(pchar(Text2))/2; + 2: X2 := X + MoveX - glTextWidth(pchar(Text2)); + end; + + SetFontPos(X2, Y2); + glPrint(PChar(Text2)); + + {if Size >= 10 then + Y2 := Y2 + Size * 2.8 + else} + if (Style = 1) then + Y2 := Y2 + Size * 2.8 + else + Y2 := Y2 + Size * 2.15; + end; + SetFontStyle(0); // reset to default + + //end; + end; +end; + +constructor TText.Create; +begin + Create(0, 0, ''); +end; + +constructor TText.Create(X, Y: real; Tekst: string); +begin + Create(X, Y, 0, 0, 10, 0, 0, 0, 0, Tekst); +end; + +constructor TText.Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string); +begin + inherited Create; + Alpha := 1; + X := ParX; + Y := ParY; + W := ParW; + Style := ParStyle; + Size := ParSize; + Text := ParTekst; + ColR := ParColR; + ColG := ParColG; + ColB := ParColB; + Int := 1; + Align := ParAlign; + SelectBool := false; + Visible := true; +end; + + +end. diff --git a/Game/Code/SMpeg/USmpeg.pas b/Game/Code/SMpeg/USmpeg.pas new file mode 100644 index 00000000..40ae8694 --- /dev/null +++ b/Game/Code/SMpeg/USmpeg.pas @@ -0,0 +1,305 @@ +unit USmpeg; + +interface +uses SDL, + smpeg, + OpenGL12, + SysUtils, + UIni; + +procedure OpenSmpeg(FileName: string); +procedure SkipSmpeg(Time: single); +procedure PlaySmpeg; +procedure PauseSmpeg; //PauseMod +procedure UpdateSmpeg; +procedure CloseSmpeg; +function glmovie_init(Width : GLuint; Height : TGLuint ) : TGLenum; +procedure glmpeg_update(surface: PSDL_Surface; x: Sint32; y: Sint32; w: Uint32; h: Uint32); cdecl; +procedure DrawSmpeg(frame: PGLubyte); +procedure glmovie_resize( width : GLuint; height : GLuint ); +procedure glmovie_quit; + +var + mpeg: PSMPEG; + mpeg_info: TSMPEG_Info; + surface: PSDL_Surface; + +type + { Some data is redundant at this stage. } + PGLMovieTexture = ^TGLMovieTexture; + TGLMovieTexture = record + id : TGLuint; (* OpenGL texture id. *) + poly_width : TGLuint; (* Quad width for tile. *) + poly_height : TGLuint; (* Quad height for tile. *) + movie_width : TGLuint; (* Width of movie inside tile. *) + movie_height : TGLuint; (* Height of movie inside tile. *) + skip_rows : TGLuint; (* Number of rows of movie to skip *) + skip_pixels : TGLuint; (* Number of columns of movie to skip *) + row : TGLuint; (* Row number of tile in scheme. *) + col : TGLuint; (* Column number of tile in scheme. *) + end; + +type + TGLuintArray = array of TGLuint; + PGLuintArray = ^TGLuintArray; + TGLMovieTextureArray = array of TGLMovieTexture; + PGLMovieTextureArray = ^TGLMovieTextureArray; + +var + (* Our evil maximum texture size. Boo 3Dfxnot *) + texture_size : TGLuint = 1024;//512; + texture_ids : TGLuint; + textures: TGLMovieTexture; + tiled_width : TGLuint = 0; + tiled_height : TGLuint = 0; + movie_width : TGLuint = 0; + movie_height : TGLuint = 0; + +implementation + +procedure OpenSmpeg(FileName: string); +begin + mpeg := SMPEG_new(PChar(FileName), @mpeg_info, 0); // audio + if ( mpeg = nil ) then begin + SDL_Quit; + Exit; + end; + +// SMPEG_setvolume(mpeg, 50); + SMPEG_enableaudio(mpeg, 0); + + (* Everything needs to be in RGB for GL, but needs to be 32-bit for SMPEG. *) + surface := SDL_AllocSurface( SDL_SWSURFACE, + mpeg_info.width, + mpeg_info.height, + 32, + $000000FF, + $0000FF00, + $00FF0000, + $FF000000 ); + + if ( surface = nil ) then begin + SDL_Quit; + Exit; + end; + + (* *Initialize* with mpeg size. *) + if (glmovie_init( mpeg_info.width, mpeg_info.height ) <> GL_NO_ERROR ) then begin + SDL_Quit; + Exit; + end; + + SMPEG_setdisplay(mpeg, surface, nil, @glmpeg_update); +end; + +procedure SkipSmpeg(Time: single); +begin + SMPEG_skip(mpeg, Time); +end; + +procedure PlaySmpeg; +begin + SMPEG_play(mpeg); +end; + +//Pause Mod +procedure PauseSmpeg; +begin + SMPEG_pause(mpeg); +end; + +procedure UpdateSmpeg; +begin +// glmpeg_update(surface,0,0,0,0); + DrawSmpeg( PGLubyte( surface.pixels ) ); +end; + +procedure CloseSmpeg; +begin + SMPEG_delete(mpeg); + //Fixing the Memory Lag in earlyer Versions (X-Mas Mod, all Official Versions) + glmovie_quit; +end; + +function glmovie_init( Width : GLuint; Height : TGLuint ) : TGLenum; +type + PGLubyteArray = ^TGLubyteArray; + TGLubyteArray = array of TGLubyte; +var + (* Initial black texels. *) + pixels : TGLubyteArray; + (* Absolute offsets from within tiled frame. *) + //offset_x: GLuint; + //offset_y: GLuint; + skip_rows : GLuint; + skip_pixels : GLuint; + i, j, current : GLuint; +begin + skip_rows := 0; + current := 0; + (* Save original movie dimensions. *) + movie_width := width; + movie_height := height; + + (* Get the power of 2 dimensions. *) + tiled_width := 1024{512}; + tiled_height := 1024{512}; + + texture_size := 1024{512}; + + (* Time for fun with data type = record *) + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glEnable(GL_TEXTURE_2D); + glEnable(GL_DITHER); + + glGenTextures(1, @texture_ids); + + current := 0; + (* Setup texture. *) + textures.id := texture_ids; + textures.poly_width := texture_size; + textures.poly_height := texture_size; + textures.movie_width := movie_width - 2; + textures.movie_height := movie_height - 2; + textures.row := i; + textures.col := j; + textures.skip_pixels := skip_pixels; + textures.skip_rows := skip_rows; + + SetLength( pixels, textures.poly_width * textures.poly_height * 4 ); + if ( pixels = nil ) then + begin + glDeleteTextures(1, @texture_ids); + result := GL_OUT_OF_MEMORY; + exit; + end; + //FillChar( pixels^, textures[ current ].poly_width * textures[ current ].poly_height * 4, 0 ); + + (* Do all of our useful binding. *) + glBindTexture(GL_TEXTURE_2D, texture_ids); +// glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + (* Specify our 256x256 black texture. *) + glTexImage2D( GL_TEXTURE_2D, + 0, + GL_RGB, + 1024{512},//textures.poly_width, + 1024{512},//textures.poly_height, + 0, + GL_RGBA, + GL_UNSIGNED_BYTE, + @pixels[0] ); + SetLength( pixels, 0 ); + + + (* Simple state setup at the end. *) + result := glGetError( ); +end; + +procedure glmpeg_update( surface : PSDL_Surface; x : Sint32; y : Sint32; w : Uint32; + h : Uint32 ); cdecl; +var + error : TGLenum; +begin + glClear( GL_COLOR_BUFFER_BIT ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity; + DrawSmpeg( PGLubyte( surface.pixels ) ); + error := glGetError( ); + if ( error <> GL_NO_ERROR ) then Exit; + SDL_GL_SwapBuffers; +end; + +procedure DrawSmpeg(frame: PGLubyte); +var + Shift: TGLdouble; + CropT: real; + CropB: real; + TexT: real; + TexB: real; + TexL: real; + TexR: real; + Wide: boolean; +begin + (* full screen mpeg *) +{ CropT := 0; + CropB := 600; + TexT := 0; + TexB := 1; + TexL := 0; + TexW := 1;} + + // set movie texture crop + Wide := false; + if (textures.movie_width = 720-2) and (textures.movie_height = 344-2) then begin + TexT := 0; + TexB := 342/1024; + Wide := true; + end; + if textures.movie_height = 304-2 then begin + TexT := 0; + TexB := 304/1024; + Wide := true; + end; + if textures.movie_height = 152-2 then begin + TexT := 0; + TexB := 152/1024; + Wide := true; + end; + + CropT := 110; // (110/800 = 13,75% max crop) + CropB := 490; // (110/800 = 13,75% max crop) + + if (textures.movie_height <> 304-2) and (textures.movie_height <> 152-2) and (textures.movie_height <> 344-2) then begin + TexT := 110 / 600 * (textures.movie_height / 1024{512}); + TexB := 490 / 600 * (textures.movie_height / 1024{512}); + + if Ini.MovieSize >= 1 then begin + // full screen size + CropT := 0; + CropB := 600; + TexT := 0; + TexB := textures.movie_height / 1024{512}; + end; + end; + + TexL := {10}0/600 * (textures.movie_width / 1024{512}); + TexR := {590}600/600 * (textures.movie_width / 1024{512}); + + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + glColor3f(1, 1, 1); + glBindTexture( GL_TEXTURE_2D, texture_ids ); +// glPixelStorei( GL_UNPACK_ROW_LENGTH, movie_width ); + glPixelStorei( GL_UNPACK_SKIP_ROWS, 0); + glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0); + glTexSubImage2D( GL_TEXTURE_2D, 0, 0, (* offset_x *) 0, (* offset_y *) textures.movie_width + 2, textures.movie_height + 2, GL_RGBA, GL_UNSIGNED_BYTE, frame ); + + // draw + glBegin( GL_QUADS ); + glTexCoord2f(TexL, TexT); glVertex2f(0, CropT); + glTexCoord2f(TexL, TexB); glVertex2f(0, CropB); + glTexCoord2f(TexR, TexB); glVertex2f(800, CropB); + glTexCoord2f(TexR, TexT); glVertex2f(800, CropT); + glEnd; + glDisable(GL_TEXTURE_2D); +end; + +procedure glmovie_resize( width : GLuint; height : GLuint ); +begin + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity; + gluOrtho2D(0, 800, 600, 0); +end; + +procedure glmovie_quit; +begin + glDeleteTextures(1, @texture_ids); + SDL_FreeSurface(surface); +end; + +end. diff --git a/Game/Code/Screens/UScreenCredits.pas b/Game/Code/Screens/UScreenCredits.pas new file mode 100644 index 00000000..5e0530af --- /dev/null +++ b/Game/Code/Screens/UScreenCredits.pas @@ -0,0 +1,1088 @@ +unit UScreenCredits; + +interface + +uses + UMenu, SDL, UDisplay, UTexture, OpenGL12, UMusic, UFiles, SysUtils, UThemes, ULCD, ULight, UGraphicClasses; + +type + TCreditsStages=(InitialDelay,Intro,MainPart,Outro); + + TScreenCredits = class(TMenu) + public + + Credits_X: Real; + Credits_Time: Cardinal; + Credits_Alpha: Cardinal; + CTime: Cardinal; + CTime_hold: Cardinal; + ESC_Alpha: Integer; + + credits_entry_tex: TTexture; + credits_entry_dx_tex: TTexture; + credits_bg_tex: TTexture; + credits_bg_ovl: TTexture; +// credits_bg_logo: TTexture; + credits_bg_scrollbox_left: TTexture; + credits_blindguard: TTexture; + credits_blindy: TTexture; + credits_canni: TTexture; + credits_commandio: TTexture; + credits_lazyjoker: TTexture; + credits_mog: TTexture; + credits_mota: TTexture; + credits_skillmaster: TTexture; + credits_whiteshark: TTexture; + intro_layer01: TTexture; + intro_layer02: TTexture; + intro_layer03: TTexture; + intro_layer04: TTexture; + intro_layer05: TTexture; + intro_layer06: TTexture; + intro_layer07: TTexture; + intro_layer08: TTexture; + intro_layer09: TTexture; + outro_bg: TTexture; + outro_esc: TTexture; + outro_exd: TTexture; + + deluxe_slidein: cardinal; + + CurrentScrollText: String; + NextScrollUpdate: Real; + EndofLastScrollingPart: Cardinal; + CurrentScrollStart, CurrentScrollEnd: Integer; + + CRDTS_Stage: TCreditsStages; + + Fadeout: boolean; + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function Draw: boolean; override; + procedure onShow; override; + procedure onHide; override; + procedure DrawCredits; + procedure Draw_FunkyText; + end; + +const + Funky_Text: AnsiString = + 'Grandma Deluxe has arrived! Thanks to Corvus5 for the massive work on UltraStar, Wome for the nice tune youīre hearing, '+ + 'all the people who put massive effort and work in new songs (donīt forget UltraStar w/o songs would be nothing), ppl from '+ + 'irc helping us - eBandit and Gabari, scene ppl who really helped instead of compiling and running away. Thank for the translations to Jakob0 and Spearedge (Swedish), Pino (Dutch) and Canni (French). Greetings to DennisTheMenace for betatesting, '+ + 'Demoscene.tv, KakiArts, Sourceforge,..'; + + + Timings: array[0..21] of Cardinal=( + 20, // 0 Delay vor Start + + 149, // 1 Ende erster Intro Zoom + 155, // 2 Start 2. Action im Intro + 170, // 3 Ende Separation im Intro + 271, // 4 Anfang Zoomout im Intro + 0, // 5 unused + 261, // 6 Start fade-to-white im Intro + + 271, // 7 Start Main Part + 280, // 8 Start On-Beat-Sternchen Main Part + + 396, // 9 Start BlindGuard + 666, // 10 Start blindy + 936, // 11 Start Canni + 1206, // 12 Start Commandio + 1476, // 13 Start LazyJoker + 1746, // 14 Start Mog + 2016, // 15 Start Mota + 2286, // 16 Start SkillMaster + 2556, // 17 Start WhiteShark + 2826, // 18 Ende Whiteshark + 3096, // 19 Start FadeOut Mainscreen + 3366, // 20 Ende Credits Tune + 60); // 21 start flare im intro + +implementation + +uses Dialogs,Windows, UGraphic, UMain, UIni, USongs, Textgl, opengl, ULanguage, Math; + +function TScreenCredits.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + FadeTo(@ScreenMain); + Music.PlayBack; + end; +{ SDLK_SPACE: + begin + setlength(CTime_hold,length(CTime_hold)+1); + CTime_hold[high(CTime_hold)]:=CTime; + end; +} + end;//esac + end; //fi +end; + +constructor TScreenCredits.Create; +begin + inherited Create; + credits_bg_tex := Texture.LoadTexture(true, 'CRDTS_BG', 'PNG', 'Plain', 0); + credits_bg_ovl := Texture.LoadTexture(true, 'CRDTS_OVL', 'PNG', 'Transparent', 0); + + credits_blindguard := Texture.LoadTexture(true, 'CRDTS_blindguard', 'PNG', 'Font Black', 0); + credits_blindy := Texture.LoadTexture(true, 'CRDTS_blindy', 'PNG', 'Font Black', 0); + credits_canni := Texture.LoadTexture(true, 'CRDTS_canni', 'PNG', 'Font Black', 0); + credits_commandio := Texture.LoadTexture(true, 'CRDTS_commandio', 'PNG', 'Font Black', 0); + credits_lazyjoker := Texture.LoadTexture(true, 'CRDTS_lazyjoker', 'PNG', 'Font Black', 0); + credits_mog := Texture.LoadTexture(true, 'CRDTS_mog', 'PNG', 'Font Black', 0); + credits_mota := Texture.LoadTexture(true, 'CRDTS_mota', 'PNG', 'Font Black', 0); + credits_skillmaster := Texture.LoadTexture(true, 'CRDTS_skillmaster', 'PNG', 'Font Black', 0); + credits_whiteshark := Texture.LoadTexture(true, 'CRDTS_whiteshark', 'PNG', 'Font Black', 0); + + intro_layer01 := Texture.LoadTexture(true, 'INTRO_L01', 'PNG', 'Transparent', 0); + intro_layer02 := Texture.LoadTexture(true, 'INTRO_L02', 'PNG', 'Transparent', 0); + intro_layer03 := Texture.LoadTexture(true, 'INTRO_L03', 'PNG', 'Transparent', 0); + intro_layer04 := Texture.LoadTexture(true, 'INTRO_L04', 'PNG', 'Transparent', 0); + intro_layer05 := Texture.LoadTexture(true, 'INTRO_L05', 'PNG', 'Transparent', 0); + intro_layer06 := Texture.LoadTexture(true, 'INTRO_L06', 'PNG', 'Transparent', 0); + intro_layer07 := Texture.LoadTexture(true, 'INTRO_L07', 'PNG', 'Transparent', 0); + intro_layer08 := Texture.LoadTexture(true, 'INTRO_L08', 'PNG', 'Transparent', 0); + intro_layer09 := Texture.LoadTexture(true, 'INTRO_L09', 'PNG', 'Transparent', 0); + + outro_bg := Texture.LoadTexture(true, 'OUTRO_BG', 'PNG', 'Plain', 0); + outro_esc := Texture.LoadTexture(true, 'OUTRO_ESC', 'PNG', 'Transparent', 0); + outro_exd := Texture.LoadTexture(true, 'OUTRO_EXD', 'PNG', 'Plain', 0); + + CRDTS_Stage:=InitialDelay; +end; + +function TScreenCredits.Draw: boolean; +begin + DrawCredits; +end; + +procedure TScreenCredits.onShow; +begin + CRDTS_Stage:=InitialDelay; + Credits_X := 580; + deluxe_slidein := 0; + Credits_Alpha := 0; + Music.Open(soundpath + 'wome-credits-tune.mp3'); //danke kleinster liebster weeeetüüüüü!! + Music.SetVolume(100); //Whiteshark, you hear me now? :P + CTime:=0; +// setlength(CTime_hold,0); +end; + +procedure TScreenCredits.onHide; +begin + Music.Stop; +end; + +Procedure TScreenCredits.Draw_FunkyText; +var + S,I, Len: Integer; + X,Y,A: Real; + visibleText: PChar; +begin + SetFontSize(10); + //Init ScrollingText + if (CTime = Timings[7]) then + begin + //Set Position of Text + Credits_X := 600; + CurrentScrollStart:=1; + CurrentScrollEnd:=1; + end; + + if (CTime > Timings[7]) and (CurrentScrollStart < length(Funky_Text)) then + begin + X:=0; + visibleText:=pchar(Copy(Funky_Text, CurrentScrollStart, CurrentScrollEnd)); + for S := 0 to length(visibleText)-1 do begin + Y:=abs(sin((Credits_X+X)*0.93{*(((Credits_X+X))/1200)}/100*pi)); + SetFontPos(Credits_X+X,538-Y*(Credits_X+X)*(Credits_X+X)*(Credits_X+X)/1000000); + if (Credits_X+X < 15) then A:=0; + if (Credits_X+X >=15) then A:=Credits_X+X-15; + if Credits_X+X > 32 then A:=17; + glColor4f( 230/255-40/255+Y*(Credits_X+X)/900, 200/255-30/255+Y*(Credits_X+X)/1000, 155/255-20/255+Y*(Credits_X+X)/1100, A/17); + glPrintLetter(visibleText[S]); + X := X + Fonts[ActFont].Width[Ord(visibleText[S])] * Fonts[ActFont].Tex.H / 30 * Fonts[ActFont].AspectW; + end; + if (Credits_X<0) and (CurrentScrollStart < length(Funky_Text)) then begin + Credits_X:=Credits_X + Fonts[ActFont].Width[Ord(Funky_Text[CurrentScrollStart])] * Fonts[ActFont].Tex.H / 30 * Fonts[ActFont].AspectW; + inc(CurrentScrollStart); + end; + visibleText:=pchar(Copy(Funky_Text, CurrentScrollStart, CurrentScrollEnd)); + if (Credits_X+glTextWidth(visibleText) < 600) and (CurrentScrollEnd < length(Funky_Text)) then begin + inc(CurrentScrollEnd); + end; + end; +{ // timing hack + X:=5; + SetFontStyle (2); + SetFontItalic(False); + SetFontSize(9); + glColor4f(1, 1, 1, 1); + for S:=0 to high(CTime_hold) do begin + visibleText:=pchar(inttostr(CTime_hold[S])); + SetFontPos (500, X); + glPrint (Addr(visibleText[0])); + X:=X+20; + end;} +end; + +procedure Start3D; +begin + glMatrixMode(GL_PROJECTION); + glPushMatrix; + glLoadIdentity; + glFrustum(-0.3*4/3,0.3*4/3,-0.3,0.3,1,1000); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity; +end; +procedure End3D; +begin + glMatrixMode(GL_PROJECTION); + glPopMatrix; + glMatrixMode(GL_MODELVIEW); +end; + +procedure TScreenCredits.DrawCredits; +var + T,I: Cardinal; + X: Real; + Ver: PChar; + RuntimeStr: AnsiString; + Data: TFFTData; + j,k,l:cardinal; + f,g,h: Real; + STime:cardinal; + Delay:cardinal; + + myPixel: longword; + myColor: Cardinal; + myScale: Real; + myAngle: Real; +const myLogoCoords: Array[0..27,0..1] of Cardinal = ((39,32),(84,32),(100,16),(125,24), + (154,31),(156,58),(168,32),(203,36), + (258,34),(251,50),(274,93),(294,84), + (232,54),(278,62),(319,34),(336,92), + (347,23),(374,32),(377,58),(361,83), + (385,91),(405,91),(429,35),(423,51), + (450,32),(485,34),(444,91),(486,93)); + +begin +//dis does teh muiwk y0r +Data := Music.GetFFTData; + + + + T := GetTickCount div 33; + if T <> Credits_Time then + begin + Credits_Time := T; + inc(CTime); + inc(CTime_hold); + Credits_X := Credits_X-2; + if (CRDTS_Stage=InitialDelay) and (CTime=Timings[0]) then + begin +// CTime:=Timings[20]; +// CRDTS_Stage:=Outro; + + CRDTS_Stage:=Intro; + CTime:=0; + Music.Play; + + end; + if (CRDTS_Stage=Intro) and (CTime=Timings[7]) then + begin + CRDTS_Stage:=MainPart; + end; + if (CRDTS_Stage=MainPart) and (CTime=Timings[20]) then + begin + CRDTS_Stage:=Outro; + end; + end; + + //draw background + if CRDTS_Stage=InitialDelay then + begin + glClearColor(0,0,0,0); + glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); + end + else + if CRDTS_Stage=Intro then + begin + Start3D; + glPushMatrix; + + glClearColor(0,0,0,0); + glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); + + glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + if CTime < Timings[1] then begin + myScale:= 0.5+0.5*(Timings[1]-CTime)/(Timings[1]); // slowly move layers together + myAngle:=cos((CTime)*pi/((Timings[1])*2)); // and make logo face towards camera + end else begin // this is the part when the logo stands still + myScale:=0.5; + myAngle:=0; + end; + if CTime > Timings[2] then begin + myScale:= 0.5+0.5*(CTime-Timings[2])/(Timings[3]-Timings[2]); // get some space between layers + myAngle:=0; + end; +// if CTime > Timings[3] then myScale:=1; // keep the space between layers + glTranslatef(0,0,-5+0.5*myScale); + if CTime > Timings[3] then myScale:=1; // keep the space between layers + if CTime > Timings[3] then begin // make logo rotate left and grow +// myScale:=(CTime-Timings[4])/(Timings[7]-Timings[4]); + glRotatef(20*sqr(CTime-Timings[3])/sqr((Timings[7]-Timings[3])/2),0,0,1); + glScalef(1+sqr(CTime-Timings[3])/(32*(Timings[7]-Timings[3])),1+sqr(CTime-Timings[3])/(32*(Timings[7]-Timings[3])),1); + end; + if CTime < Timings[2] then + glRotatef(30*myAngle,0.5*myScale+myScale,1+myScale,0); +// glScalef(0.5,0.5,0.5); + glScalef(4/3,-1,1); + glColor4f(1, 1, 1, 1); + + glBindTexture(GL_TEXTURE_2D, intro_layer01.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex3f(-1, -1, -0.4 * myScale); + glTexCoord2f(0,1);glVertex3f(-1, 1, -0.4 * myScale); + glTexCoord2f(1,1); glVertex3f(1, 1, -0.4 * myScale); + glTexCoord2f(1,0);glVertex3f(1, -1, -0.4 * myScale); + glEnd; + glBindTexture(GL_TEXTURE_2D, intro_layer02.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex3f(-1, -1, -0.3 * myScale); + glTexCoord2f(0,1);glVertex3f(-1, 1, -0.3 * myScale); + glTexCoord2f(1,1); glVertex3f(1, 1, -0.3 * myScale); + glTexCoord2f(1,0);glVertex3f(1, -1, -0.3 * myScale); + glEnd; + glBindTexture(GL_TEXTURE_2D, intro_layer03.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex3f(-1, -1, -0.2 * myScale); + glTexCoord2f(0,1);glVertex3f(-1, 1, -0.2 * myScale); + glTexCoord2f(1,1); glVertex3f(1, 1, -0.2 * myScale); + glTexCoord2f(1,0);glVertex3f(1, -1, -0.2 * myScale); + glEnd; + glBindTexture(GL_TEXTURE_2D, intro_layer04.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex3f(-1, -1, -0.1 * myScale); + glTexCoord2f(0,1);glVertex3f(-1, 1, -0.1 * myScale); + glTexCoord2f(1,1); glVertex3f(1, 1, -0.1 * myScale); + glTexCoord2f(1,0);glVertex3f(1, -1, -0.1 * myScale); + glEnd; + glBindTexture(GL_TEXTURE_2D, intro_layer05.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex3f(-1, -1, 0 * myScale); + glTexCoord2f(0,1);glVertex3f(-1, 1, 0 * myScale); + glTexCoord2f(1,1); glVertex3f(1, 1, 0 * myScale); + glTexCoord2f(1,0);glVertex3f(1, -1, 0 * myScale); + glEnd; + glBindTexture(GL_TEXTURE_2D, intro_layer06.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex3f(-1, -1, 0.1 * myScale); + glTexCoord2f(0,1);glVertex3f(-1, 1, 0.1 * myScale); + glTexCoord2f(1,1); glVertex3f(1, 1, 0.1 * myScale); + glTexCoord2f(1,0);glVertex3f(1, -1, 0.1 * myScale); + glEnd; + glBindTexture(GL_TEXTURE_2D, intro_layer07.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex3f(-1, -1, 0.2 * myScale); + glTexCoord2f(0,1);glVertex3f(-1, 1, 0.2 * myScale); + glTexCoord2f(1,1); glVertex3f(1, 1, 0.2 * myScale); + glTexCoord2f(1,0);glVertex3f(1, -1, 0.2 * myScale); + glEnd; + glBindTexture(GL_TEXTURE_2D, intro_layer08.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex3f(-1, -1, 0.3 * myScale); + glTexCoord2f(0,1);glVertex3f(-1, 1, 0.3 * myScale); + glTexCoord2f(1,1); glVertex3f(1, 1, 0.3 * myScale); + glTexCoord2f(1,0);glVertex3f(1, -1, 0.3 * myScale); + glEnd; + glBindTexture(GL_TEXTURE_2D, intro_layer09.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex3f(-1, -1, 0.22 * myScale); + glTexCoord2f(0,1);glVertex3f(-1, 1, 0.22 * myScale); + glTexCoord2f(1,1); glVertex3f(1, 1, 0.22 * myScale); + glTexCoord2f(1,0);glVertex3f(1, -1, 0.22 * myScale); + glEnd; + gldisable(gl_texture_2d); + glDisable(GL_BLEND); + + glPopMatrix; + End3D; + + // do some sparkling effects + if (CTime < Timings[1]) and (CTime > Timings[21]) then + begin + for k:=1 to 3 do begin + l:=410+floor((CTime-Timings[21])/(Timings[1]-Timings[21])*(536-410))+RandomRange(-5,5); + j:=floor((Timings[1]-CTime)/22)+RandomRange(285,301); + GoldenRec.Spawn(l, j, 1, 16, 0, -1, Flare, 0); + end; + end; + + // fade to white at end + if Ctime > Timings[6] then + begin + glColor4f(1,1,1,sqr(Ctime-Timings[6])*(Ctime-Timings[6])/sqr(Timings[7]-Timings[6])); + glEnable(GL_BLEND); + glBegin(GL_QUADS); + glVertex2f(0,0); + glVertex2f(0,600); + glVertex2f(800,600); + glVertex2f(800,0); + glEnd; + glDisable(GL_BLEND); + end; + + end; + if (CRDTS_Stage=MainPart) then + // main credits screen background, scroller, logo and girl + begin + + glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + glColor4f(1, 1, 1, 1); + glBindTexture(GL_TEXTURE_2D, credits_bg_tex.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(0, 0); + glTexCoord2f(0,600/1024);glVertex2f(0, 600); + glTexCoord2f(800/1024,600/1024); glVertex2f(800, 600); + glTexCoord2f(800/1024,0);glVertex2f(800, 0); + glEnd; + glDisable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + + // draw scroller + Draw_FunkyText; + +//######################################################################### +// draw credits names + +// BlindGuard (von links oben reindrehen, nach rechts unten rausdrehen) + STime:=Timings[9]-10; + Delay:=Timings[10]-Timings[9]; + if CTime > STime then + begin + k:=0; + ESC_Alpha:=20; + for j:=0 to 40 do + if Data[j]>=Data[k] then k:=j; + if Data[k]>0.25 then ESC_Alpha:=5 else inc(ESC_Alpha); + if ESC_Alpha >20 then ESC_Alpha:=20; + if ((CTime-STime)<20) then ESC_Alpha:=20; + k:=CTime-STime; + if CTime <=STime+10 then j:=CTime-STime else j:=10; + if (CTime >=STime+Delay-10) then if (CTime <=STime+Delay) then j:=(STime+Delay)-CTime else j:=0; + glColor4f(1, 1, 1, ESC_Alpha/20*j/10); + + if (CTime >= STime+10) and (CTime<=STime+12) then begin + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + end; + + glPushMatrix; + gltranslatef(0,329,0); + if CTime <= STime+10 then begin glrotatef((CTime-STime)*9+270,0,0,1);end; + gltranslatef(223,0,0); + if CTime >=STime+Delay-10 then if CTime <=STime+Delay then begin + gltranslatef(223,0,0); + glrotatef((CTime-(STime+Delay-10))*-9,0,0,1); + gltranslatef(-223,0,0); + end; + glBindTexture(GL_TEXTURE_2D, credits_blindguard.TexNum); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(-163, -129); + glTexCoord2f(0,1);glVertex2f(-163, 129); + glTexCoord2f(1,1); glVertex2f(163, 129); + glTexCoord2f(1,0);glVertex2f(163, -129); + glEnd; + gldisable(gl_texture_2d); + gldisable(GL_BLEND); + glPopMatrix; + end; + +// Blindy (zoom von 0 auf volle grösse und drehung, zoom auf doppelte grösse und nach rechts oben schieben) + STime:=Timings[10]-10; + Delay:=Timings[11]-Timings[10]+5; + if CTime > STime then + begin + k:=0; + ESC_Alpha:=20; + for j:=0 to 40 do + if Data[j]>=Data[k] then k:=j; + if Data[k]>0.25 then ESC_Alpha:=5 else inc(ESC_Alpha); + if ESC_Alpha >20 then ESC_Alpha:=20; + if ((CTime-STime)<20) then ESC_Alpha:=20; + k:=CTime-STime; + if CTime <=STime+10 then j:=CTime-STime else j:=10; + if (CTime >=STime+Delay-10) then if (CTime <=STime+Delay) then j:=(STime+Delay)-CTime else j:=0; + glColor4f(1, 1, 1, ESC_Alpha/20*j/10); + + if (CTime >= STime+20) and (CTime<=STime+22) then begin + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + end; + + glPushMatrix; + gltranslatef(223,329,0); + if CTime <= STime+20 then begin + j:=CTime-Stime; + glscalef(j*j/400,j*j/400,j*j/400); + glrotatef(j*18.0,0,0,1); + end; + if CTime >=STime+Delay-10 then if CTime <=STime+Delay then begin + j:=CTime-(STime+Delay-10); + f:=j*10.0; + gltranslatef(f*3,-f,0); + glscalef(1+j/10,1+j/10,1+j/10); + glrotatef(j*9.0,0,0,1); + end; + glBindTexture(GL_TEXTURE_2D, credits_blindy.TexNum); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(-163, -129); + glTexCoord2f(0,1);glVertex2f(-163, 129); + glTexCoord2f(1,1); glVertex2f(163, 129); + glTexCoord2f(1,0);glVertex2f(163, -129); + glEnd; + gldisable(gl_texture_2d); + gldisable(GL_BLEND); + glPopMatrix; + end; + +// Canni (von links reinschieben, nach rechts oben rausschieben) + STime:=Timings[11]-10; + Delay:=Timings[12]-Timings[11]+5; + if CTime > STime then + begin + k:=0; + ESC_Alpha:=20; + for j:=0 to 40 do + if Data[j]>=Data[k] then k:=j; + if Data[k]>0.25 then ESC_Alpha:=5 else inc(ESC_Alpha); + if ESC_Alpha >20 then ESC_Alpha:=20; + if ((CTime-STime)<20) then ESC_Alpha:=20; + k:=CTime-STime; + if CTime <=STime+10 then j:=CTime-STime else j:=10; + if (CTime >=STime+Delay-10) then if (CTime <=STime+Delay) then j:=(STime+Delay)-CTime else j:=0; + glColor4f(1, 1, 1, ESC_Alpha/20*j/10); + + if (CTime >= STime+10) and (CTime<=STime+12) then begin + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + end; + + glPushMatrix; + gltranslatef(223,329,0); + if CTime <= STime+10 then begin + gltranslatef(((CTime-STime)*21.0)-210,0,0); + end; + if CTime >=STime+Delay-10 then if CTime <=STime+Delay then begin + j:=(CTime-(STime+Delay-10))*21; + gltranslatef(j,-j/2,0); + end; + glBindTexture(GL_TEXTURE_2D, credits_canni.TexNum); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(-163, -129); + glTexCoord2f(0,1);glVertex2f(-163, 129); + glTexCoord2f(1,1); glVertex2f(163, 129); + glTexCoord2f(1,0);glVertex2f(163, -129); + glEnd; + gldisable(gl_texture_2d); + gldisable(GL_BLEND); + glPopMatrix; + end; + +// Commandio (von unten reinklappen, nach rechts oben rausklappen) + STime:=Timings[12]-10; + Delay:=Timings[13]-Timings[12]; + if CTime > STime then + begin + k:=0; + ESC_Alpha:=20; + for j:=0 to 40 do + if Data[j]>=Data[k] then k:=j; + if Data[k]>0.25 then ESC_Alpha:=5 else inc(ESC_Alpha); + if ESC_Alpha >20 then ESC_Alpha:=20; + if ((CTime-STime)<20) then ESC_Alpha:=20; + k:=CTime-STime; + if CTime <=STime+10 then j:=CTime-STime else j:=10; + if (CTime >=STime+Delay-10) then if (CTime <=STime+Delay) then j:=(STime+Delay)-CTime else j:=0; + glColor4f(1, 1, 1, ESC_Alpha/20*j/10); + + if (CTime >= STime+10) and (CTime<=STime+12) then begin + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + end; + + glPushMatrix; + gltranslatef(223,329,0); + if CTime <= STime+10 then + f:=258.0-25.8*(CTime-STime) + else + f:=0; + + if CTime >=STime+Delay-10 then if CTime <=STime+Delay then begin + j:=CTime-(STime+Delay-10); + g:=32.6*j; + end else + g:=0; + glBindTexture(GL_TEXTURE_2D, credits_commandio.TexNum); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(-163+g-f*1.5, -129+f*1.5-g/2); + glTexCoord2f(0,1);glVertex2f(-163+g*1.5, 129-(g*1.5*258/326)); + glTexCoord2f(1,1); glVertex2f(163+g, 129+g/4); + glTexCoord2f(1,0);glVertex2f(163+f*1.5+g/4, -129+f*1.5-g/4); + glEnd; + gldisable(gl_texture_2d); + gldisable(GL_BLEND); + glPopMatrix; + end; + +// lazy joker (just scrolls from left to right, no twinkling stars, no on-beat flashing) + STime:=Timings[13]-35; + Delay:=Timings[14]-Timings[13]+5; + if CTime > STime then + begin + k:=0; + for j:=0 to 40 do + if Data[j]>=Data[k] then k:=j; + if Data[k]>0.25 then ESC_Alpha:=5 else inc(ESC_Alpha); + if ESC_Alpha >20 then ESC_Alpha:=20; + if ((CTime-STime)>10) and ((CTime-STime)<20) then ESC_Alpha:=20; + ESC_Alpha:=10; + f:=CTime-STime; + if CTime <=STime+40 then j:=CTime-STime else j:=40; + if (CTime >=STime+Delay-40) then if (CTime <=STime+Delay) then j:=(STime+Delay)-CTime else j:=0; + glColor4f(1, 1, 1, ESC_Alpha/20*j*j/1600); + + glPushMatrix; + gltranslatef(180+(f-70),329,0); + glBindTexture(GL_TEXTURE_2D, credits_lazyjoker.TexNum); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(-163, -129); + glTexCoord2f(0,1);glVertex2f(-163, 129); + glTexCoord2f(1,1); glVertex2f(163, 129); + glTexCoord2f(1,0);glVertex2f(163, -129); + glEnd; + gldisable(gl_texture_2d); + gldisable(GL_BLEND); + glPopMatrix; + end; + +// Mog (von links reinklappen, nach rechts unten rausklappen) + STime:=Timings[14]-10; + Delay:=Timings[15]-Timings[14]+5; + if CTime > STime then + begin + k:=0; + ESC_Alpha:=20; + for j:=0 to 40 do + if Data[j]>=Data[k] then k:=j; + if Data[k]>0.25 then ESC_Alpha:=5 else inc(ESC_Alpha); + if ESC_Alpha >20 then ESC_Alpha:=20; + if ((CTime-STime)<20) then ESC_Alpha:=20; + k:=CTime-STime; + if CTime <=STime+10 then j:=CTime-STime else j:=10; + if (CTime >=STime+Delay-10) then if (CTime <=STime+Delay) then j:=(STime+Delay)-CTime else j:=0; + glColor4f(1, 1, 1, ESC_Alpha/20*j/10); + + if (CTime >= STime+10) and (CTime<=STime+12) then begin + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + end; + + glPushMatrix; + gltranslatef(223,329,0); + if CTime <= STime+10 then + f:=326.0-32.6*(CTime-STime) + else + f:=0; + + if CTime >=STime+Delay-10 then if CTime <=STime+Delay then begin + j:=CTime-(STime+Delay-10); + g:=32.6*j; + end else + g:=0; + glBindTexture(GL_TEXTURE_2D, credits_mog.TexNum); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(-163+g*1.5, -129+g*1.5); + glTexCoord2f(0,1);glVertex2f(-163+g*1.2, 129+g); + glTexCoord2f(1,1); glVertex2f(163-f+g/2, 129+f*1.5+g/4); + glTexCoord2f(1,0);glVertex2f(163-f+g*1.5, -129-f*1.5); + glEnd; + gldisable(gl_texture_2d); + gldisable(GL_BLEND); + glPopMatrix; + end; + +// Mota (von rechts oben reindrehen, nach links unten rausschieben und verkleinern und dabei drehen) + STime:=Timings[15]-10; + Delay:=Timings[16]-Timings[15]+5; + if CTime > STime then + begin + k:=0; + ESC_Alpha:=20; + for j:=0 to 40 do + if Data[j]>=Data[k] then k:=j; + if Data[k]>0.25 then ESC_Alpha:=5 else inc(ESC_Alpha); + if ESC_Alpha >20 then ESC_Alpha:=20; + if ((CTime-STime)<20) then ESC_Alpha:=20; + k:=CTime-STime; + if CTime <=STime+10 then j:=CTime-STime else j:=10; + if (CTime >=STime+Delay-10) then if (CTime <=STime+Delay) then j:=(STime+Delay)-CTime else j:=0; + glColor4f(1, 1, 1, ESC_Alpha/20*j/10); + + if (CTime >= STime+10) and (CTime<=STime+12) then begin + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + end; + + glPushMatrix; + gltranslatef(223,329,0); + if CTime <= STime+10 then begin + gltranslatef(223,0,0); + glrotatef((10-(CTime-STime))*9,0,0,1); + gltranslatef(-223,0,0); + end; + if CTime >=STime+Delay-10 then if CTime <=STime+Delay then begin + j:=CTime-(STime+Delay-10); + f:=j*10.0; + gltranslatef(-f*2,-f,0); + glscalef(1-j/10,1-j/10,1-j/10); + glrotatef(-j*9.0,0,0,1); + end; + glBindTexture(GL_TEXTURE_2D, credits_mota.TexNum); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(-163, -129); + glTexCoord2f(0,1);glVertex2f(-163, 129); + glTexCoord2f(1,1); glVertex2f(163, 129); + glTexCoord2f(1,0);glVertex2f(163, -129); + glEnd; + gldisable(gl_texture_2d); + gldisable(GL_BLEND); + glPopMatrix; + end; + +// Skillmaster (von rechts unten reinschieben, nach rechts oben rausdrehen) + STime:=Timings[16]-10; + Delay:=Timings[17]-Timings[16]+5; + if CTime > STime then + begin + k:=0; + ESC_Alpha:=20; + for j:=0 to 40 do + if Data[j]>=Data[k] then k:=j; + if Data[k]>0.25 then ESC_Alpha:=5 else inc(ESC_Alpha); + if ESC_Alpha >20 then ESC_Alpha:=20; + if ((CTime-STime)<20) then ESC_Alpha:=20; + k:=CTime-STime; + if CTime <=STime+10 then j:=CTime-STime else j:=10; + if (CTime >=STime+Delay-10) then if (CTime <=STime+Delay) then j:=(STime+Delay)-CTime else j:=0; + glColor4f(1, 1, 1, ESC_Alpha/20*j/10); + + if (CTime >= STime+10) and (CTime<=STime+12) then begin + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + end; + + glPushMatrix; + gltranslatef(223,329,0); + if CTime <= STime+10 then begin + j:=STime+10-CTime; + f:=j*10.0; + gltranslatef(+f*2,+f/2,0); + end; + if CTime >=STime+Delay-10 then if CTime <=STime+Delay then begin + j:=CTime-(STime+Delay-10); + f:=j*10.0; + gltranslatef(0,-223,0); + glrotatef(j*-9,0,0,1); + gltranslatef(0,223,0); + glrotatef(j*9,0,0,1); + end; + glBindTexture(GL_TEXTURE_2D, credits_skillmaster.TexNum); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(-163, -129); + glTexCoord2f(0,1);glVertex2f(-163, 129); + glTexCoord2f(1,1); glVertex2f(163, 129); + glTexCoord2f(1,0);glVertex2f(163, -129); + glEnd; + gldisable(gl_texture_2d); + gldisable(GL_BLEND); + glPopMatrix; + end; + +// WhiteShark (von links unten reinklappen, nach rechts oben rausklappen) + STime:=Timings[17]-10; + Delay:=Timings[18]-Timings[17]; + if CTime > STime then + begin + k:=0; + ESC_Alpha:=20; + for j:=0 to 40 do + if Data[j]>=Data[k] then k:=j; + if Data[k]>0.25 then ESC_Alpha:=5 else inc(ESC_Alpha); + if ESC_Alpha >20 then ESC_Alpha:=20; + if ((CTime-STime)<20) then ESC_Alpha:=20; + k:=CTime-STime; + if CTime <=STime+10 then j:=CTime-STime else j:=10; + if (CTime >=STime+Delay-10) then if (CTime <=STime+Delay) then j:=(STime+Delay)-CTime else j:=0; + glColor4f(1, 1, 1, ESC_Alpha/20*j/10); + + if (CTime >= STime+10) and (CTime<=STime+12) then begin + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 0); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 1); + GoldenRec.Spawn(RandomRange(65,390), RandomRange(200,460), 1, 16, 0, -1, PerfectLineTwinkle, 5); + end; + + glPushMatrix; + gltranslatef(223,329,0); + if CTime <= STime+10 then + f:=326.0-32.6*(CTime-STime) + else + f:=0; + + if CTime >=STime+Delay-10 then if CTime <=STime+Delay then begin + j:=CTime-(STime+Delay-10); + g:=32.6*j; + end else + g:=0; + glBindTexture(GL_TEXTURE_2D, credits_whiteshark.TexNum); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(-163-f+g, -129+f/4-g/2); + glTexCoord2f(0,1);glVertex2f(-163-f/4+g, 129+g/2+f/4); + glTexCoord2f(1,1); glVertex2f(163-f*1.2+g/4, 129+f/2-g/4); + glTexCoord2f(1,0);glVertex2f(163-f*1.5+g/4, -129+f*1.5+g/4); + glEnd; + gldisable(gl_texture_2d); + gldisable(GL_BLEND); + glPopMatrix; + end; + + +// #################################################################### +// do some twinkle stuff (kinda on beat) + if (CTime>Timings[8]) and (CTime < Timings[19]) then begin + k:=0; + for j:=0 to 40 do + if Data[j]>=Data[k] then k:=j; + if Data[k]>0.2 then begin + l:=RandomRange(6,16); + j:=RandomRange(0,27); + GoldenRec.Spawn(myLogoCoords[j,0], myLogoCoords[j,1], 16-l, l, 0, -1, PerfectNote, 0); + end; + end; + +//################################################# +// draw the rest of the main screen (girl and logo + glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glColor4f(1, 1, 1, 1); + glBindTexture(GL_TEXTURE_2D, credits_bg_ovl.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(800-393, 0); + glTexCoord2f(0,600/1024);glVertex2f(800-393, 600); + glTexCoord2f(393/512,600/1024); glVertex2f(800, 600); + glTexCoord2f(393/512,0);glVertex2f(800, 0); + glEnd; +{ glBindTexture(GL_TEXTURE_2D, credits_bg_logo.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(0, 0); + glTexCoord2f(0,112/128);glVertex2f(0, 112); + glTexCoord2f(497/512,112/128); glVertex2f(497, 112); + glTexCoord2f(497/512,0);glVertex2f(497, 0); + glEnd; +} + gldisable(gl_texture_2d); + glDisable(GL_BLEND); + + // fade out at end of main part + if Ctime > Timings[19] then + begin + glColor4f(0,0,0,(Ctime-Timings[19])/(Timings[20]-Timings[19])); + glEnable(GL_BLEND); + glBegin(GL_QUADS); + glVertex2f(0,0); + glVertex2f(0,600); + glVertex2f(800,600); + glVertex2f(800,0); + glEnd; + glDisable(GL_BLEND); + end; + end + else + if (CRDTS_Stage=Outro) then + begin + if CTime=Timings[20] then begin + CTime_hold:=0; + Music.Stop; + Music.Open(soundpath + 'credits-outro-tune.mp3'); + Music.Play; + Music.SetVolume(20); + Music.SetLoop(True); + end; + if CTime_hold > 231 then begin + Music.Play; + Ctime_hold:=0; + end; + glClearColor(0,0,0,0); + glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); + + // do something useful + // outro background + glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + glColor4f(1, 1, 1, 1); + glBindTexture(GL_TEXTURE_2D, outro_bg.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(0, 0); + glTexCoord2f(0,600/1024);glVertex2f(0, 600); + glTexCoord2f(800/1024,600/1024); glVertex2f(800, 600); + glTexCoord2f(800/1024,0);glVertex2f(800, 0); + glEnd; + + //outro overlays + glColor4f(1, 1, 1, (1+sin(CTime/15))/3+1/3); + glBindTexture(GL_TEXTURE_2D, outro_esc.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(0, 0); + glTexCoord2f(0,223/256);glVertex2f(0, 223); + glTexCoord2f(487/512,223/256); glVertex2f(487, 223); + glTexCoord2f(487/512,0);glVertex2f(487, 0); + glEnd; + + ESC_Alpha:=20; + if (RandomRange(0,20) > 18) and (ESC_Alpha=20) then + ESC_Alpha:=0 + else inc(ESC_Alpha); + if ESC_Alpha > 20 then ESC_Alpha:=20; + glColor4f(1, 1, 1, ESC_Alpha/20); + glBindTexture(GL_TEXTURE_2D, outro_exd.TexNum); + glbegin(gl_quads); + glTexCoord2f(0,0);glVertex2f(800-310, 600-247); + glTexCoord2f(0,247/256);glVertex2f(800-310, 600); + glTexCoord2f(310/512,247/256); glVertex2f(800, 600); + glTexCoord2f(310/512,0);glVertex2f(800, 600-247); + glEnd; + glDisable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + + // outro scrollers? + // ... + end; + +{ // draw credits runtime counter + SetFontStyle (2); + SetFontItalic(False); + SetFontSize(9); + SetFontPos (5, 5); + glColor4f(1, 1, 1, 1); +// RuntimeStr:='CTime: '+inttostr(floor(CTime/30.320663991914489602156136106092))+'.'+inttostr(floor(CTime/3.0320663991914489602156136106092)-floor(CTime/30.320663991914489602156136106092)*10); + RuntimeStr:='CTime: '+inttostr(CTime); + glPrint (Addr(RuntimeStr[1])); +} + // make the stars shine + GoldenRec.Draw; + + //timing hack +// Draw_FunkyText; +end; + +end. diff --git a/Game/Code/Screens/UScreenEdit.pas b/Game/Code/Screens/UScreenEdit.pas new file mode 100644 index 00000000..b78df989 --- /dev/null +++ b/Game/Code/Screens/UScreenEdit.pas @@ -0,0 +1,109 @@ +unit UScreenEdit; + +interface + +uses UMenu, SDL, UThemes; + +type + TScreenEdit = class(TMenu) + public +{ Tex_Background: TTexture; + FadeOut: boolean; + Path: string; + FileName: string;} + constructor Create; override; + procedure onShow; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; +{ function Draw: boolean; override; + procedure Finish;} + end; + +implementation + +uses UGraphic, UMusic, USkins; + +function TScreenEdit.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Music.PlayBack; + FadeTo(@ScreenMain); +// Result := false; + end; + SDLK_RETURN: + begin + if Interaction = 0 then begin + Music.PlayStart; + FadeTo(@ScreenEditConvert); + end; +// if Interaction = 1 then begin +// Music.PlayStart; +// FadeTo(@ScreenEditHeader); +// end; + + if Interaction = 1 then begin + Music.PlayBack; + FadeTo(@ScreenMain); + end; + end; + + SDLK_DOWN: + begin + InteractNext; + end; + SDLK_UP: + begin + InteractPrev; + end; + end; + end; +end; + +constructor TScreenEdit.Create; +begin + inherited Create; + AddButton(400-200, 100 + 0*70, 400, 40, Skin.GetTextureFileName('ButtonF')); + AddButtonText(10, 5, 0, 0, 0, 'Convert Midi to Txt'); +// Button[High(Button)].Text[0].Size := 11; + +// AddButton(400-200, 100 + 1*60, 400, 40, 'ButtonF'); +// AddButtonText(10, 5, 0, 0, 0, 'Edit Headers'); + +// AddButton(400-200, 100 + 2*60, 400, 40, 'ButtonF'); +// AddButtonText(10, 5, 0, 0, 0, 'Set GAP'); + + AddButton(400-200, 100 + 3*60, 400, 40, Skin.GetTextureFileName('ButtonF')); + AddButtonText(10, 5, 0, 0, 0, 'Exit'); + +end; + +procedure TScreenEdit.onShow; +begin +// Interaction := 0; +end; + +(*function TScreenEdit.Draw: boolean; +var + Min: integer; + Sec: integer; + Tekst: string; + Pet: integer; + AktBeat: integer; +begin +end; + +procedure TScreenEdit.Finish; +begin +// +end;*) + +end. diff --git a/Game/Code/Screens/UScreenEditConvert.pas b/Game/Code/Screens/UScreenEditConvert.pas new file mode 100644 index 00000000..b5803bf6 --- /dev/null +++ b/Game/Code/Screens/UScreenEditConvert.pas @@ -0,0 +1,531 @@ +unit UScreenEditConvert; + +interface + +uses UMenu, SDL, MidiFile, MidiOut, ULog, USongs, UMusic, UThemes; + +type + TNote = record + Event: integer; + EventType: integer; + Channel: integer; + Start: real; + Len: real; + Data1: integer; + Data2: integer; + Str: string; + end; + + TTrack = record + Note: array of TNote; + Name: string; + Hear: boolean; + Status: byte; // 0 - none, 1 - notes, 2 - lyrics, 3 - notes + lyrics + end; + + TNuta = record + Start: integer; + Len: integer; + Tone: integer; + Lyric: string; + NewSentence: boolean; + end; + + TArrayTrack = array of TTrack; + + TScreenEditConvert = class(TMenu) + public + ATrack: TArrayTrack; // actual track +// Track: TArrayTrack; + Channel: TArrayTrack; + ColR: array[0..100] of real; + ColG: array[0..100] of real; + ColB: array[0..100] of real; + Len: real; + Sel: integer; + Selected: boolean; +// FileName: string; + MidiFile: TMidiFile; + MidiTrack: TMidiTrack; + MidiEvent: pMidiEvent; + MidiOut: TMidiOutput; + Song: TSong; + Czesc: TCzesci; + BPM: real; + Ticks: real; + Nuta: array of TNuta; + + procedure AddLyric(Start: integer; Tekst: string); + procedure Extract; + + procedure MidiFile1MidiEvent(event: PMidiEvent); + function SelectedNumber: integer; + constructor Create; override; + procedure onShow; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function Draw: boolean; override; + procedure onHide; override; + end; + +implementation +uses UGraphic, SysUtils, UDrawTexture, TextGL, UFiles, UMain, UIni, OpenGL, USkins; + +function TScreenEditConvert.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + T: integer; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE: + begin + MidiFile.StopPlaying; + Music.PlayBack; + FadeTo(@ScreenEdit); + end; + + SDLK_RETURN: + begin + if Interaction = 0 then begin + Music.PlayStart; + ScreenOpen.BackScreen := @ScreenEditConvert; + FadeTo(@ScreenOpen); + end; + + if Interaction = 1 then begin + Selected := false; + MidiFile.OnMidiEvent := MidiFile1MidiEvent; +// MidiFile.GoToTime(MidiFile.GetTrackLength div 2); + MidiFile.StartPlaying; + end; + + if Interaction = 2 then begin + Selected := true; + MidiFile.OnMidiEvent := nil; + {for T := 0 to High(ATrack) do begin + if ATrack[T].Hear then begin + MidiTrack := MidiFile.GetTrack(T); + MidiTrack.OnMidiEvent := MidiFile1MidiEvent; + end; + end; + MidiFile.StartPlaying;//} + end; + + if Interaction = 3 then begin + if SelectedNumber > 0 then begin + Extract; + SaveSong(Song, Czesc, ChangeFileExt(FileName, '.txt'), false); + end; + end; + + end; + + SDLK_SPACE: + begin +// ATrack[Sel].Hear := not ATrack[Sel].Hear; + ATrack[Sel].Status := (ATrack[Sel].Status + 1) mod 4; + +{ if Selected then begin + MidiTrack := MidiFile.GetTrack(Sel); + if Track[Sel].Hear then + MidiTrack.OnMidiEvent := MidiFile1MidiEvent + else + MidiTrack.OnMidiEvent := nil; + end;} + end; + + SDLK_RIGHT: + begin + InteractNext; + end; + + SDLK_LEFT: + begin + InteractPrev; + end; + + SDLK_DOWN: + begin + Inc(Sel); + if Sel > High(ATrack) then Sel := 0; + end; + SDLK_UP: + begin + Dec(Sel); + if Sel < 0 then Sel := High(ATrack); + end; + end; + end; +end; + +procedure TScreenEditConvert.AddLyric(Start: integer; Tekst: string); +var + N: integer; +begin + for N := 0 to High(Nuta) do begin + if Nuta[N].Start = Start then begin + // check for new sentece + if Copy(Tekst, 1, 1) = '\' then Delete(Tekst, 1, 1); + if Copy(Tekst, 1, 1) = '/' then begin + Delete(Tekst, 1, 1); + Nuta[N].NewSentence := true; + end; + + // overwrite lyric od append + if Nuta[N].Lyric = '-' then + Nuta[N].Lyric := Tekst + else + Nuta[N].Lyric := Nuta[N].Lyric + Tekst; + end; + end; +end; + +procedure TScreenEditConvert.Extract; +var + T: integer; + C: integer; + N: integer; + Nu: integer; + NutaTemp: TNuta; + Move: integer; + Max, Min: integer; +begin + // song info + Song.Title := ''; + Song.Artist := ''; + Song.Mp3 := ''; + Song.Resolution := 4; + SetLength(Song.BPM, 1); + Song.BPM[0].BPM := BPM*4; + + SetLength(Nuta, 0); + + // extract notes + for T := 0 to High(ATrack) do begin +// if ATrack[T].Hear then begin + if ((ATrack[T].Status div 1) and 1) = 1 then begin + for N := 0 to High(ATrack[T].Note) do begin + if (ATrack[T].Note[N].EventType = 9) and (ATrack[T].Note[N].Data2 > 0) then begin + Nu := Length(Nuta); + SetLength(Nuta, Nu + 1); + Nuta[Nu].Start := Round(ATrack[T].Note[N].Start / Ticks); + Nuta[Nu].Len := Round(ATrack[T].Note[N].Len / Ticks); + Nuta[Nu].Tone := ATrack[T].Note[N].Data1 - 12*5; + Nuta[Nu].Lyric := '-'; + end; + end; + end; + end; + + // extract lyrics + for T := 0 to High(ATrack) do begin +// if ATrack[T].Hear then begin + if ((ATrack[T].Status div 2) and 1) = 1 then begin + for N := 0 to High(ATrack[T].Note) do begin + if (ATrack[T].Note[N].EventType = 15) then begin +// Log.LogStatus('<' + Track[T].Note[N].Str + '>', 'MIDI'); + AddLyric(Round(ATrack[T].Note[N].Start / Ticks), ATrack[T].Note[N].Str); + end; + end; + end; + end; + + // sort notes + for N := 0 to High(Nuta) do + for Nu := 0 to High(Nuta)-1 do + if Nuta[Nu].Start > Nuta[Nu+1].Start then begin + NutaTemp := Nuta[Nu]; + Nuta[Nu] := Nuta[Nu+1]; + Nuta[Nu+1] := NutaTemp; + end; + + // move to 0 at beginning + Move := Nuta[0].Start; + for N := 0 to High(Nuta) do + Nuta[N].Start := Nuta[N].Start - Move; + + // copy notes + SetLength(Czesc.Czesc, 1); + Czesc.Ilosc := 1; + Czesc.High := 0; + + C := 0; + N := 0; + Czesc.Czesc[C].IlNut := 0; + Czesc.Czesc[C].HighNut := -1; + + for Nu := 0 to High(Nuta) do begin + if Nuta[Nu].NewSentence then begin // nowa linijka + SetLength(Czesc.Czesc, Length(Czesc.Czesc)+1); + Czesc.Ilosc := Czesc.Ilosc + 1; + Czesc.High := Czesc.High + 1; + C := C + 1; + N := 0; + SetLength(Czesc.Czesc[C].Nuta, 0); + Czesc.Czesc[C].IlNut := 0; + Czesc.Czesc[C].HighNut := -1; + + //Calculate Start of the Last Sentence + if (C > 0) and (Nu > 0) then + begin + Max := Nuta[Nu].Start; + Min := Nuta[Nu-1].Start + Nuta[Nu-1].Len; + + case (Max - Min) of + 0: Czesc.Czesc[C].Start := Max; + 1: Czesc.Czesc[C].Start := Max; + 2: Czesc.Czesc[C].Start := Max - 1; + 3: Czesc.Czesc[C].Start := Max - 2; + else + if ((Max - Min) > 4) then + Czesc.Czesc[C].Start := Min + 2 + else + Czesc.Czesc[C].Start := Max; + + end; // case + + end; + end; + + // tworzy miejsce na nowa nute + SetLength(Czesc.Czesc[C].Nuta, Length(Czesc.Czesc[C].Nuta)+1); + Czesc.Czesc[C].IlNut := Czesc.Czesc[C].IlNut + 1; + Czesc.Czesc[C].HighNut := Czesc.Czesc[C].HighNut + 1; + + // dopisuje + Czesc.Czesc[C].Nuta[N].Start := Nuta[Nu].Start; + Czesc.Czesc[C].Nuta[N].Dlugosc := Nuta[Nu].Len; + Czesc.Czesc[C].Nuta[N].Ton := Nuta[Nu].Tone; + Czesc.Czesc[C].Nuta[N].Tekst := Nuta[Nu].Lyric; + //All Notes are Freestyle when Converted Fix: + Czesc.Czesc[C].Nuta[N].Wartosc := 1; + Inc(N); + end; +end; + +function TScreenEditConvert.SelectedNumber: integer; +var + T: integer; // track +begin + Result := 0; + for T := 0 to High(ATrack) do +// if ATrack[T].Hear then Inc(Result); + if ((ATrack[T].Status div 1) and 1) = 1 then Inc(Result); +end; + +procedure TScreenEditConvert.MidiFile1MidiEvent(event: PMidiEvent); +begin +// Log.LogStatus(IntToStr(event.event), 'MIDI'); + MidiOut.PutShort(event.event, event.data1, event.data2); +end; + +constructor TScreenEditConvert.Create; +var + P: integer; +begin + inherited Create; + AddButton(40, 20, 100, 40, Skin.GetTextureFileName('ButtonF')); + AddButtonText(15, 5, 0, 0, 0, 'Open'); +// Button[High(Button)].Text[0].Size := 11; + + AddButton(160, 20, 100, 40, Skin.GetTextureFileName('ButtonF')); + AddButtonText(25, 5, 0, 0, 0, 'Play'); + + AddButton(280, 20, 200, 40, Skin.GetTextureFileName('ButtonF')); + AddButtonText(25, 5, 0, 0, 0, 'Play Selected'); + + AddButton(500, 20, 100, 40, Skin.GetTextureFileName('ButtonF')); + AddButtonText(20, 5, 0, 0, 0, 'Save'); + + +{ MidiOut := TMidiOutput.Create(nil); +// MidiOut.Close; +// MidiOut.DeviceID := 0; + if Ini.Debug = 1 then + MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table + Log.LogStatus(MidiOut.ProductName, 'MIDI'); + MidiOut.Open; +// MidiOut.SetVolume(100, 100); // temporary} + + FileName := GamePath + 'file.mid'; + MidiFile := TMidiFile.Create(nil); + + for P := 0 to 100 do begin + ColR[P] := Random(10)/10; + ColG[P] := Random(10)/10; + ColB[P] := Random(10)/10; + end; + +end; + +procedure TScreenEditConvert.onShow; +var + T: integer; // track + N: integer; // note + C: integer; // channel + CN: integer; // channel note +begin + MidiOut := TMidiOutput.Create(nil); + if Ini.Debug = 1 then + MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table + Log.LogStatus(MidiOut.ProductName, 'MIDI'); + MidiOut.Open; + + + if FileExists(FileName) then begin + MidiFile.Filename := FileName; + MidiFile.ReadFile; + + + Len := 0; + Sel := 0; + BPM := MidiFile.Bpm; + Ticks := MidiFile.TicksPerQuarter / 4; + +{ for T := 0 to MidiFile.NumberOfTracks-1 do begin + SetLength(Track, Length(Track)+1); + MidiTrack := MidiFile.GetTrack(T); + MidiTrack.OnMidiEvent := MidiFile1MidiEvent; + Track[T].Name := MidiTrack.getName; + + for N := 0 to MidiTrack.getEventCount-1 do begin + SetLength(Track[T].Note, Length(Track[T].Note)+1); + MidiEvent := MidiTrack.GetEvent(N); + Track[T].Note[N].Start := MidiEvent.time; + Track[T].Note[N].Len := MidiEvent.len; + Track[T].Note[N].Event := MidiEvent.event; + Track[T].Note[N].EventType := MidiEvent.event div 16; + Track[T].Note[N].Channel := MidiEvent.event and 15; + Track[T].Note[N].Data1 := MidiEvent.data1; + Track[T].Note[N].Data2 := MidiEvent.data2; + Track[T].Note[N].Str := MidiEvent.str; + + if Track[T].Note[N].Start + Track[T].Note[N].Len > Len then + Len := Track[T].Note[N].Start + Track[T].Note[N].Len; + end; + end;} + + + SetLength(Channel, 16); + for T := 0 to 15 do + begin + Channel[T].Name := IntToStr(T+1); + SetLength(Channel[T].Note, 0); + Channel[T].Status := 0; + end; + + for T := 0 to MidiFile.NumberOfTracks-1 do begin + MidiTrack := MidiFile.GetTrack(T); + MidiTrack.OnMidiEvent := MidiFile1MidiEvent; + + for N := 0 to MidiTrack.getEventCount-1 do begin + MidiEvent := MidiTrack.GetEvent(N); + C := MidiEvent.event and 15; + + CN := Length(Channel[C].Note); + SetLength(Channel[C].Note, CN+1); + + Channel[C].Note[CN].Start := MidiEvent.time; + Channel[C].Note[CN].Len := MidiEvent.len; + Channel[C].Note[CN].Event := MidiEvent.event; + Channel[C].Note[CN].EventType := MidiEvent.event div 16; + Channel[C].Note[CN].Channel := MidiEvent.event and 15; + Channel[C].Note[CN].Data1 := MidiEvent.data1; + Channel[C].Note[CN].Data2 := MidiEvent.data2; + Channel[C].Note[CN].Str := MidiEvent.str; + + if Channel[C].Note[CN].Start + Channel[C].Note[CN].Len > Len then + Len := Channel[C].Note[CN].Start + Channel[C].Note[CN].Len; + end; + end; + ATrack := Channel; + + end; + + Interaction := 0; +end; + +function TScreenEditConvert.Draw: boolean; +var + Pet: integer; + Pet2: integer; + Bottom: real; + X: real; + Y: real; + H: real; + YSkip: real; +begin + // draw static menu + inherited Draw; + + Y := 100; + + H := Length(ATrack)*40; + if H > 480 then H := 480; + Bottom := Y + H; + + YSkip := H / Length(ATrack); + + // select + DrawQuad(10, Y+Sel*YSkip, 780, YSkip, 0.8, 0.8, 0.8); + + // selected - now me use Status System + for Pet := 0 to High(ATrack) do + if ATrack[Pet].Hear then + DrawQuad(10, Y+Pet*YSkip, 50, YSkip, 0.8, 0.3, 0.3); + glColor3f(0, 0, 0); + for Pet := 0 to High(ATrack) do begin + if ((ATrack[Pet].Status div 1) and 1) = 1 then begin + SetFontPos(25, Y + Pet*YSkip + 10); + SetFontSize(5); + glPrint('N'); + end; + if ((ATrack[Pet].Status div 2) and 1) = 1 then begin + SetFontPos(40, Y + Pet*YSkip + 10); + SetFontSize(5); + glPrint('L'); + end; + end; + + DrawLine(10, Y, 10, Bottom, 0, 0, 0); + DrawLine(60, Y, 60, Bottom, 0, 0, 0); + DrawLine(790, Y, 790, Bottom, 0, 0, 0); + + for Pet := 0 to Length(ATrack) do + DrawLine(10, Y+Pet*YSkip, 790, Y+Pet*YSkip, 0, 0, 0); + + for Pet := 0 to High(ATrack) do begin + SetFontPos(11, Y + 10 + Pet*YSkip); + SetFontSize(5); + glPrint(pchar(ATrack[Pet].Name)); + end; + + for Pet := 0 to High(ATrack) do + for Pet2 := 0 to High(ATrack[Pet].Note) do begin + if ATrack[Pet].Note[Pet2].EventType = 9 then + DrawQuad(60 + ATrack[Pet].Note[Pet2].Start/Len * 725, Y + (Pet+1)*YSkip - ATrack[Pet].Note[Pet2].Data1*35/127, 3, 3, ColR[Pet], ColG[Pet], ColB[Pet]); + if ATrack[Pet].Note[Pet2].EventType = 15 then + DrawLine(60 + ATrack[Pet].Note[Pet2].Start/Len * 725, Y + 0.75 * YSkip + Pet*YSkip, 60 + ATrack[Pet].Note[Pet2].Start/Len * 725, Y + YSkip + Pet*YSkip, ColR[Pet], ColG[Pet], ColB[Pet]); + end; + + // playing line + X := 60+MidiFile.GetCurrentTime/MidiFile.GetTrackLength*730; + DrawLine(X, Y, X, Bottom, 0.3, 0.3, 0.3); + + +end; + +procedure TScreenEditConvert.onHide; +begin + MidiOut.Close; + MidiOut.Free; +end; + +end. diff --git a/Game/Code/Screens/UScreenEditHeader.pas b/Game/Code/Screens/UScreenEditHeader.pas new file mode 100644 index 00000000..35d7840f --- /dev/null +++ b/Game/Code/Screens/UScreenEditHeader.pas @@ -0,0 +1,366 @@ +unit UScreenEditHeader; + +interface + +uses UMenu, SDL, USongs, UThemes; + +type + TScreenEditHeader = class(TMenu) + public + AktSong: TSong; + TextTitle: integer; + TextArtist: integer; + TextMp3: integer; + TextBackground: integer; + TextVideo: integer; + TextVideoGAP: integer; + TextRelative: integer; + TextResolution: integer; + TextNotesGAP: integer; + TextStart: integer; + TextGAP: integer; + TextBPM: integer; + StaticTitle: integer; + StaticArtist: integer; + StaticMp3: integer; + StaticBackground: integer; + StaticVideo: integer; + StaticVideoGAP: integer; + StaticRelative: integer; + StaticResolution: integer; + StaticNotesGAP: integer; + StaticStart: integer; + StaticGAP: integer; + StaticBPM: integer; + Sel: array[0..11] of boolean; + procedure SetRoundButtons; + + constructor Create; override; + procedure onShow; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; +{ function Draw: boolean; override; + procedure Finish;} + end; + +implementation + +uses UGraphic, UMusic, SysUtils, UFiles, USkins; + +function TScreenEditHeader.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + T: integer; +begin + Result := true; + If (PressedDown) Then begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE : + begin +// Music.PlayBack; +// FadeTo(@MainScreen); + Result := false; + end; + + SDLK_RETURN: + begin + if Interaction = 1 then begin +// Save; + end; + end; + + SDLK_RIGHT: + begin + case Interaction of + 0..0: InteractNext; + 1: Interaction := 0; + end; + end; + + SDLK_LEFT: + begin + case Interaction of + 0: Interaction := 1; + 1..1: InteractPrev; + end; + end; + + SDLK_DOWN: + begin + case Interaction of + 0..1: Interaction := 2; + 2..12: InteractNext; + 13: Interaction := 0; + end; + end; + + SDLK_UP: + begin + case Interaction of + 0..1: Interaction := 13; + 2: Interaction := 0; + 3..13: InteractPrev; + end; + end; + + SDLK_BACKSPACE: + begin + T := Interaction - 2 + TextTitle; + if (Interaction >= 2) and (Interaction <= 13) and (Length(Text[T].Text) >= 1) then begin + Text[T].DeleteLastL; + SetRoundButtons; + end; + end; + + end; + case ScanCode of + 32..255: + begin + if (Interaction >= 2) and (Interaction <= 13) then begin + Text[Interaction - 2 + TextTitle].Text := + Text[Interaction - 2 + TextTitle].Text + chr(ScanCode); + SetRoundButtons; + end; + end; + end; + end; +end; + +constructor TScreenEditHeader.Create; +begin + inherited Create; + + AddButton(40, 20, 100, 40, Skin.GetTextureFileName('ButtonF')); + AddButtonText(15, 5, 'Open'); + + AddButton(160, 20, 100, 40, Skin.GetTextureFileName('ButtonF')); + AddButtonText(20, 5, 'Save'); + + AddBox(80, 60, 640, 550); + + AddText(160, 110 + 0*30, 0, 10, 0, 0, 0, 'Title:'); + AddText(160, 110 + 1*30, 0, 10, 0, 0, 0, 'Artist:'); + AddText(160, 110 + 2*30, 0, 10, 0, 0, 0, 'MP3:'); + + AddText(160, 110 + 4*30, 0, 10, 0, 0, 0, 'Background:'); + AddText(160, 110 + 5*30, 0, 10, 0, 0, 0, 'Video:'); + AddText(160, 110 + 6*30, 0, 10, 0, 0, 0, 'VideoGAP:'); + + AddText(160, 110 + 8*30, 0, 10, 0, 0, 0, 'Relative:'); + AddText(160, 110 + 9*30, 0, 10, 0, 0, 0, 'Resolution:'); + AddText(160, 110 + 10*30, 0, 10, 0, 0, 0, 'NotesGAP:'); + + AddText(160, 110 + 12*30, 0, 10, 0, 0, 0, 'Start:'); + AddText(160, 110 + 13*30, 0, 10, 0, 0, 0, 'GAP:'); + AddText(160, 110 + 14*30, 0, 10, 0, 0, 0, 'BPM:'); + + TextTitle := AddText(340, 110 + 0*30, 0, 10, 0, 0, 0, ''); + TextArtist := AddText(340, 110 + 1*30, 0, 10, 0, 0, 0, ''); + TextMp3 := AddText(340, 110 + 2*30, 0, 10, 0, 0, 0, ''); + + TextBackground := AddText(340, 110 + 4*30, 0, 10, 0, 0, 0, ''); + TextVideo := AddText(340, 110 + 5*30, 0, 10, 0, 0, 0, ''); + TextVideoGAP := AddText(340, 110 + 6*30, 0, 10, 0, 0, 0, ''); + + TextRelative := AddText(340, 110 + 8*30, 0, 10, 0, 0, 0, ''); + TextResolution := AddText(340, 110 + 9*30, 0, 10, 0, 0, 0, ''); + TextNotesGAP := AddText(340, 110 + 10*30, 0, 10, 0, 0, 0, ''); + + TextStart := AddText(340, 110 + 12*30, 0, 10, 0, 0, 0, ''); + TextGAP := AddText(340, 110 + 13*30, 0, 10, 0, 0, 0, ''); + TextBPM := AddText(340, 110 + 14*30, 0, 10, 0, 0, 0, ''); + + StaticTitle := AddStatic(130, 115 + 0*30, 20, 20, 1, 1, 1, 'RoundButton', 'BMP', 'Transparent', $FF00FF); + StaticArtist := AddStatic(130, 115 + 1*30, 20, 20, 1, 1, 1, 'RoundButton', 'BMP', 'Transparent', $FF00FF); + StaticMp3 := AddStatic(130, 115 + 2*30, 20, 20, 1, 1, 1, 'RoundButton', 'BMP', 'Transparent', $FF00FF); + StaticBackground := AddStatic(130, 115 + 4*30, 20, 20, 1, 1, 1, 'RoundButton', 'BMP', 'Transparent', $FF00FF); + StaticVideo := AddStatic(130, 115 + 5*30, 20, 20, 1, 1, 1, 'RoundButton', 'BMP', 'Transparent', $FF00FF); + StaticVideoGAP := AddStatic(130, 115 + 6*30, 20, 20, 1, 1, 1, 'RoundButton', 'BMP', 'Transparent', $FF00FF); + StaticRelative := AddStatic(130, 115 + 8*30, 20, 20, 1, 1, 1, 'RoundButton', 'BMP', 'Transparent', $FF00FF); + StaticResolution := AddStatic(130, 115 + 9*30, 20, 20, 1, 1, 1, 'RoundButton', 'BMP', 'Transparent', $FF00FF); + StaticNotesGAP := AddStatic(130, 115 + 10*30, 20, 20, 1, 1, 1, 'RoundButton', 'BMP', 'Transparent', $FF00FF); + StaticStart := AddStatic(130, 115 + 12*30, 20, 20, 1, 1, 1, 'RoundButton', 'BMP', 'Transparent', $FF00FF); + StaticGAP := AddStatic(130, 115 + 13*30, 20, 20, 1, 1, 1, 'RoundButton', 'BMP', 'Transparent', $FF00FF); + StaticBPM := AddStatic(130, 115 + 14*30, 20, 20, 1, 1, 1, 'RoundButton', 'BMP', 'Transparent', $FF00FF); + + AddInteraction(iText, TextTitle); + AddInteraction(iText, TextArtist); + AddInteraction(iText, TextMp3); + AddInteraction(iText, TextBackground); + AddInteraction(iText, TextVideo); + AddInteraction(iText, TextVideoGAP); + AddInteraction(iText, TextRelative); + AddInteraction(iText, TextResolution); + AddInteraction(iText, TextNotesGAP); + AddInteraction(iText, TextStart); + AddInteraction(iText, TextGAP); + AddInteraction(iText, TextBPM); +end; + +procedure TScreenEditHeader.onShow; +begin +{ if FileExists(FileName) then begin // load file + AktSong.FileName := FileName; + SkanujPlik(AktSong); + + SetLength(TrueBoolStrs, 1); + TrueBoolStrs[0] := 'yes'; + SetLength(FalseBoolStrs, 1); + FalseBoolStrs[0] := 'no'; + + Text[TextTitle].Text := AktSong.Title; + Text[TextArtist].Text := AktSong.Artist; + Text[TextMP3].Text := AktSong.Mp3; + Text[TextBackground].Text := AktSong.Background; + Text[TextVideo].Text := AktSong.Video; + Text[TextVideoGAP].Text := FloatToStr(AktSong.VideoGAP); + Text[TextRelative].Text := BoolToStr(AktSong.Relative, true); + Text[TextResolution].Text := IntToStr(AktSong.Resolution); + Text[TextNotesGAP].Text := IntToStr(AktSong.NotesGAP); + Text[TextStart].Text := FloatToStr(AktSong.Start); + Text[TextGAP].Text := FloatToStr(AktSong.GAP); + Text[TextBPM].Text := FloatToStr(AktSong.BPM[0].BPM); + SetRoundButtons; + end;} + + Interaction := 0; +end; + +(*function TScreenEdit.Draw: boolean; +var + Min: integer; + Sec: integer; + Tekst: string; + Pet: integer; + AktBeat: integer; +begin +{ glClearColor(1,1,1,1); + + // control music + if PlaySentence then begin + // stop the music + if (Music.Position > PlayStopTime) then begin + Music.Stop; + PlaySentence := false; + end; + + // click + if (Click) and (PlaySentence) then begin + AktBeat := Floor(AktSong.BPM[0].BPM * (Music.Position - AktSong.GAP / 1000) / 60); + Text[TextDebug].Text := IntToStr(AktBeat); + if AktBeat <> LastClick then begin + for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then begin + Music.PlayClick; + LastClick := AktBeat; + end; + end; + end; // click + end; // if PlaySentence + + Text[TextSentence].Text := IntToStr(Czesci[0].Akt + 1) + ' / ' + IntToStr(Czesci[0].Ilosc); + Text[TextNote].Text := IntToStr(AktNuta + 1) + ' / ' + IntToStr(Czesci[0].Czesc[Czesci[0].Akt].IlNut); + + // Song info + Text[TextBPM].Text := FloatToStr(AktSong.BPM[0].BPM / 4); + Text[TextGAP].Text := FloatToStr(AktSong.GAP); + + // Note info + Text[TextNStart].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + Text[TextNDlugosc].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + Text[TextNTon].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton); + Text[TextNText].Text := Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst; + + // draw static menu + inherited Draw; + + // draw notes + SingDrawNoteLines(20, 300, 780, 15); + SingDrawBeatDelimeters(40, 300, 760, 0); + SingDrawCzesc(40, 405, 760, 0); + + // draw text + Lyric.Draw;} + +end;*) + +procedure TScreenEditHeader.SetRoundButtons; +begin + if Length(Text[TextTitle].Text) > 0 then Static[StaticTitle].Visible := true + else Static[StaticTitle].Visible := false; + + if Length(Text[TextArtist].Text) > 0 then Static[StaticArtist].Visible := true + else Static[StaticArtist].Visible := false; + + if Length(Text[TextMp3].Text) > 0 then Static[StaticMp3].Visible := true + else Static[StaticMp3].Visible := false; + + if Length(Text[TextBackground].Text) > 0 then Static[StaticBackground].Visible := true + else Static[StaticBackground].Visible := false; + + if Length(Text[TextVideo].Text) > 0 then Static[StaticVideo].Visible := true + else Static[StaticVideo].Visible := false; + + try + StrToFloat(Text[TextVideoGAP].Text); + if StrToFloat(Text[TextVideoGAP].Text)<> 0 then Static[StaticVideoGAP].Visible := true + else Static[StaticVideoGAP].Visible := false; + except + Static[StaticVideoGAP].Visible := false; + end; + + if LowerCase(Text[TextRelative].Text) = 'yes' then Static[StaticRelative].Visible := true + else Static[StaticRelative].Visible := false; + + try + StrToInt(Text[TextResolution].Text); + if (StrToInt(Text[TextResolution].Text) <> 0) and (StrToInt(Text[TextResolution].Text) >= 1) + then Static[StaticResolution].Visible := true + else Static[StaticResolution].Visible := false; + except + Static[StaticResolution].Visible := false; + end; + + try + StrToInt(Text[TextNotesGAP].Text); + Static[StaticNotesGAP].Visible := true; + except + Static[StaticNotesGAP].Visible := false; + end; + + // start + try + StrToFloat(Text[TextStart].Text); + if (StrToFloat(Text[TextStart].Text) > 0) then Static[StaticStart].Visible := true + else Static[StaticStart].Visible := false; + except + Static[StaticStart].Visible := false; + end; + + // GAP + try + StrToFloat(Text[TextGAP].Text); + Static[StaticGAP].Visible := true; + except + Static[StaticGAP].Visible := false; + end; + + // BPM + try + StrToFloat(Text[TextBPM].Text); + if (StrToFloat(Text[TextBPM].Text) > 0) then Static[StaticBPM].Visible := true + else Static[StaticBPM].Visible := false; + except + Static[StaticBPM].Visible := false; + end; + +end; + +(*procedure TScreenEdit.Finish; +begin +// +end;*) + +end. diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas new file mode 100644 index 00000000..a105ec8b --- /dev/null +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -0,0 +1,1371 @@ +unit UScreenEditSub; + +interface + +uses UMenu, UMusic, SDL, SysUtils, UFiles, UTime, USongs, UIni, ULog, USmpeg, UTexture, UMenuText, + ULyrics, Math, OpenGL12, UThemes, MidiOut; + +type + TScreenEditSub = class(TMenu) + private + //Variable is True if no SOng is loaded + Error: Boolean; + + TextNote: integer; + TextSentence: integer; + TextTitle: integer; + TextArtist: integer; + TextMp3: integer; + TextBPM: integer; + TextGAP: integer; + TextDebug: integer; + TextNStart: integer; + TextNDlugosc: integer; + TextNTon: integer; + TextNText: integer; + AktNuta: integer; + PlaySentence: boolean; + PlaySentenceMidi: boolean; + PlayStopTime: real; + LastClick: integer; + Click: boolean; + CopySrc: integer; + + MidiOut: TMidiOutput; + MidiStart: real; + MidiStop: real; + MidiTime: real; + MidiPos: real; + MidiLastNote: integer; + + TextEditMode: boolean; + + procedure NewBeat; + procedure CzesciDivide; + procedure CzesciMultiply; + procedure LyricsCapitalize; + procedure LyricsCorrectSpaces; + procedure FixTimings; + procedure DivideSentence; + procedure JoinSentence; + procedure DivideNote; + procedure DeleteNote; + procedure TransposeNote(Transpose: integer); + procedure ChangeWholeTone(Tone: integer); + procedure MoveAllToEnd(Move: integer); + procedure MoveTextToRight; + procedure MarkSrc; + procedure PasteText; + procedure CopySentence(Src, Dst: integer); + procedure CopySentences(Src, Dst, Num: integer); + //Note Name Mod + function GetNoteName(Note: Integer): String; + public + Tex_Background: TTexture; + FadeOut: boolean; + Path: string; + FileName: string; + constructor Create; override; + procedure onShow; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function ParseInputEditText(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; + function Draw: boolean; override; + procedure onHide; override; + end; + +implementation +uses UGraphic, UDraw, UMain, USkins, ULanguage; + +// Method for input parsing. If False is returned, GetNextWindow +// should be checked to know the next window to load; +function TScreenEditSub.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + SDL_ModState: Word; + R: real; +begin + Result := true; + + if TextEditMode then begin + Result := ParseInputEditText(PressedKey, ScanCode, PressedDown); + end else begin + + SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT {+ KMOD_CAPS}); + + If (PressedDown) then begin // Key Down + case PressedKey of + SDLK_ESCAPE, + SDLK_BACKSPACE: + begin + FadeTo(@ScreenSong); + end; + + SDLK_Q: + begin + Result := false; + end; + + SDLK_BACKQUOTE: + begin + // Increase Note Length (same as Alt + Right) + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Inc(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + end; + + SDLK_EQUALS: + begin + // Increase BPM + if SDL_ModState = 0 then + AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 5) + 1) / 5; // (1/20) + if SDL_ModState = KMOD_LSHIFT then + AktSong.BPM[0].BPM := AktSong.BPM[0].BPM + 4; // (1/1) + if SDL_ModState = KMOD_LCTRL then + AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 25) + 1) / 25; // (1/100) + end; + + SDLK_MINUS: + begin + // Decrease BPM + if SDL_ModState = 0 then + AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 5) - 1) / 5; + if SDL_ModState = KMOD_LSHIFT then + AktSong.BPM[0].BPM := AktSong.BPM[0].BPM - 4; + if SDL_ModState = KMOD_LCTRL then + AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 25) - 1) / 25; + end; + + SDLK_0: + begin + // Increase GAP + if SDL_ModState = 0 then + AktSong.GAP := AktSong.GAP + 10; + if SDL_ModState = KMOD_LSHIFT then + AktSong.GAP := AktSong.GAP + 1000; + end; + + SDLK_9: + begin + // Decrease GAP + if SDL_ModState = 0 then + AktSong.GAP := AktSong.GAP - 10; + if SDL_ModState = KMOD_LSHIFT then + AktSong.GAP := AktSong.GAP - 1000; + end; + + SDLK_KP_PLUS: + begin + // Increase tone of all notes + if SDL_ModState = 0 then + ChangeWholeTone(1); + if SDL_ModState = KMOD_LSHIFT then + ChangeWholeTone(12); + end; + + SDLK_KP_MINUS: + begin + // Decrease tone of all notes + if SDL_ModState = 0 then + ChangeWholeTone(-1); + if SDL_ModState = KMOD_LSHIFT then + ChangeWholeTone(-12); + end; + + SDLK_SLASH: + begin + if SDL_ModState = 0 then begin + // Insert start of sentece + if AktNuta > 0 then + DivideSentence; + end; + + if SDL_ModState = KMOD_LSHIFT then begin + // Join next sentence with current + if Czesci[0].Akt < Czesci[0].High then + JoinSentence; + end; + + if SDL_ModState = KMOD_LCTRL then begin + // divide note + DivideNote; + end; + + end; + + SDLK_S: + begin + // Save Song + if SDL_ModState = KMOD_LSHIFT then + SaveSong(AktSong, Czesci[0], Path + FileName, true) + else + SaveSong(AktSong, Czesci[0], Path + FileName, false); + + {if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL + KMOD_LALT then + // Save Song + SaveSongDebug(AktSong, Czesci[0], 'C:\song.asm', false);} + + end; + + SDLK_D: + begin + // Divide lengths by 2 + CzesciDivide; + end; + + SDLK_M: + begin + // Multiply lengths by 2 + CzesciMultiply; + end; + + SDLK_C: + begin + // Capitalize letter at the beginning of line + if SDL_ModState = 0 then + LyricsCapitalize; + + // Correct spaces + if SDL_ModState = KMOD_LSHIFT then + LyricsCorrectSpaces; + + // Copy sentence + if SDL_ModState = KMOD_LCTRL then + MarkSrc; + end; + + SDLK_V: + begin + // Paste text + if SDL_ModState = KMOD_LCTRL then begin + if Czesci[0].Czesc[Czesci[0].Akt].IlNut >= Czesci[0].Czesc[CopySrc].IlNut then + PasteText + else + beep; + end; + + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + CopySentence(CopySrc, Czesci[0].Akt); + end; + end; + + SDLK_4: + begin + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + CopySentence(CopySrc, Czesci[0].Akt); + CopySentence(CopySrc+1, Czesci[0].Akt+1); + CopySentence(CopySrc+2, Czesci[0].Akt+2); + CopySentence(CopySrc+3, Czesci[0].Akt+3); + end; + + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then begin + CopySentences(CopySrc, Czesci[0].Akt, 4); + end; + end; + SDLK_5: + begin + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + CopySentence(CopySrc, Czesci[0].Akt); + CopySentence(CopySrc+1, Czesci[0].Akt+1); + CopySentence(CopySrc+2, Czesci[0].Akt+2); + CopySentence(CopySrc+3, Czesci[0].Akt+3); + CopySentence(CopySrc+4, Czesci[0].Akt+4); + end; + + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then begin + CopySentences(CopySrc, Czesci[0].Akt, 5); + end; + end; + + SDLK_T: + begin + // Fixes timings between sentences + FixTimings; + end; + + SDLK_F4: + begin + // Enter Text Edit Mode + TextEditMode := true; + end; + + SDLK_P: + begin + if SDL_ModState = 0 then begin + // Play Sentence + PlaySentenceMidi := false; + Click := true; + Music.Stop; + R := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + if R <= Music.Length then begin + Music.MoveTo(R); + PlayStopTime := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + PlaySentence := true; + Music.Play; + LastClick := -100; + end; + end; + + if SDL_ModState = KMOD_LSHIFT then begin + PlaySentenceMidi := true; + + MidiTime := USTime.GetTime; + MidiStart := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + MidiStop := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + + LastClick := -100; + end; + if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL then begin + PlaySentenceMidi := true; + MidiTime := USTime.GetTime; + MidiStart := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + MidiStop := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + LastClick := -100; + + PlaySentence := true; + Click := true; + Music.Stop; + Music.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote)+0{-0.10}); + PlayStopTime := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec)+0; + Music.Play; + LastClick := -100; + end; + end; + + SDLK_SPACE: + begin + //Thx to f1fth_freed0m for his One Note Midi Playback + if SDL_ModState = KMOD_LSHIFT then begin //Play One Notes Midi [Shift + Space] + PlaySentenceMidi := true; + + MidiTime := USTime.GetTime; + MidiStart := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + MidiStop := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + LastClick := -100; + end + + else if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL then begin + //Play One Notes Midi + MP3 [CTRL + Shift + Space] + PlaySentenceMidi := true; + MidiTime := USTime.GetTime; + MidiStart := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + MidiStop := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + LastClick := -100; + + PlaySentence := true; + Click := true; + Music.Stop; + Music.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start)); + PlayStopTime := (GetTimeFromBeat( + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc)); + Music.Play; + LastClick := -100; + end + + Else + begin + // Play One Notes MP3 [Space] + PlaySentenceMidi := false; // stop midi + PlaySentence := true; + Click := false; + Music.Stop; + + Music.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start)); + PlayStopTime := (GetTimeFromBeat( + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc)); + Music.Play; + LastClick := -100; + end; + end; + + SDLK_RETURN: + begin + end; + + SDLK_LCTRL: + begin + end; + + SDLK_DELETE: + begin + if SDL_ModState = KMOD_LCTRL then begin + // moves text to right in current sentence + DeleteNote; + end; + end; + + SDLK_PERIOD: + begin + // moves text to right in current sentence + MoveTextToRight; + end; + + SDLK_RIGHT: + begin + // right + if SDL_ModState = 0 then begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Inc(AktNuta); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].IlNut then AktNuta := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.Selected := AktNuta; + end; + + // ctrl + right + if SDL_ModState = KMOD_LCTRL then begin + if Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc > 1 then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + if AktNuta = 0 then begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Start); + Inc(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + end; + end; + end; + + // shift + right + if SDL_ModState = KMOD_LSHIFT then begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + if AktNuta = 0 then begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Start); + Inc(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + end; + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Inc(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + end; + + // alt + right + if SDL_ModState = KMOD_LALT then begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Inc(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + end; + + // alt + ctrl + shift + right = move all from cursor to right + if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then begin + MoveAllToEnd(1); + end; + + end; + + SDLK_LEFT: + begin + // left + if SDL_ModState = 0 then begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Dec(AktNuta); + if AktNuta = -1 then AktNuta := Czesci[0].Czesc[Czesci[0].Akt].HighNut; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.Selected := AktNuta; + end; + + // ctrl + left + if SDL_ModState = KMOD_LCTRL then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + if AktNuta = 0 then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Start); + Dec(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + end; + end; + + // shift + left + if SDL_ModState = KMOD_LSHIFT then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + + // resizing sentences + if AktNuta = 0 then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Start); + Dec(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + end; + + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Dec(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + + end; + + // alt + left + if SDL_ModState = KMOD_LALT then begin + if Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc > 1 then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Dec(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + end; + end; + + // alt + ctrl + shift + right = move all from cursor to left + if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then begin + MoveAllToEnd(-1); + end; + + end; + + SDLK_DOWN: + begin + // skip to next sentence + if SDL_ModState = 0 then begin + MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); + PlaySentenceMidi := false; + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Inc(Czesci[0].Akt); + AktNuta := 0; + if Czesci[0].Akt > Czesci[0].High then Czesci[0].Akt := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + + Lyric.AddCzesc(Czesci[0].Akt); + Lyric.Selected := 0; + Music.Stop; + PlaySentence := false; + end; + + // decrease tone + if SDL_ModState = KMOD_LCTRL then begin + TransposeNote(-1); + end; + + end; + + SDLK_UP: + begin + // skip to previous sentence + if SDL_ModState = 0 then begin + MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); + PlaySentenceMidi := false; + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Dec(Czesci[0].Akt); + AktNuta := 0; + if Czesci[0].Akt = -1 then Czesci[0].Akt := Czesci[0].High; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + + Lyric.AddCzesc(Czesci[0].Akt); + Lyric.Selected := 0; + Music.Stop; + PlaySentence := false; + end; + + // increase tone + if SDL_ModState = KMOD_LCTRL then begin + TransposeNote(1); + end; + end; + + // Golden Note Patch + SDLK_G: + begin + case Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc of + 0, 1: Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 2; + 2: Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 1; + end; // case + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Freestyle := False; + end; + + // Freestyle Note Patch + SDLK_F: + begin + case Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc of + 0: + begin; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 1; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Freestyle := False; + end; + 1,2: + begin; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Freestyle := True; + end; + end; // case + + end; + + + end; + end; + end; // if +end; + +function TScreenEditSub.ParseInputEditText(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + SDL_ModState: Word; +begin + // used when in Text Edit Mode + Result := true; + + SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT {+ KMOD_CAPS}); + + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_ESCAPE: + begin + FadeTo(@ScreenSong); + end; + SDLK_F4, SDLK_RETURN: + begin + // Exit Text Edit Mode + TextEditMode := false; + end; + SDLK_0..SDLK_9, SDLK_A..SDLK_Z, SDLK_SPACE, SDLK_MINUS, SDLK_EXCLAIM, SDLK_COMMA, SDLK_SLASH, SDLK_ASTERISK, SDLK_QUESTION, SDLK_QUOTE, SDLK_QUOTEDBL, SDLK_RIGHTBRACKET, SDLK_HASH: + begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst := + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst + chr(ScanCode); + + Lyric.ChangeCurText(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst); + end; + SDLK_BACKSPACE: + begin + Delete(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst, + Length(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst), 1); + + Lyric.ChangeCurText(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst); + end; + SDLK_RIGHT: + begin + // right + if SDL_ModState = 0 then begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Inc(AktNuta); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].IlNut then AktNuta := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.Selected := AktNuta; + end; + end; + SDLK_LEFT: + begin + // left + if SDL_ModState = 0 then begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Dec(AktNuta); + if AktNuta = -1 then AktNuta := Czesci[0].Czesc[Czesci[0].Akt].HighNut; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.Selected := AktNuta; + end; + end; + end; + end; +end; + +procedure TScreenEditSub.NewBeat; +begin + // click +{ for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = Czas.AktBeat) then begin + // old} +// Music.PlayClick; +end; + +procedure TScreenEditSub.CzesciDivide; +var + C: integer; + N: integer; +begin + AktSong.BPM[0].BPM := AktSong.BPM[0].BPM / 2; + for C := 0 to Czesci[0].High do begin + Czesci[0].Czesc[C].Start := Czesci[0].Czesc[C].Start div 2; + Czesci[0].Czesc[C].StartNote := Czesci[0].Czesc[C].StartNote div 2; + Czesci[0].Czesc[C].Koniec := Czesci[0].Czesc[C].Koniec div 2; + for N := 0 to Czesci[0].Czesc[C].HighNut do begin + Czesci[0].Czesc[C].Nuta[N].Start := Czesci[0].Czesc[C].Nuta[N].Start div 2; + Czesci[0].Czesc[C].Nuta[N].Dlugosc := Round(Czesci[0].Czesc[C].Nuta[N].Dlugosc / 2); + end; // N + end; // C +end; + +procedure TScreenEditSub.CzesciMultiply; +var + C: integer; + N: integer; +begin + AktSong.BPM[0].BPM := AktSong.BPM[0].BPM * 2; + for C := 0 to Czesci[0].High do begin + Czesci[0].Czesc[C].Start := Czesci[0].Czesc[C].Start * 2; + Czesci[0].Czesc[C].StartNote := Czesci[0].Czesc[C].StartNote * 2; + Czesci[0].Czesc[C].Koniec := Czesci[0].Czesc[C].Koniec * 2; + for N := 0 to Czesci[0].Czesc[C].HighNut do begin + Czesci[0].Czesc[C].Nuta[N].Start := Czesci[0].Czesc[C].Nuta[N].Start * 2; + Czesci[0].Czesc[C].Nuta[N].Dlugosc := Czesci[0].Czesc[C].Nuta[N].Dlugosc * 2; + end; // N + end; // C +end; + +procedure TScreenEditSub.LyricsCapitalize; +var + C: integer; + N: integer; // temporary + S: string; +begin + // temporary +{ for C := 0 to Czesci[0].High do + for N := 0 to Czesci[0].Czesc[C].HighNut do + Czesci[0].Czesc[C].Nuta[N].Tekst := AnsiLowerCase(Czesci[0].Czesc[C].Nuta[N].Tekst);} + + for C := 0 to Czesci[0].High do begin + S := AnsiUpperCase(Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 1, 1)); + S := S + Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 2, Length(Czesci[0].Czesc[C].Nuta[0].Tekst)-1); + Czesci[0].Czesc[C].Nuta[0].Tekst := S; + end; // C +end; + +procedure TScreenEditSub.LyricsCorrectSpaces; +var + C: integer; + N: integer; +begin + for C := 0 to Czesci[0].High do begin + // correct starting spaces in the first word + while Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 1, 1) = ' ' do + Czesci[0].Czesc[C].Nuta[0].Tekst := Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 2, 100); + + // move spaces on the start to the end of the previous note + for N := 1 to Czesci[0].Czesc[C].HighNut do begin + while (Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, 1, 1) = ' ') do begin + Czesci[0].Czesc[C].Nuta[N].Tekst := Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, 2, 100); + Czesci[0].Czesc[C].Nuta[N-1].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst + ' '; + end; + end; // N + + // correct '-' to '- ' + for N := 0 to Czesci[0].Czesc[C].HighNut do begin + if Czesci[0].Czesc[C].Nuta[N].Tekst = '-' then + Czesci[0].Czesc[C].Nuta[N].Tekst := '- '; + end; // N + + // add space to the previous note when the current word is '- ' + for N := 1 to Czesci[0].Czesc[C].HighNut do begin + if Czesci[0].Czesc[C].Nuta[N].Tekst = '- ' then + Czesci[0].Czesc[C].Nuta[N-1].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst + ' '; + end; // N + + // correct too many spaces at the end of note + for N := 0 to Czesci[0].Czesc[C].HighNut do begin + while Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, Length(Czesci[0].Czesc[C].Nuta[N].Tekst)-1, 2) = ' ' do + Czesci[0].Czesc[C].Nuta[N].Tekst := Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, 1, Length(Czesci[0].Czesc[C].Nuta[N].Tekst)-1); + end; // N + + // and correct if there is no space at the end of sentence + N := Czesci[0].Czesc[C].HighNut; + if Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, Length(Czesci[0].Czesc[C].Nuta[N].Tekst), 1) <> ' ' then + Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[C].Nuta[N].Tekst + ' '; + + end; // C +end; + +procedure TScreenEditSub.FixTimings; +var + C: integer; + S: integer; + Min: integer; + Max: integer; +begin + for C := 1 to Czesci[0].High do begin + with Czesci[0].Czesc[C-1] do begin + Min := Nuta[HighNut].Start + Nuta[HighNut].Dlugosc; + Max := Czesci[0].Czesc[C].StartNote; + case (Max - Min) of + 0: S := Max; + 1: S := Max; + 2: S := Max - 1; + 3: S := Max - 2; + else + if ((Max - Min) > 4) then + S := Min + 2 + else + S := Max; + end; // case + + Czesci[0].Czesc[C].Start := S; + end; // with + end; // for +end; + +procedure TScreenEditSub.DivideSentence; +var + C: integer; + CStart: integer; + CNew: integer; + CLen: integer; + N: integer; + NStart: integer; + NHigh: integer; + NNewL: integer; +begin + // increase sentence length by 1 + CLen := Length(Czesci[0].Czesc); + SetLength(Czesci[0].Czesc, CLen + 1); + Inc(Czesci[0].Ilosc); + Inc(Czesci[0].High); + + // move needed sentences to one forward. newly has the copy of divided sentence + CStart := Czesci[0].Akt; + for C := CLen-1 downto CStart do + Czesci[0].Czesc[C+1] := Czesci[0].Czesc[C]; + + // clear and set new sentence + CNew := CStart + 1; + NStart := AktNuta; + Czesci[0].Czesc[CNew].Start := Czesci[0].Czesc[CStart].Nuta[NStart].Start; + Czesci[0].Czesc[CNew].StartNote := Czesci[0].Czesc[CStart].Nuta[NStart].Start; + Czesci[0].Czesc[CNew].Lyric := ''; + Czesci[0].Czesc[CNew].LyricWidth := 0; + Czesci[0].Czesc[CNew].Koniec := 0; + Czesci[0].Czesc[CNew].BaseNote := 0; // 0.5.0: we modify it later in this procedure + Czesci[0].Czesc[CNew].IlNut := 0; + Czesci[0].Czesc[CNew].HighNut := -1; + SetLength(Czesci[0].Czesc[CNew].Nuta, 0); + + // move right notes to new sentences + NHigh := Czesci[0].Czesc[CStart].HighNut; + for N := NStart to NHigh do begin + NNewL := Czesci[0].Czesc[CNew].IlNut; + SetLength(Czesci[0].Czesc[CNew].Nuta, NNewL + 1); + Czesci[0].Czesc[CNew].Nuta[NNewL] := Czesci[0].Czesc[CStart].Nuta[N]; + + // increase sentence counters + Inc(Czesci[0].Czesc[CNew].IlNut); + Inc(Czesci[0].Czesc[CNew].HighNut); + Czesci[0].Czesc[CNew].Koniec := Czesci[0].Czesc[CNew].Nuta[NNewL].Start + + Czesci[0].Czesc[CNew].Nuta[NNewL].Dlugosc; + end; + + // clear old notes and set sentence counters + Czesci[0].Czesc[CStart].HighNut := NStart - 1; + Czesci[0].Czesc[CStart].IlNut := Czesci[0].Czesc[CStart].HighNut + 1; + Czesci[0].Czesc[CStart].Koniec := Czesci[0].Czesc[CStart].Nuta[NStart-1].Start + + Czesci[0].Czesc[CStart].Nuta[NStart-1].Dlugosc; + SetLength(Czesci[0].Czesc[CStart].Nuta, Czesci[0].Czesc[CStart].IlNut); + + // 0.5.0: modify BaseNote + Czesci[0].Czesc[CNew].BaseNote := 120; + for N := 0 to Czesci[0].Czesc[CNew].IlNut do + if Czesci[0].Czesc[CNew].Nuta[N].Ton < Czesci[0].Czesc[CNew].BaseNote then + Czesci[0].Czesc[CNew].BaseNote := Czesci[0].Czesc[CNew].Nuta[N].Ton; + + Czesci[0].Akt := Czesci[0].Akt + 1; + AktNuta := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.AddCzesc(Czesci[0].Akt); + +end; + +procedure TScreenEditSub.JoinSentence; +var + C: integer; + N: integer; + NStart: integer; + NDst: integer; +begin + C := Czesci[0].Akt; + + // set new sentence + NStart := Czesci[0].Czesc[C].IlNut; + Czesci[0].Czesc[C].IlNut := Czesci[0].Czesc[C].IlNut + Czesci[0].Czesc[C+1].IlNut; + Czesci[0].Czesc[C].HighNut := Czesci[0].Czesc[C].HighNut + Czesci[0].Czesc[C+1].IlNut; + SetLength(Czesci[0].Czesc[C].Nuta, Czesci[0].Czesc[C].IlNut); + + // move right notes to new sentences + for N := 0 to Czesci[0].Czesc[C+1].HighNut do begin + NDst := NStart + N; + Czesci[0].Czesc[C].Nuta[NDst] := Czesci[0].Czesc[C+1].Nuta[N]; + end; + + // increase sentence counters + NDst := Czesci[0].Czesc[C].HighNut; + Czesci[0].Czesc[C].Koniec := Czesci[0].Czesc[C].Nuta[NDst].Start + + Czesci[0].Czesc[C].Nuta[NDst].Dlugosc; + + // move needed sentences to one backward. + for C := Czesci[0].Akt + 1 to Czesci[0].High - 1 do + Czesci[0].Czesc[C] := Czesci[0].Czesc[C+1]; + + // increase sentence length by 1 + SetLength(Czesci[0].Czesc, Length(Czesci[0].Czesc) - 1); + Dec(Czesci[0].Ilosc); + Dec(Czesci[0].High); +end; + +procedure TScreenEditSub.DivideNote; +var + C: integer; + N: integer; + NLen: integer; +begin + C := Czesci[0].Akt; + + NLen := Czesci[0].Czesc[C].IlNut + 1; + SetLength(Czesci[0].Czesc[C].Nuta, NLen); + Inc(Czesci[0].Czesc[C].HighNut); + Inc(Czesci[0].Czesc[C].IlNut); + + // we copy all notes including selected one + for N := Czesci[0].Czesc[C].HighNut downto AktNuta+1 do begin + Czesci[0].Czesc[C].Nuta[N] := Czesci[0].Czesc[C].Nuta[N-1]; + end; + + // me slightly modify new note + Czesci[0].Czesc[C].Nuta[AktNuta].Dlugosc := 1; + Inc(Czesci[0].Czesc[C].Nuta[AktNuta+1].Start); + Dec(Czesci[0].Czesc[C].Nuta[AktNuta+1].Dlugosc); + Czesci[0].Czesc[C].Nuta[AktNuta+1].Tekst := '- '; + Czesci[0].Czesc[C].Nuta[AktNuta+1].Color := 0; +end; + +procedure TScreenEditSub.DeleteNote; +var + C: integer; + N: integer; + NLen: integer; +begin + C := Czesci[0].Akt; + + //Do Not delete Last Note + if (Czesci[0].High > 0) OR (Czesci[0].Czesc[C].HighNut > 0) then + begin + + // we copy all notes from the next to the selected one + for N := AktNuta+1 to Czesci[0].Czesc[C].HighNut do begin + Czesci[0].Czesc[C].Nuta[N-1] := Czesci[0].Czesc[C].Nuta[N]; + end; + + NLen := Czesci[0].Czesc[C].IlNut - 1; + + if (NLen > 0) then + begin + SetLength(Czesci[0].Czesc[C].Nuta, NLen); + Dec(Czesci[0].Czesc[C].HighNut); + Dec(Czesci[0].Czesc[C].IlNut); + + + // me slightly modify new note + if AktNuta > Czesci[0].Czesc[C].HighNut then Dec(AktNuta); + Czesci[0].Czesc[C].Nuta[AktNuta].Color := 1; + end + //Last Note of current Sentence Deleted - > Delete Sentence + else + begin + //Move all Sentences after the current to the Left + for N := C+1 to Czesci[0].High do + Czesci[0].Czesc[N-1] := Czesci[0].Czesc[N]; + + //Delete Last Sentence + SetLength(Czesci[0].Czesc, Czesci[0].High); + Czesci[0].High := High(Czesci[0].Czesc); + Czesci[0].Ilosc := Length(Czesci[0].Czesc); + + AktNuta := 0; + if (C > 0) then + Czesci[0].Akt := C - 1 + else + Czesci[0].Akt := 0; + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + end; + end; +end; + +procedure TScreenEditSub.TransposeNote(Transpose: integer); +begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton, Transpose); +end; + +procedure TScreenEditSub.ChangeWholeTone(Tone: integer); +var + C: integer; + N: integer; +begin + for C := 0 to Czesci[0].High do begin + Czesci[0].Czesc[C].BaseNote := Czesci[0].Czesc[C].BaseNote + Tone; + for N := 0 to Czesci[0].Czesc[C].HighNut do + Czesci[0].Czesc[C].Nuta[N].Ton := Czesci[0].Czesc[C].Nuta[N].Ton + Tone; + end; +end; + +procedure TScreenEditSub.MoveAllToEnd(Move: integer); +var + C: integer; + N: integer; + NStart: integer; +begin + for C := Czesci[0].Akt to Czesci[0].High do begin + NStart := 0; + if C = Czesci[0].Akt then NStart := AktNuta; + for N := NStart to Czesci[0].Czesc[C].HighNut do begin + Inc(Czesci[0].Czesc[C].Nuta[N].Start, Move); // move note start + + if N = 0 then begin // fix beginning + Inc(Czesci[0].Czesc[C].Start, Move); + Inc(Czesci[0].Czesc[C].StartNote, Move); + end; + + if N = Czesci[0].Czesc[C].HighNut then // fix ending + Inc(Czesci[0].Czesc[C].Koniec, Move); + + end; // for + end; // for +end; + +procedure TScreenEditSub.MoveTextToRight; +var + C: integer; + N: integer; + NHigh: integer; +begin +{ C := Czesci[0].Akt; + + for N := Czesci[0].Czesc[C].HighNut downto 1 do begin + Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst; + end; // for + + Czesci[0].Czesc[C].Nuta[0].Tekst := '- ';} + + C := Czesci[0].Akt; + NHigh := Czesci[0].Czesc[C].HighNut; + + // last word + Czesci[0].Czesc[C].Nuta[NHigh].Tekst := Czesci[0].Czesc[C].Nuta[NHigh-1].Tekst + Czesci[0].Czesc[C].Nuta[NHigh].Tekst; + + // other words + for N := NHigh - 1 downto AktNuta + 1 do begin + Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst; + end; // for + Czesci[0].Czesc[C].Nuta[AktNuta].Tekst := '- '; +end; + +procedure TScreenEditSub.MarkSrc; +begin + CopySrc := Czesci[0].Akt; +end; + +procedure TScreenEditSub.PasteText; +var + C: integer; + N: integer; +begin + C := Czesci[0].Akt; + + for N := 0 to Czesci[0].Czesc[CopySrc].HighNut do + Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[CopySrc].Nuta[N].Tekst; +end; + +procedure TScreenEditSub.CopySentence(Src, Dst: integer); +var + N: integer; + Time1: integer; + Time2: integer; + TD: integer; +begin + Time1 := Czesci[0].Czesc[Src].Nuta[0].Start; + Time2 := Czesci[0].Czesc[Dst].Nuta[0].Start; + TD := Time2-Time1; + + SetLength(Czesci[0].Czesc[Dst].Nuta, Czesci[0].Czesc[Src].IlNut); + Czesci[0].Czesc[Dst].IlNut := Czesci[0].Czesc[Src].IlNut; + Czesci[0].Czesc[Dst].HighNut := Czesci[0].Czesc[Src].HighNut; + for N := 0 to Czesci[0].Czesc[Src].HighNut do begin + Czesci[0].Czesc[Dst].Nuta[N].Tekst := Czesci[0].Czesc[Src].Nuta[N].Tekst; + Czesci[0].Czesc[Dst].Nuta[N].Dlugosc := Czesci[0].Czesc[Src].Nuta[N].Dlugosc; + Czesci[0].Czesc[Dst].Nuta[N].Ton := Czesci[0].Czesc[Src].Nuta[N].Ton; + Czesci[0].Czesc[Dst].Nuta[N].Start := Czesci[0].Czesc[Src].Nuta[N].Start + TD; + end; + N := Czesci[0].Czesc[Src].HighNut; + Czesci[0].Czesc[Dst].Koniec := Czesci[0].Czesc[Dst].Nuta[N].Start + Czesci[0].Czesc[Dst].Nuta[N].Dlugosc; +end; + +procedure TScreenEditSub.CopySentences(Src, Dst, Num: integer); +var + C: integer; +begin + // create place for new sentences + SetLength(Czesci[0].Czesc, Czesci[0].Ilosc + Num - 1); + + // moves sentences next to the destination + for C := Czesci[0].High downto Dst + 1 do begin + Czesci[0].Czesc[C + Num - 1] := Czesci[0].Czesc[C]; + end; + + // prepares new sentences: sets sentence start and create first note + for C := 1 to Num-1 do begin + Czesci[0].Czesc[Dst + C].Start := Czesci[0].Czesc[Dst + C - 1].StartNote + + (Czesci[0].Czesc[Src + C].StartNote - Czesci[0].Czesc[Src + C - 1].StartNote); + SetLength(Czesci[0].Czesc[Dst + C].Nuta, 1); + Czesci[0].Czesc[Dst + C].IlNut := 1; + Czesci[0].Czesc[Dst + C].HighNut := 0; + Czesci[0].Czesc[Dst + C].Nuta[0].Start := Czesci[0].Czesc[Dst + C].Start; + Czesci[0].Czesc[Dst + C].Nuta[0].Dlugosc := 1; + Czesci[0].Czesc[Dst + C].StartNote := Czesci[0].Czesc[Dst + C].Start; + Czesci[0].Czesc[Dst + C].Koniec := Czesci[0].Czesc[Dst + C].Start + 1; + end; + + // increase counters + Czesci[0].Ilosc := Czesci[0].Ilosc + Num - 1; + Czesci[0].High := Czesci[0].High + Num - 1; + + for C := 0 to Num-1 do + CopySentence(Src + C, Dst + C); +end; + + +constructor TScreenEditSub.Create; +begin + inherited Create; + SetLength(Player, 1); + + // linijka + AddStatic(20, 10, 80, 30, 0, 0, 0, Skin.GetTextureFileName('ButtonF'), 'JPG', 'Font Black'); + AddText(40, 17, 1, 6, 1, 1, 1, 'Line'); + TextSentence := AddText(120, 14, 1, 8, 0, 0, 0, '0 / 0'); + + // nuta + AddStatic(220, 10, 80, 30, 0, 0, 0, Skin.GetTextureFileName('ButtonF'), 'JPG', 'Font Black'); + AddText(242, 17, 1, 6, 1, 1, 1, 'Note'); + TextNote := AddText(320, 14, 1, 8, 0, 0, 0, '0 / 0'); + + // file info + AddStatic(150, 50, 500, 150, 0, 0, 0, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black'); + AddStatic(151, 52, 498, 146, 1, 1, 1, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black'); + AddText(180, 65, 0, 8, 0, 0, 0, 'Title:'); + AddText(180, 90, 0, 8, 0, 0, 0, 'Artist:'); + AddText(180, 115, 0, 8, 0, 0, 0, 'Mp3:'); + AddText(180, 140, 0, 8, 0, 0, 0, 'BPM:'); + AddText(180, 165, 0, 8, 0, 0, 0, 'GAP:'); + + TextTitle := AddText(250, 65, 0, 8, 0, 0, 0, 'a'); + TextArtist := AddText(250, 90, 0, 8, 0, 0, 0, 'b'); + TextMp3 := AddText(250, 115, 0, 8, 0, 0, 0, 'c'); + TextBPM := AddText(250, 140, 0, 8, 0, 0, 0, 'd'); + TextGAP := AddText(250, 165, 0, 8, 0, 0, 0, 'e'); + +{ AddInteraction(2, TextTitle); + AddInteraction(2, TextArtist); + AddInteraction(2, TextMp3); + AddInteraction(2, TextBPM); + AddInteraction(2, TextGAP);} + + // note info + AddText(20, 190, 0, 8, 0, 0, 0, 'Start:'); + AddText(20, 215, 0, 8, 0, 0, 0, 'Duration:'); + AddText(20, 240, 0, 8, 0, 0, 0, 'Tone:'); + AddText(20, 265, 0, 8, 0, 0, 0, 'Text:'); + + TextNStart := AddText(120, 190, 0, 8, 0, 0, 0, 'a'); + TextNDlugosc := AddText(120, 215, 0, 8, 0, 0, 0, 'b'); + TextNTon := AddText(120, 240, 0, 8, 0, 0, 0, 'c'); + TextNText := AddText(120, 265, 0, 8, 0, 0, 0, 'd'); + + // debug + TextDebug := AddText(30, 550, 0, 8, 0, 0, 0, ''); + +end; + +procedure TScreenEditSub.onShow; +begin + Log.LogStatus('Initializing', 'TEditScreen.onShow'); + + try + ResetSingTemp; + Error := not LoadSong(Path + FileName); + except + Error := True; + end; + + if Error then + begin + //Error Loading Song -> Go back to Song Screen and Show some Error Message + FadeTo(@ScreenSong); + ScreenPopupError.ShowPopup (Language.Translate('ERROR_CORRUPT_SONG')); + Exit; + end + else begin + MidiOut := TMidiOutput.Create(nil); + if Ini.Debug = 1 then + MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table + MidiOut.Open; + + Text[TextTitle].Text := AktSong.Title; + Text[TextArtist].Text := AktSong.Artist; + Text[TextMp3].Text := AktSong.Mp3; + + Czesci[0].Akt := 0; + AktNuta := 0; + Czesci[0].Czesc[0].Nuta[0].Color := 1; + + Music.Open(Path + AktSong.Mp3); + //Set Down Music Volume for Better hearability of Midi Sounds + //Music.SetVolume(40); + + Lyric.Clear; + Lyric.X := 400; + Lyric.Y := 500; + Lyric.Align := 1; + Lyric.Size := 14; + Lyric.ColR := 0; + Lyric.ColG := 0; + Lyric.ColB := 0; + Lyric.ColSR := Skin_FontHighlightR; + Lyric.ColSG := Skin_FontHighlightG; + Lyric.ColSB := Skin_FontHighlightB; + Lyric.Style := 0; + Lyric.AddCzesc(0); + Lyric.Selected := 0; + + NotesH := 7; + NotesW := 4; + + end; + +// Interaction := 0; + TextEditMode := false; +end; + +function TScreenEditSub.Draw: boolean; +var + Min: integer; + Sec: integer; + Tekst: string; + Pet: integer; + AktBeat: integer; +begin + glClearColor(1,1,1,1); + + // midi music + if PlaySentenceMidi then begin + MidiPos := USTime.GetTime - MidiTime + MidiStart; + + // stop the music + if (MidiPos > MidiStop) then begin + MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); + PlaySentenceMidi := false; + end; + + // click + AktBeat := Floor(GetMidBeat(MidiPos - AktSong.GAP / 1000)); + Text[TextDebug].Text := IntToStr(AktBeat); + + if AktBeat <> LastClick then begin + for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then begin + + LastClick := AktBeat; + if Pet > 0 then + MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet-1].Ton + 60, 127); + MidiOut.PutShort($91, Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Ton + 60, 127); + MidiLastNote := Pet; + + end; + end; + end; // if PlaySentenceMidi + + // mp3 music + if PlaySentence then begin + // stop the music + if (Music.Position > PlayStopTime) then begin + Music.Stop; + PlaySentence := false; + end; + + // click + if (Click) and (PlaySentence) then begin +// AktBeat := Floor(AktSong.BPM[0].BPM * (Music.Position - AktSong.GAP / 1000) / 60); + AktBeat := Floor(GetMidBeat(Music.Position - AktSong.GAP / 1000)); + Text[TextDebug].Text := IntToStr(AktBeat); + if AktBeat <> LastClick then begin + for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then begin + Music.PlayClick; + LastClick := AktBeat; + end; + end; + end; // click + end; // if PlaySentence + + + Text[TextSentence].Text := IntToStr(Czesci[0].Akt + 1) + ' / ' + IntToStr(Czesci[0].Ilosc); + Text[TextNote].Text := IntToStr(AktNuta + 1) + ' / ' + IntToStr(Czesci[0].Czesc[Czesci[0].Akt].IlNut); + + // Song info + Text[TextBPM].Text := FloatToStr(AktSong.BPM[0].BPM / 4); + Text[TextGAP].Text := FloatToStr(AktSong.GAP); + + //Error reading Variables when no Song is loaded + if not Error then + begin + // Note info + Text[TextNStart].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + Text[TextNDlugosc].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + Text[TextNTon].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton) + ' ( ' + GetNoteName(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton) + ' )'; + Text[TextNText].Text := Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst; + end; + + // Text Edit Mode + if TextEditMode then + Text[TextNText].Text := Text[TextNText].Text + '|'; + + // draw static menu + inherited Draw; + + // draw notes + SingDrawNoteLines(20, 300, 780, 15); + //Error Drawing when no Song is loaded + if not Error then + begin + SingDrawBeatDelimeters(40, 300, 760, 0); + EditDrawCzesc(40, 405, 760, 0, 15); + end; + + // draw text + Lyric.Draw; + +end; + +procedure TScreenEditSub.onHide; +begin + MidiOut.Close; + MidiOut.Free; + //Music.SetVolume(100); +end; + +function TScreenEditSub.GetNoteName(Note: Integer): String; +var N1, N2: Integer; +begin + if (Note > 0) then + begin + N1 := Note mod 12; + N2 := Note div 12; + end + else + begin + N1 := (Note + (-Trunc(Note/12)+1)*12) mod 12; + N2 := -1; + end; + + + + case N1 of + 0: Result := 'c'; + 1: Result := 'c#'; + 2: Result := 'd'; + 3: Result := 'd#'; + 4: Result := 'e'; + 5: Result := 'f'; + 6: Result := 'f#'; + 7: Result := 'g'; + 8: Result := 'g#'; + 9: Result := 'a'; + 10: Result := 'b'; + 11: Result := 'h'; + end; + + case N2 of + 0: Result := UpperCase(Result); //Normal Uppercase Note, 1: Normal lowercase Note + 2: Result := Result + ''''; //One Striped + 3: Result := Result + ''''''; //Two Striped + 4: Result := Result + ''''''''; //etc. + 5: Result := Result + ''''''''''; + 6: Result := Result + ''''''''''''; + 7: Result := Result + ''''''''''''''; + end; +end; + +end. diff --git a/Game/Code/Screens/UScreenLevel.pas b/Game/Code/Screens/UScreenLevel.pas new file mode 100644 index 00000000..34fc87af --- /dev/null +++ b/Game/Code/Screens/UScreenLevel.pas @@ -0,0 +1,90 @@ +unit UScreenLevel; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, SysUtils, UThemes; + +type + TScreenLevel = class(TMenu) + public + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure SetAnimationProgress(Progress: real); override; + end; + +implementation + +uses UGraphic, UMain, UIni, UTexture; + +function TScreenLevel.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Music.PlayBack; + FadeTo(@ScreenName); + end; + + SDLK_RETURN: + begin + Ini.Difficulty := Interaction; + Ini.SaveLevel; + Music.PlayStart; + //Set Standard Mode + ScreenSong.Mode := 0; + FadeTo(@ScreenSong); + end; + + // Up and Down could be done at the same time, + // but I don't want to declare variables inside + // functions like this one, called so many times + SDLK_DOWN: InteractNext; + SDLK_UP: InteractPrev; + SDLK_RIGHT: InteractNext; + SDLK_LEFT: InteractPrev; + end; + end; +end; + +constructor TScreenLevel.Create; +var + I: integer; +begin + inherited Create; + + LoadFromTheme(Theme.Level); + + AddButton(Theme.Level.ButtonEasy); + AddButton(Theme.Level.ButtonMedium); + AddButton(Theme.Level.ButtonHard); + + Interaction := 0; +end; + +procedure TScreenLevel.onShow; +begin + Interaction := Ini.Difficulty; + +// LCD.WriteText(1, ' Choose mode: '); +// UpdateLCD; +end; + +procedure TScreenLevel.SetAnimationProgress(Progress: real); +begin + Button[0].Texture.ScaleW := Progress; + Button[1].Texture.ScaleW := Progress; + Button[2].Texture.ScaleW := Progress; +end; + +end. diff --git a/Game/Code/Screens/UScreenLoading.pas b/Game/Code/Screens/UScreenLoading.pas new file mode 100644 index 00000000..438b606e --- /dev/null +++ b/Game/Code/Screens/UScreenLoading.pas @@ -0,0 +1,46 @@ +unit UScreenLoading; + +interface + +uses + UMenu, SDL, SysUtils, UThemes, OpenGL12; + +type + TScreenLoading = class(TMenu) + public + Fadeout: boolean; + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function GetBGTexNum: GLUInt; + procedure onShow; override; + end; + +implementation + +uses UGraphic, UTime; + +function TScreenLoading.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; +end; + +constructor TScreenLoading.Create; +begin + inherited Create; + + LoadFromTheme(Theme.Loading); + + Fadeout := false; +end; + +procedure TScreenLoading.onShow; +begin +// nothing +end; + +function TScreenLoading.GetBGTexNum: GLUInt; +begin + Result := Self.BackImg.TexNum; +end; + +end. diff --git a/Game/Code/Screens/UScreenMain.pas b/Game/Code/Screens/UScreenMain.pas new file mode 100644 index 00000000..e1f41554 --- /dev/null +++ b/Game/Code/Screens/UScreenMain.pas @@ -0,0 +1,275 @@ +unit UScreenMain; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, SysUtils, UThemes, ULCD, ULight; + +type + TScreenMain = class(TMenu) + public + TextDescription: integer; + TextDescriptionLong: integer; + + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure InteractNext; override; + procedure InteractPrev; override; + procedure InteractInc; override; + procedure InteractDec; override; + procedure UpdateLCD; + procedure SetAnimationProgress(Progress: real); override; + //function Draw: boolean; override; + end; + +implementation + +uses Windows, UGraphic, UMain, UIni, UTexture, USongs, Textgl, opengl, ULanguage, UParty, UDLLManager, UScreenCredits, USkins, ULog; + + +function TScreenMain.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var +I: Integer; +SDL_ModState: Word; +begin + Result := true; + + SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT); + + //Deactivate Credits when Key is pressed +// if Credits_Visible then +// begin +// Credits_Visible := False; +// exit; +// end; + + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Result := False; + end; + + SDLK_C: + begin + if (SDL_ModState = KMOD_LALT) then + begin + //If CreditsScreen is not Created -> Then Create + If (ScreenCredits = nil) then + begin + try + //Display White Loading Text + SetFontStyle(2); //Font: Outlined1 + SetFontSize(12); + SetFontItalic(False); + SetFontPos (400 - glTextWidth ('Loading Credits ...')/2, 250); //Position + glColor4f(1,1,1,1); + glPrint('Loading Credits ...'); + SwapBuffers; + + ScreenCredits := TScreenCredits.Create; + except + Log.LogError ('Couldn''t Create Credits Screen'); + end; + end; + + If (ScreenCredits <> nil) then + begin + Music.PlayStart; + FadeTo(@ScreenCredits); + end; + end; + end; + SDLK_M: + begin + if (Ini.Players >= 1) AND (Length(DLLMan.Plugins)>=1) then + begin + Music.PlayStart; + FadeTo(@ScreenPartyOptions); + end; + end; + + SDLK_S: + begin + Music.PlayStart; + FadeTo(@ScreenStatMain); + end; + + SDLK_E: + begin + Music.PlayStart; + FadeTo(@ScreenEdit); + end; + + SDLK_RETURN: + begin + //Solo + if (Interaction = 0) then + begin + if (Length(Songs.Song) >= 1) then + begin + Music.PlayStart; + if (Ini.Players >= 0) and (Ini.Players <= 3) then PlayersPlay := Ini.Players + 1; + if (Ini.Players = 4) then PlayersPlay := 6; + + ScreenName.Goto_SingScreen := False; + FadeTo(@ScreenName); + end + else //show error message + ScreenPopupError.ShowPopup(Language.Translate('ERROR_NO_SONGS')); + end; + + //Multi + if Interaction = 1 then begin + if (Length(Songs.Song) >= 1) then + begin + if (Length(DLLMan.Plugins)>=1) then + begin + Music.PlayStart; + FadeTo(@ScreenPartyOptions); + end + else //show error message, No Plugins Loaded + ScreenPopupError.ShowPopup(Language.Translate('ERROR_NO_PLUGINS')); + end + else //show error message, No Songs Loaded + ScreenPopupError.ShowPopup(Language.Translate('ERROR_NO_SONGS')); + end; + + //Stats + if Interaction = 2 then begin + Music.PlayStart; + FadeTo(@ScreenStatMain); + end; + + //Editor + if Interaction = 3 then begin + Music.PlayStart; + FadeTo(@ScreenEdit); + end; + + //Options + if Interaction = 4 then begin + Music.PlayStart; + FadeTo(@ScreenOptions); + end; + + //Exit + if Interaction = 5 then begin + Result := false; + end; + end; + // Up and Down could be done at the same time, + // but I don't want to declare variables inside + // functions like this one, called so many times + SDLK_DOWN: InteractInc; + SDLK_UP: InteractDec; + SDLK_RIGHT: InteractNext; + SDLK_LEFT: InteractPrev; + end; + end + else // Key Up + case PressedKey of + SDLK_RETURN : + begin + end; + end; +end; + +constructor TScreenMain.Create; +var + I: integer; +begin + inherited Create; + + //---------------- + //Attention ^^: + //New Creation Order needed because of LoadFromTheme + //and Button Collections. + //At First Custom Texts and Statics + //Then LoadFromTheme + //after LoadFromTheme the Buttons and Selects + //---------------- + + + TextDescription := AddText(Theme.Main.TextDescription); + TextDescriptionLong := AddText(Theme.Main.TextDescriptionLong); + + LoadFromTheme(Theme.Main); + + AddButton(Theme.Main.ButtonSolo); + AddButton(Theme.Main.ButtonMulti); + AddButton(Theme.Main.ButtonStat); + AddButton(Theme.Main.ButtonEditor); + AddButton(Theme.Main.ButtonOptions); + AddButton(Theme.Main.ButtonExit); + + Interaction := 0; +end; + +procedure TScreenMain.onShow; +begin + LCD.WriteText(1, ' Choose mode: '); + UpdateLCD; +end; + +procedure TScreenMain.InteractNext; +begin + inherited InteractNext; + Text[TextDescription].Text := Theme.Main.Description[Interaction]; + Text[TextDescriptionLong].Text := Theme.Main.DescriptionLong[Interaction]; + UpdateLCD; + Light.LightOne(1, 200); +end; + +procedure TScreenMain.InteractPrev; +begin + inherited InteractPrev; + Text[TextDescription].Text := Theme.Main.Description[Interaction]; + Text[TextDescriptionLong].Text := Theme.Main.DescriptionLong[Interaction]; + UpdateLCD; + Light.LightOne(0, 200); +end; + +procedure TScreenMain.InteractDec; +begin + inherited InteractDec; + Text[TextDescription].Text := Theme.Main.Description[Interaction]; + Text[TextDescriptionLong].Text := Theme.Main.DescriptionLong[Interaction]; + UpdateLCD; + Light.LightOne(0, 200); +end; + +procedure TScreenMain.InteractInc; +begin + inherited InteractInc; + Text[TextDescription].Text := Theme.Main.Description[Interaction]; + Text[TextDescriptionLong].Text := Theme.Main.DescriptionLong[Interaction]; + UpdateLCD; + Light.LightOne(1, 200); +end; + +procedure TScreenMain.UpdateLCD; +begin + case Interaction of + 0: LCD.WriteText(2, ' sing '); + 1: LCD.WriteText(2, ' editor '); + 2: LCD.WriteText(2, ' options '); + 3: LCD.WriteText(2, ' exit '); + end +end; + +procedure TScreenMain.SetAnimationProgress(Progress: real); +begin + Static[0].Texture.ScaleW := Progress; + Static[0].Texture.ScaleH := Progress; +end; +end. diff --git a/Game/Code/Screens/UScreenName.pas b/Game/Code/Screens/UScreenName.pas new file mode 100644 index 00000000..a91f0b8a --- /dev/null +++ b/Game/Code/Screens/UScreenName.pas @@ -0,0 +1,234 @@ +unit UScreenName; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, SysUtils, UThemes; + +type + TScreenName = class(TMenu) + public + Goto_SingScreen: Boolean; //If True then next Screen in SingScreen + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure SetAnimationProgress(Progress: real); override; + end; + +implementation + +uses UGraphic, UMain, UIni, UTexture; + +function TScreenName.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + I: integer; +SDL_ModState: Word; +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); + + case PressedKey of + SDLK_0..SDLK_9, SDLK_A..SDLK_Z, SDLK_SPACE, SDLK_MINUS, SDLK_EXCLAIM, SDLK_COMMA, SDLK_SLASH, SDLK_ASTERISK, SDLK_QUESTION, SDLK_QUOTE, SDLK_QUOTEDBL: + begin + Button[Interaction].Text[0].Text := Button[Interaction].Text[0].Text + chr(ScanCode); + end; + + // Templates for Names Mod + SDLK_F1: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[0] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[0]; + end; + SDLK_F2: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[1] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[1]; + end; + SDLK_F3: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[2] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[2]; + end; + SDLK_F4: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[3] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[3]; + end; + SDLK_F5: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[4] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[4]; + end; + SDLK_F6: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[5] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[5]; + end; + SDLK_F7: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[6] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[6]; + end; + SDLK_F8: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[7] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[7]; + end; + SDLK_F9: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[8] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[8]; + end; + SDLK_F10: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[9] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[9]; + end; + SDLK_F11: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[10] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[10]; + end; + SDLK_F12: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[11] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[11]; + end; + + + SDLK_BACKSPACE: + begin + Button[Interaction].Text[0].DeleteLastL; + end; + + SDLK_ESCAPE: + begin + Ini.SaveNames; + Music.PlayBack; + if GoTo_SingScreen then + FadeTo(@ScreenSong) + else + FadeTo(@ScreenMain); + end; + + SDLK_RETURN: + begin + for I := 1 to 6 do + Ini.Name[I-1] := Button[I-1].Text[0].Text; + Ini.SaveNames; + Music.PlayStart; + + if GoTo_SingScreen then + FadeTo(@ScreenSing) + else + FadeTo(@ScreenLevel); + + GoTo_SingScreen := False; + end; + + // Up and Down could be done at the same time, + // but I don't want to declare variables inside + // functions like this one, called so many times + SDLK_DOWN: InteractNext; + SDLK_UP: InteractPrev; + SDLK_RIGHT: InteractNext; + SDLK_LEFT: InteractPrev; + end; + end; +end; + +constructor TScreenName.Create; +var + I: integer; +begin + inherited Create; + + LoadFromTheme(Theme.Name); + + + for I := 1 to 6 do + AddButton(Theme.Name.ButtonPlayer[I]); + + Interaction := 0; +end; + +procedure TScreenName.onShow; +var + I: integer; +begin + for I := 1 to 6 do + Button[I-1].Text[0].Text := Ini.Name[I-1]; + + for I := 1 to PlayersPlay do begin + Button[I-1].Visible := true; + Button[I-1].Selectable := true; + end; + + for I := PlayersPlay+1 to 6 do begin + Button[I-1].Visible := false; + Button[I-1].Selectable := false; + end; + +end; + +procedure TScreenName.SetAnimationProgress(Progress: real); +var + I: integer; +begin + for I := 1 to 6 do + Button[I-1].Texture.ScaleW := Progress; +end; + +end. diff --git a/Game/Code/Screens/UScreenOpen.pas b/Game/Code/Screens/UScreenOpen.pas new file mode 100644 index 00000000..cb1393c8 --- /dev/null +++ b/Game/Code/Screens/UScreenOpen.pas @@ -0,0 +1,165 @@ +unit UScreenOpen; + +interface + +uses UMenu, UMusic, SDL, SysUtils, UFiles, UTime, USongs, UIni, ULog, USmpeg, UTexture, UMenuText, + ULyrics, Math, OpenGL12, UThemes; + +type + TScreenOpen = class(TMenu) + private + TextF: array[0..1] of integer; + TextN: integer; + public + Tex_Background: TTexture; + FadeOut: boolean; + Path: string; + BackScreen: pointer; + procedure AddBox(X, Y, W, H: real); + constructor Create; override; + procedure onShow; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; +// function Draw: boolean; override; +// procedure Finish; + end; + +implementation +uses UGraphic, UDraw, UMain, USkins; + +function TScreenOpen.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + if (PressedDown) then begin // Key Down + case ScanCode of + ord('a')..ord('z'), ord('A')..ord('Z'), ord('0')..ord('9'), 32, ord('-'), ord('.'), ord(':'), ord('\'): + begin + if Interaction = 0 then begin + Text[TextN].Text := Text[TextN].Text + chr(ScanCode); + end; + end; + end; + + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + 8: // del + begin + if Interaction = 0 then + begin + Text[TextN].DeleteLastL; + end; + end; + + SDLK_ESCAPE : + begin + //Empty Filename and go to last Screen + FileName := ''; + Music.PlayBack; + FadeTo(BackScreen); + end; + + SDLK_RETURN: + begin + if (Interaction = 2) then begin + //Update Filename and go to last Screen + FileName := Text[TextN].Text; + Music.PlayBack; + FadeTo(BackScreen); + end + else if (Interaction = 1) then + begin + //Empty Filename and go to last Screen + FileName := ''; + Music.PlayBack; + FadeTo(BackScreen); + end; + end; + + SDLK_LEFT: + begin + InteractPrev; + end; + + SDLK_RIGHT: + begin + InteractNext; + end; + + SDLK_DOWN: + begin + end; + + SDLK_UP: + begin + end; + end; + end; +end; + +procedure TScreenOpen.AddBox(X, Y, W, H: real); +begin + AddStatic(X, Y, W, H, 0, 0, 0, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black'); + AddStatic(X+2, Y+2, W-4, H-4, 1, 1, 1, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black'); +end; + +constructor TScreenOpen.Create; +begin + inherited Create; + + // linijka +{ AddStatic(20, 10, 80, 30, 0, 0, 0, 'Bar', 'JPG', 'Font Black'); + AddText(35, 17, 1, 6, 1, 1, 1, 'Linijka'); + TextSentence := AddText(120, 14, 1, 8, 0, 0, 0, '0 / 0');} + + // file list +// AddBox(400, 100, 350, 450); + +// TextF[0] := AddText(430, 155, 0, 8, 0, 0, 0, 'a'); +// TextF[1] := AddText(430, 180, 0, 8, 0, 0, 0, 'a'); + + // file name + AddBox(20, 540, 500, 40); + TextN := AddText(50, 548, 0, 8, 0, 0, 0, FileName); + AddInteraction(iText, TextN); + + // buttons + {AddButton(540, 540, 100, 40, Skin.SkinPath + Skin.ButtonF); + AddButtonText(10, 5, 0, 0, 0, 'Cancel'); + + AddButton(670, 540, 100, 40, Skin.SkinPath + Skin.ButtonF); + AddButtonText(30, 5, 0, 0, 0, 'OK');} + // buttons + AddButton(540, 540, 100, 40, Skin.GetTextureFileName('ButtonF')); + AddButtonText(10, 5, 0, 0, 0, 'Cancel'); + + AddButton(670, 540, 100, 40, Skin.GetTextureFileName('ButtonF')); + AddButtonText(30, 5, 0, 0, 0, 'OK'); + + +end; + +procedure TScreenOpen.onShow; +begin + Interaction := 0; +end; + +(*function TScreenEditSub.Draw: boolean; +var + Min: integer; + Sec: integer; + Tekst: string; + Pet: integer; + AktBeat: integer; +begin + +end; + +procedure TScreenEditSub.Finish; +begin +// +end;*) + +end. + diff --git a/Game/Code/Screens/UScreenOptions.pas b/Game/Code/Screens/UScreenOptions.pas new file mode 100644 index 00000000..55e4f88c --- /dev/null +++ b/Game/Code/Screens/UScreenOptions.pas @@ -0,0 +1,167 @@ +unit UScreenOptions; + +interface + +uses + UMenu, SDL, SysUtils, UDisplay, UMusic, UFiles, UIni, UThemes; + +type + TScreenOptions = class(TMenu) + public + TextDescription: integer; + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure InteractNext; override; + procedure InteractPrev; override; + procedure SetAnimationProgress(Progress: real); override; + end; + +implementation + +uses UGraphic; + +function TScreenOptions.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE, + SDLK_BACKSPACE: + begin + Ini.Save; + Music.PlayBack; + FadeTo(@ScreenMain); + end; + SDLK_RETURN: + begin + if SelInteraction = 0 then begin + Music.PlayStart; + FadeTo(@ScreenOptionsGame); + end; + + if SelInteraction = 1 then begin + Music.PlayStart; + FadeTo(@ScreenOptionsGraphics); + end; + + if SelInteraction = 2 then begin + Music.PlayStart; + FadeTo(@ScreenOptionsSound); + end; + + if SelInteraction = 3 then begin + Music.PlayStart; + FadeTo(@ScreenOptionsLyrics); + end; + + if SelInteraction = 4 then begin + Music.PlayStart; + FadeTo(@ScreenOptionsThemes); + end; + + if SelInteraction = 5 then begin + Music.PlayStart; + FadeTo(@ScreenOptionsRecord); + end; + + if SelInteraction = 6 then begin + Music.PlayStart; + FadeTo(@ScreenOptionsAdvanced); + end; + + if SelInteraction = 7 then begin + Ini.Save; + Music.PlayBack; + FadeTo(@ScreenMain); + end; + end; + SDLK_DOWN: InteractInc; + SDLK_UP: InteractDec; + SDLK_RIGHT: InteractNext; + SDLK_LEFT: InteractPrev; + end; + end; +end; + +constructor TScreenOptions.Create; +var + I: integer; +begin + inherited Create; + + TextDescription := AddText(Theme.Options.TextDescription); + + LoadFromTheme(Theme.Options); + + AddButton(Theme.Options.ButtonGame); + if (Length(Button[0].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[0]); + + AddButton(Theme.Options.ButtonGraphics); + if (Length(Button[1].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[1]); + + AddButton(Theme.Options.ButtonSound); + if (Length(Button[2].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[2]); + + AddButton(Theme.Options.ButtonLyrics); + if (Length(Button[3].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[3]); + + AddButton(Theme.Options.ButtonThemes); + if (Length(Button[4].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[4]); + + AddButton(Theme.Options.ButtonRecord); + if (Length(Button[5].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[5]); + + AddButton(Theme.Options.ButtonAdvanced); + if (Length(Button[6].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[6]); + + AddButton(Theme.Options.ButtonExit); + if (Length(Button[7].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[7]); + + Interaction := 0; +end; + +procedure TScreenOptions.onShow; +begin +// +end; + +procedure TScreenOptions.InteractNext; +begin + inherited InteractNext; + Text[TextDescription].Text := Theme.Options.Description[Interaction]; +end; + +procedure TScreenOptions.InteractPrev; +begin + inherited InteractPrev; + Text[TextDescription].Text := Theme.Options.Description[Interaction]; +end; + + +procedure TScreenOptions.SetAnimationProgress(Progress: real); +begin + Button[0].Texture.ScaleW := Progress; + Button[1].Texture.ScaleW := Progress; + Button[2].Texture.ScaleW := Progress; + Button[3].Texture.ScaleW := Progress; + Button[4].Texture.ScaleW := Progress; + Button[5].Texture.ScaleW := Progress; + Button[6].Texture.ScaleW := Progress; + Button[7].Texture.ScaleW := Progress; +end; + +end. diff --git a/Game/Code/Screens/UScreenOptionsAdvanced.pas b/Game/Code/Screens/UScreenOptionsAdvanced.pas new file mode 100644 index 00000000..8422e2b1 --- /dev/null +++ b/Game/Code/Screens/UScreenOptionsAdvanced.pas @@ -0,0 +1,102 @@ +unit UScreenOptionsAdvanced; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, UIni, UThemes; + +type + TScreenOptionsAdvanced = class(TMenu) + public + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + end; + +implementation + +uses UGraphic; + +function TScreenOptionsAdvanced.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Ini.Save; + Music.PlayBack; + FadeTo(@ScreenOptions); + end; + SDLK_RETURN: + begin + //SelectLoadAnimation Hidden because it is useless atm + //if SelInteraction = 7 then begin + if SelInteraction = 6 then begin + Ini.Save; + Music.PlayBack; + FadeTo(@ScreenOptions); + end; + end; + SDLK_DOWN: + InteractNext; + SDLK_UP : + InteractPrev; + SDLK_RIGHT: + begin + //SelectLoadAnimation Hidden because it is useless atm + //if (SelInteraction >= 0) and (SelInteraction <= 6) then begin + if (SelInteraction >= 0) and (SelInteraction <= 5) then begin + Music.PlayOption; + InteractInc; + end; + end; + SDLK_LEFT: + begin + //SelectLoadAnimation Hidden because it is useless atm + //if (SelInteraction >= 0) and (SelInteraction <= 6) then begin + if (SelInteraction >= 0) and (SelInteraction <= 5) then begin + Music.PlayOption; + InteractDec; + end; + end; + end; + end; +end; + +constructor TScreenOptionsAdvanced.Create; +var + I: integer; +begin + inherited Create; + + LoadFromTheme(Theme.OptionsAdvanced); + + //SelectLoadAnimation Hidden because it is useless atm + //AddSelect(Theme.OptionsAdvanced.SelectLoadAnimation, Ini.LoadAnimation, ILoadAnimation); + AddSelect(Theme.OptionsAdvanced.SelectScreenFade, Ini.ScreenFade, IScreenFade); + AddSelect(Theme.OptionsAdvanced.SelectEffectSing, Ini.EffectSing, IEffectSing); + AddSelect(Theme.OptionsAdvanced.SelectLineBonus, Ini.LineBonus, ILineBonus); + AddSelectSlide(Theme.OptionsAdvanced.SelectOnSongClick, Ini.OnSongClick, IOnSongClick); + AddSelect(Theme.OptionsAdvanced.SelectAskbeforeDel, Ini.AskbeforeDel, IAskbeforeDel); + AddSelect(Theme.OptionsAdvanced.SelectPartyPopup, Ini.PartyPopup, IPartyPopup); + + AddButton(Theme.OptionsAdvanced.ButtonExit); + if (Length(Button[0].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[7]); + + Interaction := 0; +end; + +procedure TScreenOptionsAdvanced.onShow; +begin + Interaction := 0; +end; + +end. diff --git a/Game/Code/Screens/UScreenOptionsGame.pas b/Game/Code/Screens/UScreenOptionsGame.pas new file mode 100644 index 00000000..238f63c0 --- /dev/null +++ b/Game/Code/Screens/UScreenOptionsGame.pas @@ -0,0 +1,107 @@ +unit UScreenOptionsGame; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, UIni, UThemes, USongs; + +type + TScreenOptionsGame = class(TMenu) + public + old_Tabs, old_Sorting: integer; + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure RefreshSongs; + end; + +implementation + +uses UGraphic; + +function TScreenOptionsGame.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Music.PlayBack; + RefreshSongs; + FadeTo(@ScreenOptions); + end; + SDLK_RETURN: + begin + if SelInteraction = 6 then begin + Music.PlayBack; + RefreshSongs; + FadeTo(@ScreenOptions); + end; + end; + SDLK_DOWN: + InteractNext; + SDLK_UP : + InteractPrev; + SDLK_RIGHT: + begin + if (SelInteraction >= 0) and (SelInteraction <= 5) then begin + Music.PlayOption; + InteractInc; + end; + end; + SDLK_LEFT: + begin + if (SelInteraction >= 0) and (SelInteraction <= 5) then begin + Music.PlayOption; + InteractDec; + end; + end; + end; + end; +end; + +constructor TScreenOptionsGame.Create; +var + I: integer; +begin + inherited Create; + + LoadFromTheme(Theme.OptionsGame); + + //Refresh Songs Patch + old_Sorting := Ini.Sorting; + old_Tabs := Ini.Tabs; + + AddSelect(Theme.OptionsGame.SelectPlayers, Ini.Players, IPlayers); + AddSelect(Theme.OptionsGame.SelectDifficulty, Ini.Difficulty, IDifficulty); + AddSelectSlide(Theme.OptionsGame.SelectLanguage, Ini.Language, ILanguage); + AddSelect(Theme.OptionsGame.SelectTabs, Ini.Tabs, ITabs); + AddSelectSlide(Theme.OptionsGame.SelectSorting, Ini.Sorting, ISorting); + AddSelect(Theme.OptionsGame.SelectDebug, Ini.Debug, IDebug); + + + AddButton(Theme.OptionsGame.ButtonExit); + if (Length(Button[0].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[7]); + +end; + +//Refresh Songs Patch +procedure TScreenOptionsGame.RefreshSongs; +begin +if (ini.Sorting <> old_Sorting) or (ini.Tabs <> old_Tabs) then + ScreenSong.Refresh; +end; + +procedure TScreenOptionsGame.onShow; +begin +// Interaction := 0; +end; + +end. diff --git a/Game/Code/Screens/UScreenOptionsGraphics.pas b/Game/Code/Screens/UScreenOptionsGraphics.pas new file mode 100644 index 00000000..e45d37bc --- /dev/null +++ b/Game/Code/Screens/UScreenOptionsGraphics.pas @@ -0,0 +1,96 @@ +unit UScreenOptionsGraphics; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, UIni, UThemes; + +type + TScreenOptionsGraphics = class(TMenu) + public + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + end; + +implementation + +uses UGraphic, UMain; + +function TScreenOptionsGraphics.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE, + SDLK_BACKSPACE: + begin + Ini.Save; + Music.PlayBack; + FadeTo(@ScreenOptions); + end; + SDLK_RETURN: + begin +{ if SelInteraction <= 1 then begin + Restart := true; + end;} + if SelInteraction = 5 then begin + Ini.Save; + Music.PlayBack; + FadeTo(@ScreenOptions); + end; + end; + SDLK_DOWN: + InteractNext; + SDLK_UP : + InteractPrev; + SDLK_RIGHT: + begin + if (SelInteraction >= 0) and (SelInteraction <= 4) then begin + Music.PlayOption; + InteractInc; + end; + end; + SDLK_LEFT: + begin + if (SelInteraction >= 0) and (SelInteraction <= 4) then begin + Music.PlayOption; + InteractDec; + end; + end; + end; + end; +end; + +constructor TScreenOptionsGraphics.Create; +var + I: integer; +begin + inherited Create; + + LoadFromTheme(Theme.OptionsGraphics); + + AddSelectSlide(Theme.OptionsGraphics.SelectSlideResolution, Ini.Resolution, IResolution); + AddSelect(Theme.OptionsGraphics.SelectFullscreen, Ini.Fullscreen, IFullscreen); + AddSelect(Theme.OptionsGraphics.SelectDepth, Ini.Depth, IDepth); + AddSelect(Theme.OptionsGraphics.SelectOscilloscope, Ini.Oscilloscope, IOscilloscope); + AddSelect(Theme.OptionsGraphics.SelectMovieSize, Ini.MovieSize, IMovieSize); + + + AddButton(Theme.OptionsGraphics.ButtonExit); + if (Length(Button[0].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[7]); + +end; + +procedure TScreenOptionsGraphics.onShow; +begin + Interaction := 0; +end; + +end. diff --git a/Game/Code/Screens/UScreenOptionsLyrics.pas b/Game/Code/Screens/UScreenOptionsLyrics.pas new file mode 100644 index 00000000..75d54d47 --- /dev/null +++ b/Game/Code/Screens/UScreenOptionsLyrics.pas @@ -0,0 +1,91 @@ +unit UScreenOptionsLyrics; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, UIni, UThemes; + +type + TScreenOptionsLyrics = class(TMenu) + public + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + end; + +implementation + +uses UGraphic; + +function TScreenOptionsLyrics.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Ini.Save; + Music.PlayBack; + FadeTo(@ScreenOptions); + end; + SDLK_RETURN: + begin + if SelInteraction = 3 then begin + Ini.Save; + Music.PlayBack; + FadeTo(@ScreenOptions); + end; + end; + SDLK_DOWN: + InteractNext; + SDLK_UP : + InteractPrev; + SDLK_RIGHT: + begin + if (SelInteraction >= 0) and (SelInteraction <= 2) then begin + Music.PlayOption; + InteractInc; + end; + end; + SDLK_LEFT: + begin + if (SelInteraction >= 0) and (SelInteraction <= 2) then begin + Music.PlayOption; + InteractDec; + end; + end; + end; + end; +end; + +constructor TScreenOptionsLyrics.Create; +var + I: integer; +begin + inherited Create; + + LoadFromTheme(Theme.OptionsLyrics); + + AddSelect(Theme.OptionsLyrics.SelectLyricsFont, Ini.LyricsFont, ILyricsFont); + AddSelect(Theme.OptionsLyrics.SelectLyricsEffect, Ini.LyricsEffect, ILyricsEffect); + AddSelect(Theme.OptionsLyrics.SelectSolmization, Ini.Solmization, ISolmization); + + + AddButton(Theme.OptionsLyrics.ButtonExit); + if (Length(Button[0].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[7]); + +end; + +procedure TScreenOptionsLyrics.onShow; +begin + Interaction := 0; +end; + +end. diff --git a/Game/Code/Screens/UScreenOptionsRecord.pas b/Game/Code/Screens/UScreenOptionsRecord.pas new file mode 100644 index 00000000..2ff989fa --- /dev/null +++ b/Game/Code/Screens/UScreenOptionsRecord.pas @@ -0,0 +1,132 @@ +unit UScreenOptionsRecord; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, UIni, UThemes; + +type + TScreenOptionsRecord = class(TMenu) + private + SelectSlideInput: integer; + SelectSlideChannelL: integer; + SelectSlideChannelR: integer; + public + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure UpdateCard; + end; + +implementation + +uses SysUtils, UGraphic, URecord, ULog; + +function TScreenOptionsRecord.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE, + SDLK_BACKSPACE: + begin + Ini.Save; + Music.PlayBack; + FadeTo(@ScreenOptions); + end; + SDLK_RETURN: + begin + if SelInteraction = 4 then begin + Ini.Save; + Music.PlayBack; + FadeTo(@ScreenOptions); + end; + end; + SDLK_DOWN: + InteractNext; + SDLK_UP : + InteractPrev; + SDLK_RIGHT: + begin + if (SelInteraction >= 0) and (SelInteraction <= 3) then begin + Music.PlayOption; + InteractInc; + end; + if SelInteraction = 0 then UpdateCard; + end; + SDLK_LEFT: + begin + if (SelInteraction >= 0) and (SelInteraction <= 3) then begin + Music.PlayOption; + InteractDec; + end; + if SelInteraction = 0 then UpdateCard; + end; + end; + end; +end; + +constructor TScreenOptionsRecord.Create; +var + I: integer; + SC: integer; + SCI: integer; +begin + inherited Create; + + LoadFromTheme(Theme.OptionsRecord); + + SetLength(ICard, Length(Recording.SoundCard)); + for SC := 0 to High(Recording.SoundCard) do + ICard[SC] := Recording.SoundCard[SC].Description; +// end; + +// if Length(Recording.SoundCard[Ini.Card].Input) > 0 then begin + SetLength(IInput, Length(Recording.SoundCard[Ini.Card].Input)); + for SCI := 0 to High(Recording.SoundCard[Ini.Card].Input) do + IInput[SCI] := Recording.SoundCard[Ini.Card].Input[SCI].Name; +// end; + + + AddSelectSlide(Theme.OptionsRecord.SelectSlideCard, Ini.Card, ICard); + SelectSlideInput := AddSelectSlide(Theme.OptionsRecord.SelectSlideInput, Ini.CardList[0].Input, IInput); + SelectSlideChannelL := AddSelectSlide(Theme.OptionsRecord.SelectSlideChannelL, Ini.CardList[0].ChannelL, IChannel); + SelectSlideChannelR := AddSelectSlide(Theme.OptionsRecord.SelectSlideChannelR, Ini.CardList[0].ChannelR, IChannel); + + AddButton(Theme.OptionsRecord.ButtonExit); + if (Length(Button[0].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[7]); + + Interaction := 0; +end; + +procedure TScreenOptionsRecord.onShow; +begin + Interaction := 0; +end; + +procedure TScreenOptionsRecord.UpdateCard; +var + SC: integer; + SCI: integer; +begin + SC := Ini.Card; +// if SC = 1 then beep; + + SetLength(IInput, Length(Recording.SoundCard[SC].Input)); + for SCI := 0 to High(Recording.SoundCard[SC].Input) do begin + IInput[SCI] := Recording.SoundCard[SC].Input[SCI].Name; +// Log.LogError(IInput[SCI]); + end; + + UpdateSelectSlideOptions(Theme.OptionsRecord.SelectSlideInput, SelectSlideInput, IInput, Ini.CardList[SC].Input); + UpdateSelectSlideOptions(Theme.OptionsRecord.SelectSlideChannelL, SelectSlideChannelL, IChannel, Ini.CardList[SC].ChannelL); + UpdateSelectSlideOptions(Theme.OptionsRecord.SelectSlideChannelR, SelectSlideChannelR, IChannel, Ini.CardList[SC].ChannelR); +end; + +end. \ No newline at end of file diff --git a/Game/Code/Screens/UScreenOptionsSound.pas b/Game/Code/Screens/UScreenOptionsSound.pas new file mode 100644 index 00000000..ba4af6da --- /dev/null +++ b/Game/Code/Screens/UScreenOptionsSound.pas @@ -0,0 +1,97 @@ +unit UScreenOptionsSound; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, UIni, UThemes; + +type + TScreenOptionsSound = class(TMenu) + public + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + end; + +implementation + +uses UGraphic; + +function TScreenOptionsSound.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Ini.Save; + Music.PlayBack; + FadeTo(@ScreenOptions); + end; + SDLK_RETURN: + begin + if SelInteraction = 6 then begin + Ini.Save; + Music.PlayBack; + FadeTo(@ScreenOptions); + end; + end; + SDLK_DOWN: + InteractNext; + SDLK_UP : + InteractPrev; + SDLK_RIGHT: + begin + if (SelInteraction >= 0) and (SelInteraction <= 5) then begin + Music.PlayOption; + InteractInc; + end; + end; + SDLK_LEFT: + begin + if (SelInteraction >= 0) and (SelInteraction <= 5) then begin + Music.PlayOption; + InteractDec; + end; + end; + end; + end; +end; + +constructor TScreenOptionsSound.Create; +var + I: integer; +begin + inherited Create; + + LoadFromTheme(Theme.OptionsSound); + + AddSelect(Theme.OptionsSound.SelectMicBoost, Ini.MicBoost, IMicBoost); + AddSelect(Theme.OptionsSound.SelectClickAssist, Ini.ClickAssist, IClickAssist); + AddSelect(Theme.OptionsSound.SelectBeatClick, Ini.BeatClick, IBeatClick); + AddSelect(Theme.OptionsSound.SelectThreshold, Ini.Threshold, IThreshold); + + //Song Preview + AddSelectSlide(Theme.OptionsSound.SelectSlidePreviewVolume, Ini.PreviewVolume, IPreviewVolume); + AddSelectSlide + (Theme.OptionsSound.SelectSlidePreviewFading, Ini.PreviewFading, IPreviewFading); + + AddButton(Theme.OptionsSound.ButtonExit); + if (Length(Button[0].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[7]); + + Interaction := 0; +end; + +procedure TScreenOptionsSound.onShow; +begin + Interaction := 0; +end; + +end. diff --git a/Game/Code/Screens/UScreenOptionsThemes.pas b/Game/Code/Screens/UScreenOptionsThemes.pas new file mode 100644 index 00000000..e5f928c1 --- /dev/null +++ b/Game/Code/Screens/UScreenOptionsThemes.pas @@ -0,0 +1,159 @@ +unit UScreenOptionsThemes; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, UIni, UThemes; + +type + TScreenOptionsThemes = class(TMenu) + public + SkinSelect: Integer; + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure InteractInc; override; + procedure InteractDec; override; + end; + +implementation + +uses UGraphic, USkins; + +function TScreenOptionsThemes.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Ini.Save; + + // Reload all screens, after Theme changed + // Todo : JB - Check if theme was actually changed + UGraphic.UnLoadScreens(); + UGraphic.LoadScreens( false ); + + Music.PlayBack; + FadeTo(@ScreenOptions); + end; + SDLK_RETURN: + begin + if SelInteraction = 3 then + begin + Ini.Save; + + // Reload all screens, after Theme changed + // Todo : JB - Check if theme was actually changed + UGraphic.UnLoadScreens(); + UGraphic.LoadScreens( false ); + + Music.PlayBack; + FadeTo(@ScreenOptions); + end; + end; + SDLK_DOWN: + InteractNext; + SDLK_UP : + InteractPrev; + SDLK_RIGHT: + begin + if (SelInteraction >= 0) and (SelInteraction <= 2) then + begin + Music.PlayOption; + InteractInc; + end; + end; + SDLK_LEFT: + begin + if (SelInteraction >= 0) and (SelInteraction <= 2) then + begin + Music.PlayOption; + InteractDec; + end; + end; + end; + end; +end; + +procedure TScreenOptionsThemes.InteractInc; +begin + inherited InteractInc; + //Update Skins + if (SelInteraction = 0) then + begin + Skin.OnThemeChange; + UpdateSelectSlideOptions (Theme.OptionsThemes.SelectSkin, SkinSelect, ISkin, Ini.SkinNo); + + Theme.LoadTheme('Themes\' + ITheme[Ini.Theme] + '.ini', Ini.Color); + + ScreenOptionsThemes := TScreenOptionsThemes.create(); + ScreenOptionsThemes.onshow; + Display.ActualScreen := @ScreenOptionsThemes; + ScreenOptionsThemes.Draw; + + + Display.Draw; + SwapBuffers; + + freeandnil( self ); + + end; +end; + +procedure TScreenOptionsThemes.InteractDec; +begin + inherited InteractDec; + //Update Skins + if (SelInteraction = 0) then + begin + Skin.OnThemeChange; + UpdateSelectSlideOptions (Theme.OptionsThemes.SelectSkin, SkinSelect, ISkin, Ini.SkinNo); + + Theme.LoadTheme('Themes\' + ITheme[Ini.Theme] + '.ini', Ini.Color); + + ScreenOptionsThemes := TScreenOptionsThemes.create(); + ScreenOptionsThemes.onshow; + + Display.ActualScreen := @ScreenOptionsThemes; + ScreenOptionsThemes.Draw; + + Display.Draw; + SwapBuffers; + + freeandnil( self ); + end; +end; + +constructor TScreenOptionsThemes.Create; +var + I: integer; +begin + inherited Create; + + + LoadFromTheme(Theme.OptionsThemes); + + AddSelectSlide(Theme.OptionsThemes.SelectTheme, Ini.Theme, ITheme); + + SkinSelect := AddSelectSlide(Theme.OptionsThemes.SelectSkin, Ini.SkinNo, ISkin); + + AddSelectSlide(Theme.OptionsThemes.SelectColor, Ini.Color, IColor); + + AddButton(Theme.OptionsThemes.ButtonExit); + if (Length(Button[0].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[7]); +end; + +procedure TScreenOptionsThemes.onShow; +begin + Interaction := 0; +end; + +end. diff --git a/Game/Code/Screens/UScreenPartyNewRound.pas b/Game/Code/Screens/UScreenPartyNewRound.pas new file mode 100644 index 00000000..f0f800da --- /dev/null +++ b/Game/Code/Screens/UScreenPartyNewRound.pas @@ -0,0 +1,416 @@ +unit UScreenPartyNewRound; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, SysUtils, UThemes; + +type + TScreenPartyNewRound = class(TMenu) + public + //Texts: + TextRound1: Cardinal; + TextRound2: Cardinal; + TextRound3: Cardinal; + TextRound4: Cardinal; + TextRound5: Cardinal; + TextRound6: Cardinal; + TextRound7: Cardinal; + + TextWinner1: Cardinal; + TextWinner2: Cardinal; + TextWinner3: Cardinal; + TextWinner4: Cardinal; + TextWinner5: Cardinal; + TextWinner6: Cardinal; + TextWinner7: Cardinal; + + TextNextRound: Cardinal; + TextNextRoundNo: Cardinal; + TextNextPlayer1: Cardinal; + TextNextPlayer2: Cardinal; + TextNextPlayer3: Cardinal; + + //Statics + StaticRound1: Cardinal; + StaticRound2: Cardinal; + StaticRound3: Cardinal; + StaticRound4: Cardinal; + StaticRound5: Cardinal; + StaticRound6: Cardinal; + StaticRound7: Cardinal; + + //Scores + TextScoreTeam1: Cardinal; + TextScoreTeam2: Cardinal; + TextScoreTeam3: Cardinal; + TextNameTeam1: Cardinal; + TextNameTeam2: Cardinal; + TextNameTeam3: Cardinal; + + TextTeam1Players: Cardinal; + TextTeam2Players: Cardinal; + TextTeam3Players: Cardinal; + + StaticTeam1: Cardinal; + StaticTeam2: Cardinal; + StaticTeam3: Cardinal; + StaticNextPlayer1: Cardinal; + StaticNextPlayer2: Cardinal; + StaticNextPlayer3: Cardinal; + + + + + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure SetAnimationProgress(Progress: real); override; + end; + +implementation + +uses UGraphic, UMain, UIni, UTexture, UParty, UDLLManager, ULanguage, ULog; + +function TScreenPartyNewRound.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Music.PlayBack; + CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); + end; + + SDLK_RETURN: + begin + Music.PlayStart; + if DLLMan.Selected.LoadSong then + begin + //Select PartyMode ScreenSong + ScreenSong.Mode := 1; + FadeTo(@ScreenSong); + end + else + begin + FadeTo(@ScreenSingModi); + end; + end; + end; + end; +end; + +constructor TScreenPartyNewRound.Create; +var + I: integer; +begin + inherited Create; + + TextRound1 := AddText (Theme.PartyNewRound.TextRound1); + TextRound2 := AddText (Theme.PartyNewRound.TextRound2); + TextRound3 := AddText (Theme.PartyNewRound.TextRound3); + TextRound4 := AddText (Theme.PartyNewRound.TextRound4); + TextRound5 := AddText (Theme.PartyNewRound.TextRound5); + TextRound6 := AddText (Theme.PartyNewRound.TextRound6); + TextRound7 := AddText (Theme.PartyNewRound.TextRound7); + + TextWinner1 := AddText (Theme.PartyNewRound.TextWinner1); + TextWinner2 := AddText (Theme.PartyNewRound.TextWinner2); + TextWinner3 := AddText (Theme.PartyNewRound.TextWinner3); + TextWinner4 := AddText (Theme.PartyNewRound.TextWinner4); + TextWinner5 := AddText (Theme.PartyNewRound.TextWinner5); + TextWinner6 := AddText (Theme.PartyNewRound.TextWinner6); + TextWinner7 := AddText (Theme.PartyNewRound.TextWinner7); + + TextNextRound := AddText (Theme.PartyNewRound.TextNextRound); + TextNextRoundNo := AddText (Theme.PartyNewRound.TextNextRoundNo); + TextNextPlayer1 := AddText (Theme.PartyNewRound.TextNextPlayer1); + TextNextPlayer2 := AddText (Theme.PartyNewRound.TextNextPlayer2); + TextNextPlayer3 := AddText (Theme.PartyNewRound.TextNextPlayer3); + + StaticRound1 := AddStatic (Theme.PartyNewRound.StaticRound1); + StaticRound2 := AddStatic (Theme.PartyNewRound.StaticRound2); + StaticRound3 := AddStatic (Theme.PartyNewRound.StaticRound3); + StaticRound4 := AddStatic (Theme.PartyNewRound.StaticRound4); + StaticRound5 := AddStatic (Theme.PartyNewRound.StaticRound5); + StaticRound6 := AddStatic (Theme.PartyNewRound.StaticRound6); + StaticRound7 := AddStatic (Theme.PartyNewRound.StaticRound7); + + //Scores + TextScoreTeam1 := AddText (Theme.PartyNewRound.TextScoreTeam1); + TextScoreTeam2 := AddText (Theme.PartyNewRound.TextScoreTeam2); + TextScoreTeam3 := AddText (Theme.PartyNewRound.TextScoreTeam3); + TextNameTeam1 := AddText (Theme.PartyNewRound.TextNameTeam1); + TextNameTeam2 := AddText (Theme.PartyNewRound.TextNameTeam2); + TextNameTeam3 := AddText (Theme.PartyNewRound.TextNameTeam3); + + //Players + TextTeam1Players := AddText (Theme.PartyNewRound.TextTeam1Players); + TextTeam2Players := AddText (Theme.PartyNewRound.TextTeam2Players); + TextTeam3Players := AddText (Theme.PartyNewRound.TextTeam3Players); + + StaticTeam1 := AddStatic (Theme.PartyNewRound.StaticTeam1); + StaticTeam2 := AddStatic (Theme.PartyNewRound.StaticTeam2); + StaticTeam3 := AddStatic (Theme.PartyNewRound.StaticTeam3); + StaticNextPlayer1 := AddStatic (Theme.PartyNewRound.StaticNextPlayer1); + StaticNextPlayer2 := AddStatic (Theme.PartyNewRound.StaticNextPlayer2); + StaticNextPlayer3 := AddStatic (Theme.PartyNewRound.StaticNextPlayer3); + + LoadFromTheme(Theme.PartyNewRound); +end; + +procedure TScreenPartyNewRound.onShow; +var + I: Integer; + function GetTeamPlayers(const Num: Byte): String; + var + Players: Array of String; + J: Byte; + begin + if (Num-1 >= PartySession.Teams.NumTeams) then + exit; + + //Create Players Array + SetLength(Players, PartySession.Teams.TeamInfo[Num-1].NumPlayers); + For J := 0 to PartySession.Teams.TeamInfo[Num-1].NumPlayers-1 do + Players[J] := String(PartySession.Teams.TeamInfo[Num-1].PlayerInfo[J].Name); + + //Implode and Return + Result := Language.Implode(Players); + end; +begin + PartySession.StartRound; + + //Set Visibility of Round Infos + I := Length(PartySession.Rounds); + if (I >= 1) then + begin + Static[StaticRound1].Visible := True; + Text[TextRound1].Visible := True; + Text[TextWinner1].Visible := True; + + //Texts: + Text[TextRound1].Text := Language.Translate(DllMan.Plugins[PartySession.Rounds[0].Plugin].Name); + Text[TextWinner1].Text := PartySession.GetWinnerString(0); + end + else + begin + Static[StaticRound1].Visible := False; + Text[TextRound1].Visible := False; + Text[TextWinner1].Visible := False; + end; + + if (I >= 2) then + begin + Static[StaticRound2].Visible := True; + Text[TextRound2].Visible := True; + Text[TextWinner2].Visible := True; + + //Texts: + Text[TextRound2].Text := Language.Translate(DllMan.Plugins[PartySession.Rounds[1].Plugin].Name); + Text[TextWinner2].Text := PartySession.GetWinnerString(1); + end + else + begin + Static[StaticRound2].Visible := False; + Text[TextRound2].Visible := False; + Text[TextWinner2].Visible := False; + end; + + if (I >= 3) then + begin + Static[StaticRound3].Visible := True; + Text[TextRound3].Visible := True; + Text[TextWinner3].Visible := True; + + //Texts: + Text[TextRound3].Text := Language.Translate(DllMan.Plugins[PartySession.Rounds[2].Plugin].Name); + Text[TextWinner3].Text := PartySession.GetWinnerString(2); + end + else + begin + Static[StaticRound3].Visible := False; + Text[TextRound3].Visible := False; + Text[TextWinner3].Visible := False; + end; + + if (I >= 4) then + begin + Static[StaticRound4].Visible := True; + Text[TextRound4].Visible := True; + Text[TextWinner4].Visible := True; + + //Texts: + Text[TextRound4].Text := Language.Translate(DllMan.Plugins[PartySession.Rounds[3].Plugin].Name); + Text[TextWinner4].Text := PartySession.GetWinnerString(3); + end + else + begin + Static[StaticRound4].Visible := False; + Text[TextRound4].Visible := False; + Text[TextWinner4].Visible := False; + end; + + if (I >= 5) then + begin + Static[StaticRound5].Visible := True; + Text[TextRound5].Visible := True; + Text[TextWinner5].Visible := True; + + //Texts: + Text[TextRound5].Text := Language.Translate(DllMan.Plugins[PartySession.Rounds[4].Plugin].Name); + Text[TextWinner5].Text := PartySession.GetWinnerString(4); + end + else + begin + Static[StaticRound5].Visible := False; + Text[TextRound5].Visible := False; + Text[TextWinner5].Visible := False; + end; + + if (I >= 6) then + begin + Static[StaticRound6].Visible := True; + Text[TextRound6].Visible := True; + Text[TextWinner6].Visible := True; + + //Texts: + Text[TextRound6].Text := Language.Translate(DllMan.Plugins[PartySession.Rounds[5].Plugin].Name); + Text[TextWinner6].Text := PartySession.GetWinnerString(5); + end + else + begin + Static[StaticRound6].Visible := False; + Text[TextRound6].Visible := False; + Text[TextWinner6].Visible := False; + end; + + if (I >= 7) then + begin + Static[StaticRound7].Visible := True; + Text[TextRound7].Visible := True; + Text[TextWinner7].Visible := True; + + //Texts: + Text[TextRound7].Text := Language.Translate(DllMan.Plugins[PartySession.Rounds[6].Plugin].Name); + Text[TextWinner7].Text := PartySession.GetWinnerString(6); + end + else + begin + Static[StaticRound7].Visible := False; + Text[TextRound7].Visible := False; + Text[TextWinner7].Visible := False; + end; + + //Display Scores + if (PartySession.Teams.NumTeams >= 1) then + begin + Text[TextScoreTeam1].Text := InttoStr(PartySession.Teams.TeamInfo[0].Score); + Text[TextNameTeam1].Text := String(PartySession.Teams.TeamInfo[0].Name); + Text[TextTeam1Players].Text := GetTeamPlayers(1); + + Text[TextScoreTeam1].Visible := True; + Text[TextNameTeam1].Visible := True; + Text[TextTeam1Players].Visible := True; + Static[StaticTeam1].Visible := True; + Static[StaticNextPlayer1].Visible := True; + end + else + begin + Text[TextScoreTeam1].Visible := False; + Text[TextNameTeam1].Visible := False; + Text[TextTeam1Players].Visible := False; + Static[StaticTeam1].Visible := False; + Static[StaticNextPlayer1].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 2) then + begin + Text[TextScoreTeam2].Text := InttoStr(PartySession.Teams.TeamInfo[1].Score); + Text[TextNameTeam2].Text := String(PartySession.Teams.TeamInfo[1].Name); + Text[TextTeam2Players].Text := GetTeamPlayers(2); + + Text[TextScoreTeam2].Visible := True; + Text[TextNameTeam2].Visible := True; + Text[TextTeam2Players].Visible := True; + Static[StaticTeam2].Visible := True; + Static[StaticNextPlayer2].Visible := True; + end + else + begin + Text[TextScoreTeam2].Visible := False; + Text[TextNameTeam2].Visible := False; + Text[TextTeam2Players].Visible := False; + Static[StaticTeam2].Visible := False; + Static[StaticNextPlayer2].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 3) then + begin + Text[TextScoreTeam3].Text := InttoStr(PartySession.Teams.TeamInfo[2].Score); + Text[TextNameTeam3].Text := String(PartySession.Teams.TeamInfo[2].Name); + Text[TextTeam3Players].Text := GetTeamPlayers(3); + + Text[TextScoreTeam3].Visible := True; + Text[TextNameTeam3].Visible := True; + Text[TextTeam3Players].Visible := True; + Static[StaticTeam3].Visible := True; + Static[StaticNextPlayer3].Visible := True; + end + else + begin + Text[TextScoreTeam3].Visible := False; + Text[TextNameTeam3].Visible := False; + Text[TextTeam3Players].Visible := False; + Static[StaticTeam3].Visible := False; + Static[StaticNextPlayer3].Visible := False; + end; + + //nextRound Texts + Text[TextNextRound].Text := Language.Translate(DllMan.Selected.PluginDesc); + Text[TextNextRoundNo].Text := InttoStr(PartySession.CurRound + 1); + if (PartySession.Teams.NumTeams >= 1) then + begin + Text[TextNextPlayer1].Text := PartySession.Teams.Teaminfo[0].Playerinfo[PartySession.Teams.Teaminfo[0].CurPlayer].Name; + Text[TextNextPlayer1].Visible := True; + end + else + Text[TextNextPlayer1].Visible := False; + + if (PartySession.Teams.NumTeams >= 2) then + begin + Text[TextNextPlayer2].Text := PartySession.Teams.Teaminfo[1].Playerinfo[PartySession.Teams.Teaminfo[1].CurPlayer].Name; + Text[TextNextPlayer2].Visible := True; + end + else + Text[TextNextPlayer2].Visible := False; + + if (PartySession.Teams.NumTeams >= 3) then + begin + Text[TextNextPlayer3].Text := PartySession.Teams.Teaminfo[2].Playerinfo[PartySession.Teams.Teaminfo[2].CurPlayer].Name; + Text[TextNextPlayer3].Visible := True; + end + else + Text[TextNextPlayer3].Visible := False; + + +// LCD.WriteText(1, ' Choose mode: '); +// UpdateLCD; +end; + +procedure TScreenPartyNewRound.SetAnimationProgress(Progress: real); +begin + {Button[0].Texture.ScaleW := Progress; + Button[1].Texture.ScaleW := Progress; + Button[2].Texture.ScaleW := Progress; } +end; + +end. diff --git a/Game/Code/Screens/UScreenPartyOptions.pas b/Game/Code/Screens/UScreenPartyOptions.pas new file mode 100644 index 00000000..91611d34 --- /dev/null +++ b/Game/Code/Screens/UScreenPartyOptions.pas @@ -0,0 +1,256 @@ +unit UScreenPartyOptions; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, SysUtils, UThemes; + +type + TScreenPartyOptions = class(TMenu) + public + SelectLevel: Cardinal; + SelectPlayList: Cardinal; + SelectPlayList2: Cardinal; + SelectRounds: Cardinal; + SelectTeams: Cardinal; + SelectPlayers1: Cardinal; + SelectPlayers2: Cardinal; + SelectPlayers3: Cardinal; + + PlayList: Integer; + PlayList2: Integer; + Rounds: Integer; + NumTeams: Integer; + NumPlayer1, NumPlayer2, NumPlayer3: Integer; + + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure SetAnimationProgress(Progress: real); override; + procedure SetPlaylist2; + end; + +var + IPlaylist: array[0..2] of String; + IPlaylist2: array of String; +const + ITeams: array[0..1] of String =('2', '3'); + IPlayers: array[0..3] of String =('1', '2', '3', '4'); + IRounds: array[0..5] of String = ('2', '3', '4', '5', '6', '7'); + +implementation + +uses UGraphic, UMain, UIni, UTexture, ULanguage, UParty, UDLLManager, UPlaylist, USongs; + +function TScreenPartyOptions.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; + var + I, J: Integer; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Music.PlayBack; + FadeTo(@ScreenMain); + end; + + SDLK_RETURN: + begin + //Don'T start when Playlist is Selected and there are no Playlists + If (Playlist = 2) and (Length(PlaylistMan.Playlists) = 0) then + Exit; + + //Save Difficulty + Ini.Difficulty := SelectsS[SelectLevel].SelectedOption; + Ini.SaveLevel; + + + //Save Num Teams: + PartySession.Teams.NumTeams := NumTeams + 2; + PartySession.Teams.Teaminfo[0].NumPlayers := NumPlayer1+1; + PartySession.Teams.Teaminfo[1].NumPlayers := NumPlayer2+1; + PartySession.Teams.Teaminfo[2].NumPlayers := NumPlayer3+1; + + //Save Playlist + PlaylistMan.Mode := Playlist; + PlaylistMan.CurPlayList := High(Cardinal); + //If Category Selected Search Category ID + if Playlist = 1 then + begin + J := -1; + For I := 0 to high(CatSongs.Song) do + begin + if CatSongs.Song[I].Main then + Inc(J); + + if J = Playlist2 then + begin + PlaylistMan.CurPlayList := I; + Break; + end; + end; + + //No Categorys or Invalid Entry + If PlaylistMan.CurPlayList = High(Cardinal) then + Exit; + end + else + PlaylistMan.CurPlayList := Playlist2; + + //Start Party + PartySession.StartNewParty(Rounds + 2); + + Music.PlayStart; + //Go to Player Screen + FadeTo(@ScreenPartyPlayer); + end; + + // Up and Down could be done at the same time, + // but I don't want to declare variables inside + // functions like this one, called so many times + SDLK_DOWN: InteractNext; + SDLK_UP: InteractPrev; + SDLK_RIGHT: + begin + Music.PlayOption; + InteractInc; + + //Change Playlist2 if Playlist is Changed + If (Interaction = 1) then + begin + SetPlaylist2; + end //Change Team3 Players visibility + Else If (Interaction = 4) then + begin + SelectsS[7].Visible := (NumTeams = 1); + end; + end; + SDLK_LEFT: + begin + Music.PlayOption; + InteractDec; + + //Change Playlist2 if Playlist is Changed + If (Interaction = 1) then + begin + SetPlaylist2; + end //Change Team3 Players visibility + Else If (Interaction = 4) then + begin + SelectsS[7].Visible := (NumTeams = 1); + end; + end; + end; + end; +end; + +constructor TScreenPartyOptions.Create; +var + I: integer; +begin + inherited Create; + //Fill IPlaylist + IPlaylist[0] := Language.Translate('PARTY_PLAYLIST_ALL'); + IPlaylist[1] := Language.Translate('PARTY_PLAYLIST_CATEGORY'); + IPlaylist[2] := Language.Translate('PARTY_PLAYLIST_PLAYLIST'); + + //Fill IPlaylist2 + SetLength(IPlaylist2, 1); + IPlaylist2[0] := '---'; + + //Clear all Selects + NumTeams := 0; + NumPlayer1 := 0; + NumPlayer2 := 0; + NumPlayer3 := 0; + Rounds := 5; + PlayList := 0; + PlayList2 := 0; + + //Load Screen From Theme + LoadFromTheme(Theme.PartyOptions); + + SelectLevel := AddSelectSlide (Theme.PartyOptions.SelectLevel, Ini.Difficulty, Theme.ILevel); + SelectPlayList := AddSelectSlide (Theme.PartyOptions.SelectPlayList, PlayList, IPlaylist); + SelectPlayList2 := AddSelectSlide (Theme.PartyOptions.SelectPlayList2, PlayList2, IPlaylist2); + SelectRounds := AddSelectSlide (Theme.PartyOptions.SelectRounds, Rounds, IRounds); + SelectTeams := AddSelectSlide (Theme.PartyOptions.SelectTeams, NumTeams, ITeams); + SelectPlayers1 := AddSelectSlide (Theme.PartyOptions.SelectPlayers1, NumPlayer1, IPlayers); + SelectPlayers2 := AddSelectSlide (Theme.PartyOptions.SelectPlayers2, NumPlayer2, IPlayers); + SelectPlayers3 := AddSelectSlide (Theme.PartyOptions.SelectPlayers3, NumPlayer3, IPlayers); + + Interaction := 0; + + //Hide Team3 Players + SelectsS[7].Visible := False; +end; + +procedure TScreenPartyOptions.SetPlaylist2; +var I: Integer; +begin + Case Playlist of + 0: + begin + SetLength(IPlaylist2, 1); + IPlaylist2[0] := '---'; + end; + 1: + begin + SetLength(IPlaylist2, 0); + For I := 0 to high(CatSongs.Song) do + begin + If (CatSongs.Song[I].Main) then + begin + SetLength(IPlaylist2, Length(IPlaylist2) + 1); + IPlaylist2[high(IPlaylist2)] := CatSongs.Song[I].Artist; + end; + end; + + If (Length(IPlaylist2) = 0) then + begin + SetLength(IPlaylist2, 1); + IPlaylist2[0] := 'No Categories found'; + end; + end; + 2: + begin + if (Length(PlaylistMan.Playlists) > 0) then + begin + SetLength(IPlaylist2, Length(PlaylistMan.Playlists)); + PlaylistMan.GetNames(IPlaylist2); + end + else + begin + SetLength(IPlaylist2, 1); + IPlaylist2[0] := 'No Playlists found'; + end; + end; + end; + + Playlist2 := 0; + UpdateSelectSlideOptions(Theme.PartyOptions.SelectPlayList2, 2, IPlaylist2, Playlist2); +end; + +procedure TScreenPartyOptions.onShow; +begin + Randomize; + +// LCD.WriteText(1, ' Choose mode: '); +// UpdateLCD; +end; + +procedure TScreenPartyOptions.SetAnimationProgress(Progress: real); +begin + {for I := 0 to 6 do + SelectS[I].Texture.ScaleW := Progress;} +end; + +end. diff --git a/Game/Code/Screens/UScreenPartyPlayer.pas b/Game/Code/Screens/UScreenPartyPlayer.pas new file mode 100644 index 00000000..d6859775 --- /dev/null +++ b/Game/Code/Screens/UScreenPartyPlayer.pas @@ -0,0 +1,329 @@ +unit UScreenPartyPlayer; + +Interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, SysUtils, UThemes; + +type + TScreenPartyPlayer = class(TMenu) + public + Team1Name: Cardinal; + Player1Name: Cardinal; + Player2Name: Cardinal; + Player3Name: Cardinal; + Player4Name: Cardinal; + + Team2Name: Cardinal; + Player5Name: Cardinal; + Player6Name: Cardinal; + Player7Name: Cardinal; + Player8Name: Cardinal; + + Team3Name: Cardinal; + Player9Name: Cardinal; + Player10Name: Cardinal; + Player11Name: Cardinal; + Player12Name: Cardinal; + + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure SetAnimationProgress(Progress: real); override; + end; + +implementation + +uses UGraphic, UMain, UIni, UTexture, UParty; + +function TScreenPartyPlayer.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + I, J: integer; + SDL_ModState: Word; + procedure IntNext; + begin + repeat + InteractNext; + until Button[Interaction].Visible; + end; + procedure IntPrev; + begin + repeat + InteractPrev; + until Button[Interaction].Visible; + end; +begin + Result := true; + If (PressedDown) Then + + SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT); + + begin // Key Down + case PressedKey of + SDLK_0..SDLK_9, SDLK_A..SDLK_Z, SDLK_SPACE, SDLK_MINUS, SDLK_EXCLAIM, SDLK_COMMA, SDLK_SLASH, SDLK_ASTERISK, SDLK_QUESTION, SDLK_QUOTE, SDLK_QUOTEDBL: + begin + Button[Interaction].Text[0].Text := Button[Interaction].Text[0].Text + chr(ScanCode); + end; + + // Templates for Names Mod + SDLK_F1: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[0] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[0]; + end; + SDLK_F2: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[1] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[1]; + end; + SDLK_F3: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[2] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[2]; + end; + SDLK_F4: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[3] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[3]; + end; + SDLK_F5: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[4] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[4]; + end; + SDLK_F6: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[5] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[5]; + end; + SDLK_F7: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[6] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[6]; + end; + SDLK_F8: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[7] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[7]; + end; + SDLK_F9: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[8] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[8]; + end; + SDLK_F10: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[9] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[9]; + end; + SDLK_F11: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[10] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[10]; + end; + SDLK_F12: + if (SDL_ModState = KMOD_LALT) then + begin + Ini.NameTemplate[11] := Button[Interaction].Text[0].Text; + end + else + begin + Button[Interaction].Text[0].Text := Ini.NameTemplate[11]; + end; + + SDLK_BACKSPACE: + begin + Button[Interaction].Text[0].DeleteLastL; + end; + + SDLK_ESCAPE : + begin + Ini.SaveNames; + Music.PlayBack; + FadeTo(@ScreenPartyOptions); + end; + + SDLK_RETURN: + begin + + //Save PlayerNames + for I := 0 to PartySession.Teams.NumTeams-1 do + begin + PartySession.Teams.Teaminfo[I].Name := PChar(Button[I*5].Text[0].Text); + for J := 0 to PartySession.Teams.Teaminfo[I].NumPlayers-1 do + begin + PartySession.Teams.Teaminfo[I].Playerinfo[J].Name := PChar(Button[I*5 + J+1].Text[0].Text); + PartySession.Teams.Teaminfo[I].Playerinfo[J].TimesPlayed := 0; + end; + end; + + Music.PlayStart; + FadeTo(@ScreenPartyNewRound); + end; + + // Up and Down could be done at the same time, + // but I don't want to declare variables inside + // functions like this one, called so many times + SDLK_DOWN: IntNext; + SDLK_UP: IntPrev; + SDLK_RIGHT: IntNext; + SDLK_LEFT: IntPrev; + end; + end; +end; + +constructor TScreenPartyPlayer.Create; +var + I: integer; +begin + inherited Create; + + LoadFromTheme(Theme.PartyPlayer); + + Team1Name := AddButton(Theme.PartyPlayer.Team1Name); + AddButton(Theme.PartyPlayer.Player1Name); + AddButton(Theme.PartyPlayer.Player2Name); + AddButton(Theme.PartyPlayer.Player3Name); + AddButton(Theme.PartyPlayer.Player4Name); + + Team2Name := AddButton(Theme.PartyPlayer.Team2Name); + AddButton(Theme.PartyPlayer.Player5Name); + AddButton(Theme.PartyPlayer.Player6Name); + AddButton(Theme.PartyPlayer.Player7Name); + AddButton(Theme.PartyPlayer.Player8Name); + + Team3Name := AddButton(Theme.PartyPlayer.Team3Name); + AddButton(Theme.PartyPlayer.Player9Name); + AddButton(Theme.PartyPlayer.Player10Name); + AddButton(Theme.PartyPlayer.Player11Name); + AddButton(Theme.PartyPlayer.Player12Name); + + Interaction := 0; +end; + +procedure TScreenPartyPlayer.onShow; +var + I: integer; +begin + // Templates for Names Mod + for I := 1 to 4 do + Button[I].Text[0].Text := Ini.Name[I-1]; + + for I := 6 to 9 do + Button[I].Text[0].Text := Ini.Name[I-2]; + + for I := 11 to 14 do + Button[I].Text[0].Text := Ini.Name[I-3]; + + Button[0].Text[0].Text := Ini.NameTeam[0]; + 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; + Button[1].Visible := (PartySession.Teams.Teaminfo[0].NumPlayers >=1); + Button[2].Visible := (PartySession.Teams.Teaminfo[0].NumPlayers >=2); + Button[3].Visible := (PartySession.Teams.Teaminfo[0].NumPlayers >=3); + Button[4].Visible := (PartySession.Teams.Teaminfo[0].NumPlayers >=4); + end + else + begin + Button[0].Visible := False; + Button[1].Visible := False; + Button[2].Visible := False; + Button[3].Visible := False; + Button[4].Visible := False; + end; + + If (PartySession.Teams.NumTeams>=2) then + begin + Button[5].Visible := True; + Button[6].Visible := (PartySession.Teams.Teaminfo[1].NumPlayers >=1); + Button[7].Visible := (PartySession.Teams.Teaminfo[1].NumPlayers >=2); + Button[8].Visible := (PartySession.Teams.Teaminfo[1].NumPlayers >=3); + Button[9].Visible := (PartySession.Teams.Teaminfo[1].NumPlayers >=4); + end + else + begin + Button[5].Visible := False; + Button[6].Visible := False; + Button[7].Visible := False; + Button[8].Visible := False; + Button[9].Visible := False; + end; + + If (PartySession.Teams.NumTeams>=3) then + begin + Button[10].Visible := True; + Button[11].Visible := (PartySession.Teams.Teaminfo[2].NumPlayers >=1); + Button[12].Visible := (PartySession.Teams.Teaminfo[2].NumPlayers >=2); + Button[13].Visible := (PartySession.Teams.Teaminfo[2].NumPlayers >=3); + Button[14].Visible := (PartySession.Teams.Teaminfo[2].NumPlayers >=4); + end + else + begin + Button[10].Visible := False; + Button[11].Visible := False; + Button[12].Visible := False; + Button[13].Visible := False; + Button[14].Visible := False; + end; + +end; + +procedure TScreenPartyPlayer.SetAnimationProgress(Progress: real); +var + I: integer; +begin + for I := 0 to high(Button) do + Button[I].Texture.ScaleW := Progress; +end; + +end. diff --git a/Game/Code/Screens/UScreenPartyScore.pas b/Game/Code/Screens/UScreenPartyScore.pas new file mode 100644 index 00000000..b4e8c8e3 --- /dev/null +++ b/Game/Code/Screens/UScreenPartyScore.pas @@ -0,0 +1,290 @@ +unit UScreenPartyScore; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, SysUtils, UThemes; + +type + TScreenPartyScore = class(TMenu) + public + TextScoreTeam1: Cardinal; + TextScoreTeam2: Cardinal; + TextScoreTeam3: Cardinal; + TextNameTeam1: Cardinal; + TextNameTeam2: Cardinal; + TextNameTeam3: Cardinal; + StaticTeam1: Cardinal; + StaticTeam1BG: Cardinal; + StaticTeam1Deco: Cardinal; + StaticTeam2: Cardinal; + StaticTeam2BG: Cardinal; + StaticTeam2Deco: Cardinal; + StaticTeam3: Cardinal; + StaticTeam3BG: Cardinal; + StaticTeam3Deco: Cardinal; + TextWinner: Cardinal; + + DecoTex: Array[0..5] of Integer; + DecoColor: Array[0..5] of Record + R, G, B: Real; + end; + + MaxScore: Word; + + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure SetAnimationProgress(Progress: real); override; + end; + +implementation + +uses UGraphic, UMain, UParty, UScreenSingModi, ULanguage, UTexture, USkins; + +function TScreenPartyScore.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Music.PlayStart; + if (PartySession.CurRound < High(PartySession.Rounds)) then + FadeTo(@ScreenPartyNewRound) + else + begin + PartySession.EndRound; + FadeTo(@ScreenPartyWin); + end; + end; + + SDLK_RETURN: + begin + Music.PlayStart; + if (PartySession.CurRound < High(PartySession.Rounds)) then + FadeTo(@ScreenPartyNewRound) + else + FadeTo(@ScreenPartyWin); + end; + end; + end; +end; + +constructor TScreenPartyScore.Create; +var + I: integer; + Tex: TTexture; + R, G, B: Real; + Color: Integer; +begin + inherited Create; + + TextScoreTeam1 := AddText (Theme.PartyScore.TextScoreTeam1); + TextScoreTeam2 := AddText (Theme.PartyScore.TextScoreTeam2); + TextScoreTeam3 := AddText (Theme.PartyScore.TextScoreTeam3); + TextNameTeam1 := AddText (Theme.PartyScore.TextNameTeam1); + TextNameTeam2 := AddText (Theme.PartyScore.TextNameTeam2); + TextNameTeam3 := AddText (Theme.PartyScore.TextNameTeam3); + + StaticTeam1 := AddStatic (Theme.PartyScore.StaticTeam1); + StaticTeam1BG := AddStatic (Theme.PartyScore.StaticTeam1BG); + StaticTeam1Deco := AddStatic (Theme.PartyScore.StaticTeam1Deco); + StaticTeam2 := AddStatic (Theme.PartyScore.StaticTeam2); + StaticTeam2BG := AddStatic (Theme.PartyScore.StaticTeam2BG); + StaticTeam2Deco := AddStatic (Theme.PartyScore.StaticTeam2Deco); + StaticTeam3 := AddStatic (Theme.PartyScore.StaticTeam3); + StaticTeam3BG := AddStatic (Theme.PartyScore.StaticTeam3BG); + StaticTeam3Deco := AddStatic (Theme.PartyScore.StaticTeam3Deco); + + TextWinner := AddText (Theme.PartyScore.TextWinner); + + //Load Deco Textures + if Theme.PartyScore.DecoTextures.ChangeTextures then + begin + //Get Color + LoadColor(R, G, B, Theme.PartyScore.DecoTextures.FirstColor); + Color := $10000 * Round(R*255) + $100 * Round(G*255) + Round(B*255); + DecoColor[0].R := R; + DecoColor[0].G := G; + DecoColor[0].B := B; + + //Load Texture + Tex := Texture.LoadTexture(pchar(Skin.GetTextureFileName(Theme.PartyScore.DecoTextures.FirstTexture)), 'JPG', PChar(Theme.PartyScore.DecoTextures.FirstTyp), Color); + DecoTex[0] := Tex.TexNum; + + //Get Second Color + LoadColor(R, G, B, Theme.PartyScore.DecoTextures.SecondColor); + Color := $10000 * Round(R*255) + $100 * Round(G*255) + Round(B*255); + DecoColor[1].R := R; + DecoColor[1].G := G; + DecoColor[1].B := B; + + //Load Second Texture + Tex := Texture.LoadTexture(pchar(Skin.GetTextureFileName(Theme.PartyScore.DecoTextures.SecondTexture)), 'JPG', PChar(Theme.PartyScore.DecoTextures.SecondTyp), Color); + DecoTex[1] := Tex.TexNum; + + //Get Third Color + LoadColor(R, G, B, Theme.PartyScore.DecoTextures.ThirdColor); + Color := $10000 * Round(R*255) + $100 * Round(G*255) + Round(B*255); + DecoColor[2].R := R; + DecoColor[2].G := G; + DecoColor[2].B := B; + + //Load Third Texture + Tex := Texture.LoadTexture(pchar(Skin.GetTextureFileName(Theme.PartyScore.DecoTextures.ThirdTexture)), 'JPG', PChar(Theme.PartyScore.DecoTextures.ThirdTyp), Color); + DecoTex[2] := Tex.TexNum; + end; + + LoadFromTheme(Theme.PartyScore); +end; + +procedure TScreenPartyScore.onShow; +var + I, J: Integer; + Placings: Array [0..5] of Byte; +begin + //Get Maxscore + MaxScore := 0; + for I := 0 to ScreenSingModi.PlayerInfo.NumPlayers - 1 do + begin + if (ScreenSingModi.PlayerInfo.Playerinfo[I].Score > MaxScore) then + MaxScore := ScreenSingModi.PlayerInfo.Playerinfo[I].Score; + end; + + //Get Placings + for I := 0 to ScreenSingModi.PlayerInfo.NumPlayers - 1 do + begin + Placings[I] := 0; + for J := 0 to ScreenSingModi.PlayerInfo.NumPlayers - 1 do + If (ScreenSingModi.PlayerInfo.Playerinfo[J].Score > ScreenSingModi.PlayerInfo.Playerinfo[I].Score) then + Inc(Placings[I]); + end; + + + //Set Static Length + Static[StaticTeam1].Texture.ScaleW := ScreenSingModi.PlayerInfo.Playerinfo[0].Percentage / 100; + Static[StaticTeam2].Texture.ScaleW := ScreenSingModi.PlayerInfo.Playerinfo[1].Percentage / 100; + Static[StaticTeam3].Texture.ScaleW := ScreenSingModi.PlayerInfo.Playerinfo[2].Percentage / 100; + + //fix: prevents static from drawn out of bounds. + if Static[StaticTeam1].Texture.ScaleW > 99 then Static[StaticTeam1].Texture.ScaleW := 99; + if Static[StaticTeam2].Texture.ScaleW > 99 then Static[StaticTeam2].Texture.ScaleW := 99; + if Static[StaticTeam3].Texture.ScaleW > 99 then Static[StaticTeam3].Texture.ScaleW := 99; + + //End Last Round + PartySession.EndRound; + + //Set Winnertext + Text[TextWinner].Text := Format(Language.Translate('PARTY_SCORE_WINS'), [PartySession.GetWinnerString(PartySession.CurRound)]); + + if (ScreenSingModi.PlayerInfo.NumPlayers >= 1) then + begin + Text[TextScoreTeam1].Text := InttoStr(ScreenSingModi.PlayerInfo.Playerinfo[0].Score); + Text[TextNameTeam1].Text := String(ScreenSingModi.TeamInfo.Teaminfo[0].Name); + + //Set Deco Texture + if Theme.PartyScore.DecoTextures.ChangeTextures then + begin + Static[StaticTeam1Deco].Texture.TexNum := DecoTex[Placings[0]]; + Static[StaticTeam1Deco].Texture.ColR := DecoColor[Placings[0]].R; + Static[StaticTeam1Deco].Texture.ColG := DecoColor[Placings[0]].G; + Static[StaticTeam1Deco].Texture.ColB := DecoColor[Placings[0]].B; + end; + + Text[TextScoreTeam1].Visible := True; + Text[TextNameTeam1].Visible := True; + Static[StaticTeam1].Visible := True; + Static[StaticTeam1BG].Visible := True; + Static[StaticTeam1Deco].Visible := True; + end + else + begin + Text[TextScoreTeam1].Visible := False; + Text[TextNameTeam1].Visible := False; + Static[StaticTeam1].Visible := False; + Static[StaticTeam1BG].Visible := False; + Static[StaticTeam1Deco].Visible := False; + end; + + if (ScreenSingModi.PlayerInfo.NumPlayers >= 2) then + begin + Text[TextScoreTeam2].Text := InttoStr(ScreenSingModi.PlayerInfo.Playerinfo[1].Score); + Text[TextNameTeam2].Text := String(ScreenSingModi.TeamInfo.Teaminfo[1].Name); + + //Set Deco Texture + if Theme.PartyScore.DecoTextures.ChangeTextures then + begin + Static[StaticTeam2Deco].Texture.TexNum := DecoTex[Placings[1]]; + Static[StaticTeam2Deco].Texture.ColR := DecoColor[Placings[1]].R; + Static[StaticTeam2Deco].Texture.ColG := DecoColor[Placings[1]].G; + Static[StaticTeam2Deco].Texture.ColB := DecoColor[Placings[1]].B; + end; + + Text[TextScoreTeam2].Visible := True; + Text[TextNameTeam2].Visible := True; + Static[StaticTeam2].Visible := True; + Static[StaticTeam2BG].Visible := True; + Static[StaticTeam2Deco].Visible := True; + end + else + begin + Text[TextScoreTeam2].Visible := False; + Text[TextNameTeam2].Visible := False; + Static[StaticTeam2].Visible := False; + Static[StaticTeam2BG].Visible := False; + Static[StaticTeam2Deco].Visible := False; + end; + + if (ScreenSingModi.PlayerInfo.NumPlayers >= 3) then + begin + Text[TextScoreTeam3].Text := InttoStr(ScreenSingModi.PlayerInfo.Playerinfo[2].Score); + Text[TextNameTeam3].Text := String(ScreenSingModi.TeamInfo.Teaminfo[2].Name); + + //Set Deco Texture + if Theme.PartyScore.DecoTextures.ChangeTextures then + begin + Static[StaticTeam3Deco].Texture.TexNum := DecoTex[Placings[2]]; + Static[StaticTeam3Deco].Texture.ColR := DecoColor[Placings[2]].R; + Static[StaticTeam3Deco].Texture.ColG := DecoColor[Placings[2]].G; + Static[StaticTeam3Deco].Texture.ColB := DecoColor[Placings[2]].B; + end; + + Text[TextScoreTeam3].Visible := True; + Text[TextNameTeam3].Visible := True; + Static[StaticTeam3].Visible := True; + Static[StaticTeam3BG].Visible := True; + Static[StaticTeam3Deco].Visible := True; + end + else + begin + Text[TextScoreTeam3].Visible := False; + Text[TextNameTeam3].Visible := False; + Static[StaticTeam3].Visible := False; + Static[StaticTeam3BG].Visible := False; + Static[StaticTeam3Deco].Visible := False; + end; + + +// LCD.WriteText(1, ' Choose mode: '); +// UpdateLCD; +end; + +procedure TScreenPartyScore.SetAnimationProgress(Progress: real); +begin + if (ScreenSingModi.PlayerInfo.NumPlayers >= 1) then + Static[StaticTeam1].Texture.ScaleW := Progress * ScreenSingModi.PlayerInfo.Playerinfo[0].Percentage / 100; + if (ScreenSingModi.PlayerInfo.NumPlayers >= 2) then + Static[StaticTeam2].Texture.ScaleW := Progress * ScreenSingModi.PlayerInfo.Playerinfo[1].Percentage / 100; + if (ScreenSingModi.PlayerInfo.NumPlayers >= 3) then + Static[StaticTeam3].Texture.ScaleW := Progress * ScreenSingModi.PlayerInfo.Playerinfo[2].Percentage / 100; +end; + +end. diff --git a/Game/Code/Screens/UScreenPartyWin.pas b/Game/Code/Screens/UScreenPartyWin.pas new file mode 100644 index 00000000..e73c1a0e --- /dev/null +++ b/Game/Code/Screens/UScreenPartyWin.pas @@ -0,0 +1,256 @@ +unit UScreenPartyWin; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, SysUtils, UThemes; + +type + TScreenPartyWin = class(TMenu) + public + TextScoreTeam1: Cardinal; + TextScoreTeam2: Cardinal; + TextScoreTeam3: Cardinal; + TextNameTeam1: Cardinal; + TextNameTeam2: Cardinal; + TextNameTeam3: Cardinal; + StaticTeam1: Cardinal; + StaticTeam1BG: Cardinal; + StaticTeam1Deco: Cardinal; + StaticTeam2: Cardinal; + StaticTeam2BG: Cardinal; + StaticTeam2Deco: Cardinal; + StaticTeam3: Cardinal; + StaticTeam3BG: Cardinal; + StaticTeam3Deco: Cardinal; + TextWinner: Cardinal; + + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure SetAnimationProgress(Progress: real); override; + end; + +implementation + +uses UGraphic, UMain, UParty, UScreenSingModi, ULanguage; + +function TScreenPartyWin.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Music.PlayStart; + FadeTo(@ScreenMain); + end; + + SDLK_RETURN: + begin + Music.PlayStart; + FadeTo(@ScreenMain); + end; + end; + end; +end; + +constructor TScreenPartyWin.Create; +var + I: integer; +begin + inherited Create; + + TextScoreTeam1 := AddText (Theme.PartyWin.TextScoreTeam1); + TextScoreTeam2 := AddText (Theme.PartyWin.TextScoreTeam2); + TextScoreTeam3 := AddText (Theme.PartyWin.TextScoreTeam3); + TextNameTeam1 := AddText (Theme.PartyWin.TextNameTeam1); + TextNameTeam2 := AddText (Theme.PartyWin.TextNameTeam2); + TextNameTeam3 := AddText (Theme.PartyWin.TextNameTeam3); + + StaticTeam1 := AddStatic (Theme.PartyWin.StaticTeam1); + StaticTeam1BG := AddStatic (Theme.PartyWin.StaticTeam1BG); + StaticTeam1Deco := AddStatic (Theme.PartyWin.StaticTeam1Deco); + StaticTeam2 := AddStatic (Theme.PartyWin.StaticTeam2); + StaticTeam2BG := AddStatic (Theme.PartyWin.StaticTeam2BG); + StaticTeam2Deco := AddStatic (Theme.PartyWin.StaticTeam2Deco); + StaticTeam3 := AddStatic (Theme.PartyWin.StaticTeam3); + StaticTeam3BG := AddStatic (Theme.PartyWin.StaticTeam3BG); + StaticTeam3Deco := AddStatic (Theme.PartyWin.StaticTeam3Deco); + + TextWinner := AddText (Theme.PartyWin.TextWinner); + + LoadFromTheme(Theme.PartyWin); +end; + +procedure TScreenPartyWin.onShow; +var + I: Integer; + Placing: TeamOrderArray; + Function GetTeamColor(Team: Byte): Cardinal; + var + NameString: String; + begin + NameString := 'P' + InttoStr(Team+1) + 'Dark'; + + Result := ColorExists(NameString); + end; +begin + //Get Team Placing + Placing := PartySession.GetTeamOrder; + + //Set Winnertext + Text[TextWinner].Text := Format(Language.Translate('PARTY_SCORE_WINS'), [PartySession.Teams.Teaminfo[Placing[0]].Name]); + + if (PartySession.Teams.NumTeams >= 1) then + begin + Text[TextScoreTeam1].Text := InttoStr(PartySession.Teams.TeamInfo[Placing[0]].Score); + Text[TextNameTeam1].Text := String(PartySession.Teams.TeamInfo[Placing[0]].Name); + + Text[TextScoreTeam1].Visible := True; + Text[TextNameTeam1].Visible := True; + Static[StaticTeam1].Visible := True; + Static[StaticTeam1BG].Visible := True; + Static[StaticTeam1Deco].Visible := True; + + //Set Static Color to Team Color + If (Theme.PartyWin.StaticTeam1BG.Color = 'TeamColor') then + begin + I := GetTeamColor(Placing[0]); + if (I <> -1) then + begin + Static[StaticTeam1BG].Texture.ColR := Color[I].RGB.R; + Static[StaticTeam1BG].Texture.ColG := Color[I].RGB.G; + Static[StaticTeam1BG].Texture.ColB := Color[I].RGB.B; + end; + end; + + If (Theme.PartyWin.StaticTeam1.Color = 'TeamColor') then + begin + I := GetTeamColor(Placing[0]); + if (I <> -1) then + begin + Static[StaticTeam1].Texture.ColR := Color[I].RGB.R; + Static[StaticTeam1].Texture.ColG := Color[I].RGB.G; + Static[StaticTeam1].Texture.ColB := Color[I].RGB.B; + end; + end; + end + else + begin + Text[TextScoreTeam1].Visible := False; + Text[TextNameTeam1].Visible := False; + Static[StaticTeam1].Visible := False; + Static[StaticTeam1BG].Visible := False; + Static[StaticTeam1Deco].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 2) then + begin + Text[TextScoreTeam2].Text := InttoStr(PartySession.Teams.TeamInfo[Placing[1]].Score); + Text[TextNameTeam2].Text := String(PartySession.Teams.TeamInfo[Placing[1]].Name); + + Text[TextScoreTeam2].Visible := True; + Text[TextNameTeam2].Visible := True; + Static[StaticTeam2].Visible := True; + Static[StaticTeam2BG].Visible := True; + Static[StaticTeam2Deco].Visible := True; + + //Set Static Color to Team Color + If (Theme.PartyWin.StaticTeam2BG.Color = 'TeamColor') then + begin + I := GetTeamColor(Placing[1]); + if (I <> -1) then + begin + Static[StaticTeam2BG].Texture.ColR := Color[I].RGB.R; + Static[StaticTeam2BG].Texture.ColG := Color[I].RGB.G; + Static[StaticTeam2BG].Texture.ColB := Color[I].RGB.B; + end; + end; + + If (Theme.PartyWin.StaticTeam2.Color = 'TeamColor') then + begin + I := GetTeamColor(Placing[1]); + if (I <> -1) then + begin + Static[StaticTeam2].Texture.ColR := Color[I].RGB.R; + Static[StaticTeam2].Texture.ColG := Color[I].RGB.G; + Static[StaticTeam2].Texture.ColB := Color[I].RGB.B; + end; + end; + end + else + begin + Text[TextScoreTeam2].Visible := False; + Text[TextNameTeam2].Visible := False; + Static[StaticTeam2].Visible := False; + Static[StaticTeam2BG].Visible := False; + Static[StaticTeam2Deco].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 3) then + begin + Text[TextScoreTeam3].Text := InttoStr(PartySession.Teams.TeamInfo[Placing[2]].Score); + Text[TextNameTeam3].Text := String(PartySession.Teams.TeamInfo[Placing[2]].Name); + + Text[TextScoreTeam3].Visible := True; + Text[TextNameTeam3].Visible := True; + Static[StaticTeam3].Visible := True; + Static[StaticTeam3BG].Visible := True; + Static[StaticTeam3Deco].Visible := True; + + //Set Static Color to Team Color + If (Theme.PartyWin.StaticTeam3BG.Color = 'TeamColor') then + begin + I := GetTeamColor(Placing[2]); + if (I <> -1) then + begin + Static[StaticTeam3BG].Texture.ColR := Color[I].RGB.R; + Static[StaticTeam3BG].Texture.ColG := Color[I].RGB.G; + Static[StaticTeam3BG].Texture.ColB := Color[I].RGB.B; + end; + end; + + If (Theme.PartyWin.StaticTeam3.Color = 'TeamColor') then + begin + I := GetTeamColor(Placing[2]); + if (I <> -1) then + begin + Static[StaticTeam3].Texture.ColR := Color[I].RGB.R; + Static[StaticTeam3].Texture.ColG := Color[I].RGB.G; + Static[StaticTeam3].Texture.ColB := Color[I].RGB.B; + end; + end; + end + else + begin + Text[TextScoreTeam3].Visible := False; + Text[TextNameTeam3].Visible := False; + Static[StaticTeam3].Visible := False; + Static[StaticTeam3BG].Visible := False; + Static[StaticTeam3Deco].Visible := False; + end; + + +// LCD.WriteText(1, ' Choose mode: '); +// UpdateLCD; +end; + +procedure TScreenPartyWin.SetAnimationProgress(Progress: real); +begin + {if (ScreenSingModi.PlayerInfo.NumPlayers >= 1) then + Static[StaticTeam1].Texture.ScaleW := Progress * ScreenSingModi.PlayerInfo.Playerinfo[0].Score / maxScore; + if (ScreenSingModi.PlayerInfo.NumPlayers >= 2) then + Static[StaticTeam2].Texture.ScaleW := Progress * ScreenSingModi.PlayerInfo.Playerinfo[1].Score / maxScore; + if (ScreenSingModi.PlayerInfo.NumPlayers >= 3) then + Static[StaticTeam3].Texture.ScaleW := Progress * ScreenSingModi.PlayerInfo.Playerinfo[2].Score / maxScore;} +end; + +end. diff --git a/Game/Code/Screens/UScreenPopup.pas b/Game/Code/Screens/UScreenPopup.pas new file mode 100644 index 00000000..f583eb90 --- /dev/null +++ b/Game/Code/Screens/UScreenPopup.pas @@ -0,0 +1,247 @@ +unit UScreenPopup; + +interface + +uses + UMenu, SDL, UMusic, UFiles, SysUtils, UThemes; + +type + TScreenPopupCheck = class(TMenu) + public + Visible: Boolean; //Whether the Menu should be Drawn + + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure ShowPopup(msg: String); + function Draw: boolean; override; + end; + +type + TScreenPopupError = class(TMenu) + private + CurMenu: Byte; //Num of the cur. Shown Menu + public + Visible: Boolean; //Whether the Menu should be Drawn + + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure onHide; override; + procedure ShowPopup(msg: String); + function Draw: boolean; override; + end; + +var +// ISelections: Array of String; + SelectValue: Integer; + + +implementation + +uses UGraphic, UMain, UIni, UTexture, ULanguage, UParty, UPlaylist, UDisplay; + +function TScreenPopupCheck.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Display.CheckOK:=False; + Display.NextScreenWithCheck:=NIL; + Visible:=False; + Result := false; + end; + + SDLK_RETURN: + begin + case Interaction of + 0: begin + //Hack to Finish Singscreen correct on Exit with Q Shortcut + if (Display.NextScreenWithCheck = NIL) then + begin + if (Display.ActualScreen = @ScreenSing) then + ScreenSing.Finish + else if (Display.ActualScreen = @ScreenSingModi) then + ScreenSingModi.Finish; + end; + + Display.CheckOK:=True; + end; + 1: begin + Display.CheckOK:=False; + Display.NextScreenWithCheck:=NIL; + end; + end; + Visible:=False; + Result := false; + end; + + SDLK_DOWN: InteractNext; + SDLK_UP: InteractPrev; + + SDLK_RIGHT: InteractNext; + SDLK_LEFT: InteractPrev; + end; + end; +end; + +constructor TScreenPopupCheck.Create; +var + I: integer; +begin + inherited Create; + + AddBackground(Theme.CheckPopup.Background.Tex); + + AddButton(Theme.CheckPopup.Button1); + if (Length(Button[0].Text) = 0) then + AddButtonText(14, 20, 'Button 1'); + + AddButton(Theme.CheckPopup.Button2); + if (Length(Button[1].Text) = 0) then + AddButtonText(14, 20, 'Button 2'); + + AddText(Theme.CheckPopup.TextCheck); + + for I := 0 to High(Theme.CheckPopup.Static) do + AddStatic(Theme.CheckPopup.Static[I]); + + for I := 0 to High(Theme.CheckPopup.Text) do + AddText(Theme.CheckPopup.Text[I]); + + Interaction := 0; +end; + +function TScreenPopupCheck.Draw: boolean; +begin + inherited Draw; +end; + +procedure TScreenPopupCheck.onShow; +begin + +end; + +procedure TScreenPopupCheck.ShowPopup(msg: String); +begin + Interaction := 0; //Reset Interaction + Visible := True; //Set Visible + + Text[0].Text := Language.Translate(msg); + + Button[0].Visible := True; + Button[1].Visible := True; + + Button[0].Text[0].Text := Language.Translate('SONG_MENU_YES'); + Button[1].Text[0].Text := Language.Translate('SONG_MENU_NO'); +end; + +// error popup + +function TScreenPopupError.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Visible:=False; + Result := false; + end; + + SDLK_RETURN: + begin + Visible:=False; + Result := false; + end; + + SDLK_DOWN: InteractNext; + SDLK_UP: InteractPrev; + + SDLK_RIGHT: InteractNext; + SDLK_LEFT: InteractPrev; + end; + end; +end; + +constructor TScreenPopupError.Create; +var + I: integer; +begin + inherited Create; + + AddBackground(Theme.CheckPopup.Background.Tex); + + AddButton(Theme.ErrorPopup.Button1); + if (Length(Button[0].Text) = 0) then + AddButtonText(14, 20, 'Button 1'); + + AddText(Theme.ErrorPopup.TextError); + + for I := 0 to High(Theme.ErrorPopup.Static) do + AddStatic(Theme.ErrorPopup.Static[I]); + + for I := 0 to High(Theme.ErrorPopup.Text) do + AddText(Theme.ErrorPopup.Text[I]); + + Interaction := 0; +end; + +function TScreenPopupError.Draw: boolean; +begin + inherited Draw; +end; + +procedure TScreenPopupError.onShow; +begin + +end; + +procedure TScreenPopupError.onHide; +var i: integer; +begin +end; + +procedure TScreenPopupError.ShowPopup(msg: String); +var i: integer; +begin + Interaction := 0; //Reset Interaction + Visible := True; //Set Visible + +{ //dirty hack... Text[0] is invisible for some strange reason + for i:=1 to high(Text) do + if i-1 <= high(msg) then + begin + Text[i].Visible:=True; + Text[i].Text := msg[i-1]; + end + else + begin + Text[i].Visible:=False; + end;} + Text[0].Text:=msg; + + Button[0].Visible := True; + + Button[0].Text[0].Text := 'OK'; +end; + +end. diff --git a/Game/Code/Screens/UScreenScore.pas b/Game/Code/Screens/UScreenScore.pas new file mode 100644 index 00000000..0a80381d --- /dev/null +++ b/Game/Code/Screens/UScreenScore.pas @@ -0,0 +1,385 @@ +unit UScreenScore; + +interface + +uses + UMenu, SDL, SysUtils, UDisplay, UMusic, USongs, UThemes, ULCD, OpenGL; + +type + TScreenScore = class(TMenu) + public + TextArtist: integer; + TextTitle: integer; + + TextArtistTitle : integer; + + TextName: array[1..6] of integer; + TextScore: array[1..6] of integer; + + TextNotes: array[1..6] of integer; + TextNotesScore: array[1..6] of integer; + TextLineBonus: array[1..6] of integer; + TextLineBonusScore: array[1..6] of integer; + TextGoldenNotes: array[1..6] of integer; + TextGoldenNotesScore: array[1..6] of integer; + TextTotal: array[1..6] of integer; + TextTotalScore: array[1..6] of integer; + + PlayerStatic: array[1..6] of array of integer; + PlayerTexts : array[1..6] of array of integer; + + + StaticBoxLightest: array[1..6] of integer; + StaticBoxLight: array[1..6] of integer; + StaticBoxDark: array[1..6] of integer; + + StaticBackLevel: array[1..6] of integer; + StaticBackLevelRound: array[1..6] of integer; + StaticLevel: array[1..6] of integer; + StaticLevelRound: array[1..6] of integer; + + Animation: real; + Fadeout: boolean; + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + function Draw: boolean; override; + procedure FillPlayer(Item, P: integer); + end; + +implementation + +{{$IFDEF TRANSLATE} +uses UGraphic, UScreenSong, UMenuStatic, UTime, UMain, UIni, ULanguage; +{{$ELSE}{ +uses UGraphic, UScreenSong, UMenuStatic, UTime, UMain, UIni; +{{$ENDIF} +function TScreenScore.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then begin + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + if (not Fadeout) then begin +// Music.StopShuffle; + FadeTo(@ScreenTop5); + Fadeout := true; + end; + end; + SDLK_RETURN: + begin + if (not Fadeout) then begin +// Music.StopShuffle; + FadeTo(@ScreenTop5); + Fadeout := true; + end; + end; +{ SDLK_SYSREQ: + begin + beep; + end;} + SDLK_SYSREQ: + begin + Display.PrintScreen; + end; + end; + end; +end; + +constructor TScreenScore.Create; +var + P: integer; + I, C: integer; +begin + inherited Create; + + LoadFromTheme(Theme.Score); + + TextArtist := AddText(Theme.Score.TextArtist); + TextTitle := AddText(Theme.Score.TextTitle); + + TextArtistTitle := AddText(Theme.Score.TextArtistTitle); + + for P := 1 to 6 do begin + TextName[P] := AddText(Theme.Score.TextName[P]); + TextScore[P] := AddText(Theme.Score.TextScore[P]); + + TextNotes[P] := AddText(Theme.Score.TextNotes[P]); + TextNotesScore[P] := AddText(Theme.Score.TextNotesScore[P]); + TextLineBonus[P] := AddText(Theme.Score.TextLineBonus[P]); + TextLineBonusScore[P] := AddText(Theme.Score.TextLineBonusScore[P]); + TextGoldenNotes[P] := AddText(Theme.Score.TextGoldenNotes[P]); + TextGoldenNotesScore[P] := AddText(Theme.Score.TextGoldenNotesScore[P]); + TextTotal[P] := AddText(Theme.Score.TextTotal[P]); + TextTotalScore[P] := AddText(Theme.Score.TextTotalScore[P]); + + SetLength(PlayerStatic[P], Length(Theme.Score.PlayerStatic[P])); + + SetLength(PlayerTexts[P], Length(Theme.Score.PlayerTexts[P])); + + for I := 0 to High(Theme.Score.PlayerStatic[P]) do + PlayerStatic[P, I] := AddStatic(Theme.Score.PlayerStatic[P, I]); + + + //added by mog + for C := 0 to High(Theme.Score.PlayerTexts[P]) do + PlayerTexts[P, C] := AddText(Theme.Score.PlayerTexts[P, C]); + // more skinable now + + StaticBoxLightest[P] := AddStatic(Theme.Score.StaticBoxLightest[P]); + StaticBoxLight[P] := AddStatic(Theme.Score.StaticBoxLight[P]); + StaticBoxDark[P] := AddStatic(Theme.Score.StaticBoxDark[P]); + + StaticBackLevel[P] := AddStatic(Theme.Score.StaticBackLevel[P]); + StaticBackLevelRound[P] := AddStatic(Theme.Score.StaticBackLevelRound[P]); + StaticLevel[P] := AddStatic(Theme.Score.StaticLevel[P]); + StaticLevelRound[P] := AddStatic(Theme.Score.StaticLevelRound[P]); + end; +end; + +procedure TScreenScore.onShow; +var + P: integer; // player + PP: integer; // another player variable + S: string; + I: integer; + Skip: integer; + V: array[1..6] of boolean; // visibility array +begin + + // Singstar + Fadeout := false; + + Text[TextArtist].Text := AktSong.Artist; + Text[TextTitle].Text := AktSong.Title; + Text[TextArtistTitle].Text := AktSong.Artist + ' - ' + AktSong.Title; + + // set visibility + case PlayersPlay of + 1: begin + V[1] := true; + V[2] := false; + V[3] := false; + V[4] := false; + V[5] := false; + V[6] := false; + end; + 2, 4: begin + V[1] := false; + V[2] := true; + V[3] := true; + V[4] := false; + V[5] := false; + V[6] := false; + end; + 3, 6: begin + V[1] := false; + V[2] := false; + V[3] := false; + V[4] := true; + V[5] := true; + V[6] := true; + end; + end; + + for P := 1 to 6 do begin + Text[TextName[P]].Visible := V[P]; + Text[TextScore[P]].Visible := V[P]; + + Text[TextNotes[P]].Visible := V[P]; + Text[TextNotesScore[P]].Visible := V[P]; + Text[TextLineBonus[P]].Visible := V[P]; + Text[TextLineBonusScore[P]].Visible := V[P]; + Text[TextGoldenNotes[P]].Visible := V[P]; + Text[TextGoldenNotesScore[P]].Visible := V[P]; + Text[TextTotal[P]].Visible := V[P]; + Text[TextTotalScore[P]].Visible := V[P]; + + for I := 0 to high(PlayerStatic[P]) do + Static[PlayerStatic[P, I]].Visible := V[P]; + + for I := 0 to high(PlayerTexts[P]) do + Text[PlayerTexts[P, I]].Visible := V[P]; + + Static[StaticBoxLightest[P]].Visible := V[P]; + Static[StaticBoxLight[P]].Visible := V[P]; + Static[StaticBoxDark[P]].Visible := V[P]; + + Static[StaticBackLevel[P]].Visible := V[P]; + Static[StaticBackLevelRound[P]].Visible := V[P]; + Static[StaticLevel[P]].Visible := V[P]; + Static[StaticLevelRound[P]].Visible := V[P]; + end; + + if PlayersPlay <= 3 then begin // only for 1 screen mode + for P := 0 to PlayersPlay-1 do begin + case PlayersPlay of + 1: PP := 1; + 2: PP := P + 2; + 3: PP := P + 4; + end; + + //Replaced this whole thing with one Procedure call + FillPlayer(PP, P); + + end; // for + end; // if + + LCD.HideCursor; + LCD.Clear; + LCD.WriteText(1, Ini.Name[0]); + LCD.WriteText(2, 'Score: ' + Text[TextTotalScore[1]].Text); + +end; + +function TScreenScore.Draw: boolean; +var +{ Min: real; + Max: real; + Wsp: real; + Wsp2: real; + Pet: integer;} + + Item: integer; + P: integer; + C: integer; +begin + // 0.5.0: try also use 4 players screen with nicks + if PlayersPlay = 4 then begin + for Item := 2 to 3 do begin + if ScreenAct = 1 then P := Item-2; + if ScreenAct = 2 then P := Item; + + FillPlayer(Item, P); + end; + end; + + + // Singstar - let it be...... with 6 statics + if PlayersPlay = 6 then begin + for Item := 4 to 6 do begin + if ScreenAct = 1 then P := Item-4; + if ScreenAct = 2 then P := Item-1; + + FillPlayer(Item, P); + + end; + end; + + inherited Draw; +end; + +procedure TScreenScore.FillPlayer(Item, P: integer); +var + S: string; + Lev: real; + MaxH: real; // maximum height of score bar + Wsp: real; +begin + Text[TextName[Item]].Text := Ini.Name[P]; + + case (Player[P].ScoreTotalI) of + 0..2000: Text[TextScore[Item]].Text := Language.Translate('SING_SCORE_TONE_DEAF'); + 2010..4000: Text[TextScore[Item]].Text := Language.Translate('SING_SCORE_AMATEUR'); + 4010..6000: Text[TextScore[Item]].Text := Language.Translate('SING_SCORE_RISING_STAR'); + 6010..8000: Text[TextScore[Item]].Text := Language.Translate('SING_SCORE_LEAD_SINGER'); + 8010..9000: Text[TextScore[Item]].Text := Language.Translate('SING_SCORE_HIT_ARTIST'); + 9010..9800: Text[TextScore[Item]].Text := Language.Translate('SING_SCORE_SUPERSTAR'); + 9810..10000: Text[TextScore[Item]].Text := Language.Translate('SING_SCORE_ULTRASTAR'); + end; + + + S := IntToStr(Player[P].ScoreI); + while (Length(S)<4) do S := '0' + S; + Text[TextNotesScore[Item]].Text := S; + + S := IntToStr(Player[P].ScoreLineI); + while (Length(S)<4) do S := '0' + S; + Text[TextLineBonusScore[Item]].Text := S; + + S := IntToStr(Player[P].ScoreGoldenI); + while (Length(S)<4) do S := '0' + S; + Text[TextGoldenNotesScore[Item]].Text := S; + + S := IntToStr(Player[P].ScoreTotalI); + while (Length(S)<5) do S := '0' + S; + Text[TextTotalScore[Item]].Text := S; + + // Level bar length + + + Lev := Player[P].ScoreTotalI / 10000; + MaxH := Static[StaticBackLevel[Item]].Texture.H + Static[StaticBackLevelRound[Item]].Texture.H / 2; + + // developer note (Polish): + // w sumie np. 120 pix + // ten static moze miec 100 pix + // wlacza sie od 20 pix i rosnie do 120 pix + // wiec wysokosc = wyznaczona ilosc - 20 + // nie moze byc mniejsze od 0 + // Lev * MaxH = total number of pixels to draw + Static[StaticLevel[Item]].Visible := true; + Static[StaticLevel[Item]].Texture.H := Lev * MaxH - Static[StaticBackLevelRound[Item]].Texture.H / 2; + if Static[StaticLevel[Item]].Texture.H < 0 then Static[StaticLevel[Item]].Visible := false; + + // Y doesn't change and depend on the back texture coordinate + Static[StaticLevel[Item]].Texture.Y := Static[StaticBackLevel[Item]].Texture.Y + Static[StaticBackLevel[Item]].Texture.H - Static[StaticLevel[Item]].Texture.H; + + // we modify LevelRound texture by changing it's Y. TexY1 and TexY2 change when the height to draw is lower than 20 + if Lev * MaxH < Static[StaticBackLevelRound[Item]].Texture.H / 2 then begin + // when it's lower than 20 => we move TexY1 and TexY2 higher to show only part of this texture + Static[StaticLevelRound[Item]].Texture.Y := Static[StaticBackLevel[Item]].Texture.Y + Static[StaticBackLevel[Item]].Texture.H - Static[StaticBackLevelRound[Item]].Texture.H; + // - 0.25 when points = 0 + // - 0 wnen there are more points + // if Lev * MaxH = Static[StaticBackLevelRound[Item]].Texture.H / 2) then we do not change it + // if Lev * MaxH = 0 then we substract 0.25 + // we substract (0.25 - 0.25 * (Lev * MaxH)/Static[StaticBackLevelRound[Item]].Texture.H / 2) + Wsp := Lev * MaxH / (Static[StaticBackLevelRound[Item]].Texture.H / 2); + Static[StaticLevelRound[Item]].Texture.TexY1 := Static[StaticBackLevelRound[Item]].Texture.TexY1 - 0.25 + 0.25 * Wsp; + Static[StaticLevelRound[Item]].Texture.TexY2 := Static[StaticBackLevelRound[Item]].Texture.TexY2 - 0.25 + 0.25 * Wsp; + end else begin + // when it's higher or equal 20 => full texture is being shown + Static[StaticLevelRound[Item]].Texture.TexY1 := Static[StaticBackLevelRound[Item]].Texture.TexY1; + Static[StaticLevelRound[Item]].Texture.TexY2 := Static[StaticBackLevelRound[Item]].Texture.TexY2; + Static[StaticLevelRound[Item]].Texture.Y := Static[StaticLevel[Item]].Texture.Y - Static[StaticBackLevelRound[Item]].Texture.H; + end; + + //Load Colors of Player Buttons and Nicks + LoadColor( + Text[TextName[Item]].ColR, + Text[TextName[Item]].ColG, + Text[TextName[Item]].ColB, + 'P' + IntToStr(P+1) + 'Dark'); + + LoadColor( + Static[StaticBoxLightest[Item]].Texture.ColR, + Static[StaticBoxLightest[Item]].Texture.ColG, + Static[StaticBoxLightest[Item]].Texture.ColB, + 'P' + IntToStr(P+1) + 'Lightest'); + + LoadColor( + Static[StaticBoxLight[Item]].Texture.ColR, + Static[StaticBoxLight[Item]].Texture.ColG, + Static[StaticBoxLight[Item]].Texture.ColB, + 'P' + IntToStr(P+1) + 'Light'); + + LoadColor( + Static[StaticBoxDark[Item]].Texture.ColR, + Static[StaticBoxDark[Item]].Texture.ColG, + Static[StaticBoxDark[Item]].Texture.ColB, + 'P' + IntToStr(P+1) + 'Dark'); + + {StaticBackLevel[Item] + StaticLevelRound[Item] + and another static has to be colored here to. + S/o please do this ^^} +end; + +end. diff --git a/Game/Code/Screens/UScreenSing.pas b/Game/Code/Screens/UScreenSing.pas new file mode 100644 index 00000000..5409d9a9 --- /dev/null +++ b/Game/Code/Screens/UScreenSing.pas @@ -0,0 +1,1287 @@ +unit UScreenSing; + +interface + +uses UMenu, UMusic, SDL, SysUtils, UFiles, UTime, USongs, UIni, ULog, USmpeg, UTexture, ULyrics, + TextGL, OpenGL12, BASS, UThemes, ULCD, UGraphicClasses; + +type + TScreenSing = class(TMenu) + protected + paused: boolean; //Pause Mod + PauseTime: Real; + NumEmptySentences: integer; + public + //TextTime: integer; + + //TimeBar mod + StaticTimeProgress: integer; + TextTimeText: integer; + //eoa TimeBar mod + + StaticP1: integer; + StaticP1ScoreBG: integer; + TextP1: integer; + TextP1Score: integer; + + //moveable singbar mod + StaticP1SingBar: integer; + StaticP1ThreePSingBar: integer; + StaticP1TwoPSingBar: integer; + StaticP2RSingBar: integer; + StaticP2MSingBar: integer; + StaticP3SingBar: integer; + //eoa moveable singbar + + //Added for ps3 skin + //shown when game is in 2/4 player modus + StaticP1TwoP: integer; + StaticP1TwoPScoreBG: integer; + TextP1TwoP: integer; + TextP1TwoPScore: integer; + //shown when game is in 3/6 player modus + StaticP1ThreeP: integer; + StaticP1ThreePScoreBG: integer; + TextP1ThreeP: integer; + TextP1ThreePScore: integer; + //eoa + + StaticP2R: integer; + StaticP2RScoreBG: integer; + TextP2R: integer; + TextP2RScore: integer; + + StaticP2M: integer; + StaticP2MScoreBG: integer; + TextP2M: integer; + TextP2MScore: integer; + + StaticP3R: integer; + StaticP3RScoreBG: integer; + TextP3R: integer; + TextP3RScore: integer; + + Tex_Background: TTexture; + FadeOut: boolean; + LyricMain: TLyric; + LyricSub: TLyric; + + constructor Create; override; + procedure onShow; override; + procedure onShowFinish; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function Draw: boolean; override; + procedure Finish; virtual; + procedure UpdateLCD; + procedure Pause; //Pause Mod(Toggles Pause) + + //OnSentenceEnd for LineBonus + Singbar + procedure onSentenceEnd(S: Cardinal); + //OnSentenceChange (for Golden Notes) + procedure onSentenceChange(S: Cardinal); + end; + +implementation +uses UGraphic, UDraw, UMain, Classes, URecord, ULanguage, math; + +// Method for input parsing. If False is returned, GetNextWindow +// should be checked to know the next window to load; +function TScreenSing.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + //When not ask before Exit then Finish now + if (Ini.AskbeforeDel <> 1) then + Finish + //else just Pause and let the Popup make the Work + else if not paused then + Pause; + + Result := false; + end; + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + //Record Sound Hack: + //Sound[0].BufferLong + + Finish; + Music.PlayBack; + FadeTo(@ScreenScore); + end; + + SDLK_P://Pause Mod + begin + Pause; + end; + + SDLK_RETURN: + begin + end; + + // Up and Down could be done at the same time, + // but I don't want to declare variables inside + // functions like this one, called so many times + SDLK_DOWN : + begin + end; + SDLK_UP : + begin + end; + end; + end; +end; + +//Pause Mod +procedure TScreenSing.Pause; +begin + if not paused then //Pause einschalten + begin + PauseTime := Czas.Teraz; + Paused := true; + //stop Music + Music.Pause; + if (AktSong.Video <> '') and FileExists(AktSong.Path + AktSong.Video) then //Video + PauseSmpeg; //Video + end + else //Pause ausschalten + begin + Czas.Teraz := PauseTime; //Position of Notes + Music.MoveTo (PauseTime);//Position of Music + Music.Play; //Play Music + if (AktSong.Video <> '') and FileExists(AktSong.Path + AktSong.Video) then //Video + PlaySmpeg; + //SkipSmpeg(PauseTime); + Paused := false; + end; +end; +//Pause Mod End + +constructor TScreenSing.Create; +var + I: integer; + P: integer; +begin + inherited Create; + + LoadFromTheme(Theme.Sing); + + // time + //TextTime := AddText(75, 14, 1, 8, 0.25, 0.25, 0.25, '00:00'); + + //TimeBar mod + StaticTimeProgress := AddStatic(Theme.Sing.StaticTimeProgress); + TextTimeText := AddText(Theme.Sing.TextTimeText); + //eoa TimeBar mod + + StaticP1 := AddStatic(Theme.Sing.StaticP1); + StaticP1ScoreBG := AddStatic(Theme.Sing.StaticP1ScoreBG); + TextP1 := AddText(Theme.Sing.TextP1); + TextP1Score := AddText(Theme.Sing.TextP1Score); + + //moveable singbar mod + StaticP1SingBar := AddStatic(Theme.Sing.StaticP1SingBar); + StaticP1ThreePSingBar := AddStatic(Theme.Sing.StaticP1ThreePSingBar); + StaticP1TwoPSingBar := AddStatic(Theme.Sing.StaticP2RSingBar); + StaticP2RSingBar := AddStatic(Theme.Sing.StaticP2RSingBar); + StaticP2MSingBar := AddStatic(Theme.Sing.StaticP2MSingBar); + StaticP3SingBar := AddStatic(Theme.Sing.StaticP3SingBar); + //eoa moveable singbar + + //Added for ps3 skin + //This one is shown in 2/4P mode + StaticP1TwoP := AddStatic(Theme.Sing.StaticP1TwoP); + StaticP1TwoPScoreBG := AddStatic(Theme.Sing.StaticP1TwoPScoreBG); + TextP1TwoP := AddText(Theme.Sing.TextP1TwoP); + TextP1TwoPScore := AddText(Theme.Sing.TextP1TwoPScore); + + //This one is shown in 3/6P mode + StaticP1ThreeP := AddStatic(Theme.Sing.StaticP1ThreeP); + StaticP1ThreePScoreBG := AddStatic(Theme.Sing.StaticP1ThreePScoreBG); + TextP1ThreeP := AddText(Theme.Sing.TextP1ThreeP); + TextP1ThreePScore := AddText(Theme.Sing.TextP1ThreePScore); + //eoa + + StaticP2R := AddStatic(Theme.Sing.StaticP2R); + StaticP2RScoreBG := AddStatic(Theme.Sing.StaticP2RScoreBG); + TextP2R := AddText(Theme.Sing.TextP2R); + TextP2RScore := AddText(Theme.Sing.TextP2RScore); + + StaticP2M := AddStatic(Theme.Sing.StaticP2M); + StaticP2MScoreBG := AddStatic(Theme.Sing.StaticP2MScoreBG); + TextP2M := AddText(Theme.Sing.TextP2M); + TextP2MScore := AddText(Theme.Sing.TextP2MScore); + + StaticP3R := AddStatic(Theme.Sing.StaticP3R); + StaticP3RScoreBG := AddStatic(Theme.Sing.StaticP3RScoreBG); + TextP3R := AddText(Theme.Sing.TextP3R); + TextP3RScore := AddText(Theme.Sing.TextP3RScore); + + LyricMain := TLyric.Create; + LyricSub := TLyric.Create; +end; + +procedure TScreenSing.onShow; +var + P: integer; + V1: boolean; + V1TwoP: boolean; //added for ps3 skin + V1ThreeP: boolean; //added for ps3 skin + V2R: boolean; + V2M: boolean; + V3R: boolean; + NR: TRecR; //Line Bonus Mod +begin + Log.LogStatus('Begin', 'onShow'); + FadeOut := false; // 0.5.0: early 0.5.0 problems were by this line commented + + // prepare players + SetLength(Player, PlayersPlay); +// Player[0].ScoreTotalI := 0; + + + case PlayersPlay of + 1: begin + V1 := true; + V1TwoP := false; //added for ps3 skin + V1ThreeP := false; //added for ps3 skin + V2R := false; + V2M := false; + V3R := false; + end; + 2: begin + V1 := false; + V1TwoP := true; //added for ps3 skin + V1ThreeP := false; //added for ps3 skin + V2R := true; + V2M := false; + V3R := false; + end; + 3: begin + V1 := false; + V1TwoP := false; //added for ps3 skin + V1ThreeP := true; //added for ps3 skin + V2R := false; + V2M := true; + V3R := true; + end; + 4: begin // double screen + V1 := false; + V1TwoP := true; //added for ps3 skin + V1ThreeP := false; //added for ps3 skin + V2R := true; + V2M := false; + V3R := false; + end; + 6: begin // double screen + V1 := false; + V1TwoP := false; //added for ps3 skin + V1ThreeP := true; //added for ps3 skin + V2R := false; + V2M := true; + V3R := true; + end; + + end; + + //Added for ps3 skin + //This one is shown in 1P mode + Static[StaticP1].Visible := V1; + Static[StaticP1ScoreBG].Visible := V1; + Text[TextP1].Visible := V1; + Text[TextP1Score].Visible := V1; + //This one is shown in 2/4P mode + Static[StaticP1TwoP].Visible := V1TwoP; + Static[StaticP1TwoPScoreBG].Visible := V1TwoP; + Text[TextP1TwoP].Visible := V1TwoP; + Text[TextP1TwoPScore].Visible := V1TwoP; + //This one is shown in 3/6P mode + Static[StaticP1ThreeP].Visible := V1ThreeP; + Static[StaticP1ThreePScoreBG].Visible := V1ThreeP; + Text[TextP1ThreeP].Visible := V1ThreeP; + Text[TextP1ThreePScore].Visible := V1ThreeP; + //eoa + + Static[StaticP2R].Visible := V2R; + Static[StaticP2RScoreBG].Visible := V2R; + Text[TextP2R].Visible := V2R; + Text[TextP2RScore].Visible := V2R; + + Static[StaticP2M].Visible := V2M; + Static[StaticP2MScoreBG].Visible := V2M; + Text[TextP2M].Visible := V2M; + Text[TextP2MScore].Visible := V2M; + + Static[StaticP3R].Visible := V3R; + Static[StaticP3RScoreBG].Visible := V3R; + Text[TextP3R].Visible := V3R; + Text[TextP3RScore].Visible := V3R; + + // load notes + ResetSingTemp; +// Log.LogWarning(CatSongs.Song[CatSongs.Selected].Path + CatSongs.Song[CatSongs.Selected].FileName, '!!!'); + AktSong := CatSongs.Song[CatSongs.Selected]; + try + if not LoadSong(CatSongs.Song[CatSongs.Selected].Path + CatSongs.Song[CatSongs.Selected].FileName) then + begin + //Error Loading Song -> Go back to Song Screen and Show some Error Message + FadeTo(@ScreenSong); + //Select New Song in Party Mode + if ScreenSong.Mode = 1 then + ScreenSong.SelectRandomSong; + ScreenPopupError.ShowPopup (Language.Translate('ERROR_CORRUPT_SONG')); + Exit; + end; + except + //Error Loading Song -> Go back to Song Screen and Show some Error Message + FadeTo(@ScreenSong); + //Select New Song in Party Mode + if ScreenSong.Mode = 1 then + ScreenSong.SelectRandomSong; + ScreenPopupError.ShowPopup (Language.Translate('ERROR_CORRUPT_SONG')); + Exit; + end; + AktSong.Path := CatSongs.Song[CatSongs.Selected].Path; +// AktSong.GAP := AktSong.GAP + 40 {4096 = 100ms for buffer} + 20 {microphone} + 60000 / AktSong.BPM[0].BPM / 2; // temporary until UMain will be fixed + + // set movie + if (AktSong.Video <> '') and FileExists(AktSong.Path + AktSong.Video) then begin + OpenSmpeg(AktSong.Path + AktSong.Video); + SkipSmpeg(AktSong.VideoGAP + AktSong.Start); + AktSong.VideoLoaded := true; + end; + + // set background + if (AktSong.Background <> '') and (AktSong.VideoLoaded = false) then + try + Tex_Background := Texture.LoadTexture(AktSong.Path + AktSong.Background); + except + log.LogError('Background could not be loaded: ' + AktSong.Path + AktSong.Background); + Tex_Background.TexNum := -1; + end + else + Tex_Background.TexNum := -1; + + + + // play music (I) + Music.CaptureStart; + Music.MoveTo(AktSong.Start); +// Music.Play; + + // prepare timer (I) +// CountSkipTimeSet; + Czas.Teraz := AktSong.Start; + Czas.Razem := Music.Length; + if (AktSong.Finish > 0) then Czas.Razem := AktSong.Finish / 1000; + Czas.OldBeat := -1; + for P := 0 to High(Player) do + ClearScores(P); + + // main text + LyricMain.Clear; + LyricMain.X := 400; + LyricMain.Y := Skin_LyricsT; + LyricMain.Scale := 1.4; //1.4 + LyricMain.Align := 1; + + // sub text + LyricSub.Clear; + LyricSub.X := 400; + LyricSub.Y := Skin_LyricsT + 35; //42 //40 + LyricSub.Align := 1; + + // set custom options + case Ini.LyricsFont of + 0: + begin + LyricMain.FontStyle := 0; + LyricSub.FontStyle := 0; + LyricMain.Size := 14; // 13 + LyricSub.Size := 14; // 13 + LyricMain.ColR := Skin_FontR; + LyricMain.ColG := Skin_FontG; + LyricMain.ColB := Skin_FontB; //Change für Crazy Joker + {LyricMain.ColSR := Skin_FontHighlightR; + LyricMain.ColSG := Skin_FontHighlightG; + LyricMain.ColSB := Skin_FontHighlightB;1aa5dc} + LyricMain.ColSR := 5/255; //26 + LyricMain.ColSG := 163/255; //165 + LyricMain.ColSB := 210/255; //220 + + LyricSub.ColR := 0.4; //0.6 + LyricSub.ColG := 0.4; //0.6 + LyricSub.ColB := 0.4; //0.6 + end; + 1: + begin + LyricMain.FontStyle := 2; + LyricSub.FontStyle := 2; + LyricMain.Size := 14; + LyricSub.Size := 14; + LyricMain.ColR := 0.75; + LyricMain.ColG := 0.75; + LyricMain.ColB := 1; + LyricMain.ColSR := 0.5; + LyricMain.ColSG := 0.5; + LyricMain.ColSB := 1; + LyricSub.ColR := 0.8; + LyricSub.ColG := 0.8; + LyricSub.ColB := 0.8; + end; + 2: + begin + LyricMain.FontStyle := 3; + LyricSub.FontStyle := 3; + LyricMain.Size := 12; + LyricSub.Size := 12; + LyricMain.ColR := 0.75; + LyricMain.ColG := 0.75; + LyricMain.ColB := 1; + LyricMain.ColSR := 0.5; + LyricMain.ColSG := 0.5; + LyricMain.ColSB := 1; + LyricSub.ColR := 0.8; + LyricSub.ColG := 0.8; + LyricSub.ColB := 0.8; + end; + end; // case + + case Ini.LyricsEffect of + 0: LyricMain.Style := 1; // 0 - one selected, 1 - selected all to the current + 1: LyricMain.Style := 2; + 2: LyricMain.Style := 3; + 3: LyricMain.Style := 4; + end; // case + + // fill texts + LyricMain.AddCzesc(0); + LyricMain.Selected := -1; + LyricSub.AddCzesc(1); + LyricSub.Selected := -1; + + UpdateLCD; + + //Deactivate Pause + Paused := False; + + //Kill all Stars not Killed yet + //GoldenStarsTwinkle Mod + GoldenRec.SentenceChange; + //GoldenStarsTwinkle Mod End + + {Static[StaticP2R].Visible := V2R; + Static[StaticP2RScoreBG].Visible := V2R; + Text[TextP2R].Visible := V2R; + Text[TextP2RScore].Visible := V2R; + + Static[StaticP2M].Visible := V2M; + Static[StaticP2MScoreBG].Visible := V2M; + Text[TextP2M].Visible := V2M; + Text[TextP2MScore].Visible := V2M; + + Static[StaticP3R].Visible := V3R; + Static[StaticP3RScoreBG].Visible := V3R; + Text[TextP3R].Visible := V3R; + Text[TextP3RScore].Visible := V3R;} + + //Set Position of Line Bonus - PhrasenBonus + if (Ini.LineBonus = 1) then //Show Line Bonus at Scores + begin + Case PlayersPlay of + 1: begin + Player[0].LineBonus_TargetX := Theme.Sing.StaticP1ScoreBG.x; + Player[0].LineBonus_TargetY := Theme.Sing.TextP1Score.Y; + Player[0].LineBonus_StartX := Theme.Sing.StaticP1ScoreBG.x; + Player[0].LineBonus_StartY := Theme.Sing.TextP1Score.Y + 65; + end; + + 2: begin + //P1 + Player[0].LineBonus_TargetX := Theme.Sing.StaticP1TwoPScoreBG.x; + Player[0].LineBonus_TargetY := Theme.Sing.TextP1TwoPScore.Y; + Player[0].LineBonus_StartX := Theme.Sing.StaticP1TwoPScoreBG.X; + Player[0].LineBonus_StartY := Theme.Sing.TextP1TwoPScore.Y + 65; + + //P2 + Player[1].LineBonus_TargetX := Theme.Sing.StaticP2RScoreBG.X; + Player[1].LineBonus_TargetY := Theme.Sing.TextP2RScore.Y; + Player[1].LineBonus_StartX := Theme.Sing.StaticP2RScoreBG.X; + Player[1].LineBonus_StartY := Theme.Sing.TextP2RScore.Y + 65; + end; + + 3: begin + //P1 + Player[0].LineBonus_TargetX := Theme.Sing.StaticP1ThreePScoreBG.x; + Player[0].LineBonus_TargetY := Theme.Sing.TextP1ThreePScore.Y; + Player[0].LineBonus_StartX := Theme.Sing.StaticP1ThreePScoreBG.x; + Player[0].LineBonus_StartY := Theme.Sing.TextP1ThreePScore.Y + 65; + + //P2 + Player[1].LineBonus_TargetX := Theme.Sing.StaticP2MScoreBG.x; + Player[1].LineBonus_TargetY := Theme.Sing.TextP2MScore.Y; + Player[1].LineBonus_StartX := Theme.Sing.StaticP2MScoreBG.x; + Player[1].LineBonus_StartY := Theme.Sing.TextP2MScore.Y + 65; + + //P3 + Player[2].LineBonus_TargetX := Theme.Sing.StaticP3RScoreBG.x; + Player[2].LineBonus_TargetY := Theme.Sing.TextP3RScore.Y; + Player[2].LineBonus_StartX := Theme.Sing.StaticP3RScoreBG.x; + Player[2].LineBonus_StartY := Theme.Sing.TextP3RScore.Y + 65; + end; + + 4: begin + //P1 + Player[0].LineBonus_TargetX := Theme.Sing.StaticP1TwoPScoreBG.x; + Player[0].LineBonus_TargetY := Theme.Sing.TextP1TwoPScore.Y; + Player[0].LineBonus_StartX := Theme.Sing.StaticP1TwoPScoreBG.x; + Player[0].LineBonus_StartY := Theme.Sing.TextP1TwoPScore.Y + 65; + + //P2 + Player[1].LineBonus_TargetX := Theme.Sing.StaticP2RScoreBG.x; + Player[1].LineBonus_TargetY := Theme.Sing.TextP2RScore.Y; + Player[1].LineBonus_StartX := Theme.Sing.StaticP2RScoreBG.x; + Player[1].LineBonus_StartY := Theme.Sing.TextP2RScore.Y + 65; + + //P3 + Player[2].LineBonus_TargetX := Theme.Sing.StaticP1TwoPScoreBG.x; + Player[2].LineBonus_TargetY := Theme.Sing.TextP1TwoPScore.Y; + Player[2].LineBonus_StartX := Theme.Sing.StaticP1TwoPScoreBG.x; + Player[2].LineBonus_StartY := Theme.Sing.TextP1TwoPScore.Y + 65; + + //P4 + Player[3].LineBonus_TargetX := Theme.Sing.StaticP2RScoreBG.x; + Player[3].LineBonus_TargetY := Theme.Sing.TextP2RScore.Y; + Player[3].LineBonus_StartX := Theme.Sing.StaticP2RScoreBG.x; + Player[3].LineBonus_StartY := Theme.Sing.TextP2RScore.Y + 65; + end; + + 6: begin + //P1 + Player[0].LineBonus_TargetX := Theme.Sing.StaticP1ThreePScoreBG.x; + Player[0].LineBonus_TargetY := Theme.Sing.TextP1ThreePScore.Y; + Player[0].LineBonus_StartX := Theme.Sing.StaticP1ThreePScoreBG.x; + Player[0].LineBonus_StartY := Theme.Sing.TextP1ThreePScore.Y + 65; + + //P2 + Player[1].LineBonus_TargetX := Theme.Sing.StaticP2MScoreBG.x; + Player[1].LineBonus_TargetY := Theme.Sing.TextP2MScore.Y; + Player[1].LineBonus_StartX := Theme.Sing.StaticP2MScoreBG.x; + Player[1].LineBonus_StartY := Theme.Sing.TextP2MScore.Y + 65; + + //P3 + Player[2].LineBonus_TargetX := Theme.Sing.StaticP3RScoreBG.x; + Player[2].LineBonus_TargetY := Theme.Sing.TextP3RScore.Y; + Player[2].LineBonus_StartX := Theme.Sing.StaticP3RScoreBG.x; + Player[2].LineBonus_StartY := Theme.Sing.TextP3RScore.Y + 65; + + //P4 + Player[3].LineBonus_TargetX := Theme.Sing.StaticP1ThreePScoreBG.x; + Player[3].LineBonus_TargetY := Theme.Sing.TextP1ThreePScore.Y; + Player[3].LineBonus_StartX := Theme.Sing.StaticP1ThreePScoreBG.x; + Player[3].LineBonus_StartY := Theme.Sing.TextP1ThreePScore.Y + 65; + + //P5 + Player[4].LineBonus_TargetX := Theme.Sing.StaticP2MScoreBG.x; + Player[4].LineBonus_TargetY := Theme.Sing.TextP2MScore.Y; + Player[4].LineBonus_StartX := Theme.Sing.StaticP2MScoreBG.x; + Player[4].LineBonus_StartY := Theme.Sing.TextP2MScore.Y + 65; + + //P6 + Player[5].LineBonus_TargetX := Theme.Sing.StaticP3RScoreBG.x; + Player[5].LineBonus_TargetY := Theme.Sing.TextP3RScore.Y; + Player[5].LineBonus_StartX := Theme.Sing.StaticP3RScoreBG.x; + Player[5].LineBonus_StartY := Theme.Sing.TextP3RScore.Y + 65; + end; + end; + end + else if (Ini.LineBonus = 2) then //Show Line Bonus at Notes + begin + //SingDrawNoteLines(Nr.Left + 10*ScreenX, 120, Nr.Right + 10*ScreenX, 12); + //SingDrawNoteLines(Nr.Left + 10*ScreenX, 245, Nr.Right + 10*ScreenX, 12); + //SingDrawNoteLines(Nr.Left + 10*ScreenX, 370, Nr.Right + 10*ScreenX, 12); + + // positions + if Ini.SingWindow = 0 then begin + NR.Left := 120; + end else begin + NR.Left := 20; + end; + NR.Right := 780; + + NR.Width := NR.Right - NR.Left; + NR.WMid := NR.Width / 2; + NR.Mid := NR.Left + NR.WMid; + + Case PlayersPlay of + 1: begin + Player[0].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[0].LineBonus_TargetY := Skin_P2_NotesB - 105 - 65; + Player[0].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[0].LineBonus_StartY := Skin_P2_NotesB - 105; + end; + + 2: begin + //P1 + Player[0].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[0].LineBonus_TargetY := Skin_P1_NotesB - 105 - 65 + 28; + Player[0].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[0].LineBonus_StartY := Skin_P1_NotesB - 105 + 28; + + //P2 + Player[1].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[1].LineBonus_TargetY := Skin_P2_NotesB - 105 - 65 + 28; + Player[1].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[1].LineBonus_StartY := Skin_P2_NotesB - 105 + 28; + end; + + 3: begin + //P1 + Player[0].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[0].LineBonus_TargetY := 120 - 65 + 28; + Player[0].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[0].LineBonus_StartY := 120 + 28; + + //P2 + Player[1].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[1].LineBonus_TargetY := 245 - 65 + 28; + Player[1].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[1].LineBonus_StartY := 245 + 28; + + //P3 + Player[2].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[2].LineBonus_TargetY := 370 - 65 + 28; + Player[2].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[2].LineBonus_StartY := 370 + 28; + end; + + 4: begin + //P1 + Player[0].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[0].LineBonus_TargetY := Skin_P1_NotesB - 105 - 65 + 28; + Player[0].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[0].LineBonus_StartY := Skin_P1_NotesB - 105 + 28; + + //P2 + Player[1].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[1].LineBonus_TargetY := Skin_P2_NotesB - 105 - 65 + 28; + Player[1].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[1].LineBonus_StartY := Skin_P2_NotesB - 105 + 28; + + //P3 + Player[2].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[2].LineBonus_TargetY := Skin_P1_NotesB - 105 - 65 + 28; + Player[2].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[2].LineBonus_StartY := Skin_P1_NotesB - 105 + 28; + + //P4 + Player[3].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[3].LineBonus_TargetY := Skin_P2_NotesB - 105 - 65 + 28; + Player[3].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[3].LineBonus_StartY := Skin_P2_NotesB - 105 + 28; + end; + + 6: begin + //P1 + Player[0].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[0].LineBonus_TargetY := 120 - 65 + 28; + Player[0].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[0].LineBonus_StartY := 120 + 28; + + //P2 + Player[1].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[1].LineBonus_TargetY := 245 - 65 + 28; + Player[1].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[1].LineBonus_StartY := 245 + 28; + + //P3 + Player[2].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[2].LineBonus_TargetY := 370 - 65 + 28; + Player[2].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[2].LineBonus_StartY := 370 + 28; + + //P4 + Player[3].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[3].LineBonus_TargetY := 120 - 65 + 28; + Player[3].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[3].LineBonus_StartY := 120 + 28; + + //P5 + Player[4].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[4].LineBonus_TargetY := 245 - 65 + 28; + Player[4].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[4].LineBonus_StartY := 245 + 28; + + //P6 + Player[5].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 100); + Player[5].LineBonus_TargetY := 370 - 65 + 28; + Player[5].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 100); + Player[5].LineBonus_StartY := 370 + 28; + end; + end; + end; + //Set Position of Line Bonus - PhrasenBonus End + //Set Num of Empty Sentences for Phrasen Bonus + NumEmptySentences := 0; + for P := low(Czesci[0].Czesc) to high(Czesci[0].Czesc) do + if Czesci[0].Czesc[P].TotalNotes = 0 then Inc(NumEmptySentences); + + Log.LogStatus('End', 'onShow'); +end; + +procedure TScreenSing.onShowFinish; +begin + // play movie (II) + + if AktSong.VideoLoaded then + begin + try + PlaySmpeg; + except + //If an Error occurs Reading Video: prevent Video from being Drawn again and Close Video + AktSong.VideoLoaded := False; + Log.LogError('Error drawing Video, Video has been disabled for this Song/Session.'); + Log.LogError('Corrupted File: ' + AktSong.Video); + try + CloseSmpeg; + except + + end; + end; + end; + + // play music (II) + Music.Play; + + // prepare timer (II) + CountSkipTimeSet; +end; + +function TScreenSing.Draw: boolean; +var + Min: integer; + Sec: integer; + Tekst: string; + Flash: real; + S: integer; + T: integer; +begin + + + + //ScoreBG Mod + // set player colors + if PlayersPlay = 4 then begin + if ScreenAct = 1 then begin + LoadColor(Static[StaticP1TwoP].Texture.ColR, Static[StaticP1TwoP].Texture.ColG, + Static[StaticP1TwoP].Texture.ColB, 'P1Dark'); + LoadColor(Static[StaticP2R].Texture.ColR, Static[StaticP2R].Texture.ColG, + Static[StaticP2R].Texture.ColB, 'P2Dark'); + + + + LoadColor(Static[StaticP1TwoPScoreBG].Texture.ColR, Static[StaticP1TwoPScoreBG].Texture.ColG, + Static[StaticP1TwoPScoreBG].Texture.ColB, 'P1Dark'); + LoadColor(Static[StaticP2RScoreBG].Texture.ColR, Static[StaticP2RScoreBG].Texture.ColG, + Static[StaticP2RScoreBG].Texture.ColB, 'P2Dark'); + + + + end; + if ScreenAct = 2 then begin + LoadColor(Static[StaticP1TwoP].Texture.ColR, Static[StaticP1TwoP].Texture.ColG, + Static[StaticP1TwoP].Texture.ColB, 'P3Dark'); + LoadColor(Static[StaticP2R].Texture.ColR, Static[StaticP2R].Texture.ColG, + Static[StaticP2R].Texture.ColB, 'P4Dark'); + + + + LoadColor(Static[StaticP1TwoPScoreBG].Texture.ColR, Static[StaticP1TwoPScoreBG].Texture.ColG, + Static[StaticP1TwoPScoreBG].Texture.ColB, 'P3Dark'); + LoadColor(Static[StaticP2RScoreBG].Texture.ColR, Static[StaticP2RScoreBG].Texture.ColG, + Static[StaticP2RScoreBG].Texture.ColB, 'P4Dark'); + + + + end; + end; + + if PlayersPlay = 6 then begin + if ScreenAct = 1 then begin + LoadColor(Static[StaticP1ThreeP].Texture.ColR, Static[StaticP1ThreeP].Texture.ColG, + Static[StaticP1ThreeP].Texture.ColB, 'P1Dark'); + LoadColor(Static[StaticP2M].Texture.ColR, Static[StaticP2M].Texture.ColG, + Static[StaticP2R].Texture.ColB, 'P2Dark'); + LoadColor(Static[StaticP3R].Texture.ColR, Static[StaticP3R].Texture.ColG, + Static[StaticP3R].Texture.ColB, 'P3Dark'); + + + + LoadColor(Static[StaticP1ThreePScoreBG].Texture.ColR, Static[StaticP1ThreePScoreBG].Texture.ColG, + Static[StaticP1ThreePScoreBG].Texture.ColB, 'P1Dark'); + LoadColor(Static[StaticP2MScoreBG].Texture.ColR, Static[StaticP2MScoreBG].Texture.ColG, + Static[StaticP2RScoreBG].Texture.ColB, 'P2Dark'); + LoadColor(Static[StaticP3RScoreBG].Texture.ColR, Static[StaticP3RScoreBG].Texture.ColG, + Static[StaticP3RScoreBG].Texture.ColB, 'P3Dark'); + + + + end; + if ScreenAct = 2 then begin + LoadColor(Static[StaticP1ThreeP].Texture.ColR, Static[StaticP1ThreeP].Texture.ColG, + Static[StaticP1ThreeP].Texture.ColB, 'P4Dark'); + LoadColor(Static[StaticP2M].Texture.ColR, Static[StaticP2M].Texture.ColG, + Static[StaticP2R].Texture.ColB, 'P5Dark'); + LoadColor(Static[StaticP3R].Texture.ColR, Static[StaticP3R].Texture.ColG, + Static[StaticP3R].Texture.ColB, 'P6Dark'); + + + + + LoadColor(Static[StaticP1ThreePScoreBG].Texture.ColR, Static[StaticP1ThreePScoreBG].Texture.ColG, + Static[StaticP1ThreePScoreBG].Texture.ColB, 'P4Dark'); + LoadColor(Static[StaticP2MScoreBG].Texture.ColR, Static[StaticP2MScoreBG].Texture.ColG, + Static[StaticP2RScoreBG].Texture.ColB, 'P5Dark'); + LoadColor(Static[StaticP3RScoreBG].Texture.ColR, Static[StaticP3RScoreBG].Texture.ColG, + Static[StaticP3RScoreBG].Texture.ColB, 'P6Dark'); + + + + + end; + end; + +//Original 0.5.0 +{ // set player colors + if PlayersPlay = 4 then begin + if ScreenAct = 1 then begin + //LoadColor(Static[StaticP1].Texture.ColR, Static[StaticP1].Texture.ColG, + //Static[StaticP1].Texture.ColB, 'P1Dark'); +// LoadColor(Static[StaticP2R].Texture.ColR, Static[StaticP2R].Texture.ColG, + // Static[StaticP2R].Texture.ColB, 'P2Dark'); + end; + if ScreenAct = 2 then begin + LoadColor(Static[StaticP1].Texture.ColR, Static[StaticP1].Texture.ColG, + Static[StaticP1].Texture.ColB, 'P3Dark'); + LoadColor(Static[StaticP2R].Texture.ColR, Static[StaticP2R].Texture.ColG, + Static[StaticP2R].Texture.ColB, 'P4Dark'); + end; + end; + + if PlayersPlay = 6 then begin + if ScreenAct = 1 then begin + LoadColor(Static[StaticP1].Texture.ColR, Static[StaticP1].Texture.ColG, + Static[StaticP1].Texture.ColB, 'P1Dark'); + LoadColor(Static[StaticP2M].Texture.ColR, Static[StaticP2M].Texture.ColG, + Static[StaticP2R].Texture.ColB, 'P2Dark'); + LoadColor(Static[StaticP3R].Texture.ColR, Static[StaticP3R].Texture.ColG, + Static[StaticP3R].Texture.ColB, 'P3Dark'); + end; + if ScreenAct = 2 then begin + LoadColor(Static[StaticP1].Texture.ColR, Static[StaticP1].Texture.ColG, + Static[StaticP1].Texture.ColB, 'P4Dark'); + LoadColor(Static[StaticP2M].Texture.ColR, Static[StaticP2M].Texture.ColG, + Static[StaticP2R].Texture.ColB, 'P5Dark'); + LoadColor(Static[StaticP3R].Texture.ColR, Static[StaticP3R].Texture.ColG, + Static[StaticP3R].Texture.ColB, 'P6Dark'); + end; + end; } + //end ScoreBG Mod + + + + // set player names (for 2 screens and only Singstar skin) + if ScreenAct = 1 then begin + Text[TextP1].Text := 'P1'; + Text[TextP1TwoP].Text := 'P1'; //added for ps3 skin + Text[TextP1ThreeP].Text := 'P1'; //added for ps3 skin + Text[TextP2R].Text := 'P2'; + Text[TextP2M].Text := 'P2'; + Text[TextP3R].Text := 'P3'; + end; + + if ScreenAct = 2 then begin + case PlayersPlay of +{ 1: begin + Text[TextP1].Text := 'P2'; + end; + 2: begin + Text[TextP1].Text := 'P3'; + Text[TextP2R].Text := 'P4'; + end; + 3: begin + Text[TextP1].Text := 'P4'; + Text[TextP2M].Text := 'P5'; + Text[TextP3R].Text := 'P6'; + end;} + + 4: begin + Text[TextP1TwoP].Text := 'P3'; + Text[TextP2R].Text := 'P4'; + end; + 6: begin + Text[TextP1ThreeP].Text := 'P4'; + Text[TextP2M].Text := 'P5'; + Text[TextP3R].Text := 'P6'; + end; + end; // case + end; // if + + // stereo + +// weird stuff, maybe this is for "dual screen?", but where is player three then? + Static[StaticP1].Texture.X := Static[StaticP1].Texture.X + 10*ScreenX; + Static[StaticP1ScoreBG].Texture.X := Static[StaticP1ScoreBG].Texture.X + 10*ScreenX; + + Text[TextP1].X := Text[TextP1].X + 10*ScreenX; + Text[TextP1Score].X := Text[TextP1Score].X + 10*ScreenX; + + + Static[StaticP2R].Texture.X := Static[StaticP2R].Texture.X + 10*ScreenX; + Static[StaticP2RScoreBG].Texture.X := Static[StaticP2RScoreBG].Texture.X + 10*ScreenX; + + Text[TextP2R].X := Text[TextP2R].X + 10*ScreenX; + Text[TextP2RScore].X := Text[TextP2RScore].X + 10*ScreenX; +// end of weird stuff + + for S := 1 to 1 do + Static[S].Texture.X := Static[S].Texture.X + 10*ScreenX; + + for T := 0 to 1 do + Text[T].X := Text[T].X + 10*ScreenX; + + // update static menu with time ... + Min := Round(Czas.Teraz) div 60; + Sec := Round(Czas.Teraz) mod 60; + Text[TextTimeText].Text := ''; + if Min < 10 then Text[TextTimeText].Text := '0'; + Text[TextTimeText].Text := Text[TextTimeText].Text + IntToStr(Min) + ':'; + if Sec < 10 then Text[TextTimeText].Text := Text[TextTimeText].Text + '0'; + Text[TextTimeText].Text := Text[TextTimeText].Text + IntToStr(Sec); + + // .. and scores + if PlayersPlay = 1 then begin + Tekst := IntToStr(Player[0].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1Score].Text := Tekst; + end; + + if PlayersPlay = 2 then begin + Tekst := IntToStr(Player[0].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1TwoPScore].Text := Tekst; + + Tekst := IntToStr(Player[1].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP2RScore].Text := Tekst; + end; + + if PlayersPlay = 3 then begin + Tekst := IntToStr(Player[0].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1ThreePScore].Text := Tekst; + + Tekst := IntToStr(Player[1].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP2MScore].Text := Tekst; + + Tekst := IntToStr(Player[2].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP3RScore].Text := Tekst; + end; + + if PlayersPlay = 4 then begin + if ScreenAct = 1 then begin + Tekst := IntToStr(Player[0].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1TwoPScore].Text := Tekst; + + Tekst := IntToStr(Player[1].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP2RScore].Text := Tekst; + end; + if ScreenAct = 2 then begin + Tekst := IntToStr(Player[2].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1TwoPScore].Text := Tekst; + + Tekst := IntToStr(Player[3].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP2RScore].Text := Tekst; + end; + end; + + if PlayersPlay = 6 then begin + if ScreenAct = 1 then begin + Tekst := IntToStr(Player[0].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1ThreePScore].Text := Tekst; + + Tekst := IntToStr(Player[1].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP2MScore].Text := Tekst; + + Tekst := IntToStr(Player[2].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP3RScore].Text := Tekst; + end; + if ScreenAct = 2 then begin + Tekst := IntToStr(Player[3].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1ThreePScore].Text := Tekst; + + Tekst := IntToStr(Player[4].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP2MScore].Text := Tekst; + + Tekst := IntToStr(Player[5].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP3RScore].Text := Tekst; + end; + end; + + + // beat flash +{ Flash := 1 - (Czas.MidBeat - Czas.AktBeat); + if (Czas.AktBeat + AktSong.NotesGAP) mod AktSong.Resolution = 0 then Flash := 1 + else Flash := 0; + if Czas.AktBeat < 0 then Flash := 0; + glClearColor(Flash, Flash, Flash, 1);} + + // beat sound +// if (Ini.BeatClick = 1) and (Flash = 1) and (Czas.AktBeat <> Czas.OldBeat) then Music.PlayClick; + + // draw static menu (BG) + DrawBG; + //Draw Background + SingDrawBackground; + // update and draw movie + if ShowFinish and AktSong.VideoLoaded then begin + try + UpdateSmpeg; // this only draws + except + //If an Error occurs drawing: prevent Video from being Drawn again and Close Video + AktSong.VideoLoaded := False; + log.LogError('Error drawing Video, Video has been disabled for this Song/Session.'); + Log.LogError('Corrupted File: ' + AktSong.Video); + try + CloseSmpeg; + except + + end; + end; + end; + + // draw static menu (FG) + DrawFG; + + // check for music finish +// Log.LogError('Check for music finish: ' + BoolToStr(Music.Finished) + ' ' + FloatToStr(Czas.Teraz*1000) + ' ' + IntToStr(AktSong.Finish)); + if ShowFinish then begin + if (not Music.Finished) and ((AktSong.Finish = 0) or (Czas.Teraz*1000 <= AktSong.Finish)) then begin + //Pause Mod: + if not Paused then + Sing(Self); // analyze song + end else begin +// Log.LogError('End'); + if not FadeOut then begin +// Log.LogError('End2'); + Finish; + FadeOut := true; + FadeTo(@ScreenScore); + end; + end; + end; + + // draw custom items + SingDraw; // always draw + +//GoldenNoteStarsTwinkle Mod + GoldenRec.SpawnRec; +//GoldenNoteStarsTwinkle Mod + + // back stereo + +// weird stuff, maybe this is for "dual screen?", but where is player three then? + Static[StaticP1].Texture.X := Static[StaticP1].Texture.X - 10*ScreenX; + Static[StaticP1ScoreBG].Texture.X := Static[StaticP1ScoreBG].Texture.X - 10*ScreenX; + + Text[TextP1].X := Text[TextP1].X - 10*ScreenX; + Text[TextP1Score].X := Text[TextP1Score].X - 10*ScreenX; + + + Static[StaticP2R].Texture.X := Static[StaticP2R].Texture.X - 10*ScreenX; + Static[StaticP2RScoreBG].Texture.X := Static[StaticP2RScoreBG].Texture.X - 10*ScreenX; + + Text[TextP2R].X := Text[TextP2R].X - 10*ScreenX; + Text[TextP2RScore].X := Text[TextP2RScore].X - 10*ScreenX; +//weird end + + for S := 1 to 1 do + Static[S].Texture.X := Static[S].Texture.X - 10*ScreenX; + + for T := 0 to 1 do + Text[T].X := Text[T].X - 10*ScreenX; + +end; + +procedure TScreenSing.Finish; +begin + Music.CaptureStop; + Music.Stop; + + if Ini.SavePlayback = 1 then begin + Log.BenchmarkStart(0); + Log.LogVoice(0); + Log.LogVoice(1); + Log.LogVoice(2); + Log.BenchmarkEnd(0); + Log.LogBenchmark('Creating files', 0); + end; + + if AktSong.VideoLoaded then begin + CloseSmpeg; + AktSong.VideoLoaded := false; // to prevent drawing closed video + end; + + SetFontItalic (False); +end; + +procedure TScreenSing.UpdateLCD; +var + T: string; +begin + LCD.HideCursor; + LCD.Clear; + + T := LyricMain.Text; + if Copy(T, Length(T), 1) <> ' ' then T := T + ' '; + LCD.AddTextBR(T); + + T := LyricSub.Text; + if Copy(T, Length(T), 1) <> ' ' then T := T + ' '; + LCD.AddTextBR(T); +end; + +procedure TScreenSing.onSentenceEnd(S: Cardinal); +var +I: Integer; +A: Real; +B: integer; //Max Points for Notes +begin + + //Check for Empty Sentence + if (Czesci[0].Czesc[S].TotalNotes<=0) then + exit; + + //Set Max Note Points + if (Ini.LineBonus > 0) then + B := 9000 + else + B := 10000; + + for I := 0 to High(Player) do begin + A := Player[I].Score + Player[I].ScoreGolden - Player[I].ScoreLast + 2; + + //SingBar Mod + If ({(Ini.Oscilloscope = 2) and }(Czesci[0].Czesc[S].TotalNotes>0)) then + begin + Player[I].ScorePercentTarget := Player[I].ScorePercentTarget + floor(A / (B * Czesci[0].Czesc[S].TotalNotes / Czesci[0].Wartosc) * 40 - 26); + if Player[I].ScorePercentTarget < 0 then Player[I].ScorePercentTarget := 0; + if Player[I].ScorePercentTarget > 99 then Player[I].ScorePercentTarget := 99; + + //end Singbar Mod + end; + + //PhrasenBonus - Line Bonus Mod + + //Generate Steps 0 to 8 + A := Floor(A / (B * Czesci[0].Czesc[S].TotalNotes / Czesci[0].Wartosc) * 8); + + If (Ini.LineBonus > 0) then + begin + + //Generate Text + if A >= 8 then + Player[I].LineBonus_Text := Theme.Sing.LineBonusText[8] + else + Player[I].LineBonus_Text := Theme.Sing.LineBonusText[Floor(A)]; + + //PhrasenBonus give Points + Player[I].ScoreLine := Player[I].ScoreLine + (1000 / (Length(Czesci[0].Czesc) - NumEmptySentences) * A / 8); + Player[I].ScoreLineI := Round(Player[I].ScoreLine / 10) * 10; + //Update Total Score + Player[I].ScoreTotalI := Player[I].ScoreI + Player[I].ScoreGoldenI + Player[I].ScoreLineI; + + //Color + Case Floor(A) of + 0: begin + Player[I].LineBonus_Color.R := 1; + Player[I].LineBonus_Color.G := 0; + Player[I].LineBonus_Color.B := 0; + end; + 1..3: begin + Player[I].LineBonus_Color.R := 1; + Player[I].LineBonus_Color.G := (A * 0.25); + Player[I].LineBonus_Color.B := 0; + end; + 4: begin + Player[I].LineBonus_Color.R := 1; + Player[I].LineBonus_Color.G := 1; + Player[I].LineBonus_Color.B := 0; + end; + 5..7: begin + Player[I].LineBonus_Color.R := 1-((a-4)*0.25); + Player[I].LineBonus_Color.G := 1; + Player[I].LineBonus_Color.B := 0; + end; + 8: begin + Player[I].LineBonus_Color.R := 0; + Player[I].LineBonus_Color.G := 1; + Player[I].LineBonus_Color.B := 0; + end; + End; //Case + //Player[I].LineBonus_Color.B := 0; + //Player[I].LineBonus_Color.R := (8-A)/8; + //Player[I].LineBonus_Color.G := A/10; + + Player[I].LineBonus_PosX := Player[I].LineBonus_StartX; + Player[I].LineBonus_PosY := Player[I].LineBonus_StartY; + Player[I].LineBonus_Alpha := 0.92; + Player[I].LineBonus_Visible := True; + Player[I].LineBonus_Age := 1; + end; + //PhrasenBonus - Line Bonus Mod End// } + + //PerfectLineTwinkle Mod (effect) Pt.1 + If (Ini.EffectSing=1) then + begin + if A >= 8 then Player[I].LastSentencePerfect := True + else Player[I].LastSentencePerfect := False; + end; + //PerfectLineTwinkle Mod end + + //Refresh LastScore + Player[I].ScoreLast := Player[I].Score + Player[I].ScoreGolden; + + end; + + //PerfectLineTwinkle Mod (effect) Pt.2 + if Ini.EffectSing=1 then + GoldenRec.SpawnPerfectLineTwinkle; + //PerfectLineTwinkle Mod end +end; + +//Called on Sentence Change S= New Current Sentence +procedure TScreenSing.onSentenceChange(S: Cardinal); +begin + //GoldenStarsTwinkle Mod + GoldenRec.SentenceChange; + //GoldenStarsTwinkle Mod End +end; + +end. diff --git a/Game/Code/Screens/UScreenSingModi.pas b/Game/Code/Screens/UScreenSingModi.pas new file mode 100644 index 00000000..32526a07 --- /dev/null +++ b/Game/Code/Screens/UScreenSingModi.pas @@ -0,0 +1,1091 @@ +unit UScreenSingModi; + +interface + +uses UMenu, UMusic, SDL, SysUtils, UFiles, UTime, USongs, UIni, ULog, USmpeg, UTexture, ULyrics, + TextGL, OpenGL12, BASS, UThemes, ULCD, UScreenSing, ModiSDK; + +type + TScreenSingModi = class(TScreenSing) + protected + //paused: boolean; //Pause Mod + //PauseTime: Real; + //NumEmptySentences: integer; + public + //TextTime: integer; + + //StaticP1: integer; + //StaticP1ScoreBG: integer; + //TextP1: integer; + //TextP1Score: integer; + + //StaticP2R: integer; + //StaticP2RScoreBG: integer; + //TextP2R: integer; + //TextP2RScore: integer; + + //StaticP2M: integer; + //StaticP2MScoreBG: integer; + //TextP2M: integer; + //TextP2MScore: integer; + + //StaticP3R: integer; + //StaticP3RScoreBG: integer; + //TextP3R: integer; + //TextP3RScore: integer; + + //Tex_Background: TTexture; + //FadeOut: boolean; + //LyricMain: TLyric; + //LyricSub: TLyric; + Winner: Byte; //Who Wins + PlayerInfo: TPlayerInfo; + TeamInfo: TTeamInfo; + + constructor Create; override; + procedure onShow; override; + //procedure onShowFinish; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function Draw: boolean; override; + procedure Finish; override; + //procedure UpdateLCD; + //procedure Pause; //Pause Mod(Toggles Pause) + end; + +//Procedured for Plugin +function LoadTex (const Name, Typ: PChar): TsmallTexture; stdcall; +//function Translate (const Name: PChar): PChar; stdcall; +procedure Print (const Style, Size: Byte; const X, Y: Real; const Text: PChar); stdcall; //Procedure to Print Text +function LoadSound (const Name: PChar): Cardinal; stdcall; //Procedure that loads a Custom Sound +procedure PlaySound (const Index: Cardinal); stdcall; //Plays a Custom Sound + +//Utilys +function ToSentences(Const Czeski: TCzesci): TSentences; + +implementation +uses UGraphic, UDraw, UMain, Classes, URecord, ULanguage, math, UDLLManager, USkins, UGraphicClasses; + +// Method for input parsing. If False is returned, GetNextWindow +// should be checked to know the next window to load; +function TScreenSingModi.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Finish; + Music.PlayBack; + FadeTo(@ScreenPartyScore); + end; + + else + Result := inherited ParseInput(PressedKey, ScanCode, PressedDown); + end; + end; +end; + +constructor TScreenSingModi.Create; +begin + inherited Create; + +end; + +function ToSentences(Const Czeski: TCzesci): TSentences; +var + I, J: Integer; +begin + Result.Akt := Czeski.Akt; + Result.High := Czeski.High; + Result.Ilosc := Czeski.Ilosc; + Result.Resolution := Czeski.Resolution; + Result.NotesGAP := Czeski.NotesGAP; + Result.TotalLength := Czeski.Wartosc; + + SetLength(Result.Sentence, Length(Czeski.Czesc)); + for I := low(Result.Sentence) to high(Result.Sentence) do + begin + Result.Sentence[I].Start := Czeski.Czesc[I].Start; + Result.Sentence[I].StartNote := Czeski.Czesc[I].StartNote; + Result.Sentence[I].Lyric := Czeski.Czesc[I].Lyric; + Result.Sentence[I].LyricWidth := Czeski.Czesc[I].LyricWidth; + Result.Sentence[I].Koniec := Czeski.Czesc[I].Koniec; + Result.Sentence[I].BaseNote := Czeski.Czesc[I].BaseNote; + Result.Sentence[I].HighNote := Czeski.Czesc[I].HighNut; + Result.Sentence[I].IlNut := Czeski.Czesc[I].IlNut; + Result.Sentence[I].TotalNotes := Czeski.Czesc[I].TotalNotes; + + SetLength(Result.Sentence[I].Note, Length(Czeski.Czesc[I].Nuta)); + for J := low(Result.Sentence[I].Note) to high(Result.Sentence[I].Note) do + begin + Result.Sentence[I].Note[J].Color := Czeski.Czesc[I].Nuta[J].Color; + Result.Sentence[I].Note[J].Start := Czeski.Czesc[I].Nuta[J].Start; + Result.Sentence[I].Note[J].Length := Czeski.Czesc[I].Nuta[J].Dlugosc; + Result.Sentence[I].Note[J].Ton := Czeski.Czesc[I].Nuta[J].Ton; + Result.Sentence[I].Note[J].TonGamy := Czeski.Czesc[I].Nuta[J].TonGamy; + //Result.Sentence[I].Note[J].Text := Czeski.Czesc[I].Nuta[J].Tekst; + Result.Sentence[I].Note[J].FreeStyle := Czeski.Czesc[I].Nuta[J].FreeStyle; + Result.Sentence[I].Note[J].Typ := Czeski.Czesc[I].Nuta[J].Wartosc; + end; + end; +end; + +procedure TScreenSingModi.onShow; +{var + P: integer; + V1: boolean; + V2R: boolean; + V2M: boolean; + V3R: boolean; + NR: TRecR; //Line Bonus Mod } +var + I: Integer; +begin + + { Log.LogStatus('Begin', 'onShow'); + FadeOut := false; // 0.5.0: early 0.5.0 problems were by this line commented + + // prepare players + SetLength(Player, PlayersPlay); +// Player[0].ScoreTotalI := 0; + + + case PlayersPlay of + 1: begin + V1 := true; + V2R := false; + V2M := false; + V3R := false; + end; + 2: begin + V1 := true; + V2R := true; + V2M := false; + V3R := false; + end; + 3: begin + V1 := true; + V2R := false; + V2M := true; + V3R := true; + end; + 4: begin // double screen + V1 := true; + V2R := true; + V2M := false; + V3R := false; + end; + 6: begin // double screen + V1 := true; + V2R := false; + V2M := true; + V3R := true; + end; + + end; + + + + Static[StaticP2R].Visible := V2R; + Static[StaticP2RScoreBG].Visible := V2R; + Text[TextP2R].Visible := V2R; + Text[TextP2RScore].Visible := V2R; + + Static[StaticP2M].Visible := V2M; + Static[StaticP2MScoreBG].Visible := V2M; + Text[TextP2M].Visible := V2M; + Text[TextP2MScore].Visible := V2M; + + Static[StaticP3R].Visible := V3R; + Static[StaticP3RScoreBG].Visible := V3R; + Text[TextP3R].Visible := V3R; + Text[TextP3RScore].Visible := V3R; + + + + // load notes + CzyscNuty; +// Log.LogWarning(CatSongs.Song[CatSongs.Selected].Path + CatSongs.Song[CatSongs.Selected].FileName, '!!!'); + AktSong := CatSongs.Song[CatSongs.Selected]; + + WczytajCzesci(CatSongs.Song[CatSongs.Selected].Path + CatSongs.Song[CatSongs.Selected].FileName); + AktSong.Path := CatSongs.Song[CatSongs.Selected].Path; +// AktSong.GAP := AktSong.GAP + 40 {4096 = 100ms for buffer}{ + 20 {microphone}{ + 60000 / AktSong.BPM[0].BPM / 2; // temporary until UMain will be fixed + + // set movie + if (AktSong.Video <> '') and FileExists(AktSong.Path + AktSong.Video) then begin + OpenSmpeg(AktSong.Path + AktSong.Video); + SkipSmpeg(AktSong.VideoGAP + AktSong.Start); + AktSong.VideoLoaded := true; + end; + + // set background + if (AktSong.Background <> '') and (AktSong.VideoLoaded = false) then + Tex_Background := Texture.LoadTexture(AktSong.Path + AktSong.Background) + else + Tex_Background.TexNum := -1; + + // play music (I) + //Music.CaptureStart; + Music.MoveTo(AktSong.Start); +// Music.Play; + + // prepare timer (I) +// CountSkipTimeSet; + Czas.Teraz := AktSong.Start; + Czas.Razem := Music.Length; + if (AktSong.Finish > 0) then Czas.Razem := AktSong.Finish / 1000; + Czas.OldBeat := -1; + for P := 0 to High(Player) do + ClearScores(P); + + // main text + LyricMain.Clear; + LyricMain.X := 400; + LyricMain.Y := Skin_LyricsT; + LyricMain.Scale := 1.4; //1.4 + LyricMain.Align := 1; + + // sub text + LyricSub.Clear; + LyricSub.X := 400; + LyricSub.Y := Skin_LyricsT + 42; //40 + LyricSub.Align := 1; + + // set custom options + case Ini.LyricsFont of + 0: + begin + LyricMain.FontStyle := 0; + LyricSub.FontStyle := 0; + LyricMain.Size := 14; // 13 + LyricSub.Size := 14; // 13 + LyricMain.ColR := Skin_FontR; + LyricMain.ColG := Skin_FontG; + LyricMain.ColB := Skin_FontB; //Change für Crazy Joker + {LyricMain.ColSR := Skin_FontHighlightR; + LyricMain.ColSG := Skin_FontHighlightG; + LyricMain.ColSB := Skin_FontHighlightB;1aa5dc} { + LyricMain.ColSR := 26/255; + LyricMain.ColSG := 165/255; + LyricMain.ColSB := 220/255; + + LyricSub.ColR := 0.6; + LyricSub.ColG := 0.6; + LyricSub.ColB := 0.6; + end; + 1: + begin + LyricMain.FontStyle := 2; + LyricSub.FontStyle := 2; + LyricMain.Size := 14; + LyricSub.Size := 14; + LyricMain.ColR := 0.75; + LyricMain.ColG := 0.75; + LyricMain.ColB := 1; + LyricMain.ColSR := 0.5; + LyricMain.ColSG := 0.5; + LyricMain.ColSB := 1; + LyricSub.ColR := 0.8; + LyricSub.ColG := 0.8; + LyricSub.ColB := 0.8; + end; + 2: + begin + LyricMain.FontStyle := 3; + LyricSub.FontStyle := 3; + LyricMain.Size := 12; + LyricSub.Size := 12; + LyricMain.ColR := 0.75; + LyricMain.ColG := 0.75; + LyricMain.ColB := 1; + LyricMain.ColSR := 0.5; + LyricMain.ColSG := 0.5; + LyricMain.ColSB := 1; + LyricSub.ColR := 0.8; + LyricSub.ColG := 0.8; + LyricSub.ColB := 0.8; + end; + end; // case + + case Ini.LyricsEffect of + 0: LyricMain.Style := 1; // 0 - one selected, 1 - selected all to the current + 1: LyricMain.Style := 2; + 2: LyricMain.Style := 3; + 3: LyricMain.Style := 4; + end; // case + + // fill texts + LyricMain.AddCzesc(0); + LyricMain.Selected := -1; + LyricSub.AddCzesc(1); + LyricSub.Selected := -1; + + UpdateLCD; + + //Deactivate Pause + Paused := False; + + {Static[StaticP2R].Visible := V2R; + Static[StaticP2RScoreBG].Visible := V2R; + Text[TextP2R].Visible := V2R; + Text[TextP2RScore].Visible := V2R; + + Static[StaticP2M].Visible := V2M; + Static[StaticP2MScoreBG].Visible := V2M; + Text[TextP2M].Visible := V2M; + Text[TextP2MScore].Visible := V2M; + + Static[StaticP3R].Visible := V3R; + Static[StaticP3RScoreBG].Visible := V3R; + Text[TextP3R].Visible := V3R; + Text[TextP3RScore].Visible := V3R;} { + + //Set Position of Line Bonus - PhrasenBonus + if (Ini.LineBonus = 1) then //Show Line Bonus at Scores + begin + Case PlayersPlay of + 1: begin + Player[0].LineBonus_TargetX := Theme.Sing.StaticP1ScoreBG.x; + Player[0].LineBonus_TargetY := Theme.Sing.TextP1Score.Y; + Player[0].LineBonus_StartX := Theme.Sing.StaticP1ScoreBG.x; + Player[0].LineBonus_StartY := Theme.Sing.TextP1Score.Y + 65; + end; + + 2: begin + //P1 + Player[0].LineBonus_TargetX := Theme.Sing.StaticP1ScoreBG.x; + Player[0].LineBonus_TargetY := Theme.Sing.TextP1Score.Y; + Player[0].LineBonus_StartX := Theme.Sing.StaticP1ScoreBG.X; + Player[0].LineBonus_StartY := Theme.Sing.TextP1Score.Y + 65; + + //P2 + Player[1].LineBonus_TargetX := Theme.Sing.StaticP2RScoreBG.X; + Player[1].LineBonus_TargetY := Theme.Sing.TextP2RScore.Y; + Player[1].LineBonus_StartX := Theme.Sing.StaticP2RScoreBG.X; + Player[1].LineBonus_StartY := Theme.Sing.TextP2RScore.Y + 65; + end; + + 3: begin + //P1 + Player[0].LineBonus_TargetX := Theme.Sing.StaticP1ScoreBG.x; + Player[0].LineBonus_TargetY := Theme.Sing.TextP1Score.Y; + Player[0].LineBonus_StartX := Theme.Sing.StaticP1ScoreBG.x; + Player[0].LineBonus_StartY := Theme.Sing.TextP1Score.Y + 65; + + //P2 + Player[1].LineBonus_TargetX := Theme.Sing.StaticP2MScoreBG.x; + Player[1].LineBonus_TargetY := Theme.Sing.TextP2MScore.Y; + Player[1].LineBonus_StartX := Theme.Sing.StaticP2MScoreBG.x; + Player[1].LineBonus_StartY := Theme.Sing.TextP2MScore.Y + 65; + + //P3 + Player[2].LineBonus_TargetX := Theme.Sing.StaticP3RScoreBG.x; + Player[2].LineBonus_TargetY := Theme.Sing.TextP3RScore.Y; + Player[2].LineBonus_StartX := Theme.Sing.StaticP3RScoreBG.x; + Player[2].LineBonus_StartY := Theme.Sing.TextP3RScore.Y + 65; + end; + + 4: begin + //P1 + Player[0].LineBonus_TargetX := Theme.Sing.StaticP1ScoreBG.x; + Player[0].LineBonus_TargetY := Theme.Sing.TextP1Score.Y; + Player[0].LineBonus_StartX := Theme.Sing.StaticP1ScoreBG.x; + Player[0].LineBonus_StartY := Theme.Sing.TextP1Score.Y + 65; + + //P2 + Player[1].LineBonus_TargetX := Theme.Sing.StaticP2RScoreBG.x; + Player[1].LineBonus_TargetY := Theme.Sing.TextP2RScore.Y; + Player[1].LineBonus_StartX := Theme.Sing.StaticP2RScoreBG.x; + Player[1].LineBonus_StartY := Theme.Sing.TextP2RScore.Y + 65; + + //P3 + Player[2].LineBonus_TargetX := Theme.Sing.StaticP1ScoreBG.x; + Player[2].LineBonus_TargetY := Theme.Sing.TextP1Score.Y; + Player[2].LineBonus_StartX := Theme.Sing.StaticP1ScoreBG.x; + Player[2].LineBonus_StartY := Theme.Sing.TextP1Score.Y + 65; + + //P4 + Player[3].LineBonus_TargetX := Theme.Sing.StaticP2RScoreBG.x; + Player[3].LineBonus_TargetY := Theme.Sing.TextP2RScore.Y; + Player[3].LineBonus_StartX := Theme.Sing.StaticP2RScoreBG.x; + Player[3].LineBonus_StartY := Theme.Sing.TextP2RScore.Y + 65; + end; + + 6: begin + //P1 + Player[0].LineBonus_TargetX := Theme.Sing.StaticP1ScoreBG.x; + Player[0].LineBonus_TargetY := Theme.Sing.TextP1Score.Y; + Player[0].LineBonus_StartX := Theme.Sing.StaticP1ScoreBG.x; + Player[0].LineBonus_StartY := Theme.Sing.TextP1Score.Y + 65; + + //P2 + Player[1].LineBonus_TargetX := Theme.Sing.StaticP2MScoreBG.x; + Player[1].LineBonus_TargetY := Theme.Sing.TextP2MScore.Y; + Player[1].LineBonus_StartX := Theme.Sing.StaticP2MScoreBG.x; + Player[1].LineBonus_StartY := Theme.Sing.TextP2MScore.Y + 65; + + //P3 + Player[2].LineBonus_TargetX := Theme.Sing.StaticP3RScoreBG.x; + Player[2].LineBonus_TargetY := Theme.Sing.TextP3RScore.Y; + Player[2].LineBonus_StartX := Theme.Sing.StaticP3RScoreBG.x; + Player[2].LineBonus_StartY := Theme.Sing.TextP3RScore.Y + 65; + + //P4 + Player[3].LineBonus_TargetX := Theme.Sing.StaticP1ScoreBG.x; + Player[3].LineBonus_TargetY := Theme.Sing.TextP1Score.Y; + Player[3].LineBonus_StartX := Theme.Sing.StaticP1ScoreBG.x; + Player[3].LineBonus_StartY := Theme.Sing.TextP1Score.Y + 65; + + //P5 + Player[4].LineBonus_TargetX := Theme.Sing.StaticP2MScoreBG.x; + Player[4].LineBonus_TargetY := Theme.Sing.TextP2MScore.Y; + Player[4].LineBonus_StartX := Theme.Sing.StaticP2MScoreBG.x; + Player[4].LineBonus_StartY := Theme.Sing.TextP2MScore.Y + 65; + + //P6 + Player[5].LineBonus_TargetX := Theme.Sing.StaticP3RScoreBG.x; + Player[5].LineBonus_TargetY := Theme.Sing.TextP3RScore.Y; + Player[5].LineBonus_StartX := Theme.Sing.StaticP3RScoreBG.x; + Player[5].LineBonus_StartY := Theme.Sing.TextP3RScore.Y + 65; + end; + end; + end + else if (Ini.LineBonus = 2) then //Show Line Bonus at Notes + begin + //SingDrawNoteLines(Nr.Left + 10*ScreenX, 120, Nr.Right + 10*ScreenX, 12); + //SingDrawNoteLines(Nr.Left + 10*ScreenX, 245, Nr.Right + 10*ScreenX, 12); + //SingDrawNoteLines(Nr.Left + 10*ScreenX, 370, Nr.Right + 10*ScreenX, 12); + + // positions + if Ini.SingWindow = 0 then begin + NR.Left := 120; + end else begin + NR.Left := 20; + end; + NR.Right := 780; + + NR.Width := NR.Right - NR.Left; + NR.WMid := NR.Width / 2; + NR.Mid := NR.Left + NR.WMid; + + Case PlayersPlay of + 1: begin + Player[0].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[0].LineBonus_TargetY := Skin_P2_NotesB - 105 - 65; + Player[0].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[0].LineBonus_StartY := Skin_P2_NotesB - 105; + end; + + 2: begin + //P1 + Player[0].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[0].LineBonus_TargetY := Skin_P1_NotesB - 105 - 65 + 28; + Player[0].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[0].LineBonus_StartY := Skin_P1_NotesB - 105 + 28; + + //P2 + Player[1].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[1].LineBonus_TargetY := Skin_P2_NotesB - 105 - 65 + 28; + Player[1].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[1].LineBonus_StartY := Skin_P2_NotesB - 105 + 28; + end; + + 3: begin + //P1 + Player[0].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[0].LineBonus_TargetY := 120 - 65 + 28; + Player[0].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[0].LineBonus_StartY := 120 + 28; + + //P2 + Player[1].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[1].LineBonus_TargetY := 245 - 65 + 28; + Player[1].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[1].LineBonus_StartY := 245 + 28; + + //P3 + Player[2].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[2].LineBonus_TargetY := 370 - 65 + 28; + Player[2].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[2].LineBonus_StartY := 370 + 28; + end; + + 4: begin + //P1 + Player[0].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[0].LineBonus_TargetY := Skin_P1_NotesB - 105 - 65 + 28; + Player[0].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[0].LineBonus_StartY := Skin_P1_NotesB - 105 + 28; + + //P2 + Player[1].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[1].LineBonus_TargetY := Skin_P2_NotesB - 105 - 65 + 28; + Player[1].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[1].LineBonus_StartY := Skin_P2_NotesB - 105 + 28; + + //P3 + Player[2].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[2].LineBonus_TargetY := Skin_P1_NotesB - 105 - 65 + 28; + Player[2].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[2].LineBonus_StartY := Skin_P1_NotesB - 105 + 28; + + //P4 + Player[3].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[3].LineBonus_TargetY := Skin_P2_NotesB - 105 - 65 + 28; + Player[3].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[3].LineBonus_StartY := Skin_P2_NotesB - 105 + 28; + end; + + 6: begin + //P1 + Player[0].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[0].LineBonus_TargetY := 120 - 65 + 28; + Player[0].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[0].LineBonus_StartY := 120 + 28; + + //P2 + Player[1].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[1].LineBonus_TargetY := 245 - 65 + 28; + Player[1].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[1].LineBonus_StartY := 245 + 28; + + //P3 + Player[2].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[2].LineBonus_TargetY := 370 - 65 + 28; + Player[2].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[2].LineBonus_StartY := 370 + 28; + + //P4 + Player[3].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[3].LineBonus_TargetY := 120 - 65 + 28; + Player[3].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[3].LineBonus_StartY := 120 + 28; + + //P5 + Player[4].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[4].LineBonus_TargetY := 245 - 65 + 28; + Player[4].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[4].LineBonus_StartY := 245 + 28; + + //P6 + Player[5].LineBonus_TargetX := Round(Nr.Right + 10*ScreenX - 87); + Player[5].LineBonus_TargetY := 370 - 65 + 28; + Player[5].LineBonus_StartX := Round(Nr.Right + 10*ScreenX - 87); + Player[5].LineBonus_StartY := 370 + 28; + end; + end; + end; + //Set Position of Line Bonus - PhrasenBonus End + //Set Num of Empty Sentences for Phrasen Bonus + NumEmptySentences := 0; + for P := low(Czesci[0].Czesc) to high(Czesci[0].Czesc) do + if Czesci[0].Czesc[P].TotalNotes = 0 then Inc(NumEmptySentences); + + Log.LogStatus('End', 'onShow'); } + + PlayersPlay := TeamInfo.NumTeams; + + if DLLMan.Selected.LoadSong then //Start with Song + begin + inherited; + end + else //Start Without Song + begin + Music.CaptureStart; + end; + +//Set Playerinfo + PlayerInfo.NumPlayers := PlayersPlay; + for I := 0 to PlayerInfo.NumPlayers-1 do + begin + PlayerInfo.Playerinfo[I].Name := PChar(Ini.Name[I]); + PlayerInfo.Playerinfo[I].Score:= 0; + PlayerInfo.Playerinfo[I].Bar := 50; + PlayerInfo.Playerinfo[I].Enabled := True; + end; + + for I := PlayerInfo.NumPlayers to high(PlayerInfo.Playerinfo) do + begin + PlayerInfo.Playerinfo[I].Score:= 0; + PlayerInfo.Playerinfo[I].Bar := 0; + PlayerInfo.Playerinfo[I].Enabled := False; + end; + + Case PlayersPlay of + 1: begin + PlayerInfo.Playerinfo[0].PosX := Static[StaticP1ScoreBG].Texture.X; + PlayerInfo.Playerinfo[0].PosY := Static[StaticP1ScoreBG].Texture.Y + Static[StaticP1ScoreBG].Texture.H; + end; + 2,4: begin + PlayerInfo.Playerinfo[0].PosX := Static[StaticP1TwoPScoreBG].Texture.X; + PlayerInfo.Playerinfo[0].PosY := Static[StaticP1TwoPScoreBG].Texture.Y + Static[StaticP1TwoPScoreBG].Texture.H; + PlayerInfo.Playerinfo[2].PosX := Static[StaticP1TwoPScoreBG].Texture.X; + PlayerInfo.Playerinfo[2].PosY := Static[StaticP1TwoPScoreBG].Texture.Y + Static[StaticP1TwoPScoreBG].Texture.H; + PlayerInfo.Playerinfo[1].PosX := Static[StaticP2RScoreBG].Texture.X; + PlayerInfo.Playerinfo[1].PosY := Static[StaticP2RScoreBG].Texture.Y + Static[StaticP2RScoreBG].Texture.H; + PlayerInfo.Playerinfo[3].PosX := Static[StaticP2RScoreBG].Texture.X; + PlayerInfo.Playerinfo[3].PosY := Static[StaticP2RScoreBG].Texture.Y + Static[StaticP2RScoreBG].Texture.H; + end; + 3,6: begin + PlayerInfo.Playerinfo[0].PosX := Static[StaticP1ThreePScoreBG].Texture.X; + PlayerInfo.Playerinfo[0].PosY := Static[StaticP1ThreePScoreBG].Texture.Y + Static[StaticP1ThreePScoreBG].Texture.H; + PlayerInfo.Playerinfo[3].PosX := Static[StaticP1ThreePScoreBG].Texture.X; + PlayerInfo.Playerinfo[3].PosY := Static[StaticP1ThreePScoreBG].Texture.Y + Static[StaticP1ThreePScoreBG].Texture.H; + PlayerInfo.Playerinfo[1].PosX := Static[StaticP2MScoreBG].Texture.X; + PlayerInfo.Playerinfo[1].PosY := Static[StaticP2MScoreBG].Texture.Y + Static[StaticP2MScoreBG].Texture.H; + PlayerInfo.Playerinfo[4].PosX := Static[StaticP2MScoreBG].Texture.X; + PlayerInfo.Playerinfo[4].PosY := Static[StaticP2MScoreBG].Texture.Y + Static[StaticP2MScoreBG].Texture.H; + PlayerInfo.Playerinfo[2].PosX := Static[StaticP3RScoreBG].Texture.X; + PlayerInfo.Playerinfo[2].PosY := Static[StaticP3RScoreBG].Texture.Y + Static[StaticP3RScoreBG].Texture.H; + PlayerInfo.Playerinfo[5].PosX := Static[StaticP3RScoreBG].Texture.X; + PlayerInfo.Playerinfo[5].PosY := Static[StaticP3RScoreBG].Texture.Y + Static[StaticP3RScoreBG].Texture.H; + end; + end; + + // play music (I) + //Music.CaptureStart; + //Music.MoveTo(AktSong.Start); + + //Init Plugin + if not DLLMan.PluginInit(TeamInfo, PlayerInfo, ToSentences(Czesci[0]), LoadTex, Print, LoadSound, PlaySound) then + begin + //Fehler + Log.LogError('Could not Init Plugin'); + Halt; + end; + + // Set Background (Little Workaround, maybe change sometime) + if (DLLMan.Selected.LoadBack) AND (DLLMan.Selected.LoadSong) then + ScreenSing.Tex_Background := Tex_Background; + + Winner := 0; + + //Set Score Visibility + if PlayersPlay = 1 then begin + Text[TextP1Score].Visible := DLLMan.Selected.ShowScore; + Static[StaticP1ScoreBG].Visible := DLLMan.Selected.ShowScore; + end; + + if (PlayersPlay = 2) OR (PlayersPlay = 4) then begin + Text[TextP1TwoPScore].Visible := DLLMan.Selected.ShowScore; + Static[StaticP1TwoPScoreBG].Visible := DLLMan.Selected.ShowScore; + + Text[TextP2RScore].Visible := DLLMan.Selected.ShowScore; + Static[StaticP2RScoreBG].Visible := DLLMan.Selected.ShowScore; + end; + + if (PlayersPlay = 3) OR (PlayersPlay = 6) then begin + Text[TextP1ThreePScore].Visible := DLLMan.Selected.ShowScore; + Static[StaticP1ThreePScoreBG].Visible := DLLMan.Selected.ShowScore; + + Text[TextP2MScore].Visible := DLLMan.Selected.ShowScore; + Static[StaticP2MScoreBG].Visible := DLLMan.Selected.ShowScore; + + Text[TextP3RScore].Visible := DLLMan.Selected.ShowScore; + Static[StaticP3RScoreBG].Visible := DLLMan.Selected.ShowScore; + end; +end; + +function TScreenSingModi.Draw: boolean; +var + Min: integer; + Sec: integer; + Tekst: string; + S, I: integer; + T: integer; +begin +//Set Playerinfo + PlayerInfo.NumPlayers := PlayersPlay; + for I := 0 to PlayerInfo.NumPlayers-1 do + begin + PlayerInfo.Playerinfo[I].Name := PChar(Player[I].Name); + if PlayerInfo.Playerinfo[I].Enabled then + begin + if (Player[I].ScoreTotalI<=10000) then + PlayerInfo.Playerinfo[I].Score:= Player[I].ScoreTotalI; + PlayerInfo.Playerinfo[I].Bar := Player[I].ScorePercent; + end; + end; + +//Show Score +if DLLMan.Selected.ShowScore then +begin + //ScoreBG Mod + // set player colors + if PlayersPlay = 4 then begin + if ScreenAct = 1 then begin + LoadColor(Static[StaticP1TwoP].Texture.ColR, Static[StaticP1TwoP].Texture.ColG, + Static[StaticP1TwoP].Texture.ColB, 'P1Dark'); + LoadColor(Static[StaticP2R].Texture.ColR, Static[StaticP2R].Texture.ColG, + Static[StaticP2R].Texture.ColB, 'P2Dark'); + + + + LoadColor(Static[StaticP1TwoPScoreBG].Texture.ColR, Static[StaticP1TwoPScoreBG].Texture.ColG, + Static[StaticP1TwoPScoreBG].Texture.ColB, 'P1Dark'); + LoadColor(Static[StaticP2RScoreBG].Texture.ColR, Static[StaticP2RScoreBG].Texture.ColG, + Static[StaticP2RScoreBG].Texture.ColB, 'P2Dark'); + + + + end; + if ScreenAct = 2 then begin + LoadColor(Static[StaticP1TwoP].Texture.ColR, Static[StaticP1TwoP].Texture.ColG, + Static[StaticP1TwoP].Texture.ColB, 'P3Dark'); + LoadColor(Static[StaticP2R].Texture.ColR, Static[StaticP2R].Texture.ColG, + Static[StaticP2R].Texture.ColB, 'P4Dark'); + + + + LoadColor(Static[StaticP1TwoPScoreBG].Texture.ColR, Static[StaticP1TwoPScoreBG].Texture.ColG, + Static[StaticP1TwoPScoreBG].Texture.ColB, 'P3Dark'); + LoadColor(Static[StaticP2RScoreBG].Texture.ColR, Static[StaticP2RScoreBG].Texture.ColG, + Static[StaticP2RScoreBG].Texture.ColB, 'P4Dark'); + + + + end; + end; + + if PlayersPlay = 6 then begin + if ScreenAct = 1 then begin + LoadColor(Static[StaticP1ThreeP].Texture.ColR, Static[StaticP1ThreeP].Texture.ColG, + Static[StaticP1ThreeP].Texture.ColB, 'P1Dark'); + LoadColor(Static[StaticP2M].Texture.ColR, Static[StaticP2M].Texture.ColG, + Static[StaticP2R].Texture.ColB, 'P2Dark'); + LoadColor(Static[StaticP3R].Texture.ColR, Static[StaticP3R].Texture.ColG, + Static[StaticP3R].Texture.ColB, 'P3Dark'); + + + + LoadColor(Static[StaticP1ThreePScoreBG].Texture.ColR, Static[StaticP1ThreePScoreBG].Texture.ColG, + Static[StaticP1ThreePScoreBG].Texture.ColB, 'P1Dark'); + LoadColor(Static[StaticP2MScoreBG].Texture.ColR, Static[StaticP2MScoreBG].Texture.ColG, + Static[StaticP2RScoreBG].Texture.ColB, 'P2Dark'); + LoadColor(Static[StaticP3RScoreBG].Texture.ColR, Static[StaticP3RScoreBG].Texture.ColG, + Static[StaticP3RScoreBG].Texture.ColB, 'P3Dark'); + + + + end; + if ScreenAct = 2 then begin + LoadColor(Static[StaticP1ThreeP].Texture.ColR, Static[StaticP1ThreeP].Texture.ColG, + Static[StaticP1ThreeP].Texture.ColB, 'P4Dark'); + LoadColor(Static[StaticP2M].Texture.ColR, Static[StaticP2M].Texture.ColG, + Static[StaticP2R].Texture.ColB, 'P5Dark'); + LoadColor(Static[StaticP3R].Texture.ColR, Static[StaticP3R].Texture.ColG, + Static[StaticP3R].Texture.ColB, 'P6Dark'); + + + + + LoadColor(Static[StaticP1ThreePScoreBG].Texture.ColR, Static[StaticP1ThreePScoreBG].Texture.ColG, + Static[StaticP1ThreePScoreBG].Texture.ColB, 'P4Dark'); + LoadColor(Static[StaticP2MScoreBG].Texture.ColR, Static[StaticP2MScoreBG].Texture.ColG, + Static[StaticP2RScoreBG].Texture.ColB, 'P5Dark'); + LoadColor(Static[StaticP3RScoreBG].Texture.ColR, Static[StaticP3RScoreBG].Texture.ColG, + Static[StaticP3RScoreBG].Texture.ColB, 'P6Dark'); + + + + + end; + end; + //end ScoreBG Mod + +// set player names (for 2 screens and only Singstar skin) + if ScreenAct = 1 then begin + Text[TextP1].Text := 'P1'; + Text[TextP1TwoP].Text := 'P1'; // added for ps3 skin + Text[TextP1ThreeP].Text := 'P1'; // added for ps3 skin + Text[TextP2R].Text := 'P2'; + Text[TextP2M].Text := 'P2'; + Text[TextP3R].Text := 'P3'; + end; + + if ScreenAct = 2 then begin + case PlayersPlay of + 4: begin + Text[TextP1TwoP].Text := 'P3'; + Text[TextP2R].Text := 'P4'; + end; + 6: begin + Text[TextP1ThreeP].Text := 'P4'; + Text[TextP2M].Text := 'P5'; + Text[TextP3R].Text := 'P6'; + end; + end; // case + end; // if + + + // stereo <- and where iss P2M? or P3? + Static[StaticP1].Texture.X := Static[StaticP1].Texture.X + 10*ScreenX; + Static[StaticP1ScoreBG].Texture.X := Static[StaticP1ScoreBG].Texture.X + 10*ScreenX; + + Text[TextP1].X := Text[TextP1].X + 10*ScreenX; + Text[TextP1Score].X := Text[TextP1Score].X + 10*ScreenX; + + Static[StaticP2R].Texture.X := Static[StaticP2R].Texture.X + 10*ScreenX; + Static[StaticP2RScoreBG].Texture.X := Static[StaticP2RScoreBG].Texture.X + 10*ScreenX; + + Text[TextP2R].X := Text[TextP2R].X + 10*ScreenX; + Text[TextP2RScore].X := Text[TextP2RScore].X + 10*ScreenX; + + // .. and scores + if PlayersPlay = 1 then begin + Tekst := IntToStr(Player[0].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1Score].Text := Tekst; + end; + + if PlayersPlay = 2 then begin + Tekst := IntToStr(Player[0].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1TwoPScore].Text := Tekst; + + Tekst := IntToStr(Player[1].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP2RScore].Text := Tekst; + end; + + if PlayersPlay = 3 then begin + Tekst := IntToStr(Player[0].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1ThreePScore].Text := Tekst; + + Tekst := IntToStr(Player[1].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP2MScore].Text := Tekst; + + Tekst := IntToStr(Player[2].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP3RScore].Text := Tekst; + end; + + if PlayersPlay = 4 then begin + if ScreenAct = 1 then begin + Tekst := IntToStr(Player[0].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1TwoPScore].Text := Tekst; + + Tekst := IntToStr(Player[1].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP2RScore].Text := Tekst; + end; + if ScreenAct = 2 then begin + Tekst := IntToStr(Player[2].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1TwoPScore].Text := Tekst; + + Tekst := IntToStr(Player[3].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP2RScore].Text := Tekst; + end; + end; + + if PlayersPlay = 6 then begin + if ScreenAct = 1 then begin + Tekst := IntToStr(Player[0].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1ThreePScore].Text := Tekst; + + Tekst := IntToStr(Player[1].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP2MScore].Text := Tekst; + + Tekst := IntToStr(Player[2].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP3RScore].Text := Tekst; + end; + if ScreenAct = 2 then begin + Tekst := IntToStr(Player[3].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP1ThreePScore].Text := Tekst; + + Tekst := IntToStr(Player[4].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP2MScore].Text := Tekst; + + Tekst := IntToStr(Player[5].ScoreTotalI); + while Length(Tekst) < 5 do Tekst := '0' + Tekst; + Text[TextP3RScore].Text := Tekst; + end; + end; + +end; //ShowScore + + for S := 1 to 1 do + Static[S].Texture.X := Static[S].Texture.X + 10*ScreenX; + + for T := 0 to 1 do + Text[T].X := Text[T].X + 10*ScreenX; + +if DLLMan.Selected.LoadSong then +begin + // update static menu with time ... + Min := Round(Czas.Teraz) div 60; + Sec := Round(Czas.Teraz) mod 60; + Text[TextTimeText].Text := ''; + if Min < 10 then Text[TextTimeText].Text := '0'; + Text[TextTimeText].Text := Text[TextTimeText].Text + IntToStr(Min) + ':'; + if Sec < 10 then Text[TextTimeText].Text := Text[TextTimeText].Text + '0'; + Text[TextTimeText].Text := Text[TextTimeText].Text + IntToStr(Sec); +end; + + // draw static menu (BG) + DrawBG; + + //Draw Background + if (DllMan.Selected.LoadSong) AND (DllMan.Selected.LoadBack) then + SingDrawBackground; + + // update and draw movie + if ShowFinish and AktSong.VideoLoaded AND DllMan.Selected.LoadVideo then begin + UpdateSmpeg; // this only draws + end; + + // draw static menu (FG) + DrawFG; + + if ShowFinish then begin + if DllMan.Selected.LoadSong then + begin + if (not Music.Finished) and ((AktSong.Finish = 0) or (Czas.Teraz*1000 <= AktSong.Finish)) then begin + //Pause Mod: + if not Paused then + Sing(Self); // analyze song + end else begin + if not FadeOut then begin + Finish; + FadeOut := true; + FadeTo(@ScreenPartyScore); + end; + end; + end; + end; + + // draw custom items + SingModiDraw(PlayerInfo); // always draw + + //GoldenNoteStarsTwinkle Mod + GoldenRec.SpawnRec; + //GoldenNoteStarsTwinkle Mod + + //Update PlayerInfo + for I := 0 to PlayerInfo.NumPlayers-1 do + begin + if PlayerInfo.Playerinfo[I].Enabled then + begin + PlayerInfo.Playerinfo[I].Bar := Player[I].ScorePercent; + PlayerInfo.Playerinfo[I].Score := Player[I].ScoreTotalI; + end; + end; + + if ((ShowFinish) AND (NOT Paused)) then + begin + if not DLLMan.PluginDraw(Playerinfo, Czesci[0].Akt) then + begin + if not FadeOut then begin + Finish; + FadeOut := true; + FadeTo(@ScreenPartyScore); + end; + end; + end; + + //Change PlayerInfo/Changeables + for I := 0 to PlayerInfo.NumPlayers-1 do + begin + if (Player[I].ScoreTotalI <> PlayerInfo.Playerinfo[I].Score) then + begin + //Player[I].ScoreTotal := Player[I].ScoreTotal + (PlayerInfo.Playerinfo[I].Score - Player[I].ScoreTotalI); + Player[I].ScoreTotalI := PlayerInfo.Playerinfo[I].Score; + end; + if (PlayerInfo.Playerinfo[I].Bar <> Player[I].ScorePercent) then + Player[I].ScorePercentTarget := PlayerInfo.Playerinfo[I].Bar; + end; + + // back stereo + Static[StaticP1].Texture.X := Static[StaticP1].Texture.X - 10*ScreenX; + Static[StaticP1ScoreBG].Texture.X := Static[StaticP1ScoreBG].Texture.X - 10*ScreenX; + + Text[TextP1].X := Text[TextP1].X - 10*ScreenX; + Text[TextP1Score].X := Text[TextP1Score].X - 10*ScreenX; + + + Static[StaticP2R].Texture.X := Static[StaticP2R].Texture.X - 10*ScreenX; + Static[StaticP2RScoreBG].Texture.X := Static[StaticP2RScoreBG].Texture.X - 10*ScreenX; + + Text[TextP2R].X := Text[TextP2R].X - 10*ScreenX; + Text[TextP2RScore].X := Text[TextP2RScore].X - 10*ScreenX; + + + for S := 1 to 1 do + Static[S].Texture.X := Static[S].Texture.X - 10*ScreenX; + + for T := 0 to 1 do + Text[T].X := Text[T].X - 10*ScreenX; + + +end; + +procedure TScreenSingModi.Finish; +begin +inherited Finish; + +Winner := DllMan.PluginFinish(PlayerInfo); + +//Log.LogError('Winner: ' + InttoStr(Winner)); + +//DLLMan.UnLoadPlugin; +end; + +function LoadTex (const Name, Typ: PChar): TsmallTexture; stdcall; +var + Texname, EXT: String; + Tex: TTexture; +begin + //Get texture Name + TexName := Skin.GetTextureFileName(String(Name)); + //Get File Typ + Ext := ExtractFileExt(TexName); + if (uppercase(Ext) = '.JPG') then + Ext := 'JPG' + else + Ext := 'BMP'; + + Tex := Texture.LoadTexture(PChar(TexName), PChar(Ext), Typ, 0); + + Result.TexNum := Tex.TexNum; + Result.W := Tex.W; + Result.H := Tex.H; +end; +{ +function Translate (const Name: PChar): PChar; stdcall; +begin + Result := PChar(Language.Translate(String(Name))); +end; } + +procedure Print (const Style, Size: Byte; const X, Y: Real; const Text: PChar); stdcall; //Procedure to Print Text +begin + SetFontItalic ((Style and 128) = 128); + SetFontStyle(Style and 7); + SetFontSize(Size); + SetFontPos (X, Y); + glPrint (PChar(Language.Translate(String(Text)))); +end; + +function LoadSound (const Name: PChar): Cardinal; stdcall; //Procedure that loads a Custom Sound +begin + Result := Music.LoadCustomSound(String(Name)); +end; + +procedure PlaySound (const Index: Cardinal); stdcall; //Plays a Custom Sound +begin + Music.PlayCustomSound(Index); +end; + +end. diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas new file mode 100644 index 00000000..5b807bb0 --- /dev/null +++ b/Game/Code/Screens/UScreenSong.pas @@ -0,0 +1,1881 @@ +unit UScreenSong; + +interface + +uses + UMenu, SDL, UMusic, UFiles, UTime, UDisplay, USongs, SysUtils, ULog, UThemes, UTexture, ULanguage, + ULCD, ULight, UIni; + +type + TScreenSong = class(TMenu) + public + TextArtist: integer; + TextTitle: integer; + TextNumber: integer; + + //Video Icon Mod + VideoIcon: Cardinal; + + TextCat: integer; + StaticCat: integer; + + SongCurrent: real; + SongTarget: real; + + HighSpeed: boolean; + CoverFull: boolean; + CoverTime: real; + CoverX: integer; + CoverY: integer; + CoverW: integer; + is_jump: boolean; // Jump to Song Mod + is_jump_title:boolean; //Jump to SOng MOd-YTrue if search for Title + + EqualizerBands: array of Byte; + EqualizerTime: Cardinal; + EqualizerTime2: Byte; + + //Party Mod + Mode: Byte; //0 = Standard, 1= Go to PartyMode after Selection + Change to Random Song at Show + //party Statics (Joker) + StaticTeam1Joker1: Cardinal; + StaticTeam1Joker2: Cardinal; + StaticTeam1Joker3: Cardinal; + StaticTeam1Joker4: Cardinal; + StaticTeam1Joker5: Cardinal; + + StaticTeam2Joker1: Cardinal; + StaticTeam2Joker2: Cardinal; + StaticTeam2Joker3: Cardinal; + StaticTeam2Joker4: Cardinal; + StaticTeam2Joker5: Cardinal; + + StaticTeam3Joker1: Cardinal; + StaticTeam3Joker2: Cardinal; + StaticTeam3Joker3: Cardinal; + StaticTeam3Joker4: Cardinal; + StaticTeam3Joker5: Cardinal; + + StaticParty: Array of Cardinal; + TextParty: Array of Cardinal; + StaticNonParty: Array of Cardinal; + TextNonParty: Array of Cardinal; + + + constructor Create; override; + procedure SetScroll; + procedure SetScroll1; + procedure SetScroll2; + procedure SetScroll3; + procedure SetScroll4; + procedure SetScroll5; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function Draw: boolean; override; + procedure onShow; override; + procedure onHide; override; + procedure SelectNext; + procedure SelectPrev; + procedure UpdateLCD; + procedure SkipTo(Target: Cardinal); + procedure FixSelected; //Show Wrong Song when Tabs on Fix + procedure FixSelected2; //Show Wrong Song when Tabs on Fix + procedure ShowCatTL(Cat: Integer);// Show Cat in Top left + procedure ShowCatTLCustom(Caption: String);// Show Custom Text in Top left + procedure HideCatTL;// Show Cat in Tob left + procedure Refresh; //Refresh Song Sorting + procedure DrawEqualizer; + procedure ChangeMusic; + //Party Mode + procedure SelectRandomSong; + procedure SetJoker; + procedure SetStatics; + //procedures for Menu + procedure StartSong; + procedure OpenEditor; + procedure DoJoker(Team: Byte); + procedure SelectPlayers; + + procedure UnLoadDetailedCover; + + //Extensions + procedure DrawExtensions; + end; + +implementation +uses UGraphic, UMain, UCovers, math, OpenGL12, Windows, USkins, UDLLManager, UParty, UPlaylist, UScreenSongMenu; + +// ***** Public methods ****** // + +//Show Wrong Song when Tabs on Fix +procedure TScreenSong.FixSelected; +var I, I2: Integer; + begin + if CatSongs.VisibleSongs > 0 then + begin + I2:= 0; + for I := low(CatSongs.Song) to High(Catsongs.Song) do + begin + if CatSongs.Song[I].Visible then + inc(I2); + + if I = Interaction - 1 then + break; + end; + + SongCurrent := I2; + SongTarget := I2; + end; + end; + +procedure TScreenSong.FixSelected2; +var I, I2: Integer; + begin + if CatSongs.VisibleSongs > 0 then + begin + I2:= 0; + for I := low(CatSongs.Song) to High(Catsongs.Song) do + begin + if CatSongs.Song[I].Visible then + inc(I2); + + if I = Interaction - 1 then + break; + end; + + SongTarget := I2; + end; + end; +//Show Wrong Song when Tabs on Fix End + + procedure TScreenSong.ShowCatTLCustom(Caption: String);// Show Custom Text in Top left + begin + Text[TextCat].Text := Caption; + Text[TextCat].Visible := true; + Static[StaticCat].Visible := False; + end; + + //Show Cat in Top Left Mod + procedure TScreenSong.ShowCatTL(Cat: Integer); + begin + //Change + Text[TextCat].Text := CatSongs.Song[Cat].Artist; + //showmessage(CatSongs.Song[Cat].Path + CatSongs.Song[Cat].Cover); + //Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', true); + + Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', true); + //Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', false); + //Button[Cat]. + //Cover + + + //Show + Text[TextCat].Visible := true; + Static[StaticCat].Visible := True; + end; + + procedure TScreenSong.HideCatTL; + begin + //Hide + //Text[TextCat].Visible := false; + Static[StaticCat].Visible := false; + //New -> Show Text specified in Theme + Text[TextCat].Visible := True; + Text[TextCat].Text := Theme.Song.TextCat.Text; + end; + //Show Cat in Top Left Mod End + + +// Method for input parsing. If False is returned, GetNextWindow +// should be checked to know the next window to load; +function TScreenSong.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + I: integer; + I2: integer; + HS: integer; + SDL_ModState: Word; + Letter: Char; +begin + Result := true; + + //Song Screen Extensions (Jumpto + Menu) + if (ScreenSongMenu.Visible) then + begin + Result := ScreenSongMenu.ParseInput(PressedKey, ScanCode, PressedDown); + Exit; + end + else if (ScreenSongJumpto.Visible) then + begin + Result := ScreenSongJumpto.ParseInput(PressedKey, ScanCode, PressedDown); + Exit; + end; + + If (PressedDown) Then + begin // Key Down + + SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT); + + //Jump to Artist/Titel + if (SDL_ModState and KMOD_LALT <> 0) AND (Mode = 0) AND (PressedKey >= SDLK_A) AND (PressedKey <= SDLK_Z) then + begin + Letter := UpCase(Chr(ScanCode)); + I2 := Length(CatSongs.Song); + + //Jump To Titel + if (SDL_ModState = KMOD_LALT or KMOD_LSHIFT) then + begin + For I := 1 to high(CatSongs.Song) do + begin + if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND (Length(CatSongs.Song[(I + Interaction) mod I2].Title)>0) AND (UpCase(CatSongs.Song[(I + Interaction) mod I2].Title[1]) = Letter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + //Break and Exit + Exit; + end; + end; + end + //Jump to Artist + else if (SDL_ModState = KMOD_LALT) then + begin + For I := 1 to high(CatSongs.Song) do + begin + if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND (Length(CatSongs.Song[(I + Interaction) mod I2].Artist)>0) AND (UpCase(CatSongs.Song[(I + Interaction) mod I2].Artist[1]) = Letter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + + //Break and Exit + Exit; + end; + end; + end; + Exit; + end; + + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + if (Mode = 0) then + begin + //On Escape goto Cat-List Hack + if (Ini.Tabs_at_startup = 1) AND (CatSongs.CatNumShow <> -1) then + begin + //Find Category + I := Interaction; + while not catsongs.Song[I].Main do + begin + Dec (I); + if (I < low(catsongs.Song)) then + break; + end; + if (I<= 1) then + Interaction := high(catsongs.Song) + else + Interaction := I - 1; + + //Stop Music + Music.Stop; + + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + HideCatTL; + + + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + //SelectPrev; + //CatSongs.Song[0].Visible := False; + end + else + begin + //On Escape goto Cat-List Hack End + //Tabs off and in Search or Playlist -> Go back to Song view + if (CatSongs.CatNumShow < -1) then + begin + //Atm: Set Empty Filter + CatSongs.SetFilter('', 0); + + //Show Cat in Top Left Mod + HideCatTL; + Interaction := 0; + + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + + ChangeMusic; + end + else + begin + Music.Stop; + Music.PlayBack; + + FadeTo(@ScreenMain); + end; + + end; + end + //When in party Mode then Ask before Close + else if (Mode = 1) then + begin + Music.PlayBack; + CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); + end; + end; + SDLK_RETURN: + begin + if Length(Songs.Song) > 0 then begin +// PortWriteB($378, 0); + if CatSongs.Song[Interaction].Main then begin // clicked on Category Button + + //Show Cat in Top Left Mod + ShowCatTL (Interaction); + + //I := CatSongs.VisibleIndex(Interaction); + CatSongs.ClickCategoryButton(Interaction); + {I2 := CatSongs.VisibleIndex(Interaction); + SongCurrent := SongCurrent - I + I2; + SongTarget := SongTarget - I + I2; } + +// if I<>I2 then beep; + // SetScroll4; + + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + + //Play Music: + ChangeMusic; + + end else begin // clicked on song + if (Mode = 0) then //Normal Mode -> Start Song + begin + //Do the Action that is specified in Ini + case Ini.OnSongClick of + 0: StartSong; + 1: SelectPlayers; + 2:begin + If (CatSongs.CatNumShow = -3) then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end; + end; + end + else if (Mode = 1) then //PartyMode -> Show Menu + begin + if (Ini.PartyPopup = 1) then + ScreenSongMenu.MenuShow(SM_Party_Main) + else + ScreenSong.StartSong; + end; + end; + end; + end; + + SDLK_M: //Show SongMenu + begin + if (Length(Songs.Song) > 0) then begin + if (Mode = 0) then begin + if not CatSongs.Song[Interaction].Main then begin // clicked on Song + if CatSongs.CatNumShow = -3 then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end + else + begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + end //Party Mode -> Show Party Menu + else ScreenSongMenu.MenuShow(SM_Party_Main); + end; + end; + + SDLK_P: //Show Playlist Menu + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + end; + + SDLK_J: //Show Jumpto Menu + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then + begin + ScreenSongJumpto.Visible := True; + end; + end; + + SDLK_DOWN: + begin + if (Mode = 0) then + begin + //Only Change Cat when not in Playlist or Search Mode + if (CatSongs.CatNumShow > -2) then + begin + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then + begin + I := Interaction; + if I <= 0 then I := 1; + + while not catsongs.Song[I].Main do + begin + Inc (I); + if (I > high(catsongs.Song)) then + I := low(catsongs.Song); + end; + + Interaction := I; + + //Show Cat in Top Left Mod + ShowCatTL (Interaction); + + CatSongs.ClickCategoryButton(Interaction); + SelectNext; + FixSelected; + + //Play Music: + Music.PlayChange; + ChangeMusic; + + end; + + // + //Cat Change Hack End} + end; + end; + end; + SDLK_UP: + begin + if (Mode = 0) then + begin + //Only Change Cat when not in Playlist or Search Mode + if (CatSongs.CatNumShow > -2) then + begin + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then + begin + I := Interaction; + I2 := 0; + if I <= 0 then I := 1; + + while not catsongs.Song[I].Main or (I2 = 0) do + begin + if catsongs.Song[I].Main then + Inc(I2); + Dec (I); + if (I < low(catsongs.Song)) then + I := high(catsongs.Song); + end; + + Interaction := I; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + FixSelected; + + //Play Music: + Music.PlayChange; + ChangeMusic; + end; + end; + //Cat Change Hack End} + end; + end; + + SDLK_RIGHT: + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then begin + Music.PlayChange; + SelectNext; +// InteractNext; +// SongTarget := Interaction; + ChangeMusic; + SetScroll4; + UpdateLCD; + Light.LightOne(1, 200); + end; + end; + + SDLK_LEFT: + begin + if (Length(Songs.Song) > 0)AND (Mode = 0) then begin + Music.PlayChange; + SelectPrev; + ChangeMusic; + SetScroll4; + UpdateLCD; + Light.LightOne(0, 200); + end; + end; + + SDLK_E: + begin + OpenEditor; + end; + + SDLK_R: + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then begin + + if (SDL_ModState = KMOD_LSHIFT) AND (Ini.Tabs_at_startup = 1) then //Random Category + begin + I2 := 0; //Count Cats + for I:= low(CatSongs.Song) to high (CatSongs.Song) do + if CatSongs.Song[I].Main then Inc(I2); + + I2 := Random (I2)+1; //Zufall + + //Find Cat: + for I:= low(CatSongs.Song) to high (CatSongs.Song) do + begin + if CatSongs.Song[I].Main then + Dec(I2); + if (I2<=0) then + begin + //Show Cat in Top Left Mod + ShowCatTL (I); + + Interaction := I; + + CatSongs.ShowCategoryList; + CatSongs.ClickCategoryButton(I); + SelectNext; + FixSelected; + break; + end; + end; + + + end + else if (SDL_ModState = KMOD_LCTRL) AND (Ini.Tabs_at_startup = 1) then //random in All Categorys + begin + repeat + I2 := Random(high(CatSongs.Song)+1) - low(CatSongs.Song)+1; + until CatSongs.Song[I2].Main = false; + + //Search Cat + for I := I2 downto low(CatSongs.Song) do + begin + if CatSongs.Song[I].Main then + break; + end; + //In I ist jetzt die Kategorie in I2 der Song + + //Choose Cat + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + + //Fix: Not Existing Song selected: + //if (I+1=I2) then Inc(I2); + + //Choose Song + SkipTo(I2-I); + + end + else //Random in one Category + begin + SkipTo(Random(CatSongs.VisibleSongs)); + end; + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + end; + end; + + SDLK_1: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[0].Joker); + SelectRandomSong; + SetJoker; + end; + end; + + SDLK_2: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[1].Joker); + SelectRandomSong; + SetJoker; + end; + end; + + SDLK_3: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[2].Joker); + SelectRandomSong; + SetJoker; + end; + end; + end; + end; +end; + +constructor TScreenSong.Create; +var + Pet: integer; + I: integer; +Label CreateSongButtons; +begin + inherited Create; + + LoadFromTheme(Theme.Song); + + TextArtist := AddText(Theme.Song.TextArtist); + TextTitle := AddText(Theme.Song.TextTitle); + TextNumber := AddText(Theme.Song.TextNumber); + + //Show Cat in Top Left mod + TextCat := AddText(Theme.Song.TextCat); + StaticCat := AddStatic(Theme.Song.StaticCat); + + //Show Video Icon Mod + VideoIcon := AddStatic(Theme.Song.VideoIcon); + + //Party Mode + StaticTeam1Joker1 := AddStatic(Theme.Song.StaticTeam1Joker1); + StaticTeam1Joker2 := AddStatic(Theme.Song.StaticTeam1Joker2); + StaticTeam1Joker3 := AddStatic(Theme.Song.StaticTeam1Joker3); + StaticTeam1Joker4 := AddStatic(Theme.Song.StaticTeam1Joker4); + StaticTeam1Joker5 := AddStatic(Theme.Song.StaticTeam1Joker5); + + StaticTeam2Joker1 := AddStatic(Theme.Song.StaticTeam2Joker1); + StaticTeam2Joker2 := AddStatic(Theme.Song.StaticTeam2Joker2); + StaticTeam2Joker3 := AddStatic(Theme.Song.StaticTeam2Joker3); + StaticTeam2Joker4 := AddStatic(Theme.Song.StaticTeam2Joker4); + StaticTeam2Joker5 := AddStatic(Theme.Song.StaticTeam2Joker5); + + StaticTeam3Joker1 := AddStatic(Theme.Song.StaticTeam3Joker1); + StaticTeam3Joker2 := AddStatic(Theme.Song.StaticTeam3Joker2); + StaticTeam3Joker3 := AddStatic(Theme.Song.StaticTeam3Joker3); + StaticTeam3Joker4 := AddStatic(Theme.Song.StaticTeam3Joker4); + StaticTeam3Joker5 := AddStatic(Theme.Song.StaticTeam3Joker5); + + //Load Party or NonParty specific Statics and Texts + SetLength(StaticParty, Length(Theme.Song.StaticParty)); + for I := 0 to High(Theme.Song.StaticParty) do + StaticParty[I] := AddStatic(Theme.Song.StaticParty[I]); + + SetLength(TextParty, Length(Theme.Song.TextParty)); + for I := 0 to High(Theme.Song.TextParty) do + TextParty[I] := AddText(Theme.Song.TextParty[I]); + + SetLength(StaticNonParty, Length(Theme.Song.StaticNonParty)); + for I := 0 to High(Theme.Song.StaticNonParty) do + StaticNonParty[I] := AddStatic(Theme.Song.StaticNonParty[I]); + + SetLength(TextNonParty, Length(Theme.Song.TextNonParty)); + for I := 0 to High(Theme.Song.TextNonParty) do + TextNonParty[I] := AddText(Theme.Song.TextNonParty[I]); + + // Song List +// Songs.LoadSongList; // moved to the UltraStar unit + CatSongs.Refresh; + + if (length(CatSongs.Song) > 0) then + begin + //Set Length of Button Array one Time Instead of one time for every Song + SetButtonLength(Length(CatSongs.Song)); + + I := 0; + CreateSongButtons: + + try + for Pet := I to High(CatSongs.Song) do begin // creating all buttons + // new + Texture.Limit := 512;// 256 0.4.2 value, 512 in 0.5.0 + + if not FileExists(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover) then + CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' + + if CatSongs.Song[Pet].Cover = '' then + AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', 'Plain', Theme.Song.Cover.Reflections) + else begin + // cache texture if there is a need to this + if not Covers.CoverExists(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover) then begin + Texture.CreateCacheMipmap := true; + Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 'Plain', true); // preloads textures and creates cache mipmap + Texture.CreateCacheMipmap := false; + + // puts this texture to the cache file + Covers.AddCover(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover); + + // unload full size texture + Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, false); + + // we should also add mipmap texture by calling createtexture and use mipmap cache as data source + end; + + // and now load it from cache file (small place for the optimization by eliminating reading it from file, but not here) + AddButton(300 + Pet*250, 140, 200, 200, CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 'JPG', 'Plain', Theme.Song.Cover.Reflections); + end; + Texture.Limit := 1024*1024; + I := -1; + end; + except + //When Error is reported the First time for this Song + if (I <> Pet) then + begin + //Some Error reporting: + Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); + + //Change Cover to NoCover and Continue Loading + CatSongs.Song[Pet].Cover := ''; + I := Pet; + end + else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song + begin + Log.LogError('NoCover Cover is damaged!'); + try + AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); + except + Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); + Halt; + end; + I := Pet + 1; + end; + end; + + if (I <> -1) then + GoTo CreateSongButtons; + + end; + + // Randomize Patch + Randomize; + //Equalizer + SetLength(EqualizerBands, Theme.Song.Equalizer.Bands); + //ClearArray + For I := low(EqualizerBands) to high(EqualizerBands) do + EqualizerBands[I] := 3; + + if (Length(CatSongs.Song) > 0) then + Interaction := 0; +end; + +procedure TScreenSong.SetScroll; +var + VS, B: Integer; +begin + VS := CatSongs.VisibleSongs; + if VS > 0 then + begin + //Set Positions + Case Theme.Song.Cover.Style of + 3: SetScroll3; + 5:begin + if VS > 5 then + SetScroll5 + else + SetScroll4; + end; + else SetScroll4; + end; + //Set Visibility of Video Icon + Static[VideoIcon].Visible := (CatSongs.Song[Interaction].Video <> ''); + + //Set Texts: + Text[TextArtist].Text := CatSongs.Song[Interaction].Artist; + Text[TextTitle].Text := CatSongs.Song[Interaction].Title; + if (Ini.Tabs_at_startup = 1) And (CatSongs.CatNumShow = -1) then + begin + Text[TextNumber].Text := IntToStr(CatSongs.Song[Interaction].OrderNum) + '/' + IntToStr(CatSongs.CatCount); + Text[TextTitle].Text := '(' + IntToStr(CatSongs.Song[Interaction].CatNumber) + ' ' + Language.Translate('SING_SONGS_IN_CAT') + ')'; + end + else if (CatSongs.CatNumShow = -2) then + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) + else if (CatSongs.CatNumShow = -3) then + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) + else if (Ini.Tabs_at_startup = 1) then + Text[TextNumber].Text := IntToStr(CatSongs.Song[Interaction].CatNumber) + '/' + IntToStr(CatSongs.Song[Interaction - CatSongs.Song[Interaction].CatNumber].CatNumber) + else + Text[TextNumber].Text := IntToStr(Interaction+1) + '/' + IntToStr(Length(CatSongs.Song)); + end + else + begin + Text[TextNumber].Text := '0/0'; + Text[TextArtist].Text := ''; + Text[TextTitle].Text := ''; + for B := 0 to High(Button) do + Button[B].Visible := False; + + end; +end; + +procedure TScreenSong.SetScroll1; +var + B: integer; // button + BMin: integer; // button min + BMax: integer; // button max + Src: integer; +// Dst: integer; + Count: integer; // Dst is not used. Count is used. + Ready: boolean; + + VisCount: integer; // count of visible (or selectable) buttons + VisInt: integer; // visible position of interacted button + Typ: integer; // 0 when all songs fits the screen + Placed: integer; // number of placed visible buttons +begin +// Src := 0; +// Dst := -1; + Count := 1; + Typ := 0; + Ready := false; + Placed := 0; + + VisCount := 0; + for B := 0 to High(Button) do + if CatSongs.Song[B].Visible then Inc(VisCount); + + VisInt := 0; + for B := 0 to Interaction-1 do + if CatSongs.Song[B].Visible then Inc(VisInt); + + + if VisCount <= 6 then begin + Typ := 0; + end else begin + if VisInt <= 3 then begin + Typ := 1; + Count := 7; + Ready := true; + end; + + if (VisCount - VisInt) <= 3 then begin + Typ := 2; + Count := 7; + Ready := true; + end; + + if not Ready then begin + Typ := 3; + Src := Interaction; + end; + end; + + + + // hide all buttons + for B := 0 to High(Button) do begin + Button[B].Visible := false; + Button[B].Selectable := CatSongs.Song[B].Visible; + end; + +{ for B := Src to Dst do begin +// Button[B].Visible := true; + Button[B].Visible := CatSongs.Song[B].Visible; + Button[B].Selectable := Button[B].Visible; + Button[B].Y := 140 + (B-Src) * 60; + end;} + + + if Typ = 0 then begin + for B := 0 to High(Button) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (Placed) * 60; + Inc(Placed); + end; + end; + end; + + if Typ = 1 then begin + B := 0; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Inc(B); + end; + end; + + if Typ = 2 then begin + B := High(Button); + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (6-Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Dec(B); + end; + end; + + if Typ = 3 then begin + B := Src; + Count := 4; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (3+Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Inc(B); + end; + + B := Src-1; + Placed := 0; + Count := 3; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (2-Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Dec(B); + end; + + end; + + if Length(Button) > 0 then + Static[1].Texture.Y := Button[Interaction].Y - 5; // selection texture +end; + +procedure TScreenSong.SetScroll2; +var + B: integer; + Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + Wsp2: real; +begin + // liniowe + for B := 0 to High(Button) do + Button[B].X := 300 + (B - Interaction) * 260; + + if Length(Button) >= 3 then begin + if Interaction = 0 then + Button[High(Button)].X := 300 - 260; + + if Interaction = High(Button) then + Button[0].X := 300 + 260; + end; + + // kolowe +{ for B := 0 to High(Button) do begin + Wsp := (B - Interaction); // 0 dla srodka, -1 dla lewego, +1 dla prawego itd. + Wsp2 := Wsp / Length(Button); + Button[B].X := 300 + 10000 * sin(2*pi*Wsp2); +// Button[B].Y := 140 + 50 * ; + end;} +end; + +procedure TScreenSong.SetScroll3; // with slide +var + B: integer; + Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + Wsp2: real; +begin + SongTarget := Interaction; + + // liniowe + for B := 0 to High(Button) do + begin + Button[B].X := 300 + (B - SongCurrent) * 260; + if (Button[B].X < -Button[B].W) OR (Button[B].X > 800) then + Button[B].Visible := False + else + Button[B].Visible := True; + end; + +{ if Length(Button) >= 3 then begin + if Interaction = 0 then + Button[High(Button)].X := 300 - 260; + + if Interaction = High(Button) then + Button[0].X := 300 + 260; + end;} + + // kolowe +{ for B := 0 to High(Button) do begin + Wsp := (B - Interaction); // 0 dla srodka, -1 dla lewego, +1 dla prawego itd. + Wsp2 := Wsp / Length(Button); + Button[B].X := 300 + 10000 * sin(2*pi*Wsp2); +// Button[B].Y := 140 + 50 * ; + end;} +end; + +procedure TScreenSong.SetScroll4; // rotate +var + B: integer; + Wsp: real; + Z, Z2: real; + VS: integer; +begin + VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important + + // kolowe + for B := 0 to High(Button) do begin + Button[B].Visible := CatSongs.Song[B].Visible; // nowe + if Button[B].Visible then begin // 0.5.0 optimization for 1000 songs - updates only visible songs, hiding in tabs becomes useful for maintaing good speed + + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS {CatSongs.VisibleSongs};// 0.5.0 (II): takes another 16ms + + Z := (1 + cos(Wsp)) / 2; + Z2 := (1 + 2*Z) / 3; + + + Button[B].X := Theme.Song.Cover.X + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + Button[B].Z := Z / 2 + 0.3; + + Button[B].W := Theme.Song.Cover.H * Z2; + +// Button[B].Y := {50 +} 140 + 50 - 50 * Z2; + Button[B].Y := Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Button[B].H)) * 0.7 ; + Button[B].H := Button[B].W; + end; + end; +end; + +{procedure TScreenSong.SetScroll4; // rotate +var + B: integer; + Wsp: real; + Z: real; + Z2, Z3: real; + VS: integer; + function modreal (const X, Y: real):real; + begin + Result := Frac(x / y) * y; + if Result < -3 then + Result := Result + Y + else if Result > 3 then + Result := Result - Y; + end; +begin + VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important + Z3 := 1; + if VS < 12 then + Z2 := VS + else + Z2 := 12; + + // kolowe + for B := 0 to High(Button) do begin + Button[B].Visible := CatSongs.Song[B].Visible; // nowe + if Button[B].Visible then begin // 0.5.0 optimization for 1000 songs - updates only visible songs, hiding in tabs becomes useful for maintaing good speed + if ((ModReal(CatSongs.VisibleIndex(B) - SongCurrent, VS)>-3) AND (ModReal(CatSongs.VisibleIndex(B) - SongCurrent, VS)<3)) then + begin + if CatSongs.VisibleIndex(B)> SongCurrent then + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2 + else + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2; + + Z3 := 2; + Z := (1 + cos(Wsp)) / 2; + //Z2 := (1 + 2*Z) / 3; + //Z2 := (0.5 + Z/2); + //Z2 := sin(Wsp); + + //Z2 := Power (Z2,Z3); + + Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); + + //Button[B].X := Theme.Song.CoverX + ({Theme.Song.CoverX + Theme.Song.CoverW/2 + Theme.Song.CoverW*0.18 * VS {CatSongs.VisibleSongs {Length(Button) * sin(Wsp) {- Theme.Song.CoverX - Theme.Song.CoverW) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + if (sin(Wsp)<0) then + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W + else //*Theme.Song.CoverW*0.004*Z3 + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX; + Button[B].Z := Z-0.00001; + +// Button[B].Y := {50 + 140 + 50 - 50 * Z2; + // Button[B].Y := (Theme.Song.CoverY + 40 + 50 - 50 * Z2); + Button[B].Y := (Theme.Song.CoverY + Theme.Song.CoverW - Button[B].W); + Button[B].H := Button[B].W; + Button[B].Visible := True; + end + {else if (((CatSongs.VisibleIndex(B) - SongCurrent)>-3) AND ((CatSongs.VisibleIndex(B) - SongCurrent)<3)) OR ((round (CatSongs.VisibleIndex(B) - SongCurrent) mod VS > -3) AND ((CatSongs.VisibleIndex(B) - SongCurrent)<3)) then + begin + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / 12 ;// 0.5.0 (II): takes another 16ms + + Z := (1 + cos(Wsp)) / 2 -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + + Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); + + if (sin(Wsp)<0) then + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W + else + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX; + + Button[B].Z := Z; + + Button[B].Y := (Theme.Song.CoverY + Theme.Song.CoverW - Button[B].W); + + Button[B].H := Button[B].W; + Button[B].Visible := True; + end + else Button[B].Visible := False; + end; + end; +end; } + +procedure TScreenSong.SetScroll5; // rotate +var + B: integer; + Angle: real; + Pos: Real; + VS: integer; + diff: real; + X: Real; +begin + VS := CatSongs.VisibleSongs; // cache Visible Songs + {Vars + Theme.Song.CoverW: Radius des Kreises + Theme.Song.CoverX: X Pos Linke Kante des gewählten Covers + Theme.Song.CoverX: Y Pos Obere Kante des gewählten Covers + Theme.Song.CoverH: Höhe der Cover + + (CatSongs.VisibleIndex(B) - SongCurrent)/VS = Abstand zum MIttleren Cover in % + } + + //Change Pos of all Buttons + for B := low(Button) to high(Button) do + begin + Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visability + if Button[B].Visible then //Only Change Pos for Visible Buttons + begin + Pos := (CatSongs.VisibleIndex(B) - SongCurrent); + if (Pos < -VS/2) then + Pos := Pos + VS + else if (Pos > VS/2) then + Pos := Pos - VS; + + if (Abs(Pos) < 2.5) then {fixed Positions} + begin + Angle := Pi * (Pos / 5); + //Button[B].Visible := False; + + Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); + +// Button[B].Reflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Z := 0.95 - Abs(Pos) * 0.01; + + Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); + + Button[B].W := Button[B].H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + + X := Sin(Angle*1.3)*0.9; + + Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X - Diff; + + end + else + begin {Behind the Front Covers} +// Button[B].Visible := False; +// if VS/2-abs(Pos)>VS*0.4 then Button[B].Visible := False; + + if Pos < 0 then + Pos := (Pos - VS/2) /VS + else + Pos := (Pos + VS/2) /VS; + + Angle := pi * Pos*2; + + Button[B].Z := (0.4 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + + Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); + + Button[B].W := Button[B].H; + + Button[B].Y := Theme.Song.Cover.Y - (Button[B].H - Theme.Song.Cover.H)*0.75; + +// Button[B].Reflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + Button[B].X := Theme.Song.Cover.X+Theme.Song.Cover.H/2-Button[b].H/2 + (Theme.Song.Cover.H)*sin(Angle/2)*1.52; + + end; + + //Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Button[B].H)/1.5); //Cover at down border of the change field +// Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Button[B].H) * 0.7); + + end; + end; +end; + +procedure TScreenSong.onShow; +begin + Music.Stop; + + if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; + if Ini.Players = 4 then PlayersPlay := 6; + + //Cat Mod etc + if (Ini.Tabs_at_startup = 1) AND (CatSongs.CatNumShow = -1) then + begin + CatSongs.ShowCategoryList; + FixSelected; + //Show Cat in Top Left Mod + HideCatTL; + end; + + + if Length(CatSongs.Song) > 0 then begin + //Load Music only when Song Preview is activated + if (Ini.PreviewVolume <> 0) then + begin + Music.SetLoop(false); + Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); + Music.MoveTo(Music.Length / 4); + Music.Play; + + //Set Preview Volume + Music.SetMusicVolume (Ini.PreviewVolume * 10); + {//if Music Fade is activated, Set Volume to 0 % + if (Ini.PreviewFading <> 0) then + Music.SetMusicVolume(0);} + end; + + SetScroll; + UpdateLCD; + end; + + //Playlist Mode + if (Mode = 0) then + begin + //If Playlist Shown -> Select Next automatically + if (CatSongs.CatNumShow = -3) then + begin + SelectNext; + ChangeMusic; + end; + end + //Party Mode + else if (Mode = 1) then + begin + + SelectRandomSong; + //Show Menu directly in PartyMode + //But only if selected in Options + if (Ini.PartyPopup = 1) then + begin + ScreenSongMenu.MenuShow(SM_Party_Main); + end; + + + end; + + SetJoker; + SetStatics; +end; + +procedure TScreenSong.onHide; +begin + //When Music Fading is activated, Turn Music to 100 % + If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then + Music.SetMusicVolume(100); + + //If Preview is deactivated: Load MUsicfile now + If (Ini.PreviewVolume = 0) then + Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); + + //When hide then Stop Music (For Party Mode Popup on Exit) + if (Display.NextScreen <> @ScreenSing) and (Display.NextScreen <> @ScreenSingModi) and (Music <> nil) then + Music.Stop; +end; + +procedure TScreenSong.DrawExtensions; +begin + //Draw Song Menu + if (ScreenSongMenu.Visible) then + begin + ScreenSongMenu.Draw; + end + else if (ScreenSongJumpto.Visible) then + begin + ScreenSongJumpto.Draw; + end +end; + +function TScreenSong.Draw: boolean; +var + dx: real; + dt: real; + I: Integer; +begin + dx := SongTarget-SongCurrent; + dt := TimeSkip*7; + if dt > 1 then dt := 1; + SongCurrent := SongCurrent + dx*dt; + +{ if SongCurrent > Catsongs.VisibleSongs then begin + SongCurrent := SongCurrent - Catsongs.VisibleSongs; + SongTarget := SongTarget - Catsongs.VisibleSongs; + end;} + +// Log.BenchmarkStart(5); + SetScroll; +// Log.BenchmarkEnd(5); +// Log.LogBenchmark('SetScroll4', 5); + + //Fading Functions, Only if Covertime is under 5 Seconds + If (CoverTime < 5) then + begin + // 0.5.0: cover fade + if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin + // load new texture + Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture.Alpha := 1; + Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture2.Alpha := 1; + end; + + //Song Fade + if (CatSongs.VisibleSongs > 0) AND (Ini.PreviewVolume <> 0) AND (Not CatSongs.Song[Interaction].Main) AND (Ini.PreviewFading <> 0) then + begin + //Start Song Fade after a little Time, to prevent Song to be Played on Scrolling + if (CoverTime < 0.2) and (CoverTime + TimeSkip >= 0.2) then + Music.Play; + + //Update Song Volume + if (CoverTime < Ini.PreviewFading) then + Music.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10)) + else + Music.SetMusicVolume(Ini.PreviewVolume * 10); + + end; + + + //Update Fading Time + CoverTime := CoverTime + TimeSkip; + + //Update Fading Texture + Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5; + if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1; + + end; + + //inherited Draw; + //heres a little Hack, that causes the Statics + //are Drawn after the Buttons because of some Blending Problems. + //This should cause no Problems because all Buttons on this screen + //Has Z Position. + //Draw BG + DrawBG; + + //Instead of Draw FG Procedure: + //We draw Buttons for our own + for I := 0 to Length(Button) - 1 do + Button[I].Draw; + + // Statics + for I := 0 to Length(Static) - 1 do + Static[I].Draw; + + // and texts + for I := 0 to Length(Text) - 1 do + Text[I].Draw; + + + //Draw Equalizer + if Theme.Song.Equalizer.Visible then + DrawEqualizer; + + DrawExtensions; +end; + +procedure TScreenSong.SelectNext; +var + Skip: integer; + I: integer; + VS: Integer; +begin + VS := CatSongs.VisibleSongs; + + if VS > 0 then + begin + UnLoadDetailedCover; + + Skip := 1; + + // this 1 could be changed by CatSongs.FindNextVisible + while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do Inc(Skip); + + SongTarget := SongTarget + 1;//Skip; + + Interaction := (Interaction + Skip) mod Length(Interactions); + + // try to keep all at the beginning + if SongTarget > VS-1 then begin + SongTarget := SongTarget - VS; + SongCurrent := SongCurrent - VS; + end; + + end; + // Interaction -> Button, ktorego okladke przeczytamy + // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture +end; + +procedure TScreenSong.SelectPrev; +var + Skip: integer; + I: integer; + VS: Integer; +begin + VS := CatSongs.VisibleSongs; + + if VS > 0 then + begin + UnLoadDetailedCover; + + Skip := 1; + + while (not CatSongs.Song[(Interaction - Skip + Length(Interactions)) mod Length(Interactions)].Visible) do Inc(Skip); + SongTarget := SongTarget - 1;//Skip; + + Interaction := (Interaction - Skip + Length(Interactions)) mod Length(Interactions); + + // try to keep all at the beginning + if SongTarget < 0 then begin + SongTarget := SongTarget + CatSongs.VisibleSongs; + SongCurrent := SongCurrent + CatSongs.VisibleSongs; + end; + + // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture + end; +end; + +procedure TScreenSong.UpdateLCD; +begin + LCD.HideCursor; + LCD.Clear; + LCD.WriteText(1, Text[TextArtist].Text); + LCD.WriteText(2, Text[TextTitle].Text); +end; + +//Procedure Change current played Preview +procedure TScreenSong.ChangeMusic; +begin + //When Music Preview is avtivated -> then Change Music + if (Ini.PreviewVolume <> 0) then + begin + if (NOT CatSongs.Song[Interaction].Main) AND(CatSongs.VisibleSongs > 0) then + begin + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + Music.MoveTo(Music.Length / 4); + //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal + if (Ini.PreviewFading = 0) then + Music.Play + else + Music.SetMusicVolume(0); + end; + end + else + Music.Stop; + end; +end; + +procedure TScreenSong.SkipTo(Target: Cardinal); // 0.5.0 +var + Skip: integer; + I: integer; +begin + UnLoadDetailedCover; + + Interaction := High(CatSongs.Song); + SongTarget := 0; + + for I := 1 to Target+1 do + SelectNext; + + FixSelected2; +end; + +procedure TScreenSong.DrawEqualizer; +var + Data: TFFTData; //Audio Data + I, J: Integer; + Res: byte; + A, B: Integer; + PosX, PosY: Integer; + Pos: Real; +begin +if (not Music.Finished) AND (Theme.Song.Equalizer.Length > 0) then +begin + + + A := GetTickCount div 44; + + if (A <> EqualizerTime) then + begin + EqualizerTime := A; + Data := Music.GetFFTData; + + B:=0; + Pos := 0; + Res := ceil(92/Theme.Song.Equalizer.Bands);//How much channels are used for one Band + + //Change Lengths + for I := 0 to (Res * Theme.Song.Equalizer.Bands - 1) do + begin + A := floor(I/Res); + + if (A<>B) then //Band changed + begin + if (Pos <= Theme.Song.Equalizer.Length) then + begin + if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then + EqualizerBands[B] := EqualizerBands[B] - 1 + else + EqualizerBands[B] := floor(Pos); + end + else + EqualizerBands[B] := 1; + + B := A; + Pos := 0; + end; + + if I > 35 then + Data[i] := Data[i] * 8 + else if I > 11 then + Data[i] := Data[i] * 4.5 + else + Data[i] := Data[i] * 1.1; + + if (Data[i] >= 1) then + Data[i] := 0.9999999999999; + + if Data[i]*Theme.Song.Equalizer.Length > Pos then + Pos := Data[i]*Theme.Song.Equalizer.Length; + end; + + //Change Last Band + if (EqualizerBands[B] <= Theme.Song.Equalizer.Length) then + begin + if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then + EqualizerBands[B] := EqualizerBands[B] - 1 + else + EqualizerBands[B] := floor(Pos) + end + else + EqualizerBands[B] := 1; + end; + + //Draw every Channel + glColor4f(Theme.Song.Equalizer.ColR, Theme.Song.Equalizer.ColG, Theme.Song.Equalizer.ColB, Theme.Song.Equalizer.Alpha); //Set Color + glDisable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + PosY := Theme.Song.Equalizer.Y; + PosX := Theme.Song.Equalizer.X; + + For I := 0 to Theme.Song.Equalizer.Bands-1 do + begin + if Theme.Song.Equalizer.Direction then + PosY := Theme.Song.Equalizer.Y //+ (Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space) * Theme.Song.Equalizer.Length + else + PosX := Theme.Song.Equalizer.X; + //Draw for every visible quad + for J := 1 to EqualizerBands[I] do + begin + glBegin(GL_QUADS); + glVertex3f(PosX, PosY, Theme.Song.Equalizer.Z); + glVertex3f(PosX, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); + glVertex3f(PosX+Theme.Song.Equalizer.W, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); + glVertex3f(PosX+Theme.Song.Equalizer.W, PosY, Theme.Song.Equalizer.Z); + glEnd; + + if Theme.Song.Equalizer.Direction then //Vertically + PosY := PosY - Theme.Song.Equalizer.H - Theme.Song.Equalizer.Space + else //Horizontally + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space; + end; + if Theme.Song.Equalizer.Direction then //Horizontally + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space + else //Vertically + PosY := PosY + Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space; + end; +end; +end; + +Procedure TScreenSong.SelectRandomSong; +var + I, I2: Integer; +begin + Case PlaylistMan.Mode of + 0: //All Songs Just Select Random Song + begin + //When Tabs are activated then use Tab Method + if (Ini.Tabs_at_startup = 1) then + begin + repeat + I2 := Random(high(CatSongs.Song)+1) - low(CatSongs.Song)+1; + until CatSongs.Song[I2].Main = false; + + //Search Cat + for I := I2 downto low(CatSongs.Song) do + begin + if CatSongs.Song[I].Main then + break; + end; + //In I ist jetzt die Kategorie in I2 der Song + //I is the CatNum, I2 is the No of the Song within this Cat + + //Choose Cat + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + + //Choose Song + SkipTo(I2-I); + end + //When Tabs are deactivated use easy Method + else + SkipTo(Random(CatSongs.VisibleSongs)); + end; + 1: //One Category Select Category and Select Random Song + begin + CatSongs.ShowCategoryList; + CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); + ShowCatTL(PlaylistMan.CurPlayList); + + SelectNext; + FixSelected2; + + SkipTo(Random(CatSongs.VisibleSongs)); + end; + 2: //Playlist: Select Playlist and Select Random Song + begin + PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); + + SkipTo(Random(CatSongs.VisibleSongs)); + FixSelected2; + end; + end; + + Music.PlayChange; + ChangeMusic; + SetScroll; + UpdateLCD; +end; + +procedure TScreenSong.SetJoker; +begin + //If Party Mode + if Mode = 1 then //Show Joker that are available + begin + if (PartySession.Teams.NumTeams >= 1) then + begin + Static[StaticTeam1Joker1].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 1); + Static[StaticTeam1Joker2].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 2); + Static[StaticTeam1Joker3].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 3); + Static[StaticTeam1Joker4].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 4); + Static[StaticTeam1Joker5].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 5); + end + else + begin + Static[StaticTeam1Joker1].Visible := False; + Static[StaticTeam1Joker2].Visible := False; + Static[StaticTeam1Joker3].Visible := False; + Static[StaticTeam1Joker4].Visible := False; + Static[StaticTeam1Joker5].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 2) then + begin + Static[StaticTeam2Joker1].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 1); + Static[StaticTeam2Joker2].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 2); + Static[StaticTeam2Joker3].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 3); + Static[StaticTeam2Joker4].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 4); + Static[StaticTeam2Joker5].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 5); + end + else + begin + Static[StaticTeam2Joker1].Visible := False; + Static[StaticTeam2Joker2].Visible := False; + Static[StaticTeam2Joker3].Visible := False; + Static[StaticTeam2Joker4].Visible := False; + Static[StaticTeam2Joker5].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 3) then + begin + Static[StaticTeam3Joker1].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 1); + Static[StaticTeam3Joker2].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 2); + Static[StaticTeam3Joker3].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 3); + Static[StaticTeam3Joker4].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 4); + Static[StaticTeam3Joker5].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 5); + end + else + begin + Static[StaticTeam3Joker1].Visible := False; + Static[StaticTeam3Joker2].Visible := False; + Static[StaticTeam3Joker3].Visible := False; + Static[StaticTeam3Joker4].Visible := False; + Static[StaticTeam3Joker5].Visible := False; + end; + end + else + begin //Hide all + Static[StaticTeam1Joker1].Visible := False; + Static[StaticTeam1Joker2].Visible := False; + Static[StaticTeam1Joker3].Visible := False; + Static[StaticTeam1Joker4].Visible := False; + Static[StaticTeam1Joker5].Visible := False; + + Static[StaticTeam2Joker1].Visible := False; + Static[StaticTeam2Joker2].Visible := False; + Static[StaticTeam2Joker3].Visible := False; + Static[StaticTeam2Joker4].Visible := False; + Static[StaticTeam2Joker5].Visible := False; + + Static[StaticTeam3Joker1].Visible := False; + Static[StaticTeam3Joker2].Visible := False; + Static[StaticTeam3Joker3].Visible := False; + Static[StaticTeam3Joker4].Visible := False; + Static[StaticTeam3Joker5].Visible := False; + end; +end; + +procedure TScreenSong.SetStatics; +var + I: Integer; + Visible: Boolean; +begin + //Set Visibility of Party Statics and Text + Visible := (Mode = 1); + + For I := 0 to high(StaticParty) do + Static[StaticParty[I]].Visible := Visible; + + For I := 0 to high(TextParty) do + Text[TextParty[I]].Visible := Visible; + + //Set Visibility of Non Party Statics and Text + Visible := not Visible; + + For I := 0 to high(StaticNonParty) do + Static[StaticNonParty[I]].Visible := Visible; + + For I := 0 to high(TextNonParty) do + Text[TextNonParty[I]].Visible := Visible; +end; + +//Procedures for Menu + +procedure TScreenSong.StartSong; +begin + CatSongs.Selected := Interaction; + Music.Stop; + //Party Mode + if (Mode = 1) then + begin + FadeTo(@ScreenSingModi); + end + else + begin + FadeTo(@ScreenSing); + end; +end; + +procedure TScreenSong.SelectPlayers; +begin + CatSongs.Selected := Interaction; + Music.Stop; + + ScreenName.Goto_SingScreen := True; + FadeTo(@ScreenName); +end; + +procedure TScreenSong.OpenEditor; +begin + if (Length(Songs.Song) > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then begin + Music.Stop; + Music.PlayStart; + ScreenEditSub.Path := CatSongs.Song[Interaction].Path; + ScreenEditSub.FileName := CatSongs.Song[Interaction].FileName; + FadeTo(@ScreenEditSub); + end; +end; + +//Team No of Team (0-5) +procedure TScreenSong.DoJoker (Team: Byte); +begin + if (Mode = 1) AND (PartySession.Teams.NumTeams >= Team + 1) AND (PartySession.Teams.Teaminfo[Team].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[Team].Joker); + SelectRandomSong; + SetJoker; + end; +end; + +//Detailed Cover Unloading. Unloads the Detailed, uncached Cover of the cur. Song +procedure TScreenSong.UnLoadDetailedCover; +begin + CoverTime := 0; + + Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture + Button[Interaction].Texture2.Alpha := 0; + + if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then + Texture.UnloadTexture(Button[Interaction].Texture.Name, false); +end; + +procedure TScreenSong.Refresh; +begin { +CatSongs.Refresh; +CatSongs.ShowCategoryList; +Interaction := 0; +SelectNext; +FixSelected; } + +end; + +end. \ No newline at end of file diff --git a/Game/Code/Screens/UScreenSongJumpto.pas b/Game/Code/Screens/UScreenSongJumpto.pas new file mode 100644 index 00000000..48d23468 --- /dev/null +++ b/Game/Code/Screens/UScreenSongJumpto.pas @@ -0,0 +1,203 @@ +unit UScreenSongJumpto; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, SysUtils, UThemes; + +type + TScreenSongJumpto = class(TMenu) + private + //For ChangeMusic + LastPlayed: Integer; + VisibleBool: Boolean; + public + VisSongs: Integer; + + constructor Create; override; + + //Visible //Whether the Menu should be Drawn + //Whether the Menu should be Drawn + procedure SetVisible(Value: Boolean); + property Visible: Boolean read VisibleBool write SetVisible; + + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + function Draw: boolean; override; + + procedure SetTextFound(const Count: Cardinal); + end; + +var + IType: Array [0..2] of String; + SelectType: Integer; + + +implementation + +uses UGraphic, UMain, UIni, UTexture, ULanguage, UParty, USongs, UScreenSong, ULog; + +function TScreenSongJumpto.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_0..SDLK_9, SDLK_A..SDLK_Z, SDLK_SPACE, SDLK_MINUS, SDLK_EXCLAIM, SDLK_COMMA, SDLK_SLASH, SDLK_ASTERISK, SDLK_QUESTION, SDLK_QUOTE, SDLK_QUOTEDBL, SDLK_LEFTBRACKET, SDLK_SEMICOLON: + begin + if Interaction = 0 then + begin + Button[0].Text[0].Text := Button[0].Text[0].Text + chr(ScanCode); + SetTextFound(CatSongs.SetFilter(Button[0].Text[0].Text, SelectType)); + end; + end; + + SDLK_BACKSPACE: + begin + if (Interaction = 0) AND (Length(Button[0].Text[0].Text) > 0) then + begin + Button[0].Text[0].DeleteLastL; + SetTextFound(CatSongs.SetFilter(Button[0].Text[0].Text, SelectType)); + end; + end; + + SDLK_RETURN, + SDLK_ESCAPE: + begin + Visible := False; + Music.PlayBack; + if (VisSongs = 0) AND (Length(Button[0].Text[0].Text) > 0) then + begin + ScreenSong.UnLoadDetailedCover; + Button[0].Text[0].Text := ''; + CatSongs.SetFilter('', 0); + SetTextFound(0); + end; + end; + + // Up and Down could be done at the same time, + // but I don't want to declare variables inside + // functions like this one, called so many times + SDLK_DOWN: + begin + {SelectNext; + Button[0].Text[0].Selected := (Interaction = 0);} + end; + + SDLK_UP: + begin + {SelectPrev; + Button[0].Text[0].Selected := (Interaction = 0); } + end; + + SDLK_RIGHT: + begin + Interaction := 1; + InteractInc; + if (Length(Button[0].Text[0].Text) > 0) then + SetTextFound(CatSongs.SetFilter(Button[0].Text[0].Text, SelectType)); + Interaction := 0; + end; + SDLK_LEFT: + begin + Interaction := 1; + InteractDec; + if (Length(Button[0].Text[0].Text) > 0) then + SetTextFound(CatSongs.SetFilter(Button[0].Text[0].Text, SelectType)); + Interaction := 0; + end; + end; + end; +end; + +constructor TScreenSongJumpto.Create; +var + I: integer; +begin + inherited Create; + + AddText(Theme.SongJumpto.TextFound); + + LoadFromTheme(Theme.SongJumpto); + + AddButton(Theme.SongJumpto.ButtonSearchText); + if (Length(Button[0].Text) = 0) then + AddButtonText(14, 20, ''); + + SelectType := 0; + AddSelectSlide(Theme.SongJumpto.SelectSlideType, SelectType, Theme.SongJumpto.IType); + + + Interaction := 0; + LastPlayed := 0; +end; + +procedure TScreenSongJumpto.SetVisible(Value: Boolean); +begin +//If change from unvisible to Visible then OnShow + if (VisibleBool = False) AND (Value = True) then + OnShow; + + VisibleBool := Value; +end; + +procedure TScreenSongJumpto.onShow; +begin + //Reset Screen if no Old Search is Displayed + if (CatSongs.CatNumShow <> -2) then + begin + SelectsS[0].SetSelectOpt(0); + + Button[0].Text[0].Text := ''; + Text[0].Text := Theme.SongJumpto.NoSongsFound; + end; + + //Select Input + Interaction := 0; + Button[0].Text[0].Selected := True; + + LastPlayed := ScreenSong.Interaction; +end; + +function TScreenSongJumpto.Draw: boolean; +begin + Result := inherited Draw; +end; + +procedure TScreenSongJumpto.SetTextFound(const Count: Cardinal); +begin + if (Count = 0) then + begin + Text[0].Text := Theme.SongJumpto.NoSongsFound; + if (Length(Button[0].Text[0].Text) = 0) then + ScreenSong.HideCatTL + else + ScreenSong.ShowCatTLCustom(Format(Theme.SongJumpto.CatText, [Button[0].Text[0].Text])); + end + else + begin + Text[0].Text := Format(Theme.SongJumpto.SongsFound, [Count]); + + //Set CatTopLeftText + ScreenSong.ShowCatTLCustom(Format(Theme.SongJumpto.CatText, [Button[0].Text[0].Text])); + end; + + + //Set visSongs + VisSongs := Count; + + //Fix SongSelection + ScreenSong.Interaction := high(CatSongs.Song); + ScreenSong.SelectNext; + ScreenSong.FixSelected; + + //Play Correct Music + if (ScreenSong.Interaction <> LastPlayed) then + begin + LastPlayed := ScreenSong.Interaction; + + ScreenSong.ChangeMusic; + end; +end; + +end. diff --git a/Game/Code/Screens/UScreenSongMenu.pas b/Game/Code/Screens/UScreenSongMenu.pas new file mode 100644 index 00000000..5e1841c6 --- /dev/null +++ b/Game/Code/Screens/UScreenSongMenu.pas @@ -0,0 +1,614 @@ +unit UScreenSongMenu; + +interface + +uses + UMenu, SDL, UDisplay, UMusic, UFiles, SysUtils, UThemes; + +type + TScreenSongMenu = class(TMenu) + private + CurMenu: Byte; //Num of the cur. Shown Menu + public + Visible: Boolean; //Whether the Menu should be Drawn + + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + function Draw: boolean; override; + procedure MenuShow(sMenu: Byte); + procedure HandleReturn; + end; + +const + SM_Main = 1; + + SM_PlayList = 64 or 1; + SM_Playlist_Add = 64 or 2; + SM_Playlist_New = 64 or 3; + + SM_Playlist_DelItem = 64 or 5; + + SM_Playlist_Load = 64 or 8 or 1; + SM_Playlist_Del = 64 or 8 or 5; + + + SM_Party_Main = 128 or 1; + SM_Party_Joker = 128 or 2; + +var + ISelections: Array of String; + SelectValue: Integer; + + +implementation + +uses UGraphic, UMain, UIni, UTexture, ULanguage, UParty, UPlaylist, USongs; + +function TScreenSongMenu.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + if (CurMenu = SM_Playlist_New) AND (Interaction=0) then + begin + case PressedKey of + SDLK_0..SDLK_9, SDLK_A..SDLK_Z, SDLK_SPACE, SDLK_MINUS, SDLK_EXCLAIM, SDLK_COMMA, SDLK_SLASH, SDLK_ASTERISK, SDLK_QUESTION, SDLK_QUOTE, SDLK_QUOTEDBL: + begin + Button[Interaction].Text[0].Text := Button[Interaction].Text[0].Text + chr(ScanCode); + exit; + end; + + SDLK_BACKSPACE: + begin + Button[Interaction].Text[0].DeleteLastL; + exit; + end; + end; + end; + + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Music.PlayBack; + Visible := False; + end; + + SDLK_RETURN: + begin + HandleReturn; + end; + + SDLK_DOWN: InteractNext; + SDLK_UP: InteractPrev; + + SDLK_RIGHT: + begin + if (Interaction=3) then + InteractInc; + end; + SDLK_LEFT: + begin + if (Interaction=3) then + InteractDec; + end; + + SDLK_1: + begin //Jocker + //Joker spielen + case CurMenu of + SM_Party_Main: + begin + ScreenSong.DoJoker(0) + end; + end; + end; + SDLK_2: + begin //Jocker + //Joker spielen + case CurMenu of + SM_Party_Main: + begin + ScreenSong.DoJoker(1) + end; + end; + end; + SDLK_3: + begin //Jocker + //Joker spielen + case CurMenu of + SM_Party_Main: + begin + ScreenSong.DoJoker(2) + end; + end; + end; + + + end; + end; +end; + +constructor TScreenSongMenu.Create; +var + I: integer; +begin + inherited Create; + + //Create Dummy SelectSlide Entrys + SetLength(ISelections, 1); + ISelections[0] := 'Dummy'; + + + AddText(Theme.SongMenu.TextMenu); + + LoadFromTheme(Theme.SongMenu); + + AddButton(Theme.SongMenu.Button1); + if (Length(Button[0].Text) = 0) then + AddButtonText(14, 20, 'Button 1'); + + AddButton(Theme.SongMenu.Button2); + if (Length(Button[1].Text) = 0) then + AddButtonText(14, 20, 'Button 2'); + + AddButton(Theme.SongMenu.Button3); + if (Length(Button[2].Text) = 0) then + AddButtonText(14, 20, 'Button 3'); + + AddSelectSlide(Theme.SongMenu.SelectSlide3, SelectValue, ISelections); + + AddButton(Theme.SongMenu.Button4); + if (Length(Button[3].Text) = 0) then + AddButtonText(14, 20, 'Button 4'); + + + Interaction := 0; +end; + +function TScreenSongMenu.Draw: boolean; +begin + inherited Draw; +end; + +procedure TScreenSongMenu.onShow; +begin + +end; + +procedure TScreenSongMenu.MenuShow(sMenu: Byte); +begin + Interaction := 0; //Reset Interaction + Visible := True; //Set Visible + Case sMenu of + SM_Main: + begin + CurMenu := sMenu; + Text[0].Text := Language.Translate('SONG_MENU_NAME_MAIN'); + + Button[0].Visible := True; + Button[1].Visible := True; + Button[2].Visible := True; + Button[3].Visible := True; + SelectsS[0].Visible := False; + + Button[0].Text[0].Text := Language.Translate('SONG_MENU_PLAY'); + Button[1].Text[0].Text := Language.Translate('SONG_MENU_CHANGEPLAYERS'); + Button[2].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_ADD'); + Button[3].Text[0].Text := Language.Translate('SONG_MENU_EDIT'); + end; + + SM_PlayList: + begin + CurMenu := sMenu; + Text[0].Text := Language.Translate('SONG_MENU_NAME_PLAYLIST'); + + Button[0].Visible := True; + Button[1].Visible := True; + Button[2].Visible := True; + Button[3].Visible := True; + SelectsS[0].Visible := False; + + Button[0].Text[0].Text := Language.Translate('SONG_MENU_PLAY'); + Button[1].Text[0].Text := Language.Translate('SONG_MENU_CHANGEPLAYERS'); + Button[2].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_DEL'); + Button[3].Text[0].Text := Language.Translate('SONG_MENU_EDIT'); + end; + + SM_Playlist_Add: + begin + CurMenu := sMenu; + Text[0].Text := Language.Translate('SONG_MENU_NAME_PLAYLIST_ADD'); + + Button[0].Visible := True; + Button[1].Visible := False; + Button[2].Visible := False; + Button[3].Visible := True; + SelectsS[0].Visible := True; + + Button[0].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_ADD_NEW'); + Button[3].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_ADD_EXISTING'); + + SetLength(ISelections, Length(PlaylistMan.Playlists)); + PlaylistMan.GetNames(ISelections); + + if (Length(ISelections)>=1) then + begin + UpdateSelectSlideOptions(Theme.SongMenu.SelectSlide3, 0, ISelections, SelectValue); + end + else + begin + Button[3].Visible := False; + SelectsS[0].Visible := False; + Button[2].Visible := True; + Button[2].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_NOEXISTING'); + end; + end; + + SM_Playlist_New: + begin + CurMenu := sMenu; + Text[0].Text := Language.Translate('SONG_MENU_NAME_PLAYLIST_NEW'); + + Button[0].Visible := True; + Button[1].Visible := False; + Button[2].Visible := True; + Button[3].Visible := True; + SelectsS[0].Visible := False; + + Button[0].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_NEW_UNNAMED'); + Button[2].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_NEW_CREATE'); + Button[3].Text[0].Text := Language.Translate('SONG_MENU_CANCEL'); + end; + + SM_Playlist_DelItem: + begin + CurMenu := sMenu; + Text[0].Text := Language.Translate('SONG_MENU_NAME_PLAYLIST_DELITEM'); + + Button[0].Visible := True; + Button[1].Visible := False; + Button[2].Visible := False; + Button[3].Visible := True; + SelectsS[0].Visible := False; + + Button[0].Text[0].Text := Language.Translate('SONG_MENU_YES'); + Button[3].Text[0].Text := Language.Translate('SONG_MENU_CANCEL'); + end; + + SM_Playlist_Load: + begin + CurMenu := sMenu; + Text[0].Text := Language.Translate('SONG_MENU_NAME_PLAYLIST_LOAD'); + + //Show Delete Curent Playlist Button when Playlist is opened + Button[0].Visible := (CatSongs.CatNumShow = -3); + + Button[1].Visible := False; + Button[2].Visible := False; + Button[3].Visible := True; + SelectsS[0].Visible := True; + + Button[0].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_DELCURRENT'); + Button[3].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_LOAD'); + + SetLength(ISelections, Length(PlaylistMan.Playlists)); + PlaylistMan.GetNames(ISelections); + + if (Length(ISelections)>=1) then + begin + UpdateSelectSlideOptions(Theme.SongMenu.SelectSlide3, 0, ISelections, SelectValue); + Interaction := 3; + end + else + begin + Button[3].Visible := False; + SelectsS[0].Visible := False; + Button[2].Visible := True; + Button[2].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_NOEXISTING'); + Interaction := 2; + end; + end; + + SM_Playlist_Del: + begin + CurMenu := sMenu; + Text[0].Text := Language.Translate('SONG_MENU_NAME_PLAYLIST_DEL'); + + Button[0].Visible := True; + Button[1].Visible := False; + Button[2].Visible := False; + Button[3].Visible := True; + SelectsS[0].Visible := False; + + Button[0].Text[0].Text := Language.Translate('SONG_MENU_YES'); + Button[3].Text[0].Text := Language.Translate('SONG_MENU_CANCEL'); + end; + + + SM_Party_Main: + begin + CurMenu := sMenu; + Text[0].Text := Language.Translate('SONG_MENU_NAME_PARTY_MAIN'); + + Button[0].Visible := True; + Button[1].Visible := False; + Button[2].Visible := False; + Button[3].Visible := True; + SelectsS[0].Visible := False; + + Button[0].Text[0].Text := Language.Translate('SONG_MENU_PLAY'); + //Button[1].Text[0].Text := Language.Translate('SONG_MENU_JOKER'); + //Button[2].Text[0].Text := Language.Translate('SONG_MENU_PLAYMODI'); + Button[3].Text[0].Text := Language.Translate('SONG_MENU_JOKER'); + end; + + SM_Party_Joker: + begin + CurMenu := sMenu; + Text[0].Text := Language.Translate('SONG_MENU_NAME_PARTY_JOKER'); + + Button[0].Visible := (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0); + Button[1].Visible := (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0); + Button[2].Visible := (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0); + Button[3].Visible := True; + SelectsS[0].Visible := False; + + Button[0].Text[0].Text := String(PartySession.Teams.Teaminfo[0].Name); + Button[1].Text[0].Text := String(PartySession.Teams.Teaminfo[1].Name); + Button[2].Text[0].Text := String(PartySession.Teams.Teaminfo[2].Name); + Button[3].Text[0].Text := Language.Translate('SONG_MENU_CANCEL'); + + //Set right Interaction + if (not Button[0].Visible) then + begin + if (not Button[1].Visible) then + begin + if (not Button[2].Visible) then + begin + Interaction := 4; + end + else Interaction := 2; + end + else Interaction := 1; + end; + + end; + end; +end; + +procedure TScreenSongMenu.HandleReturn; +begin + Case CurMenu of + SM_Main: + begin + Case Interaction of + 0: //Button 1 + begin + ScreenSong.StartSong; + Visible := False; + end; + + 1: //Button 2 + begin + //Select New Players then Sing: + ScreenSong.SelectPlayers; + Visible := False; + end; + + 2: //Button 3 + begin + //Show add to Playlist Menu + MenuShow(SM_Playlist_Add); + end; + + 3: //SelectSlide 3 + begin + //Dummy + end; + + 4: //Button 4 + begin + ScreenSong.OpenEditor; + Visible := False; + end; + end; + end; + + SM_PlayList: + begin + Visible := False; + Case Interaction of + 0: //Button 1 + begin + ScreenSong.StartSong; + Visible := False; + end; + + 1: //Button 2 + begin + //Select New Players then Sing: + ScreenSong.SelectPlayers; + Visible := False; + end; + + 2: //Button 3 + begin + //Show add to Playlist Menu + MenuShow(SM_Playlist_DelItem); + end; + + 3: //SelectSlide 3 + begin + //Dummy + end; + + 4: //Button 4 + begin + ScreenSong.OpenEditor; + Visible := False; + end; + end; + end; + + SM_Playlist_Add: + begin + Case Interaction of + 0: //Button 1 + begin + MenuShow(SM_Playlist_New); + end; + + 3: //SelectSlide 3 + begin + //Dummy + end; + + 4: //Button 4 + begin + PlaylistMan.AddItem(ScreenSong.Interaction, SelectValue); + Visible := False; + end; + end; + end; + + SM_Playlist_New: + begin + Case Interaction of + 0: //Button 1 + begin + //Nothing, Button for Entering Name + end; + + 2: //Button 3 + begin + //Create Playlist and Add Song + PlaylistMan.AddItem( + ScreenSong.Interaction, + PlaylistMan.AddPlaylist(Button[0].Text[0].Text)); + Visible := False; + end; + + 3: //SelectSlide 3 + begin + //Cancel -> Go back to Add screen + MenuShow(SM_Playlist_Add); + end; + + 4: //Button 4 + begin + Visible := False; + end; + end; + end; + + SM_Playlist_DelItem: + begin + Visible := False; + Case Interaction of + 0: //Button 1 + begin + //Delete + PlayListMan.DelItem(PlayListMan.GetIndexbySongID(ScreenSong.Interaction)); + Visible := False; + end; + + 4: //Button 4 + begin + MenuShow(SM_Playlist); + end; + end; + end; + + SM_Playlist_Load: + begin + Case Interaction of + 0: //Button 1 (Delete Playlist) + begin + MenuShow(SM_Playlist_Del); + end; + 4: //Button 4 + begin + //Load Playlist + PlaylistMan.SetPlayList(SelectValue); + Visible := False; + end; + end; + end; + + SM_Playlist_Del: + begin + Visible := False; + Case Interaction of + 0: //Button 1 + begin + //Delete + PlayListMan.DelPlaylist(PlaylistMan.CurPlayList); + Visible := False; + end; + + 4: //Button 4 + begin + MenuShow(SM_Playlist_Load); + end; + end; + end; + + SM_Party_Main: + begin + Case Interaction of + 0: //Button 1 + begin + //Start Singing + ScreenSong.StartSong; + Visible := False; + end; + + 4: //Button 4 + begin + //Joker + MenuShow(SM_Party_Joker); + end; + end; + end; + + SM_Party_Joker: + begin + Visible := False; + Case Interaction of + 0: //Button 1 + begin + //Joker Team 1 + ScreenSong.DoJoker(0); + end; + + 1: //Button 2 + begin + //Joker Team 2 + ScreenSong.DoJoker(1); + end; + + 2: //Button 3 + begin + //Joker Team 3 + ScreenSong.DoJoker(2); + end; + + 4: //Button 4 + begin + //Cancel... (Fo back to old Menu) + MenuShow(SM_Party_Main); + end; + end; + end; + end; +end; + +end. + \ No newline at end of file diff --git a/Game/Code/Screens/UScreenStatDetail.pas b/Game/Code/Screens/UScreenStatDetail.pas new file mode 100644 index 00000000..324ad185 --- /dev/null +++ b/Game/Code/Screens/UScreenStatDetail.pas @@ -0,0 +1,247 @@ +unit UScreenStatDetail; + +interface + +uses + UMenu, SDL, SysUtils, UDisplay, UMusic, UIni, UThemes; + +type + TScreenStatDetail = class(TMenu) + public + Typ: Byte; + Page: CardinaL; + Count: Byte; + Reversed: Boolean; + + TotEntrys: Cardinal; + TotPages: Cardinal; + + + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure SetAnimationProgress(Progress: real); override; + + procedure SetTitle; + Procedure SetPage(NewPage: Cardinal); + end; + +implementation + +{Stat Screens: + 0 - Best Scores + 1 - Best Singers + 2 - Most sung Songs + 3 - Most popular Band +} + +uses UGraphic, UDataBase, ULanguage, math, ULog; + +function TScreenStatDetail.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE, + SDLK_BACKSPACE: + begin + Music.PlayBack; + FadeTo(@ScreenStatMain); + end; + SDLK_RETURN: + begin + if Interaction = 0 then begin + //Next Page + SetPage(Page+1); + end; + + if Interaction = 1 then begin + //Previous Page + if (Page > 0) then + SetPage(Page-1); + end; + + if Interaction = 2 then begin + //Reverse Order + Reversed := not Reversed; + SetPage(Page); + end; + + if Interaction = 3 then begin + Music.PlayBack; + FadeTo(@ScreenStatMain); + end; + end; + SDLK_LEFT: + begin + InteractPrev; + end; + SDLK_RIGHT: + begin + InteractNext; + end; + SDLK_UP: + begin + InteractPrev; + end; + SDLK_DOWN: + begin + InteractNext; + end; + end; + end; +end; + +constructor TScreenStatDetail.Create; +var + I: integer; +begin + inherited Create; + + for I := 0 to High(Theme.StatDetail.TextList) do + AddText(Theme.StatDetail.TextList[I]); + + Count := Length(Theme.StatDetail.TextList); + + AddText(Theme.StatDetail.TextDescription); + AddText(Theme.StatDetail.TextPage); + + LoadFromTheme(Theme.StatDetail); + + AddButton(Theme.StatDetail.ButtonNext); + if (Length(Button[0].Text)=0) then + AddButtonText(14, 20, Language.Translate('STAT_NEXT')); + + AddButton(Theme.StatDetail.ButtonPrev); + if (Length(Button[1].Text)=0) then + AddButtonText(14, 20, Language.Translate('STAT_PREV')); + + AddButton(Theme.StatDetail.ButtonReverse); + if (Length(Button[2].Text)=0) then + AddButtonText(14, 20, Language.Translate('STAT_REVERSE')); + + AddButton(Theme.StatDetail.ButtonExit); + if (Length(Button[3].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[7]); + + Interaction := 0; + Typ := 0; +end; + +procedure TScreenStatDetail.onShow; +begin + //Set Tot Entrys and PAges + TotEntrys := DataBase.GetTotalEntrys(Typ); + TotPages := Ceil(TotEntrys / Count); + //Show correct Title + SetTitle; + //Show First Page + Reversed := False; + SetPage(0); +end; + +procedure TScreenStatDetail.SetTitle; +begin + //Set Title + Case Reversed of + True: Text[Count].Text := Theme.StatDetail.DescriptionR[Typ]; + False: Text[Count].Text := Theme.StatDetail.Description[Typ]; + end; +end; + +Procedure TScreenStatDetail.SetPage(NewPage: Cardinal); +var + Result: AStatResult; + I: Integer; + FormatStr: String; + PerPage: Byte; +begin + SetLength(Result, Count); + if (Database.GetStats(Result, Typ, Count, NewPage, Reversed)) then + begin + Page := NewPage; + + FormatStr := Theme.StatDetail.FormatStr[Typ]; + + //refresh Texts + For I := 0 to Count-1 do + begin + try + case Typ of + 0:begin //Best Scores + //Set Texts + if (Result[I].Score>0) then + Text[I].Text := Format(FormatStr, [Result[I].Singer, + Result[I].Score, + Theme.ILevel[Result[I].Difficulty], + Result[I].SongArtist, + Result[I].SongTitle]) + else + Text[I].Text := ''; + end; + + 1:begin //Best Singers + //Set Texts + if (Result[I].AverageScore>0) then + Text[I].Text := Format(FormatStr, [Result[I].Player, + Result[I].AverageScore]) + else + Text[I].Text := ''; + end; + + 2:begin //Popular Songs + //Set Texts + if (Result[I].Artist<>'') then + Text[I].Text := Format(FormatStr, [Result[I].Artist, + Result[I].Title, + Result[I].TimesSung]) + else + Text[I].Text := ''; + end; + + 3:begin //Popular Bands + //Set Texts + if (Result[I].ArtistName<>'') then + Text[I].Text := Format(FormatStr, [Result[I].ArtistName, + Result[I].TimesSungtot]) + else + Text[I].Text := ''; + end; + end; + except + on E: EConvertError do + Log.LogError('Error Parsing FormatString in UScreenStatDetail: ' + E.Message); + end; + end; + + if (Page + 1 = TotPages) AND (TotEntrys Mod Count <> 0) then + PerPage := (TotEntrys Mod Count) + else + PerPage := Count; + + Text[Count+1].Text := Format(Theme.StatDetail.PageStr, [Page + 1, + TotPages, + PerPage, + TotEntrys]); + + //Show correct Title + SetTitle; + + end; + +end; + + +procedure TScreenStatDetail.SetAnimationProgress(Progress: real); +var I: Integer; +begin + For I := 0 to high(Button) do + Button[I].Texture.ScaleW := Progress; +end; + +end. diff --git a/Game/Code/Screens/UScreenStatMain.pas b/Game/Code/Screens/UScreenStatMain.pas new file mode 100644 index 00000000..d00552fd --- /dev/null +++ b/Game/Code/Screens/UScreenStatMain.pas @@ -0,0 +1,225 @@ +unit UScreenStatMain; + +interface + +uses + UMenu, SDL, SysUtils, UDisplay, UMusic, UIni, UThemes; + +type + TScreenStatMain = class(TMenu) + private + //Some Stat Value that don't need to be calculated 2 times + SongswithVid: Cardinal; + public + TextOverview: integer; + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure SetAnimationProgress(Progress: real); override; + + procedure SetOverview; + end; + +implementation + +uses UGraphic, UDataBase, USongs, ULanguage, windows, ULog; + +function TScreenStatMain.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE, + SDLK_BACKSPACE: + begin + Ini.Save; + Music.PlayBack; + FadeTo(@ScreenMain); + end; + SDLK_RETURN: + begin + //Exit Button Pressed + if Interaction = 4 then begin + Music.PlayBack; + FadeTo(@ScreenMain); + end + else //One of the Stats Buttons Pressed + begin + Music.PlayBack; + ScreenStatDetail.Typ := Interaction; + FadeTo(@ScreenStatDetail); + end; + end; + SDLK_LEFT: + begin + InteractPrev; + end; + SDLK_RIGHT: + begin + InteractNext; + end; + SDLK_UP: + begin + InteractPrev; + end; + SDLK_DOWN: + begin + InteractNext; + end; + end; + end; +end; + +constructor TScreenStatMain.Create; +var + I: integer; +begin + inherited Create; + + TextOverview := AddText(Theme.StatMain.TextOverview); + + LoadFromTheme(Theme.StatMain); + + AddButton(Theme.StatMain.ButtonScores); + if (Length(Button[0].Text)=0) then + AddButtonText(14, 20, Theme.StatDetail.Description[0]); + + AddButton(Theme.StatMain.ButtonSingers); + if (Length(Button[1].Text)=0) then + AddButtonText(14, 20, Theme.StatDetail.Description[1]); + + AddButton(Theme.StatMain.ButtonSongs); + if (Length(Button[2].Text)=0) then + AddButtonText(14, 20, Theme.StatDetail.Description[2]); + + AddButton(Theme.StatMain.ButtonBands); + if (Length(Button[3].Text)=0) then + AddButtonText(14, 20, Theme.StatDetail.Description[3]); + + AddButton(Theme.StatMain.ButtonExit); + if (Length(Button[4].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[4]); + + Interaction := 0; + + //Set Songs with Vid + SongswithVid := 0; + For I := 0 to high(Songs.Song) do + if (Songs.Song[I].Video <> '') then + Inc(SongswithVid); +end; + +procedure TScreenStatMain.onShow; +begin + //Set Overview Text: + SetOverview; +end; + +procedure TScreenStatMain.SetOverview; +var + Overview, Formatstr: String; + I: Integer; + //Some Vars to Save Attributes to + A1, A2, A3: Integer; + A4, A5: String; + Result1, Result2: AStatResult; + ResetTime: TSystemTime; + function GetFileCreation(Filename: String): TSystemTime; + var + FindData: TWin32FindData; + Handle: THandle; + begin + Handle := FindFirstFile(PChar(Filename), FindData); + if Handle <> INVALID_HANDLE_VALUE then + begin + FileTimeToSystemTime(FindData.ftCreationTime, Result); + Windows.FindClose(Handle); + end; + end; +begin + //Song Overview + + //Introduction + Formatstr := Language.Translate ('STAT_OVERVIEW_INTRO'); + {Format: + %0:d Ultrastar Version + %1:d Day of Reset (A1) + %2:d Month of Reset (A2) + %3:d Year of Reset (A3)} + + ResetTime := GetFileCreation(Database.Filename); + + A1 := ResetTime.wDay; + A2 := ResetTime.wMonth; + A3 := ResetTime.wYear; + try + Overview := Format(Formatstr, [Language.Translate('US_VERSION'), A1, A2, A3]); + except + on E: EConvertError do + Log.LogError('Error Parsing FormatString "STAT_OVERVIEW_INTRO": ' + E.Message); + end; + + Formatstr := Language.Translate ('STAT_OVERVIEW_SONG'); + {Format: + %0:d Count Songs (A1) + %1:d Count of Sung Songs (A2) + %2:d Count of UnSung Songs + %3:d Count of Songs with Video (A3) + %4:s Name of the most popular Song} + A1 := Length(Songs.Song); + A2 := Database.GetTotalEntrys(2); + + A3 := SongswithVid; + + SetLength(Result1, 1); + Database.GetStats(Result1, 2, 1, 0, False); + A4 := Result1[0].Artist; + A5 := Result1[0].Title; + + try + Overview := Overview + '\n \n' + Format(Formatstr, [A1, A2, A1-A2, A3, A4, A5]); + except + on E: EConvertError do + Log.LogError('Error Parsing FormatString "STAT_OVERVIEW_SONG": ' + E.Message); + end; + + //Player Overview + Formatstr := Language.Translate ('STAT_OVERVIEW_PLAYER'); + {Format: + %0:d Count Players (A1) + %1:s Best Player (Result) + %2:d Best Players Score + %3:s Best Score Player (Result2) + %4:d Best Score} + A1 := Database.GetTotalEntrys(1); + + SetLength(Result1, 1); + Database.GetStats(Result1, 1, 1, 0, False); + + SetLength(Result2, 1); + Database.GetStats(Result2, 0, 1, 0, False); + + try + Overview := Overview + '\n \n' + Format(Formatstr, [A1, Result1[0].Player, Result1[0].AverageScore, Result2[0].Singer, Result2[0].Score]); + except + on E: EConvertError do + Log.LogError('Error Parsing FormatString "STAT_OVERVIEW_PLAYER": ' + E.Message); + end; + + Text[0].Text := Overview; +end; + + +procedure TScreenStatMain.SetAnimationProgress(Progress: real); +var I: Integer; +begin + For I := 0 to high(Button) do + Button[I].Texture.ScaleW := Progress; +end; + +end. \ No newline at end of file diff --git a/Game/Code/Screens/UScreenTop5.pas b/Game/Code/Screens/UScreenTop5.pas new file mode 100644 index 00000000..3b555bd0 --- /dev/null +++ b/Game/Code/Screens/UScreenTop5.pas @@ -0,0 +1,160 @@ +unit UScreenTop5; + +interface + +uses + UMenu, SDL, SysUtils, UDisplay, UMusic, USongs, UThemes, ULCD; + +type + TScreenTop5 = class(TMenu) + public + TextLevel: integer; + TextArtistTitle: integer; + + StaticNumber: array[1..5] of integer; + TextNumber: array[1..5] of integer; + TextName: array[1..5] of integer; + TextScore: array[1..5] of integer; + + Fadeout: boolean; + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + function Draw: boolean; override; + end; + +implementation + +uses UGraphic, UDataBase, UMain, UIni; + +function TScreenTop5.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then begin + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE, + SDLK_RETURN: + begin + if (not Fadeout) then begin + FadeTo(@ScreenSong); + Fadeout := true; + end; + end; + SDLK_SYSREQ: + begin + Display.PrintScreen; + end; + end; + end; +end; + +constructor TScreenTop5.Create; +var + I: integer; +begin + inherited Create; + + LoadFromTheme(Theme.Top5); + + + TextLevel := AddText(Theme.Top5.TextLevel); + TextArtistTitle := AddText(Theme.Top5.TextArtistTitle); + + for I := 0 to 4 do + StaticNumber[I+1] := AddStatic(Theme.Top5.StaticNumber[I]); + + for I := 0 to 4 do + TextNumber[I+1] := AddText(Theme.Top5.TextNumber[I]); + for I := 0 to 4 do + TextName[I+1] := AddText(Theme.Top5.TextName[I]); + for I := 0 to 4 do + TextScore[I+1] := AddText(Theme.Top5.TextScore[I]); + +end; + +procedure TScreenTop5.onShow; +var + I: integer; + PMax: integer; +begin + Fadeout := false; + + PMax := PlayersPlay - 1; + + for I := 0 to PMax do + DataBase.AddScore(AktSong, Ini.Difficulty, Ini.Name[I], Player[I].ScoreTotalI); + + DataBase.WriteScore(AktSong); + DataBase.ReadScore(AktSong); + + Text[TextArtistTitle].Text := AktSong.Artist + ' - ' + AktSong.Title; + + for I := 1 to Length(AktSong.Score[Ini.Difficulty]) do begin + Static[StaticNumber[I]].Visible := true; + Text[TextNumber[I]].Visible := true; + Text[TextName[I]].Visible := true; + Text[TextScore[I]].Visible := true; + + Text[TextName[I]].Text := AktSong.Score[Ini.Difficulty, I-1].Name; + Text[TextScore[I]].Text := IntToStr(AktSong.Score[Ini.Difficulty, I-1].Score); + end; + + for I := Length(AktSong.Score[Ini.Difficulty])+1 to 5 do begin + Static[StaticNumber[I]].Visible := false; + Text[TextNumber[I]].Visible := false; + Text[TextName[I]].Visible := false; + Text[TextScore[I]].Visible := false; + end; + + Text[TextLevel].Text := IDifficulty[Ini.Difficulty]; +end; + +function TScreenTop5.Draw: boolean; +//var +{ Min: real; + Max: real; + Wsp: real; + Wsp2: real; + Pet: integer;} + +{ Item: integer; + P: integer; + C: integer;} +begin + // Singstar - let it be...... with 6 statics +{ if PlayersPlay = 6 then begin + for Item := 4 to 6 do begin + if ScreenAct = 1 then P := Item-4; + if ScreenAct = 2 then P := Item-1; + + FillPlayer(Item, P); + +{ if ScreenAct = 1 then begin + LoadColor( + Static[StaticBoxLightest[Item]].Texture.ColR, + Static[StaticBoxLightest[Item]].Texture.ColG, + Static[StaticBoxLightest[Item]].Texture.ColB, + 'P1Dark'); + end; + + if ScreenAct = 2 then begin + LoadColor( + Static[StaticBoxLightest[Item]].Texture.ColR, + Static[StaticBoxLightest[Item]].Texture.ColG, + Static[StaticBoxLightest[Item]].Texture.ColB, + 'P4Dark'); + end;} + +{ end; + end;} + + inherited Draw; +end; + +end. diff --git a/Game/Code/Screens/UScreenWelcome.pas b/Game/Code/Screens/UScreenWelcome.pas new file mode 100644 index 00000000..35e159f8 --- /dev/null +++ b/Game/Code/Screens/UScreenWelcome.pas @@ -0,0 +1,118 @@ +unit UScreenWelcome; + +interface + +uses + UMenu, SDL, SysUtils, UThemes; + +type + TScreenWelcome = class(TMenu) + public + Animation: real; + Fadeout: boolean; + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function Draw: boolean; override; + procedure onShow; override; + end; + +implementation + +uses UGraphic, UTime, USkins; + +function TScreenWelcome.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then begin + case PressedKey of + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + Result := False; + end; + SDLK_RETURN: + begin + FadeTo(@ScreenMain); + Fadeout := true; + end; + end; + end; +end; + +constructor TScreenWelcome.Create; +begin + inherited Create; + AddStatic(-10, -10, 0, 0, 1, 1, 1, Skin.GetTextureFileName('ButtonAlt') , 'JPG', 'Transparent'); + AddStatic(-500, 440, 200, 5, 0, 0, 0, Skin.GetTextureFileName('Rectangle'), 'JPG', 'Font Black'); + AddStatic(-500, 472, 200, 5, 0, 0, 0, Skin.GetTextureFileName('Rectangle'), 'JPG', 'Font Black'); + AddStatic(-500, 504, 200, 5, 0, 0, 0, Skin.GetTextureFileName('Rectangle'), 'JPG', 'Font Black'); + AddStatic(-500, 536, 200, 5, 0, 0, 0, Skin.GetTextureFileName('Rectangle'), 'JPG', 'Font Black'); + AddStatic(-500, 568, 200, 5, 0, 0, 0, Skin.GetTextureFileName('Rectangle'), 'JPG', 'Font Black'); + Animation := 0; + Fadeout := false; +end; + +procedure TScreenWelcome.onShow; +begin + CountSkipTimeSet; +end; + +function TScreenWelcome.Draw: boolean; +var + Min: real; + Max: real; + Wsp: real; + Pet: integer; +begin + // star animation + Animation := Animation + TimeSkip*1000; + + // draw nothing + Min := 0; Max := 1000; + if (Animation >= Min) and (Animation < Max) then begin + end; + + // popup + Min := 1000; Max := 1120; + if (Animation >= Min) and (Animation < Max) then begin + Wsp := (Animation - Min) / (Max - Min); + Static[0].Texture.X := 600; + Static[0].Texture.Y := 600 - Wsp * 230; + Static[0].Texture.W := 200; + Static[0].Texture.H := Wsp * 230; + end; + + // bounce + Min := 1120; Max := 1200; + if (Animation >= Min) and (Animation < Max) then begin + Wsp := (Animation - Min) / (Max - Min); + Static[0].Texture.Y := 370 + Wsp * 50; + Static[0].Texture.H := 230 - Wsp * 50; + end; + + // run + Min := 1500; Max := 3500; + if (Animation >= Min) and (Animation < Max) then begin + Wsp := (Animation - Min) / (Max - Min); + + Static[0].Texture.X := 600 - Wsp * 1400; + Static[0].Texture.H := 180; + + + for Pet := 1 to 5 do begin + Static[Pet].Texture.X := 770 - Wsp * 1400; + Static[Pet].Texture.W := 150 + Wsp * 200; + Static[Pet].Texture.Alpha := Wsp * 0.5; + end; + end; + + Min := 3500; + if (Animation >= Min) and (not Fadeout) then begin + FadeTo(@ScreenMain); + Fadeout := true; + end; + + inherited Draw; +end; + +end. diff --git a/Game/Code/UltraStar.dpr b/Game/Code/UltraStar.dpr new file mode 100644 index 00000000..af56d4b0 --- /dev/null +++ b/Game/Code/UltraStar.dpr @@ -0,0 +1,364 @@ +program UltraStar; + +{$DEFINE TRANSLATE} + +{$R 'UltraStar.res' 'UltraStar.rc'} + +uses +//------------------------------ + //Includes - 3rd Party Libraries + //------------------------------ + SDL in 'lib\JEDI-SDLv1.0\SDL\Pas\SDL.pas', + moduleloader in 'lib\JEDI-SDLv1.0\SDL\Pas\moduleloader.pas', + sdlutils in 'lib\JEDI-SDLv1.0\SDL\Pas\sdlutils.pas', + sdl_image in 'lib\JEDI-SDLv1.0\SDL_Image\Pas\sdl_image.pas', + OpenGL12 in 'lib\JEDI-SDLv1.0\OpenGL\Pas\OpenGL12.pas', + sdl_ttf in 'lib\JEDI-SDLv1.0\SDL_ttf\Pas\sdl_ttf.pas', + smpeg in 'lib\JEDI-SDLv1.0\smpeg\Pas\smpeg.pas', + + + bass in 'lib\bass\delphi\bass.pas', + + PNGImage in 'lib\PNGImage\PNGImage.pas', + PNGzLib in 'lib\PNGImage\PNGzLib.pas', + pnglang in 'lib\PNGImage\pnglang.pas', + + midiout in 'lib\midi\midiout.pas', + midiin in 'lib\midi\midiin.pas', + Circbuf in 'lib\midi\CIRCBUF.PAS', + MidiType in 'lib\midi\MidiType.PAS', + MidiDefs in 'lib\midi\MidiDefs.PAS', + MidiCons in 'lib\midi\MidiCons.PAS', + MidiFile in 'lib\midi\MidiFile.PAS', + Delphmcb in 'lib\midi\Delphmcb.PAS', + + zlportio in 'lib\zlportio\zlportio.pas', + ddkint in 'lib\zlportio\ddkint.pas', + + SQLiteTable3 in 'lib\SQLite\SQLiteTable3.pas', + SQLite3 in 'lib\SQLite\SQLite3.pas', + + + //------------------------------ + //Includes - Menu System + //------------------------------ + UDisplay in 'Menu\UDisplay.pas', + UMenu in 'Menu\UMenu.pas', + UMenuStatic in 'Menu\UMenuStatic.pas', + UMenuText in 'Menu\UMenuText.pas', + UMenuButton in 'Menu\UMenuButton.pas', + UMenuInteract in 'Menu\UMenuInteract.pas', + UMenuSelect in 'Menu\UMenuSelect.pas', + UMenuSelectSlide in 'Menu\UMenuSelectSlide.pas', + UDrawTexture in 'Menu\UDrawTexture.pas', + UMenuButtonCollection in 'Menu\UMenuButtonCollection.pas', + + //------------------------------ + //Includes - Classes + //------------------------------ + UGraphic in 'Classes\UGraphic.pas', + UTexture in 'Classes\UTexture.pas', + UMusic in 'Classes\UMusic.pas', + ULanguage in 'Classes\ULanguage.pas', + UMain in 'Classes\UMain.pas', + UDraw in 'Classes\UDraw.pas', + URecord in 'Classes\URecord.pas', + UTime in 'Classes\UTime.pas', + TextGL in 'Classes\TextGL.pas', + USongs in 'Classes\USongs.pas', + UIni in 'Classes\UIni.pas', + USmpeg in 'SMpeg\USmpeg.pas', + ULyrics in 'Classes\ULyrics.pas', + USkins in 'Classes\USkins.pas', + UThemes in 'Classes\UThemes.pas', + ULog in 'Classes\ULog.pas', + UJoystick in 'Classes\UJoystick.pas', + ULCD in 'Classes\ULCD.pas', + ULight in 'Classes\ULight.pas', + UDataBase in 'Classes\UDataBase.pas', + UCovers in 'Classes\UCovers.pas', + UCatCovers in 'Classes\UCatCovers.pas', + UFiles in 'Classes\UFiles.pas', + UGraphicClasses in 'Classes\UGraphicClasses.pas', + UDLLManager in 'Classes\UDLLManager.pas', + UParty in 'Classes\UParty.pas', + UPlaylist in 'Classes\UPlaylist.pas', + UCommandLine in 'Classes\UCommandLine.pas', + + //------------------------------ + //Includes - Screens + //------------------------------ + UScreenLoading in 'Screens\UScreenLoading.pas', + UScreenWelcome in 'Screens\UScreenWelcome.pas', + UScreenMain in 'Screens\UScreenMain.pas', + UScreenName in 'Screens\UScreenName.pas', + UScreenLevel in 'Screens\UScreenLevel.pas', + UScreenSong in 'Screens\UScreenSong.pas', + UScreenSing in 'Screens\UScreenSing.pas', + UScreenScore in 'Screens\UScreenScore.pas', + UScreenOptions in 'Screens\UScreenOptions.pas', + UScreenOptionsGame in 'Screens\UScreenOptionsGame.pas', + UScreenOptionsGraphics in 'Screens\UScreenOptionsGraphics.pas', + UScreenOptionsSound in 'Screens\UScreenOptionsSound.pas', + UScreenOptionsLyrics in 'Screens\UScreenOptionsLyrics.pas', + UScreenOptionsThemes in 'Screens\UScreenOptionsThemes.pas', + UScreenOptionsRecord in 'Screens\UScreenOptionsRecord.pas', + UScreenOptionsAdvanced in 'Screens\UScreenOptionsAdvanced.pas', + UScreenEditSub in 'Screens\UScreenEditSub.pas', + UScreenEdit in 'Screens\UScreenEdit.pas', + UScreenEditConvert in 'Screens\UScreenEditConvert.pas', + UScreenEditHeader in 'Screens\UScreenEditHeader.pas', + UScreenOpen in 'Screens\UScreenOpen.pas', + UScreenTop5 in 'Screens\UScreenTop5.pas', + UScreenSongMenu in 'Screens\UScreenSongMenu.pas', + UScreenSongJumpto in 'Screens\UScreenSongJumpto.pas', + UScreenStatMain in 'Screens\UScreenStatMain.pas', + UScreenStatDetail in 'Screens\UScreenStatDetail.pas', + UScreenCredits in 'Screens\UScreenCredits.pas', + UScreenPopup in 'Screens\UScreenPopup.pas', + + //------------------------------ + //Includes - Screens PartyMode + //------------------------------ + UScreenSingModi in 'Screens\UScreenSingModi.pas', + UScreenPartyNewRound in 'Screens\UScreenPartyNewRound.pas', + UScreenPartyScore in 'Screens\UScreenPartyScore.pas', + UScreenPartyPlayer in 'Screens\UScreenPartyPlayer.pas', + UScreenPartyOptions in 'Screens\UScreenPartyOptions.pas', + UScreenPartyWin in 'Screens\UScreenPartyWin.pas', + + //------------------------------ + //Includes - Modi SDK + //------------------------------ + ModiSDK in '..\..\Modis\SDK\ModiSDK.pas', + + //------------------------------ + //Includes - Delphi + //------------------------------ + Windows, + SysUtils; + +const + Version = 'UltraStar Deluxe V 1.01'; + +var + WndTitle: string; + hWnd: THandle; + I: Integer; + +begin + WndTitle := Version; + + //------------------------------ + //Start more than One Time Prevention + //------------------------------ + hWnd:= FindWindow(nil, PChar(WndTitle)); + //Programm already started + if (hWnd <> 0) then + begin + I := Messagebox(0, PChar('Another Instance of Ultrastar is already running. Contėnue ?'), PChar(WndTitle), MB_ICONWARNING or MB_YESNO); + if (I = IDYes) then + begin + I := 1; + repeat + Inc(I); + hWnd := FindWindow(nil, PChar(WndTitle + ' Instance ' + InttoStr(I))); + until (hWnd = 0); + + WndTitle := WndTitle + ' Instance ' + InttoStr(I); + end + else + Exit; + end; + + //------------------------------ + //StartUp - Create Classes and Load Files + //------------------------------ + USTime := TTime.Create; + + // Commandline Parameter Parser + Params := TCMDParams.Create; + + // Log + Benchmark + Log := TLog.Create; + Log.Title := WndTitle; + Log.Enabled := Not Params.NoLog; + Log.BenchmarkStart(0); + + // Language + Log.BenchmarkStart(1); + Log.LogStatus('Initialize Paths', 'Initialization'); InitializePaths; + Log.LogStatus('Load Language', 'Initialization'); Language := TLanguage.Create; + //Add Const Values: + Language.AddConst('US_VERSION', Version); + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading Language', 1); + + // SDL + Log.BenchmarkStart(1); + Log.LogStatus('Initialize SDL', 'Initialization'); + SDL_Init(SDL_INIT_VIDEO or SDL_INIT_AUDIO); + Log.BenchmarkEnd(1); + Log.LogBenchmark('Initializing SDL', 1); + + // Skin + Log.BenchmarkStart(1); + Log.LogStatus('Loading Skin List', 'Initialization'); Skin := TSkin.Create; + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading Skin List', 1); + + // Sound Card List + Log.BenchmarkStart(1); + Log.LogStatus('Loading Soundcard list', 'Initialization'); + Recording := TRecord.Create; + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading Soundcard list', 1); + + // Ini + Paths + Log.BenchmarkStart(1); + Log.LogStatus('Load Ini', 'Initialization'); Ini := TIni.Create; + Ini.Load; + + //Load Languagefile + if (Params.Language <> -1) then + Language.ChangeLanguage(ILanguage[Params.Language]) + else + Language.ChangeLanguage(ILanguage[Ini.Language]); + + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading Ini', 1); + + // LCD + Log.BenchmarkStart(1); + Log.LogStatus('Load LCD', 'Initialization'); LCD := TLCD.Create; + if Ini.LPT = 1 then begin +// LCD.HalfInterface := true; + LCD.Enable; + LCD.Clear; + LCD.WriteText(1, ' UltraStar '); + LCD.WriteText(2, ' Loading... '); + end; + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading LCD', 1); + + // Light + Log.BenchmarkStart(1); + Log.LogStatus('Load Light', 'Initialization'); Light := TLight.Create; + if Ini.LPT = 2 then begin + Light.Enable; + end; + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading Light', 1); + + // Theme + Log.BenchmarkStart(1); + Log.LogStatus('Load Themes', 'Initialization'); Theme := TTheme.Create('Themes\' + ITheme[Ini.Theme] + '.ini', Ini.Color); + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading Themes', 1); + + // Covers Cache + Log.BenchmarkStart(1); + Log.LogStatus('Creating Covers Cache', 'Initialization'); Covers := TCovers.Create; + Log.LogBenchmark('Loading Covers Cache Array', 1); + Log.BenchmarkStart(1); + + // Category Covers + Log.BenchmarkStart(1); + Log.LogStatus('Creating Category Covers Array', 'Initialization'); + CatCovers:= TCatCovers.Create; + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading Category Covers Array', 1); + + // Songs + //Log.BenchmarkStart(1); + Log.LogStatus('Creating Song Array', 'Initialization'); Songs := TSongs.Create; + Songs.LoadSongList; + Log.LogStatus('Creating 2nd Song Array', 'Initialization'); CatSongs := TCatSongs.Create; + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading Songs', 1); + + // PluginManager + Log.BenchmarkStart(1); + Log.LogStatus('PluginManager', 'Initialization'); + DLLMan := TDLLMan.Create; //Load PluginList + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading PluginManager', 1); + + // Party Mode Manager + Log.BenchmarkStart(1); + Log.LogStatus('PartySession Manager', 'Initialization'); + PartySession := TParty_Session.Create; //Load PartySession + + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading PartySession Manager', 1); + + // Graphics + Log.BenchmarkStart(1); + Log.LogStatus('Initialize 3D', 'Initialization'); Initialize3D(WndTitle); + Log.BenchmarkEnd(1); + Log.LogBenchmark('Initializing 3D', 1); + + // Sound + Log.BenchmarkStart(1); + Log.LogStatus('Initialize Sound', 'Initialization'); + Log.LogStatus('Creating Music', 'InitializeSound'); Music := TMusic.Create; + InitializeSound; + Log.BenchmarkEnd(1); + Log.LogBenchmark('Initializing Sound', 1); + + // Score Saving System + Log.BenchmarkStart(1); + Log.LogStatus('DataBase System', 'Initialization'); + DataBase := TDataBaseSystem.Create; + + if (Params.ScoreFile = '') then + DataBase.Init ('Ultrastar.db') + else + DataBase.Init (Params.ScoreFile); + + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading DataBase System', 1); + + //Playlist Manager + Log.BenchmarkStart(1); + Log.LogStatus('Playlist Manager', 'Initialization'); + PlaylistMan := TPlaylistManager.Create; + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading Playlist Manager', 1); + + //GoldenStarsTwinkleMod + Log.BenchmarkStart(1); + Log.LogStatus('Effect Manager', 'Initialization'); + GoldenRec := TEffectManager.Create; + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading Particel System', 1); + + // Joypad + if (Ini.Joypad = 1) OR (Params.Joypad) then begin + Log.BenchmarkStart(1); + Log.LogStatus('Initialize Joystick', 'Initialization'); Joy := TJoy.Create; + Log.BenchmarkEnd(1); + Log.LogBenchmark('Initializing Joystick', 1); + end; + + Log.BenchmarkEnd(0); + Log.LogBenchmark('Loading Time', 0); + + + //------------------------------ + //Start- Mainloop + //------------------------------ + //Music.SetLoop(true); + //Music.SetVolume(50); + //Music.Open(SkinPath + 'Menu Music 3.mp3'); + //Music.Play; + Log.LogStatus('Main Loop', 'Initialization'); MainLoop; + + //------------------------------ + //Finish Application + //------------------------------ + if Ini.LPT = 1 then LCD.Clear; + if Ini.LPT = 2 then Light.TurnOff; + + Log.Free; +end. diff --git a/Game/Code/UltraStar.rc b/Game/Code/UltraStar.rc new file mode 100644 index 00000000..cf954deb --- /dev/null +++ b/Game/Code/UltraStar.rc @@ -0,0 +1,38 @@ +Font PNG "..\Fonts\Normal\eurostar_regular.png" +Font FNT "..\Fonts\Normal\eurostar_regular.dat" + +FontB PNG "..\Fonts\Bold\eurostar_regular_bold.png" +FontB FNT "..\Fonts\Bold\eurostar_regular_bold.dat" + +FontO PNG "..\Fonts\Outline 1\Outline 1.PNG" +FontO FNT "..\Fonts\Outline 1\Outline 1.dat" + +FontO2 PNG "..\Fonts\Outline 2\Outline 2.PNG" +FontO2 FNT "..\Fonts\Outline 2\Outline 2.dat" + +MAINICON ICON "..\Graphics\ustar-icon_v01.ico" +//MAINICON ICON "..\Graphics\us.ico" + +CRDTS_BG PNG "..\Graphics\credits_v5_bg.png" +CRDTS_OVL PNG "..\Graphics\credits_v5_overlay.png" +CRDTS_blindguard PNG "..\Graphics\names_blindguard.png" +CRDTS_blindy PNG "..\Graphics\names_blindy.png" +CRDTS_canni PNG "..\Graphics\names_canni.png" +CRDTS_commandio PNG "..\Graphics\names_commandio.png" +CRDTS_lazyjoker PNG "..\Graphics\names_lazyjoker.png" +CRDTS_mog PNG "..\Graphics\names_mog.png" +CRDTS_mota PNG "..\Graphics\names_mota.png" +CRDTS_skillmaster PNG "..\Graphics\names_skillmaster.png" +CRDTS_whiteshark PNG "..\Graphics\names_whiteshark.png" +INTRO_L01 PNG "..\Graphics\intro-l-01.png" +INTRO_L02 PNG "..\Graphics\intro-l-02.png" +INTRO_L03 PNG "..\Graphics\intro-l-03.png" +INTRO_L04 PNG "..\Graphics\intro-l-04.png" +INTRO_L05 PNG "..\Graphics\intro-l-05.png" +INTRO_L06 PNG "..\Graphics\intro-l-06.png" +INTRO_L07 PNG "..\Graphics\intro-l-07.png" +INTRO_L08 PNG "..\Graphics\intro-l-08.png" +INTRO_L09 PNG "..\Graphics\intro-l-09.png" +OUTRO_BG PNG "..\Graphics\outro-bg.png" +OUTRO_ESC PNG "..\Graphics\outro-esc.png" +OUTRO_EXD PNG "..\Graphics\outro-exit-dark.png" \ No newline at end of file diff --git a/Game/Code/bamboo-build-win-delphi.bat b/Game/Code/bamboo-build-win-delphi.bat new file mode 100644 index 00000000..bcd13cfe --- /dev/null +++ b/Game/Code/bamboo-build-win-delphi.bat @@ -0,0 +1,20 @@ +del UltraStar.res +"C:\Program Files\Borland\BDS\4.0\Bin\BRC32 -r UltraStar.RC + +"C:\Program Files\Borland\BDS\4.0\Bin\dcc32.exe" -U"lib\JEDI-SDLv1.0\SDL\Pas" -O"lib\JEDI-SDLv1.0\SDL\Pas" -I"lib\JEDI-SDLv1.0\SDL\Pas" -R"lib\JEDI-SDLv1.0\SDL\Pas" UltraStar.dpr +copy UltraStar.exe ..\..\ +cd ..\..\ + + +cd ScoreConverter +"C:\Program Files\Borland\BDS\4.0\Bin\dcc32.exe" -U"..\Game\Code\Lib\SQLite" -O"..\Game\Code\Lib\SQLite" -I"..\Game\Code\Lib\SQLite" -R"..\Game\Code\Lib\SQLite" ScoreConverter.dpr +copy ScoreConverter.exe ..\ + +cd ..\ + +upx --force -9 *.exe + +cd Installer +"C:\Program Files\NSIS\makeNSIS.exe" UltraStarDeluxe.nsi + +cd ..\Game\Code \ No newline at end of file diff --git a/Game/Code/rccompillieren.bat b/Game/Code/rccompillieren.bat new file mode 100644 index 00000000..4e2f2584 --- /dev/null +++ b/Game/Code/rccompillieren.bat @@ -0,0 +1 @@ +BRC32 -r UltraStar.RC \ No newline at end of file -- cgit v1.2.3