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;
315 var
322 begin
329 var
331 begin
333 begin
334 drawLine(mapGrid.gridX0, mapGrid.gridY0+y*mapGrid.tileSize, mapGrid.gridX0+mapGrid.gridWidth, mapGrid.gridY0+y*mapGrid.tileSize, 96, 96, 96, 255);
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);
344 begin
349 begin
350 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
355 begin
358 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
363 var
366 begin
371 begin
377 var
381 var
386 begin
388 begin
391 end
393 begin
396 end
397 else
398 begin
399 exit;
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
410 var
414 begin
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
428 {$IF DEFINED(D2F_DEBUG)}
429 //mapGrid.dbgRayTraceTileHitCB := nil;
430 {$ENDIF}
433 begin
436 //mx += mw div 2;
441 begin
442 //fillRect(mx-4, my-7*8-6, 110, 7*8+6, 0, 0, 94, 250);
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
455 // ammo
457 // target
464 {
465 property MonsterRemoved: Boolean read FRemoved write FRemoved;
466 property MonsterPain: Integer read FPain write FPain;
467 property MonsterAnim: Byte read FCurAnim write FCurAnim;
468 }
472 begin
477 var
480 begin
496 begin
499 begin
512 if showMapCurPos then drawText8(4, gWinSizeY-10, Format('mappos:(%d,%d)', [pmsCurMapX, pmsCurMapY]), 255, 255, 0);
516 // ////////////////////////////////////////////////////////////////////////// //
518 begin
530 var
538 begin
541 begin
552 // press
554 begin
555 // M-M: one monster think step
557 begin
561 exit;
563 // M-I: toggle monster info
565 begin
568 exit;
570 // M-L: toggle monster LOS to player
572 begin
575 exit;
577 // M-G: toggle "show all cells occupied by monsters"
579 begin
582 exit;
584 // M-A: wake up monster
586 begin
589 begin
593 exit;
595 // C-T: teleport player
597 begin
599 //e_WriteLog(Format('TELEPORT: (%d,%d)', [pmsCurMapX, pmsCurMapY]), MSG_NOTIFY);
601 begin
603 gPlayers[0].TeleportTo(pmsCurMapX-w div 2, pmsCurMapY-h div 2, true, 69); // 69: don't change dir
605 exit;
607 // C-P: show cursor position on the map
609 begin
612 exit;
614 // C-G: toggle grid
616 begin
619 exit;
621 // C-L: toggle layers window
623 begin
627 exit;
629 // C-O: toggle outlines window
631 begin
634 if not uiVisibleWindow(winOutlines) then uiAddWindow(winOutlines) else uiRemoveWindow(winOutlines);
635 exit;
637 // F1: toggle options window
639 begin
642 if not uiVisibleWindow(winOptions) then uiAddWindow(winOptions) else uiRemoveWindow(winOptions);
643 exit;
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
648 begin
658 {$IF DEFINED(D2F_DEBUG)}
659 //mapGrid.dbgRayTraceTileHitCB := dummyWallTrc;
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;
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;
674 // ////////////////////////////////////////////////////////////////////////// //
676 begin
684 begin
693 begin