aboutsummaryrefslogtreecommitdiffstats
path: root/src/base/UCommon.pas
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-09-12 09:51:33 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-09-12 09:51:33 +0000
commitabf47ddd1fe77287136535e2d05ada48b99b8e1f (patch)
treec7bb68f38c381d1f84dd542de882cca079b9b4b2 /src/base/UCommon.pas
parentb8e1a9b524f0922329c5307b0396f78a3dc2b44f (diff)
downloadusdx-abf47ddd1fe77287136535e2d05ada48b99b8e1f.tar.gz
usdx-abf47ddd1fe77287136535e2d05ada48b99b8e1f.tar.xz
usdx-abf47ddd1fe77287136535e2d05ada48b99b8e1f.zip
- Windows resources (.rc) reduced to the icon
- Texture resource names are now directly written to resources.inc - Fonts are no resources anymore. They are moved to game/fonts and can be changed to support multiple charsets (until the TTF part is finished). Fonts are registered in fonts/fonts.in git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1367 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/base/UCommon.pas')
-rw-r--r--src/base/UCommon.pas101
1 files changed, 44 insertions, 57 deletions
diff --git a/src/base/UCommon.pas b/src/base/UCommon.pas
index 38a68d84..3f41dae6 100644
--- a/src/base/UCommon.pas
+++ b/src/base/UCommon.pas
@@ -306,87 +306,74 @@ begin
end;
-{$IFDEF Unix}
- // include resource-file info (stored in the constant array "resources")
- {$I ../resource.inc}
-{$ENDIF}
+// include resource-file info (stored in the constant array "resources")
+{$I ../resource.inc}
function GetResourceStream(const aName, aType: string): TStream;
-{$IFDEF Unix}
var
ResIndex: integer;
Filename: string;
-{$ENDIF}
begin
Result := nil;
- {$IFDEF Unix}
for ResIndex := 0 to High(resources) do
begin
- if (resources[ResIndex][0] = aName ) and
- (resources[ResIndex][1] = aType ) then
+ if (Resources[ResIndex][0] = aName ) then
begin
try
- Filename := ResourcesPath + resources[ResIndex][2];
+ Filename := ResourcesPath + Resources[ResIndex][1];
Result := TFileStream.Create(Filename, fmOpenRead);
except
- Log.LogError('Failed to open: "'+ resources[ResIndex][2] +'"', 'GetResourceStream');
+ Log.LogError('Failed to open: "'+ resources[ResIndex][1] +'"', 'GetResourceStream');
end;
- exit;
+ Exit;
end;
end;
- {$ELSE}
- try
- Result := TResourceStream.Create(HInstance, aName , PChar(aType));
- except
- Log.LogError('Invalid resource: "'+ aType + ':' + aName +'"', 'GetResourceStream');
- end;
- {$ENDIF}
end;
// +++++++++++++++++++++ helpers for RWOpsFromStream() +++++++++++++++
- function SdlStreamSeek( context : PSDL_RWops; offset : Integer; whence : Integer ) : integer; cdecl;
- var
- stream : TStream;
- origin : Word;
- begin
- stream := TStream( context.unknown );
- if ( stream = nil ) then
- raise EInvalidContainer.Create( 'SDLStreamSeek on nil' );
- case whence of
- 0 : origin := soFromBeginning; // Offset is from the beginning of the resource. Seek moves to the position Offset. Offset must be >= 0.
- 1 : origin := soFromCurrent; // Offset is from the current position in the resource. Seek moves to Position + Offset.
- 2 : origin := soFromEnd;
- else
- origin := soFromBeginning; // just in case
- end;
- Result := stream.Seek( offset, origin );
+function SdlStreamSeek( context : PSDL_RWops; offset : Integer; whence : Integer ) : integer; cdecl;
+var
+ stream : TStream;
+ origin : Word;
+begin
+ stream := TStream( context.unknown );
+ if ( stream = nil ) then
+ raise EInvalidContainer.Create( 'SDLStreamSeek on nil' );
+ case whence of
+ 0 : origin := soFromBeginning; // Offset is from the beginning of the resource. Seek moves to the position Offset. Offset must be >= 0.
+ 1 : origin := soFromCurrent; // Offset is from the current position in the resource. Seek moves to Position + Offset.
+ 2 : origin := soFromEnd;
+ else
+ origin := soFromBeginning; // just in case
end;
+ Result := stream.Seek( offset, origin );
+end;
- function SdlStreamRead( context : PSDL_RWops; Ptr : Pointer; size : Integer; maxnum: Integer ) : Integer; cdecl;
- var
- stream : TStream;
- begin
- stream := TStream( context.unknown );
- if ( stream = nil ) then
- raise EInvalidContainer.Create( 'SDLStreamRead on nil' );
- try
- Result := stream.read( Ptr^, Size * maxnum ) div size;
- except
- Result := -1;
- end;
+function SdlStreamRead( context : PSDL_RWops; Ptr : Pointer; size : Integer; maxnum: Integer ) : Integer; cdecl;
+var
+ stream : TStream;
+begin
+ stream := TStream( context.unknown );
+ if ( stream = nil ) then
+ raise EInvalidContainer.Create( 'SDLStreamRead on nil' );
+ try
+ Result := stream.read( Ptr^, Size * maxnum ) div size;
+ except
+ Result := -1;
end;
+end;
- function SDLStreamClose( context : PSDL_RWops ) : Integer; cdecl;
- var
- stream : TStream;
- begin
- stream := TStream( context.unknown );
- if ( stream = nil ) then
- raise EInvalidContainer.Create( 'SDLStreamClose on nil' );
- stream.Free;
- Result := 1;
- end;
+function SDLStreamClose( context : PSDL_RWops ) : Integer; cdecl;
+var
+ stream : TStream;
+begin
+ stream := TStream( context.unknown );
+ if ( stream = nil ) then
+ raise EInvalidContainer.Create( 'SDLStreamClose on nil' );
+ stream.Free;
+ Result := 1;
+end;
// -----------------------------------------------
(*