X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fgame%2Fg_textures.pas;h=af3b29ff8e464f1fe8467a2b804ea384bd8d0ba5;hb=ff152ddb08bd84058c4162fcee523a2864a26368;hp=0688391518db7252157ff16858960d6636178899;hpb=082b546b38711030b4490facbefa37a331cb1a37;p=d2df-sdl.git diff --git a/src/game/g_textures.pas b/src/game/g_textures.pas index 0688391..af3b29f 100644 --- a/src/game/g_textures.pas +++ b/src/game/g_textures.pas @@ -19,7 +19,7 @@ unit g_textures; interface uses - e_graphics, BinEditor, ImagingTypes, Imaging, ImagingUtility; + e_graphics, MAPDEF, BinEditor, ImagingTypes, Imaging, ImagingUtility; Type TLevelTexture = record @@ -55,7 +55,7 @@ Type constructor Create(FramesID: DWORD; Loop: Boolean; Speed: Byte); destructor Destroy(); override; procedure Draw(X, Y: Integer; Mirror: TMirrorType); - procedure DrawEx(X, Y: Integer; Mirror: TMirrorType; RPoint: TPoint; + procedure DrawEx(X, Y: Integer; Mirror: TMirrorType; RPoint: TDFPoint; Angle: SmallInt); procedure Reset(); procedure Update(); @@ -84,7 +84,7 @@ Type function g_Texture_CreateWAD(var ID: DWORD; Resource: String): Boolean; function g_Texture_CreateFile(var ID: DWORD; FileName: String): Boolean; -function g_Texture_CreateWADEx(TextureName: ShortString; Resource: String): Boolean; +function g_Texture_CreateWADEx(TextureName: ShortString; Resource: String; altrsrc: AnsiString=''): Boolean; function g_Texture_CreateFileEx(TextureName: ShortString; FileName: String): Boolean; function g_Texture_Get(TextureName: ShortString; var ID: DWORD): Boolean; procedure g_Texture_Delete(TextureName: ShortString); @@ -98,6 +98,7 @@ function g_Frames_CreateFile(ID: PDWORD; Name: ShortString; FileName: String; FWidth, FHeight, FCount: Word; BackAnimation: Boolean = False): Boolean; function g_Frames_CreateMemory(ID: PDWORD; Name: ShortString; pData: Pointer; dataSize: LongInt; FWidth, FHeight, FCount: Word; BackAnimation: Boolean = False): Boolean; +function g_Frames_Dup(NewName, OldName: ShortString): Boolean; //function g_Frames_CreateRevert(ID: PDWORD; Name: ShortString; Frames: string): Boolean; function g_Frames_Get(out ID: DWORD; FramesName: ShortString): Boolean; function g_Frames_GetTexture(out ID: DWORD; FramesName: ShortString; Frame: Word): Boolean; @@ -199,7 +200,7 @@ begin end; end; -function g_Texture_CreateWADEx(TextureName: ShortString; Resource: String): Boolean; +function texture_CreateWADExInternal (TextureName: ShortString; Resource: String; showmsg: Boolean): Boolean; var WAD: TWADFile; FileName: String; @@ -216,25 +217,39 @@ begin if WAD.GetResource(g_ExtractFilePathName(Resource), TextureData, ResourceLength) then begin - Result := e_CreateTextureMem(TextureData, ResourceLength, TexturesArray[find_id].ID); - if Result then + result := e_CreateTextureMem(TextureData, ResourceLength, TexturesArray[find_id].ID); + if result then begin - e_GetTextureSize(TexturesArray[find_id].ID, @TexturesArray[find_id].Width, - @TexturesArray[find_id].Height); + e_GetTextureSize(TexturesArray[find_id].ID, @TexturesArray[find_id].Width, @TexturesArray[find_id].Height); TexturesArray[find_id].Name := LowerCase(TextureName); end else + begin FreeMem(TextureData); + end; end else begin - e_WriteLog(Format('Error loading texture %s', [Resource]), MSG_WARNING); + if showmsg then + begin + e_WriteLog(Format('Error loading texture %s', [Resource]), MSG_WARNING); + end; //e_WriteLog(Format('WAD Reader error: %s', [WAD.GetLastErrorStr]), MSG_WARNING); - Result := False; + result := false; end; WAD.Free(); end; +function g_Texture_CreateWADEx(TextureName: ShortString; Resource: String; altrsrc: AnsiString=''): Boolean; +begin + if (Length(altrsrc) > 0) then + begin + result := texture_CreateWADExInternal(TextureName, altrsrc, false); + if result then exit; + end; + result := texture_CreateWADExInternal(TextureName, Resource, true); +end; + function g_Texture_CreateFileEx(TextureName: ShortString; FileName: String): Boolean; var find_id: DWORD; @@ -461,6 +476,9 @@ var begin Result := False; + // models without "advanced" animations asks for "nothing" like this; don't spam log + if (Length(Resource) > 0) and ((Resource[Length(Resource)] = '/') or (Resource[Length(Resource)] = '\')) then exit; + FileName := g_ExtractWadName(Resource); WAD := TWADFile.Create(); @@ -514,6 +532,30 @@ begin Result := True; end;} +function g_Frames_Dup(NewName, OldName: ShortString): Boolean; +var + find_id, b: DWORD; + a, c: Integer; +begin + Result := False; + + if not g_Frames_Get(b, OldName) then Exit; + + find_id := FindFrame(); + + FramesArray[find_id].Name := LowerCase(NewName); + FramesArray[find_id].FrameWidth := FramesArray[b].FrameWidth; + FramesArray[find_id].FrameHeight := FramesArray[b].FrameHeight; + + c := High(FramesArray[b].TexturesID); + SetLength(FramesArray[find_id].TexturesID, c+1); + + for a := 0 to c do + FramesArray[find_id].TexturesID[a] := FramesArray[b].TexturesID[a]; + + Result := True; +end; + procedure g_Frames_DeleteByName(FramesName: ShortString); var a: DWORD; @@ -757,7 +799,7 @@ begin FEnabled := True; end; -procedure TAnimation.DrawEx(X, Y: Integer; Mirror: TMirrorType; RPoint: TPoint; +procedure TAnimation.DrawEx(X, Y: Integer; Mirror: TMirrorType; RPoint: TDFPoint; Angle: SmallInt); begin if not FEnabled then