2009-12-10 22:05:38 +01:00
|
|
|
(*
|
|
|
|
* CDDL HEADER START
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the terms of the
|
|
|
|
* Common Development and Distribution License, Version 1.0 only
|
|
|
|
* (the "License"). You may not use this file except in compliance
|
|
|
|
* with the License.
|
|
|
|
*
|
|
|
|
* You can obtain a copy of the license at
|
|
|
|
* http://www.opensource.org/licenses/cddl1.php.
|
|
|
|
* See the License for the specific language governing permissions
|
|
|
|
* and limitations under the License.
|
|
|
|
*
|
|
|
|
* When distributing Covered Code, include this CDDL HEADER in each
|
|
|
|
* file and include the License file at
|
|
|
|
* http://www.opensource.org/licenses/cddl1.php. If applicable,
|
|
|
|
* add the following below this CDDL HEADER, with the fields enclosed
|
|
|
|
* by brackets "[]" replaced with your own identifying * information:
|
|
|
|
* Portions Copyright [yyyy] [name of copyright owner]
|
|
|
|
*
|
|
|
|
* CDDL HEADER END
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Portions Copyright 2009 Andreas Schneider
|
|
|
|
*)
|
|
|
|
unit UTexmapProvider;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2015-05-01 12:23:03 +02:00
|
|
|
Classes, UMulProvider, UMulBlock, UGenericIndex, UTexture;
|
2009-12-10 22:05:38 +01:00
|
|
|
|
|
|
|
type
|
|
|
|
TTexmapProvider = class(TIndexedMulProvider)
|
2015-05-01 12:23:03 +02:00
|
|
|
constructor Create(OldFormat: Boolean; AData, AIndex: TStream; AReadOnly: Boolean = False); overload;
|
|
|
|
constructor Create(OldFormat: Boolean; AData, AIndex: string; AReadOnly: Boolean = False); overload;
|
2009-12-10 22:05:38 +01:00
|
|
|
protected
|
2015-05-01 12:23:03 +02:00
|
|
|
UseOldArtFormat: Boolean;
|
2009-12-10 22:05:38 +01:00
|
|
|
function GetData(AID: Integer; AIndex: TGenericIndex): TMulBlock; override;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2015-05-01 12:23:03 +02:00
|
|
|
uses
|
|
|
|
Logging;
|
|
|
|
|
2009-12-10 22:05:38 +01:00
|
|
|
{ TTexmapProvider }
|
|
|
|
|
2015-05-01 12:23:03 +02:00
|
|
|
constructor TTexmapProvider.Create(OldFormat: Boolean; AData, AIndex: TStream; AReadOnly: Boolean = False);
|
|
|
|
begin
|
|
|
|
inherited Create(AData, AIndex, AReadOnly);
|
|
|
|
UseOldArtFormat := OldFormat;
|
|
|
|
if UseOldArtFormat
|
|
|
|
then Logger.Send([lcInfo], 'Using textures in ArtData')
|
|
|
|
else Logger.Send([lcInfo], 'Using textures in TexMaps');
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TTexmapProvider.Create(OldFormat: Boolean; AData, AIndex: string; AReadOnly: Boolean = False);
|
|
|
|
begin
|
|
|
|
inherited Create(AData, AIndex, AReadOnly);
|
|
|
|
UseOldArtFormat := OldFormat;
|
|
|
|
if UseOldArtFormat
|
|
|
|
then Logger.Send([lcInfo], 'Using textures in ArtData')
|
|
|
|
else Logger.Send([lcInfo], 'Using textures in TexMaps');
|
|
|
|
end;
|
|
|
|
|
2009-12-10 22:05:38 +01:00
|
|
|
function TTexmapProvider.GetData(AID: Integer; AIndex: TGenericIndex): TMulBlock;
|
|
|
|
begin
|
2015-05-01 12:23:03 +02:00
|
|
|
if (AIndex.Lookup > -1) and (AIndex.Size > 0) then begin
|
|
|
|
//Result := TTexture.Create(FData, AIndex)
|
|
|
|
if not UseOldArtFormat
|
|
|
|
then Result := TTexture.Create(FData, AIndex)
|
|
|
|
else Result := TOldTexture.Create(Cardinal(AID));
|
|
|
|
end else
|
2009-12-10 22:05:38 +01:00
|
|
|
Result := TTexture.Create(-1);
|
|
|
|
Result.ID := AID;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|
|
|
|
|
|
|
|
|