aboutsummaryrefslogtreecommitdiffstats
path: root/unicode/src/base
diff options
context:
space:
mode:
Diffstat (limited to 'unicode/src/base')
-rw-r--r--unicode/src/base/UBeatTimer.pas170
-rw-r--r--unicode/src/base/UCommon.pas87
-rw-r--r--unicode/src/base/UConfig.pas2
-rw-r--r--unicode/src/base/UDLLManager.pas194
-rw-r--r--unicode/src/base/UDraw.pas2
-rw-r--r--unicode/src/base/UEditorLyrics.pas12
-rw-r--r--unicode/src/base/UGraphic.pas34
-rw-r--r--unicode/src/base/UImage.pas41
-rw-r--r--unicode/src/base/UIni.pas272
-rw-r--r--unicode/src/base/UMain.pas89
-rw-r--r--unicode/src/base/UMusic.pas134
-rw-r--r--unicode/src/base/UNote.pas2
-rw-r--r--unicode/src/base/UParty.pas594
-rw-r--r--unicode/src/base/UPlatform.pas24
-rw-r--r--unicode/src/base/URecord.pas10
-rw-r--r--unicode/src/base/USingScores.pas646
-rw-r--r--unicode/src/base/USongs.pas180
-rw-r--r--unicode/src/base/UTexture.pas4
-rw-r--r--unicode/src/base/UThemes.pas33
-rw-r--r--unicode/src/base/UTime.pas28
20 files changed, 1322 insertions, 1236 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);