aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Screens
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-06-08 08:27:11 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-06-08 08:27:11 +0000
commit920a63a63cb123957adeffbbb51da04b16e92559 (patch)
treee3bcfc988b714e7ecd516b5ef5a202f28e54c56e /Game/Code/Screens
parent7b0aa41d1b59d125eb7bb71bcae939a94ff48a14 (diff)
downloadusdx-920a63a63cb123957adeffbbb51da04b16e92559.tar.gz
usdx-920a63a63cb123957adeffbbb51da04b16e92559.tar.xz
usdx-920a63a63cb123957adeffbbb51da04b16e92559.zip
goto + labels removed
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1139 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--Game/Code/Screens/UScreenSong.pas111
1 files changed, 57 insertions, 54 deletions
diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas
index b790bc36..1653e310 100644
--- a/Game/Code/Screens/UScreenSong.pas
+++ b/Game/Code/Screens/UScreenSong.pas
@@ -793,80 +793,83 @@ end;
procedure TScreenSong.GenerateThumbnails();
var
- I : Integer;
- Pet: integer;
-Label CreateSongButtons;
+ I: Integer;
+ LoadNoCover: boolean;
+ OldTextureLimit: integer;
begin
- if (length(CatSongs.Song) > 0) then
- begin
- //Set Length of Button Array one Time Instead of one time for every Song
- SetButtonLength(Length(CatSongs.Song));
+ if (Length(CatSongs.Song) <= 0) then
+ Exit;
- I := 0;
- CreateSongButtons:
+ // set length of button array once instead for every song
+ SetButtonLength(Length(CatSongs.Song));
- try
- for Pet := I to High(CatSongs.Song) do begin // creating all buttons
- // new
- Texture.Limit := 512;// 256 0.4.2 value, 512 in 0.5.0
+ // backup and set texture limit
+ OldTextureLimit := Texture.Limit;
+ Texture.Limit := 512;
- if not FileExists(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover) then
- CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover'
+ // create all buttons
+ for I := 0 to High(CatSongs.Song) do
+ begin
+ // if cover not found then show 'no cover'
+ if (not FileExists(CatSongs.Song[I].Path + CatSongs.Song[I].Cover)) then
+ CatSongs.Song[I].Cover := '';
- if CatSongs.Song[Pet].Cover = '' then
- AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), TEXTURE_TYPE_PLAIN, Theme.Song.Cover.Reflections)
- else begin
- // cache texture if there is a need to this
- if not Covers.CoverExists(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover) then
- begin
- Texture.CreateCacheMipmap := true;
- Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, TEXTURE_TYPE_PLAIN, true); // preloads textures and creates cache mipmap
- Texture.CreateCacheMipmap := false;
+ if (CatSongs.Song[I].Cover = '') then
+ begin
+ LoadNoCover := true;
+ end
+ else
+ begin
+ // cache texture if there is a need to this
+ if (not Covers.CoverExists(CatSongs.Song[I].Path + CatSongs.Song[I].Cover)) then
+ begin
+ Texture.CreateCacheMipmap := true;
+ Texture.GetTexture(CatSongs.Song[I].Path + CatSongs.Song[I].Cover, TEXTURE_TYPE_PLAIN, true); // preloads textures and creates cache mipmap
+ Texture.CreateCacheMipmap := false;
- // puts this texture to the cache file
- Covers.AddCover(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover);
+ // puts this texture to the cache file
+ Covers.AddCover(CatSongs.Song[I].Path + CatSongs.Song[I].Cover);
- // unload full size texture
- Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, TEXTURE_TYPE_PLAIN, false);
+ // unload full size texture
+ Texture.UnloadTexture(CatSongs.Song[I].Path + CatSongs.Song[I].Cover, TEXTURE_TYPE_PLAIN, false);
- // we should also add mipmap texture by calling createtexture and use mipmap cache as data source
- end;
+ // TODO: we should also add mipmap texture by calling createtexture and use mipmap cache as data source
+ end;
- // and now load it from cache file (small place for the optimization by eliminating reading it from file, but not here)
- AddButton(300 + Pet*250, 140, 200, 200, CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, TEXTURE_TYPE_PLAIN, Theme.Song.Cover.Reflections);
- end;
- Texture.Limit := 1024*1024;
- I := -1;
+ // and now load it from cache file (small place for the optimization by eliminating reading it from file, but not here)
+ try
+ // FIXME: do we really need try-except here? AddButton does not seem to throw exceptions if it fails.
+ AddButton(300 + I*250, 140, 200, 200, CatSongs.Song[I].Path + CatSongs.Song[I].Cover, TEXTURE_TYPE_PLAIN, Theme.Song.Cover.Reflections);
+ LoadNoCover := false;
+ except
+ // report error and change cover to NoCover
+ Log.LogError('Could not load Cover: ' + CatSongs.Song[I].Cover);
+ LoadNoCover := true;
end;
- except
- //When Error is reported the First time for this Song
- if (I <> Pet) then
- begin
- //Some Error reporting:
- Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover);
+ end;
- //Change Cover to NoCover and Continue Loading
- CatSongs.Song[Pet].Cover := '';
- I := Pet;
- end
- else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song
- begin
+ if (LoadNoCover) then
+ begin
+ try
+ // FIXME: do we really need try-except here? AddButton does not seem to throw exceptions if it fails.
+ AddButton(300 + I*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), TEXTURE_TYPE_PLAIN, Theme.Song.Cover.Reflections)
+ except
+ // NoSong Cover is damaged
Log.LogError('NoCover Cover is damaged!');
+ // set a dummy cover and start loading next Song
try
- AddButton(300 + Pet*250, 140, 200, 200, '', TEXTURE_TYPE_PLAIN, Theme.Song.Cover.Reflections);
+ // FIXME: do we really need try-except here? AddButton does not seem to throw exceptions if it fails.
+ AddButton(300 + I*250, 140, 200, 200, '', TEXTURE_TYPE_PLAIN, Theme.Song.Cover.Reflections);
except
ShowMessage('"No Cover" image is damaged. Ultrastar will exit now.');
-
Halt;
end;
- I := Pet + 1;
end;
end;
-
- if (I <> -1) then
- GoTo CreateSongButtons;
-
end;
+
+ // restore texture limit
+ Texture.Limit := OldTextureLimit;
end;
procedure TScreenSong.SetScroll;