diff options
author | jaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-09-20 12:37:24 +0000 |
---|---|---|
committer | jaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-09-20 12:37:24 +0000 |
commit | fd5f18250e6da98c47f23f49b7c4663c9a8bf7d3 (patch) | |
tree | 4e8f12143e4bdf8c37f6e6960bad46f88ad3c706 | |
parent | 707441e6eac0f628f9c61f0130df07c6768ba291 (diff) | |
download | usdx-fd5f18250e6da98c47f23f49b7c4663c9a8bf7d3.tar.gz usdx-fd5f18250e6da98c47f23f49b7c4663c9a8bf7d3.tar.xz usdx-fd5f18250e6da98c47f23f49b7c4663c9a8bf7d3.zip |
Adding new Resource compiler for lazarus projects..
(other one did not name resources correctly)
this resource compiler could be expanded by someone to Parse
Ultrastar.rc and compile the lrs file, rather than having it hardcoded in USDXResCompiler
other changes, include ability to read the Resource String properly in code generated by lazarus.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@422 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rw-r--r-- | Game/Code/Classes/UGraphic.pas | 43 | ||||
-rw-r--r-- | Game/Code/Classes/UTexture.pas | 22 | ||||
-rw-r--r-- | Game/Code/Menu/UMenu.pas | 3 | ||||
-rw-r--r-- | Tools/USDXResCompiler.lpi | 71 | ||||
-rw-r--r-- | Tools/USDXResCompiler.lpr | 88 |
5 files changed, 202 insertions, 25 deletions
diff --git a/Game/Code/Classes/UGraphic.pas b/Game/Code/Classes/UGraphic.pas index a8728fa7..3fbef8b1 100644 --- a/Game/Code/Classes/UGraphic.pas +++ b/Game/Code/Classes/UGraphic.pas @@ -245,6 +245,12 @@ uses UMain, {$ENDIF}
Classes;
+procedure LoadFontTextures;
+begin
+ Log.LogStatus('Building Fonts', 'LoadTextures');
+ BuildFont;
+end;
+
procedure LoadTextures;
@@ -261,6 +267,8 @@ begin Tex_Right[0] := Texture.LoadTexture(pchar(Skin.GetTextureFileName('GrayRight')), 'BMP', 'Transparent', 0); //brauch man die noch?
// P1-6
+ // TODO... do it once for each player... this is a bit crappy !!
+ // can we make it any better !?
for P := 1 to 6 do
begin
LoadColor(R, G, B, 'P' + IntToStr(P) + 'Light');
@@ -307,8 +315,8 @@ begin //PhrasenBonus - Line Bonus Mod End
// tworzenie czcionek
- Log.LogStatus('Building Fonts', 'LoadTextures');
- BuildFont;
+// Log.LogStatus('Building Fonts', 'LoadTextures');
+// BuildFont;
end;
procedure Initialize3D (Title: string);
@@ -320,12 +328,13 @@ var I: Integer;
begin
Log.LogStatus('LoadOpenGL', 'Initialize3D');
- Log.BenchmarkStart(2);
+// Log.BenchmarkStart(2);
LoadOpenGL;
Log.LogStatus('SDL_Init', 'Initialize3D');
- if ( SDL_Init(SDL_INIT_VIDEO or SDL_INIT_AUDIO)= -1 ) then begin
+ if ( SDL_Init(SDL_INIT_VIDEO or SDL_INIT_AUDIO)= -1 ) then
+ begin
Log.LogError('SDL_Init Failed', 'Initialize3D');
exit;
end;
@@ -355,17 +364,17 @@ begin InitializeScreen;
- Log.BenchmarkEnd(2);
- Log.LogBenchmark('--> Setting Screen', 2);
+// Log.BenchmarkEnd(2);
+// Log.LogBenchmark('--> Setting Screen', 2);
// ladowanie tekstur
- Log.BenchmarkStart(2);
+// Log.BenchmarkStart(2);
Texture := TTextureUnit.Create;
Texture.Limit := 1024*1024;
- LoadTextures;
- Log.BenchmarkEnd(2);
- Log.LogBenchmark('--> Loading Textures', 2);
+// LoadTextures;
+// Log.BenchmarkEnd(2);
+// Log.LogBenchmark('--> Loading Textures', 2);
{ Log.BenchmarkStart(2);
Lyric:= TLyric.Create;
@@ -373,21 +382,23 @@ begin Log.LogBenchmark('--> Loading Fonts', 2);
}
- Log.BenchmarkStart(2);
+// Log.BenchmarkStart(2);
Display := TDisplay.Create;
SDL_EnableUnicode(1);
- Log.BenchmarkEnd(2); Log.LogBenchmark('====> Creating Display', 2);
+// Log.BenchmarkEnd(2); Log.LogBenchmark('====> Creating Display', 2);
- Log.LogStatus('Loading Screens', 'Initialize3D');
- Log.BenchmarkStart(3);
+// Log.LogStatus('Loading Screens', 'Initialize3D');
+// Log.BenchmarkStart(3);
+
+ LoadFontTextures();
// Show the Loading Screen -------------
LoadLoadingScreen;
Log.LogStatus('Loading Screens', 'Initialize3D');
-// LoadTextures; // jb
-// Log.LogStatus(' Loading Textures', '');
+ LoadTextures; // jb
+ Log.LogStatus(' Loading Textures', '');
diff --git a/Game/Code/Classes/UTexture.pas b/Game/Code/Classes/UTexture.pas index f01cfd23..1c436f04 100644 --- a/Game/Code/Classes/UTexture.pas +++ b/Game/Code/Classes/UTexture.pas @@ -154,32 +154,36 @@ begin // find texture entry
T := FindTexture(Name);
- if T = -1 then begin
+ if T = -1 then
+ begin
// create texture entry
T := Length(TextureDatabase.Texture);
SetLength(TextureDatabase.Texture, T+1);
+
TextureDatabase.Texture[T].Name := Name;
- TextureDatabase.Texture[T].Typ := Typ;
+ TextureDatabase.Texture[T].Typ := Typ;
// inform database that no textures have been loaded into memory
- TextureDatabase.Texture[T].Texture.TexNum := -1;
+ TextureDatabase.Texture[T].Texture.TexNum := -1;
TextureDatabase.Texture[T].TextureCache.TexNum := -1;
end;
// use preloaded texture
- if (not FromCache) or (FromCache and not Covers.CoverExists(Name)) then begin
+ if (not FromCache) or (FromCache and not Covers.CoverExists(Name)) then
+ begin
// use full texture
- if TextureDatabase.Texture[T].Texture.TexNum = -1 then begin
+ if TextureDatabase.Texture[T].Texture.TexNum = -1 then
+ begin
// load texture
TextureDatabase.Texture[T].Texture := LoadTexture(false, pchar(Name), 'JPG', pchar(Typ), $0);
end;
// use texture
Result := TextureDatabase.Texture[T].Texture;
-
end;
- if FromCache and Covers.CoverExists(Name) then begin
+ if FromCache and Covers.CoverExists(Name) then
+ begin
// use cache texture
C := Covers.CoverNumber(Name);
@@ -381,7 +385,7 @@ var begin
lTextureStream := nil;
-// Log.LogStatus( 'From Resource - ' + inttostr( integer( FromRegistry ) ) , Identifier +' '+ Format +' '+ Typ );
+ Log.LogStatus( 'From Resource - ' + inttostr( integer( FromRegistry ) ) , Identifier +' '+ Format +' '+ Typ );
// {$IFNDEF FPC}
// TODO : JB_lazarus eeeew this is a nasty one...
@@ -396,10 +400,12 @@ begin if FromRegistry then
begin
try
+ {$IFNDEF FPC}
lTextureStream := TResourceStream.Create(HInstance, Identifier, Format);
// TEmp, untill all code is moved to refactord way..
Res := TResourceStream( lTextureStream );
+ {$ENDIF}
except
Log.LogStatus( 'ERROR Could not load from resource' , Identifier +' '+ Format +' '+ Typ );
beep;
diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 1e6c1e87..ccce325e 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -288,7 +288,8 @@ end; procedure TMenu.AddBackground(Name: string);
begin
- if Name <> '' then begin
+ if Name <> '' then
+ begin
// BackImg := Texture.LoadTexture(false, PChar(Skin.SkinPath + FileName), 'JPG', 'Plain', 0); // new theme system
BackImg := Texture.GetTexture(Skin.GetTextureFileName(Name), 'Plain');
BackImg.W := 800;
diff --git a/Tools/USDXResCompiler.lpi b/Tools/USDXResCompiler.lpi new file mode 100644 index 00000000..b7c068be --- /dev/null +++ b/Tools/USDXResCompiler.lpi @@ -0,0 +1,71 @@ +<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="\"/>
+ <Version Value="5"/>
+ <General>
+ <MainUnit Value="0"/>
+ <IconPath Value="./"/>
+ <TargetFileExt Value=".exe"/>
+ <ActiveEditorIndexAtStart Value="0"/>
+ </General>
+ <VersionInfo>
+ <ProjectVersion Value=""/>
+ <Language Value=""/>
+ <CharSet Value=""/>
+ </VersionInfo>
+ <PublishOptions>
+ <Version Value="2"/>
+ <IgnoreBinaries Value="False"/>
+ <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
+ <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
+ </PublishOptions>
+ <RunParams>
+ <local>
+ <FormatVersion Value="1"/>
+ <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ </local>
+ </RunParams>
+ <RequiredPackages Count="1">
+ <Item1>
+ <PackageName Value="lcl"/>
+ </Item1>
+ </RequiredPackages>
+ <Units Count="1">
+ <Unit0>
+ <Filename Value="USDXResCompiler.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="USDXResCompiler"/>
+ <CursorPos X="47" Y="34"/>
+ <TopLine Value="1"/>
+ <EditorIndex Value="0"/>
+ <UsageCount Value="20"/>
+ <Loaded Value="True"/>
+ </Unit0>
+ </Units>
+ <JumpHistory Count="1" HistoryIndex="0">
+ <Position1>
+ <Filename Value="USDXResCompiler.lpr"/>
+ <Caret Line="6" Column="1" TopLine="1"/>
+ </Position1>
+ </JumpHistory>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <PathDelim Value="\"/>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+ <Debugging>
+ <BreakPoints Count="1">
+ <Item1>
+ <Source Value="USDXResCompiler.lpr"/>
+ <Line Value="14"/>
+ </Item1>
+ </BreakPoints>
+ </Debugging>
+</CONFIG>
diff --git a/Tools/USDXResCompiler.lpr b/Tools/USDXResCompiler.lpr new file mode 100644 index 00000000..b6d0ef7d --- /dev/null +++ b/Tools/USDXResCompiler.lpr @@ -0,0 +1,88 @@ +program USDXResCompiler;
+
+{$mode objfpc}{$H+}
+
+uses
+ Classes,
+ SysUtils,
+ LResources;
+
+var
+ lResourceFile : TMemoryStream;
+
+procedure AddFile( aResName, aResTye, aFile : string );
+var
+ lTmpStream : TmemoryStream;
+begin
+ writeln();
+ writeln( aFile );
+ if not fileexists( aFile ) then
+ begin
+ writeln( 'NOT FOUND' );
+ exit;
+ end;
+
+ lTmpStream := TmemoryStream.create();
+ try
+ lTmpStream.loadfromfile( aFile );
+ lTmpStream.position := 0;
+
+ BinaryToLazarusResourceCode(lTmpStream, lResourceFile, aResName, aResTye);
+ writeln( 'Added' );
+ finally
+ freeandnil( lTmpStream );
+ end;
+end;
+
+
+begin
+
+ lResourceFile := TMemoryStream.create();
+ try
+ AddFile( 'Font', 'PNG', '..\Fonts\Normal\eurostar_regular.png' );
+ AddFile( 'Font', 'FNT', '.\Fonts\Normal\eurostar_regular.dat' );
+
+ AddFile( 'FontB', 'PNG', '..\Fonts\Bold\eurostar_regular_bold.png' );
+ AddFile( 'FontB', 'FNT', '..\Fonts\Bold\eurostar_regular_bold.dat' );
+
+ AddFile( 'FontO', 'PNG', '..\Fonts\Outline 1\Outline 1.PNG' );
+ AddFile( 'FontO', 'FNT', '..\Fonts\Outline 1\Outline 1.dat' );
+
+ AddFile( 'FontO2', 'PNG', '..\Fonts\Outline 2\Outline 2.PNG' );
+ AddFile( 'FontO2', 'FNT', '..\Fonts\Outline 2\Outline 2.dat' );
+
+ AddFile( 'MAINICON', 'ICON', '..\Graphics\ustar-icon_v01.ico' );
+
+ AddFile( 'MAINICON', 'ICON', '..\Graphics\ustar-icon_v01.ico' );
+
+ AddFile( 'CRDTS_BG', 'PNG', '..\Graphics\credits_v5_bg.png' );
+ AddFile( 'CRDTS_OVL', 'PNG', '..\Graphics\credits_v5_overlay.png"' );
+ AddFile( 'CRDTS_blindguard', 'PNG', '..\Graphics\names_blindguard.png' );
+ AddFile( 'CRDTS_blindy', 'PNG', '..\Graphics\names_blindy.png' );
+ AddFile( 'CRDTS_canni', 'PNG', '..\Graphics\names_canni.png' );
+ AddFile( 'CRDTS_commandio', 'PNG', '..\Graphics\names_commandio.png' );
+ AddFile( 'CRDTS_lazyjoker', 'PNG', '..\Graphics\names_lazyjoker.png' );
+ AddFile( 'CRDTS_mog', 'PNG', '..\Graphics\names_mog.png' );
+ AddFile( 'CRDTS_mota', 'PNG', '..\Graphics\names_mota.png' );
+ AddFile( 'CRDTS_skillmaste', 'PNG', '..\Graphics\names_skillmaster.png' );
+ AddFile( 'CRDTS_whiteshark', 'PNG', '..\Graphics\names_whiteshark.png' );
+ AddFile( 'INTRO_L01', 'PNG', '..\Graphics\intro-l-01.png' );
+ AddFile( 'INTRO_L02', 'PNG', '..\Graphics\intro-l-02.png' );
+ AddFile( 'INTRO_L03', 'PNG', '..\Graphics\intro-l-03.png' );
+ AddFile( 'INTRO_L04', 'PNG', '..\Graphics\intro-l-04.png' );
+ AddFile( 'INTRO_L05', 'PNG', '..\Graphics\intro-l-05.png' );
+ AddFile( 'INTRO_L06', 'PNG', '..\Graphics\intro-l-06.png' );
+ AddFile( 'INTRO_L07', 'PNG', '..\Graphics\intro-l-07.png' );
+ AddFile( 'INTRO_L08', 'PNG', '..\Graphics\intro-l-08.png' );
+ AddFile( 'INTRO_L09', 'PNG', '..\Graphics\intro-l-09.png' );
+ AddFile( 'OUTRO_BG', 'PNG', '..\Graphics\outro-bg.png' );
+ AddFile( 'OUTRO_ESC', 'PNG', '..\Graphics\outro-esc.png' );
+ AddFile( 'OUTRO_EXD', 'PNG', '..\Graphics\outro-exit-dark.png' );
+
+
+ finally
+ lResourceFile.SaveToFile( 'UltraStar.lrs' );
+ freeandnil( lResourceFile );
+ end;
+end.
+
|