summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 66c2f94)
raw | patch | inline | side by side (parent: 66c2f94)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 16 Jan 2022 22:39:30 +0000 (01:39 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 07:52:08 +0000 (10:52 +0300) |
src/game/g_map.pas | patch | blob | history | |
src/game/g_panel.pas | patch | blob | history | |
src/game/opengl/r_panel.pas | patch | blob | history |
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index 8d64ebb0ab1f5f3f2589fa5581bf93f04bc1529a..c8adfdfc0fb2f1af76d0813929863aae6b3fa5e2 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
var
mapGrid: TPanelGrid = nil; // DO NOT USE! public for debugging only!
+var (* private state *)
+ Textures: TLevelTextureArray = nil;
implementation
end;
var
- Textures: TLevelTextureArray = nil;
TextNameHash: THashStrInt = nil; // key: texture name; value: index in `Textures`
BadTextNameHash: THashStrInt = nil; // set; so we won't spam with non-existing texture messages
RespawnPoints: array of TRespawnPoint;
diff --git a/src/game/g_panel.pas b/src/game/g_panel.pas
index f8a252edf80374a6abc32a59f229d7986f42f046..9d08ba32f7e97d1f3a956ca2c72bbfae161b2f60 100644 (file)
--- a/src/game/g_panel.pas
+++ b/src/game/g_panel.pas
MAPDEF, g_textures, xdynrec;
type
- TAddTextureArray = Array of
- record
- Texture: Cardinal;
- Anim: Boolean;
- end;
+ TAddTextureArray = array of record
+ Texture: Cardinal; // Textures[Texture]
+ Anim: Boolean;
+ end;
ATextureID = array of record
+ Texture: Cardinal; // Textures[Texture]
case Anim: Boolean of
- False: (Tex: Cardinal);
- True: (AnTex: TAnimation);
+ False: ();
+ True: (AnTex: TAnimationState);
end;
PPanel = ^TPanel;
SetLength(FTextureIDs, 1);
FTextureIDs[0].Anim := False;
+{
+ // !!! set this
case PanelRec.PanelType of
PANEL_WATER:
FTextureIDs[0].Tex := LongWord(TEXTURE_SPECIAL_WATER);
PANEL_ACID2:
FTextureIDs[0].Tex := LongWord(TEXTURE_SPECIAL_ACID2);
end;
+}
FCurTexture := 0;
Exit;
for i := 0 to Length(FTextureIDs)-1 do
begin
+ FTextureIDs[i].Texture := AddTextures[i].Texture;
FTextureIDs[i].Anim := AddTextures[i].Anim;
if FTextureIDs[i].Anim then
- begin // Àíèìèðîâàííàÿ òåêñòóðà
- FTextureIDs[i].AnTex :=
- TAnimation.Create(Textures[AddTextures[i].Texture].FramesID,
- True, Textures[AddTextures[i].Texture].Speed);
- FTextureIDs[i].AnTex.Blending := ByteBool(PanelRec.Flags and PANEL_FLAG_BLENDING);
- FTextureIDs[i].AnTex.Alpha := PanelRec.Alpha;
- end
- else
- begin // Îáû÷íàÿ òåêñòóðà
- FTextureIDs[i].Tex := Textures[AddTextures[i].Texture].TextureID;
- end;
+ begin // Àíèìèðîâàííàÿ òåêñòóðà
+ FTextureIDs[i].AnTex := TAnimationState.Create(True, Textures[AddTextures[i].Texture].Speed, Textures[AddTextures[i].Texture].FramesCount);
+ FTextureIDs[i].AnTex.Blending := ByteBool(PanelRec.Flags and PANEL_FLAG_BLENDING);
+ FTextureIDs[i].AnTex.Alpha := PanelRec.Alpha;
+ end
end;
// Òåêñòóð íåñêîëüêî - íóæíî ñîõðàíÿòü òåêóùóþ:
function TPanel.GetTextureID(): DWORD;
begin
Result := LongWord(TEXTURE_NONE);
-
if (FCurTexture >= 0) then
begin
+ if FTextureIDs[FCurTexture].Anim then
+ Result := Textures[FTextureIDs[FCurTexture].Texture].FramesID
+ else
+ Result := Textures[FTextureIDs[FCurTexture].Texture].TextureID
+{
+ // !!! old behavior
if FTextureIDs[FCurTexture].Anim then
Result := FTextureIDs[FCurTexture].AnTex.FramesID
else
Result := FTextureIDs[FCurTexture].Tex;
- end;
+}
+ end
end;
function TPanel.GetTextureCount(): Integer;
index 4cd4f3851360aabde5f7b2dcaca416bd1171df86..539c9a74ea26d803730cec010f07ac4528c08148 100644 (file)
{$INCLUDE ../nogl/noGLuses.inc}
SysUtils, Classes, Math, utils,
r_graphics, g_options, r_animations, r_textures,
- g_base, g_basic, g_game
+ g_base, g_basic, g_map, g_game
;
procedure Panel_Lerp (p: TPanel; t: Single; out tX, tY, tW, tH: Integer);
// TODO: remove WITH operator
procedure r_Panel_Draw (constref p: TPanel; hasAmbient: Boolean; constref ambColor: TDFColor);
- var tx, ty, tw, th, xx, yy: Integer; NoTextureID: DWORD; NW, NH: Word;
+ var tx, ty, tw, th, xx, yy: Integer; NoTextureID, TextureID, FramesID: DWORD; NW, NH: Word; Texture: Cardinal; IsAnim: Boolean;
begin
- with p do
+ if {p.Enabled and} (p.FCurTexture >= 0) and (p.Width > 0) and (p.Height > 0) and (p.Alpha < 255) {and g_Collide(X, Y, Width, Height, sX, sY, sWidth, sHeight)} then
begin
- if {Enabled and} (FCurTexture >= 0) and (Width > 0) and (Height > 0) and (Alpha < 255) {and g_Collide(X, Y, Width, Height, sX, sY, sWidth, sHeight)} then
+ Panel_Lerp(p, gLerpFactor, tx, ty, tw, th);
+ Texture := p.TextureIDs[p.FCurTexture].Texture;
+ IsAnim := p.TextureIDs[p.FCurTexture].Anim;
+ if IsAnim then
begin
- Panel_Lerp(p, gLerpFactor, tx, ty, tw, th);
- if TextureIDs[FCurTexture].Anim then
+ if p.TextureIDs[p.FCurTexture].AnTex <> nil then
begin
- if TextureIDs[FCurTexture].AnTex = nil then
- Exit;
- for xx := 0 to tw div TextureWidth - 1 do
- for yy := 0 to th div TextureHeight - 1 do
- r_Animation_Draw(TextureIDs[FCurTexture].AnTex, tx + xx * TextureWidth, ty + yy * TextureHeight, TMirrorType.None);
+ FramesID := Textures[Texture].FramesID;
+ for xx := 0 to tw div p.TextureWidth - 1 do
+ for yy := 0 to th div p.TextureHeight - 1 do
+ r_AnimationState_Draw(FramesID, p.TextureIDs[p.FCurTexture].AnTex, tx + xx * p.TextureWidth, ty + yy * p.TextureHeight, TMirrorType.None);
end
- else
- begin
- case TextureIDs[FCurTexture].Tex of
- LongWord(TEXTURE_SPECIAL_WATER): e_DrawFillQuad(tx, ty, tx + tw - 1, ty + th - 1, 0, 0, 255, 0, TBlending.Filter);
- LongWord(TEXTURE_SPECIAL_ACID1): e_DrawFillQuad(tx, ty, tx + tw - 1, ty + th - 1, 0, 230, 0, 0, TBlending.Filter);
- LongWord(TEXTURE_SPECIAL_ACID2): e_DrawFillQuad(tx, ty, tx + tw - 1, ty + th - 1, 230, 0, 0, 0, TBlending.Filter);
- LongWord(TEXTURE_NONE):
- if g_Texture_Get('NOTEXTURE', NoTextureID) then
- begin
- e_GetTextureSize(NoTextureID, @NW, @NH);
- e_DrawFill(NoTextureID, tx, ty, tw div NW, th div NH, 0, False, False);
- end
- else
- begin
- xx := tx + (tw div 2);
- yy := ty + (th div 2);
- e_DrawFillQuad(tx, ty, xx, yy, 255, 0, 255, 0);
- e_DrawFillQuad(xx, ty, tx + tw - 1, yy, 255, 255, 0, 0);
- e_DrawFillQuad(X, yy, xx, ty + th - 1, 255, 255, 0, 0);
- e_DrawFillQuad(xx, yy, tx + tw - 1, ty + th - 1, 255, 0, 255, 0);
- end;
- else
+ end
+ else
+ begin
+ TextureID := Textures[Texture].TextureID; // GL texture
+ case TextureID of
+ LongWord(TEXTURE_SPECIAL_WATER): e_DrawFillQuad(tx, ty, tx + tw - 1, ty + th - 1, 0, 0, 255, 0, TBlending.Filter);
+ LongWord(TEXTURE_SPECIAL_ACID1): e_DrawFillQuad(tx, ty, tx + tw - 1, ty + th - 1, 0, 230, 0, 0, TBlending.Filter);
+ LongWord(TEXTURE_SPECIAL_ACID2): e_DrawFillQuad(tx, ty, tx + tw - 1, ty + th - 1, 230, 0, 0, 0, TBlending.Filter);
+ LongWord(TEXTURE_NONE):
+ if g_Texture_Get('NOTEXTURE', NoTextureID) then
begin
- if not movingActive then
- e_DrawFill(TextureIDs[FCurTexture].Tex, tx, ty, tw div TextureWidth, th div TextureHeight, Alpha, True, Blending, hasAmbient)
- else
- e_DrawFillX(TextureIDs[FCurTexture].Tex, tx, ty, tw, th, Alpha, True, Blending, g_dbg_scale, hasAmbient);
- if hasAmbient then
- e_AmbientQuad(tx, ty, tw, th, ambColor.r, ambColor.g, ambColor.b, ambColor.a);
+ e_GetTextureSize(NoTextureID, @NW, @NH);
+ e_DrawFill(NoTextureID, tx, ty, tw div NW, th div NH, 0, False, False);
end
- end
+ else
+ begin
+ xx := tx + (tw div 2);
+ yy := ty + (th div 2);
+ e_DrawFillQuad(tx, ty, xx, yy, 255, 0, 255, 0);
+ e_DrawFillQuad(xx, ty, tx + tw - 1, yy, 255, 255, 0, 0);
+ e_DrawFillQuad(tx, yy, xx, ty + th - 1, 255, 255, 0, 0);
+ e_DrawFillQuad(xx, yy, tx + tw - 1, ty + th - 1, 255, 0, 255, 0);
+ end;
+ else
+ if not p.movingActive then
+ e_DrawFill(TextureID, tx, ty, tw div p.TextureWidth, th div p.TextureHeight, p.Alpha, True, p.Blending, hasAmbient)
+ else
+ e_DrawFillX(TextureID, tx, ty, tw, th, p.Alpha, True, p.Blending, g_dbg_scale, hasAmbient);
+ if hasAmbient then
+ e_AmbientQuad(tx, ty, tw, th, ambColor.r, ambColor.g, ambColor.b, ambColor.a);
end
end
end
end;
procedure r_Panel_DrawShadowVolume (constref p: TPanel; lightX, lightY: Integer; radius: Integer);
- var tx, ty, tw, th: Integer;
+ var tx, ty, tw, th: Integer; Texture: Cardinal;
procedure extrude (x: Integer; y: Integer);
begin
end;
begin
- with p do
+ if radius < 4 then exit;
+ if p.Enabled and (p.FCurTexture >= 0) and (p.Width > 0) and (p.Height > 0) and (p.Alpha < 255) {and g_Collide(X, Y, tw, th, sX, sY, sWidth, sHeight)} then
begin
- if radius < 4 then exit;
- if Enabled and (FCurTexture >= 0) and (Width > 0) and (Height > 0) and (Alpha < 255) {and g_Collide(X, Y, tw, th, sX, sY, sWidth, sHeight)} then
+ Panel_Lerp(p, gLerpFactor, tx, ty, tw, th);
+ if not p.TextureIDs[p.FCurTexture].Anim then
begin
- Panel_Lerp(p, gLerpFactor, tx, ty, tw, th);
- if not TextureIDs[FCurTexture].Anim then
- begin
- case TextureIDs[FCurTexture].Tex of
- LongWord(TEXTURE_SPECIAL_WATER): exit;
- LongWord(TEXTURE_SPECIAL_ACID1): exit;
- LongWord(TEXTURE_SPECIAL_ACID2): exit;
- LongWord(TEXTURE_NONE): exit;
- end;
+ Texture := p.TextureIDs[p.FCurTexture].Texture;
+ case Textures[Texture].TextureID of
+ LongWord(TEXTURE_SPECIAL_WATER): exit;
+ LongWord(TEXTURE_SPECIAL_ACID1): exit;
+ LongWord(TEXTURE_SPECIAL_ACID2): exit;
+ LongWord(TEXTURE_NONE): exit;
end;
- if (tx + tw < lightX - radius) then exit;
- if (ty + th < lightY - radius) then exit;
- if (tx > lightX + radius) then exit;
- if (ty > lightY + radius) then exit;
- //e_DrawFill(TextureIDs[FCurTexture].Tex, X, Y, tw div TextureWidth, th div TextureHeight, Alpha, True, Blending);
- glBegin(GL_QUADS);
- drawLine(tx, ty, tx + tw, ty); // top
- drawLine(tx + tw, ty, tx + tw, ty + th); // right
- drawLine(tx + tw, ty + th, tx, ty + th); // bottom
- drawLine(tx, ty + th, tx, ty); // left
- glEnd;
- end
+ end;
+ if (tx + tw < lightX - radius) then exit;
+ if (ty + th < lightY - radius) then exit;
+ if (tx > lightX + radius) then exit;
+ if (ty > lightY + radius) then exit;
+ //e_DrawFill(TextureIDs[FCurTexture].Tex, X, Y, tw div TextureWidth, th div TextureHeight, Alpha, True, Blending);
+ glBegin(GL_QUADS);
+ drawLine(tx, ty, tx + tw, ty); // top
+ drawLine(tx + tw, ty, tx + tw, ty + th); // right
+ drawLine(tx + tw, ty + th, tx, ty + th); // bottom
+ drawLine(tx, ty + th, tx, ty); // left
+ glEnd;
end
end;