aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-31 14:34:31 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-31 14:34:31 +0000
commit13bf0be662f660d9f283b6c01b20dc2137dc835e (patch)
treef5594160c2bff17fa1394fae95405be4974b8c2a /Game/Code/Classes
parenteefbef6f9670e43b5f5f54f5f98ddee8f42b29d8 (diff)
downloadusdx-13bf0be662f660d9f283b6c01b20dc2137dc835e.tar.gz
usdx-13bf0be662f660d9f283b6c01b20dc2137dc835e.tar.xz
usdx-13bf0be662f660d9f283b6c01b20dc2137dc835e.zip
- removed "Font Black" and "Font" texture type
- use TEXTURE_TYPE_TRANSPARENT/COLORIZED/PLAIN in the future - texture-type is an enum now (not a string as before) -> pros: less memory consumption, compiler-check, case-insensitive, ... git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@988 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/Classes')
-rw-r--r--Game/Code/Classes/TextGL.pas10
-rw-r--r--Game/Code/Classes/UGraphic.pas56
-rw-r--r--Game/Code/Classes/ULog.pas4
-rw-r--r--Game/Code/Classes/ULyrics.pas8
-rw-r--r--Game/Code/Classes/ULyrics_bak.pas4
-rw-r--r--Game/Code/Classes/UTexture.pas266
-rw-r--r--Game/Code/Classes/UThemes.pas30
7 files changed, 183 insertions, 195 deletions
diff --git a/Game/Code/Classes/TextGL.pas b/Game/Code/Classes/TextGL.pas
index 3074fa32..d791e0cd 100644
--- a/Game/Code/Classes/TextGL.pas
+++ b/Game/Code/Classes/TextGL.pas
@@ -134,7 +134,7 @@ begin
//Log.LogStatus( 'Font' , '---------------------------');
SetLength(Fonts, 5);
- Fonts[0].Tex := Texture.LoadTexture(true, 'Font', 'PNG', 'Transparent', 0);
+ Fonts[0].Tex := Texture.LoadTexture(true, 'Font', 'PNG', TEXTURE_TYPE_TRANSPARENT, 0);
Fonts[0].Tex.H := 30;
Fonts[0].AspectW := 0.9;
Fonts[0].Done := -1;
@@ -142,27 +142,27 @@ begin
//Log.LogStatus( 'FontB' , '---------------------------');
- Fonts[1].Tex := Texture.LoadTexture(true, 'FontB', 'PNG', 'Transparent', 0);
+ Fonts[1].Tex := Texture.LoadTexture(true, 'FontB', 'PNG', TEXTURE_TYPE_TRANSPARENT, 0);
Fonts[1].Tex.H := 30;
Fonts[1].AspectW := 1;
Fonts[1].Done := -1;
Fonts[1].Outline := 0;
//Log.LogStatus( 'FontO' , '---------------------------');
- Fonts[2].Tex := Texture.LoadTexture(true, 'FontO', 'PNG', 'Transparent', 0);
+ Fonts[2].Tex := Texture.LoadTexture(true, 'FontO', 'PNG', TEXTURE_TYPE_TRANSPARENT, 0);
Fonts[2].Tex.H := 30;
Fonts[2].AspectW := 0.95;
Fonts[2].Done := -1;
Fonts[2].Outline := 5;
//Log.LogStatus( 'FontO2' , '---------------------------');
- Fonts[3].Tex := Texture.LoadTexture(true, 'FontO2', 'PNG', 'Transparent', 0);
+ Fonts[3].Tex := Texture.LoadTexture(true, 'FontO2', 'PNG', TEXTURE_TYPE_TRANSPARENT, 0);
Fonts[3].Tex.H := 30;
Fonts[3].AspectW := 0.95;
Fonts[3].Done := -1;
Fonts[3].Outline := 4;
-{ Fonts[4].Tex := Texture.LoadTexture('FontO', 'PNG', 'Transparent', 0); // for score screen
+{ Fonts[4].Tex := Texture.LoadTexture('FontO', 'PNG', TEXTURE_TYPE_TRANSPARENT, 0); // for score screen
Fonts[4].Tex.H := 30;
Fonts[4].AspectW := 0.95;
Fonts[4].Done := -1;
diff --git a/Game/Code/Classes/UGraphic.pas b/Game/Code/Classes/UGraphic.pas
index 80eedc33..d63ab31f 100644
--- a/Game/Code/Classes/UGraphic.pas
+++ b/Game/Code/Classes/UGraphic.pas
@@ -278,9 +278,9 @@ begin
// zaladowanie tekstur
Log.LogStatus('Loading Textures', 'LoadTextures');
- Tex_Left[0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayLeft')), 'BMP', 'Transparent', 0); //brauch man die noch?
- Tex_Mid[0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayMid')), 'BMP', 'Plain', 0); //brauch man die noch?
- Tex_Right[0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayRight')), 'BMP', 'Transparent', 0); //brauch man die noch?
+ Tex_Left[0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayLeft')), 'BMP', TEXTURE_TYPE_TRANSPARENT, 0); //brauch man die noch?
+ Tex_Mid[0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayMid')), 'BMP', TEXTURE_TYPE_PLAIN, 0); //brauch man die noch?
+ Tex_Right[0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayRight')), 'BMP', TEXTURE_TYPE_TRANSPARENT, 0); //brauch man die noch?
Log.LogStatus('Loading Textures - A', 'LoadTextures');
@@ -292,25 +292,25 @@ begin
LoadColor(R, G, B, 'P' + IntToStr(P) + 'Light');
Col := $10000 * Round(R*255) + $100 * Round(G*255) + Round(B*255);
- Tex_Left[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayLeft')), 'PNG', 'Colorized', Col);
- Tex_Mid[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayMid')), 'PNG', 'Colorized', Col);
- Tex_Right[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayRight')), 'PNG', 'Colorized', Col);
+ Tex_Left[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayLeft')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
+ Tex_Mid[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayMid')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
+ Tex_Right[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayRight')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
- Tex_plain_Left[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NotePlainLeft')), 'PNG', 'Colorized', Col);
- Tex_plain_Mid[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NotePlainMid')), 'PNG', 'Colorized', Col);
- Tex_plain_Right[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NotePlainRight')), 'PNG', 'Colorized', Col);
+ Tex_plain_Left[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NotePlainLeft')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
+ Tex_plain_Mid[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NotePlainMid')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
+ Tex_plain_Right[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NotePlainRight')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
- Tex_BG_Left[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NoteBGLeft')), 'PNG', 'Colorized', Col);
- Tex_BG_Mid[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NoteBGMid')), 'PNG', 'Colorized', Col);
- Tex_BG_Right[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NoteBGRight')), 'PNG', 'Colorized', Col);
+ Tex_BG_Left[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NoteBGLeft')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
+ Tex_BG_Mid[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NoteBGMid')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
+ Tex_BG_Right[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NoteBGRight')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
end;
Log.LogStatus('Loading Textures - B', 'LoadTextures');
- Tex_Note_Perfect_Star := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NotePerfectStar')), 'PNG', 'Transparent', 0);
- Tex_Note_Star := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NoteStar')) , 'PNG', 'Transparent', $FFFFFF);
- Tex_Ball := Texture.LoadTexture(pchar(Skin.GetTextureFileName('Ball')), 'BMP', 'Transparent', $FF00FF);
- Tex_Lyric_Help_Bar := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricHelpBar')), 'BMP', 'Transparent', $FF00FF);
+ Tex_Note_Perfect_Star := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NotePerfectStar')), 'PNG', TEXTURE_TYPE_TRANSPARENT, 0);
+ Tex_Note_Star := Texture.LoadTexture(pchar(Skin.GetTextureFileName('NoteStar')) , 'PNG', TEXTURE_TYPE_TRANSPARENT, $FFFFFF);
+ Tex_Ball := Texture.LoadTexture(pchar(Skin.GetTextureFileName('Ball')), 'BMP', TEXTURE_TYPE_TRANSPARENT, $FF00FF);
+ Tex_Lyric_Help_Bar := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricHelpBar')), 'BMP', TEXTURE_TYPE_TRANSPARENT, $FF00FF);
//TimeBar mod
@@ -318,9 +318,9 @@ begin
//eoa TimeBar mod
//SingBar Mod
- Tex_SingBar_Back := Texture.LoadTexture(pchar(Skin.GetTextureFileName('SingBarBack')), 'JPG', 'Plain', 0);
- Tex_SingBar_Bar := Texture.LoadTexture(pchar(Skin.GetTextureFileName('SingBarBar')), 'JPG', 'Plain', 0);
- Tex_SingBar_Front := Texture.LoadTexture(pchar(Skin.GetTextureFileName('SingBarFront')), 'JPG', 'Font', 0);
+ Tex_SingBar_Back := Texture.LoadTexture(pchar(Skin.GetTextureFileName('SingBarBack')), 'JPG', TEXTURE_TYPE_PLAIN, 0);
+ Tex_SingBar_Bar := Texture.LoadTexture(pchar(Skin.GetTextureFileName('SingBarBar')), 'JPG', TEXTURE_TYPE_PLAIN, 0);
+ Tex_SingBar_Front := Texture.LoadTexture(pchar(Skin.GetTextureFileName('SingBarFront')), 'JPG', TEXTURE_TYPE_PLAIN, 0);
//end Singbar Mod
Log.LogStatus('Loading Textures - C', 'LoadTextures');
@@ -357,14 +357,14 @@ begin
End;
Col := $10000 * Round(R*255) + $100 * Round(G*255) + Round(B*255);
- Tex_SingLineBonusBack[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LineBonusBack')), 'PNG', 'Colorized', Col);
+ Tex_SingLineBonusBack[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LineBonusBack')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
end;
//## backgrounds for the scores ##
for P := 0 to 5 do begin
LoadColor(R, G, B, 'P' + IntToStr(P+1) + 'Light');
Col := $10000 * Round(R*255) + $100 * Round(G*255) + Round(B*255);
- Tex_ScoreBG[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreBG')), 'PNG', 'Colorized', Col);
+ Tex_ScoreBG[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreBG')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
end;
@@ -379,23 +379,23 @@ begin
//NoteBar ScoreBar
LoadColor(R, G, B, 'P' + IntToStr(P) + 'Dark');
Col := $10000 * Round(R*255) + $100 * Round(G*255) + Round(B*255);
- Tex_Score_NoteBarLevel_Dark[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreLevel_Dark')), 'PNG', 'Colorized', Col);
- Tex_Score_NoteBarRound_Dark[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreLevel_Dark_Round')), 'PNG', 'Colorized', Col);
+ Tex_Score_NoteBarLevel_Dark[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreLevel_Dark')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
+ Tex_Score_NoteBarRound_Dark[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreLevel_Dark_Round')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
//LineBonus ScoreBar
LoadColor(R, G, B, 'P' + IntToStr(P) + 'Light');
Col := $10000 * Round(R*255) + $100 * Round(G*255) + Round(B*255);
- Tex_Score_NoteBarLevel_Light[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreLevel_Light')), 'PNG', 'Colorized', Col);
- Tex_Score_NoteBarRound_Light[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreLevel_Light_Round')), 'PNG', 'Colorized', Col);
+ Tex_Score_NoteBarLevel_Light[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreLevel_Light')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
+ Tex_Score_NoteBarRound_Light[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreLevel_Light_Round')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
//GoldenNotes ScoreBar
LoadColor(R, G, B, 'P' + IntToStr(P) + 'Lightest');
Col := $10000 * Round(R*255) + $100 * Round(G*255) + Round(B*255);
- Tex_Score_NoteBarLevel_Lightest[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreLevel_Lightest')), 'PNG', 'Colorized', Col);
- Tex_Score_NoteBarRound_Lightest[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreLevel_Lightest_Round')), 'PNG', 'Colorized', Col);
+ Tex_Score_NoteBarLevel_Lightest[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreLevel_Lightest')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
+ Tex_Score_NoteBarRound_Lightest[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('ScoreLevel_Lightest_Round')), 'PNG', TEXTURE_TYPE_COLORIZED, Col);
end;
//## rating pictures that show a picture according to your rate ##
for P := 0 to 6 do begin
- Tex_Score_Ratings[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('Rating_'+IntToStr(P))), 'PNG', 'Transparent', 0);
+ Tex_Score_Ratings[P] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('Rating_'+IntToStr(P))), 'PNG', TEXTURE_TYPE_TRANSPARENT, 0);
end;
Log.LogStatus('Loading Textures - Done', 'LoadTextures');
diff --git a/Game/Code/Classes/ULog.pas b/Game/Code/Classes/ULog.pas
index 4e976ab4..2a628792 100644
--- a/Game/Code/Classes/ULog.pas
+++ b/Game/Code/Classes/ULog.pas
@@ -142,13 +142,13 @@ begin
end;
procedure debugWriteln( aString : String );
-begin
+begin
{$IFDEF CONSOLE}
if FindCmdLineSwitch( cDebug ) then
writeln( 'DEBUG - '+aString );
{$ENDIF}
-end;
+end;
constructor TLog.Create;
diff --git a/Game/Code/Classes/ULyrics.pas b/Game/Code/Classes/ULyrics.pas
index 6cec37b9..01ec129d 100644
--- a/Game/Code/Classes/ULyrics.pas
+++ b/Game/Code/Classes/ULyrics.pas
@@ -266,16 +266,16 @@ var
begin
// lyric indicator (bar that indicates when the line start)
- IndicatorTex := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricHelpBar')), 'BMP', 'Transparent', $FF00FF);
+ IndicatorTex := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricHelpBar')), 'BMP', TEXTURE_TYPE_TRANSPARENT, $FF00FF);
// ball for current word hover in ball effect
- BallTex := Texture.LoadTexture(pchar(Skin.GetTextureFileName('Ball')), 'PNG', 'Transparent', 0);
+ BallTex := Texture.LoadTexture(pchar(Skin.GetTextureFileName('Ball')), 'PNG', TEXTURE_TYPE_TRANSPARENT, 0);
// duet mode: load player icon
For I := 0 to 5 do
begin
- PlayerIconTex[I][0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricIcon_P' + InttoStr(I+1))), 'PNG', 'Transparent', 0);
- PlayerIconTex[I][1] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricIconD_P' + InttoStr(I+1))), 'PNG', 'Transparent', 0);
+ PlayerIconTex[I][0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricIcon_P' + InttoStr(I+1))), 'PNG', TEXTURE_TYPE_TRANSPARENT, 0);
+ PlayerIconTex[I][1] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricIconD_P' + InttoStr(I+1))), 'PNG', TEXTURE_TYPE_TRANSPARENT, 0);
end;
// create line textures
diff --git a/Game/Code/Classes/ULyrics_bak.pas b/Game/Code/Classes/ULyrics_bak.pas
index 47c3ed03..7db7e0d9 100644
--- a/Game/Code/Classes/ULyrics_bak.pas
+++ b/Game/Code/Classes/ULyrics_bak.pas
@@ -119,8 +119,8 @@ begin
//Only 2 Players for now
For I := 0 to 1 do
begin
- PlayerIconTex[I][0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricIcon_P' + InttoStr(I+1))), 'PNG', 'Transparent', 0);
- PlayerIconTex[I][1] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricIconD_P' + InttoStr(I+1))), 'PNG', 'Transparent', 0);
+ PlayerIconTex[I][0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricIcon_P' + InttoStr(I+1))), 'PNG', TEXTURE_TYPE_TRANSPARENT, 0);
+ PlayerIconTex[I][1] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('LyricIconD_P' + InttoStr(I+1))), 'PNG', TEXTURE_TYPE_TRANSPARENT, 0);
end;
PlayersActive := Trunc(Power(2, 1)) + 1;
end;
diff --git a/Game/Code/Classes/UTexture.pas b/Game/Code/Classes/UTexture.pas
index f96745be..48628176 100644
--- a/Game/Code/Classes/UTexture.pas
+++ b/Game/Code/Classes/UTexture.pas
@@ -19,7 +19,6 @@ uses OpenGL12,
SysUtils,
Graphics,
UCommon,
- UThemes,
SDL,
sdlutils,
SDL_Image;
@@ -49,13 +48,30 @@ type
Name: string; // 0.5.0: experimental for handling cache images. maybe it's useful for dynamic skins
end;
+type
+ TTextureType = (
+ TEXTURE_TYPE_PLAIN, // Plain (alpha = 1)
+ TEXTURE_TYPE_TRANSPARENT, // Alpha is used
+ TEXTURE_TYPE_COLORIZED // Alpha is used; Hue of the HSV color-model will be replaced by a new value
+ );
+const
+ TextureTypeStr: array[TTextureType] of string = (
+ 'Plain',
+ 'Transparent',
+ 'Colorized'
+ );
+
+function TextureTypeToStr(TexType: TTextureType): string;
+function ParseTextureType(const TypeStr: string; Default: TTextureType): TTextureType;
+
+type
TTextureEntry = record
Name: string;
- Typ: string;
+ Typ: TTextureType;
// we use normal TTexture, it's easier to implement and if needed - we copy ready data
Texture: TTexture;
- TextureCache: TTexture; // 0.5.0
+ TextureCache: TTexture;
end;
TTextureDatabase = record
@@ -63,11 +79,10 @@ type
end;
TTextureUnit = class
-
private
- function LoadImage(Identifier: PChar): PSDL_Surface;
+ function LoadImage(const Identifier: string): PSDL_Surface;
function pixfmt_eq(fmt1,fmt2: PSDL_Pixelformat): boolean;
- procedure AdjustPixelFormat(var TexSurface: PSDL_Surface; Typ: PChar);
+ procedure AdjustPixelFormat(var TexSurface: PSDL_Surface; Typ: TTextureType);
function GetScaledTexture(TexSurface: PSDL_Surface; W,H: Cardinal): PSDL_Surface;
procedure ScaleTexture(var TexSurface: PSDL_Surface; W,H: Cardinal);
procedure FitTexture(var TexSurface: PSDL_Surface; W,H: Cardinal);
@@ -78,41 +93,23 @@ type
CreateCacheMipmap: boolean;
// function GetNumberFor
- function GetTexture(Name, Typ: string): TTexture; overload;
- function GetTexture(Name, Typ: string; FromCache: boolean): TTexture; overload;
- function FindTexture(Name: string): integer;
- function LoadTexture(FromRegistry: boolean; Identifier, Format, Typ: PChar; Col: LongWord): TTexture; overload;
- function LoadTexture(Identifier, Format, Typ: PChar; Col: LongWord): TTexture; overload;
- function LoadTexture(Identifier: string): TTexture; overload;
- function CreateTexture(var Data: array of byte; Name: string; W, H: word; Bits: byte): TTexture;
- procedure UnloadTexture(Name: string; FromCache: boolean);
+ function GetTexture(const Name: string; Typ: TTextureType): TTexture; overload;
+ function GetTexture(const Name: string; Typ: TTextureType; FromCache: boolean): TTexture; overload;
+ function FindTexture(const Name: string): integer;
+ function LoadTexture(FromRegistry: boolean; const Identifier, Format: string; Typ: TTextureType; Col: LongWord): TTexture; overload;
+ function LoadTexture(const Identifier, Format: string; Typ: TTextureType; Col: LongWord): TTexture; overload;
+ function LoadTexture(const Identifier: string): TTexture; overload;
+ function CreateTexture(var Data: array of byte; const Name: string; W, H: word; Bits: byte): TTexture;
+ procedure UnloadTexture(const Name: string; FromCache: boolean);
Constructor Create;
Destructor Destroy; override;
end;
-const
- TEXTURE_TYPE_PLAIN = 'Plain'; // Plain (alpha = 1)
- TEXTURE_TYPE_TRANSPARENT = 'Transparent';
- TEXTURE_TYPE_COLORIZED = 'Colorized';
- // obsolete:
- // Font Black (black is drawn, white is transparent)
-
var
Texture: TTextureUnit;
TextureDatabase: TTextureDatabase;
- // this should be in UDisplay?!
- PrintScreenData: array[0..1024*768-1] of longword;
-
- ActTex: GLuint;//integer;
-
-// TextureD8: array[1..1024*1024] of byte; // 1MB
- TextureD16: array[1..1024*1024, 1..2] of byte; // luminance/alpha tex (2MB)
-// TextureD24: array[1..1024*1024, 1..3] of byte; // normal 24-bit tex (3MB)
-// TextureD242: array[1..512*512, 1..3] of byte; // normal 24-bit tex (0,75MB)
-// TextureD32: array[1..1024*1024, 1..4] of byte; // transparent 32-bit tex (4MB)
- // total 40MB at 2048*2048
- // total 10MB at 1024*1024
+ ActTex: GLuint;
Mipmapping: Boolean;
@@ -125,6 +122,7 @@ implementation
uses ULog,
DateUtils,
UCovers,
+ UThemes,
{$ifdef LINUX}
fileutil,
{$endif}
@@ -138,40 +136,44 @@ uses ULog,
dialogs;
const
- fmt_rgba: TSDL_Pixelformat=(palette: nil;
- BitsPerPixel: 32;
- BytesPerPixel: 4;
- Rloss: 0;
- Gloss: 0;
- Bloss: 0;
- Aloss: 0;
- Rshift: 0;
- Gshift: 8;
- Bshift: 16;
- Ashift: 24;
- Rmask: $000000ff;
- Gmask: $0000ff00;
- Bmask: $00ff0000;
- Amask: $ff000000;
- ColorKey: 0;
- Alpha: 255);
- fmt_rgb: TSDL_Pixelformat=( palette: nil;
- BitsPerPixel: 24;
- BytesPerPixel: 3;
- Rloss: 0;
- Gloss: 0;
- Bloss: 0;
- Aloss: 0;
- Rshift: 0;
- Gshift: 8;
- Bshift: 16;
- Ashift: 0;
- Rmask: $000000ff;
- Gmask: $0000ff00;
- Bmask: $00ff0000;
- Amask: $00000000;
- ColorKey: 0;
- Alpha: 255);
+ fmt_rgba: TSDL_Pixelformat = (
+ palette: nil;
+ BitsPerPixel: 32;
+ BytesPerPixel: 4;
+ Rloss: 0;
+ Gloss: 0;
+ Bloss: 0;
+ Aloss: 0;
+ Rshift: 0;
+ Gshift: 8;
+ Bshift: 16;
+ Ashift: 24;
+ Rmask: $000000ff;
+ Gmask: $0000ff00;
+ Bmask: $00ff0000;
+ Amask: $ff000000;
+ ColorKey: 0;
+ Alpha: 255
+ );
+ fmt_rgb: TSDL_Pixelformat = (
+ palette: nil;
+ BitsPerPixel: 24;
+ BytesPerPixel: 3;
+ Rloss: 0;
+ Gloss: 0;
+ Bloss: 0;
+ Aloss: 0;
+ Rshift: 0;
+ Gshift: 8;
+ Bshift: 16;
+ Ashift: 0;
+ Rmask: $000000ff;
+ Gmask: $0000ff00;
+ Bmask: $00ff0000;
+ Amask: $00000000;
+ ColorKey: 0;
+ Alpha: 255
+ );
Constructor TTextureUnit.Create;
@@ -242,7 +244,7 @@ end;
end;
// -----------------------------------------------
-function TTextureUnit.LoadImage(Identifier: PChar): PSDL_Surface;
+function TTextureUnit.LoadImage(const Identifier: string): PSDL_Surface;
function FileExistsInsensative( var aFileName : PChar ): boolean;
begin
@@ -280,7 +282,7 @@ begin
if Identifier = '' then
exit;
- lFileName := Identifier;
+ lFileName := PChar(Identifier);
// Log.LogStatus( Identifier, 'LoadImage' );
@@ -336,7 +338,7 @@ begin
Log.LogStatus( 'NOT found in Resource ('+Identifier+')', ' LoadImage' );
end;
{$ELSE}
- dHandle := FindResource(hInstance, Identifier, 'TEX');
+ dHandle := FindResource(hInstance, PChar(Identifier), 'TEX');
if dHandle=0 then
begin
Log.LogStatus( 'ERROR Could not find resource' , ' '+ Identifier);
@@ -382,16 +384,16 @@ begin
end;
end;
-procedure TTextureUnit.AdjustPixelFormat(var TexSurface: PSDL_Surface; Typ: PChar);
+procedure TTextureUnit.AdjustPixelFormat(var TexSurface: PSDL_Surface; Typ: TTextureType);
var
TempSurface: PSDL_Surface;
NeededPixFmt: PSDL_Pixelformat;
begin
NeededPixFmt:=@fmt_rgba;
- if Typ= 'Plain' then NeededPixFmt:=@fmt_rgb
+ if (Typ = TEXTURE_TYPE_PLAIN) then NeededPixFmt:=@fmt_rgb
else
- if (Typ='Transparent') or
- (Typ='Colorized')
+ if (Typ = TEXTURE_TYPE_TRANSPARENT) or
+ (Typ = TEXTURE_TYPE_COLORIZED)
then NeededPixFmt:=@fmt_rgba
else
NeededPixFmt:=@fmt_rgb;
@@ -527,13 +529,12 @@ begin
end;
end;
-function TTextureUnit.LoadTexture(FromRegistry: boolean; Identifier, Format, Typ: PChar; Col: LongWord): TTexture;
+function TTextureUnit.LoadTexture(FromRegistry: boolean; const Identifier, Format: string; Typ: TTextureType; Col: LongWord): TTexture;
var
TexSurface: PSDL_Surface;
MipmapSurface: PSDL_Surface;
newWidth, newHeight: Cardinal;
oldWidth, oldHeight: Cardinal;
- kopierindex: Cardinal;
begin
Log.BenchmarkStart(4);
Mipmapping := true;
@@ -557,7 +558,7 @@ begin
{$endif}
if not assigned(TexSurface) then
begin
- Log.LogStatus( 'ERROR Could not load texture' , Identifier +' '+ Format +' '+ Typ );
+ Log.LogStatus( 'ERROR Could not load texture' , Identifier +' '+ Format +' '+ TextureTypeToStr(Typ) );
beep;
Exit;
end;
@@ -579,7 +580,7 @@ begin
if (newHeight > Limit) then
newHeight := Limit;
-
+
if (TexSurface.W > newWidth) or (TexSurface.H > newHeight) then
begin
{$ifdef blindydebug}
@@ -611,7 +612,7 @@ begin
{$ifdef blindydebug}
Log.LogStatus('',' GetScaledTexture('''+inttostr(Covers.W)+''','''+inttostr(Covers.H)+''') (for CacheMipmap)');
{$endif}
- MipmapSurface:=GetScaledTexture(TexSurface,Covers.W, Covers.H);
+ MipmapSurface:=GetScaledTexture(TexSurface, Covers.W, Covers.H);
if assigned(MipmapSurface) then
begin
{$ifdef blindydebug}
@@ -620,7 +621,7 @@ begin
{$endif}
// creating and freeing the surface could be done once, if Cover.W and Cover.H don't change
CacheMipmapSurface:=SDL_CreateRGBSurfaceFrom(@CacheMipmap[0], Covers.W, Covers.H, 24, Covers.W*3, $000000ff, $0000ff00, $00ff0000, 0);
- SDL_BlitSurface(MipMapSurface,nil,CacheMipmapSurface,nil);
+ SDL_BlitSurface(MipMapSurface, nil, CacheMipmapSurface, nil);
SDL_FreeSurface(CacheMipmapSurface);
{$ifdef blindydebug}
Log.LogStatus('',' ok');
@@ -638,7 +639,7 @@ begin
end;
// should i create a cache texture, if Covers.W/H are larger?
end;
-
+
{$ifdef blindydebug}
Log.LogStatus('',' JB-2');
{$endif}
@@ -646,16 +647,16 @@ begin
// now we might colorize the whole thing
if (Typ = TEXTURE_TYPE_COLORIZED) then
- ColorizeTexture(TexSurface,Col);
-
+ ColorizeTexture(TexSurface, Col);
+
// save actual dimensions of our texture
- oldWidth:=newWidth;
- oldHeight:=newHeight;
+ oldWidth := newWidth;
+ oldHeight := newHeight;
// make texture dimensions be powers of 2
- newWidth:=Round(Power(2, Ceil(Log2(newWidth))));
- newHeight:=Round(Power(2, Ceil(Log2(newHeight))));
+ newWidth := Round(Power(2, Ceil(Log2(newWidth))));
+ newHeight := Round(Power(2, Ceil(Log2(newHeight))));
if (newHeight <> oldHeight) or (newWidth <> oldWidth) then
- FitTexture(TexSurface,newWidth,newHeight);
+ FitTexture(TexSurface, newWidth, newHeight);
// at this point we have the image in memory...
// scaled to be at most 1024x1024 pixels large
@@ -672,13 +673,13 @@ begin
// and could now create our openGL texture from it
// prepare OpenGL texture
-
+
// JB_linux : this is causing AV's on linux... ActText seems to be nil !
// {$IFnDEF win32}
// if pointer(ActTex) = nil then
// exit;
// {$endif}
-
+
glGenTextures(1, @ActTex);
glBindTexture(GL_TEXTURE_2D, ActTex);
@@ -692,42 +693,10 @@ begin
begin
glTexImage2D(GL_TEXTURE_2D, 0, 4, newWidth, newHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, TexSurface.pixels);
end
- else {if Typ = 'Plain' then}
+ else //if Typ = TEXTURE_TYPE_PLAIN then
begin
glTexImage2D(GL_TEXTURE_2D, 0, 3, newWidth, newHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, TexSurface.pixels);
end;
-
- {$ifdef blindydebug}
- Log.LogStatus('',' JB-4');
- {$endif}
-
- {
- if Typ = 'Font Black' then
- // and so on
- begin
- // normalnie 0,125s bez niczego 0,015s - 0,030s z pix 0,125s <-- ???
- // dimensions
- TextureB.PixelFormat := pf24bit;
- TexOrigW := TextureB.Width;
- TexOrigH := TextureB.Height;
- TexNewW := Round(Power(2, Ceil(Log2(TexOrigW))));
- TexNewH := Round(Power(2, Ceil(Log2(TexOrigH))));
- TextureB.Width := TexNewW;
- TextureB.Height := TexNewH;
- // copy and process pixeldata
- for Position := 0 to TextureB.Height-1 do begin
- PPix := TextureB.ScanLine[Position];
- for Position2 := 0 to TextureB.Width-1 do begin
- Pix := PPix[Position2*3];
- TextureD32[Position*TextureB.Width + Position2 + 1, 1] := 255;
- TextureD32[Position*TextureB.Width + Position2 + 1, 2] := 255;
- TextureD32[Position*TextureB.Width + Position2 + 1, 3] := 255;
- TextureD32[Position*TextureB.Width + Position2 + 1, 4] := 255 - (Pix mod 256);
- end;
- end;
- glTexImage2D(GL_TEXTURE_2D, 0, 4, TextureB.Width, TextureB.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, @TextureD32);
- end;
- }
{$ifdef blindydebug}
Log.LogStatus('',' JB-5');
@@ -752,18 +721,16 @@ begin
Result.ColB := 1;
Result.Alpha := 1;
- // 0.4.2 new test - default use whole texure, taking TexW and TexH as const and changing these
+ // new test - default use whole texure, taking TexW and TexH as const and changing these
Result.TexX1 := 0;
Result.TexY1 := 0;
Result.TexX2 := 1;
Result.TexY2 := 1;
-
+
{$ifdef blindydebug}
Log.LogStatus('',' JB-6');
{$endif}
-
- // 0.5.0
Result.Name := Identifier;
SDL_FreeSurface(TexSurface);
@@ -775,7 +742,7 @@ begin
Log.BenchmarkEnd(4);
if Log.BenchmarkTimeLength[4] >= 1 then
- Log.LogBenchmark('**********> Texture Load Time Warning - ' + Format + '/' + Identifier + '/' + Typ, 4);
+ Log.LogBenchmark('**********> Texture Load Time Warning - ' + Format + '/' + Identifier + '/' + TextureTypeToStr(Typ), 4);
{$ifdef blindydebug}
Log.LogStatus('',' JB-8');
@@ -784,12 +751,12 @@ begin
end;
-function TTextureUnit.GetTexture(Name, Typ: string): TTexture;
+function TTextureUnit.GetTexture(const Name: string; Typ: TTextureType): TTexture;
begin
Result := GetTexture(Name, Typ, true);
end;
-function TTextureUnit.GetTexture(Name, Typ: string; FromCache: boolean): TTexture;
+function TTextureUnit.GetTexture(const Name: string; Typ: TTextureType; FromCache: boolean): TTexture;
var
T: integer; // texture
C: integer; // cover
@@ -826,7 +793,7 @@ begin
{$ifdef blindydebug}
Log.LogStatus('...', 'GetTexture('''+Name+''','''+Typ+''')');
{$endif}
- TextureDatabase.Texture[T].Texture := LoadTexture(false, pchar(Name), 'JPG', pchar(Typ), $0);
+ TextureDatabase.Texture[T].Texture := LoadTexture(false, pchar(Name), 'JPG', Typ, $0);
{$ifdef blindydebug}
Log.LogStatus('done',' ');
{$endif}
@@ -853,27 +820,27 @@ begin
end;
end;
-function TTextureUnit.FindTexture(Name: string): integer;
+function TTextureUnit.FindTexture(const Name: string): integer;
var
T: integer; // texture
begin
Result := -1;
for T := 0 to high(TextureDatabase.Texture) do
- if TextureDatabase.Texture[T].Name = Name then
+ if (TextureDatabase.Texture[T].Name = Name) then
Result := T;
end;
-function TTextureUnit.LoadTexture(Identifier, Format, Typ: PChar; Col: LongWord): TTexture;
+function TTextureUnit.LoadTexture(const Identifier, Format: string; Typ: TTextureType; Col: LongWord): TTexture;
begin
Result := LoadTexture(false, Identifier, Format, Typ, Col);
end;
-function TTextureUnit.LoadTexture(Identifier: string): TTexture;
+function TTextureUnit.LoadTexture(const Identifier: string): TTexture;
begin
- Result := LoadTexture(false, pchar(Identifier), 'JPG', 'Plain', 0);
+ Result := LoadTexture(false, pchar(Identifier), 'JPG', TEXTURE_TYPE_PLAIN, 0);
end;
-function TTextureUnit.CreateTexture(var Data: array of byte; Name: string; W, H: word; Bits: byte): TTexture;
+function TTextureUnit.CreateTexture(var Data: array of byte; const Name: string; W, H: word; Bits: byte): TTexture;
var
Position: integer;
Position2: integer;
@@ -924,7 +891,7 @@ begin
Result.Name := Name;
end;
-procedure TTextureUnit.UnloadTexture(Name: string; FromCache: boolean);
+procedure TTextureUnit.UnloadTexture(const Name: string; FromCache: boolean);
var
T: integer;
TexNum: integer;
@@ -948,6 +915,29 @@ begin
end;
end;
+function TextureTypeToStr(TexType: TTextureType): string;
+begin
+ Result := TextureTypeStr[TexType];
+end;
+
+function ParseTextureType(const TypeStr: string; Default: TTextureType): TTextureType;
+var
+ TexType: TTextureType;
+ UpCaseStr: string;
+begin
+ UpCaseStr := UpperCase(TypeStr);
+ for TexType := Low(TextureTypeStr) to High(TextureTypeStr) do
+ begin
+ if (UpCaseStr = UpperCase(TextureTypeStr[TexType])) then
+ begin
+ Result := TexType;
+ Exit;
+ end;
+ end;
+ Log.LogError('Unknown texture-type: ' + TypeStr, 'ParseTextureType');
+ Result := TEXTURE_TYPE_PLAIN;
+end;
+
{$IFDEF LAZARUS}
initialization
{$I UltraStar.lrs}
diff --git a/Game/Code/Classes/UThemes.pas b/Game/Code/Classes/UThemes.pas
index a6a91418..25ca370b 100644
--- a/Game/Code/Classes/UThemes.pas
+++ b/Game/Code/Classes/UThemes.pas
@@ -12,7 +12,8 @@ uses
ULog,
IniFiles,
SysUtils,
- Classes;
+ Classes,
+ UTexture;
type
TRGB = record
@@ -40,7 +41,7 @@ type
ColG: real;
ColB: real;
Tex: string;
- Typ: string;
+ Typ: TTextureType;
TexX1: real;
TexY1: real;
TexX2: real;
@@ -84,7 +85,7 @@ type
DColB: real;
DInt: real;
Tex: string;
- Typ: string;
+ Typ: TTextureType;
Visible: Boolean;
@@ -550,15 +551,15 @@ type
ChangeTextures: Boolean;
FirstTexture: String;
- FirstTyp: String;
+ FirstTyp: TTextureType;
FirstColor: String;
SecondTexture: String;
- SecondTyp: String;
+ SecondTyp: TTextureType;
SecondColor: String;
ThirdTexture: String;
- ThirdTyp: String;
+ ThirdTyp: TTextureType;
ThirdColor: String;
end;
@@ -1309,17 +1310,16 @@ begin
//Load Party Score DecoTextures Object
PartyScore.DecoTextures.ChangeTextures := (ThemeIni.ReadInteger('PartyScoreDecoTextures', 'ChangeTextures', 0) = 1);
-
PartyScore.DecoTextures.FirstTexture := ThemeIni.ReadString('PartyScoreDecoTextures', 'FirstTexture', '');
- PartyScore.DecoTextures.FirstTyp := ThemeIni.ReadString('PartyScoreDecoTextures', 'FirstTyp', 'Note Black');
+ PartyScore.DecoTextures.FirstTyp := ParseTextureType(ThemeIni.ReadString('PartyScoreDecoTextures', 'FirstTyp', ''), TEXTURE_TYPE_COLORIZED);
PartyScore.DecoTextures.FirstColor := ThemeIni.ReadString('PartyScoreDecoTextures', 'FirstColor', 'Black');
PartyScore.DecoTextures.SecondTexture := ThemeIni.ReadString('PartyScoreDecoTextures', 'SecondTexture', '');
- PartyScore.DecoTextures.SecondTyp := ThemeIni.ReadString('PartyScoreDecoTextures', 'SecondTyp', 'Note Black');
+ PartyScore.DecoTextures.SecondTyp := ParseTextureType(ThemeIni.ReadString('PartyScoreDecoTextures', 'SecondTyp', ''), TEXTURE_TYPE_COLORIZED);
PartyScore.DecoTextures.SecondColor := ThemeIni.ReadString('PartyScoreDecoTextures', 'SecondColor', 'Black');
PartyScore.DecoTextures.ThirdTexture := ThemeIni.ReadString('PartyScoreDecoTextures', 'ThirdTexture', '');
- PartyScore.DecoTextures.ThirdTyp := ThemeIni.ReadString('PartyScoreDecoTextures', 'ThirdTyp', 'Note Black');
+ PartyScore.DecoTextures.ThirdTyp := ParseTextureType(ThemeIni.ReadString('PartyScoreDecoTextures', 'ThirdTyp', ''), TEXTURE_TYPE_COLORIZED);
PartyScore.DecoTextures.ThirdColor := ThemeIni.ReadString('PartyScoreDecoTextures', 'ThirdColor', 'Black');
ThemeLoadText (PartyScore.TextWinner, 'PartyScoreTextWinner');
@@ -1503,7 +1503,7 @@ begin
ThemeStatic.W := ThemeIni.ReadInteger(Name, 'W', 0);
ThemeStatic.H := ThemeIni.ReadInteger(Name, 'H', 0);
- ThemeStatic.Typ := ThemeIni.ReadString(Name, 'Type', '');
+ ThemeStatic.Typ := ParseTextureType(ThemeIni.ReadString(Name, 'Type', ''), TEXTURE_TYPE_PLAIN);
ThemeStatic.Color := ThemeIni.ReadString(Name, 'Color', '');
C := ColorExists(ThemeStatic.Color);
@@ -1581,8 +1581,7 @@ begin
ThemeButton.Z := ThemeIni.ReadFloat (Name, 'Z', 0);
ThemeButton.W := ThemeIni.ReadInteger (Name, 'W', 0);
ThemeButton.H := ThemeIni.ReadInteger (Name, 'H', 0);
-
- ThemeButton.Typ := ThemeIni.ReadString(Name, 'Type', '');
+ ThemeButton.Typ := ParseTextureType(ThemeIni.ReadString(Name, 'Type', ''), TEXTURE_TYPE_PLAIN);
//Reflection Mod
ThemeButton.Reflection := (ThemeIni.ReadInteger(Name, 'Reflection', 0) = 1);
@@ -2112,7 +2111,7 @@ begin
ThemeIni.WriteInteger(Name, 'H', ThemeStatic.H);
ThemeIni.WriteString(Name, 'Tex', ThemeStatic.Tex);
- ThemeIni.WriteString(Name, 'Type', ThemeStatic.Typ);
+ ThemeIni.WriteString(Name, 'Type', TextureTypeToStr(ThemeStatic.Typ));
ThemeIni.WriteString(Name, 'Color', ThemeStatic.Color);
ThemeIni.WriteFloat(Name, 'TexX1', ThemeStatic.TexX1);
@@ -2163,8 +2162,7 @@ begin
ThemeIni.WriteInteger(Name, 'Y', ThemeButton.Y);
ThemeIni.WriteInteger(Name, 'W', ThemeButton.W);
ThemeIni.WriteInteger(Name, 'H', ThemeButton.H);
-
- ThemeIni.WriteString(Name, 'Type', ThemeButton.Typ);
+ ThemeIni.WriteString(Name, 'Type', TextureTypeToStr(ThemeButton.Typ));
ThemeIni.WriteInteger(Name, 'Texts', Length(ThemeButton.Text));
ThemeIni.WriteString(Name, 'Color', ThemeButton.Color);