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}
19 interface
21 uses
22 e_log,
25 xprofiler;
28 type
30 public
31 const
32 // both for but and for bstate
39 // event types
44 public
54 public
55 const
56 // modifiers
61 // event types
65 public
81 function g_Holmes_MouseEvent (var ev: THMouseEvent): Boolean; // returns `true` if event was eaten
84 // hooks for player
89 var
93 implementation
95 uses
100 var
101 //globalInited: Boolean = false;
113 // ////////////////////////////////////////////////////////////////////////// //
114 {$INCLUDE g_holmes.inc}
115 {$INCLUDE g_holmes_ui.inc}
118 // ////////////////////////////////////////////////////////////////////////// //
119 var
131 // ////////////////////////////////////////////////////////////////////////// //
132 var
139 var
141 begin
155 var
157 begin
174 var
176 begin
194 // ////////////////////////////////////////////////////////////////////////// //
196 begin
197 e_WriteLog(Format('Inspector: videomode changed: %dx%d', [gScreenWidth, gScreenHeight]), MSG_NOTIFY);
198 // texture space is possibly lost here, idc
204 //createCursorTexture();
208 begin
214 begin
218 // ////////////////////////////////////////////////////////////////////////// //
219 var
229 begin
238 begin
255 begin
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);
259 begin
265 begin
269 //if pan.Enabled then g_Map_DisableWall(pan.arrIdx) else g_Map_EnableWall(pan.arrIdx);
273 begin
275 e_WriteLog(Format('monster #%d (UID:%u) (proxyid:%d)', [mon.arrIdx, mon.UID, mon.proxyId]), MSG_NOTIFY);
278 begin
279 //e_WriteLog(Format('mouse: x=%d; y=%d; but=%d; bstate=%d', [msx, msy, but, bstate]), MSG_NOTIFY);
286 begin
288 begin
289 // dump monsters in cell
293 end
294 else
295 begin
296 // toggle wall
301 exit;
305 begin
310 exit;
318 var
320 begin
321 {
322 y := mapGrid.gridY0;
323 while (y < mapGrid.gridY0+mapGrid.gridHeight) do
324 begin
325 x := mapGrid.gridX0;
326 while (x < mapGrid.gridX0+mapGrid.gridWidth) do
327 begin
328 if (x+mapGrid.tileSize > vpx) and (y+mapGrid.tileSize > vpy) and
329 (x < vpx+vpw) and (y < vpy+vph) then
330 begin
331 //e_DrawQuad(x, y, x+mapGrid.tileSize-1, y+mapGrid.tileSize-1, 96, 96, 96, 96);
332 drawRect(x, y, mapGrid.tileSize, mapGrid.tileSize, 96, 96, 96, 255);
333 end;
334 Inc(x, mapGrid.tileSize);
335 end;
336 Inc(y, mapGrid.tileSize);
337 end;
338 }
340 begin
341 drawLine(mapGrid.gridX0, mapGrid.gridY0+y*mapGrid.tileSize, mapGrid.gridX0+mapGrid.gridWidth, mapGrid.gridY0+y*mapGrid.tileSize, 96, 96, 96, 255);
345 begin
346 drawLine(mapGrid.gridX0+x*mapGrid.tileSize, mapGrid.gridY0, mapGrid.gridX0+x*mapGrid.tileSize, mapGrid.gridY0+y*mapGrid.gridHeight, 96, 96, 96, 255);
351 begin
356 begin
357 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
362 begin
365 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
370 var
373 begin
378 begin
384 var
388 var
393 begin
395 begin
398 end
400 begin
403 end
404 else
405 begin
406 exit;
410 if (g_Map_traceToNearestWall(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, @ex, @ey) <> nil) then
411 begin
417 var
421 begin
427 {$IF DEFINED(D2F_DEBUG)}
428 //mapGrid.dbgRayTraceTileHitCB := hilightCell1;
429 {$ENDIF}
430 if (g_Map_traceToNearestWall(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, @ex, @ey) <> nil) then
431 //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
432 begin
435 {$IF DEFINED(D2F_DEBUG)}
436 //mapGrid.dbgRayTraceTileHitCB := nil;
437 {$ENDIF}
440 begin
443 //mx += mw div 2;
448 begin
449 //fillRect(mx-4, my-7*8-6, 110, 7*8+6, 0, 0, 94, 250);
454 // type
455 drawText6(mx, my, Format('%s(U:%u)', [monsTypeToString(mon.MonsterType), mon.UID]), 255, 127, 0); my -= 8;
456 // beh
457 drawText6(mx, my, Format('Beh: %s', [monsBehToString(mon.MonsterBehaviour)]), 255, 127, 0); my -= 8;
458 // state
459 drawText6(mx, my, Format('State:%s (%d)', [monsStateToString(mon.MonsterState), mon.MonsterSleep]), 255, 127, 0); my -= 8;
460 // health
462 // ammo
464 // target
471 {
472 property MonsterRemoved: Boolean read FRemoved write FRemoved;
473 property MonsterPain: Integer read FPain write FPain;
474 property MonsterAnim: Byte read FCurAnim write FCurAnim;
475 }
479 begin
484 var
487 begin
501 begin
504 begin
517 if showMapCurPos then drawText8(4, gWinSizeY-10, Format('mappos:(%d,%d)', [pmsCurMapX, pmsCurMapY]), 255, 255, 0);
521 // ////////////////////////////////////////////////////////////////////////// //
523 begin
535 var
543 begin
546 begin
557 // press
559 begin
560 // M-M: one monster think step
562 begin
566 exit;
568 // M-I: toggle monster info
570 begin
573 exit;
575 // M-L: toggle monster LOS to player
577 begin
580 exit;
582 // M-G: toggle "show all cells occupied by monsters"
584 begin
587 exit;
589 // M-A: wake up monster
591 begin
594 begin
598 exit;
600 // C-T: teleport player
602 begin
604 //e_WriteLog(Format('TELEPORT: (%d,%d)', [pmsCurMapX, pmsCurMapY]), MSG_NOTIFY);
606 begin
608 gPlayers[0].TeleportTo(pmsCurMapX-w div 2, pmsCurMapY-h div 2, true, 69); // 69: don't change dir
610 exit;
612 // C-P: show cursor position on the map
614 begin
617 exit;
619 // C-G: toggle grid
621 begin
624 exit;
626 // C-L: toggle layers window
628 begin
632 exit;
634 // C-O: toggle outlines window
636 begin
639 if not uiVisibleWindow(winOutlines) then uiAddWindow(winOutlines) else uiRemoveWindow(winOutlines);
640 exit;
642 // F1: toggle options window
644 begin
647 if not uiVisibleWindow(winOptions) then uiAddWindow(winOptions) else uiRemoveWindow(winOptions);
648 exit;
650 // C-UP, C-DOWN, C-LEFT, C-RIGHT: trace 10 pixels from cursor in the respective direction
651 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
653 begin
663 {$IF DEFINED(D2F_DEBUG)}
664 //mapGrid.dbgRayTraceTileHitCB := dummyWallTrc;
666 {$ENDIF}
667 pan := g_Map_traceToNearest(pmsCurMapX, pmsCurMapY, dx, dy, (GridTagWall or GridTagDoor or GridTagStep or GridTagAcid1 or GridTagAcid2 or GridTagWater), @ex, @ey);
668 {$IF DEFINED(D2F_DEBUG)}
669 //mapGrid.dbgRayTraceTileHitCB := nil;
671 {$ENDIF}
672 e_LogWritefln('v-trace: (%d,%d)-(%d,%d); end=(%d,%d); hit=%d', [pmsCurMapX, pmsCurMapY, dx, dy, ex, ey, (pan <> nil)]);
673 exit;
679 // ////////////////////////////////////////////////////////////////////////// //
681 begin
689 begin
698 begin