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}
20 procedure r_Holmes_Draw ();
21 procedure r_Holmes_DrawUI ();
24 procedure r_Holmes_plrViewPos (viewPortX
, viewPortY
: Integer);
25 procedure r_Holmes_plrViewSize (viewPortW
, viewPortH
: Integer);
26 procedure r_Holmes_plrLaser (ax0
, ay0
, ax1
, ay1
: Integer);
28 function pmsCurMapX (): Integer;
29 function pmsCurMapY (): Integer;
32 vpSet
: Boolean = false;
37 {$INCLUDE ../nogl/noGLuses.inc}
40 g_basic
, g_grid
, g_player
, g_monsters
,
41 g_map
, g_triggers
, g_items
, g_game
, g_panel
, g_console
,
54 typinfo
, SysUtils
, Classes
,
58 hlmContext
: r_fui_gfx_gl
.TGxContext
= nil;
61 laserSet
: Boolean = false;
62 laserX0
, laserY0
, laserX1
, laserY1
: Integer;
64 // ////////////////////////////////////////////////////////////////////////// //
66 {$INCLUDE r_holmes_ol.inc}
68 // ////////////////////////////////////////////////////////////////////////// //
70 procedure r_Holmes_plrViewPos (viewPortX
, viewPortY
: Integer);
77 procedure r_Holmes_plrViewSize (viewPortW
, viewPortH
: Integer);
84 procedure r_Holmes_plrLaser (ax0
, ay0
, ax1
, ay1
: Integer);
91 laserSet
:= laserSet
; // shut up, fpc!
94 function pmsCurMapX (): Integer; inline; begin result
:= round(msX
/g_dbg_scale
)+vpx
; end;
95 function pmsCurMapY (): Integer; inline; begin result
:= round(msY
/g_dbg_scale
)+vpy
; end;
97 {$IFDEF HOLMES_OLD_OUTLINES}
99 edgeBmp
: array of Byte = nil;
102 procedure drawOutlines ();
106 procedure clearEdgeBmp ();
108 SetLength(edgeBmp
, (gScreenWidth
+4)*(gScreenHeight
+4));
109 FillChar(edgeBmp
[0], Length(edgeBmp
)*sizeof(edgeBmp
[0]), 0);
112 procedure drawPanel (pan
: TPanel
);
114 sx
, len
, y0
, y1
: Integer;
116 if (pan
= nil) or (pan
.Width
< 1) or (pan
.Height
< 1) then exit
;
117 if (pan
.X
+pan
.Width
<= vpx
-1) or (pan
.Y
+pan
.Height
<= vpy
-1) then exit
;
118 if (pan
.X
>= vpx
+vpw
+1) or (pan
.Y
>= vpy
+vph
+1) then exit
;
119 if g_ol_nice
or g_ol_fill_walls
then
123 if (len
> gScreenWidth
+4) then len
:= gScreenWidth
+4;
124 if (sx
< 0) then begin len
+= sx
; sx
:= 0; end;
125 if (sx
+len
> gScreenWidth
+4) then len
:= gScreenWidth
+4-sx
;
126 if (len
< 1) then exit
;
128 assert(sx
+len
<= gScreenWidth
+4);
131 if (y0
< 0) then y0
:= 0;
132 if (y1
> gScreenHeight
+4) then y1
:= gScreenHeight
+4;
135 FillChar(edgeBmp
[y0
*(gScreenWidth
+4)+sx
], len
*sizeof(edgeBmp
[0]), 1);
141 drawRect(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, r
, g
, b
);
150 procedure flushLine ();
152 if (lsy
> 0) and (lsx
> 0) then
157 glVertex2f(lsx
-1+vpx
+0.37, lsy
-1+vpy
+0.37);
163 glVertex2f(lsx
-1+vpx
+0.37, lsy
-1+vpy
+0.37);
164 glVertex2f(lex
-0+vpx
+0.37, lsy
-1+vpy
+0.37);
172 procedure startLine (y
: Integer);
178 procedure putPixel (x
: Integer);
180 if (x
< 1) then exit
;
181 if (lex
+1 <> x
) then flushLine();
182 if (lsx
< 0) then lsx
:= x
;
186 procedure drawEdges ();
192 glDisable(GL_TEXTURE_2D
);
195 glDisable(GL_LINE_SMOOTH
);
196 glDisable(GL_POLYGON_SMOOTH
);
197 glColor4f(r
/255.0, g
/255.0, b
/255.0, 1.0);
200 a
:= @edgeBmp
[y
*(gScreenWidth
+4)+1];
206 if (a
[-1] = 0) or (a
[1] = 0) or (a
[-(gScreenWidth
+4)] = 0) or (a
[gScreenWidth
+4] = 0) or
207 (a
[-(gScreenWidth
+4)-1] = 0) or (a
[-(gScreenWidth
+4)+1] = 0) or
208 (a
[gScreenWidth
+4-1] = 0) or (a
[gScreenWidth
+4+1] = 0) then
219 procedure drawFilledWalls ();
225 glDisable(GL_TEXTURE_2D
);
228 glDisable(GL_LINE_SMOOTH
);
229 glDisable(GL_POLYGON_SMOOTH
);
230 glColor4f(r
/255.0, g
/255.0, b
/255.0, 1.0);
233 a
:= @edgeBmp
[y
*(gScreenWidth
+4)+1];
237 if (a
[0] <> 0) then putPixel(x
);
244 procedure doWallsOld (parr
: array of TPanel
; ptype
: Word; ar
, ag
, ab
: Integer);
252 if g_ol_nice
or g_ol_fill_walls
then clearEdgeBmp();
253 for f
:= 0 to High(parr
) do
256 if (pan
= nil) or not pan
.Enabled
or (pan
.Width
< 1) or (pan
.Height
< 1) then continue
;
257 if ((pan
.PanelType
and ptype
) = 0) then continue
;
260 if g_ol_nice
then drawEdges();
261 if g_ol_fill_walls
then drawFilledWalls();
267 function doWallCB (pan
: TPanel
; tag
: Integer): Boolean;
269 result
:= false; // don't stop
270 //if (pan = nil) or not pan.Enabled or (pan.Width < 1) or (pan.Height < 1) then exit;
271 if ((pan
.PanelType
and xptag
) = 0) then exit
;
275 procedure doWalls (parr
: array of TPanel
; ptype
: Word; ar
, ag
, ab
: Integer);
281 if ((ptype
and (PANEL_WALL
or PANEL_OPENDOOR
or PANEL_CLOSEDOOR
)) <> 0) then ptype
:= GridTagWall
or GridTagDoor
282 else panelTypeToTag(ptype
);
283 if g_ol_nice
or g_ol_fill_walls
then clearEdgeBmp();
284 mapGrid
.forEachInAABB(vpx
-1, vpy
-1, vpw
+2, vph
+2, doWallCB
, ptype
);
285 if g_ol_nice
then drawEdges();
286 if g_ol_fill_walls
then drawFilledWalls();
290 if g_ol_rlayer_back
then doWallsOld(gRenderBackgrounds
, PANEL_BACK
, 255, 127, 0);
291 if g_ol_rlayer_step
then doWallsOld(gSteps
, PANEL_STEP
, 192, 192, 192);
292 if g_ol_rlayer_wall
then doWallsOld(gWalls
, PANEL_WALL
, 255, 255, 255);
293 if g_ol_rlayer_door
then doWallsOld(gWalls
, PANEL_OPENDOOR
or PANEL_CLOSEDOOR
, 0, 255, 0);
294 if g_ol_rlayer_acid1
then doWallsOld(gAcid1
, PANEL_ACID1
, 255, 0, 0);
295 if g_ol_rlayer_acid2
then doWallsOld(gAcid2
, PANEL_ACID2
, 198, 198, 0);
296 if g_ol_rlayer_water
then doWallsOld(gWater
, PANEL_WATER
, 0, 255, 255);
297 if g_ol_rlayer_fore
then doWallsOld(gRenderForegrounds
, PANEL_FORE
, 210, 210, 210);
302 oliner
: TOutliner
= nil;
304 procedure drawOutlines ();
308 procedure clearOliner ();
310 //if (oliner <> nil) and ((oliner.height <> vph+2) or (oliner.width <> vpw+2)) then begin oliner.Free(); oliner := nil; end;
311 if (oliner
= nil) then oliner
:= TOutliner
.Create(vpw
+2, vph
+2) else oliner
.setup(vpw
+2, vph
+2);
314 procedure drawOutline (ol
: TOutliner
; sx
, sy
: Integer);
315 procedure xline (x0
, x1
, y
: Integer);
319 if (g_dbg_scale
< 1.0) then
322 for x
:= x0
to x1
do glVertex2f(sx
+x
+0.375, sy
+y
+0.375);
328 glVertex2f(sx
+x0
+0, sy
+y
+0);
329 glVertex2f(sx
+x1
+1, sy
+y
+0);
330 glVertex2f(sx
+x1
+1, sy
+y
+1);
331 glVertex2f(sx
+x0
+0, sy
+y
+1);
337 sp
: TOutliner
.TSpanX
;
339 if (ol
= nil) then exit
;
341 glDisable(GL_POINT_SMOOTH
);
342 for y
:= 0 to ol
.height
-1 do
344 for sp
in ol
.eachSpanAtY(y
) do
346 if (g_dbg_scale
<= 1.0) then
349 glVertex2f(sx
+sp
.x0
+0.375, sy
+y
+0.375);
350 glVertex2f(sx
+sp
.x1
+0.375, sy
+y
+0.375);
356 glVertex2f(sx
+sp
.x0
+0, sy
+y
+0);
357 glVertex2f(sx
+sp
.x0
+1, sy
+y
+0);
358 glVertex2f(sx
+sp
.x0
+1, sy
+y
+1);
359 glVertex2f(sx
+sp
.x0
+0, sy
+y
+1);
361 glVertex2f(sx
+sp
.x1
+0, sy
+y
+0);
362 glVertex2f(sx
+sp
.x1
+1, sy
+y
+0);
363 glVertex2f(sx
+sp
.x1
+1, sy
+y
+1);
364 glVertex2f(sx
+sp
.x1
+0, sy
+y
+1);
368 for sp
in ol
.eachSpanEdgeAtY(y
, -1) do
370 xline(sp
.x0
, sp
.x1
, y
);
373 glVertex2f(sx+sp.x0+0, sy+y+0);
374 glVertex2f(sx+sp.x1+1, sy+y+0);
375 glVertex2f(sx+sp.x1+1, sy+y+1);
376 glVertex2f(sx+sp.x0+0, sy+y+1);
380 for sp
in ol
.eachSpanEdgeAtY(y
, +1) do
382 xline(sp
.x0
, sp
.x1
, y
);
385 glVertex2f(sx+sp.x0+0, sy+y+0);
386 glVertex2f(sx+sp.x1+1, sy+y+0);
387 glVertex2f(sx+sp.x1+1, sy+y+1);
388 glVertex2f(sx+sp.x0+0, sy+y+1);
395 procedure doWallsOld (parr
: array of TPanel
; ptype
: Word; ar
, ag
, ab
: Integer);
403 if g_ol_nice
then clearOliner();
404 hlmContext
.color
:= TGxRGBA
.Create(r
, g
, b
);
405 for f
:= 0 to High(parr
) do
408 if (pan
= nil) or not pan
.Enabled
or (pan
.Width
< 1) or (pan
.Height
< 1) then continue
;
409 if ((pan
.PanelType
and ptype
) = 0) then continue
;
410 if (pan
.X
> vpx
+vpw
+41) or (pan
.Y
> vpy
+vph
+41) then continue
;
411 if (pan
.X
+pan
.Width
< vpx
-41) then continue
;
412 if (pan
.Y
+pan
.Height
< vpy
-41) then continue
;
415 oliner
.addRect(pan
.X
-(vpx
+1), pan
.Y
-(vpy
+1), pan
.Width
, pan
.Height
);
417 if g_ol_fill_walls
then
419 hlmContext
.fillRect(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
);
421 else if not g_ol_nice
then
423 hlmContext
.rect(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
);
428 glColor4f(r
/255.0, g
/255.0, b
/255.0, 1.0);
429 drawOutline(oliner
, vpx
+1, vpy
+1);
434 if (vpw
< 2) or (vph
< 2) then exit
;
435 if g_ol_rlayer_back
then doWallsOld(gRenderBackgrounds
, PANEL_BACK
, 255, 127, 0);
436 if g_ol_rlayer_step
then doWallsOld(gSteps
, PANEL_STEP
, 192, 192, 192);
437 if g_ol_rlayer_wall
then doWallsOld(gWalls
, PANEL_WALL
, 255, 255, 255);
438 if g_ol_rlayer_door
then doWallsOld(gWalls
, PANEL_OPENDOOR
or PANEL_CLOSEDOOR
, 0, 255, 0);
439 if g_ol_rlayer_acid1
then doWallsOld(gAcid1
, PANEL_ACID1
, 255, 0, 0);
440 if g_ol_rlayer_acid2
then doWallsOld(gAcid2
, PANEL_ACID2
, 198, 198, 0);
441 if g_ol_rlayer_water
then doWallsOld(gWater
, PANEL_WATER
, 0, 255, 255);
442 if g_ol_rlayer_fore
then doWallsOld(gRenderForegrounds
, PANEL_FORE
, 210, 210, 210);
447 procedure plrDebugDraw ();
448 procedure drawTileGrid ();
452 hlmContext
.color
:= TGxRGBA
.Create(96, 96, 96);
453 for y
:= 0 to (mapGrid
.gridHeight
div mapGrid
.tileSize
) do
455 hlmContext
.line(mapGrid
.gridX0
, mapGrid
.gridY0
+y
*mapGrid
.tileSize
, mapGrid
.gridX0
+mapGrid
.gridWidth
, mapGrid
.gridY0
+y
*mapGrid
.tileSize
);
458 hlmContext
.color
:= TGxRGBA
.Create(96, 96, 96);
459 for x
:= 0 to (mapGrid
.gridWidth
div mapGrid
.tileSize
) do
461 hlmContext
.line(mapGrid
.gridX0
+x
*mapGrid
.tileSize
, mapGrid
.gridY0
, mapGrid
.gridX0
+x
*mapGrid
.tileSize
, mapGrid
.gridY0
+y
*mapGrid
.gridHeight
);
466 procedure drawAwakeCells ();
470 hlmContext
.color
:= TGxRGBA
.Create(128, 0, 128, 64);
471 for y
:= 0 to (mapGrid
.gridHeight
div mapGrid
.tileSize
) do
473 for x
:= 0 to (mapGrid
.gridWidth
div mapGrid
.tileSize
) do
475 if awmIsSetHolmes(x
*mapGrid
.tileSize
+mapGrid
.gridX0
+1, y
*mapGrid
.tileSize
++mapGrid
.gridY0
+1) then
477 hlmContext
.fillRect(x
*mapGrid
.tileSize
++mapGrid
.gridX0
, y
*mapGrid
.tileSize
++mapGrid
.gridY0
, monsGrid
.tileSize
, monsGrid
.tileSize
);
484 procedure drawTraceBox ();
487 px
, py
, pw
, ph
: Integer;
492 if (Length(gPlayers
) < 1) then exit
;
494 if (plr
= nil) then exit
;
495 plr
.getMapBox(px
, py
, pw
, ph
);
496 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 255, 200);
497 hlmContext
.rect(px
, py
, pw
, ph
);
498 pdx
:= pmsCurMapX
-(px
+pw
div 2);
499 pdy
:= pmsCurMapY
-(py
+ph
div 2);
500 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 255, 200);
501 hlmContext
.line(px
+pw
div 2, py
+ph
div 2, px
+pw
div 2+pdx
, py
+ph
div 2+pdy
);
502 pan
:= mapGrid
.traceBox(ex
, ey
, px
, py
, pw
, ph
, pdx
, pdy
, GridTagObstacle
);
505 hlmContext
.color
:= TGxRGBA
.Create(255, 255, 255, 180);
506 hlmContext
.rect(px
+pdx
, py
+pdy
, pw
, ph
);
510 hlmContext
.color
:= TGxRGBA
.Create(255, 255, 0, 180);
511 hlmContext
.rect(px
+pdx
, py
+pdy
, pw
, ph
);
513 hlmContext
.color
:= TGxRGBA
.Create(255, 127, 0, 180);
514 hlmContext
.rect(ex
, ey
, pw
, ph
);
517 procedure hilightCell (cx
, cy
: Integer);
519 hlmContext
.color
:= TGxRGBA
.Create(0, 128, 0, 64);
520 hlmContext
.fillRect(cx
, cy
, monsGrid
.tileSize
, monsGrid
.tileSize
);
523 procedure hilightBodyCells (proxyId
: Integer);
526 pcellxy
: PGridCellCoord
;
528 //monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
529 it
:= monsGrid
.forEachBodyCell(proxyId
);
530 for pcellxy
in it
do hilightCell(pcellxy
^.x
, pcellxy
^.y
);
534 procedure hilightCell1 (cx
, cy
: Integer);
536 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
537 cx
:= cx
and (not (monsGrid
.tileSize
-1));
538 cy
:= cy
and (not (monsGrid
.tileSize
-1));
539 hlmContext
.color
:= TGxRGBA
.Create(255, 255, 0, 92);
540 hlmContext
.fillRect(cx
, cy
, monsGrid
.tileSize
, monsGrid
.tileSize
);
543 function hilightWallTrc (pan
: TPanel
; tag
: Integer; x
, y
, prevx
, prevy
: Integer): Boolean;
545 result
:= false; // don't stop
546 if (pan
= nil) then exit
; // cell completion, ignore
547 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
548 hlmContext
.color
:= TGxRGBA
.Create(0, 128, 128, 64);
549 hlmContext
.fillRect(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
);
552 procedure monsCollector (mon
: TMonster
);
555 mx
, my
, mw
, mh
: Integer;
557 mon
.getMapBox(mx
, my
, mw
, mh
);
558 hlmContext
.color
:= TGxRGBA
.Create(255, 255, 0, 160);
559 hlmContext
.rect(mx
, my
, mw
, mh
);
560 //e_DrawQuad(mx, my, mx+mw-1, my+mh-1, 255, 255, 0, 96);
561 if lineAABBIntersects(laserX0
, laserY0
, laserX1
, laserY1
, mx
, my
, mw
, mh
, ex
, ey
) then
563 //e_DrawPoint(8, ex, ey, 0, 255, 0);
564 hlmContext
.color
:= TGxRGBA
.Create(0, 255, 0, 220);
565 hlmContext
.fillRect(ex
-2, ey
-2, 7, 7);
569 procedure drawMonsterInfo (mon
: TMonster
);
571 mx
, my
, mw
, mh
: Integer;
573 procedure drawMonsterTargetLine ();
575 emx
, emy
, emw
, emh
: Integer;
580 if (g_GetUIDType(mon
.MonsterTargetUID
) = UID_PLAYER
) then
582 eplr
:= g_Player_Get(mon
.MonsterTargetUID
);
583 if (eplr
<> nil) then eplr
.getMapBox(emx
, emy
, emw
, emh
) else exit
;
585 else if (g_GetUIDType(mon
.MonsterTargetUID
) = UID_MONSTER
) then
587 enemy
:= g_Monsters_ByUID(mon
.MonsterTargetUID
);
588 if (enemy
<> nil) then enemy
.getMapBox(emx
, emy
, emw
, emh
) else exit
;
594 mon
.getMapBox(mx
, my
, mw
, mh
);
595 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 0);
596 hlmContext
.line(mx
+mw
div 2, my
+mh
div 2, emx
+emw
div 2, emy
+emh
div 2);
597 if (g_Map_traceToNearestWall(mx
+mw
div 2, my
+mh
div 2, emx
+emw
div 2, emy
+emh
div 2, @ex
, @ey
) <> nil) then
599 hlmContext
.color
:= TGxRGBA
.Create(0, 255, 0);
600 hlmContext
.line(mx
+mw
div 2, my
+mh
div 2, ex
, ey
);
604 procedure drawLOS2Plr ();
606 emx
, emy
, emw
, emh
: Integer;
611 if (eplr
= nil) then exit
;
612 eplr
.getMapBox(emx
, emy
, emw
, emh
);
613 mon
.getMapBox(mx
, my
, mw
, mh
);
614 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 0);
615 hlmContext
.line(mx
+mw
div 2, my
+mh
div 2, emx
+emw
div 2, emy
+emh
div 2);
616 {$IF DEFINED(D2F_DEBUG)}
617 mapGrid
.dbgRayTraceTileHitCB
:= hilightCell1
;
619 if (g_Map_traceToNearestWall(mx
+mw
div 2, my
+mh
div 2, emx
+emw
div 2, emy
+emh
div 2, @ex
, @ey
) <> nil) then
620 //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
622 hlmContext
.color
:= TGxRGBA
.Create(0, 255, 0);
623 hlmContext
.line(mx
+mw
div 2, my
+mh
div 2, ex
, ey
);
625 {$IF DEFINED(D2F_DEBUG)}
626 mapGrid
.dbgRayTraceTileHitCB
:= nil;
631 if (mon
= nil) then exit
;
632 mon
.getMapBox(mx
, my
, mw
, mh
);
635 //monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
636 hilightBodyCells(mon
.proxyId
);
640 //fillRect(mx-4, my-7*8-6, 110, 7*8+6, 0, 0, 94, 250);
641 hlmContext
.font
:= 'msx6';
642 hlmContext
.color
:= TGxRGBA
.Create(255, 127, 0);
644 hlmContext
.darkenRect(mx
-4, my
-7*hlmContext
.charWidth(' ')-6, 110, 7*hlmContext
.charWidth(' ')+6, 128);
649 hlmContext
.drawText(mx
, my
, Format('%s(U:%u)', [monsTypeToString(mon
.MonsterType
), mon
.UID
])); my
-= hlmContext
.charWidth(' ');
651 hlmContext
.drawText(mx
, my
, Format('Beh: %s', [monsBehToString(mon
.MonsterBehaviour
)])); my
-= hlmContext
.charWidth(' ');
653 hlmContext
.drawText(mx
, my
, Format('State:%s (%d)', [monsStateToString(mon
.MonsterState
), mon
.MonsterSleep
])); my
-= hlmContext
.charWidth(' ');
655 hlmContext
.drawText(mx
, my
, Format('Health:%d', [mon
.MonsterHealth
])); my
-= hlmContext
.charWidth(' ');
657 hlmContext
.drawText(mx
, my
, Format('Ammo:%d', [mon
.MonsterAmmo
])); my
-= hlmContext
.charWidth(' ');
659 hlmContext
.drawText(mx
, my
, Format('TgtUID:%u', [mon
.MonsterTargetUID
])); my
-= hlmContext
.charWidth(' ');
660 hlmContext
.drawText(mx
, my
, Format('TgtTime:%d', [mon
.MonsterTargetTime
])); my
-= hlmContext
.charWidth(' ');
663 drawMonsterTargetLine();
664 if showMonsLOS2Plr
then drawLOS2Plr();
666 property MonsterRemoved: Boolean read FRemoved write FRemoved;
667 property MonsterPain: Integer read FPain write FPain;
668 property MonsterAnim: Byte read FCurAnim write FCurAnim;
672 function highlightAllMonsterCells (mon
: TMonster
): Boolean;
674 result
:= false; // don't stop
675 //monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
676 hilightBodyCells(mon
.proxyId
);
679 procedure drawSelectedPlatformCells ();
683 if not showGrid
then exit
;
684 pan
:= g_Map_PanelByGUID(platMarkedGUID
);
685 if (pan
= nil) then exit
;
686 //mapGrid.forEachBodyCell(pan.proxyId, hilightCell);
687 hilightBodyCells(pan
.proxyId
);
688 hlmContext
.color
:= TGxRGBA
.Create(0, 200, 0, 200);
689 hlmContext
.rect(pan
.x
, pan
.y
, pan
.width
, pan
.height
);
692 procedure drawTrigger (var trig
: TTrigger
);
694 procedure drawPanelDest (pguid
: Integer);
698 pan
:= g_Map_PanelByGUID(pguid
);
699 if (pan
= nil) then exit
;
700 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 255, 220);
701 hlmContext
.line(trig
.trigCenter
.x
, trig
.trigCenter
.y
, pan
.x
+pan
.width
div 2, pan
.y
+pan
.height
div 2);
708 hlmContext
.font
:= 'msx6';
709 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 255, 96);
710 hlmContext
.fillRect(trig
.x
, trig
.y
, trig
.width
, trig
.height
);
711 tts
:= trigType2Str(trig
.TriggerType
);
712 tx
:= trig
.x
+(trig
.width
-Length(tts
)*6) div 2;
713 hlmContext
.darkenRect(tx
-2, trig
.y
-10, Length(tts
)*6+4, 10, 64);
714 hlmContext
.color
:= TGxRGBA
.Create(255, 127, 0);
715 hlmContext
.drawText(tx
, trig
.y
-9, tts
);
716 tx
:= trig
.x
+(trig
.width
-Length(trig
.mapId
)*6) div 2;
717 hlmContext
.darkenRect(tx
-2, trig
.y
-20, Length(trig
.mapId
)*6+4, 10, 64);
718 hlmContext
.color
:= TGxRGBA
.Create(255, 255, 0);
719 hlmContext
.drawText(tx
, trig
.y
-19, trig
.mapId
);
720 drawPanelDest(trig
.trigPanelGUID
);
721 case trig
.TriggerType
of
722 TRIGGER_NONE
: begin end;
723 TRIGGER_EXIT
: begin end;
724 TRIGGER_TELEPORT
: begin end;
725 TRIGGER_OPENDOOR
: begin end;
726 TRIGGER_CLOSEDOOR
: begin end;
727 TRIGGER_DOOR
: begin end;
728 TRIGGER_DOOR5
: begin end;
729 TRIGGER_CLOSETRAP
: begin end;
730 TRIGGER_TRAP
: begin end;
731 TRIGGER_SECRET
: begin end;
732 TRIGGER_LIFTUP
: begin end;
733 TRIGGER_LIFTDOWN
: begin end;
734 TRIGGER_LIFT
: begin end;
735 TRIGGER_TEXTURE
: begin end;
736 TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
, TRIGGER_PRESS
:
738 if (trig
.trigDataRec
.trigTWidth
> 0) and (trig
.trigDataRec
.trigTHeight
> 0) then
740 hlmContext
.color
:= TGxRGBA
.Create(0, 255, 255, 42);
742 trig
.trigDataRec
.trigTX
, trig
.trigDataRec
.trigTY
,
743 trig
.trigDataRec
.trigTWidth
, trig
.trigDataRec
.trigTHeight
);
744 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 255, 220);
746 trig
.trigCenter
.x
, trig
.trigCenter
.y
,
747 trig
.trigDataRec
.trigTX
+trig
.trigDataRec
.trigTWidth
div 2,
748 trig
.trigDataRec
.trigTY
+trig
.trigDataRec
.trigTHeight
div 2);
751 TRIGGER_SOUND
: begin end;
752 TRIGGER_SPAWNMONSTER
: begin end;
753 TRIGGER_SPAWNITEM
: begin end;
754 TRIGGER_MUSIC
: begin end;
755 TRIGGER_PUSH
: begin end;
756 TRIGGER_SCORE
: begin end;
757 TRIGGER_MESSAGE
: begin end;
758 TRIGGER_DAMAGE
: begin end;
759 TRIGGER_HEALTH
: begin end;
760 TRIGGER_SHOT
: begin end;
761 TRIGGER_EFFECT
: begin end;
762 TRIGGER_SCRIPT
: begin end;
765 //trigPanelId: Integer;
768 procedure drawTriggers ();
772 for f
:= 0 to High(gTriggers
) do drawTrigger(gTriggers
[f
]);
776 procedure drawGibsBoxes ();
779 px
, py
, pw
, ph
: Integer;
782 for f
:= 0 to High(gGibs
) do
787 gib
.getMapBox(px
, py
, pw
, ph
);
788 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 255);
789 hlmContext
.rect(px
, py
, pw
, ph
);
798 it
: TMonsterGrid
.Iter
;
799 mx
, my
, mw
, mh
: Integer;
805 if (gPlayer1
= nil) then exit
;
807 if (hlmContext
= nil) then hlmContext
:= r_fui_gfx_gl
.TGxContext
.Create();
809 gxSetContext(hlmContext
);
811 //glScissor(0, gScreenHeight-gPlayerScreenSize.Y-1, vpw, vph);
812 //hlmContext.clip := TGxRect.Create(0, gScreenHeight-gPlayerScreenSize.Y-1, gPlayerScreenSize.X, gPlayerScreenSize.Y);
815 glScalef(g_dbg_scale, g_dbg_scale, 1.0);
816 glTranslatef(-vpx, -vpy, 0);
818 hlmContext
.glSetScaleTrans(g_dbg_scale
, -vpx
, -vpy
);
819 glEnable(GL_SCISSOR_TEST
);
820 glScissor(0, gScreenHeight
-gPlayerScreenSize
.Y
-1, gPlayerScreenSize
.X
, gPlayerScreenSize
.Y
);
822 if (showGrid
) then drawTileGrid();
827 //g_Mons_AlongLine(laserX0, laserY0, laserX1, laserY1, monsCollector, true);
828 it
:= monsGrid
.forEachAlongLine(laserX0
, laserY0
, laserX1
, laserY1
, -1, true);
829 for mit
in it
do monsCollector(mit
^);
833 if (monMarkedUID
<> -1) then
835 mon
:= g_Monsters_ByUID(monMarkedUID
);
838 mon
.getMapBox(mx
, my
, mw
, mh
);
839 //e_DrawQuad(mx, my, mx+mw-1, my+mh-1, 255, 0, 0, 30);
840 hlmContext
.color
:= TGxRGBA
.Create(255, 0, 0, 220);
841 hlmContext
.rect(mx
, my
, mw
, mh
);
842 drawMonsterInfo(mon
);
846 if showAllMonsCells
and showGrid
then g_Mons_ForEach(highlightAllMonsterCells
);
847 if showTriggers
then drawTriggers();
848 if showGrid
then drawSelectedPlatformCells();
854 if showTraceBox
then drawTraceBox();
860 //pan := g_Map_traceToNearest(16, 608, 16, 8, (GridTagObstacle or GridTagLiquid), @ex, @ey);
862 {$IF DEFINED(D2F_DEBUG)}
863 mapGrid.dbgRayTraceTileHitCB := hilightCell1;
865 pan := mapGrid.traceRay(ex, ey, 16, 608, 16, 8, nil, (GridTagObstacle or GridTagLiquid));
866 if (pan <> nil) then writeln('end=(', ex, ',', ey, ')');
867 {$IF DEFINED(D2F_DEBUG)}
868 mapGrid.dbgRayTraceTileHitCB := nil;
871 pan := g_Map_PanelAtPoint(16, 608, (GridTagObstacle or GridTagLiquid));
872 if (pan <> nil) then writeln('hit!');
879 if showMapCurPos
then
881 s
:= Format('mappos:(%d,%d)', [pmsCurMapX
, pmsCurMapY
]);
882 gxSetContext(hlmContext
);
883 hlmContext
.font
:= 'win8';
884 hlmContext
.color
:= TGxRGBA
.Create(0, 0, 0);
889 if (dx
<> 0) or (dy
<> 0) then hlmContext
.drawText(4+dx
, gScreenHeight
-10+dy
, s
);
892 hlmContext
.color
:= TGxRGBA
.Create(255, 255, 0);
893 hlmContext
.drawText(4, gScreenHeight
-10, s
);
899 // ////////////////////////////////////////////////////////////////////////// //
900 procedure r_Holmes_Draw ();
902 if g_Game_IsNet
then exit
;
903 if not g_holmes_enabled
then exit
;
904 if g_holmes_imfunctional
then exit
;
906 holmesInitCommands();
909 {$IFDEF ENABLE_RENDER}
910 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
911 glDisable(GL_STENCIL_TEST
);
913 glDisable(GL_SCISSOR_TEST
);
914 glDisable(GL_TEXTURE_2D
);
916 if gGameOn
then plrDebugDraw();
923 procedure r_Holmes_DrawUI ();
925 if g_Game_IsNet
then exit
;
926 if not g_holmes_enabled
then exit
;
927 if g_holmes_imfunctional
then exit
;
929 gGfxDoClear
:= false;
931 {$IFDEF ENABLE_RENDER}
932 //if assigned(prerenderFrameCB) then prerenderFrameCB();
934 glMatrixMode(GL_MODELVIEW
);
938 if assigned(postrenderFrameCB
) then postrenderFrameCB();
947 conRegVar('hlm_ui_scale', @fuiRenderScale
, 0.01, 5.0, 'Holmes UI scale', '', false);