summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d8d64dd)
raw | patch | inline | side by side (parent: d8d64dd)
author | Dmitry D. Chernov <blackdoomer@yandex.ru> | |
Wed, 8 Nov 2023 06:52:37 +0000 (16:52 +1000) | ||
committer | Dmitry D. Chernov <blackdoomer@yandex.ru> | |
Wed, 8 Nov 2023 06:53:00 +0000 (16:53 +1000) |
This allows to change the panel texture from static to animated in the resource file without manually reassigning it first.
Corresponds to commit a0e1ce4f7986812acc44a4169d2daf8559c89973 from d2df-sdl.
Corresponds to commit a0e1ce4f7986812acc44a4169d2daf8559c89973 from d2df-sdl.
src/editor/g_map.pas | patch | blob | history | |
src/shared/WADEDITOR_dfzip.pas | patch | blob | history |
diff --git a/src/editor/g_map.pas b/src/editor/g_map.pas
index e63e97479d133e20df090a6228fc8e8576907c22..5b2cc5f54ce11899881a12d1d89592b90b20adfc 100644 (file)
--- a/src/editor/g_map.pas
+++ b/src/editor/g_map.pas
end;
end;
+function map_CreateAnimTexture(TextureName, Resource: String): Boolean;
+var
+ Data: Pointer = nil;
+ FrameLen: Integer = 0;
+ Width: Word = 0;
+ Height: Word = 0;
+begin
+ Result := GetFrame(Resource, Data, FrameLen, Width, Height);
+ if not Result then // Кадры
+ e_WriteLog(Format('GetFrame() error, res=%s', [TextureName]), MSG_WARNING)
+ else
+ begin
+ Result := g_CreateTextureMemorySize(Data, FrameLen, TextureName, 0, 0, Width, Height, 1);
+ if not Result then // Сама текстура
+ e_WriteLog(Format('g_CreateTextureMemorySize() error, res=%s', [TextureName]), MSG_WARNING);
+ end;
+end;
+
function LoadMap(Res: String): Boolean;
var
WAD: TWADEditor_1;
area: TArea;
trigger: TTrigger;
a: Integer;
- Data: Pointer;
- Width, Height, m: Word;
+ m: Word;
FileName, SectionName, ResName, _fn: String;
TextureRes, ustr: String;
pData: Pointer;
- Len, FrameLen: Integer;
- Error: Boolean;
+ Len: Integer;
+ Success: Boolean;
NoTextureID: DWORD;
NW, NH: Word;
begin
Result := False;
pData := nil;
Len := 0;
- Data := nil;
- FrameLen := 0;
- Width := 0;
- Height := 0;
NoTextureID := 0;
NW := 0;
NH := 0;
Application.ProcessMessages();
ustr := win2utf(textures[a].Resource);
- if IsSpecialTexture(ustr) then
+ Success := True;
+ if not IsSpecialTexture(ustr) then
begin
- AddTexture(ustr, False);
- Continue;
- end;
-
- g_ProcessResourceStr(ustr, @_fn, nil, nil);
-
- if _fn = '' then
- TextureRes := FileName + ustr
- else
- TextureRes := WadsDir + DirectorySeparator + ustr;
+ g_ProcessResourceStr(ustr, @_fn, nil, nil);
- Error := False;
+ if _fn = ''
+ then TextureRes := FileName + ustr
+ else TextureRes := WadsDir + DirectorySeparator + ustr;
- if not ByteBool(textures[a].Anim) then
+ if not Boolean(textures[a].Anim) then
begin // Обычная текстура
if not g_CreateTextureWAD(ustr, TextureRes) then
begin
- e_WriteLog(Format('g_CreateTextureWAD() error, res=%s',
- [ustr]), MSG_WARNING);
- Error := True;
+ e_WriteLog(Format('g_CreateTextureWAD() error, res=%s', [ustr]), MSG_WARNING);
+ Success := map_CreateAnimTexture(ustr, TextureRes);
+ if Success then
+ begin
+ textures[a].Anim := Byte(ByteBool(True));
+ e_WriteLog(Format(' wrong (outdated?) anim flag hint - texture #%d is actually animated: %s', [a, ustr]), MSG_WARNING);
+ end;
end;
-
- AddTexture(ustr, Error);
end
- else // Anim
+ else
begin // Анимированная текстура
- if not GetFrame(TextureRes, Data, FrameLen, Width, Height) then
- begin // Кадры
- e_WriteLog(Format('GetFrame() error, res=%s',
- [ustr]), MSG_WARNING);
- Error := True;
- end;
-
- if not g_CreateTextureMemorySize(Data, FrameLen, ustr, 0, 0, Width, Height, 1) then
- begin // Сама текстура
- e_WriteLog(Format('g_CreateTextureMemorySize() error, res=%s',
- [ustr]), MSG_WARNING);
- Error := True;
+ if not map_CreateAnimTexture(ustr, TextureRes) then
+ begin
+ Success := g_CreateTextureWAD(ustr, TextureRes);
+ if Success then
+ begin
+ textures[a].Anim := Byte(ByteBool(False));
+ e_WriteLog(Format(' wrong (outdated?) anim flag hint - texture #%d is actually static: %s', [a, ustr]), MSG_WARNING);
+ end;
end;
-
- AddTexture(ustr, Error);
end;
+ end;
+
+ AddTexture(ustr, not Success);
end;
end;
index fd57998a9a7c49d1874f3ce99e51f3b453a9713b..42816ab40d1b099922b82f2c8f4e2b01003ae256 100644 (file)
raise Exception.Create('EOCD not found (corrupted file?)');
end
else
- raise Exception.Create('Not DFZIP formated file');
+ raise Exception.Create('Not DFZIP formatted file');
end;
function TZIPEditor.ReadFile2(FileName: String): Boolean;