X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_panel.pas;h=0a52568dd4706237bf1506fa881add0d2694c20f;hb=716e8233028cb94e958b09dccc83e72c4ab0038d;hp=226515a5dc6a6381ba1d080f0e1f3bf3ac58e775;hpb=717e99e0ebd065bbc8f0c253cce7f5ee7df9c77b;p=d2df-sdl.git diff --git a/src/game/g_panel.pas b/src/game/g_panel.pas index 226515a..0a52568 100644 --- a/src/game/g_panel.pas +++ b/src/game/g_panel.pas @@ -1,9 +1,8 @@ -(* Copyright (C) DooM 2D:Forever Developers +(* Copyright (C) Doom 2D: Forever Developers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -30,6 +29,7 @@ type Anim: Boolean; end; + PPanel = ^TPanel; TPanel = Class (TObject) private const @@ -109,6 +109,7 @@ type tag: Integer; // used in coldets and such; sorry; see g_map.GridTagXXX proxyId: Integer; // proxy id in map grid (DO NOT USE!) mapId: AnsiString; // taken directly from map file; dunno why it is here + hasTexTrigger: Boolean; // HACK: true when there's a trigger than can change my texture constructor Create(PanelRec: TDynRecord; AddTextures: TAddTextureArray; @@ -124,6 +125,7 @@ type procedure SetTexture(ID: Integer; AnimLoop: Byte = 0); function GetTextureID(): Cardinal; function GetTextureCount(): Integer; + function CanChangeTexture(): Boolean; procedure SaveState (st: TStream); procedure LoadState (st: TStream); @@ -201,6 +203,12 @@ type TPanelArray = Array of TPanel; +const + LIFTTYPE_UP = 0; + LIFTTYPE_DOWN = 1; + LIFTTYPE_LEFT = 2; + LIFTTYPE_RIGHT = 3; + var g_dbgpan_mplat_active: Boolean = {$IF DEFINED(D2F_DEBUG)}true{$ELSE}true{$ENDIF}; g_dbgpan_mplat_step: Boolean = false; // one step, and stop @@ -209,8 +217,9 @@ var implementation uses + {$INCLUDE ../nogl/noGLuses.inc} e_texture, g_basic, g_map, g_game, g_gfx, e_graphics, g_weapons, g_triggers, - g_console, g_language, g_monsters, g_player, g_grid, e_log, GL, geom, utils, xstreams; + g_console, g_language, g_monsters, g_player, g_grid, e_log, geom, utils, xstreams; const PANEL_SIGNATURE = $4C4E4150; // 'PANL' @@ -257,15 +266,16 @@ begin PanelType := PanelRec.PanelType; Enabled := True; Door := False; - LiftType := 0; + LiftType := LIFTTYPE_UP; + hasTexTrigger := False; case PanelType of PANEL_OPENDOOR: begin Enabled := False; Door := True; end; PANEL_CLOSEDOOR: Door := True; - PANEL_LIFTUP: LiftType := 0; //??? - PANEL_LIFTDOWN: LiftType := 1; - PANEL_LIFTLEFT: LiftType := 2; - PANEL_LIFTRIGHT: LiftType := 3; + PANEL_LIFTUP: LiftType := LIFTTYPE_UP; //??? + PANEL_LIFTDOWN: LiftType := LIFTTYPE_DOWN; + PANEL_LIFTLEFT: LiftType := LIFTTYPE_LEFT; + PANEL_LIFTRIGHT: LiftType := LIFTTYPE_RIGHT; end; // Íåâèäèìàÿ: @@ -439,8 +449,8 @@ begin begin // Îáû÷íàÿ òåêñòóðà case FTextureIDs[FCurTexture].Tex of LongWord(TEXTURE_SPECIAL_WATER): e_DrawFillQuad(X, Y, X+Width-1, Y+Height-1, 0, 0, 255, 0, TBlending.Filter); - LongWord(TEXTURE_SPECIAL_ACID1): e_DrawFillQuad(X, Y, X+Width-1, Y+Height-1, 0, 128, 0, 0, TBlending.Filter); - LongWord(TEXTURE_SPECIAL_ACID2): e_DrawFillQuad(X, Y, X+Width-1, Y+Height-1, 128, 0, 0, 0, TBlending.Filter); + LongWord(TEXTURE_SPECIAL_ACID1): e_DrawFillQuad(X, Y, X+Width-1, Y+Height-1, 0, 230, 0, 0, TBlending.Filter); + LongWord(TEXTURE_SPECIAL_ACID2): e_DrawFillQuad(X, Y, X+Width-1, Y+Height-1, 230, 0, 0, 0, TBlending.Filter); LongWord(TEXTURE_NONE): if g_Texture_Get('NOTEXTURE', NoTextureID) then begin @@ -585,7 +595,7 @@ var begin if (ontop <> nil) then ontop^ := true; // yes, move with it; but skip steps (no need to process size change here, 'cause platform top cannot be changed with it) - mapGrid.traceBox(tex, tey, px, py, pw, ph, pdx, pdy, nil, (GridTagWall or GridTagDoor)); + mapGrid.traceBox(tex, tey, px, py, pw, ph, pdx, pdy, (GridTagWall or GridTagDoor)); end else begin @@ -613,7 +623,7 @@ var trtag := (GridTagWall or GridTagDoor); // if we're moving down, consider steps too if (szdy > 0) then trtag := trtag or GridTagStep; - mapGrid.traceBox(tex, tey, px, py, pw, ph, szdx, szdy, nil, trtag); + mapGrid.traceBox(tex, tey, px, py, pw, ph, szdx, szdy, trtag); end; end; end; @@ -632,7 +642,7 @@ var trtag := (GridTagWall or GridTagDoor); // if we're moving down, consider steps too if (pdy > 0) then trtag := trtag or GridTagStep; - mapGrid.traceBox(tex, tey, px, py, pw, ph, pdx, pdy, nil, trtag); + mapGrid.traceBox(tex, tey, px, py, pw, ph, pdx, pdy, trtag); end; end; end; @@ -897,7 +907,7 @@ begin (FTextureIDs[FCurTexture].AnTex <> nil) and (Width > 0) and (Height > 0) and (FAlpha < 255) then begin - FCurFrame := ClampInt(Frame, 0, FTextureIDs[FCurTexture].AnTex.TotalFrames); + FCurFrame := ClampInt(Frame, 0, FTextureIDs[FCurTexture].AnTex.TotalFrames - 1); FCurFrameCount := Count; FTextureIDs[FCurTexture].AnTex.CurrentFrame := FCurFrame; FTextureIDs[FCurTexture].AnTex.CurrentCounter := FCurFrameCount; @@ -953,22 +963,8 @@ end; procedure TPanel.SetTexture(ID: Integer; AnimLoop: Byte = 0); begin -// Íåò òåêñòóð: - if Length(FTextureIDs) = 0 then - FCurTexture := -1 - else - // Òîëüêî îäíà òåêñòóðà: - if Length(FTextureIDs) = 1 then - begin - if (ID = 0) or (ID = -1) then - FCurTexture := ID; - end - else - // Áîëüøå îäíîé òåêñòóðû: - begin - if (ID >= -1) and (ID <= High(FTextureIDs)) then - FCurTexture := ID; - end; + if (ID >= -1) and (ID < Length(FTextureIDs)) then + FCurTexture := ID; // Ïåðåêëþ÷èëèñü íà âèäèìóþ àíèì. òåêñòóðó: if (FCurTexture >= 0) and FTextureIDs[FCurTexture].Anim then @@ -1014,6 +1010,10 @@ begin Result := Result + 100; end; +function TPanel.CanChangeTexture(): Boolean; +begin + Result := (GetTextureCount() > 1) or hasTexTrigger; +end; const PAN_SAVE_VERSION = 1;