DEADSOFTWARE

Holmes should eat player keys now
[d2df-sdl.git] / src / game / g_holmes.pas
1 (* Copyright (C) DooM 2D:Forever Developers
2 *
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.
7 *
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.
12 *
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/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
17 unit g_holmes;
19 interface
21 uses
22 e_log,
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,
25 xprofiler;
28 type
29 THMouseEvent = record
30 public
31 const
32 // both for but and for bstate
33 Left = $0001;
34 Right = $0002;
35 Middle = $0004;
36 WheelUp = $0008;
37 WheelDown = $0010;
39 // event types
40 Release = 0;
41 Press = 1;
42 Motion = 2;
44 public
45 kind: Byte; // motion, press, release
46 x, y: Integer;
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);
51 end;
53 THKeyEvent = record
54 public
55 const
56 // modifiers
57 ModCtrl = $0001;
58 ModAlt = $0002;
59 ModShift = $0004;
61 // event types
62 Release = 0;
63 Press = 1;
65 public
66 kind: Byte;
67 scan: Word; // SDL_SCANCODE_XXX
68 sym: Word; // SDLK_XXX
69 bstate: Word; // button state
70 kstate: Word; // keyboard state
71 end;
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
84 // hooks for player
85 procedure g_Holmes_plrView (viewPortX, viewPortY, viewPortW, viewPortH: Integer);
86 procedure g_Holmes_plrLaser (ax0, ay0, ax1, ay1: Integer);
89 var
90 g_holmes_enabled: Boolean = {$IF DEFINED(D2F_DEBUG)}true{$ELSE}false{$ENDIF};
93 implementation
95 uses
96 SysUtils, GL, SDL2,
97 MAPDEF, g_options;
100 var
101 //globalInited: Boolean = false;
102 msX: Integer = -666;
103 msY: Integer = -666;
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 // ////////////////////////////////////////////////////////////////////////// //
119 var
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 // ////////////////////////////////////////////////////////////////////////// //
132 var
133 winOptions: THTopWindow = nil;
134 winLayers: THTopWindow = nil;
135 winOutlines: THTopWindow = nil;
138 procedure createOptionsWindow ();
139 var
140 llb: THCtlCBListBox;
141 begin
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);
151 end;
154 procedure createLayersWindow ();
155 var
156 llb: THCtlCBListBox;
157 begin
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);
170 end;
173 procedure createOutlinesWindow ();
174 var
175 llb: THCtlCBListBox;
176 begin
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);
191 end;
194 // ////////////////////////////////////////////////////////////////////////// //
195 procedure g_Holmes_VidModeChanged ();
196 begin
197 e_WriteLog(Format('Inspector: videomode changed: %dx%d', [gScreenWidth, gScreenHeight]), MSG_NOTIFY);
198 // texture space is possibly lost here, idc
199 curtexid := 0;
200 font6texid := 0;
201 font8texid := 0;
202 prfont6texid := 0;
203 prfont8texid := 0;
204 //createCursorTexture();
205 end;
207 procedure g_Holmes_WindowFocused ();
208 begin
209 msB := 0;
210 kbS := 0;
211 end;
213 procedure g_Holmes_WindowBlured ();
214 begin
215 end;
218 // ////////////////////////////////////////////////////////////////////////// //
219 var
220 vpSet: Boolean = false;
221 vpx, vpy: Integer;
222 vpw, vph: Integer;
223 laserSet: Boolean = false;
224 laserX0, laserY0, laserX1, laserY1: Integer;
225 monMarkedUID: Integer = -1;
228 procedure g_Holmes_plrView (viewPortX, viewPortY, viewPortW, viewPortH: Integer);
229 begin
230 vpSet := true;
231 vpx := viewPortX;
232 vpy := viewPortY;
233 vpw := viewPortW;
234 vph := viewPortH;
235 end;
237 procedure g_Holmes_plrLaser (ax0, ay0, ax1, ay1: Integer);
238 begin
239 laserSet := true;
240 laserX0 := ax0;
241 laserY0 := ay0;
242 laserX1 := ax1;
243 laserY1 := ay1;
244 laserSet := laserSet; // shut up, fpc!
245 end;
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;
255 begin
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
259 begin
260 if pan.Enabled then g_Map_DisableWall(pan.arrIdx) else g_Map_EnableWall(pan.arrIdx);
261 end;
262 end;
264 function monsAtDump (mon: TMonster; tag: Integer): Boolean;
265 begin
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);
270 end;
272 function monsInCell (mon: TMonster; tag: Integer): Boolean;
273 begin
274 result := false; // don't stop
275 e_WriteLog(Format('monster #%d (UID:%u) (proxyid:%d)', [mon.arrIdx, mon.UID, mon.proxyId]), MSG_NOTIFY);
276 end;
278 begin
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
286 begin
287 if ((kbS and THKeyEvent.ModShift) <> 0) then
288 begin
289 // dump monsters in cell
290 e_WriteLog('===========================', MSG_NOTIFY);
291 monsGrid.forEachInCell(pmsCurMapX, pmsCurMapY, monsInCell);
292 e_WriteLog('---------------------------', MSG_NOTIFY);
293 end
294 else
295 begin
296 // toggle wall
297 e_WriteLog('=== TOGGLE WALL ===', MSG_NOTIFY);
298 mapGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY, wallToggle, (GridTagWall or GridTagDoor));
299 e_WriteLog('--- toggle wall ---', MSG_NOTIFY);
300 end;
301 exit;
302 end;
304 if (ev.but = THMouseEvent.Right) then
305 begin
306 monMarkedUID := -1;
307 e_WriteLog('===========================', MSG_NOTIFY);
308 monsGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY, monsAtDump);
309 e_WriteLog('---------------------------', MSG_NOTIFY);
310 exit;
311 end;
312 end;
315 var
316 olEdgeL: array of Boolean = nil;
317 olEdgeR: array of Boolean = nil;
318 olEdgeU: array of Boolean = nil;
319 olEdgeD: array of Boolean = nil;
321 procedure drawOutlines ();
322 begin
323 end;
326 procedure plrDebugDraw ();
328 procedure drawTileGrid ();
329 var
330 x, y: Integer;
331 begin
332 for y := 0 to (mapGrid.gridHeight div mapGrid.tileSize) do
333 begin
334 drawLine(mapGrid.gridX0, mapGrid.gridY0+y*mapGrid.tileSize, mapGrid.gridX0+mapGrid.gridWidth, mapGrid.gridY0+y*mapGrid.tileSize, 96, 96, 96, 255);
335 end;
337 for x := 0 to (mapGrid.gridWidth div mapGrid.tileSize) do
338 begin
339 drawLine(mapGrid.gridX0+x*mapGrid.tileSize, mapGrid.gridY0, mapGrid.gridX0+x*mapGrid.tileSize, mapGrid.gridY0+y*mapGrid.gridHeight, 96, 96, 96, 255);
340 end;
341 end;
343 procedure hilightCell (cx, cy: Integer);
344 begin
345 fillRect(cx, cy, monsGrid.tileSize, monsGrid.tileSize, 0, 128, 0, 64);
346 end;
348 procedure hilightCell1 (cx, cy: Integer);
349 begin
350 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
351 fillRect(cx, cy, monsGrid.tileSize, monsGrid.tileSize, 255, 255, 0, 92);
352 end;
354 function hilightWallTrc (pan: TPanel; tag: Integer; x, y, prevx, prevy: Integer): Boolean;
355 begin
356 result := false; // don't stop
357 if (pan = nil) then exit; // cell completion, ignore
358 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
359 fillRect(pan.X, pan.Y, pan.Width, pan.Height, 0, 128, 128, 64);
360 end;
362 function monsCollector (mon: TMonster; tag: Integer): Boolean;
363 var
364 ex, ey: Integer;
365 mx, my, mw, mh: Integer;
366 begin
367 result := false;
368 mon.getMapBox(mx, my, mw, mh);
369 e_DrawQuad(mx, my, mx+mw-1, my+mh-1, 255, 255, 0, 96);
370 if lineAABBIntersects(laserX0, laserY0, laserX1, laserY1, mx, my, mw, mh, ex, ey) then
371 begin
372 e_DrawPoint(8, ex, ey, 0, 255, 0);
373 end;
374 end;
376 procedure drawMonsterInfo (mon: TMonster);
377 var
378 mx, my, mw, mh: Integer;
380 procedure drawMonsterTargetLine ();
381 var
382 emx, emy, emw, emh: Integer;
383 enemy: TMonster;
384 eplr: TPlayer;
385 ex, ey: Integer;
386 begin
387 if (g_GetUIDType(mon.MonsterTargetUID) = UID_PLAYER) then
388 begin
389 eplr := g_Player_Get(mon.MonsterTargetUID);
390 if (eplr <> nil) then eplr.getMapBox(emx, emy, emw, emh) else exit;
391 end
392 else if (g_GetUIDType(mon.MonsterTargetUID) = UID_MONSTER) then
393 begin
394 enemy := g_Monsters_ByUID(mon.MonsterTargetUID);
395 if (enemy <> nil) then enemy.getMapBox(emx, emy, emw, emh) else exit;
396 end
397 else
398 begin
399 exit;
400 end;
401 mon.getMapBox(mx, my, mw, mh);
402 drawLine(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, 255, 0, 0, 255);
403 if (g_Map_traceToNearestWall(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, @ex, @ey) <> nil) then
404 begin
405 drawLine(mx+mw div 2, my+mh div 2, ex, ey, 0, 255, 0, 255);
406 end;
407 end;
409 procedure drawLOS2Plr ();
410 var
411 emx, emy, emw, emh: Integer;
412 eplr: TPlayer;
413 ex, ey: Integer;
414 begin
415 eplr := gPlayers[0];
416 if (eplr = nil) then exit;
417 eplr.getMapBox(emx, emy, emw, emh);
418 mon.getMapBox(mx, my, mw, mh);
419 drawLine(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, 255, 0, 0, 255);
420 {$IF DEFINED(D2F_DEBUG)}
421 //mapGrid.dbgRayTraceTileHitCB := hilightCell1;
422 {$ENDIF}
423 if (g_Map_traceToNearestWall(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, @ex, @ey) <> nil) then
424 //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
425 begin
426 drawLine(mx+mw div 2, my+mh div 2, ex, ey, 0, 255, 0, 255);
427 end;
428 {$IF DEFINED(D2F_DEBUG)}
429 //mapGrid.dbgRayTraceTileHitCB := nil;
430 {$ENDIF}
431 end;
433 begin
434 if (mon = nil) then exit;
435 mon.getMapBox(mx, my, mw, mh);
436 //mx += mw div 2;
438 monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
440 if showMonsInfo then
441 begin
442 //fillRect(mx-4, my-7*8-6, 110, 7*8+6, 0, 0, 94, 250);
443 darkenRect(mx-4, my-7*8-6, 110, 7*8+6, 128);
444 my -= 8;
445 my -= 2;
447 // type
448 drawText6(mx, my, Format('%s(U:%u)', [monsTypeToString(mon.MonsterType), mon.UID]), 255, 127, 0); my -= 8;
449 // beh
450 drawText6(mx, my, Format('Beh: %s', [monsBehToString(mon.MonsterBehaviour)]), 255, 127, 0); my -= 8;
451 // state
452 drawText6(mx, my, Format('State:%s (%d)', [monsStateToString(mon.MonsterState), mon.MonsterSleep]), 255, 127, 0); my -= 8;
453 // health
454 drawText6(mx, my, Format('Health:%d', [mon.MonsterHealth]), 255, 127, 0); my -= 8;
455 // ammo
456 drawText6(mx, my, Format('Ammo:%d', [mon.MonsterAmmo]), 255, 127, 0); my -= 8;
457 // target
458 drawText6(mx, my, Format('TgtUID:%u', [mon.MonsterTargetUID]), 255, 127, 0); my -= 8;
459 drawText6(mx, my, Format('TgtTime:%d', [mon.MonsterTargetTime]), 255, 127, 0); my -= 8;
460 end;
462 drawMonsterTargetLine();
463 if showMonsLOS2Plr then drawLOS2Plr();
465 property MonsterRemoved: Boolean read FRemoved write FRemoved;
466 property MonsterPain: Integer read FPain write FPain;
467 property MonsterAnim: Byte read FCurAnim write FCurAnim;
469 end;
471 function highlightAllMonsterCells (mon: TMonster): Boolean;
472 begin
473 result := false; // don't stop
474 monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
475 end;
477 var
478 mon: TMonster;
479 mx, my, mw, mh: Integer;
480 begin
481 if (gPlayer1 = nil) then exit;
483 glEnable(GL_SCISSOR_TEST);
484 glScissor(0, gWinSizeY-gPlayerScreenSize.Y-1, vpw, vph);
486 glPushMatrix();
487 glTranslatef(-vpx, -vpy, 0);
489 drawOutlines();
491 if (showGrid) then drawTileGrid();
493 if (laserSet) then g_Mons_AlongLine(laserX0, laserY0, laserX1, laserY1, monsCollector, true);
495 if (monMarkedUID <> -1) then
496 begin
497 mon := g_Monsters_ByUID(monMarkedUID);
498 if (mon <> nil) then
499 begin
500 mon.getMapBox(mx, my, mw, mh);
501 e_DrawQuad(mx, my, mx+mw-1, my+mh-1, 255, 0, 0, 30);
502 drawMonsterInfo(mon);
503 end;
504 end;
506 if showAllMonsCells then g_Mons_ForEach(highlightAllMonsterCells);
508 glPopMatrix();
510 glDisable(GL_SCISSOR_TEST);
512 if showMapCurPos then drawText8(4, gWinSizeY-10, Format('mappos:(%d,%d)', [pmsCurMapX, pmsCurMapY]), 255, 255, 0);
513 end;
516 // ////////////////////////////////////////////////////////////////////////// //
517 function g_Holmes_MouseEvent (var ev: THMouseEvent): Boolean;
518 begin
519 result := true;
520 msX := ev.x;
521 msY := ev.y;
522 msB := ev.bstate;
523 kbS := ev.kstate;
524 msB := msB;
525 if not uiMouseEvent(ev) then plrDebugMouse(ev);
526 end;
529 function g_Holmes_KeyEvent (var ev: THKeyEvent): Boolean;
530 var
531 mon: TMonster;
532 pan: TPanel;
533 x, y, w, h: Integer;
534 ex, ey: Integer;
535 dx, dy: Integer;
537 procedure dummyWallTrc (cx, cy: Integer);
538 begin
539 end;
541 begin
542 result := false;
543 msB := ev.bstate;
544 kbS := ev.kstate;
545 case ev.scan of
546 SDL_SCANCODE_LCTRL, SDL_SCANCODE_RCTRL,
547 SDL_SCANCODE_LALT, SDL_SCANCODE_RALT,
548 SDL_SCANCODE_LSHIFT, SDL_SCANCODE_RSHIFT:
549 result := true;
550 end;
551 if uiKeyEvent(ev) then begin result := true; exit; end;
552 // press
553 if (ev.kind = THKeyEvent.Press) then
554 begin
555 // M-M: one monster think step
556 if (ev.scan = SDL_SCANCODE_M) and ((ev.kstate and THKeyEvent.ModAlt) <> 0) then
557 begin
558 result := true;
559 gmon_debug_think := false;
560 gmon_debug_one_think_step := true; // do one step
561 exit;
562 end;
563 // M-I: toggle monster info
564 if (ev.scan = SDL_SCANCODE_I) and ((ev.kstate and THKeyEvent.ModAlt) <> 0) then
565 begin
566 result := true;
567 showMonsInfo := not showMonsInfo;
568 exit;
569 end;
570 // M-L: toggle monster LOS to player
571 if (ev.scan = SDL_SCANCODE_L) and ((ev.kstate and THKeyEvent.ModAlt) <> 0) then
572 begin
573 result := true;
574 showMonsLOS2Plr := not showMonsLOS2Plr;
575 exit;
576 end;
577 // M-G: toggle "show all cells occupied by monsters"
578 if (ev.scan = SDL_SCANCODE_G) and ((ev.kstate and THKeyEvent.ModAlt) <> 0) then
579 begin
580 result := true;
581 showAllMonsCells := not showAllMonsCells;
582 exit;
583 end;
584 // M-A: wake up monster
585 if (ev.scan = SDL_SCANCODE_A) and ((ev.kstate and THKeyEvent.ModAlt) <> 0) then
586 begin
587 result := true;
588 if (monMarkedUID <> -1) then
589 begin
590 mon := g_Monsters_ByUID(monMarkedUID);
591 if (mon <> nil) then mon.WakeUp();
592 end;
593 exit;
594 end;
595 // C-T: teleport player
596 if (ev.scan = SDL_SCANCODE_T) and ((ev.kstate and THKeyEvent.ModCtrl) <> 0) then
597 begin
598 result := true;
599 //e_WriteLog(Format('TELEPORT: (%d,%d)', [pmsCurMapX, pmsCurMapY]), MSG_NOTIFY);
600 if (gPlayers[0] <> nil) then
601 begin
602 gPlayers[0].getMapBox(x, y, w, h);
603 gPlayers[0].TeleportTo(pmsCurMapX-w div 2, pmsCurMapY-h div 2, true, 69); // 69: don't change dir
604 end;
605 exit;
606 end;
607 // C-P: show cursor position on the map
608 if (ev.scan = SDL_SCANCODE_P) and ((ev.kstate and THKeyEvent.ModCtrl) <> 0) then
609 begin
610 result := true;
611 showMapCurPos := not showMapCurPos;
612 exit;
613 end;
614 // C-G: toggle grid
615 if (ev.scan = SDL_SCANCODE_G) and ((ev.kstate and THKeyEvent.ModCtrl) <> 0) then
616 begin
617 result := true;
618 showGrid := not showGrid;
619 exit;
620 end;
621 // C-L: toggle layers window
622 if (ev.scan = SDL_SCANCODE_L) and ((ev.kstate and THKeyEvent.ModCtrl) <> 0) then
623 begin
624 result := true;
625 if (winLayers = nil) then createLayersWindow();
626 if not uiVisibleWindow(winLayers) then uiAddWindow(winLayers) else uiRemoveWindow(winLayers);
627 exit;
628 end;
629 // C-O: toggle outlines window
630 if (ev.scan = SDL_SCANCODE_O) and ((ev.kstate and THKeyEvent.ModCtrl) <> 0) then
631 begin
632 result := true;
633 if (winOutlines = nil) then createOutlinesWindow();
634 if not uiVisibleWindow(winOutlines) then uiAddWindow(winOutlines) else uiRemoveWindow(winOutlines);
635 exit;
636 end;
637 // F1: toggle options window
638 if (ev.scan = SDL_SCANCODE_F1) and (ev.kstate = 0) then
639 begin
640 result := true;
641 if (winOptions = nil) then createOptionsWindow();
642 if not uiVisibleWindow(winOptions) then uiAddWindow(winOptions) else uiRemoveWindow(winOptions);
643 exit;
644 end;
645 // C-UP, C-DOWN, C-LEFT, C-RIGHT: trace 10 pixels from cursor in the respective direction
646 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
647 ((ev.kstate and THKeyEvent.ModCtrl) <> 0) then
648 begin
649 result := true;
650 dx := pmsCurMapX;
651 dy := pmsCurMapY;
652 case ev.scan of
653 SDL_SCANCODE_UP: dy -= 120;
654 SDL_SCANCODE_DOWN: dy += 120;
655 SDL_SCANCODE_LEFT: dx -= 120;
656 SDL_SCANCODE_RIGHT: dx += 120;
657 end;
658 {$IF DEFINED(D2F_DEBUG)}
659 //mapGrid.dbgRayTraceTileHitCB := dummyWallTrc;
660 mapGrid.dbgShowTraceLog := true;
661 {$ENDIF}
662 pan := g_Map_traceToNearest(pmsCurMapX, pmsCurMapY, dx, dy, (GridTagWall or GridTagDoor or GridTagStep or GridTagAcid1 or GridTagAcid2 or GridTagWater), @ex, @ey);
663 {$IF DEFINED(D2F_DEBUG)}
664 //mapGrid.dbgRayTraceTileHitCB := nil;
665 mapGrid.dbgShowTraceLog := false;
666 {$ENDIF}
667 e_LogWritefln('v-trace: (%d,%d)-(%d,%d); end=(%d,%d); hit=%d', [pmsCurMapX, pmsCurMapY, dx, dy, ex, ey, (pan <> nil)]);
668 exit;
669 end;
670 end;
671 end;
674 // ////////////////////////////////////////////////////////////////////////// //
675 procedure g_Holmes_Draw ();
676 begin
677 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
678 glDisable(GL_STENCIL_TEST);
679 glDisable(GL_BLEND);
680 glDisable(GL_SCISSOR_TEST);
681 glDisable(GL_TEXTURE_2D);
683 if gGameOn then
684 begin
685 plrDebugDraw();
686 end;
688 laserSet := false;
689 end;
692 procedure g_Holmes_DrawUI ();
693 begin
694 uiDraw();
695 drawCursor();
696 end;
699 end.