1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../../../shared/a_modes.inc}
19 {$FATAL Desktop OpenGL required for current Holmes implementation}
24 procedure r_Holmes_Draw ();
25 procedure r_Holmes_DrawUI ();
28 procedure r_Holmes_plrViewPos (viewPortX
, viewPortY
: Integer);
29 procedure r_Holmes_plrViewSize (viewPortW
, viewPortH
: Integer);
30 procedure r_Holmes_plrLaser (ax0
, ay0
, ax1
, ay1
: Integer);
32 function pmsCurMapX (): Integer;
33 function pmsCurMapY (): Integer;
36 vpSet
: Boolean = false;
41 {$INCLUDE ../nogl/noGLuses.inc}
44 g_basic
, g_grid
, g_player
, g_monsters
,
45 g_map
, g_triggers
, g_items
, g_game
, g_panel
, g_console
,
58 typinfo
, SysUtils
, Classes
,
62 hlmContext
: r_fui_gfx_gl
.TGxContext
= nil;
65 laserSet
: Boolean = false;
66 laserX0
, laserY0
, laserX1
, laserY1
: Integer;
68 // ////////////////////////////////////////////////////////////////////////// //
70 {$INCLUDE r_holmes_ol.inc}
72 // ////////////////////////////////////////////////////////////////////////// //
74 procedure r_Holmes_plrViewPos (viewPortX
, viewPortY
: Integer);
81 procedure r_Holmes_plrViewSize (viewPortW
, viewPortH
: Integer);
88 procedure r_Holmes_plrLaser (ax0
, ay0
, ax1
, ay1
: Integer);
95 laserSet
:= laserSet
; // shut up, fpc!
98 function pmsCurMapX (): Integer; inline; begin result
:= round(msX
/g_dbg_scale
)+vpx
; end;
99 function pmsCurMapY (): Integer; inline; begin result
:= round(msY
/g_dbg_scale
)+vpy
; end;
101 {$IFDEF HOLMES_OLD_OUTLINES}
103 edgeBmp
: array of Byte = nil;
106 procedure drawOutlines ();
110 procedure clearEdgeBmp ();
112 SetLength(edgeBmp
, (gScreenWidth
+4)*(gScreenHeight
+4));
113 FillChar(edgeBmp
[0], Length(edgeBmp
)*sizeof(edgeBmp
[0]), 0);
116 procedure drawPanel (pan
: TPanel
);
118 sx
, len
, y0
, y1
: Integer;
120 if (pan
= nil) or (pan
.Width
< 1) or (pan
.Height
< 1) then exit
;
121 if (pan
.X
+pan
.Width
<= vpx
-1) or (pan
.Y
+pan
.Height
<= vpy
-1) then exit
;
122 if (pan
.X
>= vpx
+vpw
+1) or (pan
.Y
>= vpy
+vph
+1) then exit
;
123 if g_ol_nice
or g_ol_fill_walls
then
127 if (len
> gScreenWidth
+4) then len
:= gScreenWidth
+4;
128 if (sx
< 0) then begin len
+= sx
; sx
:= 0; end;
129 if (sx
+len
> gScreenWidth
+4) then len
:= gScreenWidth
+4-sx
;
130 if (len
< 1) then exit
;
132 assert(sx
+len
<= gScreenWidth
+4);
135 if (y0
< 0) then y0
:= 0;
136 if (y1
> gScreenHeight
+4) then y1
:= gScreenHeight
+4;
139 FillChar(edgeBmp
[y0
*(gScreenWidth
+4)+sx
], len
*sizeof(edgeBmp
[0]), 1);
145 drawRect(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, r
, g
, b
);
154 procedure flushLine ();
156 if (lsy
> 0) and (lsx
> 0) then
161 glVertex2f(lsx
-1+vpx
+0.37, lsy
-1+vpy
+0.37);
167 glVertex2f(lsx
-1+vpx
+0.37, lsy
-1+vpy
+0.37);
168 glVertex2f(lex
-0+vpx
+0.37, lsy
-1+vpy
+0.37);
176 procedure startLine (y
: Integer);
182 procedure putPixel (x
: Integer);
184 if (x
< 1) then exit
;
185 if (lex
+1 <> x
) then flushLine();
186 if (lsx
< 0) then lsx
:= x
;
190 procedure drawEdges ();
196 glDisable(GL_TEXTURE_2D
);
199 glDisable(GL_LINE_SMOOTH
);
200 glDisable(GL_POLYGON_SMOOTH
);
201 glColor4f(r
/255.0, g
/255.0, b
/255.0, 1.0);
204 a
:= @edgeBmp
[y
*(gScreenWidth
+4)+1];
210 if (a
[-1] = 0) or (a
[1] = 0) or (a
[-(gScreenWidth
+4)] = 0) or (a
[gScreenWidth
+4] = 0) or
211 (a
[-(gScreenWidth
+4)-1] = 0) or (a
[-(gScreenWidth
+4)+1] = 0) or
212 (a
[gScreenWidth
+4-1] = 0) or (a
[gScreenWidth
+4+1] = 0) then
223 procedure drawFilledWalls ();
229 glDisable(GL_TEXTURE_2D
);
232 glDisable(GL_LINE_SMOOTH
);
233 glDisable(GL_POLYGON_SMOOTH
);
234 glColor4f(r
/255.0, g
/255.0, b
/255.0, 1.0);
237 a
:= @edgeBmp
[y
*(gScreenWidth
+4)+1];
241 if (a
[0] <> 0) then putPixel(x
);
248 procedure doWallsOld (parr
: array of TPanel
; ptype
: Word; ar
, ag
, ab
: Integer);
256 if g_ol_nice
or g_ol_fill_walls
then clearEdgeBmp();
257 for f
:= 0 to High(parr
) do
260 if (pan
= nil) or not pan
.Enabled
or (pan
.Width
< 1) or (pan
.Height
< 1) then continue
;
261 if ((pan
.PanelType
and ptype
) = 0) then continue
;
264 if g_ol_nice
then drawEdges();
265 if g_ol_fill_walls
then drawFilledWalls();
271 function doWallCB (pan
: TPanel
; tag
: Integer): Boolean;
273 result
:= false; // don't stop
274 //if (pan = nil) or not pan.Enabled or (pan.Width < 1) or (pan.Height < 1) then exit;
275 if ((pan
.PanelType
and xptag
) = 0) then exit
;
279 procedure doWalls (parr
: array of TPanel
; ptype
: Word; ar
, ag
, ab
: Integer);
285 if ((ptype
and (PANEL_WALL
or PANEL_OPENDOOR
or PANEL_CLOSEDOOR
)) <> 0) then ptype
:= GridTagWall
or GridTagDoor
286 else panelTypeToTag(ptype
);
287 if g_ol_nice
or g_ol_fill_walls
then clearEdgeBmp();
288 mapGrid
.forEachInAABB(vpx
-1, vpy
-1, vpw
+2, vph
+2, doWallCB
, ptype
);
289 if g_ol_nice
then drawEdges();
290 if g_ol_fill_walls
then drawFilledWalls();
294 if g_ol_rlayer_back
then doWallsOld(gRenderBackgrounds
, PANEL_BACK
, 255, 127, 0);
295 if g_ol_rlayer_step
then doWallsOld(gSteps
, PANEL_STEP
, 192, 192, 192);
296 if g_ol_rlayer_wall
then doWallsOld(gWalls
, PANEL_WALL
, 255, 255, 255);
297 if g_ol_rlayer_door
then doWallsOld(gWalls
, PANEL_OPENDOOR
or PANEL_CLOSEDOOR
, 0, 255, 0);
298 if g_ol_rlayer_acid1
then doWallsOld(gAcid1
, PANEL_ACID1
, 255, 0, 0);
299 if g_ol_rlayer_acid2
then doWallsOld(gAcid2
, PANEL_ACID2
, 198, 198, 0);
300 if g_ol_rlayer_water
then doWallsOld(gWater
, PANEL_WATER
, 0, 255, 255);
301 if g_ol_rlayer_fore
then doWallsOld(gRenderForegrounds
, PANEL_FORE
, 210, 210, 210);
306 oliner
: TOutliner
= nil;
308 procedure drawOutlines ();
312 procedure clearOliner ();
314 //if (oliner <> nil) and ((oliner.height <> vph+2) or (oliner.width <> vpw+2)) then begin oliner.Free(); oliner := nil; end;
315 if (oliner
= nil) then oliner
:= TOutliner
.Create(vpw
+2, vph
+2) else oliner
.setup(vpw
+2, vph
+2);
318 procedure drawOutline (ol
: TOutliner
; sx
, sy
: Integer);
319 procedure xline (x0
, x1
, y
: Integer);
323 if (g_dbg_scale
< 1.0) then
326 for x
:= x0
to x1
do glVertex2f(sx
+x
+0.375, sy
+y
+0.375);
332 glVertex2f(sx
+x0
+0, sy
+y
+0);
333 glVertex2f(sx
+x1
+1, sy
+y
+0);
334 glVertex2f(sx
+x1
+1, sy
+y
+1);
335 glVertex2f(sx
+x0
+0, sy
+y
+1);
341 sp
: TOutliner
.TSpanX
;
343 if (ol
= nil) then exit
;
345 glDisable(GL_POINT_SMOOTH
);
346 for y
:= 0 to ol
.height
-1 do
348 for sp
in ol
.eachSpanAtY(y
) do
350 if (g_dbg_scale
<= 1.0) then
353 glVertex2f(sx
+sp
.x0
+0.375, sy
+y
+0.375);
354 glVertex2f(sx
+sp
.x1
+0.375, sy
+y
+0.375);
360 glVertex2f(sx
+sp
.x0
+0, sy
+y
+0);
361 glVertex2f(sx
+sp
.x0
+1, sy
+y
+0);
362 glVertex2f(sx
+sp
.x0
+1, sy
+y
+1);
363 glVertex2f(sx
+sp
.x0
+0, sy
+y
+1);
365 glVertex2f(sx
+sp
.x1
+0, sy
+y
+0);
366 glVertex2f(sx
+sp
.x1
+1, sy
+y
+0);
367 glVertex2f(sx
+sp
.x1
+1, sy
+y
+1);
368 glVertex2f(sx
+sp
.x1
+0, sy
+y
+1);
372 for sp
in ol
.eachSpanEdgeAtY(y
, -1) do
374 xline(sp
.x0
, sp
.x1
, y
);
377 glVertex2f(sx+sp.x0+0, sy+y+0);
378 glVertex2f(sx+sp.x1+1, sy+y+0);
379 glVertex2f(sx+sp.x1+1, sy+y+1);
380 glVertex2f(sx+sp.x0+0, sy+y+1);
384 for sp
in ol
.eachSpanEdgeAtY(y
, +1) do
386 xline(sp
.x0
, sp
.x1
, y
);
389 glVertex2f(sx+sp.x0+0, sy+y+0);
390 glVertex2f(sx+sp.x1+1, sy+y+0);
391 glVertex2f(sx+sp.x1+1, sy+y+1);
392 glVertex2f(sx+sp.x0+0, sy+y+1);
399 procedure doWallsOld (parr
: array of TPanel
; ptype
: Word; ar
, ag
, ab
: Integer);
407 if g_ol_nice
then clearOliner();
408 hlmContext
.color
:= TGxRGBA
.Create(r
, g
, b
);
409 for f
:= 0 to High(parr
) do
412 if (pan
= nil) or not pan
.Enabled
or (pan
.Width
< 1) or (pan
.Height
< 1) then continue
;
413 if ((pan
.PanelType
and ptype
) = 0) then continue
;
414 if (pan
.X
> vpx
+vpw
+41) or (pan
.Y
> vpy
+vph
+41) then continue
;
415 if (pan
.X
+pan
.Width
< vpx
-41) then continue
;
416 if (pan
.Y
+pan
.Height
< vpy
-41) then continue
;
419 oliner
.addRect(pan
.X
-(vpx
+1), pan
.Y
-(vpy
+1), pan
.Width
, pan
.Height
);
421 if g_ol_fill_walls
then
423 hlmContext
.fillRect(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
);
425 else if not g_ol_nice
then
427 hlmContext
.rect(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
);
432 glColor4f(r
/255.0, g
/255.0, b
/255.0, 1.0);
433 drawOutline(oliner
, vpx
+1, vpy
+1);
438 if (vpw
< 2) or (vph
< 2) then exit
;
439 if g_ol_rlayer_back
then doWallsOld(gRenderBackgrounds
, PANEL_BACK
, 255, 127, 0);
440 if g_ol_rlayer_step
then doWallsOld(gSteps
, PANEL_STEP
, 192, 192, 192);
441 if g_ol_rlayer_wall
then doWallsOld(gWalls
, PANEL_WALL
, 255, 255, 255);
442 if g_ol_rlayer_door
then doWallsOld(gWalls
, PANEL_OPENDOOR
or PANEL_CLOSEDOOR
, 0, 255, 0);
443 if g_ol_rlayer_acid1
then doWallsOld(gAcid1
, PANEL_ACID1
, 255, 0, 0);
444 if g_ol_rlayer_acid2
then doWallsOld(gAcid2
, PANEL_ACID2
, 198, 198, 0);
445 if g_ol_rlayer_water
then doWallsOld(gWater
, PANEL_WATER
, 0, 255, 255);
446 if g_ol_rlayer_fore
then doWallsOld(gRenderForegrounds
, PANEL_FORE
, 210, 210, 210);
451 procedure plrDebugDraw ();
452 procedure drawTileGrid ();
456 hlmContext
.color
:= TGxRGBA
.Create(96, 96, 96);
457 for y
:= 0 to (mapGrid
.gridHeight
div mapGrid
.tileSize
) do
459 hlmContext
.line(mapGrid
.gridX0
, mapGrid
.gridY0
+y
*mapGrid
.tileSize
, mapGrid
.gridX0
+mapGrid
.gridWidth
, mapGrid
.gridY0
+y
*mapGrid
.tileSize
);
462 hlmContext
.color
:= TGxRGBA
.Create(96, 96, 96);
463 for x
:= 0 to (mapGrid
.gridWidth
div mapGrid
.tileSize
) do
465 hlmContext
.line(mapGrid
.gridX0
+x
*mapGrid
.tileSize
, mapGrid
.gridY0
, mapGrid
.gridX0
+x
*mapGrid
.tileSize
, mapGrid
.gridY0
+y
*mapGrid
.gridHeight
);
470 procedure drawAwakeCells ();
474 hlmContext
.color
:= TGxRGBA
.Create(128, 0, 128, 64);
475 for y
:= 0 to (mapGrid
.gridHeight
div mapGrid
.tileSize
) do
477 for x
:= 0 to (mapGrid
.gridWidth
div mapGrid
.tileSize
) do
479 if awmIsSetHolmes(x
*mapGrid
.tileSize
+mapGrid
.gridX0
+1, y
*mapGrid
.tileSize
++mapGrid
.gridY0
+1) then
481 hlmContext
.fillRect(x
*mapGrid
.tileSize
++mapGrid
.gridX0
, y
*mapGrid
.tileSize
++mapGrid
.gridY0
, monsGrid
.tileSize
, monsGrid
.tileSize
);
488 procedure drawTraceBox ();
491 px
, py
, pw
, ph
: Integer;
496 if (Length(gPlayers
) < 1) then exit
;
498 if (plr
= nil) then exit
;
499 plr
.getMapBox(px
, py
, pw
, ph
);
500 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 255, 200);
501 hlmContext
.rect(px
, py
, pw
, ph
);
502 pdx
:= pmsCurMapX
-(px
+pw
div 2);
503 pdy
:= pmsCurMapY
-(py
+ph
div 2);
504 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 255, 200);
505 hlmContext
.line(px
+pw
div 2, py
+ph
div 2, px
+pw
div 2+pdx
, py
+ph
div 2+pdy
);
506 pan
:= mapGrid
.traceBox(ex
, ey
, px
, py
, pw
, ph
, pdx
, pdy
, GridTagObstacle
);
509 hlmContext
.color
:= TGxRGBA
.Create(255, 255, 255, 180);
510 hlmContext
.rect(px
+pdx
, py
+pdy
, pw
, ph
);
514 hlmContext
.color
:= TGxRGBA
.Create(255, 255, 0, 180);
515 hlmContext
.rect(px
+pdx
, py
+pdy
, pw
, ph
);
517 hlmContext
.color
:= TGxRGBA
.Create(255, 127, 0, 180);
518 hlmContext
.rect(ex
, ey
, pw
, ph
);
521 procedure hilightCell (cx
, cy
: Integer);
523 hlmContext
.color
:= TGxRGBA
.Create(0, 128, 0, 64);
524 hlmContext
.fillRect(cx
, cy
, monsGrid
.tileSize
, monsGrid
.tileSize
);
527 procedure hilightBodyCells (proxyId
: Integer);
530 pcellxy
: PGridCellCoord
;
532 //monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
533 it
:= monsGrid
.forEachBodyCell(proxyId
);
534 for pcellxy
in it
do hilightCell(pcellxy
^.x
, pcellxy
^.y
);
538 procedure hilightCell1 (cx
, cy
: Integer);
540 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
541 cx
:= cx
and (not (monsGrid
.tileSize
-1));
542 cy
:= cy
and (not (monsGrid
.tileSize
-1));
543 hlmContext
.color
:= TGxRGBA
.Create(255, 255, 0, 92);
544 hlmContext
.fillRect(cx
, cy
, monsGrid
.tileSize
, monsGrid
.tileSize
);
547 function hilightWallTrc (pan
: TPanel
; tag
: Integer; x
, y
, prevx
, prevy
: Integer): Boolean;
549 result
:= false; // don't stop
550 if (pan
= nil) then exit
; // cell completion, ignore
551 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
552 hlmContext
.color
:= TGxRGBA
.Create(0, 128, 128, 64);
553 hlmContext
.fillRect(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
);
556 procedure monsCollector (mon
: TMonster
);
559 mx
, my
, mw
, mh
: Integer;
561 mon
.getMapBox(mx
, my
, mw
, mh
);
562 hlmContext
.color
:= TGxRGBA
.Create(255, 255, 0, 160);
563 hlmContext
.rect(mx
, my
, mw
, mh
);
564 //e_DrawQuad(mx, my, mx+mw-1, my+mh-1, 255, 255, 0, 96);
565 if lineAABBIntersects(laserX0
, laserY0
, laserX1
, laserY1
, mx
, my
, mw
, mh
, ex
, ey
) then
567 //e_DrawPoint(8, ex, ey, 0, 255, 0);
568 hlmContext
.color
:= TGxRGBA
.Create(0, 255, 0, 220);
569 hlmContext
.fillRect(ex
-2, ey
-2, 7, 7);
573 procedure drawMonsterInfo (mon
: TMonster
);
575 mx
, my
, mw
, mh
: Integer;
577 procedure drawMonsterTargetLine ();
579 emx
, emy
, emw
, emh
: Integer;
584 if (g_GetUIDType(mon
.MonsterTargetUID
) = UID_PLAYER
) then
586 eplr
:= g_Player_Get(mon
.MonsterTargetUID
);
587 if (eplr
<> nil) then eplr
.getMapBox(emx
, emy
, emw
, emh
) else exit
;
589 else if (g_GetUIDType(mon
.MonsterTargetUID
) = UID_MONSTER
) then
591 enemy
:= g_Monsters_ByUID(mon
.MonsterTargetUID
);
592 if (enemy
<> nil) then enemy
.getMapBox(emx
, emy
, emw
, emh
) else exit
;
598 mon
.getMapBox(mx
, my
, mw
, mh
);
599 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 0);
600 hlmContext
.line(mx
+mw
div 2, my
+mh
div 2, emx
+emw
div 2, emy
+emh
div 2);
601 if (g_Map_traceToNearestWall(mx
+mw
div 2, my
+mh
div 2, emx
+emw
div 2, emy
+emh
div 2, @ex
, @ey
) <> nil) then
603 hlmContext
.color
:= TGxRGBA
.Create(0, 255, 0);
604 hlmContext
.line(mx
+mw
div 2, my
+mh
div 2, ex
, ey
);
608 procedure drawLOS2Plr ();
610 emx
, emy
, emw
, emh
: Integer;
615 if (eplr
= nil) then exit
;
616 eplr
.getMapBox(emx
, emy
, emw
, emh
);
617 mon
.getMapBox(mx
, my
, mw
, mh
);
618 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 0);
619 hlmContext
.line(mx
+mw
div 2, my
+mh
div 2, emx
+emw
div 2, emy
+emh
div 2);
620 {$IF DEFINED(D2F_DEBUG)}
621 mapGrid
.dbgRayTraceTileHitCB
:= hilightCell1
;
623 if (g_Map_traceToNearestWall(mx
+mw
div 2, my
+mh
div 2, emx
+emw
div 2, emy
+emh
div 2, @ex
, @ey
) <> nil) then
624 //if (mapGrid.traceRay(ex, ey, mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, hilightWallTrc, (GridTagWall or GridTagDoor)) <> nil) then
626 hlmContext
.color
:= TGxRGBA
.Create(0, 255, 0);
627 hlmContext
.line(mx
+mw
div 2, my
+mh
div 2, ex
, ey
);
629 {$IF DEFINED(D2F_DEBUG)}
630 mapGrid
.dbgRayTraceTileHitCB
:= nil;
635 if (mon
= nil) then exit
;
636 mon
.getMapBox(mx
, my
, mw
, mh
);
639 //monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
640 hilightBodyCells(mon
.proxyId
);
644 //fillRect(mx-4, my-7*8-6, 110, 7*8+6, 0, 0, 94, 250);
645 hlmContext
.font
:= 'msx6';
646 hlmContext
.color
:= TGxRGBA
.Create(255, 127, 0);
648 hlmContext
.darkenRect(mx
-4, my
-7*hlmContext
.charWidth(' ')-6, 110, 7*hlmContext
.charWidth(' ')+6, 128);
653 hlmContext
.drawText(mx
, my
, Format('%s(U:%u)', [monsTypeToString(mon
.MonsterType
), mon
.UID
])); my
-= hlmContext
.charWidth(' ');
655 hlmContext
.drawText(mx
, my
, Format('Beh: %s', [monsBehToString(mon
.MonsterBehaviour
)])); my
-= hlmContext
.charWidth(' ');
657 hlmContext
.drawText(mx
, my
, Format('State:%s (%d)', [monsStateToString(mon
.MonsterState
), mon
.MonsterSleep
])); my
-= hlmContext
.charWidth(' ');
659 hlmContext
.drawText(mx
, my
, Format('Health:%d', [mon
.MonsterHealth
])); my
-= hlmContext
.charWidth(' ');
661 hlmContext
.drawText(mx
, my
, Format('Ammo:%d', [mon
.MonsterAmmo
])); my
-= hlmContext
.charWidth(' ');
663 hlmContext
.drawText(mx
, my
, Format('TgtUID:%u', [mon
.MonsterTargetUID
])); my
-= hlmContext
.charWidth(' ');
664 hlmContext
.drawText(mx
, my
, Format('TgtTime:%d', [mon
.MonsterTargetTime
])); my
-= hlmContext
.charWidth(' ');
667 drawMonsterTargetLine();
668 if showMonsLOS2Plr
then drawLOS2Plr();
670 property MonsterRemoved: Boolean read FRemoved write FRemoved;
671 property MonsterPain: Integer read FPain write FPain;
672 property MonsterAnim: Byte read FCurAnim write FCurAnim;
676 function highlightAllMonsterCells (mon
: TMonster
): Boolean;
678 result
:= false; // don't stop
679 //monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
680 hilightBodyCells(mon
.proxyId
);
683 procedure drawSelectedPlatformCells ();
687 if not showGrid
then exit
;
688 pan
:= g_Map_PanelByGUID(platMarkedGUID
);
689 if (pan
= nil) then exit
;
690 //mapGrid.forEachBodyCell(pan.proxyId, hilightCell);
691 hilightBodyCells(pan
.proxyId
);
692 hlmContext
.color
:= TGxRGBA
.Create(0, 200, 0, 200);
693 hlmContext
.rect(pan
.x
, pan
.y
, pan
.width
, pan
.height
);
696 procedure drawTrigger (var trig
: TTrigger
);
698 procedure drawPanelDest (pguid
: Integer);
702 pan
:= g_Map_PanelByGUID(pguid
);
703 if (pan
= nil) then exit
;
704 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 255, 220);
705 hlmContext
.line(trig
.trigCenter
.x
, trig
.trigCenter
.y
, pan
.x
+pan
.width
div 2, pan
.y
+pan
.height
div 2);
712 hlmContext
.font
:= 'msx6';
713 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 255, 96);
714 hlmContext
.fillRect(trig
.x
, trig
.y
, trig
.width
, trig
.height
);
715 tts
:= trigType2Str(trig
.TriggerType
);
716 tx
:= trig
.x
+(trig
.width
-Length(tts
)*6) div 2;
717 hlmContext
.darkenRect(tx
-2, trig
.y
-10, Length(tts
)*6+4, 10, 64);
718 hlmContext
.color
:= TGxRGBA
.Create(255, 127, 0);
719 hlmContext
.drawText(tx
, trig
.y
-9, tts
);
720 tx
:= trig
.x
+(trig
.width
-Length(trig
.mapId
)*6) div 2;
721 hlmContext
.darkenRect(tx
-2, trig
.y
-20, Length(trig
.mapId
)*6+4, 10, 64);
722 hlmContext
.color
:= TGxRGBA
.Create(255, 255, 0);
723 hlmContext
.drawText(tx
, trig
.y
-19, trig
.mapId
);
724 drawPanelDest(trig
.trigPanelGUID
);
725 case trig
.TriggerType
of
726 TRIGGER_NONE
: begin end;
727 TRIGGER_EXIT
: begin end;
728 TRIGGER_TELEPORT
: begin end;
729 TRIGGER_OPENDOOR
: begin end;
730 TRIGGER_CLOSEDOOR
: begin end;
731 TRIGGER_DOOR
: begin end;
732 TRIGGER_DOOR5
: begin end;
733 TRIGGER_CLOSETRAP
: begin end;
734 TRIGGER_TRAP
: begin end;
735 TRIGGER_SECRET
: begin end;
736 TRIGGER_LIFTUP
: begin end;
737 TRIGGER_LIFTDOWN
: begin end;
738 TRIGGER_LIFT
: begin end;
739 TRIGGER_TEXTURE
: begin end;
740 TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
, TRIGGER_PRESS
:
742 if (trig
.trigDataRec
.trigTWidth
> 0) and (trig
.trigDataRec
.trigTHeight
> 0) then
744 hlmContext
.color
:= TGxRGBA
.Create(0, 255, 255, 42);
746 trig
.trigDataRec
.trigTX
, trig
.trigDataRec
.trigTY
,
747 trig
.trigDataRec
.trigTWidth
, trig
.trigDataRec
.trigTHeight
);
748 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 255, 220);
750 trig
.trigCenter
.x
, trig
.trigCenter
.y
,
751 trig
.trigDataRec
.trigTX
+trig
.trigDataRec
.trigTWidth
div 2,
752 trig
.trigDataRec
.trigTY
+trig
.trigDataRec
.trigTHeight
div 2);
755 TRIGGER_SOUND
: begin end;
756 TRIGGER_SPAWNMONSTER
: begin end;
757 TRIGGER_SPAWNITEM
: begin end;
758 TRIGGER_MUSIC
: begin end;
759 TRIGGER_PUSH
: begin end;
760 TRIGGER_SCORE
: begin end;
761 TRIGGER_MESSAGE
: begin end;
762 TRIGGER_DAMAGE
: begin end;
763 TRIGGER_HEALTH
: begin end;
764 TRIGGER_SHOT
: begin end;
765 TRIGGER_EFFECT
: begin end;
766 TRIGGER_SCRIPT
: begin end;
769 //trigPanelId: Integer;
772 procedure drawTriggers ();
776 for f
:= 0 to High(gTriggers
) do drawTrigger(gTriggers
[f
]);
780 procedure drawGibsBoxes ();
783 px
, py
, pw
, ph
: Integer;
786 for f
:= 0 to High(gGibs
) do
791 gib
.getMapBox(px
, py
, pw
, ph
);
792 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 255);
793 hlmContext
.rect(px
, py
, pw
, ph
);
802 it
: TMonsterGrid
.Iter
;
803 mx
, my
, mw
, mh
: Integer;
809 if (gPlayer1
= nil) then exit
;
811 if (hlmContext
= nil) then hlmContext
:= r_fui_gfx_gl
.TGxContext
.Create();
813 gxSetContext(hlmContext
);
815 //glScissor(0, gScreenHeight-gPlayerScreenSize.Y-1, vpw, vph);
816 //hlmContext.clip := TGxRect.Create(0, gScreenHeight-gPlayerScreenSize.Y-1, gPlayerScreenSize.X, gPlayerScreenSize.Y);
819 glScalef(g_dbg_scale, g_dbg_scale, 1.0);
820 glTranslatef(-vpx, -vpy, 0);
822 hlmContext
.glSetScaleTrans(g_dbg_scale
, -vpx
, -vpy
);
823 glEnable(GL_SCISSOR_TEST
);
824 glScissor(0, gScreenHeight
-gPlayerScreenSize
.Y
-1, gPlayerScreenSize
.X
, gPlayerScreenSize
.Y
);
826 if (showGrid
) then drawTileGrid();
831 //g_Mons_AlongLine(laserX0, laserY0, laserX1, laserY1, monsCollector, true);
832 it
:= monsGrid
.forEachAlongLine(laserX0
, laserY0
, laserX1
, laserY1
, -1, true);
833 for mit
in it
do monsCollector(mit
^);
837 if (monMarkedUID
<> -1) then
839 mon
:= g_Monsters_ByUID(monMarkedUID
);
842 mon
.getMapBox(mx
, my
, mw
, mh
);
843 //e_DrawQuad(mx, my, mx+mw-1, my+mh-1, 255, 0, 0, 30);
844 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 0, 220);
845 hlmContext
.rect(mx
, my
, mw
, mh
);
846 drawMonsterInfo(mon
);
850 if showAllMonsCells
and showGrid
then g_Mons_ForEach(highlightAllMonsterCells
);
851 if showTriggers
then drawTriggers();
852 if showGrid
then drawSelectedPlatformCells();
858 if showTraceBox
then drawTraceBox();
864 //pan := g_Map_traceToNearest(16, 608, 16, 8, (GridTagObstacle or GridTagLiquid), @ex, @ey);
866 {$IF DEFINED(D2F_DEBUG)}
867 mapGrid.dbgRayTraceTileHitCB := hilightCell1;
869 pan := mapGrid.traceRay(ex, ey, 16, 608, 16, 8, nil, (GridTagObstacle or GridTagLiquid));
870 if (pan <> nil) then writeln('end=(', ex, ',', ey, ')');
871 {$IF DEFINED(D2F_DEBUG)}
872 mapGrid.dbgRayTraceTileHitCB := nil;
875 pan := g_Map_PanelAtPoint(16, 608, (GridTagObstacle or GridTagLiquid));
876 if (pan <> nil) then writeln('hit!');
883 if showMapCurPos
then
885 s
:= Format('mappos:(%d,%d)', [pmsCurMapX
, pmsCurMapY
]);
886 gxSetContext(hlmContext
);
887 hlmContext
.font
:= 'win8';
888 hlmContext
.color
:= TGxRGBA
.Create(0, 0, 0);
893 if (dx
<> 0) or (dy
<> 0) then hlmContext
.drawText(4+dx
, gScreenHeight
-10+dy
, s
);
896 hlmContext
.color
:= TGxRGBA
.Create(255, 255, 0);
897 hlmContext
.drawText(4, gScreenHeight
-10, s
);
903 // ////////////////////////////////////////////////////////////////////////// //
904 procedure r_Holmes_Draw ();
906 if g_Game_IsNet
then exit
;
907 if not g_holmes_enabled
then exit
;
908 if g_holmes_imfunctional
then exit
;
910 holmesInitCommands();
913 {$IFDEF ENABLE_RENDER}
914 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
915 glDisable(GL_STENCIL_TEST
);
917 glDisable(GL_SCISSOR_TEST
);
918 glDisable(GL_TEXTURE_2D
);
920 if gGameOn
then plrDebugDraw();
927 procedure r_Holmes_DrawUI ();
929 if g_Game_IsNet
then exit
;
930 if not g_holmes_enabled
then exit
;
931 if g_holmes_imfunctional
then exit
;
933 gGfxDoClear
:= false;
935 {$IFDEF ENABLE_RENDER}
936 //if assigned(prerenderFrameCB) then prerenderFrameCB();
938 glMatrixMode(GL_MODELVIEW
);
942 if assigned(postrenderFrameCB
) then postrenderFrameCB();
951 conRegVar('hlm_ui_scale', @fuiRenderScale
, 0.01, 5.0, 'Holmes UI scale', '', false);