diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-09-12 13:19:17 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-09-12 13:19:17 +0000 |
commit | 3b5af758a1ffb8c02c3fad2ef0acbc0c241b3de5 (patch) | |
tree | ea37b112534f7ffebe7a1b280cbe282f31ff4f6d /src/base | |
parent | f2d6710b465289c3e0ce7a8b9844b37be6a15974 (diff) | |
download | usdx-3b5af758a1ffb8c02c3fad2ef0acbc0c241b3de5.tar.gz usdx-3b5af758a1ffb8c02c3fad2ef0acbc0c241b3de5.tar.xz usdx-3b5af758a1ffb8c02c3fad2ef0acbc0c241b3de5.zip |
removed resource.inc
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1371 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/UCommon.pas | 27 | ||||
-rw-r--r-- | src/base/UGraphic.pas | 5 | ||||
-rw-r--r-- | src/base/UImage.pas | 68 |
3 files changed, 21 insertions, 79 deletions
diff --git a/src/base/UCommon.pas b/src/base/UCommon.pas index 3f41dae6..f2f98537 100644 --- a/src/base/UCommon.pas +++ b/src/base/UCommon.pas @@ -25,7 +25,6 @@ procedure ShowMessage( const msg : String; msgType: TMessageType = mtInfo ); procedure ConsoleWriteLn(const msg: string); -function GetResourceStream(const aName, aType : string): TStream; function RWopsFromStream(Stream: TStream): PSDL_RWops; {$IFDEF FPC} @@ -305,32 +304,6 @@ begin {$IFEND} end; - -// include resource-file info (stored in the constant array "resources") -{$I ../resource.inc} - -function GetResourceStream(const aName, aType: string): TStream; -var - ResIndex: integer; - Filename: string; -begin - Result := nil; - - for ResIndex := 0 to High(resources) do - begin - if (Resources[ResIndex][0] = aName ) then - begin - try - Filename := ResourcesPath + Resources[ResIndex][1]; - Result := TFileStream.Create(Filename, fmOpenRead); - except - Log.LogError('Failed to open: "'+ resources[ResIndex][1] +'"', 'GetResourceStream'); - end; - Exit; - end; - end; -end; - // +++++++++++++++++++++ helpers for RWOpsFromStream() +++++++++++++++ function SdlStreamSeek( context : PSDL_RWops; offset : Integer; whence : Integer ) : integer; cdecl; var diff --git a/src/base/UGraphic.pas b/src/base/UGraphic.pas index e8312300..6fa0aa8f 100644 --- a/src/base/UGraphic.pas +++ b/src/base/UGraphic.pas @@ -416,6 +416,9 @@ begin //Load_GL_EXT_framebuffer_object(); end; +const + WINDOW_ICON = 'icons/ultrastardx-icon.png'; + procedure Initialize3D (Title: string); var Icon: PSDL_Surface; @@ -428,7 +431,7 @@ begin end; // load icon image (must be 32x32 for win32) - Icon := LoadImage('WINDOWICON'); + Icon := LoadImage(ResourcesPath + WINDOW_ICON); if (Icon <> nil) then SDL_WM_SetIcon(Icon, 0); diff --git a/src/base/UImage.pas b/src/base/UImage.pas index d33c0d38..5114df25 100644 --- a/src/base/UImage.pas +++ b/src/base/UImage.pas @@ -119,7 +119,7 @@ function WriteJPGImage(const FileName: string; Surface: PSDL_Surface; Quality: i * Image loading *******************************************************) -function LoadImage(const Identifier: string): PSDL_Surface; +function LoadImage(const Filename: string): PSDL_Surface; (******************************************************* * Image manipulation @@ -741,64 +741,30 @@ end; (* - * Loads an image from the given file or resource + * Loads an image from the given file *) -function LoadImage(const Identifier: string): PSDL_Surface; +function LoadImage(const Filename: string): PSDL_Surface; var - TexRWops: PSDL_RWops; - TexStream: TStream; - FileName: string; + FilenameFound: string; begin Result := nil; - TexRWops := nil; - if Identifier = '' then - exit; + // FileExistsInsensitive() requires a var-arg + FilenameFound := Filename; - //Log.LogStatus( Identifier, 'LoadImage' ); - - FileName := Identifier; - - if (FileExistsInsensitive(FileName)) then + // try to find the file case insensitive + if (not FileExistsInsensitive(FilenameFound)) then begin - // load from file - //Log.LogStatus( 'Is File ( Loading : '+FileName+')', ' LoadImage' ); - try - Result := IMG_Load(PChar(FileName)); - //Log.LogStatus( ' '+inttostr( integer( Result ) ), ' LoadImage' ); - except - Log.LogError('Could not load from file "'+FileName+'"', 'LoadImage'); - Exit; - end; - end - else - begin - //Log.LogStatus( 'IS Resource, because file does not exist.('+Identifier+')', ' LoadImage' ); - - TexStream := GetResourceStream(Identifier, 'TEX'); - if (not assigned(TexStream)) then - begin - Log.LogError( 'Invalid file or resource "'+ Identifier+'"', 'LoadImage'); - Exit; - end; - - TexRWops := RWopsFromStream(TexStream); - if (TexRWops = nil) then - begin - Log.LogError( 'Could not assign resource "'+Identifier+'"', 'LoadImage'); - TexStream.Free(); - Exit; - end; - - //Log.LogStatus( 'resource Assigned....' , Identifier); - try - Result := IMG_Load_RW(TexRWops, 0); - except - Log.LogError( 'Could not read resource "'+Identifier+'"', 'LoadImage'); - end; + Log.LogError('Image-File does not exist "'+FilenameFound+'"', 'LoadImage'); + Exit; + end; - SDL_FreeRW(TexRWops); - TexStream.Free(); + // load from file + try + Result := IMG_Load(PChar(FilenameFound)); + except + Log.LogError('Could not load from file "'+FilenameFound+'"', 'LoadImage'); + Exit; end; end; |