From fd5f18250e6da98c47f23f49b7c4663c9a8bf7d3 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 20 Sep 2007 12:37:24 +0000 Subject: 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 --- Tools/USDXResCompiler.lpr | 88 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Tools/USDXResCompiler.lpr (limited to 'Tools/USDXResCompiler.lpr') 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. + -- cgit v1.2.3 From cf1102dac69a569279ae05dd95426d9e1c544ffc Mon Sep 17 00:00:00 2001 From: jaybinks Date: Sat, 22 Sep 2007 08:15:59 +0000 Subject: minor bug fixes to have lazarus build load resources into SDL_Image correctly... ( lazarus Resources are weak compared to delphi :( ) also Laz build will now run, and main loop works properly. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@429 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Tools/USDXResCompiler.lpr | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'Tools/USDXResCompiler.lpr') diff --git a/Tools/USDXResCompiler.lpr b/Tools/USDXResCompiler.lpr index b6d0ef7d..5acdd8d9 100644 --- a/Tools/USDXResCompiler.lpr +++ b/Tools/USDXResCompiler.lpr @@ -10,15 +10,13 @@ uses var lResourceFile : TMemoryStream; -procedure AddFile( aResName, aResTye, aFile : string ); +procedure AddFile( aResName, aResType, aFile : string ); var lTmpStream : TmemoryStream; begin - writeln(); - writeln( aFile ); if not fileexists( aFile ) then begin - writeln( 'NOT FOUND' ); + writeln( 'SKIPED' + ' ( '+aFile+' ) File not found' ); exit; end; @@ -27,8 +25,8 @@ begin lTmpStream.loadfromfile( aFile ); lTmpStream.position := 0; - BinaryToLazarusResourceCode(lTmpStream, lResourceFile, aResName, aResTye); - writeln( 'Added' ); + BinaryToLazarusResourceCode(lTmpStream, lResourceFile, aResName, aResType); + writeln( 'ADDED - ' + aResType + ' : ' + aResName + ' ( '+aFile+' )' ); finally freeandnil( lTmpStream ); end; @@ -39,21 +37,20 @@ begin lResourceFile := TMemoryStream.create(); try - AddFile( 'Font', 'PNG', '..\Fonts\Normal\eurostar_regular.png' ); - AddFile( 'Font', 'FNT', '.\Fonts\Normal\eurostar_regular.dat' ); + AddFile( 'Font', 'TEX', '..\Fonts\Normal\eurostar_regular.png' ); + AddFile( 'Font', 'FNT', '..\Fonts\Normal\eurostar_regular.dat' ); - AddFile( 'FontB', 'PNG', '..\Fonts\Bold\eurostar_regular_bold.png' ); + AddFile( 'FontB', 'TEX', '..\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', 'TEX', '..\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', 'TEX', '..\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"' ); -- cgit v1.2.3 From 82621bfeb1ccbda7425b5d11b8315a9cb91509c2 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Sun, 30 Sep 2007 04:54:03 +0000 Subject: fixed credits screen in lazarus build. ( now looks and operates the same as delphi build ) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@450 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Tools/USDXResCompiler.lpr | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'Tools/USDXResCompiler.lpr') diff --git a/Tools/USDXResCompiler.lpr b/Tools/USDXResCompiler.lpr index 5acdd8d9..38f4a1e5 100644 --- a/Tools/USDXResCompiler.lpr +++ b/Tools/USDXResCompiler.lpr @@ -52,29 +52,29 @@ begin 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' ); + AddFile( 'CRDTS_BG', 'TEX', '..\Graphics\credits_v5_bg.png' ); + AddFile( 'CRDTS_OVL', 'TEX', '..\Graphics\credits_v5_overlay.png' ); + AddFile( 'CRDTS_blindguard', 'TEX', '..\Graphics\names_blindguard.png' ); + AddFile( 'CRDTS_blindy', 'TEX', '..\Graphics\names_blindy.png' ); + AddFile( 'CRDTS_canni', 'TEX', '..\Graphics\names_canni.png' ); + AddFile( 'CRDTS_commandio', 'TEX', '..\Graphics\names_commandio.png' ); + AddFile( 'CRDTS_lazyjoker', 'TEX', '..\Graphics\names_lazyjoker.png' ); + AddFile( 'CRDTS_mog', 'TEX', '..\Graphics\names_mog.png' ); + AddFile( 'CRDTS_mota', 'TEX', '..\Graphics\names_mota.png' ); + AddFile( 'CRDTS_skillmaste', 'TEX', '..\Graphics\names_skillmaster.png' ); + AddFile( 'CRDTS_whiteshark', 'TEX', '..\Graphics\names_whiteshark.png' ); + AddFile( 'INTRO_L01', 'TEX', '..\Graphics\intro-l-01.png' ); + AddFile( 'INTRO_L02', 'TEX', '..\Graphics\intro-l-02.png' ); + AddFile( 'INTRO_L03', 'TEX', '..\Graphics\intro-l-03.png' ); + AddFile( 'INTRO_L04', 'TEX', '..\Graphics\intro-l-04.png' ); + AddFile( 'INTRO_L05', 'TEX', '..\Graphics\intro-l-05.png' ); + AddFile( 'INTRO_L06', 'TEX', '..\Graphics\intro-l-06.png' ); + AddFile( 'INTRO_L07', 'TEX', '..\Graphics\intro-l-07.png' ); + AddFile( 'INTRO_L08', 'TEX', '..\Graphics\intro-l-08.png' ); + AddFile( 'INTRO_L09', 'TEX', '..\Graphics\intro-l-09.png' ); + AddFile( 'OUTRO_BG', 'TEX', '..\Graphics\outro-bg.png' ); + AddFile( 'OUTRO_ESC', 'TEX', '..\Graphics\outro-esc.png' ); + AddFile( 'OUTRO_EXD', 'TEX', '..\Graphics\outro-exit-dark.png' ); finally -- cgit v1.2.3 From 1df4ec21cdf891aa4302b2fda620069d8d765a70 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Sun, 30 Sep 2007 06:35:59 +0000 Subject: updated USDX-Lazaurs Resource compiler.. it now reads the Ultrastar.rc file and builds based on that. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@452 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Tools/USDXResCompiler.lpr | 76 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 2 deletions(-) (limited to 'Tools/USDXResCompiler.lpr') diff --git a/Tools/USDXResCompiler.lpr b/Tools/USDXResCompiler.lpr index 38f4a1e5..6fc98efc 100644 --- a/Tools/USDXResCompiler.lpr +++ b/Tools/USDXResCompiler.lpr @@ -14,6 +14,11 @@ procedure AddFile( aResName, aResType, aFile : string ); var lTmpStream : TmemoryStream; begin + if aFile[1] = '"' then + begin + aFile := copy( aFile, 2, length( aFile ) - 2 ); + end; + if not fileexists( aFile ) then begin writeln( 'SKIPED' + ' ( '+aFile+' ) File not found' ); @@ -31,12 +36,77 @@ begin freeandnil( lTmpStream ); end; end; + +procedure addresourceline( aRCLine : String ); +var + lName : String; + lType : String; + lFile : String; + lTmp , + lTmp2 : Integer; +begin + if trim( aRCLine ) = '' then + exit; + + if aRCLine[1] = '#' then + exit; + + if ( aRCLine[1] = '/' ) AND + ( aRCLine[2] = '/' ) THEN + exit; + + // find 2nd column... and put it in lTmp + lTmp := pos( ' ', aRcLine ); + lTmp2 := pos( #9, aRcLine ); + if lTmp2 < lTmp then + lTmp := lTmp2; - + // Name = Start to lTmp + lName := trim( copy( aRcLine, 1, lTmp ) ); + + // Type = lTmp to first " + lTmp2 := pos( '"', aRcLine ); + lType := trim( copy( aRcLine, lTmp, lTmp2-lTmp ) ); + + // File = " to end of line + lFile := trim( copy( aRcLine, lTmp2, maxint ) ); + +(* + writeln( aRcLine ); + writeln( lName ); + writeln( lType ); + writeln( lFile ); + writeln( '' ); +*) + AddFile( lName , lType , lFile ); + +end; + + +var + lRCFile : TStringList; + iCount : Integer; begin + if not fileexists( paramstr(1) ) then + begin + writeln( 'MUST Specify Delphi format RC File' ); + exit; + end; + lRCFile := TStringList.create(); lResourceFile := TMemoryStream.create(); try + lRCFile.loadfromfile( paramstr(1) ); + + if trim( lRCFile.text ) = '' then + exit; + + for iCount := 0 to lRCFile.count -1 do + begin + addresourceline( lRCFile[ iCount ] ); + end; + +(* AddFile( 'Font', 'TEX', '..\Fonts\Normal\eurostar_regular.png' ); AddFile( 'Font', 'FNT', '..\Fonts\Normal\eurostar_regular.dat' ); @@ -75,11 +145,13 @@ begin AddFile( 'OUTRO_BG', 'TEX', '..\Graphics\outro-bg.png' ); AddFile( 'OUTRO_ESC', 'TEX', '..\Graphics\outro-esc.png' ); AddFile( 'OUTRO_EXD', 'TEX', '..\Graphics\outro-exit-dark.png' ); - +*) finally lResourceFile.SaveToFile( 'UltraStar.lrs' ); freeandnil( lResourceFile ); + + freeandnil( lRCFile ); end; end. -- cgit v1.2.3 From bcf55203a81aef383d0a7123996e872fa3a297dc Mon Sep 17 00:00:00 2001 From: jaybinks Date: Tue, 2 Oct 2007 04:37:08 +0000 Subject: Fixed resource compiler to work fine with linux paths. :) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@459 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Tools/USDXResCompiler.lpr | 316 +++++++++++++++++++++++----------------------- 1 file changed, 159 insertions(+), 157 deletions(-) (limited to 'Tools/USDXResCompiler.lpr') diff --git a/Tools/USDXResCompiler.lpr b/Tools/USDXResCompiler.lpr index 6fc98efc..8e6e7921 100644 --- a/Tools/USDXResCompiler.lpr +++ b/Tools/USDXResCompiler.lpr @@ -1,157 +1,159 @@ -program USDXResCompiler; - -{$mode objfpc}{$H+} - -uses - Classes, - SysUtils, - LResources; - -var - lResourceFile : TMemoryStream; - -procedure AddFile( aResName, aResType, aFile : string ); -var - lTmpStream : TmemoryStream; -begin - if aFile[1] = '"' then - begin - aFile := copy( aFile, 2, length( aFile ) - 2 ); - end; - - if not fileexists( aFile ) then - begin - writeln( 'SKIPED' + ' ( '+aFile+' ) File not found' ); - exit; - end; - - lTmpStream := TmemoryStream.create(); - try - lTmpStream.loadfromfile( aFile ); - lTmpStream.position := 0; - - BinaryToLazarusResourceCode(lTmpStream, lResourceFile, aResName, aResType); - writeln( 'ADDED - ' + aResType + ' : ' + aResName + ' ( '+aFile+' )' ); - finally - freeandnil( lTmpStream ); - end; -end; - -procedure addresourceline( aRCLine : String ); -var - lName : String; - lType : String; - lFile : String; - lTmp , - lTmp2 : Integer; -begin - if trim( aRCLine ) = '' then - exit; - - if aRCLine[1] = '#' then - exit; - - if ( aRCLine[1] = '/' ) AND - ( aRCLine[2] = '/' ) THEN - exit; - - // find 2nd column... and put it in lTmp - lTmp := pos( ' ', aRcLine ); - lTmp2 := pos( #9, aRcLine ); - if lTmp2 < lTmp then - lTmp := lTmp2; - - // Name = Start to lTmp - lName := trim( copy( aRcLine, 1, lTmp ) ); - - // Type = lTmp to first " - lTmp2 := pos( '"', aRcLine ); - lType := trim( copy( aRcLine, lTmp, lTmp2-lTmp ) ); - - // File = " to end of line - lFile := trim( copy( aRcLine, lTmp2, maxint ) ); - -(* - writeln( aRcLine ); - writeln( lName ); - writeln( lType ); - writeln( lFile ); - writeln( '' ); -*) - AddFile( lName , lType , lFile ); - -end; - - -var - lRCFile : TStringList; - iCount : Integer; -begin - if not fileexists( paramstr(1) ) then - begin - writeln( 'MUST Specify Delphi format RC File' ); - exit; - end; - - lRCFile := TStringList.create(); - lResourceFile := TMemoryStream.create(); - try - lRCFile.loadfromfile( paramstr(1) ); - - if trim( lRCFile.text ) = '' then - exit; - - for iCount := 0 to lRCFile.count -1 do - begin - addresourceline( lRCFile[ iCount ] ); - end; - -(* - AddFile( 'Font', 'TEX', '..\Fonts\Normal\eurostar_regular.png' ); - AddFile( 'Font', 'FNT', '..\Fonts\Normal\eurostar_regular.dat' ); - - AddFile( 'FontB', 'TEX', '..\Fonts\Bold\eurostar_regular_bold.png' ); - AddFile( 'FontB', 'FNT', '..\Fonts\Bold\eurostar_regular_bold.dat' ); - - AddFile( 'FontO', 'TEX', '..\Fonts\Outline 1\Outline 1.PNG' ); - AddFile( 'FontO', 'FNT', '..\Fonts\Outline 1\Outline 1.dat' ); - - AddFile( 'FontO2', 'TEX', '..\Fonts\Outline 2\Outline 2.PNG' ); - AddFile( 'FontO2', 'FNT', '..\Fonts\Outline 2\Outline 2.dat' ); - - AddFile( 'MAINICON', 'ICON', '..\Graphics\ustar-icon_v01.ico' ); - - - AddFile( 'CRDTS_BG', 'TEX', '..\Graphics\credits_v5_bg.png' ); - AddFile( 'CRDTS_OVL', 'TEX', '..\Graphics\credits_v5_overlay.png' ); - AddFile( 'CRDTS_blindguard', 'TEX', '..\Graphics\names_blindguard.png' ); - AddFile( 'CRDTS_blindy', 'TEX', '..\Graphics\names_blindy.png' ); - AddFile( 'CRDTS_canni', 'TEX', '..\Graphics\names_canni.png' ); - AddFile( 'CRDTS_commandio', 'TEX', '..\Graphics\names_commandio.png' ); - AddFile( 'CRDTS_lazyjoker', 'TEX', '..\Graphics\names_lazyjoker.png' ); - AddFile( 'CRDTS_mog', 'TEX', '..\Graphics\names_mog.png' ); - AddFile( 'CRDTS_mota', 'TEX', '..\Graphics\names_mota.png' ); - AddFile( 'CRDTS_skillmaste', 'TEX', '..\Graphics\names_skillmaster.png' ); - AddFile( 'CRDTS_whiteshark', 'TEX', '..\Graphics\names_whiteshark.png' ); - AddFile( 'INTRO_L01', 'TEX', '..\Graphics\intro-l-01.png' ); - AddFile( 'INTRO_L02', 'TEX', '..\Graphics\intro-l-02.png' ); - AddFile( 'INTRO_L03', 'TEX', '..\Graphics\intro-l-03.png' ); - AddFile( 'INTRO_L04', 'TEX', '..\Graphics\intro-l-04.png' ); - AddFile( 'INTRO_L05', 'TEX', '..\Graphics\intro-l-05.png' ); - AddFile( 'INTRO_L06', 'TEX', '..\Graphics\intro-l-06.png' ); - AddFile( 'INTRO_L07', 'TEX', '..\Graphics\intro-l-07.png' ); - AddFile( 'INTRO_L08', 'TEX', '..\Graphics\intro-l-08.png' ); - AddFile( 'INTRO_L09', 'TEX', '..\Graphics\intro-l-09.png' ); - AddFile( 'OUTRO_BG', 'TEX', '..\Graphics\outro-bg.png' ); - AddFile( 'OUTRO_ESC', 'TEX', '..\Graphics\outro-esc.png' ); - AddFile( 'OUTRO_EXD', 'TEX', '..\Graphics\outro-exit-dark.png' ); -*) - - finally - lResourceFile.SaveToFile( 'UltraStar.lrs' ); - freeandnil( lResourceFile ); - - freeandnil( lRCFile ); - end; -end. - +program USDXResCompiler; + +{$mode objfpc}{$H+} + +uses + Classes, + SysUtils, + LResources; + +var + lResourceFile : TMemoryStream; + +procedure AddFile( aResName, aResType, aFile : string ); +var + lTmpStream : TmemoryStream; +begin + if aFile[1] = '"' then + begin + aFile := copy( aFile, 2, length( aFile ) - 2 ); + end; + + if not fileexists( aFile ) then + begin + writeln( 'SKIPED' + ' ( '+aFile+' ) File not found' ); + exit; + end; + + lTmpStream := TmemoryStream.create(); + try + lTmpStream.loadfromfile( aFile ); + lTmpStream.position := 0; + + BinaryToLazarusResourceCode(lTmpStream, lResourceFile, aResName, aResType); + writeln( 'ADDED - ' + aResType + ' : ' + aResName + ' ( '+aFile+' )' ); + finally + freeandnil( lTmpStream ); + end; +end; + +procedure addresourceline( aRCLine : String ); +var + lName : String; + lType : String; + lFile : String; + lTmp , + lTmp2 : Integer; +begin + if trim( aRCLine ) = '' then + exit; + + if aRCLine[1] = '#' then + exit; + + if ( aRCLine[1] = '/' ) AND + ( aRCLine[2] = '/' ) THEN + exit; + + // find 2nd column... and put it in lTmp + lTmp := pos( ' ', aRcLine ); + lTmp2 := pos( #9, aRcLine ); + if lTmp2 < lTmp then + lTmp := lTmp2; + + // Name = Start to lTmp + lName := trim( copy( aRcLine, 1, lTmp ) ); + + // Type = lTmp to first " + lTmp2 := pos( '"', aRcLine ); + lType := trim( copy( aRcLine, lTmp, lTmp2-lTmp ) ); + + // File = " to end of line + lFile := trim( copy( aRcLine, lTmp2, maxint ) ); + + lFile := StringReplace( lFile, '\', PathDelim ,[rfReplaceAll] ); + +(* + writeln( aRcLine ); + writeln( lName ); + writeln( lType ); + writeln( lFile ); + writeln( '' ); +*) + AddFile( lName , lType , lFile ); + +end; + + +var + lRCFile : TStringList; + iCount : Integer; +begin + if not fileexists( paramstr(1) ) then + begin + writeln( 'MUST Specify Delphi format RC File' ); + exit; + end; + + lRCFile := TStringList.create(); + lResourceFile := TMemoryStream.create(); + try + lRCFile.loadfromfile( paramstr(1) ); + + if trim( lRCFile.text ) = '' then + exit; + + for iCount := 0 to lRCFile.count -1 do + begin + addresourceline( lRCFile[ iCount ] ); + end; + +(* + AddFile( 'Font', 'TEX', '..\Fonts\Normal\eurostar_regular.png' ); + AddFile( 'Font', 'FNT', '..\Fonts\Normal\eurostar_regular.dat' ); + + AddFile( 'FontB', 'TEX', '..\Fonts\Bold\eurostar_regular_bold.png' ); + AddFile( 'FontB', 'FNT', '..\Fonts\Bold\eurostar_regular_bold.dat' ); + + AddFile( 'FontO', 'TEX', '..\Fonts\Outline 1\Outline 1.PNG' ); + AddFile( 'FontO', 'FNT', '..\Fonts\Outline 1\Outline 1.dat' ); + + AddFile( 'FontO2', 'TEX', '..\Fonts\Outline 2\Outline 2.PNG' ); + AddFile( 'FontO2', 'FNT', '..\Fonts\Outline 2\Outline 2.dat' ); + + AddFile( 'MAINICON', 'ICON', '..\Graphics\ustar-icon_v01.ico' ); + + + AddFile( 'CRDTS_BG', 'TEX', '..\Graphics\credits_v5_bg.png' ); + AddFile( 'CRDTS_OVL', 'TEX', '..\Graphics\credits_v5_overlay.png' ); + AddFile( 'CRDTS_blindguard', 'TEX', '..\Graphics\names_blindguard.png' ); + AddFile( 'CRDTS_blindy', 'TEX', '..\Graphics\names_blindy.png' ); + AddFile( 'CRDTS_canni', 'TEX', '..\Graphics\names_canni.png' ); + AddFile( 'CRDTS_commandio', 'TEX', '..\Graphics\names_commandio.png' ); + AddFile( 'CRDTS_lazyjoker', 'TEX', '..\Graphics\names_lazyjoker.png' ); + AddFile( 'CRDTS_mog', 'TEX', '..\Graphics\names_mog.png' ); + AddFile( 'CRDTS_mota', 'TEX', '..\Graphics\names_mota.png' ); + AddFile( 'CRDTS_skillmaste', 'TEX', '..\Graphics\names_skillmaster.png' ); + AddFile( 'CRDTS_whiteshark', 'TEX', '..\Graphics\names_whiteshark.png' ); + AddFile( 'INTRO_L01', 'TEX', '..\Graphics\intro-l-01.png' ); + AddFile( 'INTRO_L02', 'TEX', '..\Graphics\intro-l-02.png' ); + AddFile( 'INTRO_L03', 'TEX', '..\Graphics\intro-l-03.png' ); + AddFile( 'INTRO_L04', 'TEX', '..\Graphics\intro-l-04.png' ); + AddFile( 'INTRO_L05', 'TEX', '..\Graphics\intro-l-05.png' ); + AddFile( 'INTRO_L06', 'TEX', '..\Graphics\intro-l-06.png' ); + AddFile( 'INTRO_L07', 'TEX', '..\Graphics\intro-l-07.png' ); + AddFile( 'INTRO_L08', 'TEX', '..\Graphics\intro-l-08.png' ); + AddFile( 'INTRO_L09', 'TEX', '..\Graphics\intro-l-09.png' ); + AddFile( 'OUTRO_BG', 'TEX', '..\Graphics\outro-bg.png' ); + AddFile( 'OUTRO_ESC', 'TEX', '..\Graphics\outro-esc.png' ); + AddFile( 'OUTRO_EXD', 'TEX', '..\Graphics\outro-exit-dark.png' ); +*) + + finally + lResourceFile.SaveToFile( 'UltraStar.lrs' ); + freeandnil( lResourceFile ); + + freeandnil( lRCFile ); + end; +end. + -- cgit v1.2.3