index bdf6605849405c044781a9cc89723a2a29c50060..613419e21e451e1f0793126bdbf9c67fe174eaf3 100644 (file)
--- a/src/game/g_textures.pas
+++ b/src/game/g_textures.pas
interface
uses
- e_graphics, BinEditor;
+ e_graphics, BinEditor, ImagingTypes, Imaging, ImagingUtility;
Type
TLevelTexture = record
procedure g_Texture_Delete(TextureName: ShortString);
procedure g_Texture_DeleteAll();
+function g_CreateFramesImg (ia: TDynImageDataArray; ID: PDWORD; Name: ShortString; BackAnimation: Boolean = False): Boolean;
+
function g_Frames_CreateWAD(ID: PDWORD; Name: ShortString; Resource: String;
FWidth, FHeight, FCount: Word; BackAnimation: Boolean = False): Boolean;
function g_Frames_CreateFile(ID: PDWORD; Name: ShortString; FileName: String;
function g_Texture_CreateWAD(var ID: DWORD; Resource: String): Boolean;
var
WAD: TWADFile;
- FileName,
- SectionName,
- ResourceName: String;
+ FileName: String;
TextureData: Pointer;
ResourceLength: Integer;
begin
Result := False;
- g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
+ FileName := g_ExtractWadName(Resource);
WAD := TWADFile.Create;
WAD.ReadFile(FileName);
- if WAD.GetResource(SectionName, ResourceName, TextureData, ResourceLength) then
+ if WAD.GetResource(g_ExtractFilePathName(Resource), TextureData, ResourceLength) then
begin
if e_CreateTextureMem(TextureData, ResourceLength, ID) then
Result := True
function g_Texture_CreateWADEx(TextureName: ShortString; Resource: String): Boolean;
var
WAD: TWADFile;
- FileName,
- SectionName,
- ResourceName: String;
+ FileName: String;
TextureData: Pointer;
find_id: DWORD;
ResourceLength: Integer;
begin
- g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
+ FileName := g_ExtractWadName(Resource);
find_id := FindTexture();
WAD := TWADFile.Create;
WAD.ReadFile(FileName);
- if WAD.GetResource(SectionName, ResourceName, TextureData, ResourceLength) then
+ if WAD.GetResource(g_ExtractFilePathName(Resource), TextureData, ResourceLength) then
begin
Result := e_CreateTextureMem(TextureData, ResourceLength, TexturesArray[find_id].ID);
if Result then
Result := True;
end;
+function g_CreateFramesImg (ia: TDynImageDataArray; ID: PDWORD; Name: ShortString; BackAnimation: Boolean = False): Boolean;
+var
+ find_id: DWORD;
+ a, FCount: Integer;
+begin
+ result := false;
+ find_id := FindFrame();
+
+ FCount := length(ia);
+
+ //e_WriteLog(Format('+++ creating %d frames [%s]', [FCount, Name]), MSG_NOTIFY);
+
+ if FCount < 1 then exit;
+ if FCount <= 2 then BackAnimation := False;
+ if BackAnimation then
+ SetLength(FramesArray[find_id].TexturesID, FCount+FCount-2)
+ else
+ SetLength(FramesArray[find_id].TexturesID, FCount);
+
+ //e_WriteLog(Format('+++ creating %d frames, %dx%d', [FCount, ia[0].width, ia[0].height]), MSG_NOTIFY);
+
+ for a := 0 to FCount-1 do
+ begin
+ if not e_CreateTextureImg(ia[a], FramesArray[find_id].TexturesID[a]) then exit;
+ //e_WriteLog(Format('+++ frame %d, %dx%d', [a, ia[a].width, ia[a].height]), MSG_NOTIFY);
+ end;
+
+ if BackAnimation then
+ begin
+ for a := 1 to FCount-2 do
+ begin
+ FramesArray[find_id].TexturesID[FCount+FCount-2-a] := FramesArray[find_id].TexturesID[a];
+ end;
+ end;
+
+ FramesArray[find_id].FrameWidth := ia[0].width;
+ FramesArray[find_id].FrameHeight := ia[0].height;
+ if Name <> '' then
+ FramesArray[find_id].Name := LowerCase(Name)
+ else
+ FramesArray[find_id].Name := '<noname>';
+
+ if ID <> nil then ID^ := find_id;
+
+ result := true;
+end;
+
function g_Frames_CreateWAD(ID: PDWORD; Name: ShortString; Resource: string;
FWidth, FHeight, FCount: Word; BackAnimation: Boolean = False): Boolean;
var
WAD: TWADFile;
- FileName,
- SectionName,
- ResourceName: string;
+ FileName: string;
TextureData: Pointer;
ResourceLength: Integer;
begin
Result := False;
- g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
+ FileName := g_ExtractWadName(Resource);
WAD := TWADFile.Create();
WAD.ReadFile(FileName);
- if not WAD.GetResource(SectionName, ResourceName, TextureData, ResourceLength) then
+ if not WAD.GetResource(g_ExtractFilePathName(Resource), TextureData, ResourceLength) then
begin
WAD.Free();
e_WriteLog(Format('Error loading texture %s', [Resource]), MSG_WARNING);