From 3c41f973b397b718135a7713c7501607812b0192 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 20 Sep 2007 09:42:35 +0000 Subject: renamed Ulyrics.bak.pas hack to Ulyrics_bak.pas for lazarus compatiblity. minor changes to get code base compiling in Lazarus(win) and Delphi git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@415 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCommon.pas | 268 +++---- Game/Code/Classes/ULyrics.bak.pas | 418 ---------- Game/Code/Classes/ULyrics.pas | 7 + Game/Code/Classes/ULyrics_bak.pas | 428 +++++++++++ Game/Code/Screens/UScreenEditSub.pas | 6 +- Game/Code/UltraStar.dpr | 2 +- Game/Code/UltraStar.lpi | 1397 ++++++++++++++++------------------ Game/Code/UltraStar.lpr | 825 ++++++++++---------- 8 files changed, 1657 insertions(+), 1694 deletions(-) delete mode 100644 Game/Code/Classes/ULyrics.bak.pas create mode 100644 Game/Code/Classes/ULyrics_bak.pas (limited to 'Game/Code') diff --git a/Game/Code/Classes/UCommon.pas b/Game/Code/Classes/UCommon.pas index b7ddd7ba..b572a768 100644 --- a/Game/Code/Classes/UCommon.pas +++ b/Game/Code/Classes/UCommon.pas @@ -1,132 +1,136 @@ -unit UCommon; - -interface - -{$IFDEF FPC} - {$MODE Delphi} -{$ENDIF} - -uses - -{$IFDEF win32} - windows; -{$ELSE} - lcltype, - messages; -{$ENDIF} - -{$IFNDEF win32} -type - hStream = THandle; - HGLRC = THandle; - TLargeInteger = Int64; - TWin32FindData = LongInt; -{$ENDIF} - -{$IFDEF FPC} - -type - TWndMethod = procedure(var Message: TMessage) of object; - -function RandomRange(aMin: Integer; aMax: Integer) : Integer; -//function AllocateHWnd(Method: TWndMethod): HWND; -//procedure DeallocateHWnd(Wnd: HWND); - -function MaxValue(const Data: array of Double): Double; -function MinValue(const Data: array of Double): Double; -{$ENDIF} - -{$IFNDEF win32} -(* - function QueryPerformanceCounter(lpPerformanceCount:TLARGEINTEGER):Bool; - function QueryPerformanceFrequency(lpFrequency:TLARGEINTEGER):Bool; -*) - procedure ZeroMemory( Destination: Pointer; Length: DWORD ); -{$ENDIF} - -implementation - -{$IFNDEF win32} -procedure ZeroMemory( Destination: Pointer; Length: DWORD ); -begin - FillChar( Destination^, Length, 0 ); -end; //ZeroMemory - -(* -function QueryPerformanceCounter(lpPerformanceCount:TLARGEINTEGER):Bool; - - // From http://en.wikipedia.org/wiki/RDTSC - function RDTSC: Int64; register; - asm - rdtsc - end; - -begin - // Use clock_gettime here maybe ... from libc - lpPerformanceCount := RDTSC(); - result := true; -end; - -function QueryPerformanceFrequency(lpFrequency:TLARGEINTEGER):Bool; -begin - lpFrequency := 0; - result := true; -end; -*) -{$ENDIF} - - -{$IFDEF FPC} - -function MaxValue(const Data: array of Double): Double; -var - I: Integer; -begin - Result := Data[Low(Data)]; - for I := Low(Data) + 1 to High(Data) do - if Result < Data[I] then - Result := Data[I]; -end; - -function MinValue(const Data: array of Double): Double; -var - I: Integer; -begin - Result := Data[Low(Data)]; - for I := Low(Data) + 1 to High(Data) do - if Result > Data[I] then - Result := Data[I]; -end; - -function RandomRange(aMin: Integer; aMax: Integer) : Integer; -begin -RandomRange := Random(aMax-aMin) + aMin ; -end; - - -// NOTE !!!!!!!!!! -// AllocateHWnd is in lclintfh.inc - -{ -// TODO : JB this is dodgey and bad... find a REAL solution ! -function AllocateHWnd(Method: TWndMethod): HWND; -var - TempClass: TWndClass; - ClassRegistered: Boolean; -begin - Result := CreateWindowEx(WS_EX_TOOLWINDOW, '', '', WS_POPUP , 0, 0, 0, 0, 0, 0, HInstance, nil); -end; - -procedure DeallocateHWnd(Wnd: HWND); -var - Instance: Pointer; -begin - Instance := Pointer(GetWindowLong(Wnd, GWL_WNDPROC)); - DestroyWindow(Wnd); -end; -} - -{$ENDIF} - - -end. +unit UCommon; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +uses + +{$IFDEF win32} + windows; +{$ELSE} + lcltype, + messages; +{$ENDIF} + +{$IFNDEF win32} +type + hStream = THandle; + HGLRC = THandle; + TLargeInteger = Int64; + TWin32FindData = LongInt; +{$ENDIF} + +{$IFDEF FPC} + +type + TWndMethod = procedure(var Message: TMessage) of object; + +function RandomRange(aMin: Integer; aMax: Integer) : Integer; + +function MaxValue(const Data: array of Double): Double; +function MinValue(const Data: array of Double): Double; + +{$IFDEF Win32} +function AllocateHWnd(Method: TWndMethod): HWND; +procedure DeallocateHWnd(Wnd: HWND); +{$ENDIF} + +{$ENDIF} + +{$IFNDEF win32} +(* + function QueryPerformanceCounter(lpPerformanceCount:TLARGEINTEGER):Bool; + function QueryPerformanceFrequency(lpFrequency:TLARGEINTEGER):Bool; +*) + procedure ZeroMemory( Destination: Pointer; Length: DWORD ); +{$ENDIF} + +implementation + +{$IFNDEF win32} +procedure ZeroMemory( Destination: Pointer; Length: DWORD ); +begin + FillChar( Destination^, Length, 0 ); +end; //ZeroMemory + +(* +function QueryPerformanceCounter(lpPerformanceCount:TLARGEINTEGER):Bool; + + // From http://en.wikipedia.org/wiki/RDTSC + function RDTSC: Int64; register; + asm + rdtsc + end; + +begin + // Use clock_gettime here maybe ... from libc + lpPerformanceCount := RDTSC(); + result := true; +end; + +function QueryPerformanceFrequency(lpFrequency:TLARGEINTEGER):Bool; +begin + lpFrequency := 0; + result := true; +end; +*) +{$ENDIF} + + +{$IFDEF FPC} + +function MaxValue(const Data: array of Double): Double; +var + I: Integer; +begin + Result := Data[Low(Data)]; + for I := Low(Data) + 1 to High(Data) do + if Result < Data[I] then + Result := Data[I]; +end; + +function MinValue(const Data: array of Double): Double; +var + I: Integer; +begin + Result := Data[Low(Data)]; + for I := Low(Data) + 1 to High(Data) do + if Result > Data[I] then + Result := Data[I]; +end; + +function RandomRange(aMin: Integer; aMax: Integer) : Integer; +begin +RandomRange := Random(aMax-aMin) + aMin ; +end; + + +// NOTE !!!!!!!!!! +// AllocateHWnd is in lclintfh.inc + +{$IFDEF Win32} +// TODO : JB this is dodgey and bad... find a REAL solution ! +function AllocateHWnd(Method: TWndMethod): HWND; +var + TempClass: TWndClass; + ClassRegistered: Boolean; +begin + Result := CreateWindowEx(WS_EX_TOOLWINDOW, '', '', WS_POPUP , 0, 0, 0, 0, 0, 0, HInstance, nil); +end; + +procedure DeallocateHWnd(Wnd: HWND); +var + Instance: Pointer; +begin + Instance := Pointer(GetWindowLong(Wnd, GWL_WNDPROC)); + DestroyWindow(Wnd); +end; +{$ENDIF} + +{$ENDIF} + + +end. diff --git a/Game/Code/Classes/ULyrics.bak.pas b/Game/Code/Classes/ULyrics.bak.pas deleted file mode 100644 index e432f7e5..00000000 --- a/Game/Code/Classes/ULyrics.bak.pas +++ /dev/null @@ -1,418 +0,0 @@ -unit ULyrics.bak; - -interface -uses SysUtils, OpenGL12, UMusic, UTexture; - -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; - - //Textures for PlayerIcon Index: Playernum; Index2: Enabled/Disabled - PlayerIconTex: array[0..5] of array [0..1] of TTexture; - - 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); - - procedure DrawPlayerIcons; - public - //Array containing Players Singing the Next Sentence - // 1: Player 1 Active - // 2: Player 2 Active - // 3: Player 3 Active - PlayersActive: Byte; - - //Dark or Light Colors - Enabled: Boolean; - - ColR: real; - ColG: real; - ColB: real; - ColSR: real; - ColSG: real; - ColSB: real; - Italic: boolean; - Text: string; // LCD - - constructor Create; - 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); - - function SelectedLetter: integer; // LCD - function SelectedLength: integer; // LCD - - procedure Clear; - procedure Draw; - - end; - -var - Lyric: TLyric; - -implementation -uses TextGL, UGraphic, UDrawTexture, Math, USkins; - -Constructor TLyric.Create; -var - I: Integer; -begin - //Only 2 Players for now - For I := 0 to 1 do - begin - PlayerIconTex[I][0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricIcon_P' + InttoStr(I+1))), 'PNG', 'Transparent', 0); - PlayerIconTex[I][1] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricIconD_P' + InttoStr(I+1))), 'PNG', 'Transparent', 0); - end; - PlayersActive := Trunc(Power(2, 1)) + 1; -end; - -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.DrawPlayerIcons; -begin - -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; - -end. diff --git a/Game/Code/Classes/ULyrics.pas b/Game/Code/Classes/ULyrics.pas index 5cf6114d..1c2795ce 100644 --- a/Game/Code/Classes/ULyrics.pas +++ b/Game/Code/Classes/ULyrics.pas @@ -1,6 +1,13 @@ unit ULyrics; interface + +{$IFDEF FPC} + {$MODE DELPHI} +{$ENDIF} + +{$I switches.inc} + uses OpenGL12, UTexture, UThemes, UMusic; type diff --git a/Game/Code/Classes/ULyrics_bak.pas b/Game/Code/Classes/ULyrics_bak.pas new file mode 100644 index 00000000..43fa46f5 --- /dev/null +++ b/Game/Code/Classes/ULyrics_bak.pas @@ -0,0 +1,428 @@ +unit ULyrics_bak; + +interface + +{$IFDEF FPC} + {$MODE DELPHI} +{$ENDIF} + +{$I switches.inc} + +uses SysUtils, + OpenGL12, + UMusic, + UTexture; + +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; + + //Textures for PlayerIcon Index: Playernum; Index2: Enabled/Disabled + PlayerIconTex: array[0..5] of array [0..1] of TTexture; + + 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); + + procedure DrawPlayerIcons; + public + //Array containing Players Singing the Next Sentence + // 1: Player 1 Active + // 2: Player 2 Active + // 3: Player 3 Active + PlayersActive: Byte; + + //Dark or Light Colors + Enabled: Boolean; + + ColR: real; + ColG: real; + ColB: real; + ColSR: real; + ColSG: real; + ColSB: real; + Italic: boolean; + Text: string; // LCD + + constructor Create; + + procedure AddWord(Text: string); + procedure AddCzesc(NrCzesci: integer); + + function SelectedLetter: integer; // LCD + function SelectedLength: integer; // LCD + + procedure Clear; + procedure Draw; + 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; + end; + +var + Lyric: TLyric; + +implementation +uses TextGL, UGraphic, UDrawTexture, Math, USkins; + +Constructor TLyric.Create; +var + I: Integer; +begin + //Only 2 Players for now + For I := 0 to 1 do + begin + PlayerIconTex[I][0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricIcon_P' + InttoStr(I+1))), 'PNG', 'Transparent', 0); + PlayerIconTex[I][1] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricIconD_P' + InttoStr(I+1))), 'PNG', 'Transparent', 0); + end; + PlayersActive := Trunc(Power(2, 1)) + 1; +end; + +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.DrawPlayerIcons; +begin + +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; + +end. diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 93a4892a..e896d603 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -2,6 +2,10 @@ unit UScreenEditSub; interface +{$IFDEF FPC} + {$MODE DELPHI} +{$ENDIF} + {$I switches.inc} uses @@ -16,7 +20,7 @@ uses ULog, UTexture, UMenuText, - ULyrics.bak, + ULyrics_bak, Math, OpenGL12, {$IFDEF UseMIDIPort} diff --git a/Game/Code/UltraStar.dpr b/Game/Code/UltraStar.dpr index 42301946..7cbc2e55 100644 --- a/Game/Code/UltraStar.dpr +++ b/Game/Code/UltraStar.dpr @@ -73,7 +73,7 @@ uses USongs in 'Classes\USongs.pas', UIni in 'Classes\UIni.pas', ULyrics in 'Classes\ULyrics.pas', - ULyrics.bak in 'Classes\ULyrics.bak.pas', + ULyrics_bak in 'Classes\ULyrics_bak.pas', USkins in 'Classes\USkins.pas', UThemes in 'Classes\UThemes.pas', ULog in 'Classes\ULog.pas', diff --git a/Game/Code/UltraStar.lpi b/Game/Code/UltraStar.lpi index a3ff59ad..1b925455 100644 --- a/Game/Code/UltraStar.lpi +++ b/Game/Code/UltraStar.lpi @@ -1,730 +1,667 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Game/Code/UltraStar.lpr b/Game/Code/UltraStar.lpr index bb3b50b3..9793928e 100644 --- a/Game/Code/UltraStar.lpr +++ b/Game/Code/UltraStar.lpr @@ -1,412 +1,413 @@ -program UltraStar; - -{$DEFINE TRANSLATE} - -{$IFDEF FPC} - {$MODE DELPHI} -{$ELSE} - {$R 'UltraStar.res' 'UltraStar.rc'} -{$ENDIF} - -{$I switches.inc} - -uses - - // *************************************************************************** - // - // Developers PLEASE NOTE !!!!!!! - // - // As of september 2007, I am working towards porting Ultrastar-DX to run - // on Linux. I will be modifiying the source to make it compile in lazarus - // on windows & linux and I will make sure that it compiles in delphi still - // To help me in this endevour, please can you make a point of remembering - // that linux is CASE SENSATIVE, and file / unit names must be as per - // the filename exactly. - // - // EG : opengl12.pas must not be OpenGL in the uses cluase. - // - // thanks for your help... - // - // *************************************************************************** - - //------------------------------ - //Includes - 3rd Party Libraries - //------------------------------ - - // SDL / OpenGL - moduleloader in 'lib\JEDI-SDLv1.0\SDL\Pas\moduleloader.pas', - opengl12 in 'lib\JEDI-SDLv1.0\OpenGL\Pas\opengl12.pas', - sdl in 'lib\JEDI-SDLv1.0\SDL\Pas\sdl.pas', - - // Bass - {$IFDEF UseBASS} - bass in 'lib\bass\delphi\bass.pas', - {$ENDIF} - - // Midi Units - {$IFDEF UseMIDIPort} - Circbuf in 'lib\midi\CIRCBUF.PAS', - Delphmcb in 'lib\midi\Delphmcb.PAS', - MidiCons in 'lib\midi\MidiCons.PAS', - MidiDefs in 'lib\midi\MidiDefs.PAS', - MidiFile in 'lib\midi\MidiFile.PAS', - midiin in 'lib\midi\midiin.pas', - midiout in 'lib\midi\midiout.pas', - MidiType in 'lib\midi\MidiType.PAS', - {$ENDIF} - - // FFMpeg units - avcodec in 'lib\ffmpeg\avcodec.pas', - avformat in 'lib\ffmpeg\avformat.pas', - avio in 'lib\ffmpeg\avio.pas', - avutil in 'lib\ffmpeg\avutil.pas', - opt in 'lib\ffmpeg\opt.pas', - rational in 'lib\ffmpeg\rational.pas', - - - // Sql Lite - SQLiteTable3 in 'lib\SQLite\SQLiteTable3.pas', - SQLite3 in 'lib\SQLite\SQLite3.pas', - - - //------------------------------ - //Includes - Menu System - //------------------------------ - - UDisplay in 'Menu\UDisplay.pas', - UDrawTexture in 'Menu\UDrawTexture.pas', - UMenu in 'Menu\UMenu.pas', - UMenuButton in 'Menu\UMenuButton.pas', - UMenuButtonCollection in 'Menu\UMenuButtonCollection.pas', - UMenuInteract in 'Menu\UMenuInteract.pas', - UMenuSelect in 'Menu\UMenuSelect.pas', - UMenuSelectSlide in 'Menu\UMenuSelectSlide.pas', - UMenuStatic in 'Menu\UMenuStatic.pas', - UMenuText in 'Menu\UMenuText.pas', - - //------------------------------ - //Includes - Classes - //------------------------------ - - {$IFDEF FPC} - ulazjpeg in 'Classes\ulazjpeg.pas', - {$ENDIF} - - TextGL in 'Classes\TextGL.pas', - UCatCovers in 'Classes\UCatCovers.pas', - UCommandLine in 'Classes\UCommandLine.pas', - UCommon in 'Classes\UCommon.pas', - UCovers in 'Classes\UCovers.pas', - UDataBase in 'Classes\UDataBase.pas', - UDLLManager in 'Classes\UDLLManager.pas', - UDraw in 'Classes\UDraw.pas', - UFiles in 'Classes\UFiles.pas', - UGraphic in 'Classes\UGraphic.pas', - UGraphicClasses in 'Classes\UGraphicClasses.pas', - UIni in 'Classes\UIni.pas', - UJoystick in 'Classes\UJoystick.pas', - ULanguage in 'Classes\ULanguage.pas', - ULCD in 'Classes\ULCD.pas', - ULight in 'Classes\ULight.pas', - ULog in 'Classes\ULog.pas', - ULyrics in 'Classes\ULyrics.pas', - UMain in 'Classes\UMain.pas', - UMusic in 'Classes\UMusic.pas', - UParty in 'Classes\UParty.pas', - UPlaylist in 'Classes\UPlaylist.pas', - URecord in 'Classes\URecord.pas', - USkins in 'Classes\USkins.pas', - USongs in 'Classes\USongs.pas', - UTexture in 'Classes\UTexture.pas', - UThemes in 'Classes\UThemes.pas', - UTime in 'Classes\UTime.pas', - - - //------------------------------ - //Includes - Video Support - //------------------------------ - UVideo in 'Classes\UVideo.pas', - - - //------------------------------ - //Includes - Screens - //------------------------------ - UScreenCredits in 'Screens\UScreenCredits.pas', - UScreenEdit in 'Screens\UScreenEdit.pas', - UScreenEditConvert in 'Screens\UScreenEditConvert.pas', - UScreenEditHeader in 'Screens\UScreenEditHeader.pas', - UScreenEditSub in 'Screens\UScreenEditSub.pas', - UScreenLevel in 'Screens\UScreenLevel.pas', - UScreenLoading in 'Screens\UScreenLoading.pas', - UScreenMain in 'Screens\UScreenMain.pas', - UScreenName in 'Screens\UScreenName.pas', - UScreenOpen in 'Screens\UScreenOpen.pas', - UScreenOptions in 'Screens\UScreenOptions.pas', - UScreenOptionsAdvanced in 'Screens\UScreenOptionsAdvanced.pas', - UScreenOptionsGame in 'Screens\UScreenOptionsGame.pas', - UScreenOptionsGraphics in 'Screens\UScreenOptionsGraphics.pas', - UScreenOptionsLyrics in 'Screens\UScreenOptionsLyrics.pas', - UScreenOptionsRecord in 'Screens\UScreenOptionsRecord.pas', - UScreenOptionsSound in 'Screens\UScreenOptionsSound.pas', - UScreenOptionsThemes in 'Screens\UScreenOptionsThemes.pas', - UScreenPopup in 'Screens\UScreenPopup.pas', - UScreenScore in 'Screens\UScreenScore.pas', - UScreenSing in 'Screens\UScreenSing.pas', - UScreenSong in 'Screens\UScreenSong.pas', - UScreenSongJumpto in 'Screens\UScreenSongJumpto.pas', - UScreenSongMenu in 'Screens\UScreenSongMenu.pas', - UScreenStatDetail in 'Screens\UScreenStatDetail.pas', - UScreenStatMain in 'Screens\UScreenStatMain.pas', - UScreenTop5 in 'Screens\UScreenTop5.pas', - UScreenWelcome in 'Screens\UScreenWelcome.pas', - - //------------------------------ - //Includes - Screens PartyMode - //------------------------------ - UScreenPartyNewRound in 'Screens\UScreenPartyNewRound.pas', - UScreenPartyOptions in 'Screens\UScreenPartyOptions.pas', - UScreenPartyPlayer in 'Screens\UScreenPartyPlayer.pas', - UScreenPartyScore in 'Screens\UScreenPartyScore.pas', - UScreenPartyWin in 'Screens\UScreenPartyWin.pas', - UScreenSingModi in 'Screens\UScreenSingModi.pas', - - //------------------------------ - //Includes - Modi SDK - //------------------------------ - ModiSDK in '..\..\Modis\SDK\ModiSDK.pas', - - - //------------------------------ - //Includes - Delphi - //------------------------------ - {$IFDEF win32} - Windows, - {$ENDIF} - SysUtils; - -const - Version = 'UltraStar Deluxe V 1.10 Alpha Build'; - -var - WndTitle: string; - hWnd: THandle; - I: Integer; - -begin - WndTitle := Version; - - {$ifdef Win32} - //------------------------------ - //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; - {$endif} - - //------------------------------ - //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. +program UltraStar; + +{$DEFINE TRANSLATE} + +{$IFDEF FPC} + {$MODE DELPHI} +{$ELSE} + {$R 'UltraStar.res' 'UltraStar.rc'} +{$ENDIF} + +{$I switches.inc} + +uses + + // *************************************************************************** + // + // Developers PLEASE NOTE !!!!!!! + // + // As of september 2007, I am working towards porting Ultrastar-DX to run + // on Linux. I will be modifiying the source to make it compile in lazarus + // on windows & linux and I will make sure that it compiles in delphi still + // To help me in this endevour, please can you make a point of remembering + // that linux is CASE SENSATIVE, and file / unit names must be as per + // the filename exactly. + // + // EG : opengl12.pas must not be OpenGL in the uses cluase. + // + // thanks for your help... + // + // *************************************************************************** + + //------------------------------ + //Includes - 3rd Party Libraries + //------------------------------ + + // SDL / OpenGL + moduleloader in 'lib\JEDI-SDLv1.0\SDL\Pas\moduleloader.pas', + opengl12 in 'lib\JEDI-SDLv1.0\OpenGL\Pas\opengl12.pas', + sdl in 'lib\JEDI-SDLv1.0\SDL\Pas\sdl.pas', + + // Bass + {$IFDEF UseBASS} + bass in 'lib\bass\delphi\bass.pas', + {$ENDIF} + + // Midi Units + {$IFDEF UseMIDIPort} + Circbuf in 'lib\midi\CIRCBUF.PAS', + Delphmcb in 'lib\midi\Delphmcb.PAS', + MidiCons in 'lib\midi\MidiCons.PAS', + MidiDefs in 'lib\midi\MidiDefs.PAS', + MidiFile in 'lib\midi\MidiFile.PAS', + midiin in 'lib\midi\midiin.pas', + midiout in 'lib\midi\midiout.pas', + MidiType in 'lib\midi\MidiType.PAS', + {$ENDIF} + + // FFMpeg units + avcodec in 'lib\ffmpeg\avcodec.pas', + avformat in 'lib\ffmpeg\avformat.pas', + avio in 'lib\ffmpeg\avio.pas', + avutil in 'lib\ffmpeg\avutil.pas', + opt in 'lib\ffmpeg\opt.pas', + rational in 'lib\ffmpeg\rational.pas', + + + // Sql Lite + SQLiteTable3 in 'lib\SQLite\SQLiteTable3.pas', + SQLite3 in 'lib\SQLite\SQLite3.pas', + + + //------------------------------ + //Includes - Menu System + //------------------------------ + + UDisplay in 'Menu\UDisplay.pas', + UDrawTexture in 'Menu\UDrawTexture.pas', + UMenu in 'Menu\UMenu.pas', + UMenuButton in 'Menu\UMenuButton.pas', + UMenuButtonCollection in 'Menu\UMenuButtonCollection.pas', + UMenuInteract in 'Menu\UMenuInteract.pas', + UMenuSelect in 'Menu\UMenuSelect.pas', + UMenuSelectSlide in 'Menu\UMenuSelectSlide.pas', + UMenuStatic in 'Menu\UMenuStatic.pas', + UMenuText in 'Menu\UMenuText.pas', + + //------------------------------ + //Includes - Classes + //------------------------------ + + {$IFDEF FPC} + ulazjpeg in 'Classes\ulazjpeg.pas', + {$ENDIF} + + TextGL in 'Classes\TextGL.pas', + UCatCovers in 'Classes\UCatCovers.pas', + UCommandLine in 'Classes\UCommandLine.pas', + UCommon in 'Classes\UCommon.pas', + UCovers in 'Classes\UCovers.pas', + UDataBase in 'Classes\UDataBase.pas', + UDLLManager in 'Classes\UDLLManager.pas', + UDraw in 'Classes\UDraw.pas', + UFiles in 'Classes\UFiles.pas', + UGraphic in 'Classes\UGraphic.pas', + UGraphicClasses in 'Classes\UGraphicClasses.pas', + UIni in 'Classes\UIni.pas', + UJoystick in 'Classes\UJoystick.pas', + ULanguage in 'Classes\ULanguage.pas', + ULCD in 'Classes\ULCD.pas', + ULight in 'Classes\ULight.pas', + ULog in 'Classes\ULog.pas', + ULyrics in 'Classes\ULyrics.pas', + ULyrics_bak in 'Classes\ULyrics_bak.pas', + UMain in 'Classes\UMain.pas', + UMusic in 'Classes\UMusic.pas', + UParty in 'Classes\UParty.pas', + UPlaylist in 'Classes\UPlaylist.pas', + URecord in 'Classes\URecord.pas', + USkins in 'Classes\USkins.pas', + USongs in 'Classes\USongs.pas', + UTexture in 'Classes\UTexture.pas', + UThemes in 'Classes\UThemes.pas', + UTime in 'Classes\UTime.pas', + + + //------------------------------ + //Includes - Video Support + //------------------------------ + UVideo in 'Classes\UVideo.pas', + + + //------------------------------ + //Includes - Screens + //------------------------------ + UScreenCredits in 'Screens\UScreenCredits.pas', + UScreenEdit in 'Screens\UScreenEdit.pas', + UScreenEditConvert in 'Screens\UScreenEditConvert.pas', + UScreenEditHeader in 'Screens\UScreenEditHeader.pas', + UScreenEditSub in 'Screens\UScreenEditSub.pas', + UScreenLevel in 'Screens\UScreenLevel.pas', + UScreenLoading in 'Screens\UScreenLoading.pas', + UScreenMain in 'Screens\UScreenMain.pas', + UScreenName in 'Screens\UScreenName.pas', + UScreenOpen in 'Screens\UScreenOpen.pas', + UScreenOptions in 'Screens\UScreenOptions.pas', + UScreenOptionsAdvanced in 'Screens\UScreenOptionsAdvanced.pas', + UScreenOptionsGame in 'Screens\UScreenOptionsGame.pas', + UScreenOptionsGraphics in 'Screens\UScreenOptionsGraphics.pas', + UScreenOptionsLyrics in 'Screens\UScreenOptionsLyrics.pas', + UScreenOptionsRecord in 'Screens\UScreenOptionsRecord.pas', + UScreenOptionsSound in 'Screens\UScreenOptionsSound.pas', + UScreenOptionsThemes in 'Screens\UScreenOptionsThemes.pas', + UScreenPopup in 'Screens\UScreenPopup.pas', + UScreenScore in 'Screens\UScreenScore.pas', + UScreenSing in 'Screens\UScreenSing.pas', + UScreenSong in 'Screens\UScreenSong.pas', + UScreenSongJumpto in 'Screens\UScreenSongJumpto.pas', + UScreenSongMenu in 'Screens\UScreenSongMenu.pas', + UScreenStatDetail in 'Screens\UScreenStatDetail.pas', + UScreenStatMain in 'Screens\UScreenStatMain.pas', + UScreenTop5 in 'Screens\UScreenTop5.pas', + UScreenWelcome in 'Screens\UScreenWelcome.pas', + + //------------------------------ + //Includes - Screens PartyMode + //------------------------------ + UScreenPartyNewRound in 'Screens\UScreenPartyNewRound.pas', + UScreenPartyOptions in 'Screens\UScreenPartyOptions.pas', + UScreenPartyPlayer in 'Screens\UScreenPartyPlayer.pas', + UScreenPartyScore in 'Screens\UScreenPartyScore.pas', + UScreenPartyWin in 'Screens\UScreenPartyWin.pas', + UScreenSingModi in 'Screens\UScreenSingModi.pas', + + //------------------------------ + //Includes - Modi SDK + //------------------------------ + ModiSDK in '..\..\Modis\SDK\ModiSDK.pas', + + + //------------------------------ + //Includes - Delphi + //------------------------------ + {$IFDEF win32} + Windows, + {$ENDIF} + SysUtils; + +const + Version = 'UltraStar Deluxe V 1.10 Alpha Build'; + +var + WndTitle: string; + hWnd: THandle; + I: Integer; + +begin + WndTitle := Version; + + {$ifdef Win32} + //------------------------------ + //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; + {$endif} + + //------------------------------ + //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. -- cgit v1.2.3