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
80 function g_Holmes_MouseEvent (var ev: THMouseEvent): Boolean; // returns `true` if event was eaten
83 // hooks for player
88 var
92 implementation
94 uses
99 var
100 //globalInited: Boolean = false;
112 // ////////////////////////////////////////////////////////////////////////// //
113 {$INCLUDE g_holmes.inc}
114 {$INCLUDE g_holmes_ui.inc}
117 // ////////////////////////////////////////////////////////////////////////// //
118 var
129 // ////////////////////////////////////////////////////////////////////////// //
130 var
137 var
139 begin
153 var
155 begin
172 var
174 begin
190 // ////////////////////////////////////////////////////////////////////////// //
192 begin
193 e_WriteLog(Format('Inspector: videomode changed: %dx%d', [gScreenWidth, gScreenHeight]), MSG_NOTIFY);
194 // texture space is possibly lost here, idc
200 //createCursorTexture();
204 begin
210 begin
214 // ////////////////////////////////////////////////////////////////////////// //
215 var
225 begin
234 begin
251 begin
253 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);
255 begin
261 begin
265 //if pan.Enabled then g_Map_DisableWall(pan.arrIdx) else g_Map_EnableWall(pan.arrIdx);
269 begin
271 e_WriteLog(Format('monster #%d (UID:%u) (proxyid:%d)', [mon.arrIdx, mon.UID, mon.proxyId]), MSG_NOTIFY);
274 begin
275 //e_WriteLog(Format('mouse: x=%d; y=%d; but=%d; bstate=%d', [msx, msy, but, bstate]), MSG_NOTIFY);
282 begin
284 begin
285 // dump monsters in cell
289 end
290 else
291 begin
292 // toggle wall
297 exit;
301 begin
306 exit;
314 var
316 begin
317 {
318 y := mapGrid.gridY0;
319 while (y < mapGrid.gridY0+mapGrid.gridHeight) do
320 begin
321 x := mapGrid.gridX0;
322 while (x < mapGrid.gridX0+mapGrid.gridWidth) do
323 begin
324 if (x+mapGrid.tileSize > vpx) and (y+mapGrid.tileSize > vpy) and
325 (x < vpx+vpw) and (y < vpy+vph) then
326 begin
327 //e_DrawQuad(x, y, x+mapGrid.tileSize-1, y+mapGrid.tileSize-1, 96, 96, 96, 96);
328 drawRect(x, y, mapGrid.tileSize, mapGrid.tileSize, 96, 96, 96, 255);
329 end;
330 Inc(x, mapGrid.tileSize);
331 end;
332 Inc(y, mapGrid.tileSize);
333 end;
334 }
336 begin
337 drawLine(mapGrid.gridX0, mapGrid.gridY0+y*mapGrid.tileSize, mapGrid.gridX0+mapGrid.gridWidth, mapGrid.gridY0+y*mapGrid.tileSize, 96, 96, 96, 255);
341 begin
342 drawLine(mapGrid.gridX0+x*mapGrid.tileSize, mapGrid.gridY0, mapGrid.gridX0+x*mapGrid.tileSize, mapGrid.gridY0+y*mapGrid.gridHeight, 96, 96, 96, 255);
347 begin
352 begin
353 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
358 begin
361 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
366 var
369 begin
374 begin
380 var
384 var
389 begin
391 begin
394 end
396 begin
399 end
400 else
401 begin
402 exit;
406 if (g_Map_traceToNearestWall(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, @ex, @ey) <> nil) then
407 begin
413 var
417 begin
423 {$IF DEFINED(D2F_DEBUG)}
424 //mapGrid.dbgRayTraceTileHitCB := hilightCell1;
425 {$ENDIF}
426 if (g_Map_traceToNearestWall(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, @ex, @ey) <> nil) then
427 //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
428 begin
431 {$IF DEFINED(D2F_DEBUG)}
432 //mapGrid.dbgRayTraceTileHitCB := nil;
433 {$ENDIF}
436 begin
439 //mx += mw div 2;
444 begin
445 //fillRect(mx-4, my-7*8-6, 110, 7*8+6, 0, 0, 94, 250);
450 // type
451 drawText6(mx, my, Format('%s(U:%u)', [monsTypeToString(mon.MonsterType), mon.UID]), 255, 127, 0); my -= 8;
452 // beh
453 drawText6(mx, my, Format('Beh: %s', [monsBehToString(mon.MonsterBehaviour)]), 255, 127, 0); my -= 8;
454 // state
455 drawText6(mx, my, Format('State:%s (%d)', [monsStateToString(mon.MonsterState), mon.MonsterSleep]), 255, 127, 0); my -= 8;
456 // health
458 // ammo
460 // target
467 {
468 property MonsterRemoved: Boolean read FRemoved write FRemoved;
469 property MonsterPain: Integer read FPain write FPain;
470 property MonsterAnim: Byte read FCurAnim write FCurAnim;
471 }
475 begin
480 var
483 begin
497 begin
500 begin
513 if showMapCurPos then drawText8(4, gWinSizeY-10, Format('mappos:(%d,%d)', [pmsCurMapX, pmsCurMapY]), 255, 255, 0);
517 // ////////////////////////////////////////////////////////////////////////// //
519 begin
531 var
539 begin
542 begin
553 // press
555 begin
556 // M-M: one monster think step
558 begin
562 exit;
564 // M-I: toggle monster info
566 begin
569 exit;
571 // M-L: toggle monster LOS to player
573 begin
576 exit;
578 // M-G: toggle "show all cells occupied by monsters"
580 begin
583 exit;
585 // M-A: wake up monster
587 begin
590 begin
594 exit;
596 // C-T: teleport player
598 begin
600 //e_WriteLog(Format('TELEPORT: (%d,%d)', [pmsCurMapX, pmsCurMapY]), MSG_NOTIFY);
602 begin
604 gPlayers[0].TeleportTo(pmsCurMapX-w div 2, pmsCurMapY-h div 2, true, 69); // 69: don't change dir
606 exit;
608 // C-P: show cursor position on the map
610 begin
613 exit;
615 // C-G: toggle grid
617 begin
620 exit;
622 // C-L: toggle layers window
624 begin
628 exit;
630 // C-O: toggle outlines window
632 begin
635 if not uiVisibleWindow(winOutlines) then uiAddWindow(winOutlines) else uiRemoveWindow(winOutlines);
636 exit;
638 // F1: toggle options window
640 begin
643 if not uiVisibleWindow(winOptions) then uiAddWindow(winOptions) else uiRemoveWindow(winOptions);
644 exit;
646 // C-UP, C-DOWN, C-LEFT, C-RIGHT: trace 10 pixels from cursor in the respective direction
647 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
649 begin
659 {$IF DEFINED(D2F_DEBUG)}
660 //mapGrid.dbgRayTraceTileHitCB := dummyWallTrc;
662 {$ENDIF}
663 pan := g_Map_traceToNearest(pmsCurMapX, pmsCurMapY, dx, dy, (GridTagWall or GridTagDoor or GridTagStep or GridTagAcid1 or GridTagAcid2 or GridTagWater), @ex, @ey);
664 {$IF DEFINED(D2F_DEBUG)}
665 //mapGrid.dbgRayTraceTileHitCB := nil;
667 {$ENDIF}
668 e_LogWritefln('v-trace: (%d,%d)-(%d,%d); end=(%d,%d); hit=%d', [pmsCurMapX, pmsCurMapY, dx, dy, ex, ey, (pan <> nil)]);
669 exit;
675 // ////////////////////////////////////////////////////////////////////////// //
677 begin
685 begin