diff options
Diffstat (limited to 'unicode/src')
77 files changed, 5784 insertions, 3937 deletions
diff --git a/unicode/src/base/UBeatTimer.pas b/unicode/src/base/UBeatTimer.pas new file mode 100644 index 00000000..a47a06f9 --- /dev/null +++ b/unicode/src/base/UBeatTimer.pas @@ -0,0 +1,170 @@ + {* UltraStar Deluxe - Karaoke Game
+ *
+ * UltraStar Deluxe is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * $URL: https://ultrastardx.svn.sourceforge.net/svnroot/ultrastardx/trunk/src/base/USingNotes.pas $
+ * $Id: USingNotes.pas 1406 2008-09-23 21:43:52Z k-m_schindler $
+ *}
+
+unit UBeatTimer;
+
+interface
+
+{$IFDEF FPC}
+ {$MODE Delphi}
+{$ENDIF}
+
+{$I switches.inc}
+
+uses
+ UTime;
+
+type
+ (**
+ * TLyricsState contains all information concerning the
+ * state of the lyrics, e.g. the current beat or duration of the lyrics.
+ *)
+ TLyricsState = class
+ private
+ Timer: TRelativeTimer; // keeps track of the current time
+ public
+ OldBeat: integer; // previous discovered beat
+ CurrentBeat: integer; // current beat (rounded)
+ MidBeat: real; // current beat (float)
+
+ // now we use this for super synchronization!
+ // only used when analyzing voice
+ // TODO: change ...D to ...Detect(ed)
+ OldBeatD: integer; // previous discovered beat
+ CurrentBeatD: integer; // current discovered beat (rounded)
+ MidBeatD: real; // current discovered beat (float)
+
+ // we use this for audible clicks
+ // TODO: Change ...C to ...Click
+ OldBeatC: integer; // previous discovered beat
+ CurrentBeatC: integer;
+ MidBeatC: real; // like CurrentBeatC
+
+ OldLine: integer; // previous displayed sentence
+
+ StartTime: real; // time till start of lyrics (= Gap)
+ TotalTime: real; // total song time
+
+ constructor Create();
+ procedure Pause();
+ procedure Resume();
+
+ procedure Reset();
+ procedure UpdateBeats();
+
+ (**
+ * current song time (in seconds) used as base-timer for lyrics etc.
+ *)
+ function GetCurrentTime(): real;
+ procedure SetCurrentTime(Time: real);
+ end;
+
+implementation
+uses UNote, Math;
+
+
+constructor TLyricsState.Create();
+begin
+ // create a triggered timer, so we can Pause() it, set the time
+ // and Resume() it afterwards for better synching.
+ Timer := TRelativeTimer.Create(true);
+
+ // reset state
+ Reset();
+end;
+
+procedure TLyricsState.Pause();
+begin
+ Timer.Pause();
+end;
+
+procedure TLyricsState.Resume();
+begin
+ Timer.Resume();
+end;
+
+procedure TLyricsState.SetCurrentTime(Time: real);
+begin
+ // do not start the timer (if not started already),
+ // after setting the current time
+ Timer.SetTime(Time, false);
+end;
+
+function TLyricsState.GetCurrentTime(): real;
+begin
+ Result := Timer.GetTime();
+end;
+
+(**
+ * Resets the timer and state of the lyrics.
+ * The timer will be stopped afterwards so you have to call Resume()
+ * to start the lyrics timer.
+ *)
+procedure TLyricsState.Reset();
+begin
+ Pause();
+ SetCurrentTime(0);
+
+ StartTime := 0;
+ TotalTime := 0;
+
+ OldBeat := -1;
+ MidBeat := -1;
+ CurrentBeat := -1;
+
+ OldBeatC := -1;
+ MidBeatC := -1;
+ CurrentBeatC := -1;
+
+ OldBeatD := -1;
+ MidBeatD := -1;
+ CurrentBeatD := -1;
+end;
+
+(**
+ * Updates the beat information (CurrentBeat/MidBeat/...) according to the
+ * current lyric time.
+ *)
+procedure TLyricsState.UpdateBeats();
+var
+ CurLyricsTime: real;
+begin
+ CurLyricsTime := GetCurrentTime();
+
+ OldBeat := CurrentBeat;
+ MidBeat := GetMidBeat(CurLyricsTime - StartTime / 1000);
+ CurrentBeat := Floor(MidBeat);
+
+ OldBeatC := CurrentBeatC;
+ MidBeatC := GetMidBeat(CurLyricsTime - StartTime / 1000);
+ CurrentBeatC := Floor(MidBeatC);
+
+ OldBeatD := CurrentBeatD;
+ // MidBeatD = MidBeat with additional GAP
+ MidBeatD := -0.5 + GetMidBeat(CurLyricsTime - (StartTime + 120 + 20) / 1000);
+ CurrentBeatD := Floor(MidBeatD);
+end;
+
+end.
\ No newline at end of file diff --git a/unicode/src/base/UCommon.pas b/unicode/src/base/UCommon.pas index f5697916..3230a065 100644 --- a/unicode/src/base/UCommon.pas +++ b/unicode/src/base/UCommon.pas @@ -44,16 +44,16 @@ uses ULog; type - TMessageType = ( mtInfo, mtError ); + TMessageType = (mtInfo, mtError); -procedure ShowMessage(const msg : String; msgType: TMessageType = mtInfo); +procedure ShowMessage(const msg: string; msgType: TMessageType = mtInfo); procedure ConsoleWriteLn(const msg: string); function RWopsFromStream(Stream: TStream): PSDL_RWops; {$IFDEF FPC} -function RandomRange(aMin: Integer; aMax: Integer): Integer; +function RandomRange(aMin: integer; aMax: integer): integer; {$ENDIF} procedure DisableFloatingPointExceptions(); @@ -61,8 +61,8 @@ procedure SetDefaultNumericLocale(); procedure RestoreNumericLocale(); {$IFNDEF MSWINDOWS} - procedure ZeroMemory(Destination: Pointer; Length: DWORD); - function MakeLong(a, b: Word): Longint; + procedure ZeroMemory(Destination: pointer; Length: dword); + function MakeLong(a, b: word): longint; {$ENDIF} function AdaptFilePaths(const aPath: widestring): widestring; @@ -71,8 +71,8 @@ function FileExistsInsensitive(var FileName: string): boolean; // A stable alternative to TList.Sort() (use TList.Sort() if applicable, see below) procedure MergeSort(List: TList; CompareFunc: TListSortCompare); -function GetAlignedMem(Size: cardinal; Alignment: integer): Pointer; -procedure FreeAlignedMem(P: Pointer); +function GetAlignedMem(Size: cardinal; Alignment: integer): pointer; +procedure FreeAlignedMem(P: pointer); implementation @@ -206,20 +206,19 @@ begin exOverflow, exUnderflow, exPrecision]); end; -function AdaptFilePaths( const aPath : widestring ): widestring; +function AdaptFilePaths(const aPath: WideString): WideString; begin - result := StringReplaceW( aPath, '\', PathDelim );//, [rfReplaceAll] ); + result := StringReplaceW(aPath, '\', PathDelim);//, [rfReplaceAll]); end; {$IFNDEF MSWINDOWS} - -procedure ZeroMemory( Destination: Pointer; Length: DWORD ); +procedure ZeroMemory(Destination: pointer; Length: dword); begin - FillChar( Destination^, Length, 0 ); + FillChar(Destination^, Length, 0); end; -function MakeLong(A, B: Word): Longint; +function MakeLong(A, B: word): longint; begin Result := (LongInt(B) shl 16) + A; end; @@ -244,7 +243,7 @@ begin Result := false; FilePath := ExtractFilePath(FileName); - if (FindFirst(FilePath+'*', faAnyFile, SearchInfo) = 0) then + if (FindFirst(FilePath + '*', faAnyFile, SearchInfo) = 0) then begin LocalFileName := ExtractFileName(FileName); repeat @@ -264,14 +263,14 @@ begin end; // +++++++++++++++++++++ helpers for RWOpsFromStream() +++++++++++++++ -function SdlStreamSeek( context : PSDL_RWops; offset : Integer; whence : Integer ) : integer; cdecl; +function SdlStreamSeek(context: PSDL_RWops; offset: integer; whence: integer): integer; cdecl; var - stream : TStream; - origin : Word; + stream: TStream; + origin: word; begin - stream := TStream( context.unknown ); - if ( stream = nil ) then - raise EInvalidContainer.Create( 'SDLStreamSeek on nil' ); + stream := TStream(context.unknown); + if (stream = nil) then + raise EInvalidContainer.Create('SDLStreamSeek on nil'); case whence of 0 : origin := soFromBeginning; // Offset is from the beginning of the resource. Seek moves to the position Offset. Offset must be >= 0. 1 : origin := soFromCurrent; // Offset is from the current position in the resource. Seek moves to Position + Offset. @@ -279,30 +278,30 @@ begin else origin := soFromBeginning; // just in case end; - Result := stream.Seek( offset, origin ); + Result := stream.Seek(offset, origin); end; -function SdlStreamRead( context : PSDL_RWops; Ptr : Pointer; size : Integer; maxnum: Integer ) : Integer; cdecl; +function SdlStreamRead(context: PSDL_RWops; Ptr: pointer; size: integer; maxnum: integer): integer; cdecl; var - stream : TStream; + stream: TStream; begin - stream := TStream( context.unknown ); - if ( stream = nil ) then - raise EInvalidContainer.Create( 'SDLStreamRead on nil' ); + stream := TStream(context.unknown); + if (stream = nil) then + raise EInvalidContainer.Create('SDLStreamRead on nil'); try - Result := stream.read( Ptr^, Size * maxnum ) div size; + Result := stream.read(Ptr^, Size * maxnum) div size; except Result := -1; end; end; -function SDLStreamClose( context : PSDL_RWops ) : Integer; cdecl; +function SDLStreamClose(context: PSDL_RWops): integer; cdecl; var - stream : TStream; + stream: TStream; begin - stream := TStream( context.unknown ); - if ( stream = nil ) then - raise EInvalidContainer.Create( 'SDLStreamClose on nil' ); + stream := TStream(context.unknown); + if (stream = nil) then + raise EInvalidContainer.Create('SDLStreamClose on nil'); stream.Free; Result := 1; end; @@ -331,12 +330,10 @@ begin end; end; - - {$IFDEF FPC} -function RandomRange(aMin: Integer; aMax: Integer) : Integer; +function RandomRange(aMin: integer; aMax: integer): integer; begin - RandomRange := Random(aMax-aMin) + aMin ; + RandomRange := Random(aMax - aMin) + aMin ; end; {$ENDIF} @@ -389,7 +386,7 @@ begin System.EnterCriticalSection(ConsoleCriticalSection); // output pending messages - for i := 0 to MessageList.Count-1 do + for i := 0 to MessageList.Count - 1 do begin _ConsoleWriteLn(MessageList[i]); end; @@ -462,7 +459,7 @@ end; procedure ShowMessage(const msg: String; msgType: TMessageType); {$IFDEF MSWINDOWS} -var Flags: Cardinal; +var Flags: cardinal; {$ENDIF} begin {$IF Defined(MSWINDOWS)} @@ -488,7 +485,7 @@ procedure _MergeSort(InList, TempList, OutList: TList; StartPos, BlockSize: inte CompareFunc: TListSortCompare); var LeftSize, RightSize: integer; // number of elements in left/right block - LeftEnd, RightEnd: integer; // Index after last element in left/right block + LeftEnd, RightEnd: integer; // Index after last element in left/right block MidPos: integer; // index of first element in right block Pos: integer; // position in output list begin @@ -564,7 +561,7 @@ end; type // stores the unaligned pointer of data allocated by GetAlignedMem() PMemAlignHeader = ^TMemAlignHeader; - TMemAlignHeader = Pointer; + TMemAlignHeader = pointer; (** * Use this function to assure that allocated memory is aligned on a specific @@ -580,9 +577,9 @@ type * alignments on 16 and 32 byte boundaries too. *) {$WARNINGS OFF} -function GetAlignedMem(Size: cardinal; Alignment: integer): Pointer; +function GetAlignedMem(Size: cardinal; Alignment: integer): pointer; var - OrigPtr: Pointer; + OrigPtr: pointer; const MIN_ALIGNMENT = 16; begin @@ -603,9 +600,9 @@ begin end; // reserve space for the header - Result := Pointer(PtrUInt(OrigPtr) + SizeOf(TMemAlignHeader)); + Result := pointer(PtrUInt(OrigPtr) + SizeOf(TMemAlignHeader)); // align memory - Result := Pointer(PtrUInt(Result) + Alignment - PtrUInt(Result) mod Alignment); + Result := pointer(PtrUInt(Result) + Alignment - PtrUInt(Result) mod Alignment); // set header with info on old pointer for FreeMem PMemAlignHeader(PtrUInt(Result) - SizeOf(TMemAlignHeader))^ := OrigPtr; @@ -613,7 +610,7 @@ end; {$WARNINGS ON} {$WARNINGS OFF} -procedure FreeAlignedMem(P: Pointer); +procedure FreeAlignedMem(P: pointer); begin if (P <> nil) then FreeMem(PMemAlignHeader(PtrUInt(P) - SizeOf(TMemAlignHeader))^); diff --git a/unicode/src/base/UConfig.pas b/unicode/src/base/UConfig.pas index cb663e2d..1214f36f 100644 --- a/unicode/src/base/UConfig.pas +++ b/unicode/src/base/UConfig.pas @@ -107,7 +107,7 @@ const // include config-file (defines + constants) {$IF Defined(MSWindows)} - {$I ../config-win.inc} + {$I ..\config-win.inc} {$ELSEIF Defined(Linux)} {$I ../config-linux.inc} {$ELSEIF Defined(FreeBSD)} diff --git a/unicode/src/base/UDLLManager.pas b/unicode/src/base/UDLLManager.pas index cd4b7991..3faa15bf 100644 --- a/unicode/src/base/UDLLManager.pas +++ b/unicode/src/base/UDLLManager.pas @@ -40,37 +40,42 @@ uses type TDLLMan = class private - hLib: THandle; + 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; + PluginPaths: array of string; Selected: ^TPluginInfo; constructor Create; procedure GetPluginList; - procedure ClearPluginInfo(No: Cardinal); - function LoadPluginInfo(Filename: String; No: Cardinal): boolean; + procedure ClearPluginInfo(No: cardinal); + function LoadPluginInfo(Filename: string; No: cardinal): boolean; - function LoadPlugin(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 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); + procedure PluginRData (handle: HSTREAM; buffer: Pointer; len: dword; user: dword); end; var DLLMan: TDLLMan; const - DLLPath = 'Plugins'; - {$IF Defined(MSWINDOWS)} DLLExt = '.dll'; {$ELSEIF Defined(DARWIN)} @@ -87,6 +92,7 @@ uses {$ELSE} dynlibs, {$ENDIF} + UPath, ULog, SysUtils; @@ -101,33 +107,33 @@ end; procedure TDLLMan.GetPluginList; var - SR: TSearchRec; + SearchRecord: TSearchRec; begin - if FindFirst(DLLPath +PathDelim+ '*' + DLLExt, faAnyFile , SR) = 0 then + if FindFirst(PluginPath + '*' + DLLExt, faAnyFile, SearchRecord) = 0 then begin repeat SetLength(Plugins, Length(Plugins)+1); SetLength(PluginPaths, Length(Plugins)); - if LoadPluginInfo(SR.Name, High(Plugins)) then //Loaded succesful + if LoadPluginInfo(SearchRecord.Name, High(Plugins)) then // loaded succesful begin - PluginPaths[High(PluginPaths)] := SR.Name; + PluginPaths[High(PluginPaths)] := SearchRecord.Name; end - else //Error Loading + else // error loading begin SetLength(Plugins, Length(Plugins)-1); SetLength(PluginPaths, Length(Plugins)); end; - until FindNext(SR) <> 0; - FindClose(SR); + until FindNext(SearchRecord) <> 0; + FindClose(SearchRecord); end; end; -procedure TDLLMan.ClearPluginInfo(No: Cardinal); +procedure TDLLMan.ClearPluginInfo(No: cardinal); begin - //Set to Party Modi Plugin +// set to party modi plugin Plugins[No].Typ := 8; Plugins[No].Name := 'unknown'; @@ -136,109 +142,117 @@ begin 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].LoadSong := true; + Plugins[No].ShowScore := true; + Plugins[No].ShowBars := true; + 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].TeamModeOnly := true; + Plugins[No].GetSoundData := true; + Plugins[No].Dummy := true; - Plugins[No].BGShowFull := False; - Plugins[No].BGShowFull_O := True; + Plugins[No].BGShowFull := true; + Plugins[No].BGShowFull_O := true; - Plugins[No].ShowRateBar:= False; - Plugins[No].ShowRateBar_O := True; + Plugins[No].ShowRateBar := true; + Plugins[No].ShowRateBar_O := true; - Plugins[No].EnLineBonus := False; - Plugins[No].EnLineBonus_O := True; + Plugins[No].EnLineBonus := true; + Plugins[No].EnLineBonus_O := true; end; -function TDLLMan.LoadPluginInfo(Filename: String; No: Cardinal): boolean; +function TDLLMan.LoadPluginInfo(Filename: string; No: cardinal): boolean; var hLibg: THandle; Info: pModi_PluginInfo; - //I: Integer; +// I: integer; begin - Result := False; - //Clear Plugin Info + Result := true; +// clear plugin info ClearPluginInfo(No); - {//Workaround Plugins Loaded 2 Times - For I := low(PluginPaths) to high(PluginPaths) do - if (PluginPaths[I] = Filename) then - exit; } +{ +// 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 +PathDelim+ Filename)); - //If Loaded +// load libary + hLibg := LoadLibrary(PChar(PluginPath + Filename)); +// if loaded if (hLibg <> 0) then begin - //Load Info Procedure - @Info := GetProcAddress (hLibg, PChar('PluginInfo')); +// load info procedure + @Info := GetProcAddress(hLibg, PChar('PluginInfo')); - //If Loaded +// if loaded if (@Info <> nil) then begin - //Load PluginInfo - Info (Plugins[No]); - Result := True; +// load plugininfo + Info(Plugins[No]); + Result := true; end else - Log.LogError('Could not Load Plugin "' + Filename + '": Info Procedure not Found'); + 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'); + else + Log.LogError('Could not load plugin "' + Filename + '": Libary not loaded'); end; -function TDLLMan.LoadPlugin(No: Cardinal): boolean; +function TDLLMan.LoadPlugin(No: cardinal): boolean; begin - Result := False; - //Load Libary - hLib := LoadLibrary(PChar(DLLPath +PathDelim+ PluginPaths[No])); - //If Loaded + Result := true; +// load libary + hLib := LoadLibrary(PChar(PluginPath + 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')); +// load info procedure + @P_Init := GetProcAddress (hLib, 'Init'); + @P_Draw := GetProcAddress (hLib, 'Draw'); + @P_Finish := GetProcAddress (hLib, 'Finish'); - //If Loaded - if (@P_Init <> nil) And (@P_Draw <> nil) And (@P_Finish <> nil) then +// if loaded + if (@P_Init <> nil) and (@P_Draw <> nil) and (@P_Finish <> nil) then begin Selected := @Plugins[No]; - Result := True; + Result := true; end else begin - Log.LogError('Could not Load Plugin "' + PluginPaths[No] + '": Procedures not Found'); - + 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'); + 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; + 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; +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 @@ -250,26 +264,26 @@ begin if (@P_Init <> nil) then Result := P_Init (TeamInfo, PlayerInfo, Sentences, Methods) else - Result := False + Result := true end; -function TDLLMan.PluginDraw (var Playerinfo: TPlayerinfo; const CurSentence: Cardinal): boolean; +function TDLLMan.PluginDraw (var Playerinfo: TPlayerinfo; const CurSentence: cardinal): boolean; begin -if (@P_Draw <> nil) then - Result := P_Draw (PlayerInfo, CurSentence) -else - Result := False + if (@P_Draw <> nil) then + Result := P_Draw (PlayerInfo, CurSentence) + else + Result := true end; function TDLLMan.PluginFinish (var Playerinfo: TPlayerinfo): byte; begin -if (@P_Finish <> nil) then - Result := P_Finish (PlayerInfo) -else - Result := 0; + if (@P_Finish <> nil) then + Result := P_Finish (PlayerInfo) + else + Result := 0; end; -procedure TDLLMan.PluginRData (handle: HSTREAM; buffer: Pointer; len: DWORD; user: DWORD); +procedure TDLLMan.PluginRData (handle: HStream; buffer: Pointer; len: dword; user: dword); begin if (@P_RData <> nil) then P_RData (handle, buffer, len, user); diff --git a/unicode/src/base/UDraw.pas b/unicode/src/base/UDraw.pas index 8a66d271..1783986f 100644 --- a/unicode/src/base/UDraw.pas +++ b/unicode/src/base/UDraw.pas @@ -638,7 +638,7 @@ begin // determine lyric help bar position and size Bounds.Left := MoveStartX + BarProgress * MoveDist; Bounds.Right := Bounds.Left + BarWidth; - Bounds.Top := Skin_LyricsT + 3; + Bounds.Top := Theme.LyricBar.IndicatorYOffset + Theme.LyricBar.UpperY ; Bounds.Bottom := Bounds.Top + BarHeight + 3; // draw lyric help bar diff --git a/unicode/src/base/UEditorLyrics.pas b/unicode/src/base/UEditorLyrics.pas index fe8c3ee5..ef9d8dd6 100644 --- a/unicode/src/base/UEditorLyrics.pas +++ b/unicode/src/base/UEditorLyrics.pas @@ -40,7 +40,7 @@ uses UTexture; type - alignment = (left, center, right); + TAlignmentType = (atLeft, atCenter, atRight); TWord = record X: real; @@ -58,7 +58,7 @@ type TEditorLyrics = class private - AlignI: alignment; + AlignI: TAlignmentType; XR: real; YR: real; SizeR: real; @@ -69,7 +69,7 @@ type procedure SetX(Value: real); procedure SetY(Value: real); function GetClientX: real; - procedure SetAlign(Value: alignment); + procedure SetAlign(Value: TAlignmentType); function GetSize: real; procedure SetSize(Value: real); procedure SetSelected(Value: integer); @@ -96,7 +96,7 @@ type property X: real write SetX; property Y: real write SetY; property ClientX: real read GetClientX; - property Align: alignment write SetAlign; + property Align: TAlignmentType write SetAlign; property Size: real read GetSize write SetSize; property Selected: integer read SelectedI write SetSelected; property FontStyle: integer write SetFontStyle; @@ -137,7 +137,7 @@ begin Result := Word[0].X; end; -procedure TEditorLyrics.SetAlign(Value: alignment); +procedure TEditorLyrics.SetAlign(Value: TAlignmentType); begin AlignI := Value; end; @@ -229,7 +229,7 @@ var WordIndex: integer; TotalWidth: real; begin - if AlignI = center then + if AlignI = atCenter then begin TotalWidth := 0; for WordIndex := 0 to High(Word) do diff --git a/unicode/src/base/UGraphic.pas b/unicode/src/base/UGraphic.pas index 17175d02..818e49aa 100644 --- a/unicode/src/base/UGraphic.pas +++ b/unicode/src/base/UGraphic.pas @@ -198,7 +198,14 @@ var Tex_Score_NoteBarRound_Lightest : array [1..6] of TTexture; Tex_Score_Ratings : array [0..7] of TTexture; - + + // arrows for SelectSlide + Tex_SelectS_ArrowL: TTexture; + Tex_SelectS_ArrowR: TTexture; + + // textures for software mouse cursor + Tex_Cursor_Unpressed: TTexture; + Tex_Cursor_Pressed: TTexture; const Skin_BGColorR = 1; Skin_BGColorG = 1; @@ -232,17 +239,6 @@ const Skin_OscG = 0; Skin_OscB = 0; - // TODO: add to theme ini file - Skin_LyricsT = 493; - Skin_LyricsUpperX = 80; - Skin_LyricsUpperW = 640; - Skin_LyricsUpperY = Skin_LyricsT; - Skin_LyricsUpperH = 41; - Skin_LyricsLowerX = 80; - Skin_LyricsLowerW = 640; - Skin_LyricsLowerY = Skin_LyricsT + Skin_LyricsUpperH + 1; - Skin_LyricsLowerH = 41; - Skin_SpectrumT = 470; Skin_SpectrumBot = 570; Skin_SpectrumH = 100; @@ -339,6 +335,15 @@ begin Tex_Ball := Texture.LoadTexture(Skin.GetTextureFileName('Ball'), TEXTURE_TYPE_TRANSPARENT, $FF00FF); Tex_Lyric_Help_Bar := Texture.LoadTexture(Skin.GetTextureFileName('LyricHelpBar'), TEXTURE_TYPE_TRANSPARENT, $FF00FF); + Tex_SelectS_ArrowL := Texture.LoadTexture(Skin.GetTextureFileName('Select_ArrowLeft'), TEXTURE_TYPE_TRANSPARENT, 0); + Tex_SelectS_ArrowR := Texture.LoadTexture(Skin.GetTextureFileName('Select_ArrowRight'), TEXTURE_TYPE_TRANSPARENT, 0); + + Tex_Cursor_Unpressed := Texture.LoadTexture(Skin.GetTextureFileName('Cursor'), TEXTURE_TYPE_TRANSPARENT, 0); + + if (Skin.GetTextureFileName('Cursor_Pressed') <> '') then + Tex_Cursor_Pressed := Texture.LoadTexture(Skin.GetTextureFileName('Cursor_Pressed'), TEXTURE_TYPE_TRANSPARENT, 0) + else + Tex_Cursor_Pressed.TexNum := 0; //TimeBar mod Tex_TimeProgress := Texture.LoadTexture(Skin.GetTextureFileName('TimeBar')); @@ -497,6 +502,7 @@ begin Log.LogStatus('TDisplay.Create', 'UGraphic.Initialize3D'); Display := TDisplay.Create; + //Display.SetCursor; //Log.BenchmarkEnd(2); Log.LogBenchmark('====> Creating Display', 2); @@ -629,15 +635,15 @@ begin begin Log.LogStatus('SDL_SetVideoMode', 'Set Video Mode... Full Screen'); screen := SDL_SetVideoMode(W, H, (Depth+1) * 16, SDL_OPENGL or SDL_FULLSCREEN ); - SDL_ShowCursor(0); end else begin Log.LogStatus('SDL_SetVideoMode', 'Set Video Mode... Windowed'); screen := SDL_SetVideoMode(W, H, 0, SDL_OPENGL or SDL_RESIZABLE); - SDL_ShowCursor(1); end; + SDL_ShowCursor(0); + if (screen = nil) then begin Log.LogCritical('SDL_SetVideoMode Failed', 'Initialize3D'); diff --git a/unicode/src/base/UImage.pas b/unicode/src/base/UImage.pas index 8dc38495..60b0a3a2 100644 --- a/unicode/src/base/UImage.pas +++ b/unicode/src/base/UImage.pas @@ -311,13 +311,13 @@ var hour, minute, second, msecond: word; begin DecodeDate(time, year, month, day); - pngTime.year := year; - pngTime.month := month; - pngTime.day := day; + pngTime.year := png_uint_16(year); + pngTime.month := png_byte(month); + pngTime.day := png_byte(day); DecodeTime(time, hour, minute, second, msecond); - pngTime.hour := hour; - pngTime.minute := minute; - pngTime.second := second; + pngTime.hour := png_byte(hour); + pngTime.minute := png_byte(minute); + pngTime.second := png_byte(second); end; (* @@ -896,8 +896,13 @@ procedure ColorizeImage(ImgSurface: PSDL_Surface; NewColor: cardinal); // replaced by division of longwords, shifted by 10 bits to keep // digits. + // The use of longwards leeds to some type size mismatch warnings + // whenever differences are formed. + // This should not be a problem, since the results should all be positive. + // replacing longword by longint would probably resolve this cosmetic fault :-) + function ColorToHue(const Color: longword): longword; - // returns hue within the range [0.0-6.0] but shl 10, ie. times 1024 + // returns hue within the range [0.0-6.0] but shl 10, ie. times 1024 var Red, Green, Blue: longword; Min, Max, Delta: longword; @@ -919,7 +924,8 @@ procedure ColorizeImage(ImgSurface: PSDL_Surface; NewColor: cardinal); if Blue > Max then Max := Blue; // calc hue - Delta := Max - Min; + Delta := Max - Min; // This gives a type size mismatch warning, because Delta is longword, ie. >= 0 + // But the assignments above are easy enough to be sure, that Max - Min is >= 0. if (Delta = 0) then Result := 0 else @@ -1023,16 +1029,19 @@ begin end else // all colors except black and white begin - Delta := Max - Min; + Delta := Max - Min; // This gives a type size mismatch warning, because Delta is longword, ie. >= 0 + // But the assignments above are easy enough to be sure, that Max - Min is >= 0. Sat := (Delta shl 10) div Max; // shl 10 - // shr 10 corrects that sat and f are shl 10 + // shr 10 corrects that Sat and f are shl 10 // the resulting p, q and t are unshifted p := (Max*(1024-Sat)) shr 10; q := (Max*(1024-(Sat*f) shr 10)) shr 10; t := (Max*(1024-(Sat*(1024-f)) shr 10)) shr 10; + // The above 3 lines give type size mismatch warning, but all variables are longword and the ranges should be ok. + case HueInteger of 0: begin Red := Max; Green := t; Blue := p; end; // (v,t,p) 1: begin Red := q; Green := Max; Blue := p; end; // (q,v,p) @@ -1043,13 +1052,13 @@ begin end; {$IFDEF FPC_BIG_ENDIAN} - PixelColors[3] := Red; - PixelColors[2] := Green; - PixelColors[1] := Blue + PixelColors[3] := byte(Red); + PixelColors[2] := byte(Green); + PixelColors[1] := byte(Blue); {$ELSE} - PixelColors[0] := Red; - PixelColors[1] := Green; - PixelColors[2] := Blue; + PixelColors[0] := byte(Red); + PixelColors[1] := byte(Green); + PixelColors[2] := byte(Blue); {$ENDIF} end; diff --git a/unicode/src/base/UIni.pas b/unicode/src/base/UIni.pas index 241b34e8..61c39d32 100644 --- a/unicode/src/base/UIni.pas +++ b/unicode/src/base/UIni.pas @@ -78,6 +78,7 @@ type function ReadArrayIndex(const SearchArray: array of string; IniFile: TCustomIniFile; IniSection: string; IniProperty: string; Default: integer): integer; + procedure TranslateOptionValues; procedure LoadInputDeviceCfg(IniFile: TMemIniFile); procedure SaveInputDeviceCfg(IniFile: TIniFile); procedure LoadThemes(IniFile: TCustomIniFile); @@ -155,6 +156,7 @@ type // Controller Joypad: integer; + Mouse: integer; // default encoding for texts (lyrics, song-name, ...) EncodingDefault: TEncoding; @@ -198,14 +200,13 @@ const IBackgroundMusic: array[0..1] of string = ('Off', 'On'); - ITextureSize: array[0..2] of string = ('128', '256', '512'); - ITextureSizeVals: array[0..2] of integer = ( 128, 256, 512); + ITextureSize: array[0..3] of string = ('64', '128', '256', '512'); + ITextureSizeVals: array[0..3] of integer = ( 64, 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'); + IOscilloscope: array[0..1] of string = ('Off', 'On'); ISpectrum: array[0..1] of string = ('Off', 'On'); ISpectrograph: array[0..1] of string = ('Off', 'On'); @@ -246,15 +247,75 @@ const 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'); + ILineBonus: array[0..1] of string = ('Off', 'On'); IPartyPopup: array[0..1] of string = ('Off', 'On'); IJoypad: array[0..1] of string = ('Off', 'On'); + IMouse: array[0..2] of string = ('Off', 'Hardware Cursor', 'Software Cursor'); // Recording options IChannelPlayer: array[0..6] of string = ('Off', '1', '2', '3', '4', '5', '6'); IMicBoost: array[0..3] of string = ('Off', '+6dB', '+12dB', '+18dB'); +var + IDifficultyTranslated: array[0..2] of string = ('Easy', 'Medium', 'Hard'); + ITabsTranslated: array[0..1] of string = ('Off', 'On'); + + ISortingTranslated: array[0..7] of string = ('Edition', 'Genre', 'Language', 'Folder', 'Title', 'Artist', 'Title2', 'Artist2'); + + IDebugTranslated: array[0..1] of string = ('Off', 'On'); + + IFullScreenTranslated: array[0..1] of string = ('Off', 'On'); + IVisualizerTranslated: array[0..2] of string = ('Off', 'WhenNoVideo','On'); + + IBackgroundMusicTranslated: array[0..1] of string = ('Off', 'On'); + ISingWindowTranslated: array[0..1] of string = ('Small', 'Big'); + + //SingBar Mod + IOscilloscopeTranslated: array[0..1] of string = ('Off', 'On'); + + ISpectrumTranslated: array[0..1] of string = ('Off', 'On'); + ISpectrographTranslated: array[0..1] of string = ('Off', 'On'); + IMovieSizeTranslated: array[0..2] of string = ('Half', 'Full [Vid]', 'Full [BG+Vid]'); + + IClickAssistTranslated: array[0..1] of string = ('Off', 'On'); + IBeatClickTranslated: array[0..1] of string = ('Off', 'On'); + ISavePlaybackTranslated: array[0..1] of string = ('Off', 'On'); + + IVoicePassthroughTranslated: array[0..1] of string = ('Off', 'On'); + + //Song Preview + IPreviewVolumeTranslated: array[0..10] of string = ('Off', '10%', '20%', '30%', '40%', '50%', '60%', '70%', '80%', '90%', '100%'); + + IAudioOutputBufferSizeTranslated: array[0..9] of string = ('Auto', '256', '512', '1024', '2048', '4096', '8192', '16384', '32768', '65536'); + + IAudioInputBufferSizeTranslated: array[0..9] of string = ('Auto', '256', '512', '1024', '2048', '4096', '8192', '16384', '32768', '65536'); + + IPreviewFadingTranslated: array[0..5] of string = ('Off', '1 Sec', '2 Secs', '3 Secs', '4 Secs', '5 Secs'); + + ILyricsFontTranslated: array[0..2] of string = ('Plain', 'OLine1', 'OLine2'); + ILyricsEffectTranslated: array[0..4] of string = ('Simple', 'Zoom', 'Slide', 'Ball', 'Shift'); + ISolmizationTranslated: array[0..3] of string = ('Off', 'Euro', 'Jap', 'American'); + INoteLinesTranslated: array[0..1] of string = ('Off', 'On'); + + IColorTranslated: array[0..8] of string = ('Blue', 'Green', 'Pink', 'Red', 'Violet', 'Orange', 'Yellow', 'Brown', 'Black'); + + // Advanced + ILoadAnimationTranslated: array[0..1] of string = ('Off', 'On'); + IEffectSingTranslated: array[0..1] of string = ('Off', 'On'); + IScreenFadeTranslated: array[0..1] of string = ('Off', 'On'); + IAskbeforeDelTranslated: array[0..1] of string = ('Off', 'On'); + IOnSongClickTranslated: array[0..2] of string = ('Sing', 'Select Players', 'Open Menu'); + ILineBonusTranslated: array[0..1] of string = ('Off', 'On'); + IPartyPopupTranslated: array[0..1] of string = ('Off', 'On'); + + IJoypadTranslated: array[0..1] of string = ('Off', 'On'); + IMouseTranslated: array[0..2] of string = ('Off', 'Hardware Cursor', 'Software Cursor'); + + // Recording options + IChannelPlayerTranslated: array[0..6] of string = ('Off', '1', '2', '3', '4', '5', '6'); + IMicBoostTranslated: array[0..3] of string = ('Off', '+6dB', '+12dB', '+18dB'); + implementation uses @@ -270,6 +331,188 @@ uses UUnicodeUtils; (** + * Translate and set the values of options, which need translation. + *) +procedure TIni.TranslateOptionValues; +begin + ULanguage.Language.ChangeLanguage(ILanguage[Language]); + + IDifficultyTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_EASY'); + IDifficultyTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_MEDIUM'); + IDifficultyTranslated[2] := ULanguage.Language.Translate('OPTION_VALUE_HARD'); + + ITabsTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + ITabsTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + ISortingTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_EDITION'); + ISortingTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_GENRE'); + ISortingTranslated[2] := ULanguage.Language.Translate('OPTION_VALUE_LANGUAGE'); + ISortingTranslated[3] := ULanguage.Language.Translate('OPTION_VALUE_FOLDER'); + ISortingTranslated[4] := ULanguage.Language.Translate('OPTION_VALUE_TITLE'); + ISortingTranslated[5] := ULanguage.Language.Translate('OPTION_VALUE_ARTIST'); + ISortingTranslated[6] := ULanguage.Language.Translate('OPTION_VALUE_TITLE2'); + ISortingTranslated[7] := ULanguage.Language.Translate('OPTION_VALUE_ARTIST2'); + + IDebugTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IDebugTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IFullScreenTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IFullScreenTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IVisualizerTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IVisualizerTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_WHENNOVIDEO'); + IVisualizerTranslated[2] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IBackgroundMusicTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IBackgroundMusicTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + ISingWindowTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_SMALL'); + ISingWindowTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_BIG'); + + IOscilloscopeTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IOscilloscopeTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + ISpectrumTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + ISpectrumTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + ISpectrographTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + ISpectrographTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IMovieSizeTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_HALF'); + IMovieSizeTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_FULL_VID'); + IMovieSizeTranslated[2] := ULanguage.Language.Translate('OPTION_VALUE_FULL_VID_BG'); + + IClickAssistTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IClickAssistTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IBeatClickTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IBeatClickTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + ISavePlaybackTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + ISavePlaybackTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IVoicePassthroughTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IVoicePassthroughTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + ILyricsFontTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_PLAIN'); + ILyricsFontTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_OLINE1'); + ILyricsFontTranslated[2] := ULanguage.Language.Translate('OPTION_VALUE_OLINE2'); + + ILyricsEffectTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_SIMPLE'); + ILyricsEffectTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ZOOM'); + ILyricsEffectTranslated[2] := ULanguage.Language.Translate('OPTION_VALUE_SLIDE'); + ILyricsEffectTranslated[3] := ULanguage.Language.Translate('OPTION_VALUE_BALL'); + ILyricsEffectTranslated[4] := ULanguage.Language.Translate('OPTION_VALUE_SHIFT'); + + ISolmizationTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + ISolmizationTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_EURO'); + ISolmizationTranslated[2] := ULanguage.Language.Translate('OPTION_VALUE_JAPAN'); + ISolmizationTranslated[3] := ULanguage.Language.Translate('OPTION_VALUE_AMERICAN'); + + INoteLinesTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + INoteLinesTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IColorTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_BLUE'); + IColorTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_GREEN'); + IColorTranslated[2] := ULanguage.Language.Translate('OPTION_VALUE_PINK'); + IColorTranslated[3] := ULanguage.Language.Translate('OPTION_VALUE_RED'); + IColorTranslated[4] := ULanguage.Language.Translate('OPTION_VALUE_VIOLET'); + IColorTranslated[5] := ULanguage.Language.Translate('OPTION_VALUE_ORANGE'); + IColorTranslated[6] := ULanguage.Language.Translate('OPTION_VALUE_YELLOW'); + IColorTranslated[7] := ULanguage.Language.Translate('OPTION_VALUE_BROWN'); + IColorTranslated[8] := ULanguage.Language.Translate('OPTION_VALUE_BALCK'); + + // Advanced + ILoadAnimationTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + ILoadAnimationTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IEffectSingTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IEffectSingTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IScreenFadeTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IScreenFadeTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IAskbeforeDelTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IAskbeforeDelTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IOnSongClickTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_SING'); + IOnSongClickTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_SELECT_PLAYERS'); + IOnSongClickTranslated[2] := ULanguage.Language.Translate('OPTION_VALUE_OPEN_MENU'); + + ILineBonusTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + ILineBonusTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IPartyPopupTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IPartyPopupTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IJoypadTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IJoypadTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); + + IMouseTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IMouseTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_HARDWARE_CURSOR'); + IMouseTranslated[2] := ULanguage.Language.Translate('OPTION_VALUE_SOFTWARE_CURSOR'); + + IAudioOutputBufferSizeTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_AUTO'); + IAudioOutputBufferSizeTranslated[1] := '256'; + IAudioOutputBufferSizeTranslated[2] := '512'; + IAudioOutputBufferSizeTranslated[3] := '1024'; + IAudioOutputBufferSizeTranslated[4] := '2048'; + IAudioOutputBufferSizeTranslated[5] := '4096'; + IAudioOutputBufferSizeTranslated[6] := '8192'; + IAudioOutputBufferSizeTranslated[7] := '16384'; + IAudioOutputBufferSizeTranslated[8] := '32768'; + IAudioOutputBufferSizeTranslated[9] := '65536'; + + + IAudioInputBufferSizeTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_AUTO'); + IAudioInputBufferSizeTranslated[1] := '256'; + IAudioInputBufferSizeTranslated[2] := '512'; + IAudioInputBufferSizeTranslated[3] := '1024'; + IAudioInputBufferSizeTranslated[4] := '2048'; + IAudioInputBufferSizeTranslated[5] := '4096'; + IAudioInputBufferSizeTranslated[6] := '8192'; + IAudioInputBufferSizeTranslated[7] := '16384'; + IAudioInputBufferSizeTranslated[8] := '32768'; + IAudioInputBufferSizeTranslated[9] := '65536'; + + //Song Preview + IPreviewVolumeTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IPreviewVolumeTranslated[1] := '10%'; + IPreviewVolumeTranslated[2] := '20%'; + IPreviewVolumeTranslated[3] := '30%'; + IPreviewVolumeTranslated[4] := '40%'; + IPreviewVolumeTranslated[5] := '50%'; + IPreviewVolumeTranslated[6] := '60%'; + IPreviewVolumeTranslated[7] := '70%'; + IPreviewVolumeTranslated[8] := '80%'; + IPreviewVolumeTranslated[9] := '90%'; + IPreviewVolumeTranslated[10] := '100%'; + + + IPreviewFadingTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IPreviewFadingTranslated[1] := '1 ' + ULanguage.Language.Translate('OPTION_VALUE_SEC'); + IPreviewFadingTranslated[2] := '2 ' + ULanguage.Language.Translate('OPTION_VALUE_SECS'); + IPreviewFadingTranslated[3] := '3 ' + ULanguage.Language.Translate('OPTION_VALUE_SECS'); + IPreviewFadingTranslated[4] := '4 ' + ULanguage.Language.Translate('OPTION_VALUE_SECS'); + IPreviewFadingTranslated[5] := '5 ' + ULanguage.Language.Translate('OPTION_VALUE_SECS'); + + // Recording options + IChannelPlayerTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IChannelPlayerTranslated[1] := '1'; + IChannelPlayerTranslated[2] := '2'; + IChannelPlayerTranslated[3] := '3'; + IChannelPlayerTranslated[4] := '4'; + IChannelPlayerTranslated[5] := '5'; + IChannelPlayerTranslated[6] := '6'; + + IMicBoostTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); + IMicBoostTranslated[1] := '+6dB'; + IMicBoostTranslated[2] := '+12dB'; + IMicBoostTranslated[3] := '+18dB'; + +end; + +(** * Returns the filename without its fileextension *) function TIni.RemoveFileExt(FullName: string): string; @@ -593,6 +836,7 @@ begin end; // reverse order + Log.LogStatus( 'Log size of resolution: ' + IntToStr(Length(IResolution)), 'Video'); for I := 0 to (Length(IResolution) div 2) - 1 do begin swap(IResolution[I], IResolution[High(IResolution)-I]); @@ -686,7 +930,7 @@ begin SingWindow := GetArrayIndex(ISingWindow, IniFile.ReadString('Graphics', 'SingWindow', 'Big')); // Oscilloscope - Oscilloscope := GetArrayIndex(IOscilloscope, IniFile.ReadString('Graphics', 'Oscilloscope', 'Bar')); + Oscilloscope := GetArrayIndex(IOscilloscope, IniFile.ReadString('Graphics', 'Oscilloscope', IOscilloscope[0])); // Spectrum Spectrum := GetArrayIndex(ISpectrum, IniFile.ReadString('Graphics', 'Spectrum', 'Off')); @@ -713,16 +957,16 @@ begin PreviewVolume := GetArrayIndex(IPreviewVolume, IniFile.ReadString('Sound', 'PreviewVolume', IPreviewVolume[7])); //Preview Fading - PreviewFading := GetArrayIndex(IPreviewFading, IniFile.ReadString('Sound', 'PreviewFading', IPreviewFading[1])); + PreviewFading := GetArrayIndex(IPreviewFading, IniFile.ReadString('Sound', 'PreviewFading', IPreviewFading[3])); //AudioRepeat aka VoicePassthrough VoicePassthrough := GetArrayIndex(IVoicePassthrough, IniFile.ReadString('Sound', 'VoicePassthrough', IVoicePassthrough[0])); // Lyrics Font - LyricsFont := GetArrayIndex(ILyricsFont, IniFile.ReadString('Lyrics', 'LyricsFont', ILyricsFont[1])); + LyricsFont := GetArrayIndex(ILyricsFont, IniFile.ReadString('Lyrics', 'LyricsFont', ILyricsFont[0])); // Lyrics Effect - LyricsEffect := GetArrayIndex(ILyricsEffect, IniFile.ReadString('Lyrics', 'LyricsEffect', ILyricsEffect[1])); + LyricsEffect := GetArrayIndex(ILyricsEffect, IniFile.ReadString('Lyrics', 'LyricsEffect', ILyricsEffect[2])); // Solmization Solmization := GetArrayIndex(ISolmization, IniFile.ReadString('Lyrics', 'Solmization', ISolmization[0])); @@ -770,7 +1014,7 @@ begin OnSongClick := GetArrayIndex(IOnSongClick, IniFile.ReadString('Advanced', 'OnSongClick', 'Sing')); // Linebonus - LineBonus := GetArrayIndex(ILineBonus, IniFile.ReadString('Advanced', 'LineBonus', 'At Score')); + LineBonus := GetArrayIndex(ILineBonus, IniFile.ReadString('Advanced', 'LineBonus', ILineBonus[1])); // PartyPopup PartyPopup := GetArrayIndex(IPartyPopup, IniFile.ReadString('Advanced', 'PartyPopup', 'On')); @@ -778,8 +1022,13 @@ begin // Joypad Joypad := GetArrayIndex(IJoypad, IniFile.ReadString('Controller', 'Joypad', IJoypad[0])); + // Mouse + Mouse := GetArrayIndex(IMouse, IniFile.ReadString('Controller', 'Mouse', IMouse[2])); + LoadPaths(IniFile); + TranslateOptionValues; + IniFile.Free; end; @@ -920,6 +1169,9 @@ begin // Joypad IniFile.WriteString('Controller', 'Joypad', IJoypad[Joypad]); + // Mouse + IniFile.WriteString('Controller', 'Mouse', IMouse[Mouse]); + // Directories (add a template if section is missing) // Note: Value must be ' ' and not '', otherwise no key is generated on Linux if (not IniFile.SectionExists('Directories')) then diff --git a/unicode/src/base/UMain.pas b/unicode/src/base/UMain.pas index 8d11b91d..1962e953 100644 --- a/unicode/src/base/UMain.pas +++ b/unicode/src/base/UMain.pas @@ -66,11 +66,6 @@ implementation uses Math, gl, -{ - SDL_ttf, - UParty, - UCore, -} UCatCovers, UCommandLine, UCommon, @@ -88,10 +83,12 @@ uses UPath, UPlaylist, UMusic, + UBeatTimer, UPlatform, USkins, USongs, UThemes, + UParty, UTime; procedure Main; @@ -236,14 +233,12 @@ begin Log.BenchmarkEnd(1); Log.LogBenchmark('Loading PluginManager', 1); -{ // Party Mode Manager Log.BenchmarkStart(1); Log.LogStatus('PartySession Manager', 'Initialization'); PartySession := TPartySession.Create; //Load PartySession Log.BenchmarkEnd(1); Log.LogBenchmark('Loading PartySession Manager', 1); -} // Graphics Log.BenchmarkStart(1); @@ -364,9 +359,11 @@ begin CountMidTime; Delay := Floor(1000 / MAX_FPS - 1000 * TimeMid); + Log.LogError ('MainLoop', 'Delay: ' + intToStr(Delay)); if Delay >= 1 then SDL_Delay(Delay); // dynamic, maximum is 100 fps + Log.LogError ('MainLoop', 'Delay: ok ' + intToStr(Delay)); CountSkipTime; @@ -380,9 +377,26 @@ begin end; end; +procedure DoQuit; +begin + // if question option is enabled then show exit popup + if (Ini.AskbeforeDel = 1) then + begin + Display.CurrentScreen^.CheckFadeTo(nil,'MSG_QUIT_USDX'); + end + else // if ask-for-exit is disabled then simply exit + begin + Display.Fade := 0; + Display.NextScreenWithCheck := nil; + Display.CheckOK := true; + end; +end; + procedure CheckEvents; var - Event: TSDL_event; + Event: TSDL_event; + mouseDown: boolean; + mouseBtn: integer; begin if Assigned(Display.NextScreen) then Exit; @@ -396,17 +410,46 @@ begin Display.NextScreenWithCheck := nil; Display.CheckOK := true; end; - SDL_MOUSEBUTTONDOWN: + + SDL_MOUSEMOTION, SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP: begin -{ - with Event.button do + if (Ini.Mouse > 0) then begin - if State = SDL_BUTTON_LEFT then + case Event.type_ of + SDL_MOUSEMOTION: + begin + mouseDown := false; + mouseBtn := 0; + end; + SDL_MOUSEBUTTONDOWN: + begin + mouseDown := true; + mouseBtn := Event.button.button; + end; + SDL_MOUSEBUTTONUP: + begin + mouseDown := false; + mouseBtn := Event.button.button; + end; + end; + + Display.MoveCursor(Event.button.X * 800 / Screen.w, + Event.button.Y * 600 / Screen.h, + mouseDown and ((mouseBtn <> SDL_BUTTON_WHEELDOWN) or (mouseBtn <> SDL_BUTTON_WHEELUP))); + + if (ScreenPopupError <> nil) and (ScreenPopupError.Visible) then + done := not ScreenPopupError.ParseMouse(mouseBtn, mouseDown, Event.button.x, Event.button.y) + else if (ScreenPopupCheck <> nil) and (ScreenPopupCheck.Visible) then + done := not ScreenPopupCheck.ParseMouse(mouseBtn, mouseDown, Event.button.x, Event.button.y) + else begin - // + done := not Display.CurrentScreen^.ParseMouse(mouseBtn, mouseDown, Event.button.x, Event.button.y); + + // if screen wants to exit + if done then + DoQuit; end; end; -} end; SDL_VIDEORESIZE: begin @@ -442,14 +485,14 @@ begin if boolean( Ini.FullScreen ) then begin SDL_SetVideoMode(ScreenW, ScreenH, (Ini.Depth+1) * 16, SDL_OPENGL or SDL_FULLSCREEN); - SDL_ShowCursor(0); end else begin SDL_SetVideoMode(ScreenW, ScreenH, (Ini.Depth+1) * 16, SDL_OPENGL or SDL_RESIZABLE); - SDL_ShowCursor(1); end; + Display.SetCursor; + glViewPort(0, 0, ScreenW, ScreenH); {$IFEND} end @@ -469,19 +512,7 @@ begin // 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.CurrentScreen^.CheckFadeTo(nil,'MSG_QUIT_USDX'); - end - else // if ask-for-exit is disabled then simply exit - begin - Display.Fade := 0; - Display.NextScreenWithCheck := nil; - Display.CheckOK := true; - end; - end; + DoQuit; end; end; diff --git a/unicode/src/base/UMusic.pas b/unicode/src/base/UMusic.pas index 19c3b942..5fc9805f 100644 --- a/unicode/src/base/UMusic.pas +++ b/unicode/src/base/UMusic.pas @@ -36,7 +36,8 @@ interface uses UTime, SysUtils, - Classes; + Classes, + UBeatTimer; type TNoteType = (ntFreestyle, ntNormal, ntGolden); @@ -99,51 +100,6 @@ type Line: array of TLine; end; - (** - * TLyricsState contains all information concerning the - * state of the lyrics, e.g. the current beat or duration of the lyrics. - *) - TLyricsState = class - private - Timer: TRelativeTimer; // keeps track of the current time - public - OldBeat: integer; // previous discovered beat - CurrentBeat: integer; // current beat (rounded) - MidBeat: real; // current beat (float) - - // now we use this for super synchronization! - // only used when analyzing voice - // TODO: change ...D to ...Detect(ed) - OldBeatD: integer; // previous discovered beat - CurrentBeatD: integer; // current discovered beat (rounded) - MidBeatD: real; // current discovered beat (float) - - // we use this for audible clicks - // TODO: Change ...C to ...Click - OldBeatC: integer; // previous discovered beat - CurrentBeatC: integer; - MidBeatC: real; // like CurrentBeatC - - OldLine: integer; // previous displayed sentence - - StartTime: real; // time till start of lyrics (= Gap) - TotalTime: real; // total song time - - constructor Create(); - procedure Pause(); - procedure Resume(); - - procedure Reset(); - procedure UpdateBeats(); - - (** - * current song time (in seconds) used as base-timer for lyrics etc. - *) - function GetCurrentTime(): real; - procedure SetCurrentTime(Time: real); - end; - - const FFTSize = 512; // size of FFT data (output: FFTSize/2 values) type @@ -977,92 +933,6 @@ begin end; end; - -{ TVoiceRemoval } - -constructor TLyricsState.Create(); -begin - // create a triggered timer, so we can Pause() it, set the time - // and Resume() it afterwards for better synching. - Timer := TRelativeTimer.Create(true); - - // reset state - Reset(); -end; - -procedure TLyricsState.Pause(); -begin - Timer.Pause(); -end; - -procedure TLyricsState.Resume(); -begin - Timer.Resume(); -end; - -procedure TLyricsState.SetCurrentTime(Time: real); -begin - // do not start the timer (if not started already), - // after setting the current time - Timer.SetTime(Time, false); -end; - -function TLyricsState.GetCurrentTime(): real; -begin - Result := Timer.GetTime(); -end; - -(** - * Resets the timer and state of the lyrics. - * The timer will be stopped afterwards so you have to call Resume() - * to start the lyrics timer. - *) -procedure TLyricsState.Reset(); -begin - Pause(); - SetCurrentTime(0); - - StartTime := 0; - TotalTime := 0; - - OldBeat := -1; - MidBeat := -1; - CurrentBeat := -1; - - OldBeatC := -1; - MidBeatC := -1; - CurrentBeatC := -1; - - OldBeatD := -1; - MidBeatD := -1; - CurrentBeatD := -1; -end; - -(** - * Updates the beat information (CurrentBeat/MidBeat/...) according to the - * current lyric time. - *) -procedure TLyricsState.UpdateBeats(); -var - CurLyricsTime: real; -begin - CurLyricsTime := GetCurrentTime(); - - OldBeat := CurrentBeat; - MidBeat := GetMidBeat(CurLyricsTime - StartTime / 1000); - CurrentBeat := Floor(MidBeat); - - OldBeatC := CurrentBeatC; - MidBeatC := GetMidBeat(CurLyricsTime - StartTime / 1000); - CurrentBeatC := Floor(MidBeatC); - - OldBeatD := CurrentBeatD; - // MidBeatD = MidBeat with additional GAP - MidBeatD := -0.5 + GetMidBeat(CurLyricsTime - (StartTime + 120 + 20) / 1000); - CurrentBeatD := Floor(MidBeatD); -end; - - { TAudioConverter } function TAudioConverter.Init(SrcFormatInfo: TAudioFormatInfo; DstFormatInfo: TAudioFormatInfo): boolean; diff --git a/unicode/src/base/UNote.pas b/unicode/src/base/UNote.pas index 5e70bfe1..6da4cf07 100644 --- a/unicode/src/base/UNote.pas +++ b/unicode/src/base/UNote.pas @@ -126,12 +126,10 @@ uses UDLLManager, UParty, UConfig, - UCore, UCommon, UGraphic, UGraphicClasses, UPath, - UPluginDefs, UPlatform, UThemes; diff --git a/unicode/src/base/UParty.pas b/unicode/src/base/UParty.pas index 937aab78..b02d13be 100644 --- a/unicode/src/base/UParty.pas +++ b/unicode/src/base/UParty.pas @@ -34,208 +34,85 @@ interface {$I switches.inc} uses - UPartyDefs, - UCoreModule, - UPluginDefs; + ModiSDK; type - ARounds = array [0..252] of integer; //0..252 needed for - PARounds = ^ARounds; - TRoundInfo = record - Modi: cardinal; + Plugin: word; Winner: byte; end; TeamOrderEntry = record - Teamnum: byte; - Score: byte; + TeamNum: byte; + Score: byte; end; TeamOrderArray = array[0..5] of byte; - TUS_ModiInfoEx = record - Info: TUS_ModiInfo; - Owner: integer; - TimesPlayed: byte; //Helper for setting round plugins + TPartyPlugin = record + ID: byte; + TimesPlayed: byte; end; - TPartySession = class (TCoreModule) + TPartySession = class private - bPartyMode: boolean; //Is this party or single player - CurRound: byte; - - Modis: array of TUS_ModiInfoEx; - Teams: TTeamInfo; - + function GetRandomPlayer(Team: byte): byte; + function GetRandomPlugin(Plugins: array of TPartyPlugin): byte; function IsWinner(Player, Winner: byte): boolean; procedure GenScores; - function GetRandomPlugin(TeamMode: boolean): cardinal; - function GetRandomPlayer(Team: byte): byte; public - //Teams: TTeamInfo; - Rounds: array of TRoundInfo; - - //TCoreModule methods to inherit - constructor Create; override; - procedure Info(const pInfo: PModuleInfo); override; - function Load: boolean; override; - function Init: boolean; override; - procedure DeInit; override; - destructor Destroy; override; - - //Register modus service - function RegisterModi(nothin: TwParam; pModiInfo: TlParam): integer; //Registers a new modus. wParam: Pointer to TUS_ModiInfo - - //Start new Party - function StartParty(NumRounds: TwParam; PAofIRounds: TlParam): integer; //Starts new party mode. Returns non zero on success - function GetCurModi(wParam: TwParam; lParam: TlParam): integer; //Returns pointer to cur. Modis TUS_ModiInfo (to Use with Singscreen) - function StopParty(wParam: TwParam; lParam: TlParam): integer; //Stops party mode. Returns 1 if party mode was enabled before. - function NextRound(wParam: TwParam; lParam: TlParam): integer; //Increases curround by 1; Returns num of round or -1 if last round is already played - - function CallModiInit(wParam: TwParam; lParam: TlParam): integer; //Calls curmodis init proc. If an error occurs, returns nonzero. In this case a new plugin was selected. Please renew loading - function CallModiDeInit(wParam: TwParam; lParam: TlParam): integer; //Calls DeInitProc and ends the round - - function GetTeamInfo(wParam: TwParam; pTeamInfo: TlParam): integer; //Writes TTeamInfo record to pointer at lParam. Returns zero on success - function SetTeamInfo(wParam: TwParam; pTeamInfo: TlParam): integer; //Read TTeamInfo record from pointer at lParam. Returns zero on success - - function GetTeamOrder(wParam: TwParam; lParam: TlParam): integer; //Returns team order. Structure: Bits 1..3: Team at place1; Bits 4..6: Team at place2 ... - function GetWinnerString(wParam: TwParam; lParam: TlParam): integer; //wParam is roundnum. If (Pointer = nil) then return length of the string. Otherwise write the string to address at lParam + 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; -const - StandardModus = 0; //Modus ID that will be played in non-party mode +var + PartySession: TPartySession; implementation uses - UCore, + UDLLManager, UGraphic, - ULanguage, - ULog, UNote, - SysUtils; - -{********************* - TPluginLoader - Implentation -*********************} - -//------------- -// function that gives some infos about the module to the core -//------------- -procedure TPartySession.Info(const pInfo: PModuleInfo); -begin - pInfo^.Name := 'TPartySession'; - pInfo^.Version := MakeVersion(1,0,0,chr(0)); - pInfo^.Description := 'Manages party modi and party game'; -end; + ULanguage, + ULog; -//------------- -// Just the constructor -//------------- constructor TPartySession.Create; begin inherited; - //UnSet PartyMode - bPartyMode := false; -end; - -//------------- -//Is called on loading. -//In this method only events and services should be created -//to offer them to other modules or plugins during the init process -//If false is returned this will cause a forced exit -//------------- -function TPartySession.Load: boolean; -begin - //Add register party modus service - Result := true; - Core.Services.AddService('Party/RegisterModi', nil, Self.RegisterModi); - Core.Services.AddService('Party/StartParty', nil, Self.StartParty); - Core.Services.AddService('Party/GetCurModi', nil, Self.GetCurModi); -end; - -//------------- -//Is called on init process -//In this method you can hook some events and create + init -//your classes, variables etc. -//If false is returned this will cause a forced exit -//------------- -function TPartySession.Init: boolean; -begin - //Just set private var to true. - Result := true; -end; - -//------------- -//Is called if this module has been inited and there is an exit. -//Deinit is in reverse initing order -//------------- -procedure TPartySession.DeInit; -begin - //Force DeInit -end; - -//------------- -//Is called if this module will be unloaded and has been created -//Should be used to free memory -//------------- -destructor TPartySession.Destroy; -begin - //Just save some memory if it wasn't done now.. - SetLength(Modis, 0); - inherited; -end; - -//------------- -// Registers a new modus. wParam: Pointer to TUS_ModiInfo -// Service for plugins -//------------- -function TPartySession.RegisterModi(nothin: TwParam; pModiInfo: TlParam): integer; -var - Len: integer; - Info: PUS_ModiInfo; -begin - Info := PModiInfo; - //Copy Info if cbSize is correct - if (Info.cbSize = SizeOf(TUS_ModiInfo)) then - begin - Len := Length(Modis); - SetLength(Modis, Len + 1); - - Modis[Len].Info := Info^; - end - else - Core.ReportError(integer(PChar('Plugins try to register modus with wrong pointer, or wrong TUS_ModiInfo record.')), PChar('TPartySession')); - - // FIXME: return a valid result - Result := 0; end; //---------- // Returns a number of a random plugin //---------- -function TPartySession.GetRandomPlugin(TeamMode: boolean): cardinal; +function TPartySession.GetRandomPlugin(Plugins: array of TPartyPlugin): byte; var - LowestTP: byte; + LowestTP: byte; NumPwithLTP: word; - I: integer; - R: word; + I: integer; + R: word; begin - Result := StandardModus; //If there are no matching modi, play standard modus LowestTP := high(byte); NumPwithLTP := 0; //Search for Plugins not often played yet - for I := 0 to high(Modis) do + for I := 0 to high(Plugins) do begin - if (Modis[I].TimesPlayed < lowestTP) and (((Modis[I].Info.LoadingSettings and MLS_TeamOnly) <> 0) = TeamMode) then + if (Plugins[I].TimesPlayed < lowestTP) then begin - lowestTP := Modis[I].TimesPlayed; + lowestTP := Plugins[I].TimesPlayed; NumPwithLTP := 1; end - else if (Modis[I].TimesPlayed = lowestTP) and (((Modis[I].Info.LoadingSettings and MLS_TeamOnly) <> 0) = TeamMode) then + else if (Plugins[I].TimesPlayed = lowestTP) then begin Inc(NumPwithLTP); end; @@ -245,118 +122,97 @@ begin R := Random(NumPwithLTP); //Search for random plugin - for I := 0 to high(Modis) do + for I := 0 to high(Plugins) do begin - if (Modis[I].TimesPlayed = lowestTP) and (((Modis[I].Info.LoadingSettings and MLS_TeamOnly) <> 0) = TeamMode) then + if Plugins[I].TimesPlayed = LowestTP then begin //Plugin found if (R = 0) then begin - Result := I; - Inc(Modis[I].TimesPlayed); + Result := Plugins[I].ID; + Inc(Plugins[I].TimesPlayed); Break; end; - Dec(R); end; end; end; //---------- -// Starts new party mode. Returns non zero on success +//StartNewParty - Reset and prepares for new party //---------- -function TPartySession.StartParty(NumRounds: TwParam; PAofIRounds: TlParam): integer; +procedure TPartySession.StartNewParty(NumRounds: byte); var - I: integer; - aiRounds: PARounds; + Plugins: array of TPartyPlugin; TeamMode: boolean; + Len: integer; + I, J: integer; begin - Result := 0; - if (Teams.NumTeams >= 1) and (NumRounds < High(byte)-1) then - begin - bPartyMode := false; - aiRounds := PAofIRounds; - - try - //Is this team mode (More than one player per team) ? - TeamMode := true; - for I := 0 to Teams.NumTeams-1 do - TeamMode := TeamMode and (Teams.Teaminfo[I].NumPlayers > 1); - - //Set Rounds - SetLength(Rounds, NumRounds); - - for I := 0 to High(Rounds) do - begin //Set plugins - if (aiRounds[I] = -1) then - Rounds[I].Modi := GetRandomPlugin(TeamMode) - else if (aiRounds[I] >= 0) and (aiRounds[I] <= High(Modis)) and (TeamMode or ((Modis[aiRounds[I]].Info.LoadingSettings and MLS_TeamOnly) = 0)) then - Rounds[I].Modi := aiRounds[I] - else - Rounds[I].Modi := StandardModus; - - Rounds[I].Winner := High(byte); //Set winner to not played - end; - - CurRound := High(byte); //Set CurRound to not defined + //Set current round to 1 + CurRound := 255; - //Return true and set party mode - bPartyMode := true; - Result := 1; + PlayersPlay := Teams.NumTeams; - except - Core.ReportError(integer(PChar('Can''t start party mode.')), PChar('TPartySession')); + //Get team-mode 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; -end; -//---------- -// Returns pointer to Cur. ModiInfoEx (to use with sing screen) -//---------- -function TPartySession.GetCurModi(wParam: TwParam; lParam: TlParam): integer; -begin - if (bPartyMode) and (CurRound <= High(Rounds)) then - begin //If PartyMode is enabled: - //Return the Plugin of the Cur Round - Result := integer(@Modis[Rounds[CurRound].Modi]); - end - else - begin //Return standard modus - Result := integer(@Modis[StandardModus]); + //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 those plugins playable with current PlayerConfiguration + Len := Length(Plugins); + SetLength(Plugins, Len + 1); + Plugins[Len].ID := I; + Plugins[Len].TimesPlayed := 0; + end; end; -end; -//---------- -// Stops party mode. Returns 1 if party mode was enabled before and -1 if change was not possible -//---------- -function TPartySession.StopParty(wParam: TwParam; lParam: TlParam): integer; -begin - Result := -1; - if (bPartyMode) then + //Set rounds + if (Length(Plugins) >= 1) then begin - // to-do : Whitü: Check here if sing screen is not shown atm. - bPartyMode := false; - Result := 1; + SetLength (Rounds, NumRounds); + for I := 0 to NumRounds - 1 do + begin + PartySession.Rounds[I].Plugin := GetRandomPlugin(Plugins); + PartySession.Rounds[I].Winner := 255; + end; end else - Result := 0; + SetLength (Rounds, 0); end; -//---------- -//GetRandomPlayer - gives back a random player to play next round -//---------- +{** + * Returns a random player to play next round + *} function TPartySession.GetRandomPlayer(Team: byte): byte; var - I, R: integer; - lowestTP: byte; + I, R: integer; + LowestTP: byte; NumPwithLTP: byte; begin - LowestTP := high(byte); + LowestTP := high(byte); NumPwithLTP := 0; - Result := 0; + Result := 0; //Search for players that have not often played yet - for I := 0 to Teams.Teaminfo[Team].NumPlayers-1 do + for I := 0 to Teams.Teaminfo[Team].NumPlayers - 1 do begin if (Teams.Teaminfo[Team].Playerinfo[I].TimesPlayed < lowestTP) then begin @@ -369,11 +225,11 @@ begin end; end; - //Create random no + //Create random number R := Random(NumPwithLTP); //Search for random player - for I := 0 to Teams.Teaminfo[Team].NumPlayers-1 do + for I := 0 to Teams.Teaminfo[Team].NumPlayers - 1 do begin if Teams.Teaminfo[Team].Playerinfo[I].TimesPlayed = lowestTP then begin @@ -389,212 +245,93 @@ begin end; end; -//---------- -// NextRound - Increases CurRound by 1; Returns num of round or -1 if last round is already played -//---------- -function TPartySession.NextRound(wParam: TwParam; lParam: TlParam): integer; +{** + * Prepares ScreenSingModi for next round and loads plugin + *} +procedure TPartySession.StartRound; var I: integer; begin if ((CurRound < high(Rounds)) or (CurRound = high(CurRound))) then - begin //everythings OK! -> Start the Round, maaaaan + begin + //Increase Current Round Inc(CurRound); - //Set Players to play this Round - for I := 0 to Teams.NumTeams-1 do - Teams.Teaminfo[I].CurPlayer := GetRandomPlayer(I); - - // FIXME: return a valid result - Result := 0; - end - else - Result := -1; -end; - -//---------- -//IsWinner - returns true if the players bit is set in the winner byte -//---------- -function TPartySession.IsWinner(Player, Winner: byte): boolean; -var - Bit: byte; -begin - Bit := 1 shl Player; - - Result := ((Winner and Bit) = Bit); -end; - -//---------- -//GenScores - inc scores for cur. round -//---------- -procedure TPartySession.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; + Rounds[CurRound].Winner := 255; + DllMan.LoadPlugin(Rounds[CurRound].Plugin); -//---------- -// CallModiInit - calls CurModis Init Proc. If an error occurs, returns nonzero. In this case a new plugin was selected. Please renew loading -//---------- -function TPartySession.CallModiInit(wParam: TwParam; lParam: TlParam): integer; -begin - if (not bPartyMode) then - begin //Set rounds if not in party mode - SetLength(Rounds, 1); - Rounds[0].Modi := StandardModus; - Rounds[0].Winner := High(byte); - CurRound := 0; - end; + //Select Players + for I := 0 to Teams.NumTeams - 1 do + Teams.Teaminfo[I].CurPlayer := GetRandomPlayer(I); - try - //Core. - except - on E : Exception do - begin - Core.ReportError(integer(PChar('Error starting modus: ' + Modis[Rounds[CurRound].Modi].Info.Name + ' ErrorStr: ' + E.Message)), PChar('TPartySession')); - if (Rounds[CurRound].Modi = StandardModus) then - begin - Core.ReportError(integer(PChar('Can''t start standard modus, will exit now!')), PChar('TPartySession')); - Halt; - end - else //Select standard modus - begin - Rounds[CurRound].Modi := StandardModus - end; - end; + //Set ScreenSingModie Variables + ScreenSingModi.TeamInfo := Teams; end; - - // FIXME: return a valid result - Result := 0; end; //---------- -// CallModiDeInit - calls DeInitProc and ends the round +//EndRound - Get Winner from ScreenSingModi and Save Data to RoundArray //---------- -function TPartySession.CallModiDeInit(wParam: TwParam; lParam: TlParam): integer; +procedure TPartySession.EndRound; var - I: integer; - MaxScore: word; + I: Integer; begin - if (bPartyMode) then - begin - //Get Winner Byte! - if (@Modis[Rounds[CurRound].Modi].Info.ModiDeInit <> nil) then //get winners from plugin - Rounds[CurRound].Winner := Modis[Rounds[CurRound].Modi].Info.ModiDeInit(Modis[Rounds[CurRound].Modi].Info.ID) - else - begin //Create winners by score :/ - Rounds[CurRound].Winner := 0; - MaxScore := 0; - for I := 0 to Teams.NumTeams-1 do - begin - // to-do : recode percentage stuff - //PlayerInfo.Playerinfo[I].Percentage := PlayerInfo.Playerinfo[I].Score div 9999; - if (Player[I].ScoreTotalInt > MaxScore) then - begin - MaxScore := Player[I].ScoreTotalInt; - Rounds[CurRound].Winner := 1 shl I; - end - else if (Player[I].ScoreTotalInt = MaxScore) and (Player[I].ScoreTotalInt <> 0) then - begin - Rounds[CurRound].Winner := Rounds[CurRound].Winner or (1 shl I); - end; - end; - - - //When nobody has points -> everybody looses - if (MaxScore = 0) then - Rounds[CurRound].Winner := 0; - - end; + //Copy Winner + Rounds[CurRound].Winner := ScreenSingModi.Winner; + //Set Scores + GenScores; - //Generate the 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); - //Inc players TimesPlayed - if ((Modis[Rounds[CurRound-1].Modi].Info.LoadingSettings and MLS_IncTP) = MLS_IncTP) then - begin - for I := 0 to Teams.NumTeams-1 do - Inc(Teams.TeamInfo[I].Playerinfo[Teams.TeamInfo[I].CurPlayer].TimesPlayed); - end; - end - else if (@Modis[Rounds[CurRound].Modi].Info.ModiDeInit <> nil) then - Modis[Rounds[CurRound].Modi].Info.ModiDeInit(Modis[Rounds[CurRound].Modi].Info.ID); - - // FIXME: return a valid result - Result := 0; end; //---------- -// GetTeamInfo - writes TTeamInfo record to pointer at lParam. Returns zero on success +//IsWinner - returns true if the player's bit is set in the winner byte //---------- -function TPartySession.GetTeamInfo(wParam: TwParam; pTeamInfo: TlParam): integer; +function TPartySession.IsWinner(Player, Winner: byte): boolean; var - Info: ^TTeamInfo; + Mask: byte; begin - Result := -1; - Info := pTeamInfo; - if (Info <> nil) then - begin - try - // to - do : Check Delphi memory management in this case - //Not sure if i had to copy PChars to a new address or if delphi manages this o0 - Info^ := Teams; - Result := 0; - except - Result := -2; - end; - end; + Mask := 1 shl Player; + Result := (Winner and Mask) <> 0; end; //---------- -// SetTeamInfo - read TTeamInfo record from pointer at lParam. Returns zero on success +//GenScores - increase scores for current round //---------- -function TPartySession.SetTeamInfo(wParam: TwParam; pTeamInfo: TlParam): integer; +procedure TPartySession.GenScores; var - TeamInfobackup: TTeamInfo; - Info: ^TTeamInfo; + I: byte; begin - Result := -1; - Info := pTeamInfo; - if (Info <> nil) then + for I := 0 to Teams.NumTeams - 1 do begin - try - TeamInfoBackup := Teams; - // to - do : Check Delphi memory management in this case - //Not sure if i had to copy PChars to a new address or if delphi manages this o0 - Teams := Info^; - Result := 0; - except - Teams := TeamInfoBackup; - Result := -2; - end; + if isWinner(I, Rounds[CurRound].Winner) then + Inc(Teams.Teaminfo[I].Score); end; end; //---------- -// GetTeamOrder - returns team order. Structure: Bits 1..3: Team at place1; Bits 4..6: Team at place2 ... +//GetTeamOrder - returns the placement of each Team [First Position of Array is Teamnum of first placed Team, ...] //---------- -function TPartySession.GetTeamOrder(wParam: TwParam; lParam: TlParam): integer; +function TPartySession.GetTeamOrder: TeamOrderArray; var - I, J: integer; - ATeams: array [0..5] of TeamOrderEntry; + I, J: integer; + ATeams: array [0..5] of TeamOrderEntry; TempTeam: TeamOrderEntry; begin - // to-do : PartyMode: Write this in another way, so that teams with the same score get the same place + // TODO: PartyMode: Write this in another way, so that teams with the same score get the same place //Fill Team array - for I := 0 to Teams.NumTeams-1 do + 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 + 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]; @@ -603,63 +340,44 @@ begin end; //Copy to Result - Result := 0; for I := 0 to Teams.NumTeams-1 do - Result := Result or (ATeams[I].TeamNum Shl I*3); + Result[I] := ATeams[I].TeamNum; end; //---------- -// GetWinnerString - wParam is Roundnum. If (pointer = nil) then return length of the string. Otherwise write the string to address at lParam +//GetWinnerString - Get string with WinnerTeam Name, when there is more than one Winner than Connect with and or , //---------- -function TPartySession.GetWinnerString(wParam: TwParam; lParam: TlParam): integer; +function TPartySession.GetWinnerString(Round: byte): string; var Winners: array of UTF8String; - I: integer; - ResultStr: String; - S: ^String; + I: integer; begin - ResultStr := Language.Translate('PARTY_NOBODY'); + Result := Language.Translate('PARTY_NOBODY'); + + if (Round > High(Rounds)) then + exit; - if (wParam <= High(Rounds)) then + if (Rounds[Round].Winner = 0) then begin - if (Rounds[wParam].Winner <> 0) then - begin - if (Rounds[wParam].Winner = 255) then - begin - ResultStr := Language.Translate('PARTY_NOTPLAYEDYET'); - end - else - begin - SetLength(Winners, 0); - for I := 0 to Teams.NumTeams-1 do - begin - if isWinner(I, Rounds[wParam].Winner) then - begin - SetLength(Winners, Length(Winners) + 1); - Winners[high(Winners)] := Teams.TeamInfo[I].Name; - end; - end; - ResultStr := Language.Implode(Winners); - end; - end; + exit; end; - //Now return what we have got - if (lParam = nil) then - begin //Return string length - Result := Length(ResultStr); - end - else - begin //Return string - try - S := lParam; - S^ := ResultStr; - Result := 0; - except - Result := -1; + 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; end. diff --git a/unicode/src/base/UPlatform.pas b/unicode/src/base/UPlatform.pas index e4cb6f0c..6f13481c 100644 --- a/unicode/src/base/UPlatform.pas +++ b/unicode/src/base/UPlatform.pas @@ -43,9 +43,9 @@ uses type TDirectoryEntry = record - Name : WideString; - IsDirectory : boolean; - IsFile : boolean; + Name: WideString; + IsDirectory: boolean; + IsFile: boolean; end; TDirectoryEntryArray = array of TDirectoryEntry; @@ -54,12 +54,12 @@ type function GetExecutionDir(): string; procedure Init; virtual; function DirectoryFindFiles(Dir, Filter: WideString; ReturnAllSubDirs: boolean): TDirectoryEntryArray; virtual; abstract; - function TerminateIfAlreadyRunning(var WndTitle : string): boolean; virtual; + function TerminateIfAlreadyRunning(var WndTitle: string): boolean; virtual; function FindSongFile(Dir, Mask: WideString): WideString; virtual; procedure Halt; virtual; - function GetLogPath : WideString; virtual; abstract; - function GetGameSharedPath : WideString; virtual; abstract; - function GetGameUserPath : WideString; virtual; abstract; + function GetLogPath: WideString; virtual; abstract; + function GetGameSharedPath: WideString; virtual; abstract; + function GetGameUserPath: WideString; virtual; abstract; function CopyFile(const Source, Target: WideString; FailIfExists: boolean): boolean; virtual; end; @@ -79,13 +79,13 @@ uses ULog; -// I have modified it to use the Platform_singleton in this location ( in the implementaiton ) +// I modified it to use the Platform_singleton in this location (in the implementation) // so that this variable can NOT be overwritten from anywhere else in the application. // the accessor function platform, emulates all previous calls to work the same way. var - Platform_singleton : TPlatform; + Platform_singleton: TPlatform; -function Platform : TPlatform; +function Platform: TPlatform; begin Result := Platform_singleton; end; @@ -117,7 +117,7 @@ end; (** * Default TerminateIfAlreadyRunning() implementation *) -function TPlatform.TerminateIfAlreadyRunning(var WndTitle : string): Boolean; +function TPlatform.TerminateIfAlreadyRunning(var WndTitle: string): boolean; begin Result := false; end; @@ -143,7 +143,7 @@ const var SourceFile, TargetFile: TFileStream; FileCopyBuffer: array [0..COPY_BUFFER_SIZE-1] of byte; // temporary copy-buffer. - NumberOfBytes: integer; // number of bytes read from SourceFile + NumberOfBytes: integer; // number of bytes read from SourceFile begin Result := false; SourceFile := nil; diff --git a/unicode/src/base/URecord.pas b/unicode/src/base/URecord.pas index 8f37262d..2c2093a0 100644 --- a/unicode/src/base/URecord.pas +++ b/unicode/src/base/URecord.pas @@ -54,7 +54,7 @@ type function GetToneString: string; // converts a tone to its string represenatation; - procedure BoostBuffer(Buffer: PByteArray; Size: cardinal); + procedure BoostBuffer(Buffer: PByteArray; Size: integer); procedure ProcessNewBuffer(Buffer: PByteArray; BufferSize: integer); // we call it to analyze sound by checking Autocorrelation @@ -135,7 +135,7 @@ type procedure UpdateInputDeviceConfig; // handle microphone input - procedure HandleMicrophoneData(Buffer: PByteArray; Size: cardinal; + procedure HandleMicrophoneData(Buffer: PByteArray; Size: integer; InputDevice: TAudioInputDevice); end; @@ -459,7 +459,7 @@ begin Result := '-'; end; -procedure TCaptureBuffer.BoostBuffer(Buffer: PByteArray; Size: cardinal); +procedure TCaptureBuffer.BoostBuffer(Buffer: PByteArray; Size: integer); var i: integer; Value: longint; @@ -602,7 +602,7 @@ end; * Length - number of bytes in Buffer * Input - Soundcard-Input used for capture *} -procedure TAudioInputProcessor.HandleMicrophoneData(Buffer: PByteArray; Size: cardinal; InputDevice: TAudioInputDevice); +procedure TAudioInputProcessor.HandleMicrophoneData(Buffer: PByteArray; Size: integer; InputDevice: TAudioInputDevice); var MultiChannelBuffer: PByteArray; // buffer handled as array of bytes (offset relative to channel) SingleChannelBuffer: PByteArray; // temporary buffer for new samples per channel @@ -611,13 +611,11 @@ var CaptureChannel: TCaptureBuffer; AudioFormat: TAudioFormatInfo; SampleSize: integer; - SampleCount: integer; SamplesPerChannel: integer; i: integer; begin AudioFormat := InputDevice.AudioFormat; SampleSize := AudioSampleSize[AudioFormat.Format]; - SampleCount := Size div SampleSize; SamplesPerChannel := Size div AudioFormat.FrameSize; SingleChannelBufferSize := SamplesPerChannel * SampleSize; diff --git a/unicode/src/base/USingScores.pas b/unicode/src/base/USingScores.pas index 2d9b1e5e..c998644b 100644 --- a/unicode/src/base/USingScores.pas +++ b/unicode/src/base/USingScores.pas @@ -34,211 +34,211 @@ interface {$I switches.inc} uses - UThemes, gl, + UThemes, UTexture; ////////////////////////////////////////////////////////////// // ATTENTION: // -// Enabled Flag does not Work atm. This should cause Popups // -// Not to Move and Scores to stay until Renenabling. // -// To use e.g. in Pause Mode // -// Also InVisible Flag causes Attributes not to change. // -// This should be fixed after next Draw when Visible = True,// -// but not testet yet // +// Enabled flag does not work atm. This should cause popups // +// not to move and scores to stay until re-enabling. // +// To use e.g. in pause mode // +// also invisible flag causes attributes not to change. // +// This should be fixed after next draw when visible = true,// +// but not tested yet // ////////////////////////////////////////////////////////////// -//Some constants containing options that could change by time +// some constants containing options that could change by time const - MaxPlayers = 6; //Maximum of Players that could be added - MaxPositions = 6; //Maximum of Score Positions that could be added + MaxPlayers = 6; // maximum of players that could be added + MaxPositions = 6; // maximum of score positions that could be added type //----------- - // TScorePlayer - Record Containing Information about a Players Score + // TScorePlayer - record containing information about a players score //----------- TScorePlayer = record - Position: Byte; //Index of the Position where the Player should be Drawn - Enabled: Boolean; //Is the Score Display Enabled - Visible: Boolean; //Is the Score Display Visible - Score: Word; //Current Score of the Player - ScoreDisplayed: Word; //Score cur. Displayed(for counting up) - ScoreBG: TTexture;//Texture of the Players Scores BG - Color: TRGB; //Teh Players Color - RBPos: Real; //Cur. Percentille of the Rating Bar - RBTarget: Real; //Target Position of Rating Bar - RBVisible:Boolean; //Is Rating bar Drawn + Position: byte; // index of the position where the player should be drawn + Enabled: boolean; // is the score display enabled + Visible: boolean; // is the score display visible + Score: word; // current score of the player + ScoreDisplayed: word; // score cur. displayed (for counting up) + ScoreBG: TTexture; // texture of the players scores bg + Color: TRGB; // the players color + RBPos: real; // cur. percentille of the rating bar + RBTarget: real; // target position of rating bar + RBVisible: boolean; // is rating bar drawn end; - aScorePlayer = array[0..MaxPlayers-1] of TScorePlayer; + aScorePlayer = array [0..MaxPlayers-1] of TScorePlayer; //----------- - // TScorePosition - Record Containing Information about a Score Position, that can be used + // TScorePosition - record containing information about a score position, that can be used //----------- PScorePosition = ^TScorePosition; TScorePosition = record - //The Position is Used for Which Playercount - PlayerCount: Byte; - // 1 - One Player per Screen - // 2 - 2 Players per Screen - // 4 - 3 Players per Screen - // 6 would be 2 and 3 Players per Screen - - BGX: Real; //X Position of the Score BG - BGY: Real; //Y Position of the Score BG - BGW: Real; //Width of the Score BG - BGH: Real; //Height of the Score BG - - RBX: Real; //X Position of the Rating Bar - RBY: Real; //Y Position of the Rating Bar - RBW: Real; //Width of the Rating Bar - RBH: Real; //Height of the Rating Bar - - TextX: Real; //X Position of the Score Text - TextY: Real; //Y Position of the Score Text - TextFont: Byte; //Font of the Score Text - TextSize: integer; //Size of the Score Text - - PUW: Real; //Width of the LineBonus Popup - PUH: Real; //Height of the LineBonus Popup - PUFont: Byte; //Font for the PopUps - PUFontSize: integer; //FontSize for the PopUps - PUStartX: Real; //X Start Position of the LineBonus Popup - PUStartY: Real; //Y Start Position of the LineBonus Popup - PUTargetX: Real; //X Target Position of the LineBonus Popup - PUTargetY: Real; //Y Target Position of the LineBonus Popup + // the position is used for which playercount + PlayerCount: byte; + // 1 - 1 player per screen + // 2 - 2 players per screen + // 4 - 3 players per screen + // 6 would be 2 and 3 players per screen + + BGX: real; // x position of the score bg + BGY: real; // y position of the score bg + BGW: real; // width of the score bg + BGH: real; // height of the score bg + + RBX: real; // x position of the rating bar + RBY: real; // y position of the rating bar + RBW: real; // width of the rating bar + RBH: real; // height of the rating bar + + TextX: real; // x position of the score text + TextY: real; // y position of the score text + TextFont: byte; // font of the score text + TextSize: integer; // size of the score text + + PUW: real; // width of the line bonus popup + PUH: real; // height of the line bonus popup + PUFont: byte; // font for the popups + PUFontSize: integer; // font size for the popups + PUStartX: real; // x start position of the line bonus popup + PUStartY: real; // y start position of the line bonus popup + PUTargetX: real; // x target position of the line bonus popup + PUTargetY: real; // y target position of the line bonus popup end; - aScorePosition = array[0..MaxPositions-1] of TScorePosition; + aScorePosition = array [0..MaxPositions-1] of TScorePosition; //----------- - // TScorePopUp - Record Containing Information about a LineBonus Popup - // List, Next Item is Saved in Next attribute + // TScorePopUp - record containing information about a line bonus popup + // list, next item is saved in next attribute //----------- PScorePopUp = ^TScorePopUp; TScorePopUp = record - Player: Byte; //Index of the PopUps Player - TimeStamp: Cardinal; //Timestamp of Popups Spawn - Rating: Byte; //0 to 8, Type of Rating (Cool, bad, etc.) - ScoreGiven:Word; //Score that has already been given to the Player - ScoreDiff: Word; //Difference Between Cur Score at Spawn and Old Score - Next: PScorePopUp; //Next Item in List + Player: byte; // index of the popups player + TimeStamp: cardinal; // timestamp of popups spawn + Rating: byte; // 0 to 8, type of rating (cool, bad, etc.) + ScoreGiven: word; // score that has already been given to the player + ScoreDiff: word; // difference between cur score at spawn and old score + Next: PScorePopUp; // next item in list end; aScorePopUp = array of TScorePopUp; //----------- - // TSingScores - Class containing Scores Positions and Drawing Scores, Rating Bar + Popups + // TSingScores - class containing scores positions and drawing scores, rating bar + popups //----------- TSingScores = class private Positions: aScorePosition; - aPlayers: aScorePlayer; - oPositionCount: Byte; - oPlayerCount: Byte; + aPlayers: aScorePlayer; + oPositionCount: byte; + oPlayerCount: byte; - //Saves the First and Last Popup of the List + // saves the first and last popup of the list FirstPopUp: PScorePopUp; LastPopUp: PScorePopUp; - // Draws a Popup by Pointer + // draws a popup by pointer procedure DrawPopUp(const PopUp: PScorePopUp); - // Draws a Score by Playerindex - procedure DrawScore(const Index: Integer); + // draws a score by playerindex + procedure DrawScore(const Index: integer); - // Draws the RatingBar by Playerindex - procedure DrawRatingBar(const Index: Integer); + // draws the rating bar by playerindex + procedure DrawRatingBar(const Index: integer); - // Removes a PopUp w/o destroying the List + // removes a popup w/o destroying the list procedure KillPopUp(const last, cur: PScorePopUp); public - Settings: record //Record containing some Displaying Options - Phase1Time: Real; //time for Phase 1 to complete (in msecs) - //The Plop Up of the PopUp - Phase2Time: Real; //time for Phase 2 to complete (in msecs) - //The Moving (mainly Upwards) of the Popup - Phase3Time: Real; //time for Phase 3 to complete (in msecs) - //The Fade out and Score adding + Settings: record // Record containing some Displaying Options + Phase1Time: real; // time for phase 1 to complete (in msecs) + // the plop up of the popup + Phase2Time: real; // time for phase 2 to complete (in msecs) + // the moving (mainly upwards) of the popup + Phase3Time: real; // time for phase 3 to complete (in msecs) + // the fade out and score adding - PopUpTex: array [0..8] of TTexture; //Textures for every Popup Rating + PopUpTex: array [0..8] of TTexture; // textures for every popup rating - RatingBar_BG_Tex: TTexture; //Rating Bar Texs - RatingBar_FG_Tex: TTexture; - RatingBar_Bar_Tex: TTexture; + RatingBar_BG_Tex: TTexture; // rating bar texs + RatingBar_FG_Tex: TTexture; + RatingBar_Bar_Tex: TTexture; end; - Visible: Boolean; //Visibility of all Scores - Enabled: Boolean; //Scores are changed, PopUps are Moved etc. - RBVisible: Boolean; //Visibility of all Rating Bars + Visible: boolean; // visibility of all scores + Enabled: boolean; // scores are changed, popups are moved etc. + RBVisible: boolean; // visibility of all rating bars - //Propertys for Reading Position and Playercount - property PositionCount: Byte read oPositionCount; - property PlayerCount: Byte read oPlayerCount; - property Players: aScorePlayer read aPlayers; + // properties for reading position and playercount + property PositionCount: byte read oPositionCount; + property PlayerCount: byte read oPlayerCount; + property Players: aScorePlayer read aPlayers; - //Constructor just sets some standard Settings + // constructor just sets some standard settings constructor Create; - // Adds a Position to Array and Increases Position Count + // adds a position to array and increases position count procedure AddPosition(const pPosition: PScorePosition); - // Adds a Player to Array and Increases Player Count - procedure AddPlayer(const ScoreBG: TTexture; const Color: TRGB; const Score: Word = 0; const Enabled: Boolean = True; const Visible: Boolean = True); + // adds a player to array and increases player count + procedure AddPlayer(const ScoreBG: TTexture; const Color: TRGB; const Score: word = 0; const Enabled: boolean = true; const Visible: boolean = true); - //Change a Players Visibility, Enable - procedure ChangePlayerVisibility(const Index: Byte; const pVisible: Boolean); - procedure ChangePlayerEnabled(const Index: Byte; const pEnabled: Boolean); + // change a players visibility, enable + procedure ChangePlayerVisibility(const Index: byte; const pVisible: boolean); + procedure ChangePlayerEnabled(const Index: byte; const pEnabled: boolean); - // Deletes all Player Information + // deletes all player information procedure ClearPlayers; - // Deletes Positions and Playerinformation + // deletes positions and playerinformation procedure Clear; - // Loads some Settings and the Positions from Theme + // loads some settings and the positions from theme procedure LoadfromTheme; - // has to be called after Positions and Players have been added, before first call of Draw - //It gives every Player a Score Position + // has to be called after positions and players have been added, before first call of draw + // it gives every player a score position procedure Init; - //Spawns a new Line Bonus PopUp for the Player - procedure SpawnPopUp(const PlayerIndex: Byte; const Rating: Byte; const Score: Word); + // spawns a new line bonus popup for the player + procedure SpawnPopUp(const PlayerIndex: byte; const Rating: byte; const Score: word); - //Removes all PopUps from Mem + // removes all popups from mem procedure KillAllPopUps; - // Draws Scores and Linebonus PopUps + // draws scores and line bonus popups procedure Draw; end; - implementation -uses SDL, - SysUtils, - ULog, - UGraphic, - TextGL; +uses + SysUtils, + SDL, + TextGL, + ULog, + UGraphic; {** - * Sets some standard Settings + * sets some standard settings *} -Constructor TSingScores.Create; +constructor TSingScores.Create; begin inherited; - //Clear PopupList Pointers + // clear popuplist pointers FirstPopUp := nil; LastPopUp := nil; - //Clear Variables - Visible := True; - Enabled := True; - RBVisible := True; + // clear variables + Visible := true; + Enabled := true; + RBVisible := true; - //Clear Position Index - oPositionCount := 0; - oPlayerCount := 0; + // clear position index + oPositionCount := 0; + oPlayerCount := 0; Settings.Phase1Time := 350; // plop it up . -> [ ] Settings.Phase2Time := 550; // shift it up ^[ ]^ @@ -260,22 +260,21 @@ begin end; {** - * Adds a Position to Array and Increases Position Count + * adds a position to array and increases position count *} -Procedure TSingScores.AddPosition(const pPosition: PScorePosition); +procedure TSingScores.AddPosition(const pPosition: PScorePosition); begin if (PositionCount < MaxPositions) then begin Positions[PositionCount] := pPosition^; - Inc(oPositionCount); end; end; {** - * Adds a Player to Array and Increases Player Count + * adds a player to array and increases player count *} -Procedure TSingScores.AddPlayer(const ScoreBG: TTexture; const Color: TRGB; const Score: Word; const Enabled: Boolean; const Visible: Boolean); +procedure TSingScores.AddPlayer(const ScoreBG: TTexture; const Color: TRGB; const Score: word; const Enabled: boolean; const Visible: boolean); begin if (PlayerCount < MaxPlayers) then begin @@ -283,48 +282,48 @@ begin aPlayers[PlayerCount].Enabled := Enabled; aPlayers[PlayerCount].Visible := Visible; aPlayers[PlayerCount].Score := Score; - aPlayers[PlayerCount].ScoreDisplayed := Score; + aPlayers[PlayerCount].ScoreDisplayed := Score; aPlayers[PlayerCount].ScoreBG := ScoreBG; aPlayers[PlayerCount].Color := Color; aPlayers[PlayerCount].RBPos := 0.5; aPlayers[PlayerCount].RBTarget := 0.5; - aPlayers[PlayerCount].RBVisible := True; + aPlayers[PlayerCount].RBVisible := true; Inc(oPlayerCount); end; end; {** - * Change a Players Visibility + * change a players visibility *} -Procedure TSingScores.ChangePlayerVisibility(const Index: Byte; const pVisible: Boolean); +procedure TSingScores.ChangePlayerVisibility(const Index: byte; const pVisible: boolean); begin if (Index < MaxPlayers) then aPlayers[Index].Visible := pVisible; end; {** - * Change Player Enabled + * change player enabled *} -Procedure TSingScores.ChangePlayerEnabled(const Index: Byte; const pEnabled: Boolean); +procedure TSingScores.ChangePlayerEnabled(const Index: byte; const pEnabled: boolean); begin if (Index < MaxPlayers) then aPlayers[Index].Enabled := pEnabled; end; {** - * Procedure Deletes all Player Information + * procedure deletes all player information *} -Procedure TSingScores.ClearPlayers; +procedure TSingScores.ClearPlayers; begin KillAllPopUps; oPlayerCount := 0; end; {** - * Procedure Deletes Positions and Playerinformation + * procedure deletes positions and playerinformation *} -Procedure TSingScores.Clear; +procedure TSingScores.Clear; begin KillAllPopUps; oPlayerCount := 0; @@ -332,14 +331,16 @@ begin end; {** - * Procedure Loads some Settings and the Positions from Theme + * procedure loads some settings and the positions from theme *} -Procedure TSingScores.LoadfromTheme; -var I: Integer; - Procedure AddbyStatics(const PC: Byte; const ScoreStatic, SingBarStatic: TThemeStatic; ScoreText: TThemeText); - var nPosition: TScorePosition; +procedure TSingScores.LoadfromTheme; +var + I: integer; + procedure AddbyStatics(const PC: byte; const ScoreStatic, SingBarStatic: TThemeStatic; ScoreText: TThemeText); + var + nPosition: TScorePosition; begin - nPosition.PlayerCount := PC; //Only for one Player Playing + nPosition.PlayerCount := PC; // only for one player playing nPosition.BGX := ScoreStatic.X; nPosition.BGY := ScoreStatic.Y; @@ -373,54 +374,55 @@ var I: Integer; begin Clear; - //Set Textures - //Popup Tex - For I := 0 to 8 do + // set textures + // popup tex + for I := 0 to 8 do Settings.PopUpTex[I] := Tex_SingLineBonusBack[I]; - //Rating Bar Tex + // rating bar tex Settings.RatingBar_BG_Tex := Tex_SingBar_Back; Settings.RatingBar_FG_Tex := Tex_SingBar_Front; Settings.RatingBar_Bar_Tex := Tex_SingBar_Bar; - //Load Positions from Theme + // load positions from theme - // Player1: + // player 1: AddByStatics(1, Theme.Sing.StaticP1ScoreBG, Theme.Sing.StaticP1SingBar, Theme.Sing.TextP1Score); AddByStatics(2, Theme.Sing.StaticP1TwoPScoreBG, Theme.Sing.StaticP1TwoPSingBar, Theme.Sing.TextP1TwoPScore); AddByStatics(4, Theme.Sing.StaticP1ThreePScoreBG, Theme.Sing.StaticP1ThreePSingBar, Theme.Sing.TextP1ThreePScore); - // Player2: + // player 2: AddByStatics(2, Theme.Sing.StaticP2RScoreBG, Theme.Sing.StaticP2RSingBar, Theme.Sing.TextP2RScore); AddByStatics(4, Theme.Sing.StaticP2MScoreBG, Theme.Sing.StaticP2MSingBar, Theme.Sing.TextP2MScore); - // Player3: + // player 3: AddByStatics(4, Theme.Sing.StaticP3RScoreBG, Theme.Sing.StaticP3SingBar, Theme.Sing.TextP3RScore); end; {** - * Spawns a new Line Bonus PopUp for the Player + * spawns a new line bonus popup for the player *} -Procedure TSingScores.SpawnPopUp(const PlayerIndex: Byte; const Rating: Byte; const Score: Word); -var Cur: PScorePopUp; +procedure TSingScores.SpawnPopUp(const PlayerIndex: byte; const Rating: byte; const Score: word); +var + Cur: PScorePopUp; begin if (PlayerIndex < PlayerCount) then begin - //Get Memory and Add Data + // get memory and add data GetMem(Cur, SizeOf(TScorePopUp)); - Cur.Player := PlayerIndex; + Cur.Player := PlayerIndex; Cur.TimeStamp := SDL_GetTicks; - //limit rating value to 8 - //a higher value would cause a crash when selecting the bg textur + // limit rating value to 8 + // a higher value would cause a crash when selecting the bg texture if (Rating > 8) then Cur.Rating := 8 else Cur.Rating := Rating; Cur.ScoreGiven:= 0; - If (Players[PlayerIndex].Score < Score) then + if (Players[PlayerIndex].Score < Score) then begin Cur.ScoreDiff := Score - Players[PlayerIndex].Score; aPlayers[PlayerIndex].Score := Score; @@ -429,77 +431,77 @@ begin Cur.ScoreDiff := 0; Cur.Next := nil; - //Log.LogError('TSingScores.SpawnPopUp| Player: ' + InttoStr(PlayerIndex) + ', Score: ' + InttoStr(Score) + ', ScoreDiff: ' + InttoStr(Cur.ScoreDiff)); + // Log.LogError('TSingScores.SpawnPopUp| Player: ' + InttoStr(PlayerIndex) + ', Score: ' + InttoStr(Score) + ', ScoreDiff: ' + InttoStr(Cur.ScoreDiff)); - //Add it to the Chain + // add it to the chain if (FirstPopUp = nil) then - //the first PopUp in the List + // the first popup in the list FirstPopUp := Cur else - //second or earlier popup + // second or earlier popup LastPopUp.Next := Cur; - //Set new Popup to Last PopUp in the List + // set new popup to last popup in the list LastPopUp := Cur; end else - Log.LogError('TSingScores: Try to add PopUp for not existing player'); + Log.LogError('TSingScores: Try to add popup for non-existing player'); end; {** - * Removes a PopUp w/o destroying the List + * removes a popup w/o destroying the list *} -Procedure TSingScores.KillPopUp(const last, cur: PScorePopUp); +procedure TSingScores.KillPopUp(const last, cur: PScorePopUp); begin - //Give Player the Last Points that missing till now + // give player the last points that missing till now aPlayers[Cur.Player].ScoreDisplayed := aPlayers[Cur.Player].ScoreDisplayed + Cur.ScoreDiff - Cur.ScoreGiven; - //Change Bars Position + // change bars position if (Cur.ScoreDiff > 0) THEN - begin //Popup w/ scorechange -> give missing Percentille + begin // popup w/ scorechange -> give missing percentille aPlayers[Cur.Player].RBTarget := aPlayers[Cur.Player].RBTarget + (Cur.ScoreDiff - Cur.ScoreGiven) / Cur.ScoreDiff * (Cur.Rating / 20 - 0.26); end else - begin //Popup w/o scorechange -> give complete Percentille + begin // popup w/o scorechange -> give complete percentille aPlayers[Cur.Player].RBTarget := aPlayers[Cur.Player].RBTarget + (Cur.Rating / 20 - 0.26); end; - If (aPlayers[Cur.Player].RBTarget > 1) then + if (aPlayers[Cur.Player].RBTarget > 1) then aPlayers[Cur.Player].RBTarget := 1 else - If (aPlayers[Cur.Player].RBTarget < 0) then + if (aPlayers[Cur.Player].RBTarget < 0) then aPlayers[Cur.Player].RBTarget := 0; - //If this is the First PopUp => Make Next PopUp the First - If (Cur = FirstPopUp) then + // if this is the first popup => make next popup the first + if (Cur = FirstPopUp) then FirstPopUp := Cur.Next - //Else => Remove Curent Popup from Chain + // else => remove curent popup from chain else Last.Next := Cur.Next; - //If this is the Last PopUp, Make PopUp before the Last - If (Cur = LastPopUp) then + // if this is the last popup, make popup before the last + if (Cur = LastPopUp) then LastPopUp := Last; - //Free the Memory + // free the memory FreeMem(Cur, SizeOf(TScorePopUp)); end; {** - * Removes all PopUps from Mem + * removes all popups from mem *} -Procedure TSingScores.KillAllPopUps; +procedure TSingScores.KillAllPopUps; var Cur: PScorePopUp; Last: PScorePopUp; begin Cur := FirstPopUp; - //Remove all PopUps: - While (Cur <> nil) do + // remove all popups: + while (Cur <> nil) do begin Last := Cur; Cur := Cur.Next; @@ -511,40 +513,42 @@ begin end; {** - * Has to be called after Positions and Players have been added, before first call of Draw - * It gives every Player a Score Position + * has to be called after positions and players have been added, before first call of draw + * it gives each player a score position *} -Procedure TSingScores.Init; +procedure TSingScores.Init; var - PlC: Array [0..1] of Byte; //Playercount First Screen and Second Screen - I, J: Integer; - MaxPlayersperScreen: Byte; - CurPlayer: Byte; - - Function GetPositionCountbyPlayerCount(bPlayerCount: Byte): Byte; - var I: Integer; + PlC: array [0..1] of byte; // playercount first screen and second screen + I, J: integer; + MaxPlayersperScreen: byte; + CurPlayer: byte; + + function GetPositionCountbyPlayerCount(bPlayerCount: byte): byte; + var + I: integer; begin Result := 0; bPlayerCount := 1 shl (bPlayerCount - 1); - For I := 0 to PositionCount-1 do + for I := 0 to PositionCount - 1 do begin - If ((Positions[I].PlayerCount AND bPlayerCount) <> 0) then + if ((Positions[I].PlayerCount and bPlayerCount) <> 0) then Inc(Result); end; end; - Function GetPositionbyPlayernum(bPlayerCount, bPlayer: Byte): Byte; - var I: Integer; + function GetPositionbyPlayernum(bPlayerCount, bPlayer: byte): byte; + var + I: integer; begin bPlayerCount := 1 shl (bPlayerCount - 1); - Result := High(Byte); + Result := High(byte); - For I := 0 to PositionCount-1 do + for I := 0 to PositionCount - 1 do begin - If ((Positions[I].PlayerCount AND bPlayerCount) <> 0) then + if ((Positions[I].PlayerCount and bPlayerCount) <> 0) then begin - If (bPlayer = 0) then + if (bPlayer = 0) then begin Result := I; Break; @@ -558,17 +562,16 @@ var begin MaxPlayersPerScreen := 0; - For I := 1 to 6 do + for I := 1 to 6 do begin - //If there are enough Positions -> Write to MaxPlayers - If (GetPositionCountbyPlayerCount(I) = I) then + // if there are enough positions -> write to maxplayers + if (GetPositionCountbyPlayerCount(I) = I) then MaxPlayersPerScreen := I else Break; end; - - //Split Players to both Screen or Display on One Screen + // split players to both screens or display on one screen if (Screens = 2) and (MaxPlayersPerScreen < PlayerCount) then begin PlC[0] := PlayerCount div 2 + PlayerCount mod 2; @@ -580,9 +583,8 @@ begin PlC[1] := 0; end; - - //Check if there are enough Positions for all Players - For I := 0 to Screens - 1 do + // check if there are enough positions for all players + for I := 0 to Screens - 1 do begin if (PlC[I] > MaxPlayersperScreen) then begin @@ -592,34 +594,34 @@ begin end; CurPlayer := 0; - //Give every Player a Position - For I := 0 to Screens - 1 do - For J := 0 to PlC[I]-1 do + // give every player a position + for I := 0 to Screens - 1 do + for J := 0 to PlC[I]-1 do begin - aPlayers[CurPlayer].Position := GetPositionbyPlayernum(PlC[I], J) OR (I shl 7); - //Log.LogError('Player ' + InttoStr(CurPlayer) + ' gets Position: ' + InttoStr(aPlayers[CurPlayer].Position)); + aPlayers[CurPlayer].Position := GetPositionbyPlayernum(PlC[I], J) or (I shl 7); + // Log.LogError('Player ' + InttoStr(CurPlayer) + ' gets Position: ' + InttoStr(aPlayers[CurPlayer].Position)); Inc(CurPlayer); end; end; {** - * Draws Scores and Linebonus PopUps + * draws scores and linebonus popups *} -Procedure TSingScores.Draw; +procedure TSingScores.Draw; var - I: Integer; - CurTime: Cardinal; + I: integer; + CurTime: cardinal; CurPopUp, LastPopUp: PScorePopUp; begin CurTime := SDL_GetTicks; - If Visible then + if Visible then begin - //Draw Popups + // draw popups LastPopUp := nil; CurPopUp := FirstPopUp; - While (CurPopUp <> nil) do + while (CurPopUp <> nil) do begin if (CurTime - CurPopUp.TimeStamp > Settings.Phase1Time + Settings.Phase2Time + Settings.Phase3Time) then begin @@ -638,64 +640,64 @@ begin end; - IF (RBVisible) then - //Draw Players w/ Rating Bar - For I := 0 to PlayerCount-1 do + if (RBVisible) then + // draw players w/ rating bar + for I := 0 to PlayerCount-1 do begin DrawScore(I); DrawRatingBar(I); end else - //Draw Players w/o Rating Bar - For I := 0 to PlayerCount-1 do + // draw players w/o rating bar + for I := 0 to PlayerCount-1 do begin DrawScore(I); end; - end; //eo Visible + end; // eo visible end; {** - * Draws a Popup by Pointer + * draws a popup by pointer *} -Procedure TSingScores.DrawPopUp(const PopUp: PScorePopUp); +procedure TSingScores.DrawPopUp(const PopUp: PScorePopUp); var - Progress: Real; - CurTime: Cardinal; - X, Y, W, H, Alpha: Real; - FontSize: integer; - FontOffset: Real; - TimeDiff: Cardinal; - PIndex: Byte; - TextLen: Real; - ScoretoAdd: Word; - PosDiff: Real; + Progress: real; + CurTime: cardinal; + X, Y, W, H, Alpha: real; + FontSize: real; + FontOffset: real; + TimeDiff: cardinal; + PIndex: byte; + TextLen: real; + ScoretoAdd: word; + PosDiff: real; begin if (PopUp <> nil) then begin - //Only Draw if Player has a Position + // only draw if player has a position PIndex := Players[PopUp.Player].Position; - If PIndex <> high(byte) then + if PIndex <> High(byte) then begin - //Only Draw if Player is on Cur Screen - If ((Players[PopUp.Player].Position AND 128) = 0) = (ScreenAct = 1) then + // only draw if player is on cur screen + if ((Players[PopUp.Player].Position and 128) = 0) = (ScreenAct = 1) then begin CurTime := SDL_GetTicks; - If Not (Enabled AND Players[PopUp.Player].Enabled) then - //Increase Timestamp with TIem where there is no Movement ... + if not (Enabled and Players[PopUp.Player].Enabled) then + // increase timestamp with tiem where there is no movement ... begin - //Inc(PopUp.TimeStamp, LastRender); + // Inc(PopUp.TimeStamp, LastRender); end; TimeDiff := CurTime - PopUp.TimeStamp; - //Get Position of PopUp - PIndex := PIndex AND 127; + // get position of popup + PIndex := PIndex and 127; - //Check for Phase ... - If (TimeDiff <= Settings.Phase1Time) then + // check for phase ... + if (TimeDiff <= Settings.Phase1Time) then begin - //Phase 1 - The Ploping up + // phase 1 - the ploping up Progress := TimeDiff / Settings.Phase1Time; @@ -705,26 +707,26 @@ begin X := Positions[PIndex].PUStartX + (Positions[PIndex].PUW - W)/2; Y := Positions[PIndex].PUStartY + (Positions[PIndex].PUH - H)/2; - FontSize := Round(Progress * Positions[PIndex].PUFontSize); - FontOffset := (H - FontSize) / 2; + FontSize := Progress * Positions[PIndex].PUFontSize; + FontOffset := (H - FontSize) / 2; Alpha := 1; end - Else If (TimeDiff <= Settings.Phase2Time + Settings.Phase1Time) then + else if (TimeDiff <= Settings.Phase2Time + Settings.Phase1Time) then begin - //Phase 2 - The Moving + // phase 2 - the moving Progress := (TimeDiff - Settings.Phase1Time) / Settings.Phase2Time; W := Positions[PIndex].PUW; H := Positions[PIndex].PUH; PosDiff := Positions[PIndex].PUTargetX - Positions[PIndex].PUStartX; - If PosDiff > 0 then + if PosDiff > 0 then PosDiff := PosDiff + W; X := Positions[PIndex].PUStartX + PosDiff * sqr(Progress); PosDiff := Positions[PIndex].PUTargetY - Positions[PIndex].PUStartY; - If PosDiff < 0 then + if PosDiff < 0 then PosDiff := PosDiff + Positions[PIndex].BGH; Y := Positions[PIndex].PUStartY + PosDiff * sqr(Progress); @@ -735,65 +737,67 @@ begin else begin - //Phase 3 - The Fading out + Score adding + // phase 3 - the fading out + score adding Progress := (TimeDiff - Settings.Phase1Time - Settings.Phase2Time) / Settings.Phase3Time; - If (PopUp.Rating > 0) then + if (PopUp.Rating > 0) then begin - //Add Scores if Player Enabled - If (Enabled AND Players[PopUp.Player].Enabled) then + // add scores if player enabled + if (Enabled and Players[PopUp.Player].Enabled) then begin ScoreToAdd := Round(PopUp.ScoreDiff * Progress) - PopUp.ScoreGiven; Inc(PopUp.ScoreGiven, ScoreToAdd); aPlayers[PopUp.Player].ScoreDisplayed := Players[PopUp.Player].ScoreDisplayed + ScoreToAdd; - //Change Bars Position - aPlayers[PopUp.Player].RBTarget := aPlayers[PopUp.Player].RBTarget + ScoreToAdd/PopUp.ScoreDiff * (PopUp.Rating / 20 - 0.26); - If (aPlayers[PopUp.Player].RBTarget > 1) then + // change bar positions + if PopUp.ScoreDiff = 0 then + Log.LogError('TSingScores.DrawPopUp', 'PopUp.ScoreDiff is 0 and we want to divide by it. No idea how this happens.') + else + aPlayers[PopUp.Player].RBTarget := aPlayers[PopUp.Player].RBTarget + ScoreToAdd/PopUp.ScoreDiff * (PopUp.Rating / 20 - 0.26); + if (aPlayers[PopUp.Player].RBTarget > 1) then aPlayers[PopUp.Player].RBTarget := 1 - else If (aPlayers[PopUp.Player].RBTarget < 0) then + else if (aPlayers[PopUp.Player].RBTarget < 0) then aPlayers[PopUp.Player].RBTarget := 0; end; - //Set Positions etc. - Alpha := 0.7 - 0.7 * Progress; + // set positions etc. + Alpha := 0.7 - 0.7 * Progress; W := Positions[PIndex].PUW; H := Positions[PIndex].PUH; PosDiff := Positions[PIndex].PUTargetX - Positions[PIndex].PUStartX; - If (PosDiff > 0) then + if (PosDiff > 0) then PosDiff := W else PosDiff := 0; X := Positions[PIndex].PUTargetX + PosDiff * Progress; PosDiff := Positions[PIndex].PUTargetY - Positions[PIndex].PUStartY; - If (PosDiff < 0) then + if (PosDiff < 0) then PosDiff := -Positions[PIndex].BGH else PosDiff := 0; - Y := Positions[PIndex].PUTargetY - PosDiff * (1-Progress); + Y := Positions[PIndex].PUTargetY - PosDiff * (1 - Progress); FontSize := Positions[PIndex].PUFontSize; FontOffset := (H - FontSize) / 2; end else begin - //Here the Effect that Should be shown if a PopUp without Score is Drawn - //And or Spawn with the GraphicObjects etc. - //Some Work for Blindy to do :P + // here the effect that should be shown if a popup without score is drawn + // and or spawn with the graphicobjects etc. + // some work for blindy to do :p - //ATM: Just Let it Slide in the Scores just like the Normal PopUp + // atm: just let it slide in the scores just like the normal popup Alpha := 0; end; end; - //Draw PopUp - - if (Alpha > 0) AND (Players[PopUp.Player].Visible) then + // draw popup + if (Alpha > 0) and (FontSize > 0) and (Players[PopUp.Player].Visible) then begin - //Draw BG: + // draw bg: glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -811,45 +815,46 @@ begin glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); - //Set FontStyle and Size + // set font style and size SetFontStyle(Positions[PIndex].PUFont); - SetFontItalic(False); + SetFontItalic(false); SetFontSize(FontSize); + SetFontReflection(false, 0); - //Draw Text + // draw text TextLen := glTextWidth(Theme.Sing.LineBonusText[PopUp.Rating]); - //Color and Pos + // color and pos SetFontPos (X + (W - TextLen) / 2, Y + FontOffset); glColor4f(1, 1, 1, Alpha); - //Draw + // draw glPrint(Theme.Sing.LineBonusText[PopUp.Rating]); - end; //eo Alpha check - end; //eo Right Screen - end; //eo Player has Position + end; // eo alpha check + end; // eo right screen + end; // eo player has position end else - Log.LogError('TSingScores: Try to Draw a not existing PopUp'); + Log.LogError('TSingScores: Try to draw a non-existing popup'); end; {** - * Draws a Score by Playerindex + * draws a score by playerindex *} -Procedure TSingScores.DrawScore(const Index: Integer); +procedure TSingScores.DrawScore(const Index: integer); var Position: PScorePosition; ScoreStr: String; begin - //Only Draw if Player has a Position - If Players[Index].Position <> high(byte) then + // only draw if player has a position + if Players[Index].Position <> High(byte) then begin - //Only Draw if Player is on Cur Screen - If (((Players[Index].Position AND 128) = 0) = (ScreenAct = 1)) AND Players[Index].Visible then + // only draw if player is on cur screen + if (((Players[Index].Position and 128) = 0) = (ScreenAct = 1)) and Players[Index].Visible then begin Position := @Positions[Players[Index].Position and 127]; - //Draw ScoreBG + // draw scorebg glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -867,50 +872,51 @@ begin glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); - //Draw Score Text + // draw score text SetFontStyle(Position.TextFont); - SetFontItalic(False); + SetFontItalic(false); SetFontSize(Position.TextSize); SetFontPos(Position.TextX, Position.TextY); + SetFontReflection(false, 0); ScoreStr := InttoStr(Players[Index].ScoreDisplayed div 10) + '0'; - While (Length(ScoreStr) < 5) do + while (Length(ScoreStr) < 5) do ScoreStr := '0' + ScoreStr; glPrint(ScoreStr); - end; //eo Right Screen - end; //eo Player has Position + end; // eo right screen + end; // eo player has position end; -Procedure TSingScores.DrawRatingBar(const Index: Integer); +procedure TSingScores.DrawRatingBar(const Index: integer); var - Position: PScorePosition; - R,G,B, Size: Real; - Diff: Real; + Position: PScorePosition; + R, G, B: real; + Size, Diff: real; begin - //Only Draw if Player has a Position - if Players[Index].Position <> high(byte) then + // only draw if player has a position + if Players[Index].Position <> High(byte) then begin - //Only Draw if Player is on Cur Screen + // only draw if player is on cur screen if (((Players[Index].Position and 128) = 0) = (ScreenAct = 1) and Players[index].RBVisible and Players[index].Visible) then begin Position := @Positions[Players[Index].Position and 127]; - if (Enabled AND Players[Index].Enabled) then + if (Enabled and Players[Index].Enabled) then begin - //Move Position if Enabled + // move position if enabled Diff := Players[Index].RBTarget - Players[Index].RBPos; - If(Abs(Diff) < 0.02) then + if (Abs(Diff) < 0.02) then aPlayers[Index].RBPos := aPlayers[Index].RBTarget else aPlayers[Index].RBPos := aPlayers[Index].RBPos + Diff*0.1; end; - //Get Colors for RatingBar + // get colors for rating bar if (Players[index].RBPos <= 0.22) then begin R := 1; @@ -920,7 +926,7 @@ begin else if (Players[index].RBPos <= 0.42) then begin R := 1; - G := Players[index].RBPos*5; + G := Players[index].RBPos * 5; B := 0; end else if (Players[index].RBPos <= 0.57) then @@ -931,7 +937,7 @@ begin end else if (Players[index].RBPos <= 0.77) then begin - R := 1-(Players[index].RBPos-0.57)*5; + R := 1 - (Players[index].RBPos - 0.57) * 5; G := 1; B := 0; end @@ -942,12 +948,12 @@ begin B := 0; end; - //Enable all glFuncs Needed + // enable all glfuncs needed glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - //Draw RatingBar BG + // draw rating bar bg glColor4f(1, 1, 1, 0.8); glBindTexture(GL_TEXTURE_2D, Settings.RatingBar_BG_Tex.TexNum); @@ -965,7 +971,7 @@ begin glVertex2f(Position.RBX+Position.RBW, Position.RBY); glEnd; - //Draw Rating bar itself + // draw rating bar itself Size := Position.RBX + Position.RBW * Players[Index].RBPos; glColor4f(R, G, B, 1); glBindTexture(GL_TEXTURE_2D, Settings.RatingBar_Bar_Tex.TexNum); @@ -983,7 +989,7 @@ begin glVertex2f(Size, Position.RBY); glEnd; - //Draw Ratingbar FG (Teh thing with the 3 lines to get better readability) + // draw rating bar fg (the thing with the 3 lines to get better readability) glColor4f(1, 1, 1, 0.6); glBindTexture(GL_TEXTURE_2D, Settings.RatingBar_FG_Tex.TexNum); glBegin(GL_QUADS); @@ -1000,11 +1006,11 @@ begin glVertex2f(Position.RBX + Position.RBW, Position.RBY); glEnd; - //Disable all Enabled glFuncs + // disable all enabled glfuncs glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); - end; //eo Right Screen - end; //eo Player has Position + end; // eo Right Screen + end; // eo Player has Position end; end. diff --git a/unicode/src/base/USongs.pas b/unicode/src/base/USongs.pas index 852ccfc4..e1fb6ca9 100644 --- a/unicode/src/base/USongs.pas +++ b/unicode/src/base/USongs.pas @@ -73,35 +73,35 @@ type ); TBPM = record - BPM: real; - StartBeat: real; + BPM: real; + StartBeat: real; end; TScore = record - Name: widestring; - Score: integer; - Length: string; + Name: widestring; + Score: integer; + Length: string; end; {$IFDEF USE_PSEUDO_THREAD} - TSongs = class( TPseudoThread ) + TSongs = class(TPseudoThread) {$ELSE} - TSongs = class( TThread ) + TSongs = class(TThread) {$ENDIF} private - fNotify, fWatch : longint; - fParseSongDirectory : boolean; - fProcessing : boolean; + fNotify, fWatch: longint; + fParseSongDirectory: boolean; + fProcessing: boolean; {$ifdef MSWINDOWS} - fDirWatch : TDirectoryWatch; + fDirWatch: TDirectoryWatch; {$endif} procedure int_LoadSongList; procedure DoDirChanged(Sender: TObject); protected procedure Execute; override; public - SongList : TList; // array of songs - Selected : integer; // selected song index + SongList: TList; // array of songs + Selected: integer; // selected song index constructor Create(); destructor Destroy(); override; @@ -112,7 +112,7 @@ type procedure BrowseXMLFiles(Dir: widestring); procedure Sort(Order: integer); function FindSongFile(Dir, Mask: widestring): widestring; - property Processing : boolean read fProcessing; + property Processing: boolean read fProcessing; end; @@ -121,24 +121,24 @@ type Selected: integer; // selected song index Order: integer; // order type (0=title) CatNumShow: integer; // Category Number being seen - CatCount: integer; //Number of Categorys + CatCount: integer; // Number of Categorys procedure SortSongs(); - procedure Refresh; // refreshes arrays by recreating them from Songs array - 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: UTF8String; Filter: TSongFilter): Cardinal; + procedure Refresh; // refreshes arrays by recreating them from Songs array + 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: UTF8String; Filter: TSongFilter): cardinal; end; var - Songs: TSongs; // all songs - CatSongs: TCatSongs; // categorized songs + Songs: TSongs; // all songs + CatSongs: TCatSongs; // categorized songs const IN_ACCESS = $00000001; //* File was accessed */ @@ -177,7 +177,7 @@ begin // FIXME: threaded loading does not work this way. // It will just cause crashes but nothing else at the moment. - (* +(* {$ifdef MSWINDOWS} fDirWatch := TDirectoryWatch.create(nil); fDirWatch.OnChange := DoDirChanged; @@ -188,7 +188,7 @@ begin // now we can start the thread Resume(); - *) +*) // until it is fixed, simply load the song-list int_LoadSongList(); @@ -196,7 +196,7 @@ end; destructor TSongs.Destroy(); begin - FreeAndNil( SongList ); + FreeAndNil(SongList); inherited; end; @@ -207,7 +207,7 @@ end; procedure TSongs.Execute(); var - fChangeNotify : THandle; + fChangeNotify: THandle; begin {$IFDEF USE_PSEUDO_THREAD} int_LoadSongList(); @@ -241,13 +241,13 @@ begin for I := 0 to SongPaths.Count-1 do BrowseDir(SongPaths[I]); - if assigned( CatSongs ) then + if assigned(CatSongs) then CatSongs.Refresh; - if assigned( CatCovers ) then + if assigned(CatCovers) then CatCovers.Load; - //if assigned( Covers ) then + //if assigned(Covers) then // Covers.Load; if assigned(ScreenSong) then @@ -273,81 +273,81 @@ end; procedure TSongs.BrowseDir(Dir: widestring); begin - BrowseTXTFiles(Dir); - BrowseXMLFiles(Dir); + BrowseTXTFiles(Dir); + BrowseXMLFiles(Dir); end; procedure TSongs.BrowseTXTFiles(Dir: widestring); var - i : integer; - Files : TDirectoryEntryArray; - lSong : TSong; + i: integer; + Files: TDirectoryEntryArray; + lSong: TSong; begin try - Files := Platform.DirectoryFindFiles( Dir, '.txt', true) + Files := Platform.DirectoryFindFiles(Dir, '.txt', true) except Log.LogError('Couldn''t deal with directory/file: ' + Dir + ' in TSongs.BrowseTXTFiles') end; - for i := 0 to Length(Files)-1 do + for i := 0 to Length(Files) - 1 do begin if Files[i].IsDirectory then begin - BrowseTXTFiles( Dir + Files[i].Name + PathDelim ); //Recursive Call + BrowseTXTFiles(Dir + Files[i].Name + PathDelim); //Recursive Call end else begin - lSong := TSong.create( Dir + Files[i].Name ); + lSong := TSong.create(Dir + Files[i].Name); if lSong.Analyse then - SongList.add( lSong ) + SongList.add(lSong) else begin Log.LogError('AnalyseFile failed for "' + Files[i].Name + '".'); - freeandnil( lSong ); + freeandnil(lSong); end; end; end; - SetLength( Files, 0); + SetLength(Files, 0); end; procedure TSongs.BrowseXMLFiles(Dir: widestring); var - i : integer; - Files : TDirectoryEntryArray; - lSong : TSong; + i: integer; + Files: TDirectoryEntryArray; + lSong: TSong; begin try - Files := Platform.DirectoryFindFiles( Dir, '.xml', true) + Files := Platform.DirectoryFindFiles(Dir, '.xml', true) except Log.LogError('Couldn''t deal with directory/file: ' + Dir + ' in TSongs.BrowseXMLFiles') end; - for i := 0 to Length(Files)-1 do + for i := 0 to Length(Files) - 1 do begin if Files[i].IsDirectory then begin - BrowseXMLFiles( Dir + Files[i].Name + PathDelim ); //Recursive Call + BrowseXMLFiles(Dir + Files[i].Name + PathDelim); // Recursive Call end else begin - lSong := TSong.create( Dir + Files[i].Name ); + lSong := TSong.create(Dir + Files[i].Name); if lSong.AnalyseXML then - SongList.add( lSong ) + SongList.add(lSong) else begin Log.LogError('AnalyseFile failed for "' + Files[i].Name + '".'); - freeandnil( lSong ); + freeandnil(lSong); end; end; end; - SetLength( Files, 0); + SetLength(Files, 0); end; @@ -421,7 +421,7 @@ end; function TSongs.FindSongFile(Dir, Mask: widestring): widestring; var - SR: TSearchRec; // for parsing song directory + SR: TSearchRec; // for parsing song directory begin Result := ''; if FindFirst(Dir + Mask, faDirectory, SR) = 0 then @@ -490,13 +490,13 @@ var Inc(Order); CatIndex := Length(Song); SetLength(Song, CatIndex+1); - Song[CatIndex] := TSong.Create(); - Song[CatIndex].Artist := '[' + CategoryName + ']'; - Song[CatIndex].Main := true; + Song[CatIndex] := TSong.Create(); + Song[CatIndex].Artist := '[' + CategoryName + ']'; + Song[CatIndex].Main := true; Song[CatIndex].OrderTyp := 0; Song[CatIndex].OrderNum := Order; - Song[CatIndex].Cover := CatCovers.GetCover(Ini.Sorting, CategoryName); - Song[CatIndex].Visible := true; + Song[CatIndex].Cover := CatCovers.GetCover(Ini.Sorting, CategoryName); + Song[CatIndex].Visible := true; // set number of songs in previous category PrevCatBtnIndex := CatIndex - CatNumber - 1; @@ -507,21 +507,21 @@ var end; begin - CatNumShow := -1; + CatNumShow := -1; SortSongs(); CurCategory := ''; - Order := 0; - CatNumber := 0; + Order := 0; + CatNumber := 0; // Note: do NOT set Letter to ' ', otherwise no category-button will be // created for songs beginning with ' ' if songs of this category exist. // TODO: trim song-properties so ' ' will not occur as first chararcter. - Letter := 0; + Letter := 0; // clear song-list - for SongIndex := 0 to Songs.SongList.Count-1 do + for SongIndex := 0 to Songs.SongList.Count - 1 do begin // free category buttons // Note: do NOT delete songs, they are just references to Songs.SongList entries @@ -531,7 +531,7 @@ begin end; SetLength(Song, 0); - for SongIndex := 0 to Songs.SongList.Count-1 do + for SongIndex := 0 to Songs.SongList.Count - 1 do begin CurSong := TSong(Songs.SongList[SongIndex]); // if tabs are on, add section buttons for each new section @@ -545,11 +545,11 @@ begin // TODO: remove this block if it is not needed anymore { - if CurSection = 'Singstar Part 2' then CoverName := 'Singstar'; - if CurSection = 'Singstar German' then CoverName := 'Singstar'; - if CurSection = 'Singstar Spanish' then CoverName := 'Singstar'; - if CurSection = 'Singstar Italian' then CoverName := 'Singstar'; - if CurSection = 'Singstar French' then CoverName := 'Singstar'; + if CurSection = 'Singstar Part 2' then CoverName := 'Singstar'; + if CurSection = 'Singstar German' then CoverName := 'Singstar'; + if CurSection = 'Singstar Spanish' then CoverName := 'Singstar'; + if CurSection = 'Singstar Italian' then CoverName := 'Singstar'; + if CurSection = 'Singstar French' then CoverName := 'Singstar'; if CurSection = 'Singstar 80s Polish' then CoverName := 'Singstar 80s'; } @@ -668,15 +668,14 @@ begin CurSong.Visible := true else if (Ini.Tabs = 1) then CurSong.Visible := false; - - { +{ if (Ini.Tabs = 1) and (Order = 1) then begin //open first tab CurSong.Visible := true; end; CurSong.Visible := true; - } +} end; // set CatNumber of last category @@ -694,7 +693,7 @@ end; procedure TCatSongs.ShowCategory(Index: integer); var - S: integer; // song + S: integer; // song begin CatNumShow := Index; for S := 0 to high(CatSongs.Song) do @@ -706,13 +705,13 @@ begin CatSongs.Song[S].Visible := false; } // KMS: This should be the same, but who knows :-) - CatSongs.Song[S].Visible := ( (CatSongs.Song[S].OrderNum = Index) and (not CatSongs.Song[S].Main) ); + CatSongs.Song[S].Visible := ((CatSongs.Song[S].OrderNum = Index) and (not CatSongs.Song[S].Main)); end; end; procedure TCatSongs.HideCategory(Index: integer); // hides all songs in category var - S: integer; // song + S: integer; // song begin for S := 0 to high(CatSongs.Song) do begin @@ -723,7 +722,7 @@ end; procedure TCatSongs.ClickCategoryButton(Index: integer); var - Num: integer; + Num: integer; begin Num := CatSongs.Song[Index].OrderNum; if Num <> CatNumShow then @@ -739,7 +738,7 @@ end; //Hide Categorys when in Category Hack procedure TCatSongs.ShowCategoryList; var - S: integer; + S: integer; begin // Hide All Songs Show All Cats for S := 0 to high(CatSongs.Song) do @@ -749,8 +748,8 @@ begin 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 +// Wrong song selected when tabs on bug +function TCatSongs.FindNextVisible(SearchFrom:integer): integer;// Find next Visible Song var I: integer; begin @@ -761,11 +760,11 @@ 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 + if (I = SearchFrom) then // Make One Round and no song found->quit break; end; end; -//Wrong song selected when tabs on bug End +// Wrong song selected when tabs on bug End (** * Returns the number of visible songs. @@ -791,19 +790,20 @@ var SongIndex: integer; begin Result := 0; - for SongIndex := 0 to Index-1 do + for SongIndex := 0 to Index - 1 do begin if (CatSongs.Song[SongIndex].Visible) then Inc(Result); end; end; -function TCatSongs.SetFilter(FilterStr: UTF8String; Filter: TSongFilter): Cardinal; +function TCatSongs.SetFilter(FilterStr: UTF8String; Filter: TSongFilter): cardinal; var - I, J: integer; + I, J: integer; TmpString: UTF8String; WordArray: array of UTF8String; begin + FilterStr := Trim(FilterStr); if (FilterStr <> '') then begin @@ -838,7 +838,7 @@ begin fltArtist: TmpString := Song[I].Artist; end; - Song[i].Visible:=True; + Song[i].Visible:=true; // Look for every Searched Word for J := 0 to High(WordArray) do begin @@ -849,7 +849,7 @@ begin Inc(Result); end else - Song[i].Visible := False; + Song[i].Visible := false; end; CatNumShow := -2; end diff --git a/unicode/src/base/UTexture.pas b/unicode/src/base/UTexture.pas index 962bd2b0..97f244fe 100644 --- a/unicode/src/base/UTexture.pas +++ b/unicode/src/base/UTexture.pas @@ -336,8 +336,8 @@ begin X := 0; Y := 0; Z := 0; - W := 0; - H := 0; + W := oldWidth; + H := oldHeight; ScaleW := 1; ScaleH := 1; Rot := 0; diff --git a/unicode/src/base/UThemes.pas b/unicode/src/base/UThemes.pas index 9bf858ed..3fd77853 100644 --- a/unicode/src/base/UThemes.pas +++ b/unicode/src/base/UThemes.pas @@ -42,13 +42,13 @@ uses type TRGB = record - R: single; - G: single; - B: single; + R: single; + G: single; + B: single; end; TRGBA = record - R, G, B, A: Double; + R, G, B, A: double; end; type @@ -175,11 +175,12 @@ type W: integer; H: integer; Z: real; + SBGW: integer; TextSize: integer; - //SBGW Mod - SBGW: integer; + showArrows:boolean; + oneItemOnly:boolean; Text: string; ColR, ColG, ColB, Int: real; @@ -359,6 +360,11 @@ type PausePopUp: TThemeStatic; end; + TThemeLyricBar = record + IndicatorYOffset, UpperX, UpperW, UpperY, UpperH, + LowerX, LowerW, LowerY, LowerH : integer; + end; + TThemeScore = class(TThemeBasic) TextArtist: TThemeText; TextTitle: TThemeText; @@ -723,6 +729,7 @@ type Level: TThemeLevel; Song: TThemeSong; Sing: TThemeSing; + LyricBar: TThemeLyricBar; Score: TThemeScore; Top5: TThemeTop5; Options: TThemeOptions; @@ -1031,9 +1038,19 @@ begin ThemeLoadStatic(Song.StaticTeam3Joker5, 'SongStaticTeam3Joker5'); + //LyricBar asd + LyricBar.UpperX := ThemeIni.ReadInteger('SingLyricsUpperBar', 'X', 0); + LyricBar.UpperW := ThemeIni.ReadInteger('SingLyricsUpperBar', 'W', 0); + LyricBar.UpperY := ThemeIni.ReadInteger('SingLyricsUpperBar', 'Y', 0); + LyricBar.UpperH := ThemeIni.ReadInteger('SingLyricsUpperBar', 'H', 0); + LyricBar.IndicatorYOffset := ThemeIni.ReadInteger('SingLyricsUpperBar', 'IndicatorYOffset', 0); + LyricBar.LowerX := ThemeIni.ReadInteger('SingLyricsLowerBar', 'X', 0); + LyricBar.LowerW := ThemeIni.ReadInteger('SingLyricsLowerBar', 'W', 0); + LyricBar.LowerY := ThemeIni.ReadInteger('SingLyricsLowerBar', 'Y', 0); + LyricBar.LowerH := ThemeIni.ReadInteger('SingLyricsLowerBar', 'H', 0); + // Sing ThemeLoadBasic(Sing, 'Sing'); - //TimeBar mod ThemeLoadStatic(Sing.StaticTimeProgress, 'SingTimeProgress'); ThemeLoadText(Sing.TextTimeText, 'SingTimeText'); @@ -1769,7 +1786,7 @@ begin ThemeSelectS.SkipX := ThemeIni.ReadInteger(Name, 'SkipX', 0); - ThemeSelectS.SBGW := ThemeIni.ReadInteger(Name, 'SBGW', 450); + ThemeSelectS.SBGW := ThemeIni.ReadInteger(Name, 'SBGW', 400); LoadColor(ThemeSelectS.ColR, ThemeSelectS.ColG, ThemeSelectS.ColB, ThemeIni.ReadString(Name, 'Color', '')); ThemeSelectS.Int := ThemeIni.ReadFloat(Name, 'Int', 1); diff --git a/unicode/src/base/UTime.pas b/unicode/src/base/UTime.pas index 3f35dffd..83844cb5 100644 --- a/unicode/src/base/UTime.pas +++ b/unicode/src/base/UTime.pas @@ -61,20 +61,20 @@ procedure CountSkipTime; procedure CountMidTime; var - USTime : TTime; + USTime: TTime; VideoBGTimer: TRelativeTimer; - TimeNew : int64; - TimeOld : int64; - TimeSkip : real; - TimeMid : real; - TimeMidTemp : int64; + TimeNew: int64; + TimeOld: int64; + TimeSkip: real; + TimeMid: real; + TimeMidTemp: int64; implementation uses sdl, - ucommon; + UCommon; const cSDLCorrectionRatio = 1000; @@ -91,14 +91,14 @@ http://www.gamedev.net/community/forums/topic.asp?topic_id=466145&whichpage=1%EE procedure CountSkipTimeSet; begin - TimeNew := SDL_GetTicks(); + TimeNew := SDL_GetTicks(); end; procedure CountSkipTime; begin - TimeOld := TimeNew; - TimeNew := SDL_GetTicks(); - TimeSkip := (TimeNew-TimeOld) / cSDLCorrectionRatio; + TimeOld := TimeNew; + TimeNew := SDL_GetTicks(); + TimeSkip := (TimeNew-TimeOld) / cSDLCorrectionRatio; end; procedure CountMidTime; @@ -127,10 +127,10 @@ end; **} (* - * Creates a new timer. - * If TriggerMode is false (default), the timer + * creates a new timer. + * if triggermode is false (default), the timer * will immediately begin with counting. - * If TriggerMode is true, it will wait until Get/SetTime() or Pause() is called + * if triggermode is true, it will wait until get/settime() or pause() is called * for the first time. *) constructor TRelativeTimer.Create(TriggerMode: boolean); diff --git a/unicode/src/lib/ffmpeg/avcodec.pas b/unicode/src/lib/ffmpeg/avcodec.pas index 6039835c..ceb1b7f0 100644 --- a/unicode/src/lib/ffmpeg/avcodec.pas +++ b/unicode/src/lib/ffmpeg/avcodec.pas @@ -29,6 +29,11 @@ * Min. version: 51.16.0, revision 6577, Sat Oct 7 15:30:46 2006 UTC * Max. version: 52.11.0, revision 16912, Sun Feb 1 02:00:19 2009 UTC *) +{ + * update to + * Max. version: 52.31.2, Sar Jun 13 22:05:00 2009 UTC + * MiSchi +} unit avcodec; @@ -60,8 +65,8 @@ uses const (* Max. supported version by this header *) LIBAVCODEC_MAX_VERSION_MAJOR = 52; - LIBAVCODEC_MAX_VERSION_MINOR = 11; - LIBAVCODEC_MAX_VERSION_RELEASE = 0; + LIBAVCODEC_MAX_VERSION_MINOR = 31; + LIBAVCODEC_MAX_VERSION_RELEASE = 2; LIBAVCODEC_MAX_VERSION = (LIBAVCODEC_MAX_VERSION_MAJOR * VERSION_MAJOR) + (LIBAVCODEC_MAX_VERSION_MINOR * VERSION_MINOR) + (LIBAVCODEC_MAX_VERSION_RELEASE * VERSION_RELEASE); @@ -85,9 +90,9 @@ const {$IFEND} const - AV_NOPTS_VALUE: cint64 = $8000000000000000; + AV_NOPTS_VALUE: cint64 = $8000000000000000; AV_TIME_BASE = 1000000; - AV_TIME_BASE_Q : TAVRational = (num: 1; den: AV_TIME_BASE); + AV_TIME_BASE_Q: TAVRational = (num: 1; den: AV_TIME_BASE); (** * Identifies the syntax and semantics of the bitstream. @@ -233,6 +238,28 @@ type CODEC_ID_MOTIONPIXELS, CODEC_ID_TGV, CODEC_ID_TGQ, +{$IF LIBAVCODEC_VERSION >= 52012000} // >= 52.12.0 + CODEC_ID_TQI, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52022002} // >= 52.22.2 + CODEC_ID_AURA, + CODEC_ID_AURA2, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52027000} // >= 52.27.0 + CODEC_ID_V210X, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52028000} // >= 52.28.0 + CODEC_ID_TMV, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52029000} // >= 52.29.0 + CODEC_ID_V210, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52030002} // >= 52.30.2 + CODEC_ID_DPX, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52031002} // >= 52.31.2 + CODEC_ID_MAD, +{$IFEND} //* various PCM "codecs" */ CODEC_ID_PCM_S16LE= $10000, @@ -308,7 +335,7 @@ type CODEC_ID_MP2= $15000, CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 CODEC_ID_AAC, - {$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 + {$IF LIBAVCODEC_VERSION < 52000000} // < 52.0.0 _CODEC_ID_MPEG4AAC, // will be redefined to CODEC_ID_AAC below {$IFEND} CODEC_ID_AC3, @@ -354,6 +381,15 @@ type CODEC_ID_EAC3, CODEC_ID_SIPR, CODEC_ID_MP1, +{$IF LIBAVCODEC_VERSION >= 52020000} // >= 52.20.0 + CODEC_ID_TWINVQ, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52022000} // >= 52.22.0 + CODEC_ID_TRUEHD, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52026000} // >= 52.26.0 + CODEC_ID_MP4ALS, +{$IFEND} //* subtitle codecs */ CODEC_ID_DVD_SUBTITLE= $17000, @@ -369,11 +405,11 @@ type CODEC_ID_PROBE= $19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it CODEC_ID_MPEG2TS= $20000, {*< _FAKE_ codec to indicate a raw MPEG-2 TS - * stream (only used by libavformat) *} + * stream (only used by libavformat) *} __CODEC_ID_4BYTE = $FFFFF // ensure 4-byte enum ); -{$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 +{$IF LIBAVCODEC_VERSION < 52000000} // < 52.0.0 {* CODEC_ID_MP3LAME is obsolete *} const CODEC_ID_MP3LAME = CODEC_ID_MP3; @@ -407,7 +443,7 @@ type _TSampleFormatArray = array [0 .. MaxInt div SizeOf(TSampleFormat)-1] of TSampleFormat; PSampleFormatArray = ^_TSampleFormatArray; -const +const {* Audio channel masks *} CH_FRONT_LEFT = $00000001; CH_FRONT_RIGHT = $00000002; @@ -434,13 +470,28 @@ const CH_LAYOUT_MONO = (CH_FRONT_CENTER); CH_LAYOUT_STEREO = (CH_FRONT_LEFT or CH_FRONT_RIGHT); CH_LAYOUT_SURROUND = (CH_LAYOUT_STEREO or CH_FRONT_CENTER); +{$IF LIBAVCODEC_VERSION >= 52027000} // >= 52.27.0 + CH_LAYOUT_2_1 = (CH_LAYOUT_STEREO or CH_BACK_CENTER); + CH_LAYOUT_4POINT0 = (CH_LAYOUT_SURROUND or CH_BACK_CENTER); + CH_LAYOUT_2_2 = (CH_LAYOUT_STEREO or CH_SIDE_LEFT or CH_SIDE_RIGHT); +{$IFEND} CH_LAYOUT_QUAD = (CH_LAYOUT_STEREO or CH_BACK_LEFT or CH_BACK_RIGHT); CH_LAYOUT_5POINT0 = (CH_LAYOUT_SURROUND or CH_SIDE_LEFT or CH_SIDE_RIGHT); CH_LAYOUT_5POINT1 = (CH_LAYOUT_5POINT0 or CH_LOW_FREQUENCY); +{$IF LIBAVCODEC_VERSION >= 52025000} // >= 52.25.0 + CH_LAYOUT_5POINT0_BACK = (CH_LAYOUT_SURROUND or CH_BACK_LEFT or + CH_BACK_RIGHT); + CH_LAYOUT_5POINT1_BACK = (CH_LAYOUT_5POINT0_BACK or CH_LOW_FREQUENCY); +{$IFEND} CH_LAYOUT_7POINT1 = (CH_LAYOUT_5POINT1 or CH_BACK_LEFT or CH_BACK_RIGHT); +{$IF LIBAVCODEC_VERSION < 52025000} // < 52.25.0 CH_LAYOUT_7POINT1_WIDE = (CH_LAYOUT_SURROUND or CH_LOW_FREQUENCY or - CH_BACK_LEFT or CH_BACK_RIGHT or - CH_FRONT_LEFT_OF_CENTER or CH_FRONT_RIGHT_OF_CENTER); + CH_BACK_LEFT or CH_BACK_RIGHT or +{$ELSE} + CH_LAYOUT_7POINT1_WIDE = (CH_LAYOUT_5POINT1_BACK or +{$IFEND} + CH_FRONT_LEFT_OF_CENTER or + CH_FRONT_RIGHT_OF_CENTER); CH_LAYOUT_STEREO_DOWNMIX = (CH_STEREO_LEFT or CH_STEREO_RIGHT); @@ -482,20 +533,76 @@ type TAVDiscard = ( {* We leave some space between them for extensions (drop some - * keyframes for intra-only or drop just some bidir frames). *} - AVDISCARD_NONE =-16, ///< discard nothing - AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi - AVDISCARD_NONREF = 8, ///< discard all non reference - AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames - AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes - AVDISCARD_ALL = 48 ///< discard all + * keyframes for intra-only or drop just some bidir frames). + *} + AVDISCARD_NONE = -16, ///< discard nothing + AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi + AVDISCARD_NONREF = 8, ///< discard all non reference + AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames + AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes + AVDISCARD_ALL = 48 ///< discard all + ); + +{$IF LIBAVCODEC_VERSION >= 52028000} // >= 52.28.0 + TAVColorPrimaries = ( + AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B + AVCOL_PRI_UNSPECIFIED = 2, + AVCOL_PRI_BT470M = 4, + AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM + AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC + AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above + AVCOL_PRI_FILM = 8, + AVCOL_PRI_NB ///< Not part of ABI + ); + + TAVColorTransferCharacteristic = ( + AVCOL_TRC_BT709 = 1, ///< also ITU-R BT1361 + AVCOL_TRC_UNSPECIFIED = 2, + AVCOL_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM + AVCOL_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG + AVCOL_TRC_NB ///< Not part of ABI + ); + + TAVColorSpace = ( + AVCOL_SPC_RGB = 0, + AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B + AVCOL_SPC_UNSPECIFIED = 2, + AVCOL_SPC_FCC = 4, + AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 + AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above + AVCOL_SPC_SMPTE240M = 7, + AVCOL_SPC_NB ///< Not part of ABI ); + TAVColorRange = ( + AVCOL_RANGE_UNSPECIFIED = 0, + AVCOL_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges + AVCOL_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges + AVCOL_RANGE_NB ///< Not part of ABI + ); + +(** + * X X 3 4 X X are luma samples, + * 1 2 1-6 are possible chroma positions + * X X 5 6 X 0 is undefined/unknown position + *) + TAVChromaLocation = ( + AVCHROMA_LOC_UNSPECIFIED = 0, + AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4, h264 default + AVCHROMA_LOC_CENTER = 2, ///< mpeg1, jpeg, h263 + AVCHROMA_LOC_TOPLEFT = 3, ///< DV + AVCHROMA_LOC_TOP = 4, + AVCHROMA_LOC_BOTTOMLEFT = 5, + AVCHROMA_LOC_BOTTOM = 6, + AVCHROMA_LOC_NB ///< Not part of ABI + ); +{$IFEND} + PRcOverride = ^TRcOverride; TRcOverride = record {16} - start_frame: cint; - end_frame: cint; - qscale: cint; // if this is 0 then quality_factor will be used instead + start_frame: cint; + end_frame: cint; + qscale: cint; // if this is 0 then quality_factor will be used instead quality_factor: cfloat; end; @@ -655,8 +762,8 @@ type end; const - FF_QSCALE_TYPE_MPEG1 = 0; - FF_QSCALE_TYPE_MPEG2 = 1; + FF_QSCALE_TYPE_MPEG1 = 0; + FF_QSCALE_TYPE_MPEG2 = 1; FF_QSCALE_TYPE_H264 = 2; FF_BUFFER_TYPE_INTERNAL = 1; @@ -678,7 +785,311 @@ const FF_BUFFER_HINTS_PRESERVE = $04; // User must not alter buffer content FF_BUFFER_HINTS_REUSABLE = $08; // Codec will reuse the buffer (update) +const + {$IF LIBAVCODEC_VERSION < 52000000} // < 52.0.0 + DEFAULT_FRAME_RATE_BASE = 1001000; + {$IFEND} + + FF_ASPECT_EXTENDED = 15; + + FF_RC_STRATEGY_XVID = 1; + + FF_BUG_AUTODETECT = 1; ///< autodetection + FF_BUG_OLD_MSMPEG4 = 2; + FF_BUG_XVID_ILACE = 4; + FF_BUG_UMP4 = 8; + FF_BUG_NO_PADDING = 16; + FF_BUG_AMV = 32; + FF_BUG_AC_VLC = 0; ///< will be removed, libavcodec can now handle these non compliant files by default + FF_BUG_QPEL_CHROMA = 64; + FF_BUG_STD_QPEL = 128; + FF_BUG_QPEL_CHROMA2 = 256; + FF_BUG_DIRECT_BLOCKSIZE = 512; + FF_BUG_EDGE = 1024; + FF_BUG_HPEL_CHROMA = 2048; + FF_BUG_DC_CLIP = 4096; + FF_BUG_MS = 8192; ///< workaround various bugs in microsofts broken decoders + //FF_BUG_FAKE_SCALABILITY = 16 //Autodetection should work 100%. + + FF_COMPLIANCE_VERY_STRICT = 2; ///< strictly conform to a older more strict version of the spec or reference software + FF_COMPLIANCE_STRICT = 1; ///< strictly conform to all the things in the spec no matter what consequences + FF_COMPLIANCE_NORMAL = 0; + FF_COMPLIANCE_INOFFICIAL = -1; ///< allow inofficial extensions + FF_COMPLIANCE_EXPERIMENTAL = -2; ///< allow non standarized experimental things + + FF_ER_CAREFUL = 1; + FF_ER_COMPLIANT = 2; + FF_ER_AGGRESSIVE = 3; + FF_ER_VERY_AGGRESSIVE = 4; + + FF_DCT_AUTO = 0; + FF_DCT_FASTINT = 1; + FF_DCT_INT = 2; + FF_DCT_MMX = 3; + FF_DCT_MLIB = 4; + FF_DCT_ALTIVEC = 5; + FF_DCT_FAAN = 6; + + FF_IDCT_AUTO = 0; + FF_IDCT_INT = 1; + FF_IDCT_SIMPLE = 2; + FF_IDCT_SIMPLEMMX = 3; + FF_IDCT_LIBMPEG2MMX = 4; + FF_IDCT_PS2 = 5; + FF_IDCT_MLIB = 6; + FF_IDCT_ARM = 7; + FF_IDCT_ALTIVEC = 8; + FF_IDCT_SH4 = 9; + FF_IDCT_SIMPLEARM = 10; + FF_IDCT_H264 = 11; + FF_IDCT_VP3 = 12; + FF_IDCT_IPP = 13; + FF_IDCT_XVIDMMX = 14; + FF_IDCT_CAVS = 15; + FF_IDCT_SIMPLEARMV5TE= 16; + FF_IDCT_SIMPLEARMV6 = 17; + FF_IDCT_SIMPLEVIS = 18; + FF_IDCT_WMV2 = 19; + FF_IDCT_FAAN = 20; + FF_IDCT_EA = 21; + FF_IDCT_SIMPLENEON = 22; + FF_IDCT_SIMPLEALPHA = 23; + + FF_EC_GUESS_MVS = 1; + FF_EC_DEBLOCK = 2; + + FF_MM_FORCE = $80000000; (* force usage of selected flags (OR) *) + (* lower 16 bits - CPU features *) + FF_MM_MMX = $0001; ///< standard MMX + FF_MM_3DNOW = $0004; ///< AMD 3DNOW + {$IF LIBAVCODEC_MAX_VERSION_MAJOR < 53} + FF_MM_MMXEXT = $0002; ///< SSE integer functions or AMD MMX ext + {$IFEND} + {$IF LIBAVCODEC_VERSION >= 52024000} // >= 52.24.0 + FF_MM_MMX2 = $0002; ///< SSE integer functions or AMD MMX ext + {$IFEND} + FF_MM_SSE = $0008; ///< SSE functions + FF_MM_SSE2 = $0010; ///< PIV SSE2 functions + FF_MM_3DNOWEXT = $0020; ///< AMD 3DNowExt + FF_MM_SSE3 = $0040; ///< Prescott SSE3 functions + FF_MM_SSSE3 = $0080; ///< Conroe SSSE3 functions + {$IF LIBAVCODEC_VERSION >= 52022003} // >= 52.22.3 + FF_MM_SSE4 = $0100; ///< Penryn SSE4.1 functions + FF_MM_SSE42 = $0200; ///< Nehalem SSE4.2 functions + {$IFEND} + FF_MM_IWMMXT = $0100; ///< XScale IWMMXT + FF_MM_ALTIVEC = $0001; ///< standard AltiVec + + FF_PRED_LEFT = 0; + FF_PRED_PLANE = 1; + FF_PRED_MEDIAN = 2; + + FF_DEBUG_PICT_INFO = 1; + FF_DEBUG_RC = 2; + FF_DEBUG_BITSTREAM = 4; + FF_DEBUG_MB_TYPE = 8; + FF_DEBUG_QP = 16; + FF_DEBUG_MV = 32; + FF_DEBUG_DCT_COEFF = $00000040; + FF_DEBUG_SKIP = $00000080; + FF_DEBUG_STARTCODE = $00000100; + FF_DEBUG_PTS = $00000200; + FF_DEBUG_ER = $00000400; + FF_DEBUG_MMCO = $00000800; + FF_DEBUG_BUGS = $00001000; + FF_DEBUG_VIS_QP = $00002000; + FF_DEBUG_VIS_MB_TYPE = $00004000; + FF_DEBUG_BUFFERS = $00008000; + + FF_DEBUG_VIS_MV_P_FOR = $00000001; //visualize forward predicted MVs of P frames + FF_DEBUG_VIS_MV_B_FOR = $00000002; //visualize forward predicted MVs of B frames + FF_DEBUG_VIS_MV_B_BACK = $00000004; //visualize backward predicted MVs of B frames + + FF_CMP_SAD = 0; + FF_CMP_SSE = 1; + FF_CMP_SATD = 2; + FF_CMP_DCT = 3; + FF_CMP_PSNR = 4; + FF_CMP_BIT = 5; + FF_CMP_RD = 6; + FF_CMP_ZERO = 7; + FF_CMP_VSAD = 8; + FF_CMP_VSSE = 9; + FF_CMP_NSSE = 10; + FF_CMP_W53 = 11; + FF_CMP_W97 = 12; + FF_CMP_DCTMAX = 13; + FF_CMP_DCT264 = 14; + FF_CMP_CHROMA = 256; + + FF_DTG_AFD_SAME = 8; + FF_DTG_AFD_4_3 = 9; + FF_DTG_AFD_16_9 = 10; + FF_DTG_AFD_14_9 = 11; + FF_DTG_AFD_4_3_SP_14_9 = 13; + FF_DTG_AFD_16_9_SP_14_9 = 14; + FF_DTG_AFD_SP_4_3 = 15; + + FF_DEFAULT_QUANT_BIAS = 999999; + + FF_LAMBDA_SHIFT = 7; + FF_LAMBDA_SCALE = (1 shl FF_LAMBDA_SHIFT); + FF_QP2LAMBDA = 118; ///< factor to convert from H.263 QP to lambda + FF_LAMBDA_MAX = (256 * 128 - 1); + + FF_QUALITY_SCALE = FF_LAMBDA_SCALE; //FIXME maybe remove + + FF_CODER_TYPE_VLC = 0; + FF_CODER_TYPE_AC = 1; + FF_CODER_TYPE_RAW = 2; + FF_CODER_TYPE_RLE = 3; + FF_CODER_TYPE_DEFLATE = 4; + + SLICE_FLAG_CODED_ORDER = $0001; ///< draw_horiz_band() is called in coded order instead of display + SLICE_FLAG_ALLOW_FIELD = $0002; ///< allow draw_horiz_band() with field slices (MPEG2 field pics) + SLICE_FLAG_ALLOW_PLANE = $0004; ///< allow draw_horiz_band() with 1 component at a time (SVQ1) + + FF_MB_DECISION_SIMPLE = 0; ///< uses mb_cmp + FF_MB_DECISION_BITS = 1; ///< chooses the one which needs the fewest bits + FF_MB_DECISION_RD = 2; ///< rate distortion + + FF_AA_AUTO = 0; + FF_AA_FASTINT = 1; //not implemented yet + FF_AA_INT = 2; + FF_AA_FLOAT = 3; + + FF_PROFILE_UNKNOWN = -99; + FF_PROFILE_AAC_MAIN = 0; + FF_PROFILE_AAC_LOW = 1; + FF_PROFILE_AAC_SSR = 2; + FF_PROFILE_AAC_LTP = 3; + + FF_LEVEL_UNKNOWN = -99; + + X264_PART_I4X4 = $001; (* Analyse i4x4 *) + X264_PART_I8X8 = $002; (* Analyse i8x8 (requires 8x8 transform) *) + X264_PART_P8X8 = $010; (* Analyse p16x8, p8x16 and p8x8 *) + X264_PART_P4X4 = $020; (* Analyse p8x4, p4x8, p4x4 *) + X264_PART_B8X8 = $100; (* Analyse b16x8, b8x16 and b8x8 *) + + FF_COMPRESSION_DEFAULT = -1; + +const + AVPALETTE_SIZE = 1024; + AVPALETTE_COUNT = 256; + +{$IF LIBAVCODEC_MAX_VERSION_MAJOR < 53} +type +(** + * AVPaletteControl + * This structure defines a method for communicating palette changes + * between and demuxer and a decoder. + * + * @deprecated Use AVPacket to send palette changes instead. + * This is totally broken. + *) + PAVPaletteControl = ^TAVPaletteControl; + TAVPaletteControl = record + (* demuxer sets this to 1 to indicate the palette has changed; + * decoder resets to 0 *) + palette_changed: cint; + + (* 4-byte ARGB palette entries, stored in native byte order; note that + * the individual palette components should be on a 8-bit scale; if + * the palette data comes from a IBM VGA native format, the component + * data is probably 6 bits in size and needs to be scaled *) + palette: array [0..AVPALETTE_COUNT - 1] of cuint; + end; {deprecated;} +{$IFEND} + +{$IF LIBAVCODEC_VERSION >= 52023000} // >= 52.23.0 +type + PAVPacket = ^TAVPacket; + TAVPacket = record +(* + * Presentation timestamp in AVStream->time_base units; the time at which + * the decompressed packet will be presented to the user. + * Can be AV_NOPTS_VALUE if it is not stored in the file. + * pts MUST be larger or equal to dts as presentation cannot happen before + * decompression, unless one wants to view hex dumps. Some formats misuse + * the terms dts and pts/cts to mean something different. Such timestamps + * must be converted to true pts/dts before they are stored in AVPacket. + *) + pts: cint64; +(* + * Decompression timestamp in AVStream->time_base units; the time at which + * the packet is decompressed. + * Can be AV_NOPTS_VALUE if it is not stored in the file. + *) + dts: cint64; + data: PByteArray; + size: cint; + stream_index: cint; + flags: cint; +(* + * Duration of this packet in AVStream->time_base units, 0 if unknown. + * Equals next_pts - this_pts in presentation order. + *) + duration: cint; + destruct: procedure (para1: PAVPacket); cdecl; + priv: pointer; + pos: cint64; // byte position in stream, -1 if unknown + +(* + * Time difference in AVStream->time_base units from the pts of this + * packet to the point at which the output from the decoder has converged + * independent from the availability of previous frames. That is, the + * frames are virtually identical no matter if decoding started from + * the very first frame or from this keyframe. + * Is AV_NOPTS_VALUE if unknown. + * This field is not the display duration of the current packet. + * + * The purpose of this field is to allow seeking in streams that have no + * keyframes in the conventional sense. It corresponds to the + * recovery point SEI in H.264 and match_time_delta in NUT. It is also + * essential for some types of subtitle streams to ensure that all + * subtitles are correctly displayed after seeking. + *) + convergence_duration: cint64; + end; + +const + {$IF LIBAVCODEC_VERSION >= 52030002} // >= 52.30.2 + PKT_FLAG_KEY = $0001; + {$ELSE} + AV_PKT_FLAG_KEY = $0001; + {$IF LIBAVCODEC_VERSION_MAJOR < 53} + PKT_FLAG_KEY = AV_PKT_FLAG_KEY; + {$IFEND} + {$IFEND} +{$IFEND} + type + PAVClass = ^TAVClass; {const} + PAVCodecContext = ^TAVCodecContext; + + PAVCodec = ^TAVCodec; + +{$IF LIBAVCODEC_VERSION >= 52018000} // >= 52.18.0 + PAVHWAccel = ^TAVHWAccel; +{$IFEND} + + // int[4] + PQuadIntArray = ^TQuadIntArray; + TQuadIntArray = array[0..3] of cint; + // int (*func)(struct AVCodecContext *c2, void *arg) + TExecuteFunc = function(c2: PAVCodecContext; arg: Pointer): cint; cdecl; + + TAVClass = record + class_name: PAnsiChar; + (* actually passing a pointer to an AVCodecContext + or AVFormatContext, which begin with an AVClass. + Needed because av_log is in libavcodec and has no visibility + of AVIn/OutputFormat *) + item_name: function(): PAnsiChar; cdecl; + option: PAVOption; + end; + {** * Audio Video Frame. * New fields can be added to the end of FF_COMMON_FRAME with minor version @@ -724,7 +1135,7 @@ type * - decoding: Set by libavcodec. *) pts: cint64; - (**\ + (** * picture number in bitstream order * - encoding: set by * - decoding: Set by libavcodec. @@ -753,6 +1164,7 @@ type * is this picture used as reference * The values for this are the same as the MpegEncContext.picture_structure * variable, that is 1->top field, 2->bottom field, 3->frame/both fields. + * Set to 4 for delayed, non-reference frames. * - encoding: unused * - decoding: Set by libavcodec. (before get_buffer() call)). *) @@ -877,7 +1289,7 @@ type *) ref_index: array [0..1] of PShortint; - {$IF LIBAVCODEC_VERSION >= 51068000} // 51.68.0 + {$IF LIBAVCODEC_VERSION >= 51068000} // >= 51.68.0 (** * reordered opaque 64bit number (generally a PTS) from AVCodecContext.reordered_opaque * output in AVFrame.reordered_opaque @@ -886,8 +1298,20 @@ type *) reordered_opaque: cint64; {$IFEND} + + {$IF LIBAVCODEC_VERSION = 52021000} // = 52.21.0 + (** + * hardware accelerator private data (FFmpeg allocated) + * - encoding: unused + * - decoding: Set by libavcodec + *) + hwaccel_data_private: pointer; + {$IFEND} + {$IF LIBAVCODEC_VERSION >= 52022000} // >= 52.22.0 + hwaccel_picture_private: pointer; + {$IFEND} - {$IF LIBAVCODEC_VERSION >= 51070000} // 51.70.0 + {$IF LIBAVCODEC_VERSION >= 51070000} // >= 51.70.0 (** * Bits per sample/pixel of internal libavcodec pixel/sample format. * This field is applicable only when sample_fmt is SAMPLE_FMT_S32. @@ -897,7 +1321,7 @@ type bits_per_raw_sample: cint; {$IFEND} - {$IF LIBAVCODEC_VERSION >= 52002000} // 52.2.0 + {$IF LIBAVCODEC_VERSION >= 52002000} // >= 52.2.0 (** * Audio channel layout. * - encoding: set by user. @@ -913,7 +1337,7 @@ type request_channel_layout: cint64; {$IFEND} - {$IF LIBAVCODEC_VERSION >= 52004000} // 52.4.0 + {$IF LIBAVCODEC_VERSION >= 52004000} // >= 52.4.0 (** * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow. * - encoding: Set by user. @@ -928,234 +1352,73 @@ type *) rc_min_vbv_overflow_use: cfloat; {$IFEND} - end; - -const - {$IF LIBAVCODEC_VERSION < 52000000} // < 52.0.0 - DEFAULT_FRAME_RATE_BASE = 1001000; - {$IFEND} - - FF_ASPECT_EXTENDED = 15; - - FF_RC_STRATEGY_XVID = 1; - - FF_BUG_AUTODETECT = 1; ///< autodetection - FF_BUG_OLD_MSMPEG4 = 2; - FF_BUG_XVID_ILACE = 4; - FF_BUG_UMP4 = 8; - FF_BUG_NO_PADDING = 16; - FF_BUG_AMV = 32; - FF_BUG_AC_VLC = 0; ///< will be removed, libavcodec can now handle these non compliant files by default - FF_BUG_QPEL_CHROMA = 64; - FF_BUG_STD_QPEL = 128; - FF_BUG_QPEL_CHROMA2 = 256; - FF_BUG_DIRECT_BLOCKSIZE = 512; - FF_BUG_EDGE = 1024; - FF_BUG_HPEL_CHROMA = 2048; - FF_BUG_DC_CLIP = 4096; - FF_BUG_MS = 8192; ///< workaround various bugs in microsofts broken decoders - //FF_BUG_FAKE_SCALABILITY = 16 //Autodetection should work 100%. - - FF_COMPLIANCE_VERY_STRICT = 2; ///< strictly conform to a older more strict version of the spec or reference software - FF_COMPLIANCE_STRICT = 1; ///< strictly conform to all the things in the spec no matter what consequences - FF_COMPLIANCE_NORMAL = 0; - FF_COMPLIANCE_INOFFICIAL = -1; ///< allow inofficial extensions - FF_COMPLIANCE_EXPERIMENTAL = -2; ///< allow non standarized experimental things - - FF_ER_CAREFUL = 1; - FF_ER_COMPLIANT = 2; - FF_ER_AGGRESSIVE = 3; - FF_ER_VERY_AGGRESSIVE = 4; - - FF_DCT_AUTO = 0; - FF_DCT_FASTINT = 1; - FF_DCT_INT = 2; - FF_DCT_MMX = 3; - FF_DCT_MLIB = 4; - FF_DCT_ALTIVEC = 5; - FF_DCT_FAAN = 6; - - FF_IDCT_AUTO = 0; - FF_IDCT_INT = 1; - FF_IDCT_SIMPLE = 2; - FF_IDCT_SIMPLEMMX = 3; - FF_IDCT_LIBMPEG2MMX = 4; - FF_IDCT_PS2 = 5; - FF_IDCT_MLIB = 6; - FF_IDCT_ARM = 7; - FF_IDCT_ALTIVEC = 8; - FF_IDCT_SH4 = 9; - FF_IDCT_SIMPLEARM = 10; - FF_IDCT_H264 = 11; - FF_IDCT_VP3 = 12; - FF_IDCT_IPP = 13; - FF_IDCT_XVIDMMX = 14; - FF_IDCT_CAVS = 15; - FF_IDCT_SIMPLEARMV5TE= 16; - FF_IDCT_SIMPLEARMV6 = 17; - FF_IDCT_SIMPLEVIS = 18; - FF_IDCT_WMV2 = 19; - FF_IDCT_FAAN = 20; - FF_IDCT_EA = 21; - FF_IDCT_SIMPLENEON = 22; - FF_IDCT_SIMPLEALPHA = 23; - - FF_EC_GUESS_MVS = 1; - FF_EC_DEBLOCK = 2; - - FF_MM_FORCE = $80000000; (* force usage of selected flags (OR) *) - (* lower 16 bits - CPU features *) - FF_MM_MMX = $0001; ///< standard MMX - FF_MM_3DNOW = $0004; ///< AMD 3DNOW - FF_MM_MMXEXT = $0002; ///< SSE integer functions or AMD MMX ext - FF_MM_SSE = $0008; ///< SSE functions - FF_MM_SSE2 = $0010; ///< PIV SSE2 functions - FF_MM_3DNOWEXT = $0020; ///< AMD 3DNowExt - FF_MM_SSE3 = $0040; ///< Prescott SSE3 functions - FF_MM_SSSE3 = $0080; ///< Conroe SSSE3 functions - FF_MM_IWMMXT = $0100; ///< XScale IWMMXT - FF_MM_ALTIVEC = $0001; ///< standard AltiVec - - FF_PRED_LEFT = 0; - FF_PRED_PLANE = 1; - FF_PRED_MEDIAN = 2; - - FF_DEBUG_PICT_INFO = 1; - FF_DEBUG_RC = 2; - FF_DEBUG_BITSTREAM = 4; - FF_DEBUG_MB_TYPE = 8; - FF_DEBUG_QP = 16; - FF_DEBUG_MV = 32; - FF_DEBUG_DCT_COEFF = $00000040; - FF_DEBUG_SKIP = $00000080; - FF_DEBUG_STARTCODE = $00000100; - FF_DEBUG_PTS = $00000200; - FF_DEBUG_ER = $00000400; - FF_DEBUG_MMCO = $00000800; - FF_DEBUG_BUGS = $00001000; - FF_DEBUG_VIS_QP = $00002000; - FF_DEBUG_VIS_MB_TYPE = $00004000; - FF_DEBUG_BUFFERS = $00008000; - - FF_DEBUG_VIS_MV_P_FOR = $00000001; //visualize forward predicted MVs of P frames - FF_DEBUG_VIS_MV_B_FOR = $00000002; //visualize forward predicted MVs of B frames - FF_DEBUG_VIS_MV_B_BACK = $00000004; //visualize backward predicted MVs of B frames - - FF_CMP_SAD = 0; - FF_CMP_SSE = 1; - FF_CMP_SATD = 2; - FF_CMP_DCT = 3; - FF_CMP_PSNR = 4; - FF_CMP_BIT = 5; - FF_CMP_RD = 6; - FF_CMP_ZERO = 7; - FF_CMP_VSAD = 8; - FF_CMP_VSSE = 9; - FF_CMP_NSSE = 10; - FF_CMP_W53 = 11; - FF_CMP_W97 = 12; - FF_CMP_DCTMAX = 13; - FF_CMP_DCT264 = 14; - FF_CMP_CHROMA = 256; - - FF_DTG_AFD_SAME = 8; - FF_DTG_AFD_4_3 = 9; - FF_DTG_AFD_16_9 = 10; - FF_DTG_AFD_14_9 = 11; - FF_DTG_AFD_4_3_SP_14_9 = 13; - FF_DTG_AFD_16_9_SP_14_9 = 14; - FF_DTG_AFD_SP_4_3 = 15; - - FF_DEFAULT_QUANT_BIAS = 999999; - - FF_LAMBDA_SHIFT = 7; - FF_LAMBDA_SCALE = (1 shl FF_LAMBDA_SHIFT); - FF_QP2LAMBDA = 118; ///< factor to convert from H.263 QP to lambda - FF_LAMBDA_MAX = (256 * 128 - 1); - - FF_QUALITY_SCALE = FF_LAMBDA_SCALE; //FIXME maybe remove - - FF_CODER_TYPE_VLC = 0; - FF_CODER_TYPE_AC = 1; - FF_CODER_TYPE_RAW = 2; - FF_CODER_TYPE_RLE = 3; - FF_CODER_TYPE_DEFLATE = 4; - - SLICE_FLAG_CODED_ORDER = $0001; ///< draw_horiz_band() is called in coded order instead of display - SLICE_FLAG_ALLOW_FIELD = $0002; ///< allow draw_horiz_band() with field slices (MPEG2 field pics) - SLICE_FLAG_ALLOW_PLANE = $0004; ///< allow draw_horiz_band() with 1 component at a time (SVQ1) - - FF_MB_DECISION_SIMPLE = 0; ///< uses mb_cmp - FF_MB_DECISION_BITS = 1; ///< chooses the one which needs the fewest bits - FF_MB_DECISION_RD = 2; ///< rate distortion - - FF_AA_AUTO = 0; - FF_AA_FASTINT = 1; //not implemented yet - FF_AA_INT = 2; - FF_AA_FLOAT = 3; - - FF_PROFILE_UNKNOWN = -99; - FF_PROFILE_AAC_MAIN = 0; - FF_PROFILE_AAC_LOW = 1; - FF_PROFILE_AAC_SSR = 2; - FF_PROFILE_AAC_LTP = 3; - - FF_LEVEL_UNKNOWN = -99; - - X264_PART_I4X4 = $001; (* Analyse i4x4 *) - X264_PART_I8X8 = $002; (* Analyse i8x8 (requires 8x8 transform) *) - X264_PART_P8X8 = $010; (* Analyse p16x8, p8x16 and p8x8 *) - X264_PART_P4X4 = $020; (* Analyse p8x4, p4x8, p4x4 *) - X264_PART_B8X8 = $100; (* Analyse b16x8, b8x16 and b8x8 *) - - FF_COMPRESSION_DEFAULT = -1; - -const - AVPALETTE_SIZE = 1024; - AVPALETTE_COUNT = 256; - -type -(** - * AVPaletteControl - * This structure defines a method for communicating palette changes - * between and demuxer and a decoder. - * - * @deprecated Use AVPacket to send palette changes instead. - * This is totally broken. - *) - PAVPaletteControl = ^TAVPaletteControl; - TAVPaletteControl = record - (* demuxer sets this to 1 to indicate the palette has changed; - * decoder resets to 0 *) - palette_changed: cint; - - (* 4-byte ARGB palette entries, stored in native byte order; note that - * the individual palette components should be on a 8-bit scale; if - * the palette data comes from a IBM VGA native format, the component - * data is probably 6 bits in size and needs to be scaled *) - palette: array [0..AVPALETTE_COUNT - 1] of cuint; - end; {deprecated;} + {$IF LIBAVCODEC_VERSION >= 52018000} // >= 52.18.0 + (** + * Hardware accelerator in use + * - encoding: unused. + * - decoding: Set by libavcodec + *) + hwaccel: PAVHWAccel; + {$IFEND} + {$IF LIBAVCODEC_VERSION >= 52020000} // >= 52.20.0 + (** + * For some codecs, the time base is closer to the field rate than the frame rate. + * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration + * if no telecine is used ... + * + * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. + *) + ticks_per_frame: cint; + {$IFEND} + {$IF LIBAVCODEC_VERSION >= 52021000} // >= 52.21.0 + (** + * Hardware accelerator context. + * For some hardware accelerators, a global context needs to be + * provided by the user. In that case, this holds display-dependent + * data FFmpeg cannot instantiate itself. Please refer to the + * FFmpeg HW accelerator documentation to know how to fill this + * is. e.g. for VA API, this is a struct vaapi_context. + * - encoding: unused + * - decoding: Set by user + *) + hwaccel_context: pointer; + {$IFEND} + {$IF LIBAVCODEC_VERSION >= 52028000} // >= 52.28.0 + (** + * Chromaticity coordinates of the source primaries. + * - encoding: Set by user + * - decoding: Set by libavcodec + *) + color_primaries: TAVColorPrimaries; -type - PAVClass = ^TAVClass; {const} - PAVCodecContext = ^TAVCodecContext; + (** + * Color Transfer Characteristic. + * - encoding: Set by user + * - decoding: Set by libavcodec + *) + color_trc: TAVColorTransferCharacteristic; - PAVCodec = ^TAVCodec; + (** + * YUV colorspace type. + * - encoding: Set by user + * - decoding: Set by libavcodec + *) + colorspace: TAVColorSpace; - // int[4] - PQuadIntArray = ^TQuadIntArray; - TQuadIntArray = array[0..3] of cint; - // int (*func)(struct AVCodecContext *c2, void *arg) - TExecuteFunc = function(c2: PAVCodecContext; arg: Pointer): cint; cdecl; + (** + * MPEG vs JPEG YUV range. + * - encoding: Set by user + * - decoding: Set by libavcodec + *) + color_range: TAVColorRange; - TAVClass = record - class_name: PAnsiChar; - (* actually passing a pointer to an AVCodecContext - or AVFormatContext, which begin with an AVClass. - Needed because av_log is in libavcodec and has no visibility - of AVIn/OutputFormat *) - item_name: function(): PAnsiChar; cdecl; - option: PAVOption; + (** + * This defines the location of chroma samples. + * - encoding: Set by user + * - decoding: Set by libavcodec + *) + chroma_sample_location: TAVChromaLocation; + {$IFEND} end; (** @@ -1273,6 +1536,13 @@ type * decoder to draw a horizontal band. It improves cache usage. Not * all codecs can do that. You must check the codec capabilities * beforehand. + * The function is also used by hardware acceleration APIs. + * It is called at least once during frame decoding to pass + * the data needed for hardware render. + * In that mode instead of pixel data, AVFrame points to + * a structure specific to the acceleration API. The application + * reads the structure and can change some fields to indicate progress + * or mark state. * - encoding: unused * - decoding: Set by user. * @param height the height of the slice @@ -1301,7 +1571,9 @@ type *) frame_size: cint; frame_number: cint; ///< audio or video frame number +{$IF LIBAVCODEC_MAX_VERSION_MAJOR < 53} real_pict_num: cint; ///< returns the real picture number of previous encoded frame +{$IFEND} (** * Number of frames the decoded output will be delayed relative to @@ -1490,6 +1762,9 @@ type * If pic.reference is set then the frame will be read later by libavcodec. * avcodec_align_dimensions() should be used to find the required width and * height, as they normally need to be rounded up to the next multiple of 16. + * if CODEC_CAP_DR1 is not set then get_buffer() must call + * avcodec_default_get_buffer() instead of providing buffers allocated by + * some other means. * - encoding: unused * - decoding: Set by libavcodec., user can override. *) @@ -1505,7 +1780,8 @@ type release_buffer: procedure (c: PAVCodecContext; pic: PAVFrame); cdecl; (** - * If 1 the stream has a 1 frame delay during decoding. + * Size of the frame reordering buffer in the decoder. + * For MPEG-2 it is 1 IPB or 0 low delay IP. * - encoding: Set by libavcodec. * - decoding: Set by libavcodec. *) @@ -2012,6 +2288,9 @@ type * libavcodec will pass previous buffer in pic, function should return * same buffer or new buffer with old frame "painted" into it. * If pic.data[0] == NULL must behave like get_buffer(). + * if CODEC_CAP_DR1 is not set then reget_buffer() must call + * avcodec_default_reget_buffer() instead of providing buffers allocated by + * some other means. * - encoding: unused * - decoding: Set by libavcodec., user can override *) @@ -2465,6 +2744,15 @@ type *) reordered_opaque: cint64; {$IFEND} + + {$IF LIBAVCODEC_VERSION >= 52028000} // 52.28.0 + (** + * This defines the location of chroma samples. + * - encoding: Set by user + * - decoding: Set by libavcodec + *) + chroma_sample_location: TAVChromaLocation; + {$IFEND} end; (** @@ -2479,7 +2767,11 @@ type encode: function (avctx: PAVCodecContext; buf: PByteArray; buf_size: cint; data: pointer): cint; cdecl; close: function (avctx: PAVCodecContext): cint; cdecl; decode: function (avctx: PAVCodecContext; outdata: pointer; var outdata_size: cint; + {$IF LIBAVCODEC_VERSION < 52025000} // 52.25.0 buf: {const} PByteArray; buf_size: cint): cint; cdecl; + {$ELSE} + avpkt: PAVPacket): cint; cdecl; + {$IFEND} (** * Codec capabilities. * see CODEC_CAP_* @@ -2495,8 +2787,8 @@ type pix_fmts: {const} PAVPixelFormat; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 {$IF LIBAVCODEC_VERSION >= 51055000} // 51.55.0 (** - * Descriptive name for the codec, meant to be more human readable than \p name. - * You \e should use the NULL_IF_CONFIG_SMALL() macro to define it. + * Descriptive name for the codec, meant to be more human readable than name. + * You should use the NULL_IF_CONFIG_SMALL() macro to define it. *) long_name: {const} PAnsiChar; {$IFEND} @@ -2511,6 +2803,105 @@ type {$IFEND} end; +{$IF LIBAVCODEC_VERSION >= 52018000} // 52.18.0 +(** + * AVHWAccel. + *) + TAVHWAccel = record + (** + * Name of the hardware accelerated codec. + * The name is globally unique among encoders and among decoders (but an + * encoder and a decoder can share the same name). + *) + name: PAnsiChar; + + (** + * Type of codec implemented by the hardware accelerator. + * + * See CODEC_TYPE_xxx + *) + type_: TCodecType; + + (** + * Codec implemented by the hardware accelerator. + * + * See CODEC_ID_xxx + *) + id: TCodecID; + + (** + * Supported pixel format. + * + * Only hardware accelerated formats are supported here. + *) + pix_fmt: {const} PAVPixelFormat; + + (** + * Hardware accelerated codec capabilities. + * see FF_HWACCEL_CODEC_CAP_* + *) + capabilities: cint; + + next: PAVCodec; + + (** + * Called at the beginning of each frame or field picture. + * + * Meaningful frame information (codec specific) is guaranteed to + * be parsed at this point. This function is mandatory. + * + * Note that buf can be NULL along with buf_size set to 0. + * Otherwise, this means the whole frame is available at this point. + * + * @param avctx the codec context + * @param buf the frame data buffer base + * @param buf_size the size of the frame in bytes + * @return zero if successful, a negative value otherwise + *) + start_frame: function (avctx: PAVCodecContext; + buf: PByteArray; + buf_size: cint): cint; cdecl; + + (** + * Callback for each slice. + * + * Meaningful slice information (codec specific) is guaranteed to + * be parsed at this point. This function is mandatory. + * + * @param avctx the codec context + * @param buf the slice data buffer base + * @param buf_size the size of the slice in bytes + * @return zero if successful, a negative value otherwise + *) + decode_slice: function (avctx: PAVCodecContext; + buf: PByteArray; + buf_size: cint): cint; cdecl; + + (** + * Called at the end of each frame or field picture. + * + * The whole picture is parsed at this point and can now be sent + * to the hardware accelerator. This function is mandatory. + * + * @param avctx the codec context + * @return zero if successful, a negative value otherwise + *) + end_frame: function (avctx: PAVCodecContext): cint; cdecl; + +{$IF LIBAVCODEC_VERSION >= 52021000} // >= 52.21.0 + (** + * Size of HW accelerator private data. + * + * Private data is allocated with av_mallocz() before + * AVCodecContext.get_buffer() and deallocated after + * AVCodecContext.release_buffer(). + *) + priv_data_size: cint; +{$IFEND} + + end; +{$IFEND} + (** * four components are given, that's all. * the last component is alpha @@ -2594,9 +2985,69 @@ type {$IFEND} end; +{$IF LIBAVCODEC_VERSION >= 52025000} // 52.25.0 +{ packet functions } -(* resample.c *) +(** + * @deprecated use NULL instead + *) +procedure av_destruct_packet_nofree(pkt: PAVPacket); + cdecl; external av__codec; +(* + * Default packet destructor. + *) +procedure av_destruct_packet(pkt: PAVPacket); + cdecl; external av__codec; + +(* + * Initialize optional fields of a packet with default values. + * + * @param pkt packet + *) +procedure av_init_packet(pkt: PAVPacket); + cdecl; external av__codec; + +(* + * Allocate the payload of a packet and initialize its fields with + * default values. + * + * @param pkt packet + * @param size wanted payload size + * @return 0 if OK, AVERROR_xxx otherwise + *) +function av_new_packet(pkt: PAVPacket; size: cint): cint; + cdecl; external av__codec; + +(* + * Reduce packet size, correctly zeroing padding + * + * @param pkt packet + * @param size new size + *) +procedure av_shrink_packet(pkt: PAVPacket; size: cint); + cdecl; external av__codec; + +(* + * @warning This is a hack - the packet memory allocation stuff is broken. The + * packet is allocated if it was not really allocated. + *) +function av_dup_packet(pkt: PAVPacket): cint; + cdecl; external av__codec; + +(* + * Free a packet. + * + * @param pkt packet to free + *) +procedure av_free_packet(pkt: PAVPacket); +{$IF LIBAVCODEC_VERSION >= 52028000} // 52.28.0 + cdecl; external av__codec; +{$IFEND} +{$IFEND} + +(* resample.c *) +type PReSampleContext = pointer; PAVResampleContext = pointer; PImgReSampleContext = pointer; @@ -2611,15 +3062,44 @@ function audio_resample (s: PReSampleContext; output: PSmallint; input: PSmallin procedure audio_resample_close (s: PReSampleContext); cdecl; external av__codec; - +(** + * Initializes an audio resampler. + * Note, if either rate is not an integer then simply scale both rates up so they are. + * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq + * @param log2_phase_count log2 of the number of entries in the polyphase filterbank + * @param linear If 1 then the used FIR filter will be linearly interpolated + between the 2 closest, if 0 the closest will be used + * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate + *) function av_resample_init (out_rate: cint; in_rate: cint; filter_length: cint; log2_phase_count: cint; linear: cint; cutoff: cdouble): PAVResampleContext; cdecl; external av__codec; +(** + * resamples. + * @param src an array of unconsumed samples + * @param consumed the number of samples of src which have been consumed are returned here + * @param src_size the number of unconsumed samples available + * @param dst_size the amount of space in samples available in dst + * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context. + * @return the number of samples written in dst or -1 if an error occurred + *) function av_resample (c: PAVResampleContext; dst: PSmallint; src: PSmallint; var consumed: cint; src_size: cint; dst_size: cint; update_ctx: cint): cint; cdecl; external av__codec; +(** + * Compensates samplerate/timestamp drift. The compensation is done by changing + * the resampler parameters, so no audible clicks or similar distortions occur + * @param compensation_distance distance in output samples over which the compensation should be performed + * @param sample_delta number of output samples which should be output less + * + * example: av_resample_compensate(c, 10, 500) + * here instead of 510 samples only 500 samples would be output + * + * note, due to rounding the actual compensation might be slightly different, + * especially if the compensation_distance is large and the in_rate used during init is small + *) procedure av_resample_compensate (c: PAVResampleContext; sample_delta: cint; compensation_distance: cint); cdecl; external av__codec; @@ -2627,7 +3107,6 @@ procedure av_resample_compensate (c: PAVResampleContext; sample_delta: cint; procedure av_resample_close (c: PAVResampleContext); cdecl; external av__codec; - {$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 (* YUV420 format is assumed ! *) @@ -2660,7 +3139,6 @@ procedure img_resample (s: PImgReSampleContext; output: PAVPicture; input: {cons *) procedure img_resample_close (s: PImgReSampleContext); cdecl; external av__codec; deprecated; - {$IFEND} (** @@ -2692,6 +3170,7 @@ procedure avpicture_free (picture: PAVPicture); * If a planar format is specified, several pointers will be set pointing to * the different picture planes and the line sizes of the different planes * will be stored in the lines_sizes array. + * Call with ptr == NULL to get the required size for the ptr buffer. * * @param picture AVPicture whose fields are to be filled in * @param ptr Buffer which will contain or contains the actual image data @@ -2712,11 +3191,14 @@ function avpicture_layout (src: {const} PAVPicture; pix_fmt: TAVPixelFormat; (** * Calculate the size in bytes that a picture of the given width and height * would occupy if stored in the given picture format. + * Note that this returns the size of a compact representation as generated + * by avpicture_layout, which can be smaller than the size required for e.g. + * avpicture_fill. * * @param pix_fmt the given picture format * @param width the width of the image * @param height the height of the image - * @return Image data size in bytes + * @return Image data size in bytes or -1 on error (e.g. too large dimensions). *) function avpicture_get_size (pix_fmt: TAVPixelFormat; width: cint; height: cint): cint; cdecl; external av__codec; @@ -2724,12 +3206,34 @@ function avpicture_get_size (pix_fmt: TAVPixelFormat; width: cint; height: cint) procedure avcodec_get_chroma_sub_sample (pix_fmt: TAVPixelFormat; var h_shift: cint; var v_shift: cint); cdecl; external av__codec; +(** + * Returns the pixel format corresponding to the name \p name. + * + * If there is no pixel format with name \p name, then looks for a + * pixel format with the name corresponding to the native endian + * format of \p name. + * For example in a little-endian system, first looks for "gray16", + * then for "gray16le". + * + * Finally if no pixel format has been found, returns \c PIX_FMT_NONE. + *) function avcodec_get_pix_fmt_name(pix_fmt: TAVPixelFormat): PAnsiChar; cdecl; external av__codec; procedure avcodec_set_dimensions(s: PAVCodecContext; width: cint; height: cint); cdecl; external av__codec; +(** + * Returns the pixel format corresponding to the name name. + * + * If there is no pixel format with name name, then looks for a + * pixel format with the name corresponding to the native endian + * format of name. + * For example in a little-endian system, first looks for "gray16", + * then for "gray16le". + * + * Finally if no pixel format has been found, returns PIX_FMT_NONE. + *) function avcodec_get_pix_fmt(name: {const} PAnsiChar): TAVPixelFormat; cdecl; external av__codec; @@ -2773,7 +3277,7 @@ function avcodec_get_pix_fmt_loss (dst_pix_fmt: TAVPixelFormat; src_pix_fmt: TAV * some formats to other formats. avcodec_find_best_pix_fmt() searches which of * the given pixel formats should be used to suffer the least amount of loss. * The pixel formats from which it chooses one, are determined by the - * \p pix_fmt_mask parameter. + * pix_fmt_mask parameter. * * @code * src_pix_fmt = PIX_FMT_YUV420P; @@ -2791,10 +3295,14 @@ function avcodec_get_pix_fmt_loss (dst_pix_fmt: TAVPixelFormat; src_pix_fmt: TAV function avcodec_find_best_pix_fmt(pix_fmt_mask: cint64; src_pix_fmt: TAVPixelFormat; has_alpha: cint; loss_ptr: PCint): cint; cdecl; external av__codec; -{$ELSE} +{$ELSEIF LIBAVCODEC_VERSION < 52022001} function avcodec_find_best_pix_fmt(pix_fmt_mask: cint; src_pix_fmt: TAVPixelFormat; has_alpha: cint; loss_ptr: PCint): cint; cdecl; external av__codec; +{$ELSE} +function avcodec_find_best_pix_fmt(pix_fmt_mask: cint; src_pix_fmt: TAVPixelFormat; + has_alpha: cint; loss_ptr: PCint): TAVPixelFormat; + cdecl; external av__codec; {$IFEND} {$IF LIBAVCODEC_VERSION >= 51041000} // 51.41.0 @@ -2808,8 +3316,13 @@ function avcodec_find_best_pix_fmt(pix_fmt_mask: cint; src_pix_fmt: TAVPixelForm * a negative value to print the corresponding header. * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1. *) +{$IF LIBAVCODEC_VERSION < 52022001} // 52.22.1 procedure avcodec_pix_fmt_string (buf: PAnsiChar; buf_size: cint; pix_fmt: cint); cdecl; external av__codec; +{$ELSE} +procedure avcodec_pix_fmt_string (buf: PAnsiChar; buf_size: cint; pix_fmt: TAVPixelFormat); + cdecl; external av__codec; +{$IFEND} {$IFEND} const @@ -2822,7 +3335,8 @@ const *) function img_get_alpha_info (src: {const} PAVPicture; pix_fmt: TAVPixelFormat; - width: cint; height: cint): cint; + width: cint; + height: cint): cint; cdecl; external av__codec; {$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 @@ -2838,8 +3352,11 @@ function img_convert (dst: PAVPicture; dst_pix_fmt: TAVPixelFormat; (* deinterlace a picture *) (* deinterlace - if not supported return -1 *) -function avpicture_deinterlace (dst: PAVPicture; src: {const} PAVPicture; - pix_fmt: TAVPixelFormat; width: cint; height: cint): cint; +function avpicture_deinterlace (dst: PAVPicture; + src: {const} PAVPicture; + pix_fmt: TAVPixelFormat; + width: cint; + height: cint): cint; cdecl; external av__codec; {* external high level API *} @@ -2852,6 +3369,11 @@ var {$IFEND} {$IF LIBAVCODEC_VERSION >= 51049000} // 51.49.0 +(** + * If c is NULL, returns the first registered codec, + * if c is non-NULL, returns the next registered codec after c, + * or NULL if c is the last one. + *) function av_codec_next(c: PAVCodec): PAVCodec; cdecl; external av__codec; {$IFEND} @@ -2871,20 +3393,27 @@ function avcodec_build(): cuint; (** * Initializes libavcodec. * - * @warning This function \e must be called before any other libavcodec + * @warning This function must be called before any other libavcodec * function. *) procedure avcodec_init(); cdecl; external av__codec; (** - * Register the codec \p codec and initialize libavcodec. + * Register the codec codec and initialize libavcodec. * * @see avcodec_init() *) +{$IF LIBAVCODEC_VERSION >= 52014000} // 52.14.0 +procedure avcodec_register(codec: PAVCodec); + cdecl; external av__codec; +// Deprecated in favor of avcodec_register. +procedure register_avcodec(codec: PAVCodec); + cdecl; external av__codec; deprecated; +{$ELSEIF LIBAVCODEC_VERSION_MAJOR < 53} procedure register_avcodec(codec: PAVCodec); cdecl; external av__codec; - +{$IFEND} (** * Finds a registered encoder with a matching codec ID. * @@ -3050,125 +3579,189 @@ function avcodec_open(avctx: PAVCodecContext; codec: PAVCodec): cint; {$IF LIBAVCODEC_VERSION < 52000000} // < 52.0.0 (** - * @deprecated Use avcodec_decode_audio2() instead. + * @deprecated Use avcodec_decode_audio2 instead. *) function avcodec_decode_audio(avctx: PAVCodecContext; samples: PSmallint; var frame_size_ptr: cint; buf: {const} PByteArray; buf_size: cint): cint; - cdecl; external av__codec; + cdecl; external av__codec; {deprecated;} {$IFEND} +{$IF LIBAVCODEC_MAX_VERSION_MAJOR < 53} {$IF LIBAVCODEC_VERSION >= 51030000} // 51.30.0 (** - * Decodes an audio frame from \p buf into \p samples. - * The avcodec_decode_audio2() function decodes an audio frame from the input - * buffer \p buf of size \p buf_size. To decode it, it makes use of the - * audio codec which was coupled with \p avctx using avcodec_open(). The - * resulting decoded frame is stored in output buffer \p samples. If no frame - * could be decompressed, \p frame_size_ptr is zero. Otherwise, it is the - * decompressed frame size in \e bytes. + * Decodes an audio frame from buf into samples. + * Wrapper function which calls avcodec_decode_audio3. + * + * @deprecated Use avcodec_decode_audio3 instead. + * @param avctx the codec context + * @param[out] samples the output buffer + * @param[in,out] frame_size_ptr the output buffer size in bytes + * @param[in] buf the input buffer + * @param[in] buf_size the input buffer size in bytes + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame could be decompressed. + *) +function avcodec_decode_audio2(avctx: PAVCodecContext; samples: PSmallint; + var frame_size_ptr: cint; + buf: {const} PByteArray; buf_size: cint): cint; + cdecl; external av__codec; {deprecated;} +{$IFEND} +{$IFEND} + +{$IF LIBAVCODEC_VERSION >= 52025000} // 52.25.0 +(** + * Decodes the audio frame of size avpkt->size from avpkt->data into samples. + * Some decoders may support multiple frames in a single AVPacket, such + * decoders would then just decode the first frame. + * If no frame + * could be decompressed, frame_size_ptr is zero. Otherwise, it is the + * decompressed frame size in bytes. * - * @warning You \e must set \p frame_size_ptr to the allocated size of the - * output buffer before calling avcodec_decode_audio2(). + * @warning You must set frame_size_ptr to the allocated size of the + * output buffer before calling avcodec_decode_audio3(). * - * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than + * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than * the actual read bytes because some optimized bitstream readers read 32 or 64 * bits at once and could read over the end. * - * @warning The end of the input buffer \p buf should be set to 0 to ensure that + * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that * no overreading happens for damaged MPEG streams. * - * @note You might have to align the input buffer \p buf and output buffer \p + * @note You might have to align the input buffer avpkt->data and output buffer * samples. The alignment requirements depend on the CPU: On some CPUs it isn't * necessary at all, on others it won't work at all if not aligned and on others - * it will work but it will have an impact on performance. In practice, the - * bitstream should have 4 byte alignment at minimum and all sample data should - * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If - * the linesize is not a multiple of 16 then there's no sense in aligning the - * start of the buffer to 16. + * * it will work but it will have an impact on performance. + * + * In practice, avpkt->data should have 4 byte alignment at minimum and + * samples should be 16 byte aligned unless the CPU doesn't need it + * (AltiVec and SSE do). * * @note Some codecs have a delay between input and output, these need to be - * feeded with buf=NULL, buf_size=0 at the end to return the remaining frames. + * feeded with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames. * * @param avctx the codec context * @param[out] samples the output buffer * @param[in,out] frame_size_ptr the output buffer size in bytes - * @param[in] buf the input buffer - * @param[in] buf_size the input buffer size in bytes + * @param[in] avpkt The input AVPacket containing the input buffer. + * You can create such packet with av_init_packet() and by then setting + * data and size, some decoders might in addition need other fields. + * All decoders are designed to use the least fields possible though. * @return On error a negative value is returned, otherwise the number of bytes * used or zero if no frame could be decompressed. *) -function avcodec_decode_audio2(avctx: PAVCodecContext; samples: PSmallint; +function avcodec_decode_audio3(avctx: PAVCodecContext; samples: PSmallint; var frame_size_ptr: cint; - buf: {const} PByteArray; buf_size: cint): cint; + avpkt: PAVPacket): cint; cdecl; external av__codec; {$IFEND} +{$IF LIBAVCODEC_MAX_VERSION_MAJOR < 53} (** - * Decodes a video frame from \p buf into \p picture. - * The avcodec_decode_video() function decodes a video frame from the input - * buffer \p buf of size \p buf_size. To decode it, it makes use of the - * video codec which was coupled with \p avctx using avcodec_open(). The - * resulting decoded frame is stored in \p picture. + * Decodes a video frame from buf into picture. + * Wrapper function which calls avcodec_decode_video2. * - * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than + * @deprecated Use avcodec_decode_video2 instead. + * @param avctx the codec context + * @param[out] picture The AVFrame in which the decoded video frame will be stored. + * @param[in] buf the input buffer + * @param[in] buf_size the size of the input buffer in bytes + * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame could be decompressed. + *) +function avcodec_decode_video(avctx: PAVCodecContext; picture: PAVFrame; + var got_picture_ptr: cint; + buf: {const} PByteArray; buf_size: cint): cint; + cdecl; external av__codec; {deprecated;} +{$IFEND} + +{$IF LIBAVCODEC_VERSION >= 52025000} // 52.25.0 +(** + * Decodes the video frame of size avpkt->size from avpkt->data into picture. + * Some decoders may support multiple frames in a single AVPacket, such + * decoders would then just decode the first frame. + * + * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than * the actual read bytes because some optimized bitstream readers read 32 or 64 * bits at once and could read over the end. * - * @warning The end of the input buffer \p buf should be set to 0 to ensure that + * @warning The end of the input buffer buf should be set to 0 to ensure that * no overreading happens for damaged MPEG streams. * - * @note You might have to align the input buffer \p buf and output buffer \p - * samples. The alignment requirements depend on the CPU: on some CPUs it isn't + * @note You might have to align the input buffer avpkt->data. + * The alignment requirements depend on the CPU: on some CPUs it isn't * necessary at all, on others it won't work at all if not aligned and on others - * it will work but it will have an impact on performance. In practice, the - * bitstream should have 4 byte alignment at minimum and all sample data should - * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If - * the linesize is not a multiple of 16 then there's no sense in aligning the - * start of the buffer to 16. + * it will work but it will have an impact on performance. + * + * In practice, avpkt->data should have 4 byte alignment at minimum. * * @param avctx the codec context * @param[out] picture The AVFrame in which the decoded video frame will be stored. - * @param[in] buf the input buffer - * @param[in] buf_size the size of the input buffer in bytes + * @param[in] avpkt The input AVpacket containing the input buffer. + * You can create such packet with av_init_packet() and by then setting + * data and size, some decoders might in addition need other fields like + * flags&PKT_FLAG_KEY. All decoders are designed to use the least + * fields possible. * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. * @return On error a negative value is returned, otherwise the number of bytes * used or zero if no frame could be decompressed. *) -function avcodec_decode_video(avctx: PAVCodecContext; picture: PAVFrame; +function avcodec_decode_video2(avctx: PAVCodecContext; picture: PAVFrame; var got_picture_ptr: cint; - buf: {const} PByteArray; buf_size: cint): cint; + avpkt: PAVPacket): cint; cdecl; external av__codec; +{$IFEND} +{$IF LIBAVCODEC_MAX_VERSION_MAJOR < 53} (* Decode a subtitle message. Return -1 if error, otherwise return the * number of bytes used. If no subtitle could be decompressed, - * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. *) + * got_sub_ptr is zero. Otherwise, the subtitle is stored in*sub. + *) function avcodec_decode_subtitle(avctx: PAVCodecContext; sub: PAVSubtitle; var got_sub_ptr: cint; buf: {const} PByteArray; buf_size: cint): cint; cdecl; external av__codec; +{$IFEND} + +{$IF LIBAVCODEC_VERSION >= 52025000} // 52.25.0 +(* Decodes a subtitle message. + * Returns a negative value on error, otherwise returns the number of bytes used. + * If no subtitle could be decompressed, got_sub_ptr is zero. + * Otherwise, the subtitle is stored in sub. + * + * @param avctx the codec context + * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored. + * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero. + * @param[in] avpkt The input AVPacket containing the input buffer. + *) +function avcodec_decode_subtitle2(avctx: PAVCodecContext; sub: PAVSubtitle; + var got_sub_ptr: cint; + avpkt: PAVPacket): cint; + cdecl; external av__codec; +{$IFEND} + function avcodec_parse_frame(avctx: PAVCodecContext; pdata: PPointer; data_size_ptr: PCint; buf: PByteArray; buf_size: cint): cint; cdecl; external av__codec; (** - * Encodes an audio frame from \p samples into \p buf. - * The avcodec_encode_audio() function encodes an audio frame from the input - * buffer \p samples. To encode it, it makes use of the audio codec which was - * coupled with \p avctx using avcodec_open(). The resulting encoded frame is - * stored in output buffer \p buf. + * Encodes an audio frame from samples into buf. * - * @note The output buffer should be at least \c FF_MIN_BUFFER_SIZE bytes large. + * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large. + * However, for PCM audio the user will know how much space is needed + * because it depends on the value passed in buf_size as described + * below. In that case a lower value can be used. * * @param avctx the codec context * @param[out] buf the output buffer * @param[in] buf_size the output buffer size * @param[in] samples the input buffer containing the samples * The number of samples read from this buffer is frame_size*channels, - * both of which are defined in \p avctx. - * For PCM audio the number of samples read from \p samples is equal to - * \p buf_size * input_sample_size / output_sample_size. + * both of which are defined in avctx. + * For PCM audio the number of samples read from samples is equal to + * buf_size * input_sample_size / output_sample_size. * @return On error a negative value is returned, on success zero or the number * of bytes used to encode the data read from the input buffer. *) @@ -3177,12 +3770,9 @@ function avcodec_encode_audio(avctx: PAVCodecContext; buf: PByte; cdecl; external av__codec; (** - * Encodes a video frame from \p pict into \p buf. - * The avcodec_encode_video() function encodes a video frame from the input - * \p pict. To encode it, it makes use of the video codec which was coupled with - * \p avctx using avcodec_open(). The resulting encoded bytes representing the - * frame are stored in the output buffer \p buf. The input picture should be - * stored using a specific format, namely \c avctx.pix_fmt. + * Encodes a video frame from pict into buf. + * The input picture should be + * stored using a specific format, namely avctx.pix_fmt. * * @param avctx the codec context * @param[out] buf the output buffer for the bitstream of encoded frame @@ -3208,6 +3798,7 @@ function avcodec_close(avctx: PAVCodecContext): cint; * functions. * * @see register_avcodec + * @see avcodec_register * @see av_register_codec_parser * @see av_register_bitstream_filter *) @@ -3226,7 +3817,7 @@ procedure avcodec_default_free_buffers(s: PAVCodecContext); (* misc useful functions *) (** - * Returns a single letter to describe the given picture type \p pict_type. + * Returns a single letter to describe the given picture type pict_type. * * @param[in] pict_type the picture type * @return A single character representing the picture type. @@ -3271,6 +3862,15 @@ type next_frame_offset: cint64; (* offset of the next frame *) (* video info *) pict_type: cint; (* XXX: put it back in AVCodecContext *) + (** + * This field is used for proper frame duration computation in lavf. + * It signals, how much longer the frame duration of the current frame + * is compared to normal frame duration. + * + * frame_duration = (1 + repeat_pict) * time_base + * + * It is used by codecs like H.264 to display telecined material. + *) repeat_pict: cint; (* XXX: put it back in AVCodecContext *) pts: cint64; (* pts of the current frame *) dts: cint64; (* dts of the current frame *) @@ -3293,6 +3893,94 @@ type {$IF LIBAVCODEC_VERSION >= 51057001} // 51.57.1 cur_frame_end: array [0..AV_PARSER_PTS_NB - 1] of cint64; {$IFEND} + {$IF LIBAVCODEC_VERSION >= 52016000} // 52.16.0 + (*! + * Set by parser to 1 for key frames and 0 for non-key frames. + * It is initialized to -1, so if the parser doesn't set this flag, + * old-style fallback using FF_I_TYPE picture type as key frames + * will be used. + *) + key_frame: cint; + {$IFEND} + {$IF LIBAVCODEC_VERSION >= 52018000} // 52.18.0 + (** + * Time difference in stream time base units from the pts of this + * packet to the point at which the output from the decoder has converged + * independent from the availability of previous frames. That is, the + * frames are virtually identical no matter if decoding started from + * the very first frame or from this keyframe. + * Is AV_NOPTS_VALUE if unknown. + * This field is not the display duration of the current frame. + * + * The purpose of this field is to allow seeking in streams that have no + * keyframes in the conventional sense. It corresponds to the + * recovery point SEI in H.264 and match_time_delta in NUT. It is also + * essential for some types of subtitle streams to ensure that all + * subtitles are correctly displayed after seeking. + *) + convergence_duration: cint64; + {$IFEND} + {$IF LIBAVCODEC_VERSION >= 52019000} // 52.19.0 + // Timestamp generation support: + (** + * Synchronization point for start of timestamp generation. + * + * Set to >0 for sync point, 0 for no sync point and <0 for undefined + * (default). + * + * For example, this corresponds to presence of H.264 buffering period + * SEI message. + *) + dts_sync_point: cint; + + (** + * Offset of the current timestamp against last timestamp sync point in + * units of AVCodecContext.time_base. + * + * Set to INT_MIN when dts_sync_point unused. Otherwise, it must + * contain a valid timestamp offset. + * + * Note that the timestamp of sync point has usually a nonzero + * dts_ref_dts_delta, which refers to the previous sync point. Offset of + * the next frame after timestamp sync point will be usually 1. + * + * For example, this corresponds to H.264 cpb_removal_delay. + *) + dts_ref_dts_delta: cint; + + (** + * Presentation delay of current frame in units of AVCodecContext.time_base. + * + * Set to INT_MIN when dts_sync_point unused. Otherwise, it must + * contain valid non-negative timestamp delta (presentation time of a frame + * must not lie in the past). + * + * This delay represents the difference between decoding and presentation + * time of the frame. + * + * For example, this corresponds to H.264 dpb_output_delay. + *) + pts_dts_delta: cint; + {$IFEND} + + {$IF LIBAVCODEC_VERSION >= 52021000} // 52.21.0 + (** + * Position of the packet in file. + * + * Analogous to cur_frame_pts/dts + *) + cur_frame_pos: array [0..AV_PARSER_PTS_NB - 1] of cint64; + + (** + * Byte position of currently parsed frame in stream. + *) + pos: cint64; + + (** + * Previous frame byte position. + *) + last_pos: cint64; + {$IFEND} end; TAVCodecParser = record @@ -3327,12 +4015,60 @@ procedure av_register_codec_parser(parser: PAVCodecParser); function av_parser_init(codec_id: cint): PAVCodecParserContext; cdecl; external av__codec; +{$IF LIBAVCODEC_MAX_VERSION_MAJOR < 53} function av_parser_parse(s: PAVCodecParserContext; avctx: PAVCodecContext; - poutbuf: PPointer; poutbuf_size: PCint; - buf: {const} PByteArray; buf_size: cint; - pts: cint64; dts: cint64): cint; - cdecl; external av__codec; + poutbuf: PPointer; + poutbuf_size: PCint; + buf: {const} PByteArray; + buf_size: cint; + pts: cint64; + dts: cint64): cint; + cdecl; external av__codec; deprecated; +{$IFEND} + +{$IF LIBAVCODEC_VERSION >= 52021000} // 52.21.0 +(** + * Parse a packet. + * + * @param s parser context. + * @param avctx codec context. + * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished. + * @param poutbuf_size set to size of parsed buffer or zero if not yet finished. + * @param buf input buffer. + * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output). + * @param pts input presentation timestamp. + * @param dts input decoding timestamp. + * @param pos input byte position in stream. + * @return the number of bytes of the input bitstream used. + * + * Example: + * @code + * while (in_len) do + * begin + * len := av_parser_parse2(myparser, AVCodecContext, data, size, + * in_data, in_len, + * pts, dts, pos); + * in_data := in_data + len; + * in_len := in_len - len; + * + * if (size) then + * decode_frame(data, size); + * end; + * @endcode + *) +function av_parser_parse2(s: PAVCodecParserContext; + avctx: PAVCodecContext; + poutbuf: PPointer; + poutbuf_size: PCint; + buf: {const} PByteArray; + buf_size: cint; + pts: cint64; + dts: cint64; + pos: cint64): cint; + cdecl; external av__codec; +{$IFEND} + function av_parser_change(s: PAVCodecParserContext; avctx: PAVCodecContext; poutbuf: PPointer; poutbuf_size: PCint; @@ -3395,6 +4131,22 @@ function av_bitstream_filter_next(f: PAVBitStreamFilter): PAVBitStreamFilter; procedure av_fast_realloc(ptr: pointer; size: PCuint; min_size: cuint); cdecl; external av__codec; +{$IF LIBAVCODEC_VERSION >= 52025000} // >= 52.25.0 +(** + * Allocates a buffer, reusing the given one if large enough. + * + * Contrary to av_fast_realloc the current buffer contents might not be + * preserved and on error the old buffer is freed, thus no special + * handling to avoid memleaks is necessary. + * + * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer + * @param size size of the buffer *ptr points to + * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and + * *size 0 if an error occurred. + *) +procedure av_fast_malloc(ptr: pointer; size: PCuint; min_size: cuint); + cdecl; external av__codec; +{$IFEND} {$IF LIBAVCODEC_VERSION < 51057000} // 51.57.0 (* for static data only *) @@ -3407,7 +4159,7 @@ procedure av_fast_realloc(ptr: pointer; size: PCuint; min_size: cuint); * and should correctly use static arrays * *) -procedure av_free_static(); +procedure av_free_static(); cdecl; external av__codec; deprecated; (** @@ -3433,22 +4185,49 @@ procedure av_realloc_static(ptr: pointer; size: cuint); (** * Copy image 'src' to 'dst'. *) -procedure av_picture_copy(dst: PAVPicture; src: {const} PAVPicture; - pix_fmt: cint; width: cint; height: cint); +procedure av_picture_copy(dst: PAVPicture; + src: {const} PAVPicture; +{$IF LIBAVCODEC_VERSION < 52022001} // 52.22.1 + pix_fmt: cint; +{$ELSE} + pix_fmt: TAVPixelFormat; +{$IFEND} + width: cint; + height: cint); cdecl; external av__codec; (** * Crop image top and left side. *) -function av_picture_crop(dst: PAVPicture; src: {const} PAVPicture; - pix_fmt: cint; top_band: cint; left_band: cint): cint; +function av_picture_crop(dst: PAVPicture; + src: {const} PAVPicture; +{$IF LIBAVCODEC_VERSION < 52022001} // 52.22.1 + pix_fmt: cint; +{$ELSE} + pix_fmt: TAVPixelFormat; +{$IFEND} + top_band: cint; + left_band: cint): cint; cdecl; external av__codec; (** * Pad image. *) -function av_picture_pad(dst: PAVPicture; src: {const} PAVPicture; height: cint; width: cint; pix_fmt: cint; - padtop: cint; padbottom: cint; padleft: cint; padright: cint; color: PCint): cint; +function av_picture_pad(dst: PAVPicture; + src: {const} PAVPicture; + height: cint; + width: cint; +{$IF LIBAVCODEC_VERSION < 52022001} // 52.22.1 + pix_fmt: cint; +{$ELSE} + pix_fmt: TAVPixelFormat; +{$IFEND} + padtop: cint; + padbottom: cint; + padleft: cint; + padright: + cint; + color: PCint): cint; cdecl; external av__codec; {$IFEND} @@ -3481,7 +4260,7 @@ function av_xiphlacing(s: PByte; v: cuint): cuint; {$IF LIBAVCODEC_VERSION >= 51041000} // 51.41.0 (** - * Parses \p str and put in \p width_ptr and \p height_ptr the detected values. + * Parses str and put in width_ptr and height_ptr the detected values. * * @return 0 in case of a successful parsing, a negative value otherwise * @param[in] str the string to parse: it has to be a string in the format @@ -3495,11 +4274,11 @@ function av_parse_video_frame_size(width_ptr: PCint; height_ptr: PCint; str: {co cdecl; external av__codec; (** - * Parses \p str and put in \p frame_rate the detected values. + * Parses str and put in frame_rate the detected values. * * @return 0 in case of a successful parsing, a negative value otherwise * @param[in] str the string to parse: it has to be a string in the format - * <frame_rate_nom>/<frame_rate_den>, a float number or a valid video rate abbreviation + * <frame_rate_num>/<frame_rate_den>, a float number or a valid video rate abbreviation * @param[in,out] frame_rate pointer to the AVRational which will contain the detected * frame rate *) @@ -3518,11 +4297,13 @@ const EDOM = ESysEDOM; ENOSYS = ESysENOSYS; EILSEQ = ESysEILSEQ; + EPIPE = ESysEPIPE; {$ELSE} ENOENT = 2; EIO = 5; ENOMEM = 12; EINVAL = 22; + EPIPE = 32; // just an assumption. needs to be checked. EDOM = 33; {$IFDEF MSWINDOWS} // Note: we assume that ffmpeg was compiled with MinGW. @@ -3559,11 +4340,76 @@ const AVERROR_NOMEM = AVERROR_SIGN * ENOMEM; (**< not enough memory *) AVERROR_NOFMT = AVERROR_SIGN * EILSEQ; (**< unknown format *) AVERROR_NOTSUPP = AVERROR_SIGN * ENOSYS; (**< Operation not supported. *) - AVERROR_NOENT = AVERROR_SIGN * ENOENT; {**< No such file or directory. *} + AVERROR_NOENT = AVERROR_SIGN * ENOENT; (**< No such file or directory. *) +{$IF LIBAVCODEC_VERSION >= 52017000} // 52.17.0 + AVERROR_EOF = AVERROR_SIGN * EPIPE; (**< End of file. *) +{$IFEND} // Note: function calls as constant-initializers are invalid //AVERROR_PATCHWELCOME = -MKTAG('P','A','W','E'); {**< Not yet implemented in FFmpeg. Patches welcome. *} AVERROR_PATCHWELCOME = -(ord('P') or (ord('A') shl 8) or (ord('W') shl 16) or (ord('E') shl 24)); +{$IF LIBAVCODEC_VERSION >= 52018000} // 52.18.0 +(** + * Registers the hardware accelerator hwaccel. + *) +procedure av_register_hwaccel (hwaccel: PAVHWAccel) + cdecl; external av__codec; + +(** + * If hwaccel is NULL, returns the first registered hardware accelerator, + * if hwaccel is non-NULL, returns the next registered hardware accelerator + * after hwaccel, or NULL if hwaccel is the last one. + *) +function av_hwaccel_next (hwaccel: PAVHWAccel): PAVHWAccel; + cdecl; external av__codec; +{$IFEND} + +{$IF LIBAVCODEC_VERSION >= 52030000} // 52.30.0 +(** + * Lock operation used by lockmgr + *) +type + TAVLockOp = ( + AV_LOCK_CREATE, ///< Create a mutex + AV_LOCK_OBTAIN, ///< Lock the mutex + AV_LOCK_RELEASE, ///< Unlock the mutex + AV_LOCK_DESTROY ///< Free mutex resources + ); + +(** + * Register a user provided lock manager supporting the operations + * specified by AVLockOp. mutex points to a (void) where the + * lockmgr should store/get a pointer to a user allocated mutex. It's + * NULL upon AV_LOCK_CREATE and != NULL for all other ops. + * + * @param cb User defined callback. Note: FFmpeg may invoke calls to this + * callback during the call to av_lockmgr_register(). + * Thus, the application must be prepared to handle that. + * If cb is set to NULL the lockmgr will be unregistered. + * Also note that during unregistration the previously registered + * lockmgr callback may also be invoked. + *) +// ToDo: Implement and test this +//function av_lockmgr_register(cb: function (mutex: pointer; op: TAVLockOp)): cint; +// cdecl; external av__codec; +{$IFEND} + implementation +{$IF (LIBAVCODEC_VERSION >= 52025000) and (LIBAVCODEC_VERSION <= 5202700)} // 52.25.0 +procedure av_free_packet(pkt: PAVPacket);{$IFDEF HASINLINE} inline; {$ENDIF} +begin + if (pkt <> nil) then + begin + if (pkt.destruct <> nil) then + pkt.destruct(pkt) + else + begin + pkt.data = NULL; + pkt.size = 0; + end; + end; +end; +{$IFEND} + end. diff --git a/unicode/src/lib/ffmpeg/avformat.pas b/unicode/src/lib/ffmpeg/avformat.pas index 62df8a83..0ec2c118 100644 --- a/unicode/src/lib/ffmpeg/avformat.pas +++ b/unicode/src/lib/ffmpeg/avformat.pas @@ -29,6 +29,11 @@ * Min. version: 50.5.0 , revision 6577, Sat Oct 7 15:30:46 2006 UTC * Max. version: 52.25.0, revision 16986, Wed Feb 4 05:56:39 2009 UTC *) +{ + * update to + * Max. version: 52.34.0, Sat Jun 13 00:37:00 2009 UTC + * MiSchi +} unit avformat; @@ -60,7 +65,7 @@ uses const (* Max. supported version by this header *) LIBAVFORMAT_MAX_VERSION_MAJOR = 52; - LIBAVFORMAT_MAX_VERSION_MINOR = 25; + LIBAVFORMAT_MAX_VERSION_MINOR = 34; LIBAVFORMAT_MAX_VERSION_RELEASE = 0; LIBAVFORMAT_MAX_VERSION = (LIBAVFORMAT_MAX_VERSION_MAJOR * VERSION_MAJOR) + (LIBAVFORMAT_MAX_VERSION_MINOR * VERSION_MINOR) + @@ -92,13 +97,11 @@ function avformat_version(): cuint; cdecl; external av__format; {$IFEND} - type PAVFile = Pointer; (* * Public Metadata API. - * !!WARNING!! This is a work in progress. Don't use outside FFmpeg for now. * The metadata API allows libavformat to export metadata tags to a client * application using a sequence of key/value pairs. * Important concepts to keep in mind: @@ -111,7 +114,7 @@ type * want to store, e.g., the email address of the child of producer Alice * and actor Bob, that could have key=alice_and_bobs_childs_email_address. * 3. A tag whose value is localized for a particular language is appended - * with a dash character ('-') and the ISO 639 3-letter language code. + * with a dash character ('-') and the ISO 639-2/B 3-letter language code. * For example: Author-ger=Michael, Author-eng=Mike * The original/default language is in the unqualified "Author" tag. * A demuxer should set a default if it sets any translated tag. @@ -130,53 +133,51 @@ type PAVMetadata = Pointer; {$IF LIBAVFORMAT_VERSION > 52024001} // > 52.24.1 - (** - * gets a metadata element with matching key. - * @param prev set to the previous matching element to find the next. - * @param flags allows case as well as suffix insensitive comparisons. - * @return found tag or NULL, changing key or value leads to undefined behavior. + * Gets a metadata element with matching key. + * @param prev Set to the previous matching element to find the next. + * @param flags Allows case as well as suffix-insensitive comparisons. + * @return Found tag or NULL, changing key or value leads to undefined behavior. *) function av_metadata_get(m: PAVMetadata; key: {const} PAnsiChar; prev: {const} PAVMetadataTag ; flags: cint): PAVMetadataTag; cdecl; external av__format; (** - * sets the given tag in m, overwriting an existing tag. - * @param key tag key to add to m (will be av_strduped). - * @param value tag value to add to m (will be av_strduped). - * @return >= 0 if success otherwise error code that is <0. + * Sets the given tag in m, overwriting an existing tag. + * @param key tag key to add to m (will be av_strduped) + * @param value tag value to add to m (will be av_strduped) + * @return >= 0 on success otherwise an error code <0 *) function av_metadata_set(var pm: PAVMetadata; key: {const} PAnsiChar; value: {const} PAnsiChar): cint; cdecl; external av__format; (** - * Free all the memory allocated for an AVMetadata struct. + * Frees all the memory allocated for an AVMetadata struct. *) procedure av_metadata_free(var m: PAVMetadata); cdecl; external av__format; - {$IFEND} (* packet functions *) +{$IF LIBAVCODEC_VERSION < 52032000} // < 52.32.0 type PAVPacket = ^TAVPacket; TAVPacket = record (** - * Presentation time stamp in time_base units. - * This is the time at which the decompressed packet will be presented - * to the user. + * Presentation timestamp in time_base units; the time at which the + * decompressed packet will be presented to the user. * Can be AV_NOPTS_VALUE if it is not stored in the file. * pts MUST be larger or equal to dts as presentation can not happen before * decompression, unless one wants to view hex dumps. Some formats misuse - * the terms dts and pts/cts to mean something different, these timestamps + * the terms dts and pts/cts to mean something different. Such timestamps * must be converted to true pts/dts before they are stored in AVPacket. *) pts: cint64; (** - * Decompression time stamp in time_base units. - * This is the time at which the packet is decompressed. + * Decompression timestamp in time_base units; the time at which the + * packet is decompressed. * Can be AV_NOPTS_VALUE if it is not stored in the file. *) dts: cint64; @@ -245,6 +246,7 @@ procedure av_init_packet(var pkt: TAVPacket); *) function av_new_packet(var pkt: TAVPacket; size: cint): cint; cdecl; external av__format; +{$IFEND} (** * Allocate and read the payload of a packet and initialize its fields with @@ -257,6 +259,7 @@ function av_new_packet(var pkt: TAVPacket; size: cint): cint; function av_get_packet(s: PByteIOContext; var pkt: TAVPacket; size: cint): cint; cdecl; external av__format; +{$IF LIBAVCODEC_VERSION < 52032000} // < 52.32.0 (** * @warning This is a hack - the packet memory allocation stuff is broken. The * packet is allocated if it was not really allocated. @@ -270,6 +273,7 @@ function av_dup_packet(pkt: PAVPacket): cint; * @param pkt packet to free *) procedure av_free_packet(pkt: PAVPacket); {$IFDEF HasInline}inline;{$ENDIF} +{$IFEND} (*************************************************) (* fractional numbers for exact pts handling *) @@ -278,7 +282,6 @@ type (** * The exact value of the fractional number is: 'val + num / den'. * num is assumed to be 0 <= num < den. - * @deprecated Use AVRational instead. *) PAVFrac = ^TAVFrac; TAVFrac = record @@ -297,7 +300,7 @@ type end; const - AVPROBE_SCORE_MAX = 100; ///< Maximum score, half of that is used for file-extension-based detection. + AVPROBE_SCORE_MAX = 100; ///< Maximum score, half of that is used for file-extension-based detection AVPROBE_PADDING_SIZE = 32; ///< extra allocated bytes at the end of the probe buffer //! Demuxer will use url_fopen, no opened file should be provided by the caller. @@ -310,6 +313,9 @@ const AVFMT_NOTIMESTAMPS = $0080; (**< Format does not need / have any timestamps. *) AVFMT_GENERIC_INDEX = $0100; (**< Use generic index building code. *) AVFMT_TS_DISCONT = $0200; (**< Format allows timestamp discontinuities. *) + {$IF LIBAVFORMAT_VERSION >= 52029002} // 52.29.2 + AVFMT_VARIABLE_FPS = $0400; (**< Format allows variable fps. *) + {$IFEND} // used by AVIndexEntry AVINDEX_KEYFRAME = $0001; @@ -320,7 +326,7 @@ const AVFMT_NOOUTPUTLOOP = -1; AVFMT_INFINITEOUTPUTLOOP = 0; - AVFMT_FLAG_GENPTS = $0001; ///< Generate pts if missing even if it requires parsing future frames. + AVFMT_FLAG_GENPTS = $0001; ///< Generate missing pts even if it requires parsing future frames. AVFMT_FLAG_IGNIDX = $0002; ///< Ignore index. AVFMT_FLAG_NONBLOCK = $0004; ///< Do not block when reading packets from input. @@ -339,7 +345,11 @@ const AV_DISPOSITION_KARAOKE = $0020; // used by TAVFormatContext.debug - FF_FDEBUG_TS = 0001; + FF_FDEBUG_TS = 0001; + + {$IF LIBAVFORMAT_VERSION >= 52034000} // > 52.34.0 + MAX_PROBE_PACKETS = 100; + {$IFEND} type PPAVCodecTag = ^PAVCodecTag; @@ -367,12 +377,29 @@ type PAVImageInfo = ^TAVImageInfo; {$IFEND} +{$IF LIBAVFORMAT_VERSION >= 52030001} // >= 52.30.1 +(** + * Convert all the metadata sets from ctx according to the source and + * destination conversion tables. + * @param d_conv destination tags format conversion table + * @param s_conv source tags format conversion table + *) + PAVMetadataConv = ^TAVMetadataConv; + TAVMetadataConv = record + ctx: PAVFormatContext; + d_conv: {const} PAVMetadataConv; + s_conv: {const} PAVMetadataConv; + end; +{$IFEND} + PAVChapter = ^TAVChapter; TAVChapter = record id: cint; ///< unique ID to identify the chapter time_base: TAVRational; ///< time base in which the start/end timestamps are specified start, end_: cint64; ///< chapter start/end time in time_base units + {$IF LIBAVFORMAT_VERSION < 53000000} // 53.00.0 title: PAnsiChar; ///< chapter title + {$IFEND} {$IF LIBAVFORMAT_VERSION >= 52024001} // 52.24.1 metadata: PAVMetadata; {$IFEND} @@ -415,13 +442,13 @@ type name: PAnsiChar; (** * Descriptive name for the format, meant to be more human-readable - * than \p name. You \e should use the NULL_IF_CONFIG_SMALL() macro + * than name. You should use the NULL_IF_CONFIG_SMALL() macro * to define it. *) long_name: PAnsiChar; mime_type: PAnsiChar; extensions: PAnsiChar; (**< comma-separated filename extensions *) - (** Size of private data so that it can be allocated in the wrapper. *) + (** size of private data so that it can be allocated in the wrapper *) priv_data_size: cint; (* output support *) audio_codec: TCodecID; (**< default audio codec *) @@ -439,7 +466,7 @@ type {$IF LIBAVFORMAT_VERSION >= 51008000} // 51.8.0 (** * List of supported codec_id-codec_tag pairs, ordered by "better - * choice first". The arrays are all CODEC_ID_NONE terminated. + * choice first". The arrays are all terminated by CODEC_ID_NONE. *) codec_tag: {const} PPAVCodecTag; {$IFEND} @@ -448,6 +475,10 @@ type subtitle_codec: TCodecID; (**< default subtitle codec *) {$IFEND} + {$IF LIBAVFORMAT_VERSION >= 52030001} // 52.30.1 + {const} metadata_conv: PAVMetadataConv; + {$IFEND} + (* private fields *) next: PAVOutputFormat; end; @@ -456,14 +487,14 @@ type name: PAnsiChar; (** * Descriptive name for the format, meant to be more human-readable - * than \p name. You \e should use the NULL_IF_CONFIG_SMALL() macro + * than name. You should use the NULL_IF_CONFIG_SMALL() macro * to define it. *) long_name: PAnsiChar; (** Size of private data so that it can be allocated in the wrapper. *) priv_data_size: cint; (** - * Tell if a given file has a chance of being parsed by this format. + * Tell if a given file has a chance of being parsed as this format. * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes * big so you do not have to check for that unless you need more. *) @@ -475,21 +506,28 @@ type read_header: function (c: PAVFormatContext; ap: PAVFormatParameters): cint; cdecl; (** Read one packet and put it in 'pkt'. pts and flags are also set. 'av_new_stream' can be called only if the flag - AVFMTCTX_NOHEADER is used. *) + AVFMTCTX_NOHEADER is used. + @return 0 on success, < 0 on error. + When returning an error, pkt must not have been allocated + or must be freed before returning *) read_packet: function (c: PAVFormatContext; var pkt: TAVPacket): cint; cdecl; (** Close the stream. The AVFormatContext and AVStreams are not freed by this function *) read_close: function (c: PAVFormatContext): cint; cdecl; + +{$IF LIBAVFORMAT_VERSION_MAJOR < 53} (** * Seek to a given timestamp relative to the frames in * stream component stream_index. - * @param stream_index must not be -1 - * @param flags selects which direction should be preferred if no exact - * match is available + * @param stream_index Must not be -1. + * @param flags Selects which direction should be preferred if no exact + * match is available. * @return >= 0 on success (but not necessarily the new offset) *) read_seek: function (c: PAVFormatContext; stream_index: cint; timestamp: cint64; flags: cint): cint; cdecl; +{$IFEND} + (** * Gets the next timestamp in stream[stream_index].time_base units. * @return the timestamp or AV_NOPTS_VALUE if an error occurred @@ -517,6 +555,25 @@ type codec_tag: {const} PPAVCodecTag; {$IFEND} + {$IF LIBAVFORMAT_VERSION >= 52030000} // 52.30.0 + (** + * Seek to timestamp ts. + * Seeking will be done so that the point from which all active streams + * can be presented successfully will be closest to ts and within min/max_ts. + * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. + *) + read_seek2: function (s: PAVFormatContext; + stream_index: cint; + min_ts: cint64; + ts: cint64; + max_ts: cint64; + flags: cint): cint; cdecl; + {$IFEND} + + {$IF LIBAVFORMAT_VERSION >= 52030001} // 52.30.1 + {const} metadata_conv: PAVMetadataConv; + {$IFEND} + (* private fields *) next: PAVInputFormat; end; @@ -551,11 +608,11 @@ type id: cint; (**< format-specific stream ID *) codec: PAVCodecContext; (**< codec context *) (** - * Real base frame rate of the stream. - * This is the lowest frame rate with which all timestamps can be + * Real base framerate of the stream. + * This is the lowest framerate with which all timestamps can be * represented accurately (it is the least common multiple of all - * frame rates in the stream). Note, this value is just a guess! - * For example if the timebase is 1/90000 and all frames have either + * framerates in the stream). Note, this value is just a guess! + * For example, if the time base is 1/90000 and all frames have either * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1. *) r_frame_rate: TAVRational; @@ -572,7 +629,7 @@ type (** * This is the fundamental unit of time (in seconds) in terms * of which frame timestamps are represented. For fixed-fps content, - * time base should be 1/frame rate and timestamp increments should be 1. + * time base should be 1/framerate and timestamp increments should be 1. *) time_base: TAVRational; pts_wrap_bits: cint; (* number of bits in pts (used for wrapping control) *) @@ -599,7 +656,9 @@ type *) duration: cint64; - language: array [0..3] of PAnsiChar; (* ISO 639 3-letter language code (empty string if undefined) *) + {$IF LIBAVFORMAT_VERSION_MAJOR < 53} + language: array [0..3] of PAnsiChar; (* ISO 639-2/B 3-letter language code (empty string if undefined) *) + {$IFEND} (* av_read_frame() support *) need_parsing: TAVStreamParseType; @@ -620,7 +679,7 @@ type unused: array [0..4] of cint64; {$IFEND} - {$IF LIBAVFORMAT_VERSION >= 52006000} // 52.6.0 + {$IF (LIBAVFORMAT_VERSION >= 52006000) and (LIBAVFORMAT_VERSION_MAJOR < 53)} // 52.6.0 - 53.0.0 filename: PAnsiChar; (**< source filename of the stream *) {$IFEND} @@ -653,6 +712,25 @@ type cur_len: cint; cur_pkt: TAVPacket; {$IFEND} + + {$IF LIBAVFORMAT_VERSION >= 52030000} // > 52.30.0 + // Timestamp generation support: + (** + * Timestamp corresponding to the last dts sync point. + * + * Initialized when AVCodecParserContext.dts_sync_point >= 0 and + * a DTS is received from the underlying container. Otherwise set to + * AV_NOPTS_VALUE by default. + *) + reference_dts: cint64; + {$IFEND} + {$IF LIBAVFORMAT_VERSION >= 52034000} // > 52.34.0 + (** + * Number of packets to buffer for codec probing + * NOT PART OF PUBLIC API + *) + probe_packets: cint; + {$IFEND} end; (** @@ -663,7 +741,7 @@ type * sizeof(AVFormatContext) must not be used outside libav*. *) TAVFormatContext = record - av_class: PAVClass; (**< Set by av_alloc_format_context. *) + av_class: PAVClass; (**< Set by avformat_alloc_context. *) (* Can only be iformat or oformat, not both at the same time. *) iformat: PAVInputFormat; oformat: PAVOutputFormat; @@ -680,6 +758,7 @@ type filename: array [0..1023] of AnsiChar; (* input or output filename *) (* stream info *) timestamp: cint64; + {$IF LIBAVFORMAT_VERSION < 53000000} // 53.00.0 title: array [0..511] of AnsiChar; author: array [0..511] of AnsiChar; copyright: array [0..511] of AnsiChar; @@ -688,6 +767,7 @@ type year: cint; (**< ID3 year, 0 if none *) track: cint; (**< track number, 0 if none *) genre: array [0..31] of AnsiChar; (**< ID3 genre *) + {$IFEND} ctx_flags: cint; (**< Format-specific flags, see AVFMTCTX_xx *) (* private data for pts handling (do not modify directly). *) @@ -735,7 +815,7 @@ type loop_input: cint; {$IF LIBAVFORMAT_VERSION >= 50006000} // 50.6.0 - (** Decoding: size of data to probe; encoding: unused. *) + (** decoding: size of data to probe; encoding: unused. *) probesize: cuint; {$IFEND} @@ -775,8 +855,8 @@ type {$IF LIBAVFORMAT_VERSION >= 52004000} // 52.4.0 (** - * Maximum amount of memory in bytes to use per stream for the index. - * If the needed index exceeds this size, entries will be discarded as + * Maximum amount of memory in bytes to use for the index of each stream. + * If the index exceeds this size, entries will be discarded as * needed to maintain a smaller size. This can lead to slower or less * accurate seeking (depends on demuxer). * Demuxers for which a full in-memory index is mandatory will ignore @@ -833,8 +913,10 @@ type *) TAVProgram = record id : cint; + {$IF LIBAVFORMAT_VERSION < 53000000} // 53.00.0 provider_name : PAnsiChar; ///< network name for DVB streams name : PAnsiChar; ///< service name for DVB streams + {$IFEND} flags : cint; discard : TAVDiscard; ///< selects which program to discard and which to feed to the caller {$IF LIBAVFORMAT_VERSION >= 51016000} // 51.16.0 @@ -908,8 +990,18 @@ var {$IFEND} {$IF LIBAVFORMAT_VERSION >= 52003000} // 52.3.0 +(** + * If f is NULL, returns the first registered input format, + * if f is non-NULL, returns the next registered input format after f + * or NULL if f is the last one. + *) function av_iformat_next(f: PAVInputFormat): PAVInputFormat; cdecl; external av__format; +(** + * If f is NULL, returns the first registered output format, + * if f is non-NULL, returns the next registered input format after f + * or NULL if f is the last one. + *) function av_oformat_next(f: PAVOutputFormat): PAVOutputFormat; cdecl; external av__format; {$IFEND} @@ -917,8 +1009,8 @@ function av_oformat_next(f: PAVOutputFormat): PAVOutputFormat; function av_guess_image2_codec(filename: {const} PAnsiChar): TCodecID; cdecl; external av__format; -(* XXX: use automatic init with either ELF sections or C file parser *) -(* modules *) +(* XXX: Use automatic init with either ELF sections or C file parser *) +(* modules. *) (* utils.c *) procedure av_register_input_format(format: PAVInputFormat); @@ -1006,7 +1098,7 @@ procedure av_pkt_dump_log(avcl: Pointer; level: cint; pkt: PAVPacket; dump_paylo * * @see av_register_input_format() * @see av_register_output_format() - * @see register_protocol() + * @see av_register_protocol() *) procedure av_register_all(); cdecl; external av__format; @@ -1062,18 +1154,28 @@ function av_open_input_file(var ic_ptr: PAVFormatContext; filename: PAnsiChar; ap: PAVFormatParameters): cint; cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION >= 52026000} // 52.26.0 (** * Allocate an AVFormatContext. * Can be freed with av_free() but do not forget to free everything you * explicitly allocated as well! *) +function avformat_alloc_context(): PAVFormatContext; + cdecl; external av__format; +{$ELSE} + {$IF LIBAVFORMAT_VERSION_MAJOR < 53} +(** + * @deprecated Use avformat_alloc_context() instead. + *) function av_alloc_format_context(): PAVFormatContext; cdecl; external av__format; + {$IFEND} +{$IFEND} (** * Read packets of a media file to get stream information. This * is useful for file formats with no headers such as MPEG. This - * function also computes the real frame rate in case of MPEG-2 repeat + * function also computes the real framerate in case of MPEG-2 repeat * frame mode. * The logical file position is not changed by this function; * examined packets may be buffered for later processing. @@ -1111,7 +1213,7 @@ function av_read_packet(s: PAVFormatContext; var pkt: TAVPacket): cint; * then it contains one frame. * * pkt->pts, pkt->dts and pkt->duration are always set to correct - * values in AVStream.timebase units (and guessed if the format cannot + * values in AVStream.time_base units (and guessed if the format cannot * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format * has B-frames, so it is better to rely on pkt->dts if you do not * decompress the payload. @@ -1122,7 +1224,7 @@ function av_read_frame(s: PAVFormatContext; var pkt: TAVPacket): cint; cdecl; external av__format; (** - * Seek to the key frame at timestamp. + * Seek to the keyframe at timestamp. * 'timestamp' in 'stream_index'. * @param stream_index If stream_index is (-1), a default * stream is selected, and timestamp is automatically converted @@ -1136,15 +1238,51 @@ function av_seek_frame(s: PAVFormatContext; stream_index: cint; timestamp: cint6 flags: cint): cint; cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION >= 52026000} // 52.26.0 (** - * Start playing a network based stream (e.g. RTSP stream) at the + * Seek to timestamp ts. + * Seeking will be done so that the point from which all active streams + * can be presented successfully will be closest to ts and within min/max_ts. + * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. + * + * If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in byte and + * are the file position (this may not be supported by all demuxers). + * If flags contain AVSEEK_FLAG_FRAME then all timestamps are in frames + * in the stream with stream_index (this may not be supported by all demuxers). + * Otherwise all timestamps are in units of the stream selected by stream_index + * or if stream_index is -1, in AV_TIME_BASE units. + * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as + * keyframes (this may not be supported by all demuxers). + * + * @param stream_index index of the stream which is used as time base reference. + * @param min_ts smallest acceptable timestamp + * @param ts target timestamp + * @param max_ts largest acceptable timestamp + * @param flags flags + * @returns >=0 on success, error code otherwise + * + * @NOTE This is part of the new seek API which is still under construction. + * Thus do not use this yet. It may change at any time, do not expect + * ABI compatibility yet! + *) +function avformat_seek_file(s: PAVFormatContext; + stream_index: cint; + min_ts: cint64; + ts: cint64; + max_ts: cint64; + flags: cint): cint; + cdecl; external av__format; +{$IFEND} + +(** + * Start playing a network-based stream (e.g. RTSP stream) at the * current position. *) function av_read_play(s: PAVFormatContext): cint; cdecl; external av__format; (** - * Pause a network based stream (e.g. RTSP stream). + * Pause a network-based stream (e.g. RTSP stream). * * Use av_read_play() to resume it. *) @@ -1239,7 +1377,7 @@ function av_index_search_timestamp(st: PAVStream; timestamp: cint64; flags: cint {$IF LIBAVFORMAT_VERSION >= 52004000} // 52.4.0 (** * Ensures the index uses less memory than the maximum specified in - * AVFormatContext.max_index_size, by discarding entries if it grows + * AVFormatContext.max_index_size by discarding entries if it grows * too large. * This function is not part of the public API and should only be called * by demuxers. @@ -1337,7 +1475,7 @@ function av_write_frame(s: PAVFormatContext; var pkt: TAVPacket): cint; * Writes a packet to an output media file ensuring correct interleaving. * * The packet must contain one audio or video frame. - * If the packets are already correctly interleaved the application should + * If the packets are already correctly interleaved, the application should * call av_write_frame() instead as it is slightly faster. It is also important * to keep in mind that completely non-interleaved input will need huge amounts * of memory to interleave with this, so it is preferable to interleave at the @@ -1355,7 +1493,7 @@ function av_interleaved_write_frame(s: PAVFormatContext; var pkt: TAVPacket): ci * Interleave a packet per dts in an output media file. * * Packets with pkt->destruct == av_destruct_packet will be freed inside this - * function, so they cannot be used after it, note calling av_free_packet() + * function, so they cannot be used after it. Note that calling av_free_packet() * on them is still safe. * * @param s media file handle @@ -1370,6 +1508,24 @@ function av_interleave_packet_per_dts(s: PAVFormatContext; _out: PAVPacket; pkt: PAVPacket; flush: cint): cint; cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION >= 52025000} // 52.25.0 +(** + * Add packet to AVFormatContext->packet_buffer list, determining its + * interleaved position using compare() function argument. + * + * This function is not part of the public API and should only be called + * by muxers using their own interleave function. + *) +{ +procedure ff_interleave_add_packet(s: PAVFormatContext; + pkt: PAVPacket; + compare: function(para1: PAVFormatContext; + para2: PAVPacket; + para3: PAVPacket): cint); + cdecl; external av__format; +} +{$IFEND} + (** * @brief Write the stream trailer to an output media file and * free the file private data. @@ -1396,7 +1552,7 @@ function parse_image_size(width_ptr: PCint; height_ptr: PCint; {$IF LIBAVFORMAT_VERSION_MAJOR < 53} (** - * Converts frame rate from string to a fraction. + * Converts framerate from a string to a fraction. * @deprecated Use av_parse_video_frame_rate instead. *) function parse_frame_rate(frame_rate: PCint; frame_rate_base: PCint; @@ -1405,7 +1561,7 @@ function parse_frame_rate(frame_rate: PCint; frame_rate_base: PCint; {$IFEND} (** - * Parses \p datestr and returns a corresponding number of microseconds. + * Parses datestr and returns a corresponding number of microseconds. * @param datestr String representing a date or a duration. * - If a date the syntax is: * @code @@ -1416,7 +1572,7 @@ function parse_frame_rate(frame_rate: PCint; frame_rate_base: PCint; * If the year-month-day part is not specified it takes the current * year-month-day. * Returns the number of microseconds since 1st of January, 1970 up to - * the time of the parsed date or INT64_MIN if \p datestr cannot be + * the time of the parsed date or INT64_MIN if datestr cannot be * successfully parsed. * - If a duration the syntax is: * @code @@ -1424,10 +1580,10 @@ function parse_frame_rate(frame_rate: PCint; frame_rate_base: PCint; * [-]S+[.m...] * @endcode * Returns the number of microseconds contained in a time interval - * with the specified duration or INT64_MIN if \p datestr cannot be + * with the specified duration or INT64_MIN if datestr cannot be * successfully parsed. - * @param duration Flag which tells how to interpret \p datestr, if - * not zero \p datestr is interpreted as a duration, otherwise as a + * @param duration Flag which tells how to interpret datestr, if + * not zero datestr is interpreted as a duration, otherwise as a * date. *) function parse_date(datestr: PAnsiChar; duration: cint): cint64; @@ -1444,7 +1600,11 @@ const function ffm_read_write_index(fd: cint): cint64; cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION < 52027000} // 52.27.0 procedure ffm_write_write_index(fd: cint; pos: cint64); +{$ELSE} +function ffm_write_write_index(fd: cint; pos: cint64): cint; +{$IFEND} cdecl; external av__format; procedure ffm_set_write_index(s: PAVFormatContext; pos: cint64; file_size: cint64); @@ -1460,7 +1620,7 @@ function find_info_tag(arg: PAnsiChar; arg_size: cint; tag1: PAnsiChar; info: PA cdecl; external av__format; (** - * Returns in 'buf' the path with '%d' replaced by number. + * Returns in 'buf' the path with '%d' replaced by a number. * * Also handles the '%0nd' format where 'n' is the total number * of digits and '%%'. @@ -1526,10 +1686,12 @@ begin end; {$IFEND} +{$IF LIBAVCODEC_VERSION < 52032000} // < 52.32.0 procedure av_free_packet(pkt: PAVPacket); begin if ((pkt <> nil) and (@pkt^.destruct <> nil)) then pkt^.destruct(pkt); end; +{$IFEND} end. diff --git a/unicode/src/lib/ffmpeg/avio.pas b/unicode/src/lib/ffmpeg/avio.pas index 33778206..dc0a330b 100644 --- a/unicode/src/lib/ffmpeg/avio.pas +++ b/unicode/src/lib/ffmpeg/avio.pas @@ -27,7 +27,12 @@ (* * Conversion of libavformat/avio.h - * revision 16100, Sat Dec 13 13:39:13 2008 UTC + * unbuffered I/O operations + * revision 16100, Sat Dec 13 13:39:13 2008 UTC + * update Tue, Jun 10 01:00:00 2009 UTC + * + * @warning This file has to be considered an internal but installed + * header, so it should not be directly included in your projects. *) unit avio; @@ -103,6 +108,7 @@ type name: PAnsiChar; url_open: function (h: PURLContext; filename: {const} PAnsiChar; flags: cint): cint; cdecl; url_read: function (h: PURLContext; buf: PByteArray; size: cint): cint; cdecl; + url_read_complete: function (h: PURLContext; buf: PByteArray; size: cint): cint; cdecl; url_write: function (h: PURLContext; buf: PByteArray; size: cint): cint; cdecl; url_seek: function (h: PURLContext; pos: cint64; whence: cint): cint64; cdecl; url_close: function (h: PURLContext): cint; cdecl; @@ -180,6 +186,16 @@ function url_exist(filename: {const} PAnsiChar): cint; cdecl; external av__format; function url_filesize (h: PURLContext): cint64; cdecl; external av__format; +{ + * Return the file descriptor associated with this URL. For RTP, this + * will return only the RTP file descriptor, not the RTCP file descriptor. + * To get both, use rtp_get_file_handles(). + * + * @return the file descriptor associated with this URL, or <0 on error. +} +(* not implemented *) +function url_get_file_handle(h: PURLContext): cint; + cdecl; external av__format; (** * Return the maximum packet size associated to packetized file @@ -240,19 +256,34 @@ function av_url_read_seek(h: PURLContext; stream_index: cint; cdecl; external av__format; {$IFEND} -{ +(** var +{$IF LIBAVFORMAT_VERSION_MAJOR < 53} first_protocol: PURLProtocol; external av__format; +{$IFEND} url_interrupt_cb: PURLInterruptCB; external av__format; -} +**) +{ +* If protocol is NULL, returns the first registered protocol, +* if protocol is non-NULL, returns the next registered protocol after protocol, +* or NULL if protocol is the last one. +} {$IF LIBAVFORMAT_VERSION >= 52002000} // 52.2.0 function av_protocol_next(p: PURLProtocol): PURLProtocol; cdecl; external av__format; {$IFEND} +{$IF LIBAVFORMAT_VERSION <= 52028000} // 52.28.0 +(** + * @deprecated Use av_register_protocol() instead. + *) function register_protocol (protocol: PURLProtocol): cint; cdecl; external av__format; +{$ELSE} +function av_register_protocol (protocol: PURLProtocol): cint; + cdecl; external av__format; +{$IFEND} type TReadWriteFunc = function (opaque: Pointer; buf: PByteArray; buf_size: cint): cint; cdecl; @@ -521,7 +552,7 @@ function ff_crc04C11DB7_update(checksum: culong; buf: {const} PByteArray; {$IFEND} function get_checksum(s: PByteIOContext): culong; cdecl; external av__format; -procedure init_checksum(s: PByteIOContext; +procedure init_gsum(s: PByteIOContext; update_checksum: pointer; checksum: culong); cdecl; external av__format; @@ -531,9 +562,11 @@ function udp_set_remote_url(h: PURLContext; uri: {const} PAnsiChar): cint; cdecl; external av__format; function udp_get_local_port(h: PURLContext): cint; cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION_MAJOR <= 52} function udp_get_file_handle(h: PURLContext): cint; cdecl; external av__format; - +{$IFEND} + implementation function url_is_streamed(s: PByteIOContext): cint; diff --git a/unicode/src/lib/ffmpeg/avutil.pas b/unicode/src/lib/ffmpeg/avutil.pas index 6de35f1b..6a93ea12 100644 --- a/unicode/src/lib/ffmpeg/avutil.pas +++ b/unicode/src/lib/ffmpeg/avutil.pas @@ -29,14 +29,21 @@ * * libavutil/avutil.h: * Min. version: 49.0.1, revision 6577, Sat Oct 7 15:30:46 2006 UTC - * Max. version: 49.14.0, revision 16912, Sun Feb 1 02:00:19 2009 UTC + * Max. version: 49.14.0, revision 16912, Sun Feb 1 02:00:19 2009 UTC * * libavutil/mem.h: - * revision 16590, Tue Jan 13 23:44:16 2009 UTC + * revision 16590, Tue Jan 13 23:44:16 2009 UTC * * libavutil/log.h: - * revision 16571, Tue Jan 13 00:14:43 2009 UTC + * revision 16571, Tue Jan 13 00:14:43 2009 UTC *) +{ + Update changes auf avutil.h, mem.h and log.h + Max. version 50.03.0, Tue, Jun 09 24:00:00 2009 UTC + include/keep pixfmt.h (change in revision 50.01.0) + Maybe, the pixelformats are not needed, but it has not been checked. + log.h is only partial. +} unit avutil; @@ -62,8 +69,8 @@ uses const (* Max. supported version by this header *) - LIBAVUTIL_MAX_VERSION_MAJOR = 49; - LIBAVUTIL_MAX_VERSION_MINOR = 14; + LIBAVUTIL_MAX_VERSION_MAJOR = 50; + LIBAVUTIL_MAX_VERSION_MINOR = 3; LIBAVUTIL_MAX_VERSION_RELEASE = 0; LIBAVUTIL_MAX_VERSION = (LIBAVUTIL_MAX_VERSION_MAJOR * VERSION_MAJOR) + (LIBAVUTIL_MAX_VERSION_MINOR * VERSION_MINOR) + @@ -112,6 +119,14 @@ type * components stored in AVFrame.data[1] should be in the range 0..255. * This is important as many custom PAL8 video codecs that were designed * to run on the IBM VGA graphics adapter use 6-bit palette components. + * + * For all the 8bit per pixel formats, an RGB32 palette is in data[1] like + * for pal8. This palette is filled in automatically by the function + * allocating the picture. + * + * Note, make sure that all newly added big endian formats have pix_fmt&1==1 + * and that all newly added little endian formats have pix_fmt&1==0 + * this allows simpler detection of big vs little endian. *) PAVPixelFormat = ^TAVPixelFormat; @@ -123,11 +138,15 @@ type PIX_FMT_BGR24, ///< packed RGB 8:8:8, 24bpp, BGRBGR... PIX_FMT_YUV422P, ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) PIX_FMT_YUV444P, ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) +{$IF LIBAVUTIL_VERSION <= 50001000} // 50.01.0 PIX_FMT_RGB32, ///< packed RGB 8:8:8, 32bpp, (msb)8A 8R 8G 8B(lsb), in CPU endianness +{$IFEND} PIX_FMT_YUV410P, ///< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) PIX_FMT_YUV411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) +{$IF LIBAVUTIL_VERSION <= 50000000} // 50.00.0 PIX_FMT_RGB565, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), in CPU endianness PIX_FMT_RGB555, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), in CPU endianness, most significant bit to 0 +{$IFEND} PIX_FMT_GRAY8, ///< Y , 8bpp PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white @@ -135,13 +154,17 @@ type PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG) PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG) PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG) - PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h) + PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing PIX_FMT_XVMC_MPEG2_IDCT, PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 +{$IF LIBAVUTIL_VERSION <= 50001000} // 50.01.0 PIX_FMT_BGR32, ///< packed RGB 8:8:8, 32bpp, (msb)8A 8B 8G 8R(lsb), in CPU endianness +{$IFEND} +{$IF LIBAVUTIL_VERSION <= 50000000} // 50.00.0 PIX_FMT_BGR565, ///< packed RGB 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), in CPU endianness PIX_FMT_BGR555, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), in CPU endianness, most significant bit to 1 +{$IFEND} PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb) PIX_FMT_BGR4, ///< packed RGB 1:2:1, 4bpp, (msb)1B 2G 1R(lsb) PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb) @@ -150,10 +173,15 @@ type PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb) PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 for UV PIX_FMT_NV21, ///< as above, but U and V bytes are swapped - +{$IF LIBAVUTIL_VERSION <= 50001000} // 50.01.0 PIX_FMT_RGB32_1, ///< packed RGB 8:8:8, 32bpp, (msb)8R 8G 8B 8A(lsb), in CPU endianness PIX_FMT_BGR32_1, ///< packed RGB 8:8:8, 32bpp, (msb)8B 8G 8R 8A(lsb), in CPU endianness - +{$ELSE} // 50.02.0 + PIX_FMT_ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB... + PIX_FMT_RGBA, ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA... + PIX_FMT_ABGR, ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR... + PIX_FMT_BGRA, ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA... +{$IFEND} PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian PIX_FMT_YUV440P, ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) @@ -164,23 +192,74 @@ type PIX_FMT_VDPAU_MPEG2,///< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers +{$IF LIBAVUTIL_VERSION >= 49015000} // 49.15.0 + PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, big-endian + PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, little-endian +{$IFEND} +{$IF LIBAVUTIL_VERSION >= 50001000} // 50.01.0 + PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian + PIX_FMT_RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian + PIX_FMT_RGB555BE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 + PIX_FMT_RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 + + PIX_FMT_BGR565BE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian + PIX_FMT_BGR565LE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian + PIX_FMT_BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 + PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 + + PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers + PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers + PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers +{$IFEND} PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions ); const {$ifdef WORDS_BIGENDIAN} - PIX_FMT_RGBA = PIX_FMT_RGB32_1; - PIX_FMT_BGRA = PIX_FMT_BGR32_1; - PIX_FMT_ARGB = PIX_FMT_RGB32; - PIX_FMT_ABGR = PIX_FMT_BGR32; - PIX_FMT_GRAY16 = PIX_FMT_GRAY16BE; + {$IF LIBAVUTIL_VERSION <= 50001000} // 50.01.0 + PIX_FMT_RGBA = PIX_FMT_RGB32_1; + PIX_FMT_BGRA = PIX_FMT_BGR32_1; + PIX_FMT_ARGB = PIX_FMT_RGB32; + PIX_FMT_ABGR = PIX_FMT_BGR32; + {$ELSE} // 50.02.0 + PIX_FMT_RGB32 = PIX_FMT_ARGB; + PIX_FMT_RGB32_1 = PIX_FMT_RGBA; + PIX_FMT_BGR32 = PIX_FMT_ABGR; + PIX_FMT_BGR32_1 = PIX_FMT_BGRA; + {$IFEND} + PIX_FMT_GRAY16 = PIX_FMT_GRAY16BE; + {$IF LIBAVUTIL_VERSION >= 49015000} // 49.15.0 + PIX_FMT_RGB48 = PIX_FMT_RGB48BE; + {$IFEND} + {$IF LIBAVUTIL_VERSION >= 50001000} // 50.01.0 + PIX_FMT_RGB565 = PIX_FMT_RGB565BE; + PIX_FMT_RGB555 = PIX_FMT_RGB555BE; + PIX_FMT_BGR565 = PIX_FMT_BGR565BE; + PIX_FMT_BGR555 = PIX_FMT_BGR555BE + {$IFEND} {$else} - PIX_FMT_RGBA = PIX_FMT_BGR32; - PIX_FMT_BGRA = PIX_FMT_RGB32; - PIX_FMT_ARGB = PIX_FMT_BGR32_1; - PIX_FMT_ABGR = PIX_FMT_RGB32_1; - PIX_FMT_GRAY16 = PIX_FMT_GRAY16LE; -{$endif} + {$IF LIBAVUTIL_VERSION <= 50001000} // 50.01.0 + PIX_FMT_RGBA = PIX_FMT_BGR32; + PIX_FMT_BGRA = PIX_FMT_RGB32; + PIX_FMT_ARGB = PIX_FMT_BGR32_1; + PIX_FMT_ABGR = PIX_FMT_RGB32_1; + {$ELSE} // 50.02.0 + PIX_FMT_RGB32 = PIX_FMT_BGRA; + PIX_FMT_RGB32_1 = PIX_FMT_ABGR; + PIX_FMT_BGR32 = PIX_FMT_RGBA; + PIX_FMT_BGR32_1 = PIX_FMT_ARGB; + {$IFEND} + PIX_FMT_GRAY16 = PIX_FMT_GRAY16LE; + {$IF LIBAVUTIL_VERSION >= 49015000} // 49.15.0 + PIX_FMT_RGB48 = PIX_FMT_RGB48LE; + {$IFEND} + {$IF LIBAVUTIL_VERSION >= 50001000} // 50.01.0 + PIX_FMT_RGB565 = PIX_FMT_RGB565LE; + PIX_FMT_RGB555 = PIX_FMT_RGB555LE; + PIX_FMT_BGR565 = PIX_FMT_BGR565LE; + PIX_FMT_BGR555 = PIX_FMT_BGR555LE; + {$IFEND} +{$ENDIF} {$IF LIBAVUTIL_VERSION_MAJOR < 50} // 50.0.0 PIX_FMT_UYVY411 = PIX_FMT_UYYVYY411; @@ -188,40 +267,41 @@ const PIX_FMT_YUV422 = PIX_FMT_YUYV422; {$IFEND} -(* common.h *) +(* libavutil/common.h *) // until now MKTAG is all from common.h KMS 9/6/2009 -function MKTAG(a,b,c,d: AnsiChar): integer; +function MKTAG(a, b, c, d: AnsiChar): integer; -(* mem.h *) +(* libavutil/mem.h *) +(* memory handling functions *) (** - * Allocate a block of \p size bytes with alignment suitable for all + * Allocates a block of size bytes with alignment suitable for all * memory accesses (including vectors if available on the CPU). * @param size Size in bytes for the memory block to be allocated. - * @return Pointer to the allocated block, NULL if it cannot allocate - * it. + * @return Pointer to the allocated block, NULL if the block cannot + * be allocated. * @see av_mallocz() *) function av_malloc(size: cuint): pointer; cdecl; external av__util; {av_malloc_attrib av_alloc_size(1)} (** - * Allocate or reallocate a block of memory. - * If \p ptr is NULL and \p size > 0, allocate a new block. If \p - * size is zero, free the memory block pointed by \p ptr. + * Allocates or reallocates a block of memory. + * If ptr is NULL and size > 0, allocates a new block. If \p + * size is zero, frees the memory block pointed to by ptr. * @param size Size in bytes for the memory block to be allocated or * reallocated. * @param ptr Pointer to a memory block already allocated with * av_malloc(z)() or av_realloc() or NULL. - * @return Pointer to a newly reallocated block or NULL if it cannot - * reallocate or the function is used to free the memory block. + * @return Pointer to a newly reallocated block or NULL if the block + * cannot be allocated or the function is used to free the memory block. * @see av_fast_realloc() *) function av_realloc(ptr: pointer; size: cuint): pointer; cdecl; external av__util; {av_alloc_size(2)} (** - * Free a memory block which has been allocated with av_malloc(z)() or + * Frees a memory block which has been allocated with av_malloc(z)() or * av_realloc(). * @param ptr Pointer to the memory block which should be freed. * @note ptr = NULL is explicitly allowed. @@ -232,29 +312,28 @@ procedure av_free(ptr: pointer); cdecl; external av__util; (** - * Allocate a block of \p size bytes with alignment suitable for all + * Allocates a block of size bytes with alignment suitable for all * memory accesses (including vectors if available on the CPU) and - * set to zeroes all the bytes of the block. + * zeroes all the bytes of the block. * @param size Size in bytes for the memory block to be allocated. - * @return Pointer to the allocated block, NULL if it cannot allocate - * it. + * @return Pointer to the allocated block, NULL if it cannot be allocated. * @see av_malloc() *) function av_mallocz(size: cuint): pointer; cdecl; external av__util; {av_malloc_attrib av_alloc_size(1)} (** - * Duplicate the string \p s. - * @param s String to be duplicated. + * Duplicates the string s. + * @param s string to be duplicated. * @return Pointer to a newly allocated string containing a - * copy of \p s or NULL if it cannot be allocated. + * copy of \p s or NULL if the string cannot be allocated. *) function av_strdup({const} s: PAnsiChar): PAnsiChar; cdecl; external av__util; {av_malloc_attrib} (** - * Free a memory block which has been allocated with av_malloc(z)() or - * av_realloc() and set to NULL the pointer to it. + * Frees a memory block which has been allocated with av_malloc(z)() or + * av_realloc() and set the pointer pointing to it to NULL. * @param ptr Pointer to the pointer to the memory block which should * be freed. * @see av_free() @@ -262,7 +341,7 @@ function av_strdup({const} s: PAnsiChar): PAnsiChar; procedure av_freep (ptr: pointer); cdecl; external av__util; -(* log.h *) +(* libavutil/log.h *) const {$IF LIBAVUTIL_VERSION_MAJOR < 50} @@ -277,26 +356,26 @@ const AV_LOG_QUIET = -8; (** - * something went really wrong and we will crash now + * Something went really wrong and we will crash now. *) AV_LOG_PANIC = 0; (** - * something went wrong and recovery is not possible - * like no header in a format which depends on it or a combination - * of parameters which are not allowed + * Something went wrong and recovery is not possible. + * For example, no header was found for a format which depends + * on headers or an illegal combination of parameters is used. *) AV_LOG_FATAL = 8; (** - * something went wrong and cannot losslessly be recovered - * but not all future data is affected + * Something went wrong and cannot losslessly be recovered. + * However, not all future data is affected. *) AV_LOG_ERROR = 16; (** - * something somehow does not look correct / something which may or may not - * lead to some problems like use of -vstrict -2 + * Something somehow does not look correct. This may or may not + * lead to problems. An example would be the use of '-vstrict -2'. *) AV_LOG_WARNING = 24; @@ -304,7 +383,7 @@ const AV_LOG_VERBOSE = 40; (** - * stuff which is only useful for libav* developers + * Stuff which is only useful for libav* developers. *) AV_LOG_DEBUG = 48; {$IFEND} @@ -317,7 +396,9 @@ procedure av_log_set_level(level: cint); implementation -function MKTAG(a,b,c,d: AnsiChar): integer; +(* libavutil/common.h *) + +function MKTAG(a, b, c, d: AnsiChar): integer; begin Result := (ord(a) or (ord(b) shl 8) or (ord(c) shl 16) or (ord(d) shl 24)); end; diff --git a/unicode/src/lib/ffmpeg/mathematics.pas b/unicode/src/lib/ffmpeg/mathematics.pas index fb57ccea..92ee0a5e 100644 --- a/unicode/src/lib/ffmpeg/mathematics.pas +++ b/unicode/src/lib/ffmpeg/mathematics.pas @@ -27,6 +27,9 @@ (* * Conversion of libavutil/mathematics.h * revision 16844, Wed Jan 28 08:50:10 2009 UTC + * + * update, MiSchi, no code change + * Fri Jun 12 2009 21:50:00 UTC *) unit mathematics; @@ -55,11 +58,11 @@ const type TAVRounding = ( - AV_ROUND_ZERO = 0, ///< Round toward zero - AV_ROUND_INF = 1, ///< Round away from zero - AV_ROUND_DOWN = 2, ///< Round toward -infinity - AV_ROUND_UP = 3, ///< Round toward +infinity - AV_ROUND_NEAR_INF = 5 ///< Round to nearest and halfway cases away from zero + AV_ROUND_ZERO = 0, ///< Round toward zero. + AV_ROUND_INF = 1, ///< Round away from zero. + AV_ROUND_DOWN = 2, ///< Round toward -infinity. + AV_ROUND_UP = 3, ///< Round toward +infinity. + AV_ROUND_NEAR_INF = 5 ///< Round to nearest and halfway cases away from zero. ); {$IF LIBAVUTIL_VERSION >= 49013000} // 49.13.0 @@ -90,4 +93,3 @@ function av_rescale_q (a: cint64; bq, cq: TAVRational): cint64; implementation end. - diff --git a/unicode/src/lib/ffmpeg/opt.pas b/unicode/src/lib/ffmpeg/opt.pas index 833dc247..a2e2cce9 100644 --- a/unicode/src/lib/ffmpeg/opt.pas +++ b/unicode/src/lib/ffmpeg/opt.pas @@ -28,6 +28,9 @@ (* * Conversion of libavcodec/opt.h * revision 16912, Sun Feb 1 02:00:19 2009 UTC + * + * update, MiSchi, no code change + * Fri Jun 12 2009 21:50:00 UTC *) unit opt; @@ -109,8 +112,8 @@ type {$IF LIBAVCODEC_VERSION >= 51039000} // 51.39.0 (** - * Looks for an option in \p obj. Looks only for the options which - * have the flags set as specified in \p mask and \p flags (that is, + * Looks for an option in obj. Looks only for the options which + * have the flags set as specified in mask and flags (that is, * for which it is the case that opt->flags & mask == flags). * * @param[in] obj a pointer to a struct whose first element is a @@ -135,7 +138,7 @@ function av_set_string(obj: pointer; name: {const} PAnsiChar; val: {const} PAnsi {$IF LIBAVCODEC_VERSION >= 51059000} // 51.59.0 (** * @return a pointer to the AVOption corresponding to the field set or - * NULL if no matching AVOption exists, or if the value \p val is not + * NULL if no matching AVOption exists, or if the value val is not * valid * @see av_set_string3() *) @@ -167,8 +170,11 @@ function av_set_string2(obj: Pointer; name: {const} PAnsiChar; val: {const} PAns * @param alloc when 1 then the old value will be av_freed() and the * new av_strduped() * when 0 then no av_free() nor av_strdup() will be used - * @return 0 if the value has been set, an AVERROR* error code if no - * matching option exists, or if the value \p val is not valid + * @return 0 if the value has been set, or an AVERROR code in case of + * error: + * AVERROR(ENOENT) if no matching option exists + * AVERROR(ERANGE) if the value is out of range + * AVERROR(EINVAL) if the value is not valid *) function av_set_string3(obj: Pointer; name: {const} PAnsiChar; val: {const} PAnsiChar; alloc: cint; out o_out: {const} PAVOption): cint; cdecl; external av__codec; diff --git a/unicode/src/lib/ffmpeg/rational.pas b/unicode/src/lib/ffmpeg/rational.pas index 6762aa26..b940009d 100644 --- a/unicode/src/lib/ffmpeg/rational.pas +++ b/unicode/src/lib/ffmpeg/rational.pas @@ -28,6 +28,9 @@ (* * Conversion of libavutil/rational.h * revision 16912, Sun Feb 1 02:00:19 2009 UTC + * + * update, MiSchi, no code change + * Fri Jun 12 2009 22:20:00 UTC *) unit rational; @@ -135,22 +138,20 @@ function av_d2q(d: cdouble; max: cint): TAVRational; cdecl; external av__util; {av_const} {$IF LIBAVUTIL_VERSION >= 49011000} // 49.11.0 - (** - * @return 1 if \q1 is nearer to \p q than \p q2, -1 if \p q2 is nearer - * than \p q1, 0 if they have the same distance. + * @return 1 if q1 is nearer to q than q2, -1 if q2 is nearer + * than q1, 0 if they have the same distance. *) function av_nearer_q(q, q1, q2: TAVRational): cint; cdecl; external av__util; (** - * Finds the nearest value in \p q_list to \p q. + * Finds the nearest value in q_list to q. * @param q_list an array of rationals terminated by {0, 0} * @return the index of the nearest value found in the array *) function av_find_nearest_q_idx(q: TAVRational; q_list: {const} PAVRationalArray): cint; cdecl; external av__util; - {$IFEND} implementation diff --git a/unicode/src/lib/ffmpeg/swscale.pas b/unicode/src/lib/ffmpeg/swscale.pas index 965659d9..c0aabf45 100644 --- a/unicode/src/lib/ffmpeg/swscale.pas +++ b/unicode/src/lib/ffmpeg/swscale.pas @@ -45,12 +45,13 @@ interface uses ctypes, avutil, + avcodec, UConfig; const (* Max. supported version by this header *) LIBSWSCALE_MAX_VERSION_MAJOR = 0; - LIBSWSCALE_MAX_VERSION_MINOR = 6; + LIBSWSCALE_MAX_VERSION_MINOR = 7; LIBSWSCALE_MAX_VERSION_RELEASE = 1; LIBSWSCALE_MAX_VERSION = (LIBSWSCALE_MAX_VERSION_MAJOR * VERSION_MAJOR) + (LIBSWSCALE_MAX_VERSION_MINOR * VERSION_MINOR) + @@ -78,7 +79,7 @@ function swscale_version(): cuint; {$IFEND} const - {* values for the flags, the stuff on the command line is different *} + (* values for the flags, the stuff on the command line is different *) SWS_FAST_BILINEAR = 1; SWS_BILINEAR = 2; SWS_BICUBIC = 4; @@ -98,10 +99,10 @@ const SWS_PRINT_INFO = $1000; - //the following 3 flags are not completely implemented - //internal chrominace subsampling info + // the following 3 flags are not completely implemented + // internal chrominace subsampling info SWS_FULL_CHR_H_INT = $2000; - //input subsampling info + // input subsampling info SWS_FULL_CHR_H_INP = $4000; SWS_DIRECT_BGR = $8000; SWS_ACCURATE_RND = $40000; @@ -123,15 +124,14 @@ const SWS_CS_SMPTE240M = 7; SWS_CS_DEFAULT = 5; - type // when used for filters they must have an odd number of elements // coeffs cannot be shared between vectors PSwsVector = ^TSwsVector; TSwsVector = record - coeff: PCdouble; - length: cint; + coeff: PCdouble; // pointer to the list of coefficients + length: cint; // number of coefficients in the vector end; // vectors can be shared @@ -148,63 +148,179 @@ type {internal structure} end; - procedure sws_freeContext(swsContext: PSwsContext); cdecl; external sw__scale; +(** + * Allocates and returns a SwsContext. You need it to perform + * scaling/conversion operations using sws_scale(). + * + * @param srcW the width of the source image + * @param srcH the height of the source image + * @param srcFormat the source image format + * @param dstW the width of the destination image + * @param dstH the height of the destination image + * @param dstFormat the destination image format + * @param flags specify which algorithm and options to use for rescaling + * @return a pointer to an allocated context, or NULL in case of error + *) function sws_getContext(srcW: cint; srcH: cint; srcFormat: TAVPixelFormat; - dstW: cint; dstH: cint; dstFormat: TAVPixelFormat; flags: cint; - srcFilter: PSwsFilter; dstFilter: PSwsFilter; param: PCdouble): PSwsContext; + dstW: cint; dstH: cint; dstFormat: TAVPixelFormat; + flags: cint; srcFilter: PSwsFilter; + dstFilter: PSwsFilter; param: PCdouble): PSwsContext; cdecl; external sw__scale; -function sws_scale(context: PSwsContext; src: PPCuint8Array; srcStride: PCintArray; srcSliceY: cint; srcSliceH: cint; - dst: PPCuint8Array; dstStride: PCintArray): cint; + +(** + * Scales the image slice in srcSlice and puts the resulting scaled + * slice in the image in dst. A slice is a sequence of consecutive + * rows in an image. + * + * @param context the scaling context previously created with + * sws_getContext() + * @param srcSlice the array containing the pointers to the planes of + * the source slice + * @param srcStride the array containing the strides for each plane of + * the source image + * @param srcSliceY the position in the source image of the slice to + * process, that is the number (counted starting from + * zero) in the image of the first row of the slice + * @param srcSliceH the height of the source slice, that is the number + * of rows in the slice + * @param dst the array containing the pointers to the planes of + * the destination image + * @param dstStride the array containing the strides for each plane of + * the destination image + * @return the height of the output slice + *) +function sws_scale(context: PSwsContext; srcSlice: PPCuint8Array; srcStride: PCintArray; + srcSliceY: cint; srcSliceH: cint; dst: PPCuint8Array; dstStride: PCintArray): cint; cdecl; external sw__scale; -function sws_scale_ordered(context: PSwsContext; src: PPCuint8Array; srcStride: PCintArray; srcSliceY: cint; - srcSliceH: cint; dst: PPCuint8Array; dstStride: PCintArray): cint; + +{$IF LIBSWSCALE_VERSION_MAJOR < 1} +// deprecated. Use sws_scale() instead. +function sws_scale_ordered(context: PSwsContext; src: PPCuint8Array; srcStride: PCintArray; + srcSliceY: cint; srcSliceH: cint; dst: PPCuint8Array; dstStride: PCintArray): cint; cdecl; external sw__scale; deprecated; +{$IFEND} -function sws_setColorspaceDetails(c: PSwsContext; inv_table: PQuadCintArray; srcRange: cint; table: PQuadCintArray; dstRange: cint; +(** + * @param inv_table the yuv2rgb coefficients, normally ff_yuv2rgb_coeffs[x] + * @param fullRange if 1 then the luma range is 0..255 if 0 it is 16..235 + * @return -1 if not supported + *) +function sws_setColorspaceDetails(c: PSwsContext; inv_table: PQuadCintArray; + srcRange: cint; table: PQuadCintArray; dstRange: cint; brightness: cint; contrast: cint; saturation: cint): cint; cdecl; external sw__scale; -function sws_getColorspaceDetails(c: PSwsContext; var inv_table: PQuadCintArray; var srcRange: cint; var table: PQuadCintArray; var dstRange: cint; + +(** + * @return -1 if not supported + *) +function sws_getColorspaceDetails(c: PSwsContext; var inv_table: PQuadCintArray; + var srcRange: cint; var table: PQuadCintArray; var dstRange: cint; var brightness: cint; var contrast: cint; var saturation: cint): cint; cdecl; external sw__scale; + +(** + * Returns a normalized Gaussian curve used to filter stuff + * quality=3 is high quality, lower is lower quality. + *) function sws_getGaussianVec(variance: cdouble; quality: cdouble): PSwsVector; cdecl; external sw__scale; + +(** + * Allocates and returns a vector with length coefficients, all + * with the same value c. + *) function sws_getConstVec(c: cdouble; length: cint): PSwsVector; cdecl; external sw__scale; + +(** + * Allocates and returns a vector with just one coefficient, with + * value 1.0. + *) function sws_getIdentityVec: PSwsVector; cdecl; external sw__scale; + +(** + * Scales all the coefficients of a by the scalar value. + *) procedure sws_scaleVec(a: PSwsVector; scalar: cdouble); cdecl; external sw__scale; + +(** + * Scales all the coefficients of a so that their sum equals height. + *) procedure sws_normalizeVec(a: PSwsVector; height: cdouble); cdecl; external sw__scale; + procedure sws_convVec(a: PSwsVector; b: PSwsVector); cdecl; external sw__scale; + procedure sws_addVec(a: PSwsVector; b: PSwsVector); cdecl; external sw__scale; + procedure sws_subVec(a: PSwsVector; b: PSwsVector); cdecl; external sw__scale; + procedure sws_shiftVec(a: PSwsVector; shift: cint); cdecl; external sw__scale; + +(** + * Allocates and returns a clone of the vector a, that is a vector + * with the same coefficients as a. + *) function sws_cloneVec(a: PSwsVector): PSwsVector; cdecl; external sw__scale; +{$IF LIBSWSCALE_VERSION_MAJOR < 1} +// deprecated Use sws_printVec2() instead. + procedure sws_printVec(a: PSwsVector); + cdecl; external sw__scale; deprecated; +{$IFEND} + +{$IF LIBSWSCALE_VERSION >= 000007000} // >= 0.7.0 +(** + * Prints with av_log() a textual representation of the vector a + * if log_level <= av_log_level. + *) +procedure sws_printVec2(a: PSwsVector; + log_ctx: PAVClass; // PAVClass is declared in avcodec.pas + log_level: cint); cdecl; external sw__scale; +{$IFEND} + procedure sws_freeVec(a: PSwsVector); cdecl; external sw__scale; -function sws_getDefaultFilter(lumaGBlur: cfloat; chromaGBlur: cfloat; lumaSarpen: cfloat; chromaSharpen: cfloat; chromaHShift: cfloat; - chromaVShift: cfloat; verbose: cint): PSwsFilter; +function sws_getDefaultFilter(lumaGBlur: cfloat; chromaGBlur: cfloat; + lumaSharpen: cfloat; chromaSharpen: cfloat; + chromaHShift: cfloat; chromaVShift: cfloat; + verbose: cint): PSwsFilter; cdecl; external sw__scale; + procedure sws_freeFilter(filter: PSwsFilter); cdecl; external sw__scale; +(** + * Checks if context can be reused, otherwise reallocates a new + * one. + * + * If context is NULL, just calls sws_getContext() to get a new + * context. Otherwise, checks if the parameters are the ones already + * saved in context. If that is the case, returns the current + * context. Otherwise, frees context and gets a new context with + * the new parameters. + * + * Be warned that srcFilter and dstFilter are not checked, they + * are assumed to remain the same. + *) function sws_getCachedContext(context: PSwsContext; - srcW: cint; srcH: cint; srcFormat: cint; - dstW: cint; dstH: cint; dstFormat: cint; flags: cint; - srcFilter: PSwsFilter; dstFilter: PSwsFilter; param: PCdouble): PSwsContext; + srcW: cint; srcH: cint; srcFormat: TAVPixelFormat; + dstW: cint; dstH: cint; dstFormat: TAVPixelFormat; + flags: cint; srcFilter: PSwsFilter; + dstFilter: PSwsFilter; param: PCdouble): PSwsContext; cdecl; external sw__scale; implementation diff --git a/unicode/src/media/UAudioDecoder_FFmpeg.pas b/unicode/src/media/UAudioDecoder_FFmpeg.pas index 2d221f40..97d8a8df 100644 --- a/unicode/src/media/UAudioDecoder_FFmpeg.pas +++ b/unicode/src/media/UAudioDecoder_FFmpeg.pas @@ -378,14 +378,14 @@ begin // try standard format SampleFormat := asfS16; end; - + if CodecCtx^.channels > 255 then + Log.LogStatus('Error: CodecCtx^.channels > 255', 'TFFmpegDecodeStream.Open'); FormatInfo := TAudioFormatInfo.Create( - CodecCtx^.channels, + byte(CodecCtx^.channels), CodecCtx^.sample_rate, SampleFormat ); - PacketQueue := TPacketQueue.Create(); // finally start the decode thread @@ -446,7 +446,9 @@ end; function TFFmpegDecodeStream.GetLength(): real; begin - // do not forget to consider the start_time value here + // do not forget to consider the start_time value here + // there is a type size mismatch warnign because start_time and duration are cint64. + // So, in principle there could be an overflow when doing the sum. Result := (FormatCtx^.start_time + FormatCtx^.duration) / AV_TIME_BASE; end; @@ -643,7 +645,6 @@ end; function TFFmpegDecodeStream.ParseLoop(): boolean; var Packet: TAVPacket; - StatusPacket: PAVPacket; SeekTarget: int64; ByteIOCtx: PByteIOContext; ErrorCode: integer; diff --git a/unicode/src/media/UAudioInput_Bass.pas b/unicode/src/media/UAudioInput_Bass.pas index cf292c45..ad6c3818 100644 --- a/unicode/src/media/UAudioInput_Bass.pas +++ b/unicode/src/media/UAudioInput_Bass.pas @@ -95,7 +95,7 @@ var * user - players associated with left/right channels *} function MicrophoneCallback(stream: HSTREAM; buffer: Pointer; - len: Cardinal; inputDevice: Pointer): boolean; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + len: integer; inputDevice: Pointer): boolean; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} begin AudioInputProcessor.HandleMicrophoneData(buffer, len, inputDevice); Result := true; diff --git a/unicode/src/media/UAudioInput_Portaudio.pas b/unicode/src/media/UAudioInput_Portaudio.pas index 53080a03..31d2882b 100644 --- a/unicode/src/media/UAudioInput_Portaudio.pas +++ b/unicode/src/media/UAudioInput_Portaudio.pas @@ -95,7 +95,6 @@ var Error: TPaError; inputParams: TPaStreamParameters; deviceInfo: PPaDeviceInfo; - SourceIndex: integer; begin Result := false; @@ -291,8 +290,6 @@ var sourceIndex: integer; sourceName: string; {$ENDIF} - cbPolls: integer; - cbWorks: boolean; begin Result := false; diff --git a/unicode/src/media/UAudioPlayback_SoftMixer.pas b/unicode/src/media/UAudioPlayback_SoftMixer.pas index c8da6bcd..c87e461d 100644 --- a/unicode/src/media/UAudioPlayback_SoftMixer.pas +++ b/unicode/src/media/UAudioPlayback_SoftMixer.pas @@ -51,7 +51,7 @@ type SampleBuffer: PByteArray; SampleBufferSize: integer; SampleBufferCount: integer; // number of available bytes in SampleBuffer - SampleBufferPos: cardinal; + SampleBufferPos: integer; SourceBuffer: PByteArray; SourceBufferSize: integer; @@ -564,9 +564,8 @@ var ConversionOutputSize: integer; // max. number of converted data (= buffer size) ConversionOutputCount: integer; // actual number of converted data SourceSize: integer; - RequestedSourceSize: integer; NeededSampleBufferSize: integer; - BytesNeeded, BytesAvail: integer; + BytesNeeded: integer; SourceFormatInfo, OutputFormatInfo: TAudioFormatInfo; SourceFrameSize, OutputFrameSize: integer; SkipOutputCount: integer; // number of output-data bytes to skip @@ -574,7 +573,6 @@ var FillCount: integer; // number of bytes to fill with padding data CopyCount: integer; PadFrame: PByteArray; - i: integer; begin Result := -1; diff --git a/unicode/src/media/UVideo.pas b/unicode/src/media/UVideo.pas index 35f8ab4d..f55690b2 100644 --- a/unicode/src/media/UVideo.pas +++ b/unicode/src/media/UVideo.pas @@ -697,6 +697,12 @@ begin 0, fCodecContext^.Height, @(fAVFrameRGB.data), @(fAVFrameRGB.linesize)); {$ELSE} + // img_convert from lib/ffmpeg/avcodec.pas is actually deprecated. + // If ./configure does not find SWScale then this gives the error + // that the identifier img_convert is not known or similar. + // I think this should be removed, but am not sure whether there should + // be some other replacement or a warning, Therefore, I leave it for now. + // April 2009, mischi errnum := img_convert(PAVPicture(fAVFrameRGB), PIXEL_FMT_FFMPEG, PAVPicture(fAVFrame), fCodecContext^.pix_fmt, fCodecContext^.width, fCodecContext^.height); diff --git a/unicode/src/menu/UDisplay.pas b/unicode/src/menu/UDisplay.pas index 3e653183..f2eb2ced 100644 --- a/unicode/src/menu/UDisplay.pas +++ b/unicode/src/menu/UDisplay.pas @@ -45,43 +45,71 @@ type TDisplay = class private //fade-to-black-hack - BlackScreen: Boolean; + BlackScreen: boolean; - FadeEnabled: Boolean; // true if fading is enabled - FadeFailed: Boolean; // true if fading is possible (enough memory, etc.) - FadeState: integer; // fading state, 0 means that the fade texture must be initialized - LastFadeTime: Cardinal; // last fade update time + FadeEnabled: boolean; // true if fading is enabled + FadeFailed: boolean; // true if fading is possible (enough memory, etc.) + FadeState: integer; // fading state, 0 means that the fade texture must be initialized + LastFadeTime: cardinal; // last fade update time - FadeTex: array[1..2] of GLuint; + FadeTex: array[1..2] of GLuint; + + FPSCounter: cardinal; + LastFPS: cardinal; + NextFPSSwap: cardinal; - FPSCounter : Cardinal; - LastFPS : Cardinal; - NextFPSSwap : Cardinal; + OSD_LastError: string; - OSD_LastError : String; + { software cursor data } + Cursor_X: double; + Cursor_Y: double; + Cursor_Pressed: boolean; + Cursor_HiddenByScreen: boolean; // hides software cursor and deactivate auto fade in + + // used for cursor fade out when there is no movement + Cursor_Visible: boolean; + Cursor_LastMove: cardinal; + Cursor_Fade: boolean; procedure DrawDebugInformation; public - NextScreen : PMenu; - CurrentScreen : PMenu; + NextScreen: PMenu; + CurrentScreen: PMenu; //popup data NextScreenWithCheck: Pmenu; - CheckOK : Boolean; + CheckOK: boolean; // FIXME: Fade is set to 0 in UMain and other files but not used here anymore. - Fade : Real; + Fade: real; constructor Create; destructor Destroy; override; procedure SaveScreenShot; - function Draw: Boolean; + function Draw: boolean; + + { sets SDL_ShowCursor depending on options set in Ini } + procedure SetCursor; + + { called when cursor moves, positioning of software cursor } + procedure MoveCursor(X, Y: double; Pressed: boolean); + + + { draws software cursor } + procedure DrawCursor; end; var - Display: TDisplay; + Display: TDisplay; + +const + { constants for software cursor effects + time in milliseconds } + Cursor_FadeIn_Time = 500; // seconds the fade in effect lasts + Cursor_FadeOut_Time = 2000; // seconds the fade out effect lasts + Cursor_AutoHide_Time = 5000; // seconds until auto fade out starts if there is no mouse movement implementation @@ -104,15 +132,15 @@ begin inherited Create; //popup hack - CheckOK := False; + CheckOK := false; NextScreen := nil; NextScreenWithCheck := nil; - BlackScreen := False; + BlackScreen := false; // fade mod - FadeState := 0; + FadeState := 0; FadeEnabled := (Ini.ScreenFade = 1); - FadeFailed:= false; + FadeFailed := false; glGenTextures(2, @FadeTex); @@ -125,6 +153,15 @@ begin //Set LastError for OSD to No Error OSD_LastError := 'No Errors'; + + // software cursor default values + Cursor_LastMove := 0; + Cursor_Visible := false; + Cursor_Pressed := false; + Cursor_X := -1; + Cursor_Y := -1; + Cursor_Fade := false; + Cursor_HiddenByScreen := true; end; destructor TDisplay.Destroy; @@ -133,14 +170,14 @@ begin inherited Destroy; end; -function TDisplay.Draw: Boolean; +function TDisplay.Draw: boolean; var - S: integer; - FadeStateSquare: Real; - currentTime: Cardinal; - glError: glEnum; + S: integer; + FadeStateSquare: real; + currentTime: cardinal; + glError: glEnum; begin - Result := True; + Result := true; //We don't need this here anymore, //Because the background care about cleaning the buffers @@ -166,12 +203,12 @@ begin begin NextScreen := NextScreenWithCheck; NextScreenWithCheck := nil; - CheckOk := False; + CheckOk := false; end else begin // on end of game fade to black before exit - BlackScreen := True; + BlackScreen := true; end; end; @@ -188,16 +225,16 @@ begin // fade mod FadeState := 0; if ((Ini.ScreenFade = 1) and (not FadeFailed)) then - FadeEnabled := True + FadeEnabled := true else if (Ini.ScreenFade = 0) then - FadeEnabled := False; + FadeEnabled := false; end else begin // disable fading if initialization failed if (FadeEnabled and FadeFailed) then begin - FadeEnabled := False; + FadeEnabled := false; end; if (FadeEnabled and not FadeFailed) then @@ -275,7 +312,7 @@ begin glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); end - // blackscreen hack +// blackscreen hack else if not BlackScreen then begin NextScreen.OnShow; @@ -286,7 +323,7 @@ begin // fade out complete... FadeState := 0; CurrentScreen.onHide; - CurrentScreen.ShowFinish := False; + CurrentScreen.ShowFinish := false; CurrentScreen := NextScreen; NextScreen := nil; if not BlackScreen then @@ -296,16 +333,172 @@ begin end else begin - Result := False; + Result := false; Break; end; end; end; // if - //Draw OSD only on first Screen if Debug Mode is enabled +// 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 + + if not BlackScreen then + DrawCursor; +end; + +{ sets SDL_ShowCursor depending on options set in Ini } +procedure TDisplay.SetCursor; +var + Cursor: Integer; +begin + Cursor := 0; + + if (CurrentScreen <> @ScreenSing) or (Cursor_HiddenByScreen) then + begin // hide cursor on singscreen + if (Ini.Mouse = 0) and (Ini.FullScreen = 0) then + // show sdl (os) cursor in window mode even when mouse support is off + Cursor := 1 + else if (Ini.Mouse = 1) then + // show sdl (os) cursor when hardware cursor is selected + Cursor := 1; + + if (Ini.Mouse <> 2) then + Cursor_HiddenByScreen := false; + end + else if (Ini.Mouse <> 2) then + Cursor_HiddenByScreen := true; + + + SDL_ShowCursor(Cursor); + + if (Ini.Mouse = 2) then + begin + if Cursor_HiddenByScreen then + begin + // show software cursor + Cursor_HiddenByScreen := false; + Cursor_Visible := false; + Cursor_Fade := false; + end + else if (CurrentScreen = @ScreenSing) then + begin + // hide software cursor in singscreen + Cursor_HiddenByScreen := true; + Cursor_Visible := false; + Cursor_Fade := false; + end; + end; +end; + +{ called when cursor moves, positioning of software cursor } +procedure TDisplay.MoveCursor(X, Y: double; Pressed: boolean); +var + Ticks: cardinal; +begin + if (Ini.Mouse = 2) and + ((X <> Cursor_X) or (Y <> Cursor_Y) or (Pressed <> Cursor_Pressed)) then + begin + Cursor_X := X; + Cursor_Y := Y; + Cursor_Pressed := Pressed; + + Ticks := SDL_GetTicks; + + { fade in on movement (or button press) if not first movement } + if (not Cursor_Visible) and (Cursor_LastMove <> 0) then + begin + if Cursor_Fade then // we use a trick here to consider progress of fade out + Cursor_LastMove := Ticks - round(Cursor_FadeIn_Time * (1 - (Ticks - Cursor_LastMove)/Cursor_FadeOut_Time)) + else + Cursor_LastMove := Ticks; + + Cursor_Visible := true; + Cursor_Fade := true; + end + else if not Cursor_Fade then + begin + Cursor_LastMove := Ticks; + end; + end; +end; + +{ draws software cursor } +procedure TDisplay.DrawCursor; +var + Alpha: single; + Ticks: cardinal; +begin + if (Ini.Mouse = 2) then + begin // draw software cursor + Ticks := SDL_GetTicks; + + if (Cursor_Visible) and (Cursor_LastMove + Cursor_AutoHide_Time <= Ticks) then + begin // start fade out after 5 secs w/o activity + Cursor_Visible := false; + Cursor_LastMove := Ticks; + Cursor_Fade := true; + end; + + // fading + if Cursor_Fade then + begin + if Cursor_Visible then + begin // fade in + if (Cursor_LastMove + Cursor_FadeIn_Time <= Ticks) then + Cursor_Fade := false + else + Alpha := sin((Ticks - Cursor_LastMove) * 0.5 * pi / Cursor_FadeIn_Time) * 0.7; + end + else + begin //fade out + if (Cursor_LastMove + Cursor_FadeOut_Time <= Ticks) then + Cursor_Fade := false + else + Alpha := cos((Ticks - Cursor_LastMove) * 0.5 * pi / Cursor_FadeOut_Time) * 0.7; + end; + end; + + // no else if here because we may turn off fade in if block + if not Cursor_Fade then + begin + if Cursor_Visible then + Alpha := 0.7 // alpha when cursor visible and not fading + else + Alpha := 0; // alpha when cursor is hidden + end; + + if (Alpha > 0) and (not Cursor_HiddenByScreen) then + begin + glColor4f(1, 1, 1, Alpha); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + + if (Cursor_Pressed) and (Tex_Cursor_Pressed.TexNum > 0) then + glBindTexture(GL_TEXTURE_2D, Tex_Cursor_Pressed.TexNum) + else + glBindTexture(GL_TEXTURE_2D, Tex_Cursor_Unpressed.TexNum); + + glBegin(GL_QUADS); + glTexCoord2f(0, 0); + glVertex2f(Cursor_X, Cursor_Y); + + glTexCoord2f(0, 1); + glVertex2f(Cursor_X, Cursor_Y + 32); + + glTexCoord2f(1, 1); + glVertex2f(Cursor_X + 32, Cursor_Y + 32); + + glTexCoord2f(1, 0); + glVertex2f(Cursor_X + 32, Cursor_Y); + glEnd; + + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + end; + end; end; procedure TDisplay.SaveScreenShot; @@ -318,7 +511,7 @@ var Align: integer; RowSize: integer; begin - // Exit if Screenshot-path does not exist or read-only +// Exit if Screenshot-path does not exist or read-only if (ScreenshotsPath = '') then Exit; @@ -332,9 +525,9 @@ begin break end; - // we must take the row-alignment (4byte by default) into account +// we must take the row-alignment (4byte by default) into account glGetIntegerv(GL_PACK_ALIGNMENT, @Align); - // calc aligned row-size +// calc aligned row-size RowSize := ((ScreenW*3 + (Align-1)) div Align) * Align; GetMem(ScreenData, RowSize * ScreenH); @@ -347,8 +540,8 @@ begin ScreenData, ScreenW, ScreenH, 24, RowSize, $0000FF, $00FF00, $FF0000, 0); - //Success := WriteJPGImage(FileName, Surface, 95); - //Success := WriteBMPImage(FileName, Surface); +// Success := WriteJPGImage(FileName, Surface, 95); +// Success := WriteBMPImage(FileName, Surface); Success := WritePNGImage(FileName, Surface); if Success then ScreenPopupError.ShowPopup('Screenshot saved: ' + ExtractFileName(FileName)) @@ -360,12 +553,13 @@ begin end; //------------ -// DrawDebugInformation - Procedure draw FPS and some other Informations on Screen +// DrawDebugInformation - procedure draw fps and some other informations on screen //------------ procedure TDisplay.DrawDebugInformation; -var Ticks: Cardinal; +var + Ticks: cardinal; begin - //Some White Background for information +// Some White Background for information glEnable(GL_BLEND); glDisable(GL_TEXTURE_2D); glColor4f(1, 1, 1, 0.5); @@ -377,13 +571,13 @@ begin glEnd; glDisable(GL_BLEND); - //Set Font Specs +// set font specs SetFontStyle(0); SetFontSize(21); - SetFontItalic(False); + SetFontItalic(false); glColor4f(0, 0, 0, 1); - //Calculate FPS +// calculate fps Ticks := SDL_GetTicks(); if (Ticks >= NextFPSSwap) then begin @@ -394,17 +588,17 @@ begin Inc(FPSCounter); - //Draw Text +// draw text - //FPS +// fps SetFontPos(695, 0); glPrint ('FPS: ' + InttoStr(LastFPS)); - //RSpeed +// rspeed SetFontPos(695, 13); glPrint ('RSpeed: ' + InttoStr(Round(1000 * TimeMid))); - //LastError +// lasterror SetFontPos(695, 26); glColor4f(1, 0, 0, 1); glPrint (OSD_LastError); diff --git a/unicode/src/menu/UMenu.pas b/unicode/src/menu/UMenu.pas index 6d9fba96..444bac62 100644 --- a/unicode/src/menu/UMenu.pas +++ b/unicode/src/menu/UMenu.pas @@ -34,19 +34,20 @@ interface {$I switches.inc} uses - gl, SysUtils, - UTexture, - UMenuStatic, - UMenuText, - UMenuButton, - UMenuSelectSlide, - UMenuInteract, + Math, + gl, + SDL, UMenuBackground, - UThemes, + UMenuButton, UMenuButtonCollection, - Math, - UMusic; + UMenuInteract, + UMenuSelectSlide, + UMenuStatic, + UMenuText, + UMusic, + UTexture, + UThemes; type { Int16 = SmallInt;} @@ -54,15 +55,15 @@ type PMenu = ^TMenu; TMenu = class protected - Background: TMenuBackground; + Background: TMenuBackground; + + Interactions: array of TInteract; + SelInteraction: integer; - Interactions: array of TInteract; - SelInteraction: integer; + ButtonPos: integer; + Button: array of TButton; - ButtonPos: integer; - Button: array of TButton; - - SelectsS: array of TSelectSlide; + SelectsS: array of TSelectSlide; ButtonCollection: array of TButtonCollection; public Text: array of TText; @@ -72,6 +73,7 @@ type Fade: integer; // fade type ShowFinish: boolean; // true if there is no fade + RightMbESC: boolean; // true to simulate ESC keypress when RMB is pressed destructor Destroy; override; constructor Create; overload; virtual; @@ -80,10 +82,10 @@ type // interaction procedure AddInteraction(Typ, Num: integer); - procedure SetInteraction(Num: integer); + procedure SetInteraction(Num: integer); virtual; property Interaction: integer read SelInteraction write SetInteraction; - //Procedure Load BG, Texts, Statics and Button Collections from ThemeBasic + // procedure load bg, texts, statics and button collections from themebasic procedure LoadFromTheme(const ThemeBasic: TThemeBasic); procedure PrepareButtonCollections(const Collections: AThemeButtonCollection); @@ -109,7 +111,7 @@ type function AddText(X, Y, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; const Text_: UTF8String; Reflection_: boolean; ReflectionSpacing_: real; Z : real): 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 + 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; const Name: string): integer; overload; function AddButton(X, Y, W, H: real; const Name: string; Typ: TTextureType; Reflection: boolean): integer; overload; @@ -143,9 +145,10 @@ type function DrawFG: boolean; virtual; function Draw: boolean; virtual; function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown : boolean): boolean; virtual; - // FIXME: ParseMouse is not implemented in any subclass and not even used anywhere in the code - // -> do this before activation of this method - //function ParseMouse(Typ: integer; X: integer; Y: integer): boolean; virtual; abstract; + function ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean; virtual; + function InRegion(X1, Y1, W, H, X, Y: real): boolean; + function InteractAt(X, Y: real): integer; + function CollectionAt(X, Y: real): integer; procedure onShow; virtual; procedure onShowFinish; virtual; procedure onHide; virtual; @@ -165,13 +168,16 @@ type end; const - pmMove = 1; - pmClick = 2; + MENU_MDOWN = 8; + MENU_MUP = 0; + + pmMove = 1; + pmClick = 2; pmUnClick = 3; - iButton = 0; // interaction type - iText = 2; - iSelectS = 3; + iButton = 0; // interaction type + iText = 2; + iSelectS = 3; iBCollectionChild = 5; // fBlack = 0; // fade type @@ -179,21 +185,22 @@ const implementation -uses UCommon, - ULog, - UMain, - UDrawTexture, - UGraphic, - UDisplay, - UCovers, - UTime, - USkins, - //Background types - UMenuBackgroundNone, - UMenuBackgroundColor, - UMenuBackgroundTexture, - UMenuBackgroundVideo, - UMenuBackgroundFade; +uses + UCommon, + UCovers, + UDisplay, + UDrawTexture, + UGraphic, + ULog, + UMain, + USkins, + UTime, + //Background types + UMenuBackgroundNone, + UMenuBackgroundColor, + UMenuBackgroundTexture, + UMenuBackgroundVideo, + UMenuBackgroundFade; destructor TMenu.Destroy; begin @@ -218,6 +225,8 @@ begin ButtonPos := -1; Background := nil; + + RightMbESC := true; end; { constructor TMenu.Create(Back: string); @@ -249,7 +258,7 @@ begin BackH := H; end; } -function RGBFloatToInt(R, G, B: Double): cardinal; +function RGBFloatToInt(R, G, B: double): cardinal; begin Result := (Trunc(255 * R) shl 16) or (Trunc(255 * G) shl 8) or @@ -288,8 +297,8 @@ begin 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 + // 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; @@ -337,8 +346,9 @@ procedure TMenu.AddBackground(ThemedSettings: TThemeBackground); var FileExt: string; - Function IsInArray(const Piece: string; const A: array of string): boolean; - var I: integer; + function IsInArray(const Piece: string; const A: array of string): boolean; + var + I: integer; begin Result := false; @@ -350,7 +360,7 @@ procedure TMenu.AddBackground(ThemedSettings: TThemeBackground); end; end; - Function TryBGCreate(Typ: cMenuBackground): boolean; + function TryBGCreate(Typ: cMenuBackground): boolean; begin Result := true; @@ -372,7 +382,7 @@ begin Background := nil; end; - Case ThemedSettings.BGType of + case ThemedSettings.BGType of bgtAuto: begin //Automaticly choose one out of BGT_Texture, BGT_Video or BGT_Color if (Length(ThemedSettings.Tex) > 0) then @@ -489,7 +499,7 @@ end; //---------------------- procedure TMenu.AddButtonCollection(const ThemeCollection: TThemeButtonCollection; const Num: byte); var - BT, BTLen: integer; + BT, BTLen: integer; TempCol, TempDCol: cardinal; begin @@ -592,17 +602,25 @@ begin Result := AddStatic(X, Y, W, H, Name, TEXTURE_TYPE_PLAIN); end; -function TMenu.AddStatic(X, Y, W, H: real; ColR, ColG, ColB: real; const Name: string; Typ: TTextureType): integer; +function TMenu.AddStatic(X, Y, W, H: real; + ColR, ColG, ColB: real; + const Name: string; + Typ: TTextureType): integer; begin Result := AddStatic(X, Y, W, H, ColR, ColG, ColB, Name, Typ, $FFFFFF); end; -function TMenu.AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; const Name: string; Typ: TTextureType): integer; +function TMenu.AddStatic(X, Y, W, H, Z: real; + ColR, ColG, ColB: real; + const Name: string; + Typ: TTextureType): integer; begin Result := AddStatic(X, Y, W, H, Z, ColR, ColG, ColB, Name, Typ, $FFFFFF); end; -function TMenu.AddStatic(X, Y, W, H: real; const Name: string; Typ: TTextureType): integer; +function TMenu.AddStatic(X, Y, W, H: real; + const Name: string; + Typ: TTextureType): integer; var StatNum: integer; begin @@ -620,17 +638,32 @@ begin Result := StatNum; end; -function TMenu.AddStatic(X, Y, W, H: real; ColR, ColG, ColB: real; const Name: string; Typ: TTextureType; Color: integer): integer; +function TMenu.AddStatic(X, Y, W, H: real; + ColR, ColG, ColB: real; + const Name: string; + Typ: TTextureType; + Color: integer): integer; begin Result := AddStatic(X, Y, W, H, 0, ColR, ColG, ColB, Name, Typ, Color); end; -function TMenu.AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; const Name: string; Typ: TTextureType; Color: integer): integer; +function TMenu.AddStatic(X, Y, W, H, Z: real; + ColR, ColG, ColB: real; + const Name: string; + Typ: TTextureType; + Color: integer): integer; begin Result := AddStatic(X, Y, W, H, Z, ColR, ColG, ColB, 0, 0, 1, 1, Name, Typ, Color, false, 0); end; -function TMenu.AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; TexX1, TexY1, TexX2, TexY2: real; const Name: string; Typ: TTextureType; Color: integer; Reflection: boolean; ReflectionSpacing: real): integer; +function TMenu.AddStatic(X, Y, W, H, Z: real; + ColR, ColG, ColB: real; + TexX1, TexY1, TexX2, TexY2: real; + const Name: string; + Typ: TTextureType; + Color: integer; + Reflection: boolean; + ReflectionSpacing: real): integer; var StatNum: integer; begin @@ -648,12 +681,22 @@ begin begin Static[StatNum] := TStatic.Create(Texture.GetTexture(Name, Typ, Color)); // new skin end; - + // configures static Static[StatNum].Texture.X := X; Static[StatNum].Texture.Y := Y; - Static[StatNum].Texture.W := W; - Static[StatNum].Texture.H := H; + + //Set height and width via sprite size if omitted + if(H = 0) then + Static[StatNum].Texture.H := Static[StatNum].Texture.H + else + Static[StatNum].Texture.H := H; + + if(W = 0) then + Static[StatNum].Texture.W := Static[StatNum].Texture.W + else + Static[StatNum].Texture.W := W; + Static[StatNum].Texture.Z := Z; if (Typ <> TEXTURE_TYPE_COLORIZED) then begin @@ -692,12 +735,22 @@ begin Result := TextNum; end; -function TMenu.AddText(X, Y: real; Style: integer; Size, ColR, ColG, ColB: real; const Text: UTF8String): integer; +function TMenu.AddText(X, Y: real; + Style: integer; + Size, ColR, ColG, ColB: real + ; const Text: UTF8String): integer; begin Result := AddText(X, Y, 0, Style, Size, ColR, ColG, ColB, 0, Text, false, 0, 0); end; -function TMenu.AddText(X, Y, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; const Text_: UTF8String; Reflection_: boolean; ReflectionSpacing_: real; Z : real): integer; +function TMenu.AddText(X, Y, W: real; + Style: integer; + Size, ColR, ColG, ColB: real; + Align: integer; + const Text_: UTF8String; + Reflection_: boolean; + ReflectionSpacing_: real; + Z : real): integer; var TextNum: integer; begin @@ -709,9 +762,9 @@ begin end; //Function that Set Length of Button boolean in one Step instead of register new Memory for every Button -Procedure TMenu.SetButtonLength(Length: cardinal); +procedure TMenu.SetButtonLength(Length: cardinal); begin - if (ButtonPos = -1) AND (Length > 0) then + if (ButtonPos = -1) and (Length > 0) then begin //Set Length of Button SetLength(Button, Length); @@ -767,10 +820,10 @@ begin ThemeButton.Text[BT].Text); end; - //BAutton Collection Mod + // bautton collection mod if (ThemeButton.Parent <> 0) then begin - //If Collection Exists then Change Interaction to Child Button + // if collection exists then change interaction to child button if (@ButtonCollection[ThemeButton.Parent-1] <> nil) then begin Interactions[High(Interactions)].Typ := iBCollectionChild; @@ -799,8 +852,10 @@ begin end; function TMenu.AddButton(X, Y, W, H, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt: real; - const Name: string; Typ: TTextureType; - Reflection: boolean; ReflectionSpacing, DeSelectReflectionSpacing: real): integer; + const Name: string; + Typ: TTextureType; + Reflection: boolean; + ReflectionSpacing, DeSelectReflectionSpacing: real): integer; begin // adds button //SetLength is used once to reduce Memory usement @@ -853,7 +908,7 @@ begin Button[Result].Reflectionspacing := ReflectionSpacing; Button[Result].DeSelectReflectionspacing := DeSelectReflectionSpacing; - //Button Collection Mod + // button collection mod Button[Result].Parent := 0; // adds interaction @@ -866,11 +921,10 @@ begin Setlength(Button, 0); end; -// Method to draw our TMenu and all his child buttons +// method to draw our tmenu and all his child buttons function TMenu.DrawBG: boolean; begin Background.Draw; - Result := true; end; @@ -918,9 +972,9 @@ end; } { -function TMenu.AddWidget(X, Y : UInt16; WidgetSrc : PSDL_Surface): Int16; +function TMenu.AddWidget(X, Y: UInt16; WidgetSrc: PSDL_Surface): Int16; var - WidgetNum : Int16; + WidgetNum: Int16; begin if (Assigned(WidgetSrc)) then begin @@ -944,9 +998,9 @@ end; } { -procedure TMenu.ClearWidgets(MinNumber : Int16); +procedure TMenu.ClearWidgets(MinNumber: Int16); var - J : Int16; + J: Int16; begin for J := MinNumber to (Length(WidgetsSrc) - 1) do begin @@ -989,9 +1043,10 @@ begin Int := Int - ceil(Length(Interactions) / 2); //Set Interaction - if ((Int < 0) or (Int > Length(Interactions) - 1)) - then Int := Interaction //nonvalid button, keep current one - else Interaction := Int; //select row above + if ((Int < 0) or (Int > Length(Interactions) - 1)) then + Int := Interaction // invalid button, keep current one + else + Interaction := Int; // select row above end; procedure TMenu.InteractNextRow; @@ -1003,9 +1058,10 @@ begin Int := Int + ceil(Length(Interactions) / 2); //Set Interaction - if ((Int < 0) or (Int > Length(Interactions) - 1)) - then Int := Interaction //nonvalid button, keep current one - else Interaction := Int; //select row above + if ((Int < 0) or (Int > Length(Interactions) - 1)) then + Int := Interaction // invalid button, keep current one + else + Interaction := Int; // select row above end; procedure TMenu.InteractNext; @@ -1019,7 +1075,8 @@ begin Int := (Int + 1) mod Length(Interactions); //If no Interaction is Selectable Simply Select Next - if (Int = Interaction) then Break; + if (Int = Interaction) then + Break; until IsSelectable(Int); @@ -1036,10 +1093,12 @@ begin // change interaction as long as it's needed repeat Int := Int - 1; - if Int = -1 then Int := High(Interactions); + if Int = -1 then + Int := High(Interactions); //If no Interaction is Selectable Simply Select Next - if (Int = Interaction) then Break; + if (Int = Interaction) then + Break; until IsSelectable(Int); //Set Interaction @@ -1064,7 +1123,8 @@ begin while (Again = true) do begin Num := SelInteraction - CustomSwitch; - if Num = -1 then Num := High(Interactions); + if Num = -1 then + Num := High(Interactions); Interaction := Num; Again := false; // reset, default to accept changing interaction @@ -1208,6 +1268,9 @@ begin SelectsS[High(SelectsS)].Texture.Z := ThemeSelectS.Z; SelectsS[High(SelectsS)].TextureSBG.Z := ThemeSelectS.Z; + SelectsS[High(SelectsS)].showArrows := ThemeSelectS.showArrows; + SelectsS[High(SelectsS)].oneItemOnly := ThemeSelectS.oneItemOnly; + //Generate Lines SelectsS[High(SelectsS)].GenLines; @@ -1250,9 +1313,21 @@ begin SelectsS[S].TextureSBG := Texture.GetTexture(SBGName, SBGTyp, RGBFloatToInt(SBGColR, SBGColG, SBGColB)) else SelectsS[S].TextureSBG := Texture.GetTexture(SBGName, SBGTyp); + + SelectsS[High(SelectsS)].Tex_SelectS_ArrowL := Tex_SelectS_ArrowL; + SelectsS[High(SelectsS)].Tex_SelectS_ArrowL.X := X + W + SkipX; + SelectsS[High(SelectsS)].Tex_SelectS_ArrowL.Y := Y; + SelectsS[High(SelectsS)].Tex_SelectS_ArrowL.W := Tex_SelectS_ArrowL.W; + SelectsS[High(SelectsS)].Tex_SelectS_ArrowL.H := Tex_SelectS_ArrowL.H; + + SelectsS[High(SelectsS)].Tex_SelectS_ArrowR := Tex_SelectS_ArrowR; + SelectsS[High(SelectsS)].Tex_SelectS_ArrowR.X := X + W + SkipX + SBGW - Tex_SelectS_ArrowR.W; + SelectsS[High(SelectsS)].Tex_SelectS_ArrowR.Y := Y; + SelectsS[High(SelectsS)].Tex_SelectS_ArrowR.W := Tex_SelectS_ArrowR.W; + SelectsS[High(SelectsS)].Tex_SelectS_ArrowR.H := Tex_SelectS_ArrowR.H; + 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; @@ -1350,10 +1425,12 @@ begin SetLength(SelectsS[SelectNo].TextOptT, SO + 1); SelectsS[SelectNo].TextOptT[SO] := AddText; +{ + SelectsS[S].SelectedOption := SelectsS[S].SelectOptInt; // refresh - //SelectsS[S].SelectedOption := SelectsS[S].SelectOptInt; // refresh - - //if SO = Selects[S].PData^ then Selects[S].SelectedOption := SO; + if SO = Selects[S].PData^ then + Selects[S].SelectedOption := SO; +} end; procedure TMenu.UpdateSelectSlideOptions(ThemeSelectSlide: TThemeSelectSlide; SelectNum: integer; const Values: array of string; var Data: integer); @@ -1453,12 +1530,12 @@ begin end; end; end; - //interact Prev if there is Nothing to Change + // 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 + // 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 @@ -1527,10 +1604,120 @@ begin Result := true; end; +function TMenu.ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean; +var + nBut: integer; +begin + //default mouse parsing: clicking generates return keypress, + // mousewheel selects in select slide + //override ParseMouse to customize + Result := true; + + if RightMbESC and (MouseButton = SDL_BUTTON_RIGHT) and BtnDown then + begin + //if RightMbESC is set, send ESC keypress + Result:=ParseInput(SDLK_ESCAPE, 0, true); + end; + + nBut := InteractAt(X, Y); + if nBut >= 0 then + begin + //select on mouse-over + if nBut <> Interaction then + SetInteraction(nBut); + if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then + begin + //click button + Result:=ParseInput(SDLK_RETURN, 0, true); + end; + if (Interactions[nBut].Typ = iSelectS) then + begin + //forward/backward in select slide with mousewheel + if (MouseButton = SDL_BUTTON_WHEELDOWN) and BtnDown then + begin + ParseInput(SDLK_RIGHT, 0, true); + end; + if (MouseButton = SDL_BUTTON_WHEELUP) and BtnDown then + begin + ParseInput(SDLK_LEFT, 0, true); + end; + end; + end + else + begin + nBut := CollectionAt(X, Y); + if nBut >= 0 then + begin + // if over button collection, select first child but don't allow click + nBut := ButtonCollection[nBut].FirstChild - 1; + if nBut <> Interaction then + SetInteraction(nBut); + end; + end; +end; + +function TMenu.InRegion(X1, Y1, W, H, X, Y: real): boolean; +begin + Result := false; + X1 := X1 * Screen.w / 800; + W := W * Screen.w / 800; + Y1 := Y1 * Screen.h / 600; + H := H * Screen.h / 600; + if (X >= X1) and (X <= X1 + W) and (Y >= Y1) and (Y <= Y1 + H) then + Result := true; +end; + +//takes x,y coordinates and returns the interaction number +//of the control at this position +function TMenu.InteractAt(X, Y: real): integer; +var + i, nBut: integer; +begin + Result := -1; + for i := Low(Interactions) to High(Interactions) do + begin + case Interactions[i].Typ of + iButton: if InRegion(Button[Interactions[i].Num].X, Button[Interactions[i].Num].Y, Button[Interactions[i].Num].W, Button[Interactions[i].Num].H, X, Y) and + Button[Interactions[i].Num].Visible then + begin + Result:=i; + exit; + end; + iBCollectionChild: if InRegion(Button[Interactions[i].Num].X, Button[Interactions[i].Num].Y, Button[Interactions[i].Num].W, Button[Interactions[i].Num].H, X, Y) then + begin + Result:=i; + exit; + end; + iSelectS: if InRegion(SelectSs[Interactions[i].Num].X, SelectSs[Interactions[i].Num].Y, SelectSs[Interactions[i].Num].W, SelectSs[Interactions[i].Num].H, X, Y) or + InRegion(SelectSs[Interactions[i].Num].TextureSBG.X, SelectSs[Interactions[i].Num].TextureSBG.Y, SelectSs[Interactions[i].Num].TextureSBG.W, SelectSs[Interactions[i].Num].TextureSBG.H, X, Y) then + begin + Result:=i; + exit; + end; + end; + end; +end; + +//takes x,y coordinates and returns the button collection id +function TMenu.CollectionAt(X, Y: real): integer; +var + i, nBut: integer; +begin + Result := -1; + for i:= Low(ButtonCollection) to High(ButtonCollection) do + begin + if InRegion(ButtonCollection[i].X, ButtonCollection[i].Y, ButtonCollection[i].W, ButtonCollection[i].H, X, Y) and + ButtonCollection[i].Visible then + begin + Result:=i; + exit; + end; + end; +end; + procedure TMenu.SetAnimationProgress(Progress: real); begin // nothing end; end. - diff --git a/unicode/src/menu/UMenuBackgroundFade.pas b/unicode/src/menu/UMenuBackgroundFade.pas index dc37da45..b61a4542 100644 --- a/unicode/src/menu/UMenuBackgroundFade.pas +++ b/unicode/src/menu/UMenuBackgroundFade.pas @@ -62,15 +62,17 @@ const FADEINTIME = 1500; //Time the bg fades in
implementation
-uses sdl,
- gl,
- glext,
- USkins,
- UCommon,
- UGraphic;
+uses
+ sdl,
+ gl,
+ glext,
+ USkins,
+ UCommon,
+ UGraphic;
constructor TMenuBackgroundFade.Create(const ThemedSettings: TThemeBackground);
-var texFilename: string;
+var
+ texFilename: string;
begin
inherited;
FadeTime := 0;
@@ -122,7 +124,7 @@ begin if (UseTexture) then
begin //Draw Texture to Screen
- If (ScreenAct = 1) then //Clear just once when in dual screen mode
+ if (ScreenAct = 1) then //Clear just once when in dual screen mode
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
@@ -151,7 +153,7 @@ begin end
else
begin //Clear Screen w/ progress Alpha + Color
- If (ScreenAct = 1) then //Clear just once when in dual screen mode
+ if (ScreenAct = 1) then //Clear just once when in dual screen mode
glClear(GL_DEPTH_BUFFER_BIT);
glDisable(GL_TEXTURE_2D);
diff --git a/unicode/src/menu/UMenuButton.pas b/unicode/src/menu/UMenuButton.pas index c6ff8ab7..923f0b14 100644 --- a/unicode/src/menu/UMenuButton.pas +++ b/unicode/src/menu/UMenuButton.pas @@ -55,7 +55,6 @@ type PosX, PosY: real; - constructor Create(); overload; public Text: array of TText; @@ -113,6 +112,7 @@ type procedure Draw; virtual; + constructor Create(); overload; constructor Create(Textura: TTexture); overload; constructor Create(Textura, DSTexture: TTexture); overload; destructor Destroy; override; @@ -252,42 +252,6 @@ begin 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 := false; - Colorized := false; - - SelectColR := 1; - SelectColG := 1; - SelectColB := 1; - SelectInt := 1; - SelectTInt := 1; - - DeselectColR := 1; - DeselectColG := 1; - DeselectColB := 1; - DeselectInt := 0.5; - DeselectTInt := 1; - - Fade := false; - FadeTex.TexNum := 0; - FadeProgress := 0; - FadeText := false; - SelectW := DeSelectW; - SelectH := DeSelectH; - - PosX := 0; - PosY := 0; - - Parent := 0; -end; - // ***** Public methods ****** // procedure TButton.Draw; @@ -571,6 +535,42 @@ begin inherited; end; +constructor TButton.Create(); +begin + inherited Create; + // We initialize all to 0, nil or false + Visible := true; + SelectBool := false; + DeselectType := 0; + Selectable := true; + Reflection := false; + Colorized := false; + + SelectColR := 1; + SelectColG := 1; + SelectColB := 1; + SelectInt := 1; + SelectTInt := 1; + + DeselectColR := 1; + DeselectColG := 1; + DeselectColB := 1; + DeselectInt := 0.5; + DeselectTInt := 1; + + Fade := false; + FadeTex.TexNum := 0; + FadeProgress := 0; + FadeText := false; + SelectW := DeSelectW; + SelectH := DeSelectH; + + PosX := 0; + PosY := 0; + + Parent := 0; +end; + constructor TButton.Create(Textura: TTexture); begin Create(); diff --git a/unicode/src/menu/UMenuButtonCollection.pas b/unicode/src/menu/UMenuButtonCollection.pas index c6c6dd81..8b7a1c3f 100644 --- a/unicode/src/menu/UMenuButtonCollection.pas +++ b/unicode/src/menu/UMenuButtonCollection.pas @@ -41,61 +41,61 @@ type //TButtonCollection //No Extra Attributes or Functions ATM //---------------- - AButton = Array of TButton; + AButton = array of TButton; PAButton = ^AButton; TButtonCollection = class(TButton) //num of the First Button, that can be Selected - FirstChild: Byte; - CountChilds: Byte; + FirstChild: byte; + CountChilds: byte; ScreenButton: PAButton; - procedure SetSelect(Value : Boolean); override; + procedure SetSelect(Value : boolean); override; procedure Draw; override; end; implementation -procedure TButtonCollection.SetSelect(Value : Boolean); -var I: Integer; +procedure TButtonCollection.SetSelect(Value : boolean); +var + Index: 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; + if (not Fade) then + for Index := 0 to High(ScreenButton^) do + if (ScreenButton^[Index].Parent = Parent) then + ScreenButton^[Index].Visible := Value; end; procedure TButtonCollection.Draw; -var I, J: Integer; +var + I, J: integer; begin inherited; //If fading is activated, Fade Child Buttons if (Fade) then begin - For I := 0 to High(ScreenButton^) do + 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 + 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 + 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/unicode/src/menu/UMenuEqualizer.pas b/unicode/src/menu/UMenuEqualizer.pas index 6d77721c..8f57e44a 100644 --- a/unicode/src/menu/UMenuEqualizer.pas +++ b/unicode/src/menu/UMenuEqualizer.pas @@ -45,69 +45,71 @@ type Tms_Equalizer = class(TObject) private FFTData: TFFTData; // moved here to avoid stack overflows - BandData: array of Byte; - RefreshTime: Cardinal; + BandData: array of byte; + RefreshTime: cardinal; Source: IAudioPlayback; - Procedure Analyse; + procedure Analyse; public - X: Integer; - Y: Integer; - Z: Real; + X: integer; + Y: integer; + Z: real; - W: Integer; - H: Integer; - Space: Integer; + W: integer; + H: integer; + Space: integer; - Visible: Boolean; - Alpha: real; - Color: TRGB; + Visible: boolean; + Alpha: real; + Color: TRGB; - Direction: Boolean; + Direction: boolean; + BandLength: integer; - BandLength: Integer; - - Reflection: boolean; - Reflectionspacing: Real; + Reflection: boolean; + Reflectionspacing: real; constructor Create(Source: IAudioPlayback; mySkin: TThemeEqualizer); procedure Draw; - - Procedure SetBands(Value: Byte); - Function GetBands: Byte; - Property Bands: Byte read GetBands write SetBands; + procedure SetBands(Value: byte); + function GetBands: byte; + property Bands: byte read GetBands write SetBands; procedure SetSource(newSource: IAudioPlayback); end; implementation -uses math, SDL, gl, glext; - +uses + math, + SDL, + gl, + glext; constructor Tms_Equalizer.Create(Source: IAudioPlayback; mySkin: TThemeEqualizer); -var I: Integer; +var + I: integer; begin - If (Source <> nil) then + if (Source <> nil) then begin - X := mySkin.X; - Y := mySkin.Y; - W := mySkin.W; - H := mySkin.H; - Z := mySkin.Z; + X := mySkin.X; + Y := mySkin.Y; + W := mySkin.W; + H := mySkin.H; + Z := mySkin.Z; - Space := mySkin.Space; + Space := mySkin.Space; - Visible := mySkin.Visible; - Alpha := mySkin.Alpha; - Color.R := mySkin.ColR; - Color.G := mySkin.ColG; - Color.B := mySkin.ColB; + Visible := mySkin.Visible; + Alpha := mySkin.Alpha; + Color.R := mySkin.ColR; + Color.G := mySkin.ColG; + Color.B := mySkin.ColB; - Direction := mySkin.Direction; - Bands := mySkin.Bands; - BandLength := mySkin.Length; + Direction := mySkin.Direction; + Bands := mySkin.Bands; + BandLength := mySkin.Length; Reflection := mySkin.Reflection; Reflectionspacing := mySkin.Reflectionspacing; @@ -116,31 +118,31 @@ begin //Check if Visible - If (Bands <= 0) OR - (BandLength <= 0) OR - (W <= 0) OR - (H <= 0) OR + if (Bands <= 0) or + (BandLength <= 0) or + (W <= 0) or + (H <= 0) or (Alpha <= 0) then - Visible := False; + Visible := false; //ClearArray - For I := low(BandData) to high(BandData) do + for I := low(BandData) to high(BandData) do BandData[I] := 3; end else - Visible := False; + Visible := false; end; //-------- // evaluate FFT-Data //-------- -Procedure Tms_Equalizer.Analyse; - var - I: Integer; - ChansPerBand: byte; // channels per band - MaxChannel: Integer; - Pos: Real; - CurBand: Integer; +procedure Tms_Equalizer.Analyse; +var + I: integer; + ChansPerBand: byte; // channels per band + MaxChannel: integer; + Pos: real; + CurBand: integer; begin Source.GetFFTData(FFTData); @@ -188,25 +190,26 @@ end; // Draw SpectrumAnalyser, Call Analyse //-------- procedure Tms_Equalizer.Draw; - var - CurTime: Cardinal; - PosX, PosY: Real; - I, J: Integer; - Diff: Real; +var + CurTime: cardinal; + PosX, PosY: real; + I, J: integer; + Diff: real; - Function GetAlpha(Diff: Single): Single; + function GetAlpha(Diff: single): single; begin - If Direction then - Result := (Alpha * 0.6) *(0.5 - Diff/(BandLength * (H + Space))) + if Direction then + Result := (Alpha * 0.6) * (0.5 - Diff/(BandLength * (H + Space))) else - Result := (Alpha * 0.6) *(0.5 - Diff/(Bands * (H + Space))); + Result := (Alpha * 0.6) * (0.5 - Diff/(Bands * (H + Space))); end; + begin - If (Visible) AND not (AudioPlayback.Finished) then + if (Visible) and not (AudioPlayback.Finished) then begin //Call Analyse if necessary CurTime := SDL_GetTicks(); - If (CurTime > RefreshTime) then + if (CurTime > RefreshTime) then begin Analyse; @@ -244,12 +247,12 @@ begin glVertex3f(PosX+W, PosY, Z); glEnd; - If (Reflection) AND (J <= BandLength div 2) then + if (Reflection) and (J <= BandLength div 2) then begin Diff := (Y-PosY) + H; //Draw Reflection - If Direction then + if Direction then begin glBegin(GL_QUADS); glColorRGB(Color, GetAlpha(Diff)); @@ -298,22 +301,20 @@ begin end; end; -Procedure Tms_Equalizer.SetBands(Value: Byte); +procedure Tms_Equalizer.SetBands(Value: byte); begin SetLength(BandData, Value); end; -Function Tms_Equalizer.GetBands: Byte; +function Tms_Equalizer.GetBands: byte; begin Result := Length(BandData); end; -Procedure Tms_Equalizer.SetSource(newSource: IAudioPlayback); +procedure Tms_Equalizer.SetSource(newSource: IAudioPlayback); begin - If (newSource <> nil) then + if (newSource <> nil) then Source := newSource; end; - - end.
\ No newline at end of file diff --git a/unicode/src/menu/UMenuInteract.pas b/unicode/src/menu/UMenuInteract.pas index 4c2d4e86..beb6bcef 100644 --- a/unicode/src/menu/UMenuInteract.pas +++ b/unicode/src/menu/UMenuInteract.pas @@ -35,8 +35,8 @@ 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 + 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 diff --git a/unicode/src/menu/UMenuSelectSlide.pas b/unicode/src/menu/UMenuSelectSlide.pas index 1a0fa725..f9f6bbae 100644 --- a/unicode/src/menu/UMenuSelectSlide.pas +++ b/unicode/src/menu/UMenuSelectSlide.pas @@ -34,10 +34,10 @@ interface {$I switches.inc} uses - TextGL, - UTexture, gl, - UMenuText; + TextGL, + UMenuText, + UTexture; type PSelectSlide = ^TSelectSlide; @@ -54,17 +54,23 @@ type 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) + Tex_SelectS_ArrowL: TTexture; // Texture for left arrow + Tex_SelectS_ArrowR: TTexture; // Texture for right arrow SelectOptInt: integer; PData: ^integer; //For automatically Setting LineCount - Lines: Byte; + Lines: byte; + + //Arrows on/off + showArrows: boolean; //default is false + + //whether to show one item or all that fit into the select + oneItemOnly: boolean; //default is false //Visibility - Visible: Boolean; + Visible: boolean; // for selection and deselection // main static @@ -121,7 +127,7 @@ type // procedures procedure SetSelect(Value: boolean); - property Selected: Boolean read SelectBool write SetSelect; + property Selected: boolean read SelectBool write SetSelect; procedure SetSelectOpt(Value: integer); property SelectedOption: integer read SelectOptInt write SetSelectOpt; procedure Draw; @@ -132,7 +138,12 @@ type end; implementation -uses UDrawTexture, math, ULog, SysUtils; + +uses + math, + SysUtils, + UDrawTexture, + ULog; // ------------ Select constructor TSelectSlide.Create; @@ -141,24 +152,17 @@ begin 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;} + Visible := true; end; procedure TSelectSlide.SetSelect(Value: boolean); {var - SO: integer; - I: integer;} + SO: integer; + I: integer;} begin SelectBool := Value; - if Value then begin + if Value then + begin Texture.ColR := ColR; Texture.ColG := ColG; Texture.ColB := ColB; @@ -173,15 +177,9 @@ begin 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 + end + else + begin Texture.ColR := DColR; Texture.ColG := DColG; Texture.ColB := DColB; @@ -196,185 +194,215 @@ begin 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; - HalfL: integer; - HalfR: integer; + SO: integer; + HalfL: integer; + HalfR: integer; -procedure DoSelection(Sel: Cardinal); - var I: Integer; + procedure DoSelection(Sel: cardinal); + var + I: integer; begin - for I := low(TextOpt) to high(TextOpt) do + 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 (integer(Sel) <= high(TextOpt)) then + + if (integer(Sel) <= High(TextOpt)) then begin TextOpt[Sel].ColR := STColR; TextOpt[Sel].ColG := STColG; TextOpt[Sel].ColB := STColB; TextOpt[Sel].Int := STInt; + end; end; - end; + begin SelectOptInt := Value; PData^ := Value; -// SetSelect(true); // reset all colors - if (Length(TextOpt)>0) AND (Length(TextOptT)>0) then + if (Length(TextOpt) > 0) and (Length(TextOptT) > 0) then begin + //First option selected if (Value <= 0) then - begin //First Option Selected + begin Value := 0; - for SO := low (TextOpt) to high(TextOpt) do + Tex_SelectS_ArrowL.alpha := 0; + Tex_SelectS_ArrowR.alpha := 1; + + for SO := Low(TextOpt) to High(TextOpt) do begin - TextOpt[SO].Text := TextOptT[SO]; + 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 + //Last option selected + else if (Value >= High(TextOptT)) then + begin + Value := High(TextOptT); + + Tex_SelectS_ArrowL.alpha := 1; + Tex_SelectS_ArrowR.alpha := 0; + + for SO := High(TextOpt) downto Low(TextOpt) do begin - TextOpt[SO].Text := TextOptT[high(TextOptT)-(Lines-SO-1)]; + TextOpt[SO].Text := TextOptT[High(TextOptT) - (Lines - SO - 1)]; end; - DoSelection(Lines-1); + DoSelection(Lines - 1); end + + //in between first and last 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; + Tex_SelectS_ArrowL.alpha := 1; + Tex_SelectS_ArrowR.alpha := 1; - 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 + HalfL := Ceil((Lines - 1) / 2); + HalfR := Lines - 1 - HalfL; + + //Selected option is near to the left side + if (Value <= HalfL) then begin - TextOpt[SO].Text := TextOptT[high(TextOptT)-(Lines-SO-1)]; - end; + //Change texts + for SO := Low(TextOpt) to High(TextOpt) do + begin + TextOpt[SO].Text := TextOptT[SO]; + end; - DoSelection (HalfL); - end - else - begin - //Change Texts - for SO := low (TextOpt) to high(TextOpt) do + DoSelection(Value); + end + + //Selected option is near to the right side + else if (Value > High(TextOptT) - HalfR) then begin - TextOpt[SO].Text := TextOptT[Value - HalfL + SO]; - end; + 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; + DoSelection (HalfL); + end - 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; + SO: integer; begin if Visible then begin DrawTexture(Texture); DrawTexture(TextureSBG); + if showArrows then + begin + DrawTexture(Tex_SelectS_ArrowL); + DrawTexture(Tex_SelectS_ArrowR); + end; + Text.Draw; - for SO := low(TextOpt) to high(TextOpt) do + for SO := Low(TextOpt) to High(TextOpt) do TextOpt[SO].Draw; end; end; procedure TSelectSlide.GenLines; var -maxlength: Real; -I: Integer; + maxlength: real; + I: integer; begin SetFontStyle(0{Text.Style}); SetFontSize(Text.Size); maxlength := 0; - for I := low(TextOptT) to high (TextOptT) do + for I := Low(TextOptT) to High(TextOptT) do begin if (glTextWidth(TextOptT[I]) > maxlength) then maxlength := glTextWidth(TextOptT[I]); end; - Lines := floor((TextureSBG.W-40) / (maxlength+7)); - if (Lines > Length(TextOptT)) then - Lines := Length(TextOptT); - if (Lines <= 0) then + if (oneItemOnly = false) then + begin + //show all items + Lines := floor((TextureSBG.W-40) / (maxlength+7)); + if (Lines > Length(TextOptT)) then + Lines := Length(TextOptT); + + if (Lines <= 0) then + Lines := 1; + end + else + begin + //show one item only Lines := 1; + end; //Free old Space used by Texts - For I := low(TextOpt) to high(TextOpt) do + 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; + 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; - //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 - Text.Size) / 2; - TextOpt[I].Y := TextureSBG.Y + (TextureSBG.H - Text.Size) / 2; + //Better Look with 2 Options + if (Lines = 2) and (Length(TextOptT) = 2) then + TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W -40 - glTextWidth(TextOptT[1])) * I; - //Better Look with 2 Options - if (Lines=2) AND (Length(TextOptT)= 2) then - TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W -40 - glTextWidth(TextOptT[1])) * I; + if (Lines = 1) then + begin + TextOpt[I].Align := 1; //center text + TextOpt[I].X := TextureSBG.X + (TextureSBG.W / 2); end; + end; end; end. diff --git a/unicode/src/menu/UMenuStatic.pas b/unicode/src/menu/UMenuStatic.pas index 9a10fade..72f4eb36 100644 --- a/unicode/src/menu/UMenuStatic.pas +++ b/unicode/src/menu/UMenuStatic.pas @@ -40,19 +40,20 @@ uses type TStatic = class public - Texture: TTexture; // Button Screen position and size - Visible: boolean; + Texture: TTexture; // Button Screen position and size + Visible: boolean; //Reflection Mod - Reflection: boolean; - Reflectionspacing: Real; + Reflection: boolean; + Reflectionspacing: real; procedure Draw; constructor Create(Textura: TTexture); overload; end; implementation -uses UDrawTexture; +uses + UDrawTexture; procedure TStatic.Draw; begin diff --git a/unicode/src/menu/UMenuText.pas b/unicode/src/menu/UMenuText.pas index 87f9ce54..88cda855 100644 --- a/unicode/src/menu/UMenuText.pas +++ b/unicode/src/menu/UMenuText.pas @@ -34,29 +34,29 @@ interface {$I switches.inc} uses - TextGL, - UTexture, - gl, math, SysUtils, - SDL; + gl, + SDL, + TextGL, + UTexture; type TText = class private - SelectBool: boolean; - TextString: UTF8String; - TextTiles: array of UTF8String; + SelectBool: boolean; + TextString: UTF8String; + TextTiles: array of UTF8String; - STicks: Cardinal; - SelectBlink: boolean; + STicks: cardinal; + SelectBlink: boolean; public X: real; Y: real; Z: 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; //text wider than W is broken + 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; // text wider than W is broken // H: real; Size: real; ColR: real; @@ -64,13 +64,13 @@ type ColB: real; Alpha: real; Int: real; - Style: integer; - Visible: boolean; - Align: integer; // 0 = left, 1 = center, 2 = right + Style: integer; + Visible: boolean; + Align: integer; // 0 = left, 1 = center, 2 = right - //Reflection - Reflection: boolean; - ReflectionSpacing: real; + // reflection + Reflection: boolean; + ReflectionSpacing: real; procedure SetSelect(Value: boolean); property Selected: boolean read SelectBool write SetSelect; @@ -97,35 +97,36 @@ procedure TText.SetSelect(Value: boolean); begin SelectBool := Value; - //Set Cursor Visible - SelectBlink := True; + // set cursor visible + SelectBlink := true; STicks := SDL_GetTicks() div 550; end; procedure TText.SetText(Value: UTF8String); 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 + NextPos: cardinal; // next pos of a space etc. + LastPos: cardinal; // last pos " + 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 GetNextPos: boolean; var - T1, {T2,} T3: Cardinal; + T1, {T2,} T3: cardinal; begin LastPos := NextPos; - //Next Space (If Width is given) + // next space (if width is given) if (W > 0) then T1 := PosEx(' ', Value, LastPos + 1) - else T1 := Length(Value); + else + T1 := Length(Value); - {//Next - + {// next - T2 := PosEx('-', Value, LastPos + 1);} - //Next Break + // next break T3 := PosEx('\n', Value, LastPos + 1); if T1 = 0 then @@ -135,19 +136,19 @@ var if T3 = 0 then T3 := Length(Value); - //Get Nearest Pos + // get nearest pos NextPos := min(T1, T3{min(T2, T3)}); - if (LastPos = Length(Value)) then + if (LastPos = cardinal(Length(Value))) then NextPos := 0; - isBreak := (NextPos = T3) AND (NextPos <> Length(Value)); + isBreak := (NextPos = T3) and (NextPos <> cardinal(Length(Value))); Result := (NextPos <> 0); end; - procedure AddBreak(const From, bTo: Cardinal); + procedure AddBreak(const From, bTo: cardinal); begin - if (isBreak) OR (bTo - From >= 1) then + if (isBreak) or (bTo - From >= 1) then begin Inc(Len); SetLength (TextTiles, Len); @@ -162,14 +163,14 @@ var end; begin - //Set TExtstring + // set TextString TextString := Value; - //Set Cursor Visible - SelectBlink := True; + // set cursor visible + SelectBlink := true; STicks := SDL_GetTicks() div 550; - //Exit if there is no Need to Create Tiles + // exit if there is no need to create tiles if (W <= 0) and (Pos('\n', Value) = 0) then begin SetLength (TextTiles, 1); @@ -177,12 +178,12 @@ begin Exit; end; - //Create Tiles - //Reset Text Array + // create tiles + // reset text array SetLength (TextTiles, 0); Len := 0; - //Reset Counter Vars + // reset counter vars LastPos := 1; NextPos := 1; LastBreak := 1; @@ -190,57 +191,57 @@ begin if (W > 0) then begin - //Set Font Properties + // set font properties SetFontStyle(Style); SetFontSize(Size); end; - //go Through Text + // go through text while (GetNextPos) do begin - //Break in Text + // break in text if isBreak then begin - //Look for Break before the Break + // look for break before the break if (glTextWidth(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 + 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 + // 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 + else // first word after break break within the word begin - //ToDo - //AddBreak(LastBreak, LastBreak + 155); + // to do + // AddBreak(LastBreak, LastBreak + 155); end; end; - isBreak := True; - //Add Break from Text + isBreak := true; + // add break from text AddBreak(LastBreak, NextPos); end - //Text comes out of the Text Area -> CreateBreak + // text comes out of the text area -> createbreak else if (glTextWidth(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 + // 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 + // 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 + else // first word after break -> break within the word begin - //ToDo - //AddBreak(LastBreak, LastBreak + 155); + // to do + // AddBreak(LastBreak, LastBreak + 155); end; end; //end; Inc(FirstWord) end; - //Add Ending + // add ending AddBreak(LastBreak, Length(Value)+1); end; @@ -262,33 +263,34 @@ var X2, Y2: real; Text2: UTF8String; I: integer; + Ticks: cardinal; begin - if Visible then + if Visible and (Size > 0) then begin SetFontStyle(Style); SetFontSize(Size); - SetFontItalic(False); + SetFontItalic(false); glColor4f(ColR*Int, ColG*Int, ColB*Int, Alpha); - //Reflection - if Reflection = true then + // reflection + if Reflection then SetFontReflection(true, ReflectionSpacing) else SetFontReflection(false,0); - //if selected set blink... + // if selected set blink... if SelectBool then begin - I := SDL_GetTicks() div 550; - if I <> STicks then - begin //Change Visability - STicks := I; + Ticks := SDL_GetTicks() div 550; + if Ticks <> STicks then + begin // change visability + STicks := Ticks; SelectBlink := Not SelectBlink; end; end; - {if (False) then //no width set draw as one long string + {if (false) then // no width set draw as one long string begin if not (SelectBool AND SelectBlink) then Text2 := Text @@ -307,20 +309,20 @@ begin end else begin} - //now use allways: - //draw text as many strings + // now use always: + // draw text as many strings Y2 := Y + MoveY; - for I := 0 to high(TextTiles) do + for I := 0 to High(TextTiles) do begin - if (not (SelectBool and SelectBlink)) or (I <> high(TextTiles)) then + 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(Text2)/2; - 2: X2 := X + MoveX - glTextWidth(Text2); + 1: X2 := X + MoveX - glTextWidth(Text2)/2; { centered } + 2: X2 := X + MoveX - glTextWidth(Text2); { right aligned } + else X2 := X + MoveX; { left aligned (default) } end; SetFontPos(X2, Y2); @@ -353,7 +355,14 @@ begin Create(X, Y, 0, 0, 30, 0, 0, 0, 0, Text, false, 0, 0); end; -constructor TText.Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; const ParText: UTF8String; ParReflection: boolean; ParReflectionSpacing: real; ParZ:real); +constructor TText.Create(ParX, ParY, ParW: real; + ParStyle: integer; + ParSize, ParColR, ParColG, ParColB: real; + ParAlign: integer; + const ParText: UTF8String; + ParReflection: boolean; + ParReflectionSpacing: real; + ParZ: real); begin inherited Create; Alpha := 1; @@ -371,8 +380,8 @@ begin Align := ParAlign; SelectBool := false; Visible := true; - Reflection:= ParReflection; - ReflectionSpacing:= ParReflectionSpacing; + Reflection := ParReflection; + ReflectionSpacing := ParReflectionSpacing; end; end. diff --git a/unicode/src/screens/UScreenCredits.pas b/unicode/src/screens/UScreenCredits.pas index 25fa96df..cff83d70 100644 --- a/unicode/src/screens/UScreenCredits.pas +++ b/unicode/src/screens/UScreenCredits.pas @@ -34,30 +34,30 @@ interface {$I switches.inc} uses - SysUtils, - UMenu, - SDL, - SDL_Image, - UDisplay, - UTexture, - gl, - UMusic, - UFiles, - UThemes, - UGraphicClasses; + SysUtils, + UMenu, + SDL, + SDL_Image, + UDisplay, + UTexture, + gl, + UMusic, + UFiles, + UThemes, + UGraphicClasses; type - TCreditsStages=(InitialDelay,Intro,MainPart,Outro); + 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_X: real; + Credits_Time: cardinal; + Credits_Alpha: cardinal; + CTime: cardinal; + CTime_hold: cardinal; + ESC_Alpha: integer; credits_entry: TTexture; credits_entry_dx: TTexture; @@ -89,16 +89,16 @@ type deluxe_slidein: cardinal; - CurrentScrollText: String; - NextScrollUpdate: Real; - EndofLastScrollingPart: Cardinal; - CurrentScrollStart, CurrentScrollEnd: Integer; + CurrentScrollText: string; + NextScrollUpdate: real; + EndofLastScrollingPart: cardinal; + CurrentScrollStart, CurrentScrollEnd: integer; CRDTS_Stage: TCreditsStages; - Fadeout: boolean; + Fadeout: boolean; constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; function Draw: boolean; override; procedure onShow; override; procedure onHide; override; @@ -108,12 +108,12 @@ type const Funky_Text: string = - '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 '+ + 'Grandma Deluxe has arrived! Thanks to Corvus5 for the massive work on UltraStar, Wome for the nice tune you are hearing, '+ + 'all the people who put massive effort and work in new songs (do not 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. Greetings to DennisTheMenace for betatesting, '+ 'Demoscene.tv, pouet.net, KakiArts, Sourceforge,..'; - CRDTS_BG_FILE = 'credits_v5_bg.png'; + CRDTS_BG_FILE = 'credits_v5_bg.png'; CRDTS_OVL_FILE = 'credits_v5_overlay.png'; CRDTS_blindguard_FILE = 'names_blindguard.png'; CRDTS_blindy_FILE = 'names_blindy.png'; @@ -137,7 +137,7 @@ const OUTRO_ESC_FILE = 'outro-esc.png'; OUTRO_EXD_FILE = 'outro-exit-dark.png'; - Timings: array[0..21] of Cardinal=( + Timings: array[0..21] of cardinal=( 20, // 0 Delay before Start 149, // 1 End first Intro Zoom @@ -178,10 +178,10 @@ uses UCommon, UPath; -function TScreenCredits.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenCredits.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down case PressedKey of @@ -191,15 +191,15 @@ begin FadeTo(@ScreenMain); AudioPlayback.PlaySound(SoundLib.Back); end; - { +{ SDLK_SPACE: begin setlength(CTime_hold,length(CTime_hold)+1); CTime_hold[high(CTime_hold)]:=CTime; end; - } - end;//esac - end; //fi +} + end; // esac + end; // fi end; constructor TScreenCredits.Create; @@ -243,22 +243,22 @@ end; function TScreenCredits.Draw: boolean; begin DrawCredits; - Draw:=true; + Draw := true; end; procedure TScreenCredits.onShow; begin inherited; - CRDTS_Stage:=InitialDelay; - Credits_X := 580; + CRDTS_Stage := InitialDelay; + Credits_X := 580; deluxe_slidein := 0; - Credits_Alpha := 0; - //Music.SetLoop(true); loop loops not, shit + Credits_Alpha := 0; +// Music.SetLoop(true); loop loops not, shit AudioPlayback.Open(soundpath + 'wome-credits-tune.mp3'); // thank you wetue - //Music.Play; - CTime:=0; - //setlength(CTime_hold,0); +// Music.Play; + CTime := 0; +// setlength(CTime_hold,0); end; procedure TScreenCredits.onHide; @@ -268,17 +268,17 @@ end; Procedure TScreenCredits.Draw_FunkyText; var - S: Integer; - X,Y,A: Real; + S: integer; + X, Y, A: real; visibleText: string; begin SetFontSize(30); - //Init ScrollingText + // init ScrollingText if (CTime = Timings[7]) then begin - //Set Position of Text - Credits_X := 600; + // set position of text + Credits_X := 600; CurrentScrollStart := 1; CurrentScrollEnd := 1; end; @@ -291,8 +291,8 @@ begin for S := 1 to length(visibleText) 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); + 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 > 32) then A := 17 @@ -301,10 +301,10 @@ begin else A := 0; - 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); + 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); glPrint(visibleText[S]); X := X + glTextWidth(visibleText[S]); end; @@ -323,50 +323,53 @@ begin inc(CurrentScrollEnd); end; end; - { // timing hack - X:=5; - SetFontStyle (2); - SetFontItalic(False); - SetFontSize(27); - glColor4f(1, 1, 1, 1); - for S:=0 to high(CTime_hold) do begin - visibleText:=inttostr(CTime_hold[S]); - SetFontPos (500, X); - glPrint (visibleText[0]); - X:=X+20; - end; - } +{ +// timing hack + X:=5; + SetFontStyle(2); + SetFontItalic(false); + SetFontSize(27); + glColor4f(1, 1, 1, 1); + for S := 0 to high(CTime_hold) do + begin + visibleText := inttostr(CTime_hold[S]); + SetFontPos (500, X); + glPrint(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; + 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); + glMatrixMode(GL_PROJECTION); + glPopMatrix; + glMatrixMode(GL_MODELVIEW); end; procedure TScreenCredits.DrawCredits; var - T: Cardinal; - Data: TFFTData; - j,k,l:cardinal; - f,g: Real; - STime:cardinal; - Delay:cardinal; - myScale: Real; - myAngle: Real; + T: cardinal; + Data: TFFTData; + j, k, l: cardinal; + f, g: real; + STime: cardinal; + Delay: cardinal; + myScale: real; + myAngle: real; const - myLogoCoords: Array[0..27,0..1] of Cardinal = ( - (39,32),(84,32),(100,16),(125,24), + 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), @@ -375,10 +378,10 @@ const (450,32),(485,34),(444,91),(486,93) ); begin - //dis does teh muiwk y0r + // dis does teh muiwk y0r to be translated :-) AudioPlayback.GetFFTData(Data); - Log.LogStatus('',' JB-1'); + Log.LogStatus('', ' JB-1'); T := SDL_GetTicks() div 33; if T <> Credits_Time then @@ -388,165 +391,172 @@ begin inc(CTime_hold); Credits_X := Credits_X-2; - Log.LogStatus('',' JB-2'); - if (CRDTS_Stage=InitialDelay) and (CTime=Timings[0]) then + Log.LogStatus('', ' JB-2'); + if (CRDTS_Stage=InitialDelay) and (CTime = Timings[0]) then begin - //CTime:=Timings[20]; - //CRDTS_Stage:=Outro; - CRDTS_Stage:=Intro; - CTime:=0; +// CTime := Timings[20]; +// CRDTS_Stage := Outro; + CRDTS_Stage := Intro; + CTime := 0; AudioPlayback.Play; end; - if (CRDTS_Stage=Intro) and (CTime=Timings[7]) then + if (CRDTS_Stage = Intro) and (CTime = Timings[7]) then begin - CRDTS_Stage:=MainPart; + CRDTS_Stage := MainPart; end; - if (CRDTS_Stage=MainPart) and (CTime=Timings[20]) then + if (CRDTS_Stage = MainPart) and (CTime = Timings[20]) then begin - CRDTS_Stage:=Outro; + CRDTS_Stage := Outro; end; end; - Log.LogStatus('',' JB-3'); + Log.LogStatus('', ' JB-3'); - //draw background - if CRDTS_Stage=InitialDelay then - begin - glClearColor(0,0,0,0); - glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); - 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 CRDTS_Stage = Intro then + begin + Start3D; + glPushMatrix; - 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); + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); - 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); + glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); - glPopMatrix; - End3D; + 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); - // 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; + 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; + // 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; + end; if (CRDTS_Stage=MainPart) then // main credits screen background, scroller, logo and girl begin @@ -558,10 +568,10 @@ begin 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); + 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); @@ -572,38 +582,50 @@ begin //######################################################################### // draw credits names - - Log.LogStatus('',' JB-4'); + Log.LogStatus('', ' JB-4'); // BlindGuard (rotate in from upper left, rotate out to lower right) - STime:=Timings[9]-10; - Delay:=Timings[10]-Timings[9]; + STime := Timings[9] - 10; + Delay := Timings[10] - Timings[9]; if CTime > STime then begin - k:=0; - ESC_Alpha:=20; + k := 0; + ESC_Alpha := 20; try - for j:=0 to 40 do + for j := 0 to 40 do begin - if ( j < length( Data ) ) AND - ( k < length( Data ) ) then + if (j < length(Data)) and + (k < length(Data)) then begin if Data[j] >= Data[k] then - k:=j; + k := j; end; end; except end; - 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; - 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 + 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; + 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); @@ -616,23 +638,26 @@ begin 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((integer(CTime)-(integer(STime+Delay)-10))*-9,0,0,1); - gltranslatef(-223,0,0); - end; + gltranslatef(0, 329, 0); + if CTime <= STime + 10 then + glrotatef((CTime - STime) * 9 + 270, 0, 0, 1); + gltranslatef(223, 0, 0); + if CTime >= STime + Delay - 10 then + if CTime <= STime + Delay then + begin + gltranslatef(223, 0, 0); + glrotatef((integer(CTime) - (integer(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); + 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); @@ -640,35 +665,47 @@ begin end; // Blindy (zoom from 0 to full size and rotation, zoom zo doubble size and shift to upper right) - STime:=Timings[10]-10; - Delay:=Timings[11]-Timings[10]+5; + STime := Timings[10] - 10; + Delay := Timings[11] - Timings[10] + 5; if CTime > STime then begin - k:=0; - ESC_Alpha:=20; + k := 0; + ESC_Alpha := 20; try - for j:=0 to 40 do + for j := 0 to 40 do begin - if ( j < length( Data ) ) AND - ( k < length( Data ) ) then + if (j < length(Data)) and + (k < length(Data)) then begin if Data[j] >= Data[k] then - k:=j; + k := j; end; end; except end; - - 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; - 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 + 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; + 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); @@ -681,28 +718,31 @@ begin 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); + 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); + 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); @@ -710,35 +750,47 @@ begin end; // Canni (shift in from left, shift out to upper right) - STime:=Timings[11]-10; - Delay:=Timings[12]-Timings[11]+5; + STime := Timings[11] - 10; + Delay := Timings[12] - Timings[11] + 5; if CTime > STime then begin - k:=0; - ESC_Alpha:=20; + k := 0; + ESC_Alpha := 20; try - for j:=0 to 40 do + for j := 0 to 40 do begin - if ( j < length( Data ) ) AND - ( k < length( Data ) ) then + if (j < length(Data)) and + (k < length(Data)) then begin if Data[j] >= Data[k] then - k:=j; + k := j; end; end; except end; - - 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; - 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 + 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; + 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); @@ -751,23 +803,26 @@ begin 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); + 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); + 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); @@ -775,35 +830,47 @@ begin end; // Commandio (flip in from down, flip out to upper right) - STime:=Timings[12]-10; - Delay:=Timings[13]-Timings[12]; + STime := Timings[12] - 10; + Delay := Timings[13] - Timings[12]; if CTime > STime then begin - k:=0; - ESC_Alpha:=20; + k := 0; + ESC_Alpha := 20; try - for j:=0 to 40 do + for j := 0 to 40 do begin - if ( j < length( Data ) ) AND - ( k < length( Data ) ) then + if (j < length(Data)) and + (k < length(Data)) then begin if Data[j] >= Data[k] then - k:=j; + k := j; end; end; except end; - - 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; - 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 + 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; + 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); @@ -816,25 +883,27 @@ begin end; glPushMatrix; - gltranslatef(223,329,0); - if CTime <= STime+10 then - f:=258.0-25.8*(CTime-STime) + gltranslatef(223, 329, 0); + if CTime <= STime + 10 then + f := 258.0 - 25.8 * (CTime - STime) else - f:=0; - g:=0; - if CTime >=STime+Delay-10 then if CTime <=STime+Delay then begin - j:=CTime-(STime+Delay-10); - g:=32.6*j; - end; + f := 0; + g := 0; + if CTime >= STime + Delay - 10 then + if CTime <= STime + Delay then + begin + j := CTime - (STime + Delay - 10); + g := 32.6 * j; + end; 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); + 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); @@ -842,46 +911,57 @@ begin 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; + STime := Timings[13] - 35; + Delay := Timings[14] - Timings[13] + 5; if CTime > STime then begin - k:=0; + k := 0; try - for j:=0 to 40 do + for j := 0 to 40 do begin - if ( j < length( Data ) ) AND - ( k < length( Data ) ) then + if (j < length(Data)) and + (k < length(Data)) then begin if Data[j] >= Data[k] then - k:=j; + k := j; end; end; except end; - - 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); + 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); + 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); + 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); @@ -889,36 +969,47 @@ begin end; // Mog (flip in from right, flip out to lower right) - STime:=Timings[14]-10; - Delay:=Timings[15]-Timings[14]+5; + STime := Timings[14] - 10; + Delay := Timings[15] - Timings[14] + 5; if CTime > STime then begin - k:=0; - ESC_Alpha:=20; - + k := 0; + ESC_Alpha := 20; try - for j:=0 to 40 do + for j := 0 to 40 do begin - if ( j < length( Data ) ) AND - ( k < length( Data ) ) then + if (j < length(Data)) and + (k < length(Data)) then begin if Data[j] >= Data[k] then - k:=j; + k := j; end; end; except end; - - 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; - 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 + 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; + 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); @@ -931,26 +1022,28 @@ begin end; glPushMatrix; - gltranslatef(223,329,0); - if CTime <= STime+10 then - f:=326.0-32.6*(CTime-STime) + gltranslatef(223, 329, 0); + if CTime <= STime + 10 then + f := 326.0 - 32.6 * (CTime - STime) else - f:=0; - - g:=0; - if CTime >=STime+Delay-10 then if CTime <=STime+Delay then begin - j:=CTime-(STime+Delay-10); - g:=32.6*j; - end; + f := 0; + + g := 0; + if CTime >= STime + Delay - 10 then + if CTime <= STime + Delay then + begin + j := CTime - (STime + Delay - 10); + g := 32.6 * j; + end; 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); + 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); @@ -958,35 +1051,47 @@ begin end; // Mota (rotate in from upper right, shift out to lower left while shrinking and rotateing) - STime:=Timings[15]-10; - Delay:=Timings[16]-Timings[15]+5; + STime := Timings[15] - 10; + Delay := Timings[16] - Timings[15] + 5; if CTime > STime then begin - k:=0; - ESC_Alpha:=20; + k := 0; + ESC_Alpha := 20; try - for j:=0 to 40 do + for j := 0 to 40 do begin - if ( j < length( Data ) ) AND - ( k < length( Data ) ) then + if (j < length(Data)) and + (k < length(Data)) then begin if Data[j] >= Data[k] then - k:=j; + k := j; end; end; except end; - - 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; - 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 + 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; + 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); @@ -999,28 +1104,31 @@ begin 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); + 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); + 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); @@ -1028,35 +1136,47 @@ begin end; // Skillmaster (shift in from lower right, rotate out to upper right) - STime:=Timings[16]-10; - Delay:=Timings[17]-Timings[16]+5; + STime := Timings[16] - 10; + Delay := Timings[17] - Timings[16] + 5; if CTime > STime then begin - k:=0; - ESC_Alpha:=20; + k := 0; + ESC_Alpha := 20; try - for j:=0 to 40 do + for j := 0 to 40 do begin - if ( j < length( Data ) ) AND - ( k < length( Data ) ) then + if (j < length(Data)) and + (k < length(Data)) then begin if Data[j] >= Data[k] then - k:=j; + k := j; end; end; except end; - - 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; - 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 + 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; + 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); @@ -1069,28 +1189,31 @@ begin 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); - gltranslatef(0,-223,0); - glrotatef(integer(j)*-9,0,0,1); - gltranslatef(0,223,0); - glrotatef(j*9,0,0,1); + 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); + gltranslatef(0, -223, 0); + glrotatef(integer(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); + 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); @@ -1098,35 +1221,47 @@ begin end; // WhiteShark (flip in from lower left, flip out to upper right) - STime:=Timings[17]-10; - Delay:=Timings[18]-Timings[17]; + STime := Timings[17] - 10; + Delay := Timings[18] - Timings[17]; if CTime > STime then begin - k:=0; - ESC_Alpha:=20; + k := 0; + ESC_Alpha := 20; try - for j:=0 to 40 do + for j := 0 to 40 do begin - if ( j < length( Data ) ) AND - ( k < length( Data ) ) then + if (j < length(Data)) and + (k < length(Data)) then begin if Data[j] >= Data[k] then - k:=j; + k := j; end; end; except end; - - 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; - 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 + 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; + 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); @@ -1139,20 +1274,20 @@ begin end; glPushMatrix; - gltranslatef(223,329,0); - if CTime <= STime+10 then - f:=326.0-32.6*(CTime-STime) + gltranslatef(223, 329, 0); + if CTime <= STime + 10 then + f := 326.0 - 32.6 * (CTime - STime) else - f:=0; + f := 0; - if (CTime >= STime+Delay-10) and (CTime <= STime+Delay) then + if (CTime >= STime + Delay - 10) and (CTime <= STime + Delay) then begin - j:=CTime-(STime+Delay-10); - g:=32.6*j; + j := CTime - (STime + Delay - 10); + g := 32.6 * j; end else begin - g:=0; + g := 0; end; glBindTexture(GL_TEXTURE_2D, credits_whiteshark.TexNum); @@ -1160,51 +1295,50 @@ begin 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); + 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; - - Log.LogStatus('',' JB-103'); + Log.LogStatus('', ' JB-103'); // #################################################################### // do some twinkle stuff (kinda on beat) - if (CTime > Timings[8] ) and - (CTime < Timings[19] ) then + if (CTime > Timings[8] ) and + (CTime < Timings[19]) then begin k := 0; try - for j:=0 to 40 do + for j := 0 to 40 do begin - if ( j < length( Data ) ) AND - ( k < length( Data ) ) then + if (j < length(Data)) and + (k < length(Data)) then begin if Data[j] >= Data[k] then - k:=j; + k := j; end; end; except end; - if Data[k]>0.2 then + if Data[k] > 0.2 then begin - l := RandomRange(6,16); - j := RandomRange(0,27); + 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 + // draw the rest of the main screen (girl and logo) glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1212,21 +1346,21 @@ begin 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); + 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); + 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); @@ -1234,33 +1368,35 @@ begin // fade out at end of main part if Ctime > Timings[19] then begin - glColor4f(0,0,0,(Ctime-Timings[19])/(Timings[20]-Timings[19])); + 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); + glVertex2f( 0, 0); + glVertex2f( 0, 600); + glVertex2f(800, 600); + glVertex2f(800, 0); glEnd; glDisable(GL_BLEND); end; end else - if (CRDTS_Stage=Outro) then + if (CRDTS_Stage = Outro) then begin - if CTime=Timings[20] then begin - CTime_hold:=0; + if CTime = Timings[20] then + begin + CTime_hold := 0; AudioPlayback.Stop; AudioPlayback.Open(soundpath + 'credits-outro-tune.mp3'); AudioPlayback.SetVolume(0.2); - AudioPlayback.SetLoop(True); + AudioPlayback.SetLoop(true); AudioPlayback.Play; end; - if CTime_hold > 231 then begin + if CTime_hold > 231 then + begin AudioPlayback.Play; - Ctime_hold:=0; + Ctime_hold := 0; end; - glClearColor(0,0,0,0); + glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); // do something useful @@ -1272,34 +1408,36 @@ begin 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); + 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); + // 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); + 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); + 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); + 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); @@ -1308,17 +1446,17 @@ begin // ... end; - { +{ // draw credits runtime counter - SetFontStyle (2); - SetFontItalic(False); + SetFontStyle (2); + SetFontItalic(false); SetFontSize(27); 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); +// RuntimeStr := 'CTime: ' + inttostr(floor(CTime / 30.320663991914489602156136106092)) + '.' + inttostr(floor(CTime / 3.0320663991914489602156136106092) - floor(CTime / 30.320663991914489602156136106092) * 10); + RuntimeStr := 'CTime: ' + inttostr(CTime); glPrint (RuntimeStr[1]); - } +} // make the stars shine GoldenRec.Draw; diff --git a/unicode/src/screens/UScreenEditConvert.pas b/unicode/src/screens/UScreenEditConvert.pas index 835590ed..109a828b 100644 --- a/unicode/src/screens/UScreenEditConvert.pas +++ b/unicode/src/screens/UScreenEditConvert.pas @@ -34,6 +34,7 @@ interface {$I switches.inc} uses + math, UMenu, SDL, {$IFDEF UseMIDIPort} @@ -137,7 +138,7 @@ uses function TScreenEditConvert.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of @@ -180,15 +181,15 @@ begin end; if Interaction = 2 then - begin + begin Selected := true; {$IFDEF UseMIDIPort} MidiFile.OnMidiEvent := nil; {$ENDIF} {for T := 0 to High(ATrack) do - begin + begin if ATrack[T].Hear then - begin + begin MidiTrack := MidiFile.GetTrack(T); MidiTrack.OnMidiEvent := MidiFile1MidiEvent; end; @@ -197,9 +198,9 @@ begin end; if Interaction = 3 then - begin + begin if SelectedNumber > 0 then - begin + begin Extract; SaveSong(Song, Lines, ChangeFileExt(ConversionFileName, '.txt'), false); end; @@ -210,16 +211,16 @@ begin SDLK_SPACE: begin // ATrack[Sel].Hear := not ATrack[Sel].Hear; - if Notes in ATrack[Sel].Status then - begin - ATrack[Sel].Status := ATrack[Sel].Status - [Notes]; - if Lyrics in ATrack[Sel].Status then - ATrack[Sel].Status := ATrack[Sel].Status - [Lyrics] - else - ATrack[Sel].Status := ATrack[Sel].Status + [Lyrics]; - end - else - ATrack[Sel].Status := ATrack[Sel].Status + [Notes]; + if Notes in ATrack[Sel].Status then + begin + ATrack[Sel].Status := ATrack[Sel].Status - [Notes]; + if Lyrics in ATrack[Sel].Status then + ATrack[Sel].Status := ATrack[Sel].Status - [Lyrics] + else + ATrack[Sel].Status := ATrack[Sel].Status + [Lyrics]; + end + else + ATrack[Sel].Status := ATrack[Sel].Status + [Notes]; { if Selected then begin @@ -245,13 +246,13 @@ begin begin Inc(Sel); if Sel > High(ATrack) then - Sel := 0; + Sel := 0; end; SDLK_UP: begin Dec(Sel); if Sel < 0 then - Sel := High(ATrack); + Sel := High(ATrack); end; end; end; @@ -313,7 +314,7 @@ 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 + begin Nu := Length(Note); SetLength(Note, Nu + 1); Note[Nu].Start := Round(ATrack[T].Note[N].Start / Ticks); @@ -335,7 +336,7 @@ begin for N := 0 to High(ATrack[T].Note) do begin if (ATrack[T].Note[N].EventType = 15) then - begin + begin // Log.LogStatus('<' + Track[T].Note[N].Str + '>', 'MIDI'); AddLyric(Round(ATrack[T].Note[N].Start / Ticks), ATrack[T].Note[N].Str); end; @@ -453,7 +454,6 @@ begin AddButton(500, 20, 100, 40, Skin.GetTextureFileName('ButtonF')); AddButtonText(20, 5, 0, 0, 0, 'Save'); - { MidiOut := TMidiOutput.Create(nil); // MidiOut.Close; // MidiOut.DeviceID := 0; @@ -493,13 +493,11 @@ begin Log.LogStatus(MidiOut.ProductName, 'MIDI'); MidiOut.Open; - if FileExists(ConversionFileName) then begin MidiFile.Filename := ConversionFileName; MidiFile.ReadFile; - Len := 0; Sel := 0; BPM := MidiFile.Bpm; @@ -579,7 +577,7 @@ var Bottom: real; X: real; Y: real; - H: real; + Height: real; YSkip: real; begin // draw static menu @@ -587,20 +585,24 @@ begin Y := 100; - H := Length(ATrack)*40; - if H > 480 then - H := 480; - Bottom := Y + H; + Height := min(480, 40 * Length(ATrack)); + Bottom := Y + Height; - YSkip := H / Length(ATrack); + if Length(ATrack) = 0 then // prevent crash with uncomplete code. + begin + Log.LogDebug ('UScreenEditConvert -> TScreenEditConvert.Draw:', 'Length(ATrack) = 0'); + YSkip := 40; + end + else + YSkip := Height / Length(ATrack); // select - DrawQuad(10, Y+Sel*YSkip, 780, YSkip, 0.8, 0.8, 0.8); + DrawQuad(10, Y + Sel*YSkip, 780, YSkip, 0.8, 0.8, 0.8); // selected - now me use Status System for Count := 0 to High(ATrack) do if ATrack[Count].Hear then - DrawQuad(10, Y+Count*YSkip, 50, YSkip, 0.8, 0.3, 0.3); + DrawQuad(10, Y + Count*YSkip, 50, YSkip, 0.8, 0.3, 0.3); glColor3f(0, 0, 0); for Count := 0 to High(ATrack) do begin @@ -618,12 +620,12 @@ begin end; end; - DrawLine(10, Y, 10, Bottom, 0, 0, 0); - DrawLine(60, Y, 60, Bottom, 0, 0, 0); + 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 Count := 0 to Length(ATrack) do - DrawLine(10, Y+Count*YSkip, 790, Y+Count*YSkip, 0, 0, 0); + DrawLine(10, Y + Count*YSkip, 790, Y + Count*YSkip, 0, 0, 0); for Count := 0 to High(ATrack) do begin @@ -636,9 +638,21 @@ begin for Count2 := 0 to High(ATrack[Count].Note) do begin if ATrack[Count].Note[Count2].EventType = 9 then - DrawQuad(60 + ATrack[Count].Note[Count2].Start/Len * 725, Y + (Count+1)*YSkip - ATrack[Count].Note[Count2].Data1*35/127, 3, 3, ColR[Count], ColG[Count], ColB[Count]); + DrawQuad(60 + ATrack[Count].Note[Count2].Start/Len*725, + Y + (Count+1)*YSkip - ATrack[Count].Note[Count2].Data1*35/127, + 3, + 3, + ColR[Count], + ColG[Count], + ColB[Count]); if ATrack[Count].Note[Count2].EventType = 15 then - DrawLine(60 + ATrack[Count].Note[Count2].Start/Len * 725, Y + 0.75 * YSkip + Count*YSkip, 60 + ATrack[Count].Note[Count2].Start/Len * 725, Y + YSkip + Count*YSkip, ColR[Count], ColG[Count], ColB[Count]); + DrawLine(60 + ATrack[Count].Note[Count2].Start/Len*725, + Y + 0.75*YSkip + Count*YSkip, + 60 + ATrack[Count].Note[Count2].Start/Len*725, + Y + YSkip + Count*YSkip, + ColR[Count], + ColG[Count], + ColB[Count]); end; // playing line diff --git a/unicode/src/screens/UScreenEditHeader.pas b/unicode/src/screens/UScreenEditHeader.pas index 2548069d..fed226ba 100644 --- a/unicode/src/screens/UScreenEditHeader.pas +++ b/unicode/src/screens/UScreenEditHeader.pas @@ -116,7 +116,7 @@ begin SDLK_RETURN: begin if Interaction = 1 then - begin + begin // Save; end; end; @@ -159,7 +159,7 @@ begin begin T := Interaction - 2 + TextTitle; if (Interaction >= 2) and (Interaction <= 13) and (Length(Text[T].Text) >= 1) then - begin + begin Text[T].DeleteLastLetter; SetRoundButtons; end; @@ -170,7 +170,7 @@ begin 32..255: begin if (Interaction >= 2) and (Interaction <= 13) then - begin + begin Text[Interaction - 2 + TextTitle].Text := Text[Interaction - 2 + TextTitle].Text + UCS4ToUTF8String(CharCode); SetRoundButtons; diff --git a/unicode/src/screens/UScreenEditSub.pas b/unicode/src/screens/UScreenEditSub.pas index a892651a..23ab427b 100644 --- a/unicode/src/screens/UScreenEditSub.pas +++ b/unicode/src/screens/UScreenEditSub.pas @@ -133,11 +133,11 @@ uses ULanguage, UUnicodeUtils; -// Method for input parsing. If False is returned, GetNextWindow +// Method for input parsing. If false is returned, GetNextWindow // should be checked to know the next window to load; function TScreenEditSub.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; var - SDL_ModState: Word; + SDL_ModState: word; R: real; begin Result := true; @@ -206,7 +206,7 @@ begin begin // Paste text if SDL_ModState = KMOD_LCTRL then - begin + begin if Lines[0].Line[Lines[0].Current].HighNote >= Lines[0].Line[CopySrc].HighNote then PasteText else @@ -214,7 +214,7 @@ begin end; if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then - begin + begin CopySentence(CopySrc, Lines[0].Current); end; end; @@ -334,7 +334,7 @@ begin SDLK_4: begin if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then - begin + begin CopySentence(CopySrc, Lines[0].Current); CopySentence(CopySrc+1, Lines[0].Current+1); CopySentence(CopySrc+2, Lines[0].Current+2); @@ -342,14 +342,14 @@ begin end; if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then - begin + begin CopySentences(CopySrc, Lines[0].Current, 4); end; end; SDLK_5: begin if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then - begin + begin CopySentence(CopySrc, Lines[0].Current); CopySentence(CopySrc+1, Lines[0].Current+1); CopySentence(CopySrc+2, Lines[0].Current+2); @@ -358,7 +358,7 @@ begin end; if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then - begin + begin CopySentences(CopySrc, Lines[0].Current, 5); end; end; @@ -401,21 +401,21 @@ begin SDLK_SLASH: begin if SDL_ModState = 0 then - begin + begin // Insert start of sentece if CurrentNote > 0 then DivideSentence; end; if SDL_ModState = KMOD_LSHIFT then - begin + begin // Join next sentence with current if Lines[0].Current < Lines[0].High then JoinSentence; end; if SDL_ModState = KMOD_LCTRL then - begin + begin // divide note DivideNote; end; @@ -450,7 +450,7 @@ begin SDLK_DELETE: begin if SDL_ModState = KMOD_LCTRL then - begin + begin // moves text to right in current sentence DeleteNote; end; @@ -466,24 +466,24 @@ begin begin // right if SDL_ModState = 0 then - begin + begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Inc(CurrentNote); if CurrentNote > Lines[0].Line[Lines[0].Current].HighNote then - CurrentNote := 0; + CurrentNote := 0; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.Selected := CurrentNote; end; // ctrl + right if SDL_ModState = KMOD_LCTRL then - begin + begin if Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length > 1 then - begin + begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); if CurrentNote = 0 then - begin + begin Inc(Lines[0].Line[Lines[0].Current].Start); end; end; @@ -491,10 +491,10 @@ begin // shift + right if SDL_ModState = KMOD_LSHIFT then - begin + begin Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); if CurrentNote = 0 then - begin + begin Inc(Lines[0].Line[Lines[0].Current].Start); end; if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then @@ -503,7 +503,7 @@ begin // alt + right if SDL_ModState = KMOD_LALT then - begin + begin Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then Inc(Lines[0].Line[Lines[0].Current].End_); @@ -511,7 +511,7 @@ begin // alt + ctrl + shift + right = move all from cursor to right if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then - begin + begin MoveAllToEnd(1); end; @@ -521,34 +521,34 @@ begin begin // left if SDL_ModState = 0 then - begin + begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Dec(CurrentNote); if CurrentNote = -1 then - CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; + CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.Selected := CurrentNote; end; // ctrl + left if SDL_ModState = KMOD_LCTRL then - begin + begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); if CurrentNote = 0 then - begin + begin Dec(Lines[0].Line[Lines[0].Current].Start); end; end; // shift + left if SDL_ModState = KMOD_LSHIFT then - begin + begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); // resizing sentences if CurrentNote = 0 then - begin + begin Dec(Lines[0].Line[Lines[0].Current].Start); end; @@ -559,9 +559,9 @@ begin // alt + left if SDL_ModState = KMOD_LALT then - begin + begin if Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length > 1 then - begin + begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then Dec(Lines[0].Line[Lines[0].Current].End_); @@ -570,7 +570,7 @@ begin // alt + ctrl + shift + right = move all from cursor to left if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then - begin + begin MoveAllToEnd(-1); end; @@ -581,7 +581,7 @@ begin // skip to next sentence if SDL_ModState = 0 then - begin {$IFDEF UseMIDIPort} + begin {$IFDEF UseMIDIPort} MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); PlaySentenceMidi := false; {$endif} @@ -590,7 +590,7 @@ begin Inc(Lines[0].Current); CurrentNote := 0; if Lines[0].Current > Lines[0].High then - Lines[0].Current := 0; + Lines[0].Current := 0; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.AddLine(Lines[0].Current); @@ -601,7 +601,7 @@ begin // decrease tone if SDL_ModState = KMOD_LCTRL then - begin + begin TransposeNote(-1); end; @@ -612,7 +612,7 @@ begin // skip to previous sentence if SDL_ModState = 0 then - begin + begin {$IFDEF UseMIDIPort} MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); PlaySentenceMidi := false; @@ -622,7 +622,7 @@ begin Dec(Lines[0].Current); CurrentNote := 0; if Lines[0].Current = -1 then - Lines[0].Current := Lines[0].High; + Lines[0].Current := Lines[0].High; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.AddLine(Lines[0].Current); @@ -633,7 +633,7 @@ begin // increase tone if SDL_ModState = KMOD_LCTRL then - begin + begin TransposeNote(1); end; end; @@ -645,7 +645,7 @@ end; function TScreenEditSub.ParseInputEditText(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; var - SDL_ModState: Word; + SDL_ModState: word; begin // used when in Text Edit Mode Result := true; @@ -682,11 +682,11 @@ begin begin // right if SDL_ModState = 0 then - begin + begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Inc(CurrentNote); if CurrentNote > Lines[0].Line[Lines[0].Current].HighNote then - CurrentNote := 0; + CurrentNote := 0; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.Selected := CurrentNote; end; @@ -695,11 +695,11 @@ begin begin // left if SDL_ModState = 0 then - begin + begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Dec(CurrentNote); if CurrentNote = -1 then - CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; + CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.Selected := CurrentNote; end; @@ -880,7 +880,7 @@ begin Lines[0].Line[CNew].Start := Lines[0].Line[CStart].Note[NStart].Start; Lines[0].Line[CNew].Lyric := ''; Lines[0].Line[CNew].End_ := 0; - Lines[0].Line[CNew].BaseNote := 0;//High(Integer); // TODO: High (Integer) will causes a memory exception later in this procedure. Weird! + Lines[0].Line[CNew].BaseNote := 0;//High(integer); // TODO: High (integer) will causes a memory exception later in this procedure. Weird! Lines[0].Line[CNew].HighNote := -1; SetLength(Lines[0].Line[CNew].Note, 0); @@ -910,9 +910,9 @@ begin //recalculate BaseNote of the divided Sentence with Lines[0].Line[CStart] do begin - BaseNote := High(Integer); + BaseNote := High(integer); - For N := 0 to HighNote do + for N := 0 to HighNote do if Note[N].Tone < BaseNote then BaseNote := Note[N].Tone; end; @@ -994,7 +994,7 @@ begin C := Lines[0].Current; //Do Not delete Last Note - if (Lines[0].High > 0) OR (Lines[0].Line[C].HighNote > 0) then + if (Lines[0].High > 0) or (Lines[0].Line[C].HighNote > 0) then begin // we copy all notes from the next to the selected one @@ -1184,7 +1184,6 @@ begin CopySentence(Src + C, Dst + C); end; - constructor TScreenEditSub.Create; begin inherited Create; @@ -1253,7 +1252,7 @@ begin else Error := not CurrentSong.LoadSong(); except - Error := True; + Error := true; end; if Error then @@ -1285,7 +1284,7 @@ begin Lyric.Clear; Lyric.X := 400; Lyric.Y := 500; - Lyric.Align := center; + Lyric.Align := atCenter; Lyric.Size := 42; Lyric.ColR := 0; Lyric.ColG := 0; @@ -1318,7 +1317,6 @@ begin {$IFDEF UseMIDIPort} MidiPos := USTime.GetTime - MidiTime + MidiStart; - // stop the music if (MidiPos > MidiStop) then begin @@ -1337,7 +1335,6 @@ begin if (Lines[0].Line[Lines[0].Current].Note[Pet].Start = AktBeat) then begin - LastClick := AktBeat; {$IFDEF UseMIDIPort} if Pet > 0 then @@ -1429,7 +1426,8 @@ begin end; function TScreenEditSub.GetNoteName(Note: integer): string; -var N1, N2: integer; +var + N1, N2: integer; begin if (Note > 0) then begin diff --git a/unicode/src/screens/UScreenLevel.pas b/unicode/src/screens/UScreenLevel.pas index 188b32f2..caf63a33 100644 --- a/unicode/src/screens/UScreenLevel.pas +++ b/unicode/src/screens/UScreenLevel.pas @@ -34,30 +34,37 @@ interface {$I switches.inc} uses - UMenu, SDL, UDisplay, UMusic, UFiles, SysUtils, UThemes; + UMenu, + SDL, + UDisplay, + UMusic, + UFiles, + SysUtils, + UThemes; type TScreenLevel = class(TMenu) public constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; procedure SetAnimationProgress(Progress: real); override; end; implementation -uses UGraphic, - UMain, - UIni, - USong, - UTexture, - UUnicodeUtils; - -function TScreenLevel.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +uses + UGraphic, + UMain, + UIni, + USong, + UTexture, + UUnicodeUtils; + +function TScreenLevel.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of diff --git a/unicode/src/screens/UScreenLoading.pas b/unicode/src/screens/UScreenLoading.pas index e52823be..429a3261 100644 --- a/unicode/src/screens/UScreenLoading.pas +++ b/unicode/src/screens/UScreenLoading.pas @@ -46,15 +46,16 @@ type Fadeout: boolean; constructor Create; override; procedure onShow; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; end; implementation -uses UGraphic, - UTime; +uses + UGraphic, + UTime; -function TScreenLoading.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenLoading.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; end; diff --git a/unicode/src/screens/UScreenMain.pas b/unicode/src/screens/UScreenMain.pas index eb2e051e..8ce6307c 100644 --- a/unicode/src/screens/UScreenMain.pas +++ b/unicode/src/screens/UScreenMain.pas @@ -52,10 +52,7 @@ type function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; - procedure InteractNext; override; - procedure InteractPrev; override; - procedure InteractInc; override; - procedure InteractDec; override; + procedure SetInteraction(Num: integer); override; procedure SetAnimationProgress(Progress: real); override; end; @@ -80,7 +77,7 @@ function TScreenMain.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; var SDL_ModState: word; begin - Result := True; + Result := true; SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT); @@ -90,7 +87,7 @@ begin // check normal keys case UCS4UpperCase(CharCode) of Ord('Q'): begin - Result := False; + Result := false; Exit; end; Ord('C'): begin @@ -124,7 +121,7 @@ begin SDLK_ESCAPE, SDLK_BACKSPACE: begin - Result := False; + Result := false; end; SDLK_RETURN: @@ -139,7 +136,7 @@ begin if (Ini.Players = 4) then PlayersPlay := 6; - ScreenName.Goto_SingScreen := False; + ScreenName.Goto_SingScreen := false; FadeTo(@ScreenName, SoundLib.Start); end else //show error message @@ -183,7 +180,7 @@ begin //Exit if Interaction = 5 then begin - Result := False; + Result := false; end; end; {** @@ -234,36 +231,19 @@ end; procedure TScreenMain.onShow; begin inherited; + + { display cursor (on moved) } + Display.SetCursor; + {** * Start background music *} SoundLib.StartBgMusic; end; -procedure TScreenMain.InteractNext; -begin - inherited InteractNext; - Text[TextDescription].Text := Theme.Main.Description[Interaction]; - Text[TextDescriptionLong].Text := Theme.Main.DescriptionLong[Interaction]; -end; - -procedure TScreenMain.InteractPrev; -begin - inherited InteractPrev; - Text[TextDescription].Text := Theme.Main.Description[Interaction]; - Text[TextDescriptionLong].Text := Theme.Main.DescriptionLong[Interaction]; -end; - -procedure TScreenMain.InteractDec; -begin - inherited InteractDec; - Text[TextDescription].Text := Theme.Main.Description[Interaction]; - Text[TextDescriptionLong].Text := Theme.Main.DescriptionLong[Interaction]; -end; - -procedure TScreenMain.InteractInc; +procedure TScreenMain.SetInteraction(Num: integer); begin - inherited InteractInc; + inherited SetInteraction(Num); Text[TextDescription].Text := Theme.Main.Description[Interaction]; Text[TextDescriptionLong].Text := Theme.Main.DescriptionLong[Interaction]; end; diff --git a/unicode/src/screens/UScreenName.pas b/unicode/src/screens/UScreenName.pas index 64e90cc9..dc2f14ef 100644 --- a/unicode/src/screens/UScreenName.pas +++ b/unicode/src/screens/UScreenName.pas @@ -45,9 +45,9 @@ uses type TScreenName = class(TMenu) public - Goto_SingScreen: Boolean; //If True then next Screen in SingScreen + Goto_SingScreen: boolean; //If true then next Screen in SingScreen constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; procedure SetAnimationProgress(Progress: real); override; end; @@ -63,13 +63,13 @@ uses UUnicodeUtils; -function TScreenName.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenName.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; var - I: integer; -SDL_ModState: Word; + I: integer; + SDL_ModState: word; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT @@ -196,7 +196,6 @@ begin Button[Interaction].Text[0].Text := Ini.NameTemplate[11]; end; - SDLK_BACKSPACE: begin Button[Interaction].Text[0].DeleteLastLetter; @@ -224,7 +223,7 @@ begin else FadeTo(@ScreenLevel); - GoTo_SingScreen := False; + GoTo_SingScreen := false; end; // Up and Down could be done at the same time, @@ -246,7 +245,6 @@ begin LoadFromTheme(Theme.Name); - for I := 1 to 6 do AddButton(Theme.Name.ButtonPlayer[I]); @@ -262,12 +260,14 @@ begin for I := 1 to 6 do Button[I-1].Text[0].Text := Ini.Name[I-1]; - for I := 1 to PlayersPlay do begin + 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 + for I := PlayersPlay+1 to 6 do + begin Button[I-1].Visible := false; Button[I-1].Selectable := false; end; diff --git a/unicode/src/screens/UScreenOpen.pas b/unicode/src/screens/UScreenOpen.pas index fa65a1df..718ef546 100644 --- a/unicode/src/screens/UScreenOpen.pas +++ b/unicode/src/screens/UScreenOpen.pas @@ -92,7 +92,7 @@ begin Ord(' '), Ord('-'), Ord('.'), Ord(':'), Ord('\'): begin if Interaction = 0 then - begin + begin Text[TextN].Text := Text[TextN].Text + UCS4ToUTF8String(CharCode); end; end; @@ -123,7 +123,7 @@ begin SDLK_RETURN: begin if (Interaction = 2) then - begin + begin //Update Filename and go to last Screen ConversionFileName := Text[TextN].Text; AudioPlayback.PlaySound(SoundLib.Back); @@ -207,7 +207,8 @@ begin Interaction := 0; end; -(*function TScreenEditSub.Draw: boolean; +(* +function TScreenEditSub.Draw: boolean; var Min: integer; Sec: integer; @@ -219,6 +220,7 @@ end; procedure TScreenEditSub.Finish; begin // -end;*) +end; +*) end. diff --git a/unicode/src/screens/UScreenOptions.pas b/unicode/src/screens/UScreenOptions.pas index ff2a3fe2..24f1f3d7 100644 --- a/unicode/src/screens/UScreenOptions.pas +++ b/unicode/src/screens/UScreenOptions.pas @@ -48,7 +48,7 @@ type public TextDescription: integer; constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; procedure InteractNext; override; procedure InteractPrev; override; @@ -63,10 +63,10 @@ uses UGraphic, UUnicodeUtils; -function TScreenOptions.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenOptions.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of diff --git a/unicode/src/screens/UScreenOptionsAdvanced.pas b/unicode/src/screens/UScreenOptionsAdvanced.pas index a6564bf1..65aec66f 100644 --- a/unicode/src/screens/UScreenOptionsAdvanced.pas +++ b/unicode/src/screens/UScreenOptionsAdvanced.pas @@ -34,8 +34,8 @@ interface {$I switches.inc} uses - SDL, UMenu, + SDL, UDisplay, UMusic, UFiles, @@ -46,7 +46,7 @@ type TScreenOptionsAdvanced = class(TMenu) public constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; end; @@ -57,10 +57,10 @@ uses UUnicodeUtils, SysUtils; -function TScreenOptionsAdvanced.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenOptionsAdvanced.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of @@ -85,7 +85,8 @@ begin begin //SelectLoadAnimation Hidden because it is useless atm //if SelInteraction = 7 then begin - if SelInteraction = 6 then begin + if SelInteraction = 6 then + begin Ini.Save; AudioPlayback.PlaySound(SoundLib.Back); FadeTo(@ScreenOptions); @@ -99,7 +100,8 @@ begin begin //SelectLoadAnimation Hidden because it is useless atm //if (SelInteraction >= 0) and (SelInteraction <= 6) then begin - if (SelInteraction >= 0) and (SelInteraction <= 5) then begin + if (SelInteraction >= 0) and (SelInteraction <= 5) then + begin AudioPlayback.PlaySound(SoundLib.Option); InteractInc; end; @@ -108,7 +110,8 @@ begin begin //SelectLoadAnimation Hidden because it is useless atm //if (SelInteraction >= 0) and (SelInteraction <= 6) then begin - if (SelInteraction >= 0) and (SelInteraction <= 5) then begin + if (SelInteraction >= 0) and (SelInteraction <= 5) then + begin AudioPlayback.PlaySound(SoundLib.Option); InteractDec; end; @@ -126,13 +129,30 @@ begin LoadFromTheme(Theme.OptionsAdvanced); //SelectLoadAnimation Hidden because it is useless atm - //AddSelect(Theme.OptionsAdvanced.SelectLoadAnimation, Ini.LoadAnimation, ILoadAnimation); - AddSelectSlide(Theme.OptionsAdvanced.SelectScreenFade, Ini.ScreenFade, IScreenFade); - AddSelectSlide(Theme.OptionsAdvanced.SelectEffectSing, Ini.EffectSing, IEffectSing); - AddSelectSlide(Theme.OptionsAdvanced.SelectLineBonus, Ini.LineBonus, ILineBonus); - AddSelectSlide(Theme.OptionsAdvanced.SelectOnSongClick, Ini.OnSongClick, IOnSongClick); - AddSelectSlide(Theme.OptionsAdvanced.SelectAskbeforeDel, Ini.AskBeforeDel, IAskbeforeDel); - AddSelectSlide(Theme.OptionsAdvanced.SelectPartyPopup, Ini.PartyPopup, IPartyPopup); + //AddSelect(Theme.OptionsAdvanced.SelectLoadAnimation, Ini.LoadAnimation, ILoadAnimationTranslated); + Theme.OptionsAdvanced.SelectScreenFade.showArrows := true; + Theme.OptionsAdvanced.SelectScreenFade.oneItemOnly := true; + AddSelectSlide(Theme.OptionsAdvanced.SelectScreenFade, Ini.ScreenFade, IScreenFadeTranslated); + + Theme.OptionsAdvanced.SelectEffectSing.showArrows := true; + Theme.OptionsAdvanced.SelectEffectSing.oneItemOnly := true; + AddSelectSlide(Theme.OptionsAdvanced.SelectEffectSing, Ini.EffectSing, IEffectSingTranslated); + + Theme.OptionsAdvanced.SelectLineBonus.showArrows := true; + Theme.OptionsAdvanced.SelectLineBonus.oneItemOnly := true; + AddSelectSlide(Theme.OptionsAdvanced.SelectLineBonus, Ini.LineBonus, ILineBonusTranslated); + + Theme.OptionsAdvanced.SelectOnSongClick.showArrows := true; + Theme.OptionsAdvanced.SelectOnSongClick.oneItemOnly := true; + AddSelectSlide(Theme.OptionsAdvanced.SelectOnSongClick, Ini.OnSongClick, IOnSongClickTranslated); + + Theme.OptionsAdvanced.SelectAskbeforeDel.showArrows := true; + Theme.OptionsAdvanced.SelectAskbeforeDel.oneItemOnly := true; + AddSelectSlide(Theme.OptionsAdvanced.SelectAskbeforeDel, Ini.AskBeforeDel, IAskbeforeDelTranslated); + + Theme.OptionsAdvanced.SelectPartyPopup.showArrows := true; + Theme.OptionsAdvanced.SelectPartyPopup.oneItemOnly := true; + AddSelectSlide(Theme.OptionsAdvanced.SelectPartyPopup, Ini.PartyPopup, IPartyPopupTranslated); AddButton(Theme.OptionsAdvanced.ButtonExit); if (Length(Button[0].Text)=0) then diff --git a/unicode/src/screens/UScreenOptionsGame.pas b/unicode/src/screens/UScreenOptionsGame.pas index c5af4ca2..1e7bbb3a 100644 --- a/unicode/src/screens/UScreenOptionsGame.pas +++ b/unicode/src/screens/UScreenOptionsGame.pas @@ -40,15 +40,15 @@ uses UMusic, UFiles, UIni, - UThemes, - USongs; + USongs, + UThemes; type TScreenOptionsGame = class(TMenu) public old_Tabs, old_Sorting: integer; constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; procedure RefreshSongs; end; @@ -60,10 +60,12 @@ uses UUnicodeUtils, SysUtils; -function TScreenOptionsGame.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenOptionsGame.ParseInput(PressedKey: cardinal; + CharCode: UCS4Char; + PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if PressedDown then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of @@ -81,12 +83,12 @@ begin begin AudioPlayback.PlaySound(SoundLib.Back); RefreshSongs; - FadeTo(@ScreenOptions); end; SDLK_RETURN: begin - if SelInteraction = 6 then begin + if SelInteraction = 6 then + begin AudioPlayback.PlaySound(SoundLib.Back); RefreshSongs; FadeTo(@ScreenOptions); @@ -126,15 +128,34 @@ begin old_Sorting := Ini.Sorting; old_Tabs := Ini.Tabs; + Theme.OptionsGame.SelectPlayers.showArrows := true; + Theme.OptionsGame.SelectPlayers.oneItemOnly := true; AddSelectSlide(Theme.OptionsGame.SelectPlayers, Ini.Players, IPlayers); - AddSelectSlide(Theme.OptionsGame.SelectDifficulty, Ini.Difficulty, IDifficulty); + + Theme.OptionsGame.SelectDifficulty.showArrows := true; + Theme.OptionsGame.SelectDifficulty.oneItemOnly := true; + AddSelectSlide(Theme.OptionsGame.SelectDifficulty, Ini.Difficulty, IDifficultyTranslated); + + Theme.OptionsGame.SelectLanguage.showArrows := true; + Theme.OptionsGame.SelectLanguage.oneItemOnly := true; AddSelectSlide(Theme.OptionsGame.SelectLanguage, Ini.Language, ILanguage); - AddSelectSlide(Theme.OptionsGame.SelectTabs, Ini.Tabs, ITabs); - AddSelectSlide(Theme.OptionsGame.SelectSorting, Ini.Sorting, ISorting); - AddSelectSlide(Theme.OptionsGame.SelectDebug, Ini.Debug, IDebug); + + Theme.OptionsGame.SelectTabs.showArrows := true; + Theme.OptionsGame.SelectTabs.oneItemOnly := true; + AddSelectSlide(Theme.OptionsGame.SelectTabs, Ini.Tabs, ITabsTranslated); + + Theme.OptionsGame.SelectSorting.showArrows := true; + Theme.OptionsGame.SelectSorting.oneItemOnly := true; + AddSelectSlide(Theme.OptionsGame.SelectSorting, Ini.Sorting, ISortingTranslated); + + Theme.OptionsGame.SelectDebug.showArrows := true; + Theme.OptionsGame.SelectDebug.oneItemOnly := true; + AddSelectSlide(Theme.OptionsGame.SelectDebug, Ini.Debug, IDebugTranslated); + + AddButton(Theme.OptionsGame.ButtonExit); - if (Length(Button[0].Text)=0) then + if (Length(Button[0].Text) = 0) then AddButtonText(14, 20, Theme.Options.Description[7]); end; @@ -142,7 +163,7 @@ end; //Refresh Songs Patch procedure TScreenOptionsGame.RefreshSongs; begin -if (ini.Sorting <> old_Sorting) or (ini.Tabs <> old_Tabs) then + if (ini.Sorting <> old_Sorting) or (ini.Tabs <> old_Tabs) then ScreenSong.Refresh; end; diff --git a/unicode/src/screens/UScreenOptionsGraphics.pas b/unicode/src/screens/UScreenOptionsGraphics.pas index a0890dbe..2be3dd66 100644 --- a/unicode/src/screens/UScreenOptionsGraphics.pas +++ b/unicode/src/screens/UScreenOptionsGraphics.pas @@ -46,7 +46,7 @@ type TScreenOptionsGraphics = class(TMenu) public constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; end; @@ -58,10 +58,10 @@ uses UUnicodeUtils, SysUtils; -function TScreenOptionsGraphics.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenOptionsGraphics.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of @@ -84,10 +84,12 @@ begin end; SDLK_RETURN: begin -{ if SelInteraction <= 1 then begin +{ if SelInteraction <= 1 then + begin Restart := true; end;} - if SelInteraction = 6 then begin + if SelInteraction = 6 then + begin Ini.Save; AudioPlayback.PlaySound(SoundLib.Back); // FIXME: changing the video mode does not work this way in windows @@ -105,14 +107,16 @@ begin InteractPrev; SDLK_RIGHT: begin - if (SelInteraction >= 0) and (SelInteraction < 6) then begin + if (SelInteraction >= 0) and (SelInteraction < 6) then + begin AudioPlayback.PlaySound(SoundLib.Option); InteractInc; end; end; SDLK_LEFT: begin - if (SelInteraction >= 0) and (SelInteraction < 6) then begin + if (SelInteraction >= 0) and (SelInteraction < 6) then + begin AudioPlayback.PlaySound(SoundLib.Option); InteractDec; end; @@ -128,13 +132,29 @@ begin inherited Create; LoadFromTheme(Theme.OptionsGraphics); - AddSelectSlide(Theme.OptionsGraphics.SelectResolution, Ini.Resolution, IResolution); - AddSelectSlide(Theme.OptionsGraphics.SelectFullscreen, Ini.Fullscreen, IFullscreen); - AddSelectSlide(Theme.OptionsGraphics.SelectDepth, Ini.Depth, IDepth); - AddSelectSlide(Theme.OptionsGraphics.SelectVisualizer, Ini.VisualizerOption, IVisualizer); - AddSelectSlide(Theme.OptionsGraphics.SelectOscilloscope, Ini.Oscilloscope, IOscilloscope); - AddSelectSlide(Theme.OptionsGraphics.SelectMovieSize, Ini.MovieSize, IMovieSize); + Theme.OptionsGraphics.SelectResolution.showArrows := true; + Theme.OptionsGraphics.SelectResolution.oneItemOnly := true; + AddSelectSlide(Theme.OptionsGraphics.SelectResolution, Ini.Resolution, IResolution); + Theme.OptionsGraphics.SelectFullscreen.showArrows := true; + Theme.OptionsGraphics.SelectFullscreen.oneItemOnly := true; + AddSelectSlide(Theme.OptionsGraphics.SelectFullscreen, Ini.Fullscreen, IFullScreenTranslated); + + Theme.OptionsGraphics.SelectDepth.showArrows := true; + Theme.OptionsGraphics.SelectDepth.oneItemOnly := true; + AddSelectSlide(Theme.OptionsGraphics.SelectDepth, Ini.Depth, IDepth); + + Theme.OptionsGraphics.SelectVisualizer.showArrows := true; + Theme.OptionsGraphics.SelectVisualizer.oneItemOnly := true; + AddSelectSlide(Theme.OptionsGraphics.SelectVisualizer, Ini.VisualizerOption, IVisualizerTranslated); + + Theme.OptionsGraphics.SelectOscilloscope.showArrows := true; + Theme.OptionsGraphics.SelectOscilloscope.oneItemOnly := true; + AddSelectSlide(Theme.OptionsGraphics.SelectOscilloscope, Ini.Oscilloscope, IOscilloscopeTranslated); + + Theme.OptionsGraphics.SelectMovieSize.showArrows := true; + Theme.OptionsGraphics.SelectMovieSize.oneItemOnly := true; + AddSelectSlide(Theme.OptionsGraphics.SelectMovieSize, Ini.MovieSize, IMovieSizeTranslated); AddButton(Theme.OptionsGraphics.ButtonExit); if (Length(Button[0].Text)=0) then diff --git a/unicode/src/screens/UScreenOptionsLyrics.pas b/unicode/src/screens/UScreenOptionsLyrics.pas index c8995ae4..d3fbf441 100644 --- a/unicode/src/screens/UScreenOptionsLyrics.pas +++ b/unicode/src/screens/UScreenOptionsLyrics.pas @@ -46,7 +46,7 @@ type TScreenOptionsLyrics = class(TMenu) public constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; end; @@ -57,10 +57,10 @@ uses UUnicodeUtils, SysUtils; -function TScreenOptionsLyrics.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenOptionsLyrics.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of @@ -83,7 +83,8 @@ begin end; SDLK_RETURN: begin - if SelInteraction = 3 then begin + if SelInteraction = 3 then + begin Ini.Save; AudioPlayback.PlaySound(SoundLib.Back); FadeTo(@ScreenOptions); @@ -95,14 +96,16 @@ begin InteractPrev; SDLK_RIGHT: begin - if (SelInteraction >= 0) and (SelInteraction <= 3) then begin + if (SelInteraction >= 0) and (SelInteraction <= 3) then + begin AudioPlayback.PlaySound(SoundLib.Option); InteractInc; end; end; SDLK_LEFT: begin - if (SelInteraction >= 0) and (SelInteraction <= 3) then begin + if (SelInteraction >= 0) and (SelInteraction <= 3) then + begin AudioPlayback.PlaySound(SoundLib.Option); InteractDec; end; @@ -117,11 +120,17 @@ begin LoadFromTheme(Theme.OptionsLyrics); - AddSelectSlide(Theme.OptionsLyrics.SelectLyricsFont, Ini.LyricsFont, ILyricsFont); - AddSelectSlide(Theme.OptionsLyrics.SelectLyricsEffect, Ini.LyricsEffect, ILyricsEffect); - //AddSelect(Theme.OptionsLyrics.SelectSolmization, Ini.Solmization, ISolmization); GAH!!!!11 DIE!!! - AddSelectSlide(Theme.OptionsLyrics.SelectNoteLines, Ini.NoteLines, INoteLines); + Theme.OptionsLyrics.SelectLyricsFont.showArrows := true; + Theme.OptionsLyrics.SelectLyricsFont.oneItemOnly := true; + AddSelectSlide(Theme.OptionsLyrics.SelectLyricsFont, Ini.LyricsFont, ILyricsFontTranslated); + Theme.OptionsLyrics.SelectLyricsEffect.showArrows := true; + Theme.OptionsLyrics.SelectLyricsEffect.oneItemOnly := true; + AddSelectSlide(Theme.OptionsLyrics.SelectLyricsEffect, Ini.LyricsEffect, ILyricsEffectTranslated); + + Theme.OptionsLyrics.SelectNoteLines.showArrows := true; + Theme.OptionsLyrics.SelectNoteLines.oneItemOnly := true; + AddSelectSlide(Theme.OptionsLyrics.SelectNoteLines, Ini.NoteLines, INoteLinesTranslated); AddButton(Theme.OptionsLyrics.ButtonExit); if (Length(Button[0].Text)=0) then diff --git a/unicode/src/screens/UScreenOptionsRecord.pas b/unicode/src/screens/UScreenOptionsRecord.pas index 0cf9eb37..cdacd5f6 100644 --- a/unicode/src/screens/UScreenOptionsRecord.pas +++ b/unicode/src/screens/UScreenOptionsRecord.pas @@ -95,7 +95,7 @@ type public constructor Create; override; function Draw: boolean; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; procedure onHide; override; end; @@ -129,10 +129,10 @@ uses UUnicodeUtils, ULog; -function TScreenOptionsRecord.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenOptionsRecord.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of @@ -245,6 +245,8 @@ begin InputDeviceNames[DeviceIndex] := AudioInputProcessor.DeviceList[DeviceIndex].Name; end; // add device-selection slider (InteractionID: 0) + Theme.OptionsRecord.SelectSlideCard.showArrows := true; + Theme.OptionsRecord.SelectSlideCard.oneItemOnly := true; AddSelectSlide(Theme.OptionsRecord.SelectSlideCard, CurrentDeviceIndex, InputDeviceNames); // init source-selection slider @@ -253,6 +255,9 @@ begin begin InputSourceNames[SourceIndex] := InputDevice.Source[SourceIndex].Name; end; + + Theme.OptionsRecord.SelectSlideInput.showArrows := true; + Theme.OptionsRecord.SelectSlideInput.oneItemOnly := true; // add source-selection slider (InteractionID: 1) SelectInputSourceID := AddSelectSlide(Theme.OptionsRecord.SelectSlideInput, InputDeviceCfg.Input, InputSourceNames); @@ -485,7 +490,6 @@ begin PreviewDeviceIndex := -1; end; - procedure TScreenOptionsRecord.DrawVolume(x, y, Width, Height: single); var x1, y1, x2, y2: single; @@ -803,8 +807,7 @@ begin end; end; - Result := True; + Result := true; end; - end. diff --git a/unicode/src/screens/UScreenOptionsSound.pas b/unicode/src/screens/UScreenOptionsSound.pas index d0125a9d..f9a4c158 100644 --- a/unicode/src/screens/UScreenOptionsSound.pas +++ b/unicode/src/screens/UScreenOptionsSound.pas @@ -34,8 +34,8 @@ interface {$I switches.inc} uses - SDL, UMenu, + SDL, UDisplay, UMusic, UFiles, @@ -46,7 +46,7 @@ type TScreenOptionsSound = class(TMenu) public constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; end; @@ -61,14 +61,14 @@ uses function TScreenOptionsSound.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin - Result := True; + Result := true; if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of Ord('Q'): begin - Result := False; + Result := false; Exit; end; end; @@ -137,19 +137,39 @@ begin LoadFromTheme(Theme.OptionsSound); - AddSelectSlide(Theme.OptionsSound.SelectSlideVoicePassthrough, - Ini.VoicePassthrough, IVoicePassthrough); - AddSelectSlide(Theme.OptionsSound.SelectBackgroundMusic, - Ini.BackgroundMusicOption, IBackgroundMusic); - AddSelectSlide(Theme.OptionsSound.SelectMicBoost, Ini.MicBoost, IMicBoost); + Theme.OptionsSound.SelectSlideVoicePassthrough.showArrows := true; + Theme.OptionsSound.SelectSlideVoicePassthrough.oneItemOnly := true; + AddSelectSlide(Theme.OptionsSound.SelectSlideVoicePassthrough, Ini.VoicePassthrough, IVoicePassthroughTranslated); + + Theme.OptionsSound.SelectBackgroundMusic.showArrows := true; + Theme.OptionsSound.SelectBackgroundMusic.oneItemOnly := true; + AddSelectSlide(Theme.OptionsSound.SelectBackgroundMusic, Ini.BackgroundMusicOption, IBackgroundMusicTranslated); + // TODO: - MicBoost needs to be moved to ScreenOptionsRecord - AddSelectSlide(Theme.OptionsSound.SelectClickAssist, Ini.ClickAssist, IClickAssist); - AddSelectSlide(Theme.OptionsSound.SelectBeatClick, Ini.BeatClick, IBeatClick); + Theme.OptionsSound.SelectMicBoost.showArrows := true; + Theme.OptionsSound.SelectMicBoost.oneItemOnly := true; + AddSelectSlide(Theme.OptionsSound.SelectMicBoost, Ini.MicBoost, IMicBoostTranslated); + + + Theme.OptionsSound.SelectClickAssist.showArrows := true; + Theme.OptionsSound.SelectClickAssist.oneItemOnly := true; + AddSelectSlide(Theme.OptionsSound.SelectClickAssist, Ini.ClickAssist, IClickAssistTranslated); + + Theme.OptionsSound.SelectBeatClick.showArrows := true; + Theme.OptionsSound.SelectBeatClick.oneItemOnly := true; + AddSelectSlide(Theme.OptionsSound.SelectBeatClick, Ini.BeatClick, IBeatClickTranslated); + + Theme.OptionsSound.SelectThreshold.showArrows := true; + Theme.OptionsSound.SelectThreshold.oneItemOnly := true; AddSelectSlide(Theme.OptionsSound.SelectThreshold, Ini.ThresholdIndex, IThreshold); - AddSelectSlide(Theme.OptionsSound.SelectSlidePreviewVolume, - Ini.PreviewVolume, IPreviewVolume); - AddSelectSlide(Theme.OptionsSound.SelectSlidePreviewFading, - Ini.PreviewFading, IPreviewFading); + + Theme.OptionsSound.SelectSlidePreviewVolume.showArrows := true; + Theme.OptionsSound.SelectSlidePreviewVolume.oneItemOnly := true; + AddSelectSlide(Theme.OptionsSound.SelectSlidePreviewVolume, Ini.PreviewVolume, IPreviewVolumeTranslated); + + Theme.OptionsSound.SelectSlidePreviewFading.showArrows := true; + Theme.OptionsSound.SelectSlidePreviewFading.oneItemOnly := true; + AddSelectSlide(Theme.OptionsSound.SelectSlidePreviewFading, Ini.PreviewFading, IPreviewFadingTranslated); AddButton(Theme.OptionsSound.ButtonExit); if (Length(Button[0].Text) = 0) then diff --git a/unicode/src/screens/UScreenOptionsThemes.pas b/unicode/src/screens/UScreenOptionsThemes.pas index 64816d34..aaee3fd9 100644 --- a/unicode/src/screens/UScreenOptionsThemes.pas +++ b/unicode/src/screens/UScreenOptionsThemes.pas @@ -47,9 +47,9 @@ type private procedure ReloadTheme; public - SkinSelect: Integer; + SkinSelect: integer; constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; procedure InteractInc; override; procedure InteractDec; override; @@ -65,10 +65,10 @@ uses UUnicodeUtils, USkins; -function TScreenOptionsThemes.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenOptionsThemes.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of @@ -162,11 +162,17 @@ begin LoadFromTheme(Theme.OptionsThemes); + Theme.OptionsThemes.SelectTheme.showArrows := true; + Theme.OptionsThemes.SelectTheme.oneItemOnly := true; AddSelectSlide(Theme.OptionsThemes.SelectTheme, Ini.Theme, ITheme); + Theme.OptionsThemes.SelectSkin.showArrows := true; + Theme.OptionsThemes.SelectSkin.oneItemOnly := true; SkinSelect := AddSelectSlide(Theme.OptionsThemes.SelectSkin, Ini.SkinNo, ISkin); - AddSelectSlide(Theme.OptionsThemes.SelectColor, Ini.Color, IColor); + Theme.OptionsThemes.SelectColor.showArrows := true; + Theme.OptionsThemes.SelectColor.oneItemOnly := true; + AddSelectSlide(Theme.OptionsThemes.SelectColor, Ini.Color, IColorTranslated); AddButton(Theme.OptionsThemes.ButtonExit); if (Length(Button[0].Text)=0) then @@ -191,7 +197,6 @@ begin ScreenOptionsThemes.Interaction := self.Interaction; ScreenOptionsThemes.Draw; - Display.Draw; SwapBuffers; diff --git a/unicode/src/screens/UScreenPartyNewRound.pas b/unicode/src/screens/UScreenPartyNewRound.pas index afcf2f9d..4c90b4c7 100644 --- a/unicode/src/screens/UScreenPartyNewRound.pas +++ b/unicode/src/screens/UScreenPartyNewRound.pas @@ -34,73 +34,72 @@ interface {$I switches.inc} uses - SDL, - SysUtils, 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; + 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; + 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; + 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; + 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; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; procedure SetAnimationProgress(Progress: real); override; end; @@ -119,10 +118,10 @@ uses ULog, UUnicodeUtils; -function TScreenPartyNewRound.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenPartyNewRound.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of @@ -219,19 +218,19 @@ end; procedure TScreenPartyNewRound.onShow; var - I: Integer; - function GetTeamPlayers(const Num: Byte): String; + I: integer; + function GetTeamPlayers(const Num: byte): string; var Players: array of UTF8String; - //J: Byte; - begin // to-do : Party - if (Num-1 >= {PartySession.Teams.NumTeams}0) then + J: byte; + begin + if (Num-1 >= PartySession.Teams.NumTeams) then exit; - {//Create Players Array + //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);} + 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); @@ -239,193 +238,191 @@ var begin inherited; - // to-do : Party - //PartySession.StartRound; + PartySession.StartRound; //Set Visibility of Round Infos - // to-do : Party - I := {Length(PartySession.Rounds)}0; + I := Length(PartySession.Rounds); if (I >= 1) then begin - Static[StaticRound1].Visible := True; - Text[TextRound1].Visible := True; - Text[TextWinner1].Visible := True; + 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); + 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; + 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; + 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); + 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; + 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; + 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); + 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; + 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; + 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); + 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; + 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; + 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); + 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; + 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; + 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); + 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; + 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; + 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); + 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; + Static[StaticRound7].Visible := false; + Text[TextRound7].Visible := false; + Text[TextWinner7].Visible := false; end; //Display Scores - {if (PartySession.Teams.NumTeams >= 1) then + 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[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; + 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; + 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[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; + 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; + 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[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; + 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; + Text[TextScoreTeam3].Visible := false; + Text[TextNameTeam3].Visible := false; + Text[TextTeam3Players].Visible := false; + Static[StaticTeam3].Visible := false; + Static[StaticNextPlayer3].Visible := false; end; //nextRound Texts @@ -434,26 +431,26 @@ begin 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; + Text[TextNextPlayer1].Visible := true; end else - Text[TextNextPlayer1].Visible := False; + 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; + Text[TextNextPlayer2].Visible := true; end else - Text[TextNextPlayer2].Visible := False; + 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; + Text[TextNextPlayer3].Visible := true; end else - Text[TextNextPlayer3].Visible := False; } + Text[TextNextPlayer3].Visible := false; end; procedure TScreenPartyNewRound.SetAnimationProgress(Progress: real); diff --git a/unicode/src/screens/UScreenPartyOptions.pas b/unicode/src/screens/UScreenPartyOptions.pas index 74c51b15..b7226a5e 100644 --- a/unicode/src/screens/UScreenPartyOptions.pas +++ b/unicode/src/screens/UScreenPartyOptions.pas @@ -125,11 +125,11 @@ begin // Don't start when SinglePlayer Teams but only Multiplayer Plugins available OnlyMultiPlayer := true; for I := 0 to High(DLLMan.Plugins) do - begin + begin OnlyMultiPlayer := (OnlyMultiPlayer and DLLMan.Plugins[I].TeamModeOnly); end; if (OnlyMultiPlayer) and ((NumPlayer1 = 0) or (NumPlayer2 = 0) or ((NumPlayer3 = 0) and (NumTeams = 1))) then - begin + begin ScreenPopupError.ShowPopup(Language.Translate('ERROR_NO_PLUGINS')); Exit; end; @@ -137,12 +137,11 @@ begin Ini.Difficulty := SelectsS[SelectLevel].SelectedOption; Ini.SaveLevel; - //Save Num Teams: - {PartySession.Teams.NumTeams := NumTeams + 2; + 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;} + PartySession.Teams.Teaminfo[2].NumPlayers := NumPlayer3+1; //Save Playlist PlaylistMan.Mode := TSingMode( Playlist ); @@ -171,8 +170,7 @@ begin PlaylistMan.CurPlayList := Playlist2; //Start Party - // to-do : Party - //PartySession.StartNewParty(Rounds + 2); + PartySession.StartNewParty(Rounds + 2); AudioPlayback.PlaySound(SoundLib.Start); //Go to Player Screen @@ -258,7 +256,8 @@ begin end; procedure TScreenPartyOptions.SetPlaylist2; -var I: integer; +var + I: integer; begin case Playlist of 0: diff --git a/unicode/src/screens/UScreenPartyPlayer.pas b/unicode/src/screens/UScreenPartyPlayer.pas index 3e453058..9f40983a 100644 --- a/unicode/src/screens/UScreenPartyPlayer.pas +++ b/unicode/src/screens/UScreenPartyPlayer.pas @@ -45,26 +45,26 @@ uses 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; + 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; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; procedure SetAnimationProgress(Progress: real); override; end; @@ -79,9 +79,11 @@ uses UParty, UUnicodeUtils; -function TScreenPartyPlayer.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenPartyPlayer.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; var - SDL_ModState: Word; + SDL_ModState: word; + I, J: integer; + procedure IntNext; begin repeat @@ -245,7 +247,7 @@ begin SDLK_RETURN: begin - {//Save PlayerNames + //Save PlayerNames for I := 0 to PartySession.Teams.NumTeams-1 do begin PartySession.Teams.Teaminfo[I].Name := PChar(Button[I*5].Text[0].Text); @@ -256,8 +258,8 @@ begin end; end; - AudioPlayback.PlayStart; - FadeTo(@ScreenPartyNewRound);} + AudioPlayback.PlaySound(SoundLib.Start); + FadeTo(@ScreenPartyNewRound); end; // Up and Down could be done at the same time, @@ -272,8 +274,6 @@ begin end; constructor TScreenPartyPlayer.Create; -//var -// I: integer; // Auto Removed, Unused Variable begin inherited Create; @@ -321,9 +321,9 @@ begin Button[10].Text[0].Text := Ini.NameTeam[2]; // Templates for Names Mod end - {If (PartySession.Teams.NumTeams>=1) then + if (PartySession.Teams.NumTeams>=1) then begin - Button[0].Visible := True; + 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); @@ -331,16 +331,16 @@ begin end else begin - Button[0].Visible := False; - Button[1].Visible := False; - Button[2].Visible := False; - Button[3].Visible := False; - Button[4].Visible := False; + 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 + if (PartySession.Teams.NumTeams>=2) then begin - Button[5].Visible := True; + 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); @@ -348,16 +348,16 @@ begin end else begin - Button[5].Visible := False; - Button[6].Visible := False; - Button[7].Visible := False; - Button[8].Visible := False; - Button[9].Visible := False; + 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 + if (PartySession.Teams.NumTeams>=3) then begin - Button[10].Visible := True; + 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); @@ -365,12 +365,12 @@ begin end else begin - Button[10].Visible := False; - Button[11].Visible := False; - Button[12].Visible := False; - Button[13].Visible := False; - Button[14].Visible := False; - end; } + Button[10].Visible := false; + Button[11].Visible := false; + Button[12].Visible := false; + Button[13].Visible := false; + Button[14].Visible := false; + end; end; diff --git a/unicode/src/screens/UScreenPartyScore.pas b/unicode/src/screens/UScreenPartyScore.pas index 5934a389..4daa77c3 100644 --- a/unicode/src/screens/UScreenPartyScore.pas +++ b/unicode/src/screens/UScreenPartyScore.pas @@ -34,42 +34,42 @@ interface {$I switches.inc} uses - SDL, - SysUtils, 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; + 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; + MaxScore: word; constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; procedure SetAnimationProgress(Progress: real); override; end; @@ -86,10 +86,10 @@ uses USkins, UUnicodeUtils; -function TScreenPartyScore.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenPartyScore.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of @@ -106,22 +106,21 @@ begin SDLK_BACKSPACE : begin AudioPlayback.PlaySound(SoundLib.Start); - {if (PartySession.CurRound < High(PartySession.Rounds)) then + if (PartySession.CurRound < High(PartySession.Rounds)) then FadeTo(@ScreenPartyNewRound) - else // to-do : Party + else begin - PartySession.EndRound; } + PartySession.EndRound; FadeTo(@ScreenPartyWin); - //end; + end; end; SDLK_RETURN: begin AudioPlayback.PlaySound(SoundLib.Start); - // to-do : Party - {if (PartySession.CurRound < High(PartySession.Rounds)) then + if (PartySession.CurRound < High(PartySession.Rounds)) then FadeTo(@ScreenPartyNewRound) - else } + else FadeTo(@ScreenPartyWin); end; end; @@ -132,8 +131,8 @@ constructor TScreenPartyScore.Create; var // I: integer; // Auto Removed, Unused Variable Tex: TTexture; - R, G, B: Real; - Color: Integer; + R, G, B: real; + Color: integer; begin inherited Create; @@ -198,12 +197,11 @@ end; procedure TScreenPartyScore.onShow; var - I, J: Integer; - Placings: Array [0..5] of Byte; + I, J: integer; + Placings: array [0..5] of byte; begin inherited; - //Get Maxscore MaxScore := 0; @@ -218,11 +216,10 @@ begin 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 + 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; @@ -233,16 +230,16 @@ begin 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 // to-do : Party - //PartySession.EndRound; + //End Last Round + PartySession.EndRound; //Set Winnertext - //Text[TextWinner].Text := Format(Language.Translate('PARTY_SCORE_WINS'), [PartySession.GetWinnerString(PartySession.CurRound)]); + 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); + Text[TextNameTeam1].Text := string(ScreenSingModi.TeamInfo.Teaminfo[0].Name); //Set Deco Texture if Theme.PartyScore.DecoTextures.ChangeTextures then @@ -253,25 +250,25 @@ begin 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; + 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; + 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); + Text[TextNameTeam2].Text := string(ScreenSingModi.TeamInfo.Teaminfo[1].Name); //Set Deco Texture if Theme.PartyScore.DecoTextures.ChangeTextures then @@ -282,25 +279,25 @@ begin 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; + 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; + 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); + Text[TextNameTeam3].Text := string(ScreenSingModi.TeamInfo.Teaminfo[2].Name); //Set Deco Texture if Theme.PartyScore.DecoTextures.ChangeTextures then @@ -311,19 +308,19 @@ begin 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; + 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; + Text[TextScoreTeam3].Visible := false; + Text[TextNameTeam3].Visible := false; + Static[StaticTeam3].Visible := false; + Static[StaticTeam3BG].Visible := false; + Static[StaticTeam3Deco].Visible := false; end; end; diff --git a/unicode/src/screens/UScreenPartyWin.pas b/unicode/src/screens/UScreenPartyWin.pas index dc3c5ac0..caa1519e 100644 --- a/unicode/src/screens/UScreenPartyWin.pas +++ b/unicode/src/screens/UScreenPartyWin.pas @@ -35,34 +35,34 @@ interface uses SDL, - SysUtils, UMenu, 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; + 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; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; procedure SetAnimationProgress(Progress: real); override; end; @@ -77,10 +77,10 @@ uses ULanguage, UUnicodeUtils; -function TScreenPartyWin.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenPartyWin.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of @@ -138,13 +138,13 @@ begin end; procedure TScreenPartyWin.onShow; -//var -// I: Integer; // Auto Removed, Unused Variable -// Placing: Integer; // Auto Removed, Unused Variable +var + I: integer; + Placing: TeamOrderArray; - Function GetTeamColor(Team: Byte): Cardinal; + Function GetTeamColor(Team: byte): cardinal; var - NameString: String; + NameString: string; begin NameString := 'P' + InttoStr(Team+1) + 'Dark'; @@ -154,25 +154,24 @@ procedure TScreenPartyWin.onShow; begin inherited; - // to-do : Party //Get Team Placing - //Placing := PartySession.GetTeamOrder; + 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 + 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[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; + 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 + if (Theme.PartyWin.StaticTeam1BG.Color = 'TeamColor') then begin I := GetTeamColor(Placing[0]); if (I <> -1) then @@ -183,7 +182,7 @@ begin end; end; - If (Theme.PartyWin.StaticTeam1.Color = 'TeamColor') then + if (Theme.PartyWin.StaticTeam1.Color = 'TeamColor') then begin I := GetTeamColor(Placing[0]); if (I <> -1) then @@ -196,26 +195,26 @@ begin end else begin - Text[TextScoreTeam1].Visible := False; - Text[TextNameTeam1].Visible := False; - Static[StaticTeam1].Visible := False; - Static[StaticTeam1BG].Visible := False; - Static[StaticTeam1Deco].Visible := False; + 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[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; + 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 + if (Theme.PartyWin.StaticTeam2BG.Color = 'TeamColor') then begin I := GetTeamColor(Placing[1]); if (I <> -1) then @@ -226,7 +225,7 @@ begin end; end; - If (Theme.PartyWin.StaticTeam2.Color = 'TeamColor') then + if (Theme.PartyWin.StaticTeam2.Color = 'TeamColor') then begin I := GetTeamColor(Placing[1]); if (I <> -1) then @@ -239,26 +238,26 @@ begin end else begin - Text[TextScoreTeam2].Visible := False; - Text[TextNameTeam2].Visible := False; - Static[StaticTeam2].Visible := False; - Static[StaticTeam2BG].Visible := False; - Static[StaticTeam2Deco].Visible := False; + 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[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; + 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 + if (Theme.PartyWin.StaticTeam3BG.Color = 'TeamColor') then begin I := GetTeamColor(Placing[2]); if (I <> -1) then @@ -269,7 +268,7 @@ begin end; end; - If (Theme.PartyWin.StaticTeam3.Color = 'TeamColor') then + if (Theme.PartyWin.StaticTeam3.Color = 'TeamColor') then begin I := GetTeamColor(Placing[2]); if (I <> -1) then @@ -282,12 +281,12 @@ begin end else begin - Text[TextScoreTeam3].Visible := False; - Text[TextNameTeam3].Visible := False; - Static[StaticTeam3].Visible := False; - Static[StaticTeam3BG].Visible := False; - Static[StaticTeam3Deco].Visible := False; - end; } + Text[TextScoreTeam3].Visible := false; + Text[TextNameTeam3].Visible := false; + Static[StaticTeam3].Visible := false; + Static[StaticTeam3BG].Visible := false; + Static[StaticTeam3Deco].Visible := false; + end; end; procedure TScreenPartyWin.SetAnimationProgress(Progress: real); diff --git a/unicode/src/screens/UScreenPopup.pas b/unicode/src/screens/UScreenPopup.pas index 74107117..223d83ef 100644 --- a/unicode/src/screens/UScreenPopup.pas +++ b/unicode/src/screens/UScreenPopup.pas @@ -34,44 +34,43 @@ interface {$I switches.inc} uses - SDL, - SysUtils, UMenu, + SDL, UMusic, UFiles, + SysUtils, UThemes; type TScreenPopupCheck = class(TMenu) public - Visible: Boolean; //Whether the Menu should be Drawn + Visible: boolean; //Whether the Menu should be Drawn constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; - procedure ShowPopup(msg: String); + procedure ShowPopup(msg: string); function Draw: boolean; override; end; type TScreenPopupError = class(TMenu) { private - CurMenu: Byte; //Num of the cur. Shown Menu} + CurMenu: byte; //Num of the cur. Shown Menu} public - Visible: Boolean; //Whether the Menu should be Drawn + Visible: boolean; //Whether the Menu should be Drawn constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; procedure onHide; override; - procedure ShowPopup(msg: String); + procedure ShowPopup(msg: string); function Draw: boolean; override; end; var -// ISelections: Array of String; - SelectValue: Integer; - +// ISelections: array of string; + SelectValue: integer; implementation @@ -86,10 +85,10 @@ uses UDisplay, UUnicodeUtils; -function TScreenPopupCheck.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenPopupCheck.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of @@ -105,9 +104,9 @@ begin SDLK_ESCAPE, SDLK_BACKSPACE : begin - Display.CheckOK:=False; - Display.NextScreenWithCheck:=NIL; - Visible:=False; + Display.CheckOK := false; + Display.NextScreenWithCheck := NIL; + Visible := false; Result := false; end; @@ -124,14 +123,14 @@ begin ScreenSingModi.Finish; end; - Display.CheckOK:=True; + Display.CheckOK := true; end; 1: begin - Display.CheckOK:=False; - Display.NextScreenWithCheck:=NIL; + Display.CheckOK := false; + Display.NextScreenWithCheck := NIL; end; end; - Visible:=False; + Visible := false; Result := false; end; @@ -173,15 +172,15 @@ begin inherited; end; -procedure TScreenPopupCheck.ShowPopup(msg: String); +procedure TScreenPopupCheck.ShowPopup(msg: string); begin Interaction := 0; //Reset Interaction - Visible := True; //Set Visible + Visible := true; //Set Visible Text[0].Text := Language.Translate(msg); - Button[0].Visible := True; - Button[1].Visible := True; + 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'); @@ -191,10 +190,10 @@ end; // error popup -function TScreenPopupError.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenPopupError.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down case PressedKey of @@ -206,13 +205,13 @@ begin SDLK_ESCAPE, SDLK_BACKSPACE : begin - Visible:=False; + Visible := false; Result := false; end; SDLK_RETURN: begin - Visible:=False; + Visible := false; Result := false; end; @@ -242,7 +241,7 @@ end; function TScreenPopupError.Draw: boolean; begin - Draw:=inherited Draw; + Draw := inherited Draw; end; procedure TScreenPopupError.onShow; @@ -255,26 +254,26 @@ procedure TScreenPopupError.onHide; begin end; -procedure TScreenPopupError.ShowPopup(msg: String); +procedure TScreenPopupError.ShowPopup(msg: string); begin Interaction := 0; //Reset Interaction - Visible := True; //Set Visible + Visible := true; //Set Visible Background.OnShow; { //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].Visible := true; Text[i].Text := msg[i-1]; end else begin - Text[i].Visible:=False; + Text[i].Visible := false; end;} - Text[0].Text:=msg; + Text[0].Text := msg; - Button[0].Visible := True; + Button[0].Visible := true; Button[0].Text[0].Text := 'OK'; end; diff --git a/unicode/src/screens/UScreenScore.pas b/unicode/src/screens/UScreenScore.pas index 5c312938..e07d0b9e 100644 --- a/unicode/src/screens/UScreenScore.pas +++ b/unicode/src/screens/UScreenScore.pas @@ -129,6 +129,7 @@ type constructor Create; override; function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; + function ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; override; procedure onShow; override; procedure onShowFinish; override; function Draw: boolean; override; @@ -193,6 +194,15 @@ begin end; end; +function TScreenScore.ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; +begin + Result := True; + if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then begin + //left-click anywhere sends return + ParseInput(SDLK_RETURN, 0, true); + end; +end; + constructor TScreenScore.Create; var Player: integer; diff --git a/unicode/src/screens/UScreenSing.pas b/unicode/src/screens/UScreenSing.pas index 05683c83..86a811f4 100644 --- a/unicode/src/screens/UScreenSing.pas +++ b/unicode/src/screens/UScreenSing.pas @@ -58,9 +58,8 @@ type type TScreenSing = class(TMenu) - private - VideoLoaded: boolean; protected + VideoLoaded: boolean; Paused: boolean; // pause mod LyricsSync: TLyricsSyncSource; NumEmptySentences: integer; @@ -128,12 +127,13 @@ uses UNote, URecord, USong, + UDisplay, UUnicodeUtils; // method for input parsing. if false is returned, getnextwindow // should be checked to know the next window to load; -function TScreenSing.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; +function TScreenSing.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; @@ -255,6 +255,9 @@ constructor TScreenSing.Create; begin inherited Create; + //too dangerous, a mouse button is quickly pressed by accident + RightMbESC := false; + fShowVisualization := false; fCurrentVideoPlaybackEngine := VideoPlayback; @@ -299,8 +302,8 @@ begin Static[StaticPausePopup].Visible := false; Lyrics := TLyricEngine.Create( - Skin_LyricsUpperX, Skin_LyricsUpperY, Skin_LyricsUpperW, Skin_LyricsUpperH, - Skin_LyricsLowerX, Skin_LyricsLowerY, Skin_LyricsLowerW, Skin_LyricsLowerH); + Theme.LyricBar.UpperX, Theme.LyricBar.UpperY, Theme.LyricBar.UpperW, Theme.LyricBar.UpperH, + Theme.LyricBar.LowerX, Theme.LyricBar.LowerY, Theme.LyricBar.LowerW, Theme.LyricBar.LowerH); LyricsSync := TLyricsSyncSource.Create(); end; @@ -625,6 +628,9 @@ end; procedure TScreenSing.onShowFinish; begin + // hide cursor on singscreen show + Display.SetCursor; + // start lyrics LyricsState.Resume(); @@ -645,6 +651,7 @@ begin end; Background.OnFinish; + Display.SetCursor; end; function TScreenSing.Draw: boolean; @@ -745,10 +752,9 @@ begin begin // Just call this once // when Screens = 2 - If (ScreenAct = 1) then + if (ScreenAct = 1) then fCurrentVideoPlaybackEngine.GetFrame(CurrentSong.VideoGAP + LyricsState.GetCurrentTime()); - fCurrentVideoPlaybackEngine.DrawGL(ScreenAct); end; end; diff --git a/unicode/src/screens/UScreenSingModi.pas b/unicode/src/screens/UScreenSingModi.pas index b9c9365d..3ae5b7dc 100644 --- a/unicode/src/screens/UScreenSingModi.pas +++ b/unicode/src/screens/UScreenSingModi.pas @@ -33,74 +33,45 @@ interface {$I switches.inc} - -uses UMenu, - UMusic, - SDL, - SysUtils, - UFiles, - UTime, - USongs, - UIni, - ULog, - UTexture, - ULyrics, - TextGL, - gl, - - UThemes, - UScreenSing, - ModiSDK; +uses + UMenu, + UMusic, + SDL, + SysUtils, + UFiles, + UTime, + USongs, + UIni, + ULog, + UTexture, + ULyrics, + TextGL, + gl, + + UThemes, + 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 + Winner: byte; //Who Wins PlayerInfo: TPlayerInfo; TeamInfo: TTeamInfo; constructor Create; override; procedure onShow; override; //procedure onShowFinish; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; function Draw: boolean; override; procedure Finish; override; - //procedure Pause; //Pause Mod(Toggles Pause) end; type TCustomSoundEntry = record - Filename : String; + Filename : string; Stream : TAudioPlaybackStream; end; @@ -109,11 +80,19 @@ var CustomSounds: array of TCustomSoundEntry; //Procedured for Plugin -function LoadTex (const Name: PChar; Typ: TTextureType): 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 +function LoadTex(const Name: PChar; Typ: TTextureType): TsmallTexture; + {$IFDEF MSWINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +//function Translate (const Name: PChar): PChar; +// {$IFDEF MSWINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +//Procedure to Print Text +procedure Print(const Style, Size: byte; const X, Y: real; const Text: PChar); + {$IFDEF MSWINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +//Procedure that loads a Custom Sound +function LoadSound(const Name: PChar): cardinal; + {$IFDEF MSWINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +//Plays a Custom Sound +procedure PlaySound(const Index: cardinal); + {$IFDEF MSWINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} //Utilys function ToSentences(Const Lines: TLines): TSentences; @@ -133,12 +112,12 @@ uses URecord, USkins; -// Method for input parsing. If False is returned, GetNextWindow +// Method for input parsing. If false is returned, GetNextWindow // should be checked to know the next window to load; -function TScreenSingModi.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenSingModi.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down case PressedKey of @@ -164,7 +143,7 @@ end; function ToSentences(Const Lines: TLines): TSentences; var - I, J: Integer; + I, J: integer; begin Result.Current := Lines.Current; Result.High := Lines.High; @@ -199,7 +178,7 @@ end; procedure TScreenSingModi.onShow; var - I: Integer; + I: integer; begin inherited; @@ -221,14 +200,14 @@ begin PlayerInfo.Playerinfo[I].Name := PChar(Ini.Name[I]); PlayerInfo.Playerinfo[I].Score := 0; PlayerInfo.Playerinfo[I].Bar := 50; - PlayerInfo.Playerinfo[I].Enabled := True; + 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; + PlayerInfo.Playerinfo[I].Enabled := false; end; {Case PlayersPlay of @@ -275,18 +254,22 @@ begin end; // Set Background (Little Workaround, maybe change sometime) - if (DLLMan.Selected.LoadBack) AND (DLLMan.Selected.LoadSong) then + if (DLLMan.Selected.LoadBack) and (DLLMan.Selected.LoadSong) then ScreenSing.Tex_Background := Tex_Background; Winner := 0; //Set Score Visibility - {if PlayersPlay = 1 then begin + Scores.Visible := DLLMan.Selected.ShowScore; + + {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 + if (PlayersPlay = 2) or (PlayersPlay = 4) then + begin Text[TextP1TwoPScore].Visible := DLLMan.Selected.ShowScore; Static[StaticP1TwoPScoreBG].Visible := DLLMan.Selected.ShowScore; @@ -294,7 +277,8 @@ begin Static[StaticP2RScoreBG].Visible := DLLMan.Selected.ShowScore; end; - if (PlayersPlay = 3) OR (PlayersPlay = 6) then begin + if (PlayersPlay = 3) or (PlayersPlay = 6) then + begin Text[TextP1ThreePScore].Visible := DLLMan.Selected.ShowScore; Static[StaticP1ThreePScoreBG].Visible := DLLMan.Selected.ShowScore; @@ -330,116 +314,39 @@ begin 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'); - - - + Background.Draw; - 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; + // draw background picture (if any, and if no visualizations) + // when we don't check for visualizations the visualizations would + // be overdrawn by the picture when {UNDEFINED UseTexture} in UVisualizer + if (DllMan.Selected.LoadSong) and (DllMan.Selected.LoadBack) and (not fShowVisualization) then + SingDrawBackground; - 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 + // 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 + Else 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; @@ -451,92 +358,6 @@ begin Static[StaticP2R].Texture.X := Static[StaticP2R].Texture.X + 10*ScreenX; Text[TextP2R].X := Text[TextP2R].X + 10*ScreenX; - {Static[StaticP2RScoreBG].Texture.X := Static[StaticP2RScoreBG].Texture.X + 10*ScreenX; - Text[TextP2RScore].X := Text[TextP2RScore].X + 10*ScreenX;} - - // .. and scores - {if PlayersPlay = 1 then begin - TextStr := IntToStr(Player[0].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP1Score].Text := TextStr; - end; - - if PlayersPlay = 2 then begin - TextStr := IntToStr(Player[0].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP1TwoPScore].Text := TextStr; - - TextStr := IntToStr(Player[1].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP2RScore].Text := TextStr; - end; - - if PlayersPlay = 3 then begin - TextStr := IntToStr(Player[0].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP1ThreePScore].Text := TextStr; - - TextStr := IntToStr(Player[1].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP2MScore].Text := TextStr; - - TextStr := IntToStr(Player[2].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP3RScore].Text := TextStr; - end; - - if PlayersPlay = 4 then begin - if ScreenAct = 1 then begin - TextStr := IntToStr(Player[0].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP1TwoPScore].Text := TextStr; - - TextStr := IntToStr(Player[1].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP2RScore].Text := TextStr; - end; - if ScreenAct = 2 then begin - TextStr := IntToStr(Player[2].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP1TwoPScore].Text := TextStr; - - TextStr := IntToStr(Player[3].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP2RScore].Text := TextStr; - end; - end; - - if PlayersPlay = 6 then begin - if ScreenAct = 1 then begin - TextStr := IntToStr(Player[0].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP1ThreePScore].Text := TextStr; - - TextStr := IntToStr(Player[1].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP2MScore].Text := TextStr; - - TextStr := IntToStr(Player[2].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP3RScore].Text := TextStr; - end; - if ScreenAct = 2 then begin - TextStr := IntToStr(Player[3].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP1ThreePScore].Text := TextStr; - - TextStr := IntToStr(Player[4].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP2MScore].Text := TextStr; - - TextStr := IntToStr(Player[5].ScoreTotalI); - while Length(TextStr) < 5 do TextStr := '0' + TextStr; - Text[TextP3RScore].Text := TextStr; - end; - end; } - - end; //ShowScore - for S := 1 to 1 do Static[S].Texture.X := Static[S].Texture.X + 10*ScreenX; @@ -557,30 +378,43 @@ begin 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 CurrentSong.VideoLoaded AND DllMan.Selected.LoadVideo then begin +{ if ShowFinish and CurrentSong.VideoLoaded and DllMan.Selected.LoadVideo then + begin UpdateSmpeg; // this only draws end;} + // update and draw movie + if (ShowFinish and (VideoLoaded or fShowVisualization) and DllMan.Selected.LoadVideo) then + begin + if assigned(fCurrentVideoPlaybackEngine) then + begin + // Just call this once + // when Screens = 2 + if (ScreenAct = 1) then + fCurrentVideoPlaybackEngine.GetFrame(CurrentSong.VideoGAP + LyricsState.GetCurrentTime()); + + fCurrentVideoPlaybackEngine.DrawGL(ScreenAct); + end; + end; + // draw static menu (FG) DrawFG; - if ShowFinish then begin + if ShowFinish then + begin if DllMan.Selected.LoadSong then begin - if (not AudioPlayback.Finished) and ((CurrentSong.Finish = 0) or (LyricsState.GetCurrentTime*1000 <= CurrentSong.Finish)) then begin + if (not AudioPlayback.Finished) and ((CurrentSong.Finish = 0) or (LyricsState.GetCurrentTime*1000 <= CurrentSong.Finish)) then + begin //Pause Mod: if not Paused then Sing(Self); // analyze song - end else begin - if not FadeOut then begin + end + else + begin + if not FadeOut then + begin Finish; FadeOut := true; FadeTo(@ScreenPartyScore); @@ -596,6 +430,9 @@ begin GoldenRec.SpawnRec; //GoldenNoteStarsTwinkle Mod + //Draw Score + Scores.Draw; + //Update PlayerInfo for I := 0 to PlayerInfo.NumPlayers-1 do begin @@ -606,14 +443,15 @@ begin end; end; - if ((ShowFinish) AND (NOT Paused)) then + if ((ShowFinish) and (not Paused)) then begin if not DLLMan.PluginDraw(Playerinfo, Lines[0].Current) then begin - if not FadeOut then begin - Finish; - FadeOut := true; - FadeTo(@ScreenPartyScore); + if not FadeOut then + begin + Finish; + FadeOut := true; + FadeTo(@ScreenPartyScore); end; end; end; @@ -637,14 +475,12 @@ begin {Static[StaticP1ScoreBG].Texture.X := Static[StaticP1ScoreBG].Texture.X - 10*ScreenX; Text[TextP1Score].X := Text[TextP1Score].X - 10*ScreenX;} - Static[StaticP2R].Texture.X := Static[StaticP2R].Texture.X - 10*ScreenX; Text[TextP2R].X := Text[TextP2R].X - 10*ScreenX; {Static[StaticP2RScoreBG].Texture.X := Static[StaticP2RScoreBG].Texture.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; @@ -665,13 +501,13 @@ Winner := DllMan.PluginFinish(PlayerInfo); //DLLMan.UnLoadPlugin; end; -function LoadTex (const Name: PChar; Typ: TTextureType): TsmallTexture; stdcall; +function LoadTex(const Name: PChar; Typ: TTextureType): TsmallTexture; var - Texname, EXT: String; + Texname, EXT: string; Tex: TTexture; begin //Get texture Name - TexName := Skin.GetTextureFileName(String(Name)); + TexName := Skin.GetTextureFileName(string(Name)); //Get File Typ Ext := ExtractFileExt(TexName); if (uppercase(Ext) = '.JPG') then @@ -688,10 +524,11 @@ end; { function Translate (const Name: PChar): PChar; stdcall; begin - Result := PChar(Language.Translate(String(Name))); + 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 +//Procedure to Print Text +procedure Print(const Style, Size: byte; const X, Y: real; const Text: PChar); begin SetFontItalic ((Style and 128) = 128); SetFontStyle(Style and 7); @@ -699,14 +536,15 @@ begin // used by Hold_The_Line / TeamDuell SetFontSize(Size); SetFontPos (X, Y); - glPrint (Language.Translate(String(Text))); + glPrint (Language.Translate(string(Text))); end; -function LoadSound(const Name: PChar): Cardinal; stdcall; //Procedure that loads a Custom Sound +//Procedure that loads a Custom Sound +function LoadSound(const Name: PChar): cardinal; var Stream: TAudioPlaybackStream; - i: Integer; - Filename: String; + i: integer; + Filename: string; begin //Search for Sound in already loaded Sounds Filename := UpperCase(SoundPath + Name); @@ -719,7 +557,7 @@ begin end; end; - Stream := AudioPlayback.OpenSound(SoundPath + String(Name)); + Stream := AudioPlayback.OpenSound(SoundPath + string(Name)); if (Stream = nil) then begin Result := 0; @@ -731,7 +569,8 @@ begin Result := High(CustomSounds); end; -procedure PlaySound(const Index: Cardinal); stdcall; //Plays a Custom Sound +//Plays a Custom Sound +procedure PlaySound(const Index: cardinal); begin if (Index <= High(CustomSounds)) then AudioPlayback.PlaySound(CustomSounds[Index].Stream); diff --git a/unicode/src/screens/UScreenSong.pas b/unicode/src/screens/UScreenSong.pas index da725a59..00d90930 100644 --- a/unicode/src/screens/UScreenSong.pas +++ b/unicode/src/screens/UScreenSong.pas @@ -33,24 +33,23 @@ interface {$I switches.inc} - uses - UMenu, - SDL, - UMusic, - UFiles, - UTime, - UDisplay, - USongs, SysUtils, + SDL, UCommon, - ULog, - UThemes, - UTexture, + UDisplay, + UFiles, + UIni, ULanguage, + ULog, + UMenu, + UMenuEqualizer, + UMusic, USong, - UIni, - UMenuEqualizer; + USongs, + UTexture, + UThemes, + UTime; type TScreenSong = class(TMenu) @@ -111,7 +110,6 @@ type StaticNonParty: array of cardinal; TextNonParty: array of cardinal; - constructor Create; override; procedure SetScroll; //procedure SetScroll1; @@ -121,6 +119,7 @@ type procedure SetScroll5; procedure SetScroll6; function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; + function ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean; override; function Draw: boolean; override; procedure GenerateThumbnails(); procedure onShow; override; @@ -142,7 +141,7 @@ type //procedures for Menu procedure StartSong; procedure OpenEditor; - procedure DoJoker(Team: Byte); + procedure DoJoker(Team: byte); procedure SelectPlayers; procedure UnloadDetailedCover; @@ -178,7 +177,7 @@ begin if CatSongs.VisibleSongs > 0 then begin I2:= 0; - for I := low(CatSongs.Song) to High(Catsongs.Song) do + for I := Low(CatSongs.Song) to High(Catsongs.Song) do begin if CatSongs.Song[I].Visible then inc(I2); @@ -199,7 +198,7 @@ begin if CatSongs.VisibleSongs > 0 then begin I2:= 0; - for I := low(CatSongs.Song) to High(Catsongs.Song) do + for I := Low(CatSongs.Song) to High(Catsongs.Song) do begin if CatSongs.Song[I].Visible then inc(I2); @@ -243,14 +242,13 @@ begin end; //Show Cat in Top Left Mod End - -// Method for input parsing. If False is returned, GetNextWindow +// Method for input parsing. If false is returned, GetNextWindow // should be checked to know the next window to load; function TScreenSong.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; var I: integer; I2: integer; - SDL_ModState: Word; + SDL_ModState: word; UpperLetter: UCS4Char; TempStr: UTF8String; begin @@ -286,7 +284,7 @@ begin //Jump To Titel if (SDL_ModState = (KMOD_LALT or KMOD_LSHIFT)) then begin - for I := 1 to high(CatSongs.Song) do + for I := 1 to High(CatSongs.Song) do begin if (CatSongs.Song[(I + Interaction) mod I2].Visible) then begin @@ -309,7 +307,7 @@ begin //Jump to Artist else if (SDL_ModState = KMOD_LALT) then begin - for I := 1 to high(CatSongs.Song) do + for I := 1 to High(CatSongs.Song) do begin if (CatSongs.Song[(I + Interaction) mod I2].Visible) then begin @@ -407,25 +405,25 @@ begin if (Songs.SongList.Count > 0) and (Mode = smNormal) then begin - if (SDL_ModState = KMOD_LSHIFT) and (Ini.TabsAtStartup = 1) then //Random Category + if (SDL_ModState = KMOD_LSHIFT) and (Ini.TabsAtStartup = 1) then // random category begin - I2 := 0; //Count Cats - for I:= 0 to high(CatSongs.Song) do + I2 := 0; // count cats + for I := 0 to High(CatSongs.Song) do begin if CatSongs.Song[I].Main then Inc(I2); end; - I2 := Random(I2)+1; //Zufall + I2 := Random(I2 + 1); // random and include I2 - //Find Cat: - for I:= 0 to high(CatSongs.Song) do + // find cat: + for I := 0 to High(CatSongs.Song) do begin if CatSongs.Song[I].Main then Dec(I2); - if (I2<=0) then + if (I2 <= 0) then begin - //Show Cat in Top Left Mod + // show cat in top left mod ShowCatTL (I); Interaction := I; @@ -438,38 +436,38 @@ begin end; end; end - else if (SDL_ModState = KMOD_LCTRL) and (Ini.TabsAtStartup = 1) then //random in All Categorys + else if (SDL_ModState = KMOD_LCTRL) and (Ini.TabsAtStartup = 1) then // random in all categories begin repeat - I2 := Random(high(CatSongs.Song)+1) + 1; + I2 := Random(High(CatSongs.Song) + 1); until (not CatSongs.Song[I2].Main); - //Search Cat + // search cat for I := I2 downto 0 do begin if CatSongs.Song[I].Main then break; end; - //In I is now the categorie in I2 the song + // in I is now the categorie in I2 the song - //Choose Cat + // choose cat CatSongs.ShowCategoryList; - //Show Cat in Top Left Mod + // show cat in top left mod ShowCatTL (I); CatSongs.ClickCategoryButton(I); SelectNext; - //Fix: Not Existing Song selected: - //if (I+1=I2) then - Inc(I2); + // Fix: not existing song selected: + //if (I + 1 = I2) then + Inc(I2); - //Choose Song - SkipTo(I2-I); + // choose song + SkipTo(I2 - I); end - else //Random in one Category + else // random in one category begin SkipTo(Random(CatSongs.VisibleSongs)); end; @@ -501,7 +499,7 @@ begin break; end; if (I <= 1) then - Interaction := high(CatSongs.Song) + Interaction := High(CatSongs.Song) else Interaction := I - 1; @@ -513,7 +511,6 @@ begin //Show Cat in Top Left Mod HideCatTL; - //Show Wrong Song when Tabs on Fix SelectNext; FixSelected; @@ -619,13 +616,13 @@ begin begin I := Interaction; if I <= 0 then - I := 1; + I := 1; while not catsongs.Song[I].Main do begin Inc (I); - if (I > high(catsongs.Song)) then - I := low(catsongs.Song); + if (I > High(catsongs.Song)) then + I := Low(catsongs.Song); end; Interaction := I; @@ -661,15 +658,15 @@ begin I := Interaction; I2 := 0; if I <= 0 then - I := 1; + 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); + if (I < Low(catsongs.Song)) then + I := High(catsongs.Song); end; Interaction := I; @@ -715,41 +712,61 @@ begin end; SDLK_1: - begin //Joker // to-do : Party - {if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 1) and (PartySession.Teams.Teaminfo[0].Joker > 0) then + begin //Joker + if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 1) and (PartySession.Teams.Teaminfo[0].Joker > 0) then begin //Use Joker Dec(PartySession.Teams.Teaminfo[0].Joker); SelectRandomSong; SetJoker; - end; } + end; end; SDLK_2: begin //Joker - {if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 2) and (PartySession.Teams.Teaminfo[1].Joker > 0) then + if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 2) and (PartySession.Teams.Teaminfo[1].Joker > 0) then begin //Use Joker Dec(PartySession.Teams.Teaminfo[1].Joker); SelectRandomSong; SetJoker; - end; } + end; end; SDLK_3: begin //Joker - {if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 3) and (PartySession.Teams.Teaminfo[2].Joker > 0) then + if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 3) and (PartySession.Teams.Teaminfo[2].Joker > 0) then begin //Use Joker Dec(PartySession.Teams.Teaminfo[2].Joker); SelectRandomSong; SetJoker; - end; } + end; end; end; end; // if (PressedDown) end; +function TScreenSong.ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean; +begin + Result := true; + + if RightMbESC and (MouseButton = SDL_BUTTON_RIGHT) and BtnDown then + //if RightMbESC is set, send ESC keypress + Result:=ParseInput(SDLK_ESCAPE, 0, true); + + //song scrolling with mousewheel + if (MouseButton = SDL_BUTTON_WHEELDOWN) and BtnDown then + ParseInput(SDLK_RIGHT, 0, true); + + if (MouseButton = SDL_BUTTON_WHEELUP) and BtnDown then + ParseInput(SDLK_LEFT, 0, true); + + //LMB anywhere starts + if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then + ParseInput(SDLK_RETURN, 0, true); +end; + constructor TScreenSong.Create; var i: integer; @@ -811,7 +828,6 @@ begin GenerateThumbnails(); - // Randomize Patch Randomize; @@ -966,7 +982,6 @@ begin if CatSongs.Song[B].Visible then Inc(VisInt); - if VisCount <= 6 then begin Typ := 0; @@ -995,7 +1010,6 @@ begin end; - // hide all buttons for B := 0 to High(Button) do begin @@ -1013,7 +1027,6 @@ begin end; } - if Typ = 0 then begin for B := 0 to High(Button) do @@ -1310,27 +1323,26 @@ begin if Button[B].Visible then // optimization for 1000 songs - updates only visible songs, hiding in tabs becomes useful for maintaing good speed begin - Factor := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS {CatSongs.VisibleSongs};// 0.5.0 (II): takes another 16ms - - Z := (1 + cos(Factor)) / 2; - Z2 := (1 + 2*Z) / 3; + Factor := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS {CatSongs.VisibleSongs};// 0.5.0 (II): takes another 16ms + Z := (1 + cos(Factor)) / 2; + Z2 := (1 + 2*Z) / 3; - Button[B].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Factor)) * 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].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Factor)) * 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].W := Theme.Song.Cover.H * Z2; - //Button[B].Y := {50 +} 140 + 50 - 50 * Z2; - Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.H - Abs(Button[B].H)) * 0.7 ; - Button[B].H := Button[B].W; + //Button[B].Y := {50 +} 140 + 50 - 50 * Z2; + Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.H - Abs(Button[B].H)) * 0.7 ; + Button[B].H := Button[B].W; end; end; end else begin //Change Pos of all Buttons - for B := low(Button) to high(Button) do + for B := Low(Button) to High(Button) do begin Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility if Button[B].Visible then //Only Change Pos for Visible Buttons @@ -1358,7 +1370,6 @@ begin Diff := (Button[B].H - Theme.Song.Cover.H)/2; - X := Sin(Angle*1.3)*0.9; Button[B].Y := Theme.Song.Cover.Y + Theme.Song.Cover.W * X - Diff; @@ -1368,9 +1379,9 @@ begin // limit-bg-covers hack if (abs(VS/2-abs(Pos))>10) then - Button[B].Visible := false; + Button[B].Visible := false; if VS > 25 then - VS:=25; + VS:=25; // end of limit-bg-covers hack if Pos < 0 then @@ -1388,7 +1399,6 @@ begin Button[B].X := Theme.Song.Cover.X - (Button[B].H - Theme.Song.Cover.H)*0.5; - Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; Button[B].Y := Theme.Song.Cover.Y+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*(Theme.Song.Cover.H*sin(Angle/2)*1.52); @@ -1398,7 +1408,6 @@ begin end; end; - procedure TScreenSong.onShow; begin inherited; @@ -1462,7 +1471,7 @@ begin AudioPlayback.SetVolume(1.0); // if preview is deactivated: load musicfile now - If (IPreviewVolumeVals[Ini.PreviewVolume] = 0) then + if (IPreviewVolumeVals[Ini.PreviewVolume] = 0) then AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); // if hide then stop music (for party mode popup on exit) @@ -1722,41 +1731,40 @@ var I, I2: integer; begin case PlaylistMan.Mode of - smNormal: //All Songs Just Select Random Song + smNormal: // all songs just select random song begin - //When Tabs are activated then use Tab Method + // when tabs are activated then use tab method if (Ini.TabsAtStartup = 1) then begin repeat - I2 := Random(high(CatSongs.Song)+1) - low(CatSongs.Song)+1; + I2 := Low(CatSongs.Song) + Random(High(CatSongs.Song) + 1 - Low(CatSongs.Song)); until CatSongs.Song[I2].Main = false; - //Search Cat - for I := I2 downto low(CatSongs.Song) do + // 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 + // I is the cat number, I2 is the no of the song within this cat - //Choose Cat + // choose cat CatSongs.ShowCategoryList; - //Show Cat in Top Left Mod - ShowCatTL (I); + // show cat in top left mod + ShowCatTL(I); CatSongs.ClickCategoryButton(I); SelectNext; - //Choose Song - SkipTo(I2-I); + // choose song + SkipTo(I2 - I); end - //When Tabs are deactivated use easy Method + // when tabs are deactivated use easy method else SkipTo(Random(CatSongs.VisibleSongs)); end; - smPartyMode: //One Category Select Category and Select Random Song + smPartyMode: // one category select category and select random song begin CatSongs.ShowCategoryList; CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); @@ -1767,7 +1775,7 @@ begin SkipTo(Random(CatSongs.VisibleSongs)); end; - smPlaylistRandom: //Playlist: Select Playlist and Select Random Song + smPlaylistRandom: // playlist: select playlist and select random song begin PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); @@ -1784,10 +1792,8 @@ end; procedure TScreenSong.SetJoker; begin // If Party Mode - // to-do : Party if Mode = smPartyMode then //Show Joker that are available begin - (* if (PartySession.Teams.NumTeams >= 1) then begin Static[StaticTeam1Joker1].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 1); @@ -1838,7 +1844,6 @@ begin Static[StaticTeam3Joker4].Visible := false; Static[StaticTeam3Joker5].Visible := false; end; - *) end else begin //Hide all @@ -1870,19 +1875,19 @@ begin //Set Visibility of Party Statics and Text Visible := (Mode = smPartyMode); - for I := 0 to high(StaticParty) do + for I := 0 to High(StaticParty) do Static[StaticParty[I]].Visible := Visible; - for I := 0 to high(TextParty) do + 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 + for I := 0 to High(StaticNonParty) do Static[StaticNonParty[I]].Visible := Visible; - for I := 0 to high(TextNonParty) do + for I := 0 to High(TextNonParty) do Text[TextNonParty[I]].Visible := Visible; end; @@ -1927,9 +1932,8 @@ begin end; //Team No of Team (0-5) -procedure TScreenSong.DoJoker (Team: Byte); +procedure TScreenSong.DoJoker (Team: byte); begin - { if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= Team + 1) and (PartySession.Teams.Teaminfo[Team].Joker > 0) then @@ -1939,7 +1943,6 @@ begin SelectRandomSong; SetJoker; end; - } end; //Detailed Cover Unloading. Unloads the Detailed, uncached Cover of the cur. Song diff --git a/unicode/src/screens/UScreenSongJumpto.pas b/unicode/src/screens/UScreenSongJumpto.pas index b6979f63..7405742a 100644 --- a/unicode/src/screens/UScreenSongJumpto.pas +++ b/unicode/src/screens/UScreenSongJumpto.pas @@ -34,9 +34,9 @@ interface {$I switches.inc} uses - SDL, SysUtils, UMenu, + SDL, UDisplay, UMusic, UFiles, @@ -47,20 +47,20 @@ type TScreenSongJumpto = class(TMenu) private //For ChangeMusic - fLastPlayed: Integer; - fVisible: Boolean; + fLastPlayed: integer; + fVisible: boolean; fSelectType: TSongFilter; - fVisSongs: Integer; + fVisSongs: integer; - procedure SetTextFound(Count: Cardinal); + procedure SetTextFound(const Count: cardinal); //Visible //Whether the Menu should be Drawn //Whether the Menu should be Drawn - procedure SetVisible(Value: Boolean); + procedure SetVisible(Value: boolean); public constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; function Draw: boolean; override; @@ -80,10 +80,10 @@ uses ULog, UUnicodeUtils; -function TScreenSongJumpto.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenSongJumpto.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys if (IsAlphaNumericChar(CharCode) or @@ -100,7 +100,7 @@ begin case PressedKey of SDLK_BACKSPACE: begin - if (Interaction = 0) AND (Length(Button[0].Text[0].Text) > 0) then + if (Interaction = 0) and (Length(Button[0].Text[0].Text) > 0) then begin Button[0].Text[0].DeleteLastLetter(); SetTextFound(CatSongs.SetFilter(Button[0].Text[0].Text, fSelectType)); @@ -110,9 +110,9 @@ begin SDLK_RETURN, SDLK_ESCAPE: begin - Visible := False; + Visible := false; AudioPlayback.PlaySound(SoundLib.Back); - if (fVisSongs = 0) AND (Length(Button[0].Text[0].Text) > 0) then + if (fVisSongs = 0) and (Length(Button[0].Text[0].Text) > 0) then begin ScreenSong.UnLoadDetailedCover; Button[0].Text[0].Text := ''; @@ -168,15 +168,14 @@ begin fSelectType := fltAll; AddSelectSlide(Theme.SongJumpto.SelectSlideType, PInteger(@fSelectType)^, Theme.SongJumpto.IType); - Interaction := 0; fLastPlayed := 0; end; -procedure TScreenSongJumpto.SetVisible(Value: Boolean); +procedure TScreenSongJumpto.SetVisible(Value: boolean); begin //If change from invisible to Visible then OnShow - if (fVisible = False) AND (Value = True) then + if (fVisible = false) and (Value = true) then OnShow; fVisible := Value; @@ -197,7 +196,7 @@ begin //Select Input Interaction := 0; - Button[0].Text[0].Selected := True; + Button[0].Text[0].Selected := true; fLastPlayed := ScreenSong.Interaction; end; @@ -207,7 +206,7 @@ begin Result := inherited Draw; end; -procedure TScreenSongJumpto.SetTextFound(Count: Cardinal); +procedure TScreenSongJumpto.SetTextFound(const Count: cardinal); begin if (Count = 0) then begin @@ -225,7 +224,6 @@ begin ScreenSong.ShowCatTLCustom(Format(Theme.SongJumpto.CatText, [Button[0].Text[0].Text])); end; - //Set visSongs fVisSongs := Count; diff --git a/unicode/src/screens/UScreenSongMenu.pas b/unicode/src/screens/UScreenSongMenu.pas index b8720b86..e09dd9b5 100644 --- a/unicode/src/screens/UScreenSongMenu.pas +++ b/unicode/src/screens/UScreenSongMenu.pas @@ -196,7 +196,6 @@ begin SetLength(ISelections, 1); ISelections[0] := 'Dummy'; - AddText(Theme.SongMenu.TextMenu); LoadFromTheme(Theme.SongMenu); @@ -402,19 +401,16 @@ begin begin CurMenu := sMenu; Text[0].Text := Language.Translate('SONG_MENU_NAME_PARTY_JOKER'); - // to-do : Party -{ - Button[0].Visible := (PartySession.Teams.NumTeams >= 1) and (PartySession.Teams.Teaminfo[0].Joker > 0); + + 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[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 @@ -425,10 +421,10 @@ begin if (not Button[2].Visible) then Interaction := 4 else - Interaction := 2; + Interaction := 2; end else - Interaction := 1; + Interaction := 1; end; end; diff --git a/unicode/src/screens/UScreenStatDetail.pas b/unicode/src/screens/UScreenStatDetail.pas index 6241ee2e..5a0419b7 100644 --- a/unicode/src/screens/UScreenStatDetail.pas +++ b/unicode/src/screens/UScreenStatDetail.pas @@ -47,21 +47,20 @@ type TScreenStatDetail = class(TMenu) public Typ: TStatType; - Page: Cardinal; - Count: Byte; - Reversed: Boolean; - - TotEntrys: Cardinal; - TotPages: Cardinal; + Page: cardinal; + Count: byte; + Reversed: boolean; + TotEntrys: cardinal; + TotPages: cardinal; constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; procedure SetAnimationProgress(Progress: real); override; procedure SetTitle; - Procedure SetPage(NewPage: Cardinal); + Procedure SetPage(NewPage: cardinal); end; implementation @@ -74,10 +73,10 @@ uses ULog, UUnicodeUtils; -function TScreenStatDetail.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenStatDetail.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of @@ -98,24 +97,28 @@ begin end; SDLK_RETURN: begin - if Interaction = 0 then begin + if Interaction = 0 then + begin //Next Page SetPage(Page+1); end; - if Interaction = 1 then begin + if Interaction = 1 then + begin //Previous Page if (Page > 0) then SetPage(Page-1); end; - if Interaction = 2 then begin + if Interaction = 2 then + begin //Reverse Order Reversed := not Reversed; SetPage(Page); end; - if Interaction = 3 then begin + if Interaction = 3 then + begin AudioPlayback.PlaySound(SoundLib.Back); FadeTo(@ScreenStatMain); end; @@ -188,7 +191,7 @@ begin SetTitle; //Show First Page - Reversed := False; + Reversed := false; SetPage(0); end; @@ -200,12 +203,12 @@ begin Text[Count].Text := Theme.StatDetail.Description[Ord(Typ)]; end; -procedure TScreenStatDetail.SetPage(NewPage: Cardinal); +procedure TScreenStatDetail.SetPage(NewPage: cardinal); var StatList: TList; - I: Integer; - FormatStr: String; - PerPage: Byte; + I: integer; + FormatStr: string; + PerPage: byte; begin // fetch statistics StatList := Database.GetStats(Typ, Count, NewPage, Reversed); @@ -289,9 +292,9 @@ begin Database.FreeStats(StatList); end; - procedure TScreenStatDetail.SetAnimationProgress(Progress: real); -var I: Integer; +var + I: integer; begin for I := 0 to High(Button) do Button[I].Texture.ScaleW := Progress; diff --git a/unicode/src/screens/UScreenStatMain.pas b/unicode/src/screens/UScreenStatMain.pas index a183f04c..6d4d3f5b 100644 --- a/unicode/src/screens/UScreenStatMain.pas +++ b/unicode/src/screens/UScreenStatMain.pas @@ -46,14 +46,14 @@ type TScreenStatMain = class(TMenu) private //Some Stat Value that don't need to be calculated 2 times - SongsWithVid: Cardinal; + SongsWithVid: cardinal; function FormatOverviewIntro(FormatStr: string): string; function FormatSongOverview(FormatStr: string): string; function FormatPlayerOverview(FormatStr: string): string; public TextOverview: integer; constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; procedure onShow; override; procedure SetAnimationProgress(Progress: real); override; @@ -73,10 +73,10 @@ uses ULog, UUnicodeUtils; -function TScreenStatMain.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenStatMain.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then + if (PressedDown) then begin // Key Down // check normal keys case UCS4UpperCase(CharCode) of @@ -165,7 +165,7 @@ begin //Set Songs with Vid SongsWithVid := 0; - For I := 0 to Songs.SongList.Count -1 do + for I := 0 to Songs.SongList.Count -1 do if (TSong(Songs.SongList[I]).Video <> '') then Inc(SongsWithVid); end; @@ -180,7 +180,7 @@ end; function TScreenStatMain.FormatOverviewIntro(FormatStr: string): string; var - Year, Month, Day: Word; + Year, Month, Day: word; begin {Format: %0:d Ultrastar Version @@ -201,8 +201,8 @@ end; function TScreenStatMain.FormatSongOverview(FormatStr: string): string; var - CntSongs, CntSungSongs, CntVidSongs: Integer; - MostPopSongArtist, MostPopSongTitle: String; + CntSongs, CntSungSongs, CntVidSongs: integer; + MostPopSongArtist, MostPopSongTitle: string; StatList: TList; MostSungSong: TStatResultMostSungSong; begin @@ -217,7 +217,7 @@ begin CntSungSongs := Database.GetTotalEntrys(stMostSungSong); CntVidSongs := SongsWithVid; - StatList := Database.GetStats(stMostSungSong, 1, 0, False); + StatList := Database.GetStats(stMostSungSong, 1, 0, false); if ((StatList <> nil) and (StatList.Count > 0)) then begin MostSungSong := StatList[0]; @@ -245,11 +245,11 @@ end; function TScreenStatMain.FormatPlayerOverview(FormatStr: string): string; var - CntPlayers: Integer; + CntPlayers: integer; BestScoreStat: TStatResultBestScores; BestSingerStat: TStatResultBestSingers; - BestPlayer, BestScorePlayer: String; - BestPlayerScore, BestScore: Integer; + BestPlayer, BestScorePlayer: string; + BestPlayerScore, BestScore: integer; SingerStats, ScoreStats: TList; begin {Format: @@ -261,7 +261,7 @@ begin CntPlayers := Database.GetTotalEntrys(stBestSingers); - SingerStats := Database.GetStats(stBestSingers, 1, 0, False); + SingerStats := Database.GetStats(stBestSingers, 1, 0, false); if ((SingerStats <> nil) and (SingerStats.Count > 0)) then begin BestSingerStat := SingerStats[0]; @@ -275,7 +275,7 @@ begin end; Database.FreeStats(SingerStats); - ScoreStats := Database.GetStats(stBestScores, 1, 0, False); + ScoreStats := Database.GetStats(stBestScores, 1, 0, false); if ((ScoreStats <> nil) and (ScoreStats.Count > 0)) then begin BestScoreStat := ScoreStats[0]; @@ -303,7 +303,7 @@ end; procedure TScreenStatMain.SetOverview; var - Overview: String; + Overview: string; begin // Format overview Overview := FormatOverviewIntro(Language.Translate('STAT_OVERVIEW_INTRO')) + '\n \n' + @@ -312,11 +312,11 @@ begin Text[0].Text := Overview; end; - procedure TScreenStatMain.SetAnimationProgress(Progress: real); -var I: Integer; +var + I: integer; begin - For I := 0 to high(Button) do + for I := 0 to high(Button) do Button[I].Texture.ScaleW := Progress; end; diff --git a/unicode/src/screens/UScreenTop5.pas b/unicode/src/screens/UScreenTop5.pas index eaa90ab1..eeec8ed7 100644 --- a/unicode/src/screens/UScreenTop5.pas +++ b/unicode/src/screens/UScreenTop5.pas @@ -57,6 +57,7 @@ type constructor Create; override; function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; + function ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean; override; procedure onShow; override; function Draw: boolean; override; end; @@ -71,10 +72,12 @@ uses UNote, UUnicodeUtils; -function TScreenTop5.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; +function TScreenTop5.ParseInput(PressedKey: cardinal; + CharCode: UCS4Char; + PressedDown: boolean): boolean; begin Result := true; - if (PressedDown) then + if PressedDown then begin // check normal keys case UCS4UpperCase(CharCode) of @@ -92,7 +95,7 @@ begin SDLK_RETURN: begin if (not Fadeout) then - begin + begin FadeTo(@ScreenSong); Fadeout := true; end; @@ -105,6 +108,16 @@ begin end; end; +function TScreenTop5.ParseMouse(MouseButton: integer; + BtnDown: boolean; + X, Y: integer): boolean; +begin + Result := true; + if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then + //left-click anywhere sends return + ParseInput(SDLK_RETURN, 0, true); +end; + constructor TScreenTop5.Create; var I: integer; @@ -113,19 +126,16 @@ begin LoadFromTheme(Theme.Top5); - - TextLevel := AddText(Theme.Top5.TextLevel); + 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]); + begin + StaticNumber[I+1] := AddStatic(Theme.Top5.StaticNumber[I]); + TextNumber[I+1] := AddText (Theme.Top5.TextNumber[I]); + TextName[I+1] := AddText (Theme.Top5.TextName[I]); + TextScore[I+1] := AddText (Theme.Top5.TextScore[I]); + end; end; @@ -162,7 +172,7 @@ begin Text[TextScore[I]].Text := IntToStr(CurrentSong.Score[Ini.Difficulty, I-1].Score); end; - for I := Length(CurrentSong.Score[Ini.Difficulty])+1 to 5 do + for I := Length(CurrentSong.Score[Ini.Difficulty]) + 1 to 5 do begin Static[StaticNumber[I]].Visible := false; Text[TextNumber[I]].Visible := false; diff --git a/unicode/src/screens/UScreenWelcome.pas b/unicode/src/screens/UScreenWelcome.pas index 4df2b6f7..b798629f 100644 --- a/unicode/src/screens/UScreenWelcome.pas +++ b/unicode/src/screens/UScreenWelcome.pas @@ -34,7 +34,10 @@ interface {$I switches.inc} uses - UMenu, SDL, SysUtils, UThemes; + UMenu, + SDL, + SysUtils, + UThemes; type TScreenWelcome = class(TMenu) @@ -42,24 +45,29 @@ type Animation: real; Fadeout: boolean; constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; function Draw: boolean; override; procedure onShow; override; end; implementation -uses UGraphic, UTime, USkins, UTexture; +uses + UGraphic, + UTime, + USkins, + UTexture; -function TScreenWelcome.ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: Boolean): Boolean; +function TScreenWelcome.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; - If (PressedDown) Then begin + if (PressedDown) then + begin case PressedKey of SDLK_ESCAPE, SDLK_BACKSPACE : begin - Result := False; + Result := false; end; SDLK_RETURN: begin @@ -102,12 +110,14 @@ begin // draw nothing Min := 0; Max := 1000; - if (Animation >= Min) and (Animation < Max) then begin + if (Animation >= Min) and (Animation < Max) then + begin end; // popup Min := 1000; Max := 1120; - if (Animation >= Min) and (Animation < Max) then begin + if (Animation >= Min) and (Animation < Max) then + begin Factor := (Animation - Min) / (Max - Min); Static[0].Texture.X := 600; Static[0].Texture.Y := 600 - Factor * 230; @@ -117,7 +127,8 @@ begin // bounce Min := 1120; Max := 1200; - if (Animation >= Min) and (Animation < Max) then begin + if (Animation >= Min) and (Animation < Max) then + begin Factor := (Animation - Min) / (Max - Min); Static[0].Texture.Y := 370 + Factor * 50; Static[0].Texture.H := 230 - Factor * 50; @@ -125,14 +136,15 @@ begin // run Min := 1500; Max := 3500; - if (Animation >= Min) and (Animation < Max) then begin + if (Animation >= Min) and (Animation < Max) then + begin Factor := (Animation - Min) / (Max - Min); Static[0].Texture.X := 600 - Factor * 1400; Static[0].Texture.H := 180; - - for Count := 1 to 5 do begin + for Count := 1 to 5 do + begin Static[Count].Texture.X := 770 - Factor * 1400; Static[Count].Texture.W := 150 + Factor * 200; Static[Count].Texture.Alpha := Factor * 0.5; @@ -140,7 +152,8 @@ begin end; Min := 3500; - if (Animation >= Min) and (not Fadeout) then begin + if (Animation >= Min) and (not Fadeout) then + begin FadeTo(@ScreenMain); Fadeout := true; end; diff --git a/unicode/src/ultrastardx.dpr b/unicode/src/ultrastardx.dpr index 9bcc4aca..f6376365 100644 --- a/unicode/src/ultrastardx.dpr +++ b/unicode/src/ultrastardx.dpr @@ -203,6 +203,7 @@ uses USingNotes in 'base\USingNotes.pas', UPath in 'base\UPath.pas', UNote in 'base\UNote.pas', + UBeatTimer in 'base\UBeatTimer.pas', TextGL in 'base\TextGL.pas', UUnicodeUtils in 'base\UUnicodeUtils.pas', @@ -215,22 +216,6 @@ uses //------------------------------ //Includes - Plugin Support //------------------------------ - {UPluginDefines in 'pluginsupport\UPluginDefines.pas', - UPartyDefines in 'pluginsupport\UPartyDefines.pas', - - UPartyMode in 'pluginsupport\UPartyMode.pas', - UPartyManager in 'pluginsupport\UPartyManager.pas', - UPartyModePlugin in 'pluginsupport\UPartyModePlugin.pas', - UPluginLoader in 'pluginsupport\UPluginLoader.pas', } - - UModules in 'base\UModules.pas', //List of Modules to Load - UHooks in 'base\UHooks.pas', //Hook Managing - UServices in 'base\UServices.pas', //Service Managing - UCore in 'base\UCore.pas', //Core, Maybe remove this - UCoreModule in 'base\UCoreModule.pas', //^ - UPluginInterface in 'base\UPluginInterface.pas', //Interface offered by Core to Plugins - UPluginLoader in 'base\UPluginLoader.pas', //New Plugin Loader Module - UParty in 'base\UParty.pas', // TODO: rewrite Party Manager as Module, reomplent ability to offer party Mody by Plugin //------------------------------ @@ -254,7 +239,7 @@ uses UAudioPlaybackBase in 'media\UAudioPlaybackBase.pas', {$IF Defined(UsePortaudioPlayback) or Defined(UseSDLPlayback)} UFFT in 'lib\fft\UFFT.pas', - UAudioPlayback_Softmixer in 'media\UAudioPlayback_SoftMixer.pas', + UAudioPlayback_SoftMixer in 'media\UAudioPlayback_SoftMixer.pas', {$IFEND} UAudioConverter in 'media\UAudioConverter.pas', @@ -342,8 +327,6 @@ uses //Includes - Modi SDK //------------------------------ ModiSDK in '..\plugins\SDK\ModiSDK.pas', //Old SDK, will be deleted soon - UPluginDefs in '..\plugins\SDK\UPluginDefs.pas', //New SDK, not only Modis - UPartyDefs in '..\plugins\SDK\UPartyDefs.pas', //Headers to register Party Modes SysUtils; |