diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-05-08 18:31:08 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-05-08 18:31:08 +0000 |
commit | 2a708a74d0a2e9a26caeb6bacf9f252102c89326 (patch) | |
tree | ef5ae378fdf4430297e25f052f29fc862f02b9e0 /Game/Code/Classes/UCatCovers.pas | |
parent | 9aa48684216b0dca926fa7e68a1b843dc1a872ce (diff) | |
download | usdx-2a708a74d0a2e9a26caeb6bacf9f252102c89326.tar.gz usdx-2a708a74d0a2e9a26caeb6bacf9f252102c89326.tar.xz usdx-2a708a74d0a2e9a26caeb6bacf9f252102c89326.zip |
added "inherited ..." to all constructors to assure that the base-class constructor is called.
Different to C or Java, the constructor or destructor of the base class (except that of TObject) is not called by default if "inherited ..." is not given (very strange). This is no problem with classes inherited directly from TObject, because the TObject constructor is always called (and sets the values of the fields to 0-values) but i added inherited to these constructors too because the base class may change from TObject to something different and the "inherited" will probably not added in this case and causing problems.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1070 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | Game/Code/Classes/UCatCovers.pas | 153 |
1 files changed, 76 insertions, 77 deletions
diff --git a/Game/Code/Classes/UCatCovers.pas b/Game/Code/Classes/UCatCovers.pas index 516544be..d8cebffa 100644 --- a/Game/Code/Classes/UCatCovers.pas +++ b/Game/Code/Classes/UCatCovers.pas @@ -24,18 +24,21 @@ type end;
var
-CatCovers: TCatCovers;
+ CatCovers: TCatCovers;
implementation
-uses IniFiles,
- SysUtils,
- Classes,
- // UFiles,
- UMain,
- ULog;
+
+uses
+ IniFiles,
+ SysUtils,
+ Classes,
+ // UFiles,
+ UMain,
+ ULog;
constructor TCatCovers.Create;
begin
+ inherited;
Load;
end;
@@ -48,104 +51,100 @@ var I, J: Integer;
Name, Filename, Temp: string;
begin
-try
- Ini := TMemIniFile.Create(CoversPath + 'covers.ini');
- List := TStringlist.Create;
-
- //Add every Cover in Covers Ini for Every Sorting option
- for I := low(ISorting) to high(ISorting) do
- begin
- Ini.ReadSection(ISorting[I], List);
-
- for J := 0 to List.Count - 1 do
- Add(I, List.Strings[J], CoversPath + Ini.ReadString(ISorting[I], List.Strings[J], 'NoCover.jpg'));
+ try
+ Ini := TMemIniFile.Create(CoversPath + 'covers.ini');
+ List := TStringlist.Create;
+
+ //Add every Cover in Covers Ini for Every Sorting option
+ for I := low(ISorting) to high(ISorting) do
+ begin
+ Ini.ReadSection(ISorting[I], List);
+
+ for J := 0 to List.Count - 1 do
+ Add(I, List.Strings[J], CoversPath + Ini.ReadString(ISorting[I], List.Strings[J], 'NoCover.jpg'));
+ end;
+ finally
+ Ini.Free;
+ List.Free;
end;
-finally
- Ini.Free;
- List.Free;
-end;
-
-try
- //Add Covers from Folder
- if (FindFirst (CoversPath + '*.jpg', faAnyFile, SR) = 0) then
- repeat
- //Add Cover if it doesn't exist for every Section
- Name := SR.Name;
- Filename := CoversPath + Name;
- Delete (Name, length(Name) - 3, 4);
-
- for I := low(ISorting) to high(ISorting) do
- begin
- Temp := Name;
- if ((I = sTitle) or (I = sTitle2)) and (Pos ('Title', Temp) <> 0) then
- Delete (Temp, Pos ('Title', Temp), 5)
- else if (I = sArtist) or (I = sArtist2) and (Pos ('Artist', Temp) <> 0) then
- Delete (Temp, Pos ('Artist', Temp), 6);
-
- if not CoverExists(I, Temp) then
- Add (I, Temp, Filename);
- end;
- until FindNext (SR) <> 0;
-
-finally
- FindClose (SR);
-end;
-
+ try
+ //Add Covers from Folder
+ if (FindFirst (CoversPath + '*.jpg', faAnyFile, SR) = 0) then
+ repeat
+ //Add Cover if it doesn't exist for every Section
+ Name := SR.Name;
+ Filename := CoversPath + Name;
+ Delete (Name, length(Name) - 3, 4);
+
+ for I := low(ISorting) to high(ISorting) do
+ begin
+ Temp := Name;
+ if ((I = sTitle) or (I = sTitle2)) and (Pos ('Title', Temp) <> 0) then
+ Delete (Temp, Pos ('Title', Temp), 5)
+ else if (I = sArtist) or (I = sArtist2) and (Pos ('Artist', Temp) <> 0) then
+ Delete (Temp, Pos ('Artist', Temp), 6);
+
+ if not CoverExists(I, Temp) then
+ Add (I, Temp, Filename);
+ end;
+ until FindNext (SR) <> 0;
+ finally
+ FindClose (SR);
+ end;
end;
//Add a Cover
procedure TCatCovers.Add(Sorting: integer; Name, Filename: string);
begin
-if FileExists (Filename) then //If Exists -> Add
-begin
-SetLength (CNames[Sorting], Length(CNames[Sorting]) + 1);
-SetLength (CFiles[Sorting], Length(CNames[Sorting]) + 1);
+ if FileExists (Filename) then //If Exists -> Add
+ begin
+ SetLength (CNames[Sorting], Length(CNames[Sorting]) + 1);
+ SetLength (CFiles[Sorting], Length(CNames[Sorting]) + 1);
-CNames[Sorting][high(cNames[Sorting])] := Uppercase(Name);
-CFiles[Sorting][high(cNames[Sorting])] := FileName;
-end;
+ CNames[Sorting][high(cNames[Sorting])] := Uppercase(Name);
+ CFiles[Sorting][high(cNames[Sorting])] := FileName;
+ end;
end;
//Returns True when a cover with the given Name exists
function TCatCovers.CoverExists(Sorting: integer; Name: string): boolean;
var
-I: Integer;
+ I: Integer;
begin
-Result := False;
-Name := Uppercase(Name); //Case Insensitiv
+ Result := False;
+ Name := Uppercase(Name); //Case Insensitiv
-for I := low(cNames[Sorting]) to high(cNames[Sorting]) do
-begin
- if (cNames[Sorting][I] = Name) then //Found Name
+ for I := low(cNames[Sorting]) to high(cNames[Sorting]) do
begin
- Result := true;
- break; //Break For Loop
+ if (cNames[Sorting][I] = Name) then //Found Name
+ begin
+ Result := true;
+ break; //Break For Loop
+ end;
end;
end;
-end;
//Returns the Filename of a Cover
function TCatCovers.GetCover(Sorting: integer; Name: string): string;
var
I: Integer;
begin
-Result := '';
-Name := Uppercase(Name);
+ Result := '';
+ Name := Uppercase(Name);
-for I := low(cNames[Sorting]) to high(cNames[Sorting]) do
-begin
- if cNames[Sorting][I] = Name then
+ for I := low(cNames[Sorting]) to high(cNames[Sorting]) do
begin
- Result := cFiles[Sorting][I];
- Break;
+ if cNames[Sorting][I] = Name then
+ begin
+ Result := cFiles[Sorting][I];
+ Break;
+ end;
end;
-end;
-
-//No Cover
-if (Result = '') AND (FileExists(CoversPath + 'NoCover.jpg')) then
- Result := CoversPath + 'NoCover.jpg';
+ //No Cover
+ if (Result = '') AND (FileExists(CoversPath + 'NoCover.jpg')) then
+ Result := CoversPath + 'NoCover.jpg';
end;
end.
|