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, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
23 g_textures
, g_basic
, e_graphics
, g_phys
, g_grid
, g_player
, g_monsters
,
24 g_window
, g_map
, g_triggers
, g_items
, g_game
, g_panel
, g_console
,
32 // both for but and for bstate
45 kind
: Byte; // motion, press, release
47 dx
, dy
: Integer; // for wheel this is wheel motion, otherwise this is relative mouse motion
48 but
: Word; // current pressed/released button, or 0 for motion
49 bstate
: Word; // button state
50 kstate
: Word; // keyboard state (see THKeyEvent);
67 scan
: Word; // SDL_SCANCODE_XXX
68 sym
: Word; // SDLK_XXX
69 bstate
: Word; // button state
70 kstate
: Word; // keyboard state
74 procedure g_Holmes_VidModeChanged ();
75 procedure g_Holmes_WindowFocused ();
76 procedure g_Holmes_WindowBlured ();
78 procedure g_Holmes_Draw ();
79 procedure g_Holmes_DrawUI ();
81 function g_Holmes_MouseEvent (var ev
: THMouseEvent
): Boolean; // returns `true` if event was eaten
82 function g_Holmes_KeyEvent (var ev
: THKeyEvent
): Boolean; // returns `true` if event was eaten
85 procedure g_Holmes_plrView (viewPortX
, viewPortY
, viewPortW
, viewPortH
: Integer);
86 procedure g_Holmes_plrLaser (ax0
, ay0
, ax1
, ay1
: Integer);
90 g_holmes_enabled
: Boolean = {$IF DEFINED(D2F_DEBUG)}true{$ELSE}false{$ENDIF};
101 //globalInited: Boolean = false;
104 msB
: Word = 0; // button state
105 kbS
: Word = 0; // keyboard modifiers state
106 showGrid
: Boolean = true;
107 showMonsInfo
: Boolean = false;
108 showMonsLOS2Plr
: Boolean = false;
109 showAllMonsCells
: Boolean = false;
110 showMapCurPos
: Boolean = false;
113 // ////////////////////////////////////////////////////////////////////////// //
114 {$INCLUDE g_holmes.inc}
115 {$INCLUDE g_holmes_ui.inc}
118 // ////////////////////////////////////////////////////////////////////////// //
120 g_ol_nice
: Boolean = false;
121 g_ol_rlayer_back
: Boolean = false;
122 g_ol_rlayer_step
: Boolean = false;
123 g_ol_rlayer_wall
: Boolean = false;
124 g_ol_rlayer_door
: Boolean = false;
125 g_ol_rlayer_acid1
: Boolean = false;
126 g_ol_rlayer_acid2
: Boolean = false;
127 g_ol_rlayer_water
: Boolean = false;
128 g_ol_rlayer_fore
: Boolean = false;
131 // ////////////////////////////////////////////////////////////////////////// //
133 winOptions
: THTopWindow
= nil;
134 winLayers
: THTopWindow
= nil;
135 winOutlines
: THTopWindow
= nil;
138 procedure createOptionsWindow ();
142 llb
:= THCtlCBListBox
.Create(0, 0);
143 llb
.appendItem('map grid', @showGrid
);
144 llb
.appendItem('cursor position on map', @showMapCurPos
);
145 llb
.appendItem('monster info', @showMonsInfo
);
146 llb
.appendItem('monster LOS to player', @showMonsLOS2Plr
);
147 llb
.appendItem('monster cells (SLOW!)', @showAllMonsCells
);
148 winOptions
:= THTopWindow
.Create('Holmes Options', 100, 100);
149 winOptions
.escClose
:= true;
150 winOptions
.appendChild(llb
);
154 procedure createLayersWindow ();
158 llb
:= THCtlCBListBox
.Create(0, 0);
159 llb
.appendItem('background', @g_rlayer_back
);
160 llb
.appendItem('steps', @g_rlayer_step
);
161 llb
.appendItem('walls', @g_rlayer_wall
);
162 llb
.appendItem('doors', @g_rlayer_door
);
163 llb
.appendItem('acid1', @g_rlayer_acid1
);
164 llb
.appendItem('acid2', @g_rlayer_acid2
);
165 llb
.appendItem('water', @g_rlayer_water
);
166 llb
.appendItem('foreground', @g_rlayer_fore
);
167 winLayers
:= THTopWindow
.Create('visible', 10, 10);
168 winLayers
.escClose
:= true;
169 winLayers
.appendChild(llb
);
173 procedure createOutlinesWindow ();
177 llb
:= THCtlCBListBox
.Create(0, 0);
178 llb
.appendItem('background', @g_ol_rlayer_back
);
179 llb
.appendItem('steps', @g_ol_rlayer_step
);
180 llb
.appendItem('walls', @g_ol_rlayer_wall
);
181 llb
.appendItem('doors', @g_ol_rlayer_door
);
182 llb
.appendItem('acid1', @g_ol_rlayer_acid1
);
183 llb
.appendItem('acid2', @g_ol_rlayer_acid2
);
184 llb
.appendItem('water', @g_ol_rlayer_water
);
185 llb
.appendItem('foreground', @g_ol_rlayer_fore
);
186 llb
.appendItem('', nil);
187 llb
.appendItem('slow''n''nice', @g_ol_nice
);
188 winOutlines
:= THTopWindow
.Create('outlines', 100, 10);
189 winOutlines
.escClose
:= true;
190 winOutlines
.appendChild(llb
);
194 // ////////////////////////////////////////////////////////////////////////// //
195 procedure g_Holmes_VidModeChanged ();
197 e_WriteLog(Format('Inspector: videomode changed: %dx%d', [gScreenWidth
, gScreenHeight
]), MSG_NOTIFY
);
198 // texture space is possibly lost here, idc
204 //createCursorTexture();
207 procedure g_Holmes_WindowFocused ();
213 procedure g_Holmes_WindowBlured ();
218 // ////////////////////////////////////////////////////////////////////////// //
220 vpSet
: Boolean = false;
223 laserSet
: Boolean = false;
224 laserX0
, laserY0
, laserX1
, laserY1
: Integer;
225 monMarkedUID
: Integer = -1;
228 procedure g_Holmes_plrView (viewPortX
, viewPortY
, viewPortW
, viewPortH
: Integer);
237 procedure g_Holmes_plrLaser (ax0
, ay0
, ax1
, ay1
: Integer);
244 laserSet
:= laserSet
; // shut up, fpc!
248 function pmsCurMapX (): Integer; inline; begin result
:= msX
+vpx
; end;
249 function pmsCurMapY (): Integer; inline; begin result
:= msY
+vpy
; end;
252 procedure plrDebugMouse (var ev
: THMouseEvent
);
254 function wallToggle (pan
: TPanel
; tag
: Integer): Boolean;
256 result
:= false; // don't stop
257 e_WriteLog(Format('wall #%d(%d); enabled=%d (%d); (%d,%d)-(%d,%d)', [pan
.arrIdx
, pan
.proxyId
, Integer(pan
.Enabled
), Integer(mapGrid
.proxyEnabled
[pan
.proxyId
]), pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
]), MSG_NOTIFY
);
258 if ((kbS
and THKeyEvent
.ModAlt
) <> 0) then
260 if pan
.Enabled
then g_Map_DisableWall(pan
.arrIdx
) else g_Map_EnableWall(pan
.arrIdx
);
264 function monsAtDump (mon
: TMonster
; tag
: Integer): Boolean;
266 result
:= false; // don't stop
267 e_WriteLog(Format('monster #%d; UID=%d', [mon
.arrIdx
, mon
.UID
]), MSG_NOTIFY
);
268 monMarkedUID
:= mon
.UID
;
269 //if pan.Enabled then g_Map_DisableWall(pan.arrIdx) else g_Map_EnableWall(pan.arrIdx);
272 function monsInCell (mon
: TMonster
; tag
: Integer): Boolean;
274 result
:= false; // don't stop
275 e_WriteLog(Format('monster #%d (UID:%u) (proxyid:%d)', [mon
.arrIdx
, mon
.UID
, mon
.proxyId
]), MSG_NOTIFY
);
279 //e_WriteLog(Format('mouse: x=%d; y=%d; but=%d; bstate=%d', [msx, msy, but, bstate]), MSG_NOTIFY);
280 if (gPlayer1
= nil) or not vpSet
then exit
;
281 if (ev
.kind
<> THMouseEvent
.Press
) then exit
;
283 e_WriteLog(Format('mev: %d', [Integer(ev
.kind
)]), MSG_NOTIFY
);
285 if (ev
.but
= THMouseEvent
.Left
) then
287 if ((kbS
and THKeyEvent
.ModShift
) <> 0) then
289 // dump monsters in cell
290 e_WriteLog('===========================', MSG_NOTIFY
);
291 monsGrid
.forEachInCell(pmsCurMapX
, pmsCurMapY
, monsInCell
);
292 e_WriteLog('---------------------------', MSG_NOTIFY
);
297 e_WriteLog('=== TOGGLE WALL ===', MSG_NOTIFY
);
298 mapGrid
.forEachAtPoint(pmsCurMapX
, pmsCurMapY
, wallToggle
, (GridTagWall
or GridTagDoor
));
299 e_WriteLog('--- toggle wall ---', MSG_NOTIFY
);
304 if (ev
.but
= THMouseEvent
.Right
) then
307 e_WriteLog('===========================', MSG_NOTIFY
);
308 monsGrid
.forEachAtPoint(pmsCurMapX
, pmsCurMapY
, monsAtDump
);
309 e_WriteLog('---------------------------', MSG_NOTIFY
);
316 edgeBmp
: array of Byte = nil;
319 procedure drawOutlines ();
320 procedure clearEdgeBmp ();
322 SetLength(edgeBmp
, (gWinSizeX
+4)*(gWinSizeY
+4));
323 FillChar(edgeBmp
[0], Length(edgeBmp
)*sizeof(edgeBmp
[0]), 0);
326 procedure drawPanel (pan
: TPanel
);
328 sx
, len
, y0
, y1
: Integer;
330 if (pan
= nil) or (pan
.Width
< 1) or (pan
.Height
< 1) then exit
;
331 if (pan
.X
+pan
.Width
<= vpx
-1) or (pan
.Y
+pan
.Height
<= vpy
-1) or (pan
.X
>= vpx
+vpw
+1) or (pan
.Y
>= vpy
+vph
+1) then exit
;
336 if (len
> vpw
+2) then len
:= vpw
+2;
337 if (sx
< 0) then begin len
+= sx
; sx
:= 0; end;
338 if (sx
+len
> vpw
+2) then len
:= vpw
+2-sx
;
339 if (len
< 1) then exit
;
341 assert(sx
+len
<= vpw
+2);
344 if (y0
< 0) then y0
:= 0;
345 if (y1
> vph
+2) then y1
:= vph
+2;
348 FillChar(edgeBmp
[y0
*(gWinSizeX
+4)+sx
], len
*sizeof(edgeBmp
[0]), 1);
354 drawRect(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, 255, 255, 255);
358 procedure drawEdges ();
364 glDisable(GL_TEXTURE_2D
);
367 glDisable(GL_LINE_SMOOTH
);
368 glDisable(GL_POLYGON_SMOOTH
);
369 glColor4f(1.0, 1.0, 1.0, 1.0);
373 a
:= @edgeBmp
[y
*(gWinSizeX
+4)+1];
378 if (a
[-1] = 0) or (a
[1] = 0) or (a
[-(gWinSizeX
+4)] = 0) or (a
[gWinSizeX
+4] = 0) or
379 (a
[-(gWinSizeX
+4)-1] = 0) or (a
[-(gWinSizeX
+4)+1] = 0) or
380 (a
[gWinSizeX
+4-1] = 0) or (a
[gWinSizeX
+4+1] = 0) then
382 glVertex2i(x
-1+vpx
, y
-1+vpy
);
391 procedure doWalls (parr
: array of TPanel
; ptype
: Word);
396 if g_ol_nice
then clearEdgeBmp();
397 for f
:= 0 to High(parr
) do
400 if (pan
= nil) or not pan
.Enabled
or (pan
.Width
< 1) or (pan
.Height
< 1) then continue
;
401 if ((pan
.PanelType
and ptype
) = 0) then continue
;
404 if g_ol_nice
then drawEdges();
408 //function forEachInAABB (x, y, w, h: Integer; cb: TGridQueryCB; tagmask: Integer=-1; allowDisabled: Boolean=false): ITP;
409 if g_ol_rlayer_back
then doWalls(gRenderBackgrounds
, PANEL_BACK
);
410 if g_ol_rlayer_step
then doWalls(gSteps
, PANEL_STEP
);
411 if g_ol_rlayer_wall
then doWalls(gWalls
, PANEL_WALL
);
412 if g_ol_rlayer_door
then doWalls(gWalls
, PANEL_OPENDOOR
or PANEL_CLOSEDOOR
);
413 if g_ol_rlayer_acid1
then doWalls(gAcid1
, PANEL_ACID1
);
414 if g_ol_rlayer_acid2
then doWalls(gAcid2
, PANEL_ACID2
);
415 if g_ol_rlayer_water
then doWalls(gWater
, PANEL_WATER
);
416 if g_ol_rlayer_fore
then doWalls(gRenderForegrounds
, PANEL_FORE
);
420 procedure plrDebugDraw ();
422 procedure drawTileGrid ();
426 for y
:= 0 to (mapGrid
.gridHeight
div mapGrid
.tileSize
) do
428 drawLine(mapGrid
.gridX0
, mapGrid
.gridY0
+y
*mapGrid
.tileSize
, mapGrid
.gridX0
+mapGrid
.gridWidth
, mapGrid
.gridY0
+y
*mapGrid
.tileSize
, 96, 96, 96, 255);
431 for x
:= 0 to (mapGrid
.gridWidth
div mapGrid
.tileSize
) do
433 drawLine(mapGrid
.gridX0
+x
*mapGrid
.tileSize
, mapGrid
.gridY0
, mapGrid
.gridX0
+x
*mapGrid
.tileSize
, mapGrid
.gridY0
+y
*mapGrid
.gridHeight
, 96, 96, 96, 255);
437 procedure hilightCell (cx
, cy
: Integer);
439 fillRect(cx
, cy
, monsGrid
.tileSize
, monsGrid
.tileSize
, 0, 128, 0, 64);
442 procedure hilightCell1 (cx
, cy
: Integer);
444 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
445 fillRect(cx
, cy
, monsGrid
.tileSize
, monsGrid
.tileSize
, 255, 255, 0, 92);
448 function hilightWallTrc (pan
: TPanel
; tag
: Integer; x
, y
, prevx
, prevy
: Integer): Boolean;
450 result
:= false; // don't stop
451 if (pan
= nil) then exit
; // cell completion, ignore
452 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
453 fillRect(pan
.X
, pan
.Y
, pan
.Width
, pan
.Height
, 0, 128, 128, 64);
456 function monsCollector (mon
: TMonster
; tag
: Integer): Boolean;
459 mx
, my
, mw
, mh
: Integer;
462 mon
.getMapBox(mx
, my
, mw
, mh
);
463 e_DrawQuad(mx
, my
, mx
+mw
-1, my
+mh
-1, 255, 255, 0, 96);
464 if lineAABBIntersects(laserX0
, laserY0
, laserX1
, laserY1
, mx
, my
, mw
, mh
, ex
, ey
) then
466 e_DrawPoint(8, ex
, ey
, 0, 255, 0);
470 procedure drawMonsterInfo (mon
: TMonster
);
472 mx
, my
, mw
, mh
: Integer;
474 procedure drawMonsterTargetLine ();
476 emx
, emy
, emw
, emh
: Integer;
481 if (g_GetUIDType(mon
.MonsterTargetUID
) = UID_PLAYER
) then
483 eplr
:= g_Player_Get(mon
.MonsterTargetUID
);
484 if (eplr
<> nil) then eplr
.getMapBox(emx
, emy
, emw
, emh
) else exit
;
486 else if (g_GetUIDType(mon
.MonsterTargetUID
) = UID_MONSTER
) then
488 enemy
:= g_Monsters_ByUID(mon
.MonsterTargetUID
);
489 if (enemy
<> nil) then enemy
.getMapBox(emx
, emy
, emw
, emh
) else exit
;
495 mon
.getMapBox(mx
, my
, mw
, mh
);
496 drawLine(mx
+mw
div 2, my
+mh
div 2, emx
+emw
div 2, emy
+emh
div 2, 255, 0, 0, 255);
497 if (g_Map_traceToNearestWall(mx
+mw
div 2, my
+mh
div 2, emx
+emw
div 2, emy
+emh
div 2, @ex
, @ey
) <> nil) then
499 drawLine(mx
+mw
div 2, my
+mh
div 2, ex
, ey
, 0, 255, 0, 255);
503 procedure drawLOS2Plr ();
505 emx
, emy
, emw
, emh
: Integer;
510 if (eplr
= nil) then exit
;
511 eplr
.getMapBox(emx
, emy
, emw
, emh
);
512 mon
.getMapBox(mx
, my
, mw
, mh
);
513 drawLine(mx
+mw
div 2, my
+mh
div 2, emx
+emw
div 2, emy
+emh
div 2, 255, 0, 0, 255);
514 {$IF DEFINED(D2F_DEBUG)}
515 //mapGrid.dbgRayTraceTileHitCB := hilightCell1;
517 if (g_Map_traceToNearestWall(mx
+mw
div 2, my
+mh
div 2, emx
+emw
div 2, emy
+emh
div 2, @ex
, @ey
) <> nil) then
518 //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
520 drawLine(mx
+mw
div 2, my
+mh
div 2, ex
, ey
, 0, 255, 0, 255);
522 {$IF DEFINED(D2F_DEBUG)}
523 //mapGrid.dbgRayTraceTileHitCB := nil;
528 if (mon
= nil) then exit
;
529 mon
.getMapBox(mx
, my
, mw
, mh
);
532 monsGrid
.forEachBodyCell(mon
.proxyId
, hilightCell
);
536 //fillRect(mx-4, my-7*8-6, 110, 7*8+6, 0, 0, 94, 250);
537 darkenRect(mx
-4, my
-7*8-6, 110, 7*8+6, 128);
542 drawText6(mx
, my
, Format('%s(U:%u)', [monsTypeToString(mon
.MonsterType
), mon
.UID
]), 255, 127, 0); my
-= 8;
544 drawText6(mx
, my
, Format('Beh: %s', [monsBehToString(mon
.MonsterBehaviour
)]), 255, 127, 0); my
-= 8;
546 drawText6(mx
, my
, Format('State:%s (%d)', [monsStateToString(mon
.MonsterState
), mon
.MonsterSleep
]), 255, 127, 0); my
-= 8;
548 drawText6(mx
, my
, Format('Health:%d', [mon
.MonsterHealth
]), 255, 127, 0); my
-= 8;
550 drawText6(mx
, my
, Format('Ammo:%d', [mon
.MonsterAmmo
]), 255, 127, 0); my
-= 8;
552 drawText6(mx
, my
, Format('TgtUID:%u', [mon
.MonsterTargetUID
]), 255, 127, 0); my
-= 8;
553 drawText6(mx
, my
, Format('TgtTime:%d', [mon
.MonsterTargetTime
]), 255, 127, 0); my
-= 8;
556 drawMonsterTargetLine();
557 if showMonsLOS2Plr
then drawLOS2Plr();
559 property MonsterRemoved: Boolean read FRemoved write FRemoved;
560 property MonsterPain: Integer read FPain write FPain;
561 property MonsterAnim: Byte read FCurAnim write FCurAnim;
565 function highlightAllMonsterCells (mon
: TMonster
): Boolean;
567 result
:= false; // don't stop
568 monsGrid
.forEachBodyCell(mon
.proxyId
, hilightCell
);
573 mx
, my
, mw
, mh
: Integer;
575 if (gPlayer1
= nil) then exit
;
577 glEnable(GL_SCISSOR_TEST
);
578 glScissor(0, gWinSizeY
-gPlayerScreenSize
.Y
-1, vpw
, vph
);
581 glTranslatef(-vpx
, -vpy
, 0);
583 if (showGrid
) then drawTileGrid();
586 if (laserSet
) then g_Mons_AlongLine(laserX0
, laserY0
, laserX1
, laserY1
, monsCollector
, true);
588 if (monMarkedUID
<> -1) then
590 mon
:= g_Monsters_ByUID(monMarkedUID
);
593 mon
.getMapBox(mx
, my
, mw
, mh
);
594 e_DrawQuad(mx
, my
, mx
+mw
-1, my
+mh
-1, 255, 0, 0, 30);
595 drawMonsterInfo(mon
);
599 if showAllMonsCells
then g_Mons_ForEach(highlightAllMonsterCells
);
603 glDisable(GL_SCISSOR_TEST
);
605 if showMapCurPos
then drawText8(4, gWinSizeY
-10, Format('mappos:(%d,%d)', [pmsCurMapX
, pmsCurMapY
]), 255, 255, 0);
609 // ////////////////////////////////////////////////////////////////////////// //
610 function g_Holmes_MouseEvent (var ev
: THMouseEvent
): Boolean;
618 if not uiMouseEvent(ev
) then plrDebugMouse(ev
);
622 function g_Holmes_KeyEvent (var ev
: THKeyEvent
): Boolean;
630 procedure dummyWallTrc (cx
, cy
: Integer);
639 SDL_SCANCODE_LCTRL
, SDL_SCANCODE_RCTRL
,
640 SDL_SCANCODE_LALT
, SDL_SCANCODE_RALT
,
641 SDL_SCANCODE_LSHIFT
, SDL_SCANCODE_RSHIFT
:
644 if uiKeyEvent(ev
) then begin result
:= true; exit
; end;
646 if (ev
.kind
= THKeyEvent
.Press
) then
648 // M-M: one monster think step
649 if (ev
.scan
= SDL_SCANCODE_M
) and ((ev
.kstate
and THKeyEvent
.ModAlt
) <> 0) then
652 gmon_debug_think
:= false;
653 gmon_debug_one_think_step
:= true; // do one step
656 // M-I: toggle monster info
657 if (ev
.scan
= SDL_SCANCODE_I
) and ((ev
.kstate
and THKeyEvent
.ModAlt
) <> 0) then
660 showMonsInfo
:= not showMonsInfo
;
663 // M-L: toggle monster LOS to player
664 if (ev
.scan
= SDL_SCANCODE_L
) and ((ev
.kstate
and THKeyEvent
.ModAlt
) <> 0) then
667 showMonsLOS2Plr
:= not showMonsLOS2Plr
;
670 // M-G: toggle "show all cells occupied by monsters"
671 if (ev
.scan
= SDL_SCANCODE_G
) and ((ev
.kstate
and THKeyEvent
.ModAlt
) <> 0) then
674 showAllMonsCells
:= not showAllMonsCells
;
677 // M-A: wake up monster
678 if (ev
.scan
= SDL_SCANCODE_A
) and ((ev
.kstate
and THKeyEvent
.ModAlt
) <> 0) then
681 if (monMarkedUID
<> -1) then
683 mon
:= g_Monsters_ByUID(monMarkedUID
);
684 if (mon
<> nil) then mon
.WakeUp();
688 // C-T: teleport player
689 if (ev
.scan
= SDL_SCANCODE_T
) and ((ev
.kstate
and THKeyEvent
.ModCtrl
) <> 0) then
692 //e_WriteLog(Format('TELEPORT: (%d,%d)', [pmsCurMapX, pmsCurMapY]), MSG_NOTIFY);
693 if (gPlayers
[0] <> nil) then
695 gPlayers
[0].getMapBox(x
, y
, w
, h
);
696 gPlayers
[0].TeleportTo(pmsCurMapX
-w
div 2, pmsCurMapY
-h
div 2, true, 69); // 69: don't change dir
700 // C-P: show cursor position on the map
701 if (ev
.scan
= SDL_SCANCODE_P
) and ((ev
.kstate
and THKeyEvent
.ModCtrl
) <> 0) then
704 showMapCurPos
:= not showMapCurPos
;
708 if (ev
.scan
= SDL_SCANCODE_G
) and ((ev
.kstate
and THKeyEvent
.ModCtrl
) <> 0) then
711 showGrid
:= not showGrid
;
714 // C-L: toggle layers window
715 if (ev
.scan
= SDL_SCANCODE_L
) and ((ev
.kstate
and THKeyEvent
.ModCtrl
) <> 0) then
718 if (winLayers
= nil) then createLayersWindow();
719 if not uiVisibleWindow(winLayers
) then uiAddWindow(winLayers
) else uiRemoveWindow(winLayers
);
722 // C-O: toggle outlines window
723 if (ev
.scan
= SDL_SCANCODE_O
) and ((ev
.kstate
and THKeyEvent
.ModCtrl
) <> 0) then
726 if (winOutlines
= nil) then createOutlinesWindow();
727 if not uiVisibleWindow(winOutlines
) then uiAddWindow(winOutlines
) else uiRemoveWindow(winOutlines
);
730 // F1: toggle options window
731 if (ev
.scan
= SDL_SCANCODE_F1
) and (ev
.kstate
= 0) then
734 if (winOptions
= nil) then createOptionsWindow();
735 if not uiVisibleWindow(winOptions
) then uiAddWindow(winOptions
) else uiRemoveWindow(winOptions
);
738 // C-UP, C-DOWN, C-LEFT, C-RIGHT: trace 10 pixels from cursor in the respective direction
739 if ((ev
.scan
= SDL_SCANCODE_UP
) or (ev
.scan
= SDL_SCANCODE_DOWN
) or (ev
.scan
= SDL_SCANCODE_LEFT
) or (ev
.scan
= SDL_SCANCODE_RIGHT
)) and
740 ((ev
.kstate
and THKeyEvent
.ModCtrl
) <> 0) then
746 SDL_SCANCODE_UP
: dy
-= 120;
747 SDL_SCANCODE_DOWN
: dy
+= 120;
748 SDL_SCANCODE_LEFT
: dx
-= 120;
749 SDL_SCANCODE_RIGHT
: dx
+= 120;
751 {$IF DEFINED(D2F_DEBUG)}
752 //mapGrid.dbgRayTraceTileHitCB := dummyWallTrc;
753 mapGrid
.dbgShowTraceLog
:= true;
755 pan
:= g_Map_traceToNearest(pmsCurMapX
, pmsCurMapY
, dx
, dy
, (GridTagWall
or GridTagDoor
or GridTagStep
or GridTagAcid1
or GridTagAcid2
or GridTagWater
), @ex
, @ey
);
756 {$IF DEFINED(D2F_DEBUG)}
757 //mapGrid.dbgRayTraceTileHitCB := nil;
758 mapGrid
.dbgShowTraceLog
:= false;
760 e_LogWritefln('v-trace: (%d,%d)-(%d,%d); end=(%d,%d); hit=%d', [pmsCurMapX
, pmsCurMapY
, dx
, dy
, ex
, ey
, (pan
<> nil)]);
767 // ////////////////////////////////////////////////////////////////////////// //
768 procedure g_Holmes_Draw ();
770 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
771 glDisable(GL_STENCIL_TEST
);
773 glDisable(GL_SCISSOR_TEST
);
774 glDisable(GL_TEXTURE_2D
);
785 procedure g_Holmes_DrawUI ();