DEADSOFTWARE

Added support OpenGL ES 1.1 through nanoGL (have some bugs) and fix build for ARM
[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 mempool, geom,
23 e_log, e_input,
24 g_textures, g_basic, e_graphics, g_phys, g_grid, g_player, g_monsters,
25 g_window, g_map, g_triggers, g_items, g_game, g_panel, g_console, g_gfx,
26 xprofiler,
27 sdlcarcass,
28 fui_common, fui_events, fui_ctls,
29 fui_gfx_gl;
32 procedure g_Holmes_Draw ();
33 procedure g_Holmes_DrawUI ();
35 procedure g_Holmes_OnEvent (var ev: TFUIEvent);
37 // hooks for player
38 procedure g_Holmes_plrViewPos (viewPortX, viewPortY: Integer);
39 procedure g_Holmes_plrViewSize (viewPortW, viewPortH: Integer);
40 procedure g_Holmes_plrLaser (ax0, ay0, ax1, ay1: Integer);
43 var
44 g_holmes_imfunctional: Boolean = false;
45 g_holmes_enabled: Boolean = {$IF DEFINED(D2F_DEBUG)}true{$ELSE}false{$ENDIF};
48 implementation
50 uses
51 {$IFDEF USE_NANOGL}
52 nanoGL,
53 {$ELSE}
54 GL,
55 {$ENDIF}
56 {rttiobj,} typinfo, e_texture,
57 SysUtils, Classes, SDL2,
58 MAPDEF, g_main, g_options,
59 utils, hashtable, xparser;
62 var
63 hlmContext: TGxContext = nil;
64 //globalInited: Boolean = false;
65 msX: Integer = -666;
66 msY: Integer = -666;
67 msB: Word = 0; // button state
68 kbS: Word = 0; // keyboard modifiers state
69 showGrid: Boolean = {$IF DEFINED(D2F_DEBUG)}false{$ELSE}false{$ENDIF};
70 showMonsInfo: Boolean = false;
71 showMonsLOS2Plr: Boolean = false;
72 showAllMonsCells: Boolean = false;
73 showMapCurPos: Boolean = false;
74 showLayersWindow: Boolean = false;
75 showOutlineWindow: Boolean = false;
76 showTriggers: Boolean = {$IF DEFINED(D2F_DEBUG)}false{$ELSE}false{$ENDIF};
77 showTraceBox: Boolean = {$IF DEFINED(D2F_DEBUG)}false{$ELSE}false{$ENDIF};
80 // ////////////////////////////////////////////////////////////////////////// //
81 {$INCLUDE g_holmes.inc}
82 {$INCLUDE g_holmes_ol.inc} // outliner
85 // ////////////////////////////////////////////////////////////////////////// //
86 {$INCLUDE g_holmes_cmd.inc}
87 procedure holmesInitCommands (); forward;
88 procedure holmesInitBinds (); forward;
91 // ////////////////////////////////////////////////////////////////////////// //
92 var
93 g_ol_nice: Boolean = false;
94 g_ol_fill_walls: Boolean = false;
95 g_ol_rlayer_back: Boolean = false;
96 g_ol_rlayer_step: Boolean = false;
97 g_ol_rlayer_wall: Boolean = false;
98 g_ol_rlayer_door: Boolean = false;
99 g_ol_rlayer_acid1: Boolean = false;
100 g_ol_rlayer_acid2: Boolean = false;
101 g_ol_rlayer_water: Boolean = false;
102 g_ol_rlayer_fore: Boolean = false;
105 // ////////////////////////////////////////////////////////////////////////// //
106 var
107 winHelp: TUITopWindow = nil;
108 winOptions: TUITopWindow = nil;
109 winLayers: TUITopWindow = nil;
110 winOutlines: TUITopWindow = nil;
113 procedure createHelpWindow (); forward;
114 procedure createOptionsWindow (); forward;
115 procedure createLayersWindow (); forward;
116 procedure createOutlinesWindow (); forward;
119 procedure toggleLayersWindowCB (me: TUIControl);
120 begin
121 showLayersWindow := not showLayersWindow;
122 if showLayersWindow then
123 begin
124 if (winLayers = nil) then createLayersWindow();
125 uiAddWindow(winLayers);
126 end
127 else
128 begin
129 uiRemoveWindow(winLayers);
130 end;
131 end;
133 procedure toggleOutlineWindowCB (me: TUIControl);
134 begin
135 showOutlineWindow := not showOutlineWindow;
136 if showOutlineWindow then
137 begin
138 if (winOutlines = nil) then createOutlinesWindow();
139 uiAddWindow(winOutlines);
140 end
141 else
142 begin
143 uiRemoveWindow(winOutlines);
144 end;
145 end;
148 procedure createHelpWindow ();
149 procedure addHelpEmptyLine ();
150 var
151 stx: TUIStaticText;
152 begin
153 stx := TUIStaticText.Create();
154 stx.flExpand := true;
155 stx.halign := 0; // center
156 stx.text := '';
157 stx.header := false;
158 stx.line := false;
159 winHelp.appendChild(stx);
160 end;
162 procedure addHelpCaptionLine (const txt: AnsiString);
163 var
164 stx: TUIStaticText;
165 begin
166 stx := TUIStaticText.Create();
167 stx.flExpand := true;
168 stx.halign := 0; // center
169 stx.text := txt;
170 stx.header := true;
171 stx.line := true;
172 winHelp.appendChild(stx);
173 end;
175 procedure addHelpCaption (const txt: AnsiString);
176 var
177 stx: TUIStaticText;
178 begin
179 stx := TUIStaticText.Create();
180 stx.flExpand := true;
181 stx.halign := 0; // center
182 stx.text := txt;
183 stx.header := true;
184 stx.line := false;
185 winHelp.appendChild(stx);
186 end;
188 procedure addHelpKeyMouse (const key, txt, grp: AnsiString);
189 var
190 box: TUIHBox;
191 span: TUISpan;
192 stx: TUIStaticText;
193 begin
194 box := TUIHBox.Create();
195 box.flExpand := true;
196 // key
197 stx := TUIStaticText.Create();
198 stx.flExpand := true;
199 stx.halign := 1; // right
200 stx.valign := 0; // center
201 stx.text := key;
202 stx.header := true;
203 stx.line := false;
204 stx.flHGroup := grp;
205 box.appendChild(stx);
206 // span
207 span := TUISpan.Create();
208 span.flDefaultSize := TLaySize.Create(12, 1);
209 span.flExpand := true;
210 box.appendChild(span);
211 // text
212 stx := TUIStaticText.Create();
213 stx.flExpand := true;
214 stx.halign := -1; // left
215 stx.valign := 0; // center
216 stx.text := txt;
217 stx.header := false;
218 stx.line := false;
219 box.appendChild(stx);
220 winHelp.appendChild(box);
221 end;
223 procedure addHelpKey (const key, txt: AnsiString); begin addHelpKeyMouse(key, txt, 'help-keys'); end;
224 procedure addHelpMouse (const key, txt: AnsiString); begin addHelpKeyMouse(key, txt, 'help-mouse'); end;
226 var
227 slist: array of AnsiString = nil;
228 cmd: PHolmesCommand;
229 bind: THolmesBinding;
230 f: Integer;
232 llb: TUISimpleText;
233 maxkeylen: Integer;
234 s: AnsiString;
236 begin
237 winHelp := TUITopWindow.Create('Holmes Help');
238 winHelp.escClose := true;
239 winHelp.flHoriz := false;
241 // keyboard
242 for cmd in cmdlist do cmd.helpmark := false;
244 //maxkeylen := 0;
245 for bind in keybinds do
246 begin
247 if (Length(bind.key) = 0) then continue;
248 if cmdlist.get(bind.cmdName, cmd) then
249 begin
250 if (Length(cmd.help) > 0) then
251 begin
252 cmd.helpmark := true;
253 //if (maxkeylen < Length(bind.key)) then maxkeylen := Length(bind.key);
254 end;
255 end;
256 end;
258 for cmd in cmdlist do
259 begin
260 if not cmd.helpmark then continue;
261 if (Length(cmd.help) = 0) then begin cmd.helpmark := false; continue; end;
262 f := 0;
263 while (f < Length(slist)) and (CompareText(slist[f], cmd.section) <> 0) do Inc(f);
264 if (f = Length(slist)) then
265 begin
266 SetLength(slist, Length(slist)+1);
267 slist[High(slist)] := cmd.section;
268 end;
269 end;
271 addHelpCaptionLine('KEYBOARD');
272 //llb := TUISimpleText.Create(0, 0);
273 for f := 0 to High(slist) do
274 begin
275 //if (f > 0) then llb.appendItem('');
276 if (f > 0) then addHelpEmptyLine();
277 //llb.appendItem(slist[f], true, true);
278 addHelpCaption(slist[f]);
279 for cmd in cmdlist do
280 begin
281 if not cmd.helpmark then continue;
282 if (CompareText(cmd.section, slist[f]) <> 0) then continue;
283 for bind in keybinds do
284 begin
285 if (Length(bind.key) = 0) then continue;
286 if (cmd.name = bind.cmdName) then
287 begin
288 //s := bind.key;
289 //while (Length(s) < maxkeylen) do s += ' ';
290 //s := ' '+s+' -- '+cmd.help;
291 //llb.appendItem(s);
292 addHelpMouse(bind.key, cmd.help);
293 end;
294 end;
295 end;
296 end;
298 // mouse
299 for cmd in cmdlist do cmd.helpmark := false;
301 //maxkeylen := 0;
302 for bind in msbinds do
303 begin
304 if (Length(bind.key) = 0) then continue;
305 if cmdlist.get(bind.cmdName, cmd) then
306 begin
307 if (Length(cmd.help) > 0) then
308 begin
309 cmd.helpmark := true;
310 //if (maxkeylen < Length(bind.key)) then maxkeylen := Length(bind.key);
311 end;
312 end;
313 end;
315 //llb.appendItem('');
316 //llb.appendItem('mouse', true, true);
317 if (f > 0) then addHelpEmptyLine();
318 addHelpCaptionLine('MOUSE');
319 for bind in msbinds do
320 begin
321 if (Length(bind.key) = 0) then continue;
322 if cmdlist.get(bind.cmdName, cmd) then
323 begin
324 if (Length(cmd.help) > 0) then
325 begin
326 //s := bind.key;
327 //while (Length(s) < maxkeylen) do s += ' ';
328 //s := ' '+s+' -- '+cmd.help;
329 //llb.appendItem(s);
330 addHelpKey(bind.key, cmd.help);
331 end;
332 end;
333 end;
335 //winHelp.appendChild(llb);
337 uiLayoutCtl(winHelp);
338 winHelp.escClose := true;
339 winHelp.centerInScreen();
340 end;
343 procedure winLayersClosed (me: TUIControl); begin showLayersWindow := false; end;
344 procedure winOutlinesClosed (me: TUIControl); begin showOutlineWindow := false; end;
346 procedure addCheckBox (parent: TUIControl; const text: AnsiString; pvar: PBoolean; const aid: AnsiString='');
347 var
348 cb: TUICheckBox;
349 begin
350 cb := TUICheckBox.Create();
351 cb.flExpand := true;
352 cb.setVar(pvar);
353 cb.text := text;
354 cb.id := aid;
355 parent.appendChild(cb);
356 end;
358 procedure addButton (parent: TUIControl; const text: AnsiString; cb: TUIControl.TActionCB);
359 var
360 but: TUIButton;
361 begin
362 but := TUIButton.Create();
363 //but.flExpand := true;
364 but.actionCB := cb;
365 but.text := text;
366 parent.appendChild(but);
367 end;
370 procedure actionFillWalls (cb: TUIControl);
371 begin
372 TUICheckBox(cb).checked := not TUICheckBox(cb).checked;
373 TUICheckBox(cb.topLevel['cbcontour']).enabled := not TUICheckBox(cb).checked;
374 end;
376 procedure createLayersWindow ();
377 var
378 box: TUIVBox;
379 begin
380 winLayers := TUITopWindow.Create('layers');
381 winLayers.flHoriz := false;
382 winLayers.x0 := 10;
383 winLayers.y0 := 10;
384 winLayers.flHoriz := false;
385 winLayers.escClose := true;
386 winLayers.closeCB := winLayersClosed;
388 box := TUIVBox.Create();
389 addCheckBox(box, '~background', @g_rlayer_back);
390 addCheckBox(box, '~steps', @g_rlayer_step);
391 addCheckBox(box, '~walls', @g_rlayer_wall);
392 addCheckBox(box, '~doors', @g_rlayer_door);
393 addCheckBox(box, 'acid~1', @g_rlayer_acid1);
394 addCheckBox(box, 'acid~2', @g_rlayer_acid2);
395 addCheckBox(box, 'wate~r', @g_rlayer_water);
396 addCheckBox(box, '~foreground', @g_rlayer_fore);
397 winLayers.appendChild(box);
399 uiLayoutCtl(winLayers);
400 end;
403 procedure createOutlinesWindow ();
404 var
405 box: TUIVBox;
406 begin
407 winOutlines := TUITopWindow.Create('outlines');
408 winOutlines.flHoriz := false;
409 winOutlines.x0 := 100;
410 winOutlines.y0 := 30;
411 winOutlines.flHoriz := false;
412 winOutlines.escClose := true;
413 winOutlines.closeCB := winOutlinesClosed;
415 box := TUIVBox.Create();
416 box.hasFrame := true;
417 box.caption := 'layers';
418 addCheckBox(box, '~background', @g_ol_rlayer_back);
419 addCheckBox(box, '~steps', @g_ol_rlayer_step);
420 addCheckBox(box, '~walls', @g_ol_rlayer_wall);
421 addCheckBox(box, '~doors', @g_ol_rlayer_door);
422 addCheckBox(box, 'acid~1', @g_ol_rlayer_acid1);
423 addCheckBox(box, 'acid~2', @g_ol_rlayer_acid2);
424 addCheckBox(box, 'wate~r', @g_ol_rlayer_water);
425 addCheckBox(box, '~foreground', @g_ol_rlayer_fore);
426 winOutlines.appendChild(box);
428 box := TUIVBox.Create();
429 box.hasFrame := true;
430 box.caption := 'options';
431 addCheckBox(box, 'fi~ll walls', @g_ol_fill_walls, 'cbfill');
432 addCheckBox(box, 'con~tours', @g_ol_nice, 'cbcontour');
433 winOutlines.appendChild(box);
435 winOutlines.setActionCBFor('cbfill', actionFillWalls);
437 uiLayoutCtl(winOutlines);
438 end;
441 procedure createOptionsWindow ();
442 var
443 box: TUIBox;
444 span: TUISpan;
445 begin
446 winOptions := TUITopWindow.Create('Holmes Options');
447 winOptions.flHoriz := false;
448 winOptions.flHoriz := false;
449 winOptions.escClose := true;
451 box := TUIVBox.Create();
452 box.hasFrame := true;
453 box.caption := 'visual';
454 addCheckBox(box, 'map ~grid', @showGrid);
455 addCheckBox(box, 'cursor ~position on map', @showMapCurPos);
456 addCheckBox(box, '~monster info', @showMonsInfo);
457 addCheckBox(box, 'monster LO~S to player', @showMonsLOS2Plr);
458 addCheckBox(box, 'monster ~cells (SLOW!)', @showAllMonsCells);
459 addCheckBox(box, 'draw ~triggers (SLOW!)', @showTriggers);
460 winOptions.appendChild(box);
462 box := TUIHBox.Create();
463 box.hasFrame := true;
464 box.caption := 'windows';
465 box.captionAlign := 0;
466 box.flAlign := 0;
467 addButton(box, '~layers', toggleLayersWindowCB);
468 span := TUISpan.Create();
469 span.flExpand := true;
470 span.flDefaultSize := TLaySize.Create(4, 1);
471 box.appendChild(span);
472 addButton(box, '~outline', toggleOutlineWindowCB);
473 winOptions.appendChild(box);
475 uiLayoutCtl(winOptions);
476 winOptions.centerInScreen();
477 end;
480 procedure toggleLayersWindow (arg: Integer=-1);
481 begin
482 if (arg < 0) then showLayersWindow := not showLayersWindow else showLayersWindow := (arg > 0);
483 showLayersWindow := not showLayersWindow; // hack for callback
484 toggleLayersWindowCB(nil);
485 end;
487 procedure toggleOutlineWindow (arg: Integer=-1);
488 begin
489 if (arg < 0) then showOutlineWindow := not showOutlineWindow else showOutlineWindow := (arg > 0);
490 showOutlineWindow := not showOutlineWindow; // hack for callback
491 toggleOutlineWindowCB(nil);
492 end;
494 procedure toggleHelpWindow (arg: Integer=-1);
495 begin
496 if (winHelp = nil) then
497 begin
498 if (arg = 0) then exit;
499 createHelpWindow();
500 end;
501 if (arg < 0) then begin if not uiVisibleWindow(winHelp) then uiAddWindow(winHelp) else uiRemoveWindow(winHelp); end
502 else if (arg = 0) then begin if uiVisibleWindow(winHelp) then uiRemoveWindow(winHelp); end
503 else begin if (not uiVisibleWindow(winHelp)) then uiAddWindow(winHelp); end;
504 if (not uiVisibleWindow(winHelp)) then FreeAndNil(winHelp);
505 end;
507 procedure toggleOptionsWindow (arg: Integer=-1);
508 begin
509 if (winOptions = nil) then createOptionsWindow();
510 if (arg < 0) then begin if not uiVisibleWindow(winOptions) then uiAddWindow(winOptions) else uiRemoveWindow(winOptions); end
511 else if (arg = 0) then begin if uiVisibleWindow(winOptions) then uiRemoveWindow(winOptions); end
512 else begin if not uiVisibleWindow(winOptions) then uiAddWindow(winOptions); end
513 end;
516 // ////////////////////////////////////////////////////////////////////////// //
517 var
518 vpSet: Boolean = false;
519 vpx, vpy: Integer;
520 vpw, vph: Integer;
521 laserSet: Boolean = false;
522 laserX0, laserY0, laserX1, laserY1: Integer;
523 monMarkedUID: Integer = -1;
524 platMarkedGUID: Integer = -1;
527 procedure g_Holmes_plrViewPos (viewPortX, viewPortY: Integer);
528 begin
529 vpSet := true;
530 vpx := viewPortX;
531 vpy := viewPortY;
532 end;
534 procedure g_Holmes_plrViewSize (viewPortW, viewPortH: Integer);
535 begin
536 vpSet := true;
537 vpw := viewPortW;
538 vph := viewPortH;
539 end;
541 procedure g_Holmes_plrLaser (ax0, ay0, ax1, ay1: Integer);
542 begin
543 laserSet := true;
544 laserX0 := ax0;
545 laserY0 := ay0;
546 laserX1 := ax1;
547 laserY1 := ay1;
548 laserSet := laserSet; // shut up, fpc!
549 end;
552 function pmsCurMapX (): Integer; inline; begin result := round(msX/g_dbg_scale)+vpx; end;
553 function pmsCurMapY (): Integer; inline; begin result := round(msY/g_dbg_scale)+vpy; end;
556 {$IFDEF HOLMES_OLD_OUTLINES}
557 var
558 edgeBmp: array of Byte = nil;
561 procedure drawOutlines ();
562 var
563 r, g, b: Integer;
565 procedure clearEdgeBmp ();
566 begin
567 SetLength(edgeBmp, (gWinSizeX+4)*(gWinSizeY+4));
568 FillChar(edgeBmp[0], Length(edgeBmp)*sizeof(edgeBmp[0]), 0);
569 end;
571 procedure drawPanel (pan: TPanel);
572 var
573 sx, len, y0, y1: Integer;
574 begin
575 if (pan = nil) or (pan.Width < 1) or (pan.Height < 1) then exit;
576 if (pan.X+pan.Width <= vpx-1) or (pan.Y+pan.Height <= vpy-1) then exit;
577 if (pan.X >= vpx+vpw+1) or (pan.Y >= vpy+vph+1) then exit;
578 if g_ol_nice or g_ol_fill_walls then
579 begin
580 sx := pan.X-(vpx-1);
581 len := pan.Width;
582 if (len > gWinSizeX+4) then len := gWinSizeX+4;
583 if (sx < 0) then begin len += sx; sx := 0; end;
584 if (sx+len > gWinSizeX+4) then len := gWinSizeX+4-sx;
585 if (len < 1) then exit;
586 assert(sx >= 0);
587 assert(sx+len <= gWinSizeX+4);
588 y0 := pan.Y-(vpy-1);
589 y1 := y0+pan.Height;
590 if (y0 < 0) then y0 := 0;
591 if (y1 > gWinSizeY+4) then y1 := gWinSizeY+4;
592 while (y0 < y1) do
593 begin
594 FillChar(edgeBmp[y0*(gWinSizeX+4)+sx], len*sizeof(edgeBmp[0]), 1);
595 Inc(y0);
596 end;
597 end
598 else
599 begin
600 drawRect(pan.X, pan.Y, pan.Width, pan.Height, r, g, b);
601 end;
602 end;
604 var
605 lsx: Integer = -1;
606 lex: Integer = -1;
607 lsy: Integer = -1;
609 procedure flushLine ();
610 begin
611 if (lsy > 0) and (lsx > 0) then
612 begin
613 if (lex = lsx) then
614 begin
615 glBegin(GL_POINTS);
616 glVertex2f(lsx-1+vpx+0.37, lsy-1+vpy+0.37);
617 glEnd();
618 end
619 else
620 begin
621 glBegin(GL_LINES);
622 glVertex2f(lsx-1+vpx+0.37, lsy-1+vpy+0.37);
623 glVertex2f(lex-0+vpx+0.37, lsy-1+vpy+0.37);
624 glEnd();
625 end;
626 end;
627 lsx := -1;
628 lex := -1;
629 end;
631 procedure startLine (y: Integer);
632 begin
633 flushLine();
634 lsy := y;
635 end;
637 procedure putPixel (x: Integer);
638 begin
639 if (x < 1) then exit;
640 if (lex+1 <> x) then flushLine();
641 if (lsx < 0) then lsx := x;
642 lex := x;
643 end;
645 procedure drawEdges ();
646 var
647 x, y: Integer;
648 a: PByte;
649 begin
650 glDisable(GL_BLEND);
651 glDisable(GL_TEXTURE_2D);
652 glLineWidth(1);
653 glPointSize(1);
654 glDisable(GL_LINE_SMOOTH);
655 glDisable(GL_POLYGON_SMOOTH);
656 glColor4f(r/255.0, g/255.0, b/255.0, 1.0);
657 for y := 1 to vph do
658 begin
659 a := @edgeBmp[y*(gWinSizeX+4)+1];
660 startLine(y);
661 for x := 1 to vpw do
662 begin
663 if (a[0] <> 0) then
664 begin
665 if (a[-1] = 0) or (a[1] = 0) or (a[-(gWinSizeX+4)] = 0) or (a[gWinSizeX+4] = 0) or
666 (a[-(gWinSizeX+4)-1] = 0) or (a[-(gWinSizeX+4)+1] = 0) or
667 (a[gWinSizeX+4-1] = 0) or (a[gWinSizeX+4+1] = 0) then
668 begin
669 putPixel(x);
670 end;
671 end;
672 Inc(a);
673 end;
674 flushLine();
675 end;
676 end;
678 procedure drawFilledWalls ();
679 var
680 x, y: Integer;
681 a: PByte;
682 begin
683 glDisable(GL_BLEND);
684 glDisable(GL_TEXTURE_2D);
685 glLineWidth(1);
686 glPointSize(1);
687 glDisable(GL_LINE_SMOOTH);
688 glDisable(GL_POLYGON_SMOOTH);
689 glColor4f(r/255.0, g/255.0, b/255.0, 1.0);
690 for y := 1 to vph do
691 begin
692 a := @edgeBmp[y*(gWinSizeX+4)+1];
693 startLine(y);
694 for x := 1 to vpw do
695 begin
696 if (a[0] <> 0) then putPixel(x);
697 Inc(a);
698 end;
699 flushLine();
700 end;
701 end;
703 procedure doWallsOld (parr: array of TPanel; ptype: Word; ar, ag, ab: Integer);
704 var
705 f: Integer;
706 pan: TPanel;
707 begin
708 r := ar;
709 g := ag;
710 b := ab;
711 if g_ol_nice or g_ol_fill_walls then clearEdgeBmp();
712 for f := 0 to High(parr) do
713 begin
714 pan := parr[f];
715 if (pan = nil) or not pan.Enabled or (pan.Width < 1) or (pan.Height < 1) then continue;
716 if ((pan.PanelType and ptype) = 0) then continue;
717 drawPanel(pan);
718 end;
719 if g_ol_nice then drawEdges();
720 if g_ol_fill_walls then drawFilledWalls();
721 end;
723 var
724 xptag: Word;
726 function doWallCB (pan: TPanel; tag: Integer): Boolean;
727 begin
728 result := false; // don't stop
729 //if (pan = nil) or not pan.Enabled or (pan.Width < 1) or (pan.Height < 1) then exit;
730 if ((pan.PanelType and xptag) = 0) then exit;
731 drawPanel(pan);
732 end;
734 procedure doWalls (parr: array of TPanel; ptype: Word; ar, ag, ab: Integer);
735 begin
736 r := ar;
737 g := ag;
738 b := ab;
739 xptag := ptype;
740 if ((ptype and (PANEL_WALL or PANEL_OPENDOOR or PANEL_CLOSEDOOR)) <> 0) then ptype := GridTagWall or GridTagDoor
741 else panelTypeToTag(ptype);
742 if g_ol_nice or g_ol_fill_walls then clearEdgeBmp();
743 mapGrid.forEachInAABB(vpx-1, vpy-1, vpw+2, vph+2, doWallCB, ptype);
744 if g_ol_nice then drawEdges();
745 if g_ol_fill_walls then drawFilledWalls();
746 end;
748 begin
749 if g_ol_rlayer_back then doWallsOld(gRenderBackgrounds, PANEL_BACK, 255, 127, 0);
750 if g_ol_rlayer_step then doWallsOld(gSteps, PANEL_STEP, 192, 192, 192);
751 if g_ol_rlayer_wall then doWallsOld(gWalls, PANEL_WALL, 255, 255, 255);
752 if g_ol_rlayer_door then doWallsOld(gWalls, PANEL_OPENDOOR or PANEL_CLOSEDOOR, 0, 255, 0);
753 if g_ol_rlayer_acid1 then doWallsOld(gAcid1, PANEL_ACID1, 255, 0, 0);
754 if g_ol_rlayer_acid2 then doWallsOld(gAcid2, PANEL_ACID2, 198, 198, 0);
755 if g_ol_rlayer_water then doWallsOld(gWater, PANEL_WATER, 0, 255, 255);
756 if g_ol_rlayer_fore then doWallsOld(gRenderForegrounds, PANEL_FORE, 210, 210, 210);
757 end;
759 {$ELSE}
760 var
761 oliner: TOutliner = nil;
763 procedure drawOutlines ();
764 var
765 r, g, b: Integer;
767 procedure clearOliner ();
768 begin
769 //if (oliner <> nil) and ((oliner.height <> vph+2) or (oliner.width <> vpw+2)) then begin oliner.Free(); oliner := nil; end;
770 if (oliner = nil) then oliner := TOutliner.Create(vpw+2, vph+2) else oliner.setup(vpw+2, vph+2);
771 end;
773 procedure drawOutline (ol: TOutliner; sx, sy: Integer);
774 procedure xline (x0, x1, y: Integer);
775 var
776 x: Integer;
777 begin
778 if (g_dbg_scale < 1.0) then
779 begin
780 glBegin(GL_POINTS);
781 for x := x0 to x1 do glVertex2f(sx+x+0.375, sy+y+0.375);
782 glEnd();
783 end
784 else
785 begin
786 glBegin(GL_QUADS);
787 glVertex2f(sx+x0+0, sy+y+0);
788 glVertex2f(sx+x1+1, sy+y+0);
789 glVertex2f(sx+x1+1, sy+y+1);
790 glVertex2f(sx+x0+0, sy+y+1);
791 glEnd();
792 end;
793 end;
794 var
795 y: Integer;
796 sp: TOutliner.TSpanX;
797 begin
798 if (ol = nil) then exit;
799 glPointSize(1);
800 glDisable(GL_POINT_SMOOTH);
801 for y := 0 to ol.height-1 do
802 begin
803 for sp in ol.eachSpanAtY(y) do
804 begin
805 if (g_dbg_scale <= 1.0) then
806 begin
807 glBegin(GL_POINTS);
808 glVertex2f(sx+sp.x0+0.375, sy+y+0.375);
809 glVertex2f(sx+sp.x1+0.375, sy+y+0.375);
810 glEnd();
811 end
812 else
813 begin
814 glBegin(GL_QUADS);
815 glVertex2f(sx+sp.x0+0, sy+y+0);
816 glVertex2f(sx+sp.x0+1, sy+y+0);
817 glVertex2f(sx+sp.x0+1, sy+y+1);
818 glVertex2f(sx+sp.x0+0, sy+y+1);
820 glVertex2f(sx+sp.x1+0, sy+y+0);
821 glVertex2f(sx+sp.x1+1, sy+y+0);
822 glVertex2f(sx+sp.x1+1, sy+y+1);
823 glVertex2f(sx+sp.x1+0, sy+y+1);
824 glEnd();
825 end;
826 end;
827 for sp in ol.eachSpanEdgeAtY(y, -1) do
828 begin
829 xline(sp.x0, sp.x1, y);
831 glBegin(GL_QUADS);
832 glVertex2f(sx+sp.x0+0, sy+y+0);
833 glVertex2f(sx+sp.x1+1, sy+y+0);
834 glVertex2f(sx+sp.x1+1, sy+y+1);
835 glVertex2f(sx+sp.x0+0, sy+y+1);
836 glEnd();
838 end;
839 for sp in ol.eachSpanEdgeAtY(y, +1) do
840 begin
841 xline(sp.x0, sp.x1, y);
843 glBegin(GL_QUADS);
844 glVertex2f(sx+sp.x0+0, sy+y+0);
845 glVertex2f(sx+sp.x1+1, sy+y+0);
846 glVertex2f(sx+sp.x1+1, sy+y+1);
847 glVertex2f(sx+sp.x0+0, sy+y+1);
848 glEnd();
850 end;
851 end;
852 end;
854 procedure doWallsOld (parr: array of TPanel; ptype: Word; ar, ag, ab: Integer);
855 var
856 f: Integer;
857 pan: TPanel;
858 begin
859 r := ar;
860 g := ag;
861 b := ab;
862 if g_ol_nice then clearOliner();
863 hlmContext.color := TGxRGBA.Create(r, g, b);
864 for f := 0 to High(parr) do
865 begin
866 pan := parr[f];
867 if (pan = nil) or not pan.Enabled or (pan.Width < 1) or (pan.Height < 1) then continue;
868 if ((pan.PanelType and ptype) = 0) then continue;
869 if (pan.X > vpx+vpw+41) or (pan.Y > vpy+vph+41) then continue;
870 if (pan.X+pan.Width < vpx-41) then continue;
871 if (pan.Y+pan.Height < vpy-41) then continue;
872 if g_ol_nice then
873 begin
874 oliner.addRect(pan.X-(vpx+1), pan.Y-(vpy+1), pan.Width, pan.Height);
875 end;
876 if g_ol_fill_walls then
877 begin
878 hlmContext.fillRect(pan.X, pan.Y, pan.Width, pan.Height);
879 end
880 else if not g_ol_nice then
881 begin
882 hlmContext.rect(pan.X, pan.Y, pan.Width, pan.Height);
883 end;
884 end;
885 if g_ol_nice then
886 begin
887 glColor4f(r/255.0, g/255.0, b/255.0, 1.0);
888 drawOutline(oliner, vpx+1, vpy+1);
889 end;
890 end;
892 begin
893 if (vpw < 2) or (vph < 2) then exit;
894 if g_ol_rlayer_back then doWallsOld(gRenderBackgrounds, PANEL_BACK, 255, 127, 0);
895 if g_ol_rlayer_step then doWallsOld(gSteps, PANEL_STEP, 192, 192, 192);
896 if g_ol_rlayer_wall then doWallsOld(gWalls, PANEL_WALL, 255, 255, 255);
897 if g_ol_rlayer_door then doWallsOld(gWalls, PANEL_OPENDOOR or PANEL_CLOSEDOOR, 0, 255, 0);
898 if g_ol_rlayer_acid1 then doWallsOld(gAcid1, PANEL_ACID1, 255, 0, 0);
899 if g_ol_rlayer_acid2 then doWallsOld(gAcid2, PANEL_ACID2, 198, 198, 0);
900 if g_ol_rlayer_water then doWallsOld(gWater, PANEL_WATER, 0, 255, 255);
901 if g_ol_rlayer_fore then doWallsOld(gRenderForegrounds, PANEL_FORE, 210, 210, 210);
902 end;
903 {$ENDIF}
906 procedure plrDebugDraw ();
907 procedure drawTileGrid ();
908 var
909 x, y: Integer;
910 begin
911 hlmContext.color := TGxRGBA.Create(96, 96, 96);
912 for y := 0 to (mapGrid.gridHeight div mapGrid.tileSize) do
913 begin
914 hlmContext.line(mapGrid.gridX0, mapGrid.gridY0+y*mapGrid.tileSize, mapGrid.gridX0+mapGrid.gridWidth, mapGrid.gridY0+y*mapGrid.tileSize);
915 end;
917 hlmContext.color := TGxRGBA.Create(96, 96, 96);
918 for x := 0 to (mapGrid.gridWidth div mapGrid.tileSize) do
919 begin
920 hlmContext.line(mapGrid.gridX0+x*mapGrid.tileSize, mapGrid.gridY0, mapGrid.gridX0+x*mapGrid.tileSize, mapGrid.gridY0+y*mapGrid.gridHeight);
921 end;
922 end;
924 procedure drawAwakeCells ();
925 var
926 x, y: Integer;
927 begin
928 hlmContext.color := TGxRGBA.Create(128, 0, 128, 64);
929 for y := 0 to (mapGrid.gridHeight div mapGrid.tileSize) do
930 begin
931 for x := 0 to (mapGrid.gridWidth div mapGrid.tileSize) do
932 begin
933 if awmIsSetHolmes(x*mapGrid.tileSize+mapGrid.gridX0+1, y*mapGrid.tileSize++mapGrid.gridY0+1) then
934 begin
935 hlmContext.fillRect(x*mapGrid.tileSize++mapGrid.gridX0, y*mapGrid.tileSize++mapGrid.gridY0, monsGrid.tileSize, monsGrid.tileSize);
936 end;
937 end;
938 end;
939 end;
941 procedure drawTraceBox ();
942 var
943 plr: TPlayer;
944 px, py, pw, ph: Integer;
945 pdx, pdy: Integer;
946 ex, ey: Integer;
947 pan: TPanel;
948 begin
949 if (Length(gPlayers) < 1) then exit;
950 plr := gPlayers[0];
951 if (plr = nil) then exit;
952 plr.getMapBox(px, py, pw, ph);
953 hlmContext.color := TGxRGBA.Create(255, 0, 255, 200);
954 hlmContext.rect(px, py, pw, ph);
955 pdx := pmsCurMapX-(px+pw div 2);
956 pdy := pmsCurMapY-(py+ph div 2);
957 hlmContext.color := TGxRGBA.Create(255, 0, 255, 200);
958 hlmContext.line(px+pw div 2, py+ph div 2, px+pw div 2+pdx, py+ph div 2+pdy);
959 pan := mapGrid.traceBox(ex, ey, px, py, pw, ph, pdx, pdy, GridTagObstacle);
960 if (pan = nil) then
961 begin
962 hlmContext.color := TGxRGBA.Create(255, 255, 255, 180);
963 hlmContext.rect(px+pdx, py+pdy, pw, ph);
964 end
965 else
966 begin
967 hlmContext.color := TGxRGBA.Create(255, 255, 0, 180);
968 hlmContext.rect(px+pdx, py+pdy, pw, ph);
969 end;
970 hlmContext.color := TGxRGBA.Create(255, 127, 0, 180);
971 hlmContext.rect(ex, ey, pw, ph);
972 end;
974 procedure hilightCell (cx, cy: Integer);
975 begin
976 hlmContext.color := TGxRGBA.Create(0, 128, 0, 64);
977 hlmContext.fillRect(cx, cy, monsGrid.tileSize, monsGrid.tileSize);
978 end;
980 procedure hilightBodyCells (proxyId: Integer);
981 var
982 it: CellCoordIter;
983 pcellxy: PGridCellCoord;
984 begin
985 //monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
986 it := monsGrid.forEachBodyCell(proxyId);
987 for pcellxy in it do hilightCell(pcellxy^.x, pcellxy^.y);
988 it.release();
989 end;
991 procedure hilightCell1 (cx, cy: Integer);
992 begin
993 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
994 cx := cx and (not (monsGrid.tileSize-1));
995 cy := cy and (not (monsGrid.tileSize-1));
996 hlmContext.color := TGxRGBA.Create(255, 255, 0, 92);
997 hlmContext.fillRect(cx, cy, monsGrid.tileSize, monsGrid.tileSize);
998 end;
1000 function hilightWallTrc (pan: TPanel; tag: Integer; x, y, prevx, prevy: Integer): Boolean;
1001 begin
1002 result := false; // don't stop
1003 if (pan = nil) then exit; // cell completion, ignore
1004 //e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
1005 hlmContext.color := TGxRGBA.Create(0, 128, 128, 64);
1006 hlmContext.fillRect(pan.X, pan.Y, pan.Width, pan.Height);
1007 end;
1009 procedure monsCollector (mon: TMonster);
1010 var
1011 ex, ey: Integer;
1012 mx, my, mw, mh: Integer;
1013 begin
1014 mon.getMapBox(mx, my, mw, mh);
1015 hlmContext.color := TGxRGBA.Create(255, 255, 0, 160);
1016 hlmContext.rect(mx, my, mw, mh);
1017 //e_DrawQuad(mx, my, mx+mw-1, my+mh-1, 255, 255, 0, 96);
1018 if lineAABBIntersects(laserX0, laserY0, laserX1, laserY1, mx, my, mw, mh, ex, ey) then
1019 begin
1020 //e_DrawPoint(8, ex, ey, 0, 255, 0);
1021 hlmContext.color := TGxRGBA.Create(0, 255, 0, 220);
1022 hlmContext.fillRect(ex-2, ey-2, 7, 7);
1023 end;
1024 end;
1026 procedure drawMonsterInfo (mon: TMonster);
1027 var
1028 mx, my, mw, mh: Integer;
1030 procedure drawMonsterTargetLine ();
1031 var
1032 emx, emy, emw, emh: Integer;
1033 enemy: TMonster;
1034 eplr: TPlayer;
1035 ex, ey: Integer;
1036 begin
1037 if (g_GetUIDType(mon.MonsterTargetUID) = UID_PLAYER) then
1038 begin
1039 eplr := g_Player_Get(mon.MonsterTargetUID);
1040 if (eplr <> nil) then eplr.getMapBox(emx, emy, emw, emh) else exit;
1041 end
1042 else if (g_GetUIDType(mon.MonsterTargetUID) = UID_MONSTER) then
1043 begin
1044 enemy := g_Monsters_ByUID(mon.MonsterTargetUID);
1045 if (enemy <> nil) then enemy.getMapBox(emx, emy, emw, emh) else exit;
1046 end
1047 else
1048 begin
1049 exit;
1050 end;
1051 mon.getMapBox(mx, my, mw, mh);
1052 hlmContext.color := TGxRGBA.Create(255, 0, 0);
1053 hlmContext.line(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2);
1054 if (g_Map_traceToNearestWall(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, @ex, @ey) <> nil) then
1055 begin
1056 hlmContext.color := TGxRGBA.Create(0, 255, 0);
1057 hlmContext.line(mx+mw div 2, my+mh div 2, ex, ey);
1058 end;
1059 end;
1061 procedure drawLOS2Plr ();
1062 var
1063 emx, emy, emw, emh: Integer;
1064 eplr: TPlayer;
1065 ex, ey: Integer;
1066 begin
1067 eplr := gPlayers[0];
1068 if (eplr = nil) then exit;
1069 eplr.getMapBox(emx, emy, emw, emh);
1070 mon.getMapBox(mx, my, mw, mh);
1071 hlmContext.color := TGxRGBA.Create(255, 0, 0);
1072 hlmContext.line(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2);
1073 {$IF DEFINED(D2F_DEBUG)}
1074 mapGrid.dbgRayTraceTileHitCB := hilightCell1;
1075 {$ENDIF}
1076 if (g_Map_traceToNearestWall(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, @ex, @ey) <> nil) then
1077 //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
1078 begin
1079 hlmContext.color := TGxRGBA.Create(0, 255, 0);
1080 hlmContext.line(mx+mw div 2, my+mh div 2, ex, ey);
1081 end;
1082 {$IF DEFINED(D2F_DEBUG)}
1083 mapGrid.dbgRayTraceTileHitCB := nil;
1084 {$ENDIF}
1085 end;
1087 begin
1088 if (mon = nil) then exit;
1089 mon.getMapBox(mx, my, mw, mh);
1090 //mx += mw div 2;
1092 //monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
1093 hilightBodyCells(mon.proxyId);
1095 if showMonsInfo then
1096 begin
1097 //fillRect(mx-4, my-7*8-6, 110, 7*8+6, 0, 0, 94, 250);
1098 hlmContext.font := 'msx6';
1099 hlmContext.color := TGxRGBA.Create(255, 127, 0);
1101 hlmContext.darkenRect(mx-4, my-7*hlmContext.charWidth(' ')-6, 110, 7*hlmContext.charWidth(' ')+6, 128);
1102 my -= 8;
1103 my -= 2;
1105 // type
1106 hlmContext.drawText(mx, my, Format('%s(U:%u)', [monsTypeToString(mon.MonsterType), mon.UID])); my -= hlmContext.charWidth(' ');
1107 // beh
1108 hlmContext.drawText(mx, my, Format('Beh: %s', [monsBehToString(mon.MonsterBehaviour)])); my -= hlmContext.charWidth(' ');
1109 // state
1110 hlmContext.drawText(mx, my, Format('State:%s (%d)', [monsStateToString(mon.MonsterState), mon.MonsterSleep])); my -= hlmContext.charWidth(' ');
1111 // health
1112 hlmContext.drawText(mx, my, Format('Health:%d', [mon.MonsterHealth])); my -= hlmContext.charWidth(' ');
1113 // ammo
1114 hlmContext.drawText(mx, my, Format('Ammo:%d', [mon.MonsterAmmo])); my -= hlmContext.charWidth(' ');
1115 // target
1116 hlmContext.drawText(mx, my, Format('TgtUID:%u', [mon.MonsterTargetUID])); my -= hlmContext.charWidth(' ');
1117 hlmContext.drawText(mx, my, Format('TgtTime:%d', [mon.MonsterTargetTime])); my -= hlmContext.charWidth(' ');
1118 end;
1120 drawMonsterTargetLine();
1121 if showMonsLOS2Plr then drawLOS2Plr();
1123 property MonsterRemoved: Boolean read FRemoved write FRemoved;
1124 property MonsterPain: Integer read FPain write FPain;
1125 property MonsterAnim: Byte read FCurAnim write FCurAnim;
1127 end;
1129 function highlightAllMonsterCells (mon: TMonster): Boolean;
1130 begin
1131 result := false; // don't stop
1132 //monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
1133 hilightBodyCells(mon.proxyId);
1134 end;
1136 procedure drawSelectedPlatformCells ();
1137 var
1138 pan: TPanel;
1139 begin
1140 if not showGrid then exit;
1141 pan := g_Map_PanelByGUID(platMarkedGUID);
1142 if (pan = nil) then exit;
1143 //mapGrid.forEachBodyCell(pan.proxyId, hilightCell);
1144 hilightBodyCells(pan.proxyId);
1145 hlmContext.color := TGxRGBA.Create(0, 200, 0, 200);
1146 hlmContext.rect(pan.x, pan.y, pan.width, pan.height);
1147 end;
1149 procedure drawTrigger (var trig: TTrigger);
1151 procedure drawPanelDest (pguid: Integer);
1152 var
1153 pan: TPanel;
1154 begin
1155 pan := g_Map_PanelByGUID(pguid);
1156 if (pan = nil) then exit;
1157 hlmContext.color := TGxRGBA.Create(255, 0, 255, 220);
1158 hlmContext.line(trig.trigCenter.x, trig.trigCenter.y, pan.x+pan.width div 2, pan.y+pan.height div 2);
1159 end;
1161 var
1162 tts: AnsiString;
1163 tx: Integer;
1164 begin
1165 hlmContext.font := 'msx6';
1166 hlmContext.color := TGxRGBA.Create(255, 0, 255, 96);
1167 hlmContext.fillRect(trig.x, trig.y, trig.width, trig.height);
1168 tts := trigType2Str(trig.TriggerType);
1169 tx := trig.x+(trig.width-Length(tts)*6) div 2;
1170 hlmContext.darkenRect(tx-2, trig.y-10, Length(tts)*6+4, 10, 64);
1171 hlmContext.color := TGxRGBA.Create(255, 127, 0);
1172 hlmContext.drawText(tx, trig.y-9, tts);
1173 tx := trig.x+(trig.width-Length(trig.mapId)*6) div 2;
1174 hlmContext.darkenRect(tx-2, trig.y-20, Length(trig.mapId)*6+4, 10, 64);
1175 hlmContext.color := TGxRGBA.Create(255, 255, 0);
1176 hlmContext.drawText(tx, trig.y-19, trig.mapId);
1177 drawPanelDest(trig.trigPanelGUID);
1178 case trig.TriggerType of
1179 TRIGGER_NONE: begin end;
1180 TRIGGER_EXIT: begin end;
1181 TRIGGER_TELEPORT: begin end;
1182 TRIGGER_OPENDOOR: begin end;
1183 TRIGGER_CLOSEDOOR: begin end;
1184 TRIGGER_DOOR: begin end;
1185 TRIGGER_DOOR5: begin end;
1186 TRIGGER_CLOSETRAP: begin end;
1187 TRIGGER_TRAP: begin end;
1188 TRIGGER_SECRET: begin end;
1189 TRIGGER_LIFTUP: begin end;
1190 TRIGGER_LIFTDOWN: begin end;
1191 TRIGGER_LIFT: begin end;
1192 TRIGGER_TEXTURE: begin end;
1193 TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF, TRIGGER_PRESS:
1194 begin
1195 if (trig.trigDataRec.trigTWidth > 0) and (trig.trigDataRec.trigTHeight > 0) then
1196 begin
1197 hlmContext.color := TGxRGBA.Create(0, 255, 255, 42);
1198 hlmContext.fillRect(
1199 trig.trigDataRec.trigTX, trig.trigDataRec.trigTY,
1200 trig.trigDataRec.trigTWidth, trig.trigDataRec.trigTHeight);
1201 hlmContext.color := TGxRGBA.Create(255, 0, 255, 220);
1202 hlmContext.line(
1203 trig.trigCenter.x, trig.trigCenter.y,
1204 trig.trigDataRec.trigTX+trig.trigDataRec.trigTWidth div 2,
1205 trig.trigDataRec.trigTY+trig.trigDataRec.trigTHeight div 2);
1206 end;
1207 end;
1208 TRIGGER_SOUND: begin end;
1209 TRIGGER_SPAWNMONSTER: begin end;
1210 TRIGGER_SPAWNITEM: begin end;
1211 TRIGGER_MUSIC: begin end;
1212 TRIGGER_PUSH: begin end;
1213 TRIGGER_SCORE: begin end;
1214 TRIGGER_MESSAGE: begin end;
1215 TRIGGER_DAMAGE: begin end;
1216 TRIGGER_HEALTH: begin end;
1217 TRIGGER_SHOT: begin end;
1218 TRIGGER_EFFECT: begin end;
1219 TRIGGER_SCRIPT: begin end;
1220 end;
1221 //trigType2Str
1222 //trigPanelId: Integer;
1223 end;
1225 procedure drawTriggers ();
1226 var
1227 f: Integer;
1228 begin
1229 for f := 0 to High(gTriggers) do drawTrigger(gTriggers[f]);
1230 end;
1232 procedure drawGibsBoxes ();
1233 var
1234 f: Integer;
1235 px, py, pw, ph: Integer;
1236 gib: PGib;
1237 begin
1238 for f := 0 to High(gGibs) do
1239 begin
1240 gib := @gGibs[f];
1241 if gib.alive then
1242 begin
1243 gib.getMapBox(px, py, pw, ph);
1244 hlmContext.color := TGxRGBA.Create(255, 0, 255);
1245 hlmContext.rect(px, py, pw, ph);
1246 end;
1247 end;
1248 end;
1250 var
1251 mon: TMonster;
1252 mit: PMonster;
1253 it: TMonsterGrid.Iter;
1254 mx, my, mw, mh: Integer;
1255 //pan: TPanel;
1256 //ex, ey: Integer;
1257 begin
1258 if (gPlayer1 = nil) then exit;
1260 if (hlmContext = nil) then hlmContext := TGxContext.Create();
1262 gxSetContext(hlmContext);
1263 try
1264 //glScissor(0, gWinSizeY-gPlayerScreenSize.Y-1, vpw, vph);
1265 //hlmContext.clip := TGxRect.Create(0, gScreenHeight-gPlayerScreenSize.Y-1, gPlayerScreenSize.X, gPlayerScreenSize.Y);
1268 glScalef(g_dbg_scale, g_dbg_scale, 1.0);
1269 glTranslatef(-vpx, -vpy, 0);
1271 hlmContext.glSetScaleTrans(g_dbg_scale, -vpx, -vpy);
1272 glEnable(GL_SCISSOR_TEST);
1273 glScissor(0, gScreenHeight-gPlayerScreenSize.Y-1, gPlayerScreenSize.X, gPlayerScreenSize.Y);
1275 if (showGrid) then drawTileGrid();
1276 drawOutlines();
1278 if (laserSet) then
1279 begin
1280 //g_Mons_AlongLine(laserX0, laserY0, laserX1, laserY1, monsCollector, true);
1281 it := monsGrid.forEachAlongLine(laserX0, laserY0, laserX1, laserY1, -1, true);
1282 for mit in it do monsCollector(mit^);
1283 it.release();
1284 end;
1286 if (monMarkedUID <> -1) then
1287 begin
1288 mon := g_Monsters_ByUID(monMarkedUID);
1289 if (mon <> nil) then
1290 begin
1291 mon.getMapBox(mx, my, mw, mh);
1292 //e_DrawQuad(mx, my, mx+mw-1, my+mh-1, 255, 0, 0, 30);
1293 hlmContext.color := TGxRGBA.Create(255, 0, 0, 220);
1294 hlmContext.rect(mx, my, mw, mh);
1295 drawMonsterInfo(mon);
1296 end;
1297 end;
1299 if showAllMonsCells and showGrid then g_Mons_ForEach(highlightAllMonsterCells);
1300 if showTriggers then drawTriggers();
1301 if showGrid then drawSelectedPlatformCells();
1303 //drawAwakeCells();
1305 if showTraceBox then drawTraceBox();
1307 //drawGibsBoxes();
1310 //pan := g_Map_traceToNearest(16, 608, 16, 8, (GridTagObstacle or GridTagLiquid), @ex, @ey);
1311 (*
1312 {$IF DEFINED(D2F_DEBUG)}
1313 mapGrid.dbgRayTraceTileHitCB := hilightCell1;
1314 {$ENDIF}
1315 pan := mapGrid.traceRay(ex, ey, 16, 608, 16, 8, nil, (GridTagObstacle or GridTagLiquid));
1316 if (pan <> nil) then writeln('end=(', ex, ',', ey, ')');
1317 {$IF DEFINED(D2F_DEBUG)}
1318 mapGrid.dbgRayTraceTileHitCB := nil;
1319 {$ENDIF}
1321 pan := g_Map_PanelAtPoint(16, 608, (GridTagObstacle or GridTagLiquid));
1322 if (pan <> nil) then writeln('hit!');
1323 *)
1325 finally
1326 gxSetContext(nil);
1327 end;
1329 if showMapCurPos then
1330 begin
1331 gxSetContext(hlmContext);
1332 hlmContext.font := 'win8';
1333 hlmContext.color := TGxRGBA.Create(255, 255, 0);
1334 hlmContext.drawText(4, gWinSizeY-10, Format('mappos:(%d,%d)', [pmsCurMapX, pmsCurMapY]));
1335 gxSetContext(nil);
1336 end;
1337 end;
1340 // ////////////////////////////////////////////////////////////////////////// //
1341 procedure onKeyEvent (var ev: TFUIEvent);
1342 {$IF DEFINED(D2F_DEBUG)}
1343 var
1344 pan: TPanel;
1345 ex, ey: Integer;
1346 dx, dy: Integer;
1347 {$ENDIF}
1349 procedure dummyWallTrc (cx, cy: Integer);
1350 begin
1351 end;
1353 begin
1354 // press
1355 if (ev.press) then
1356 begin
1357 {$IF DEFINED(D2F_DEBUG)}
1358 // C-UP, C-DOWN, C-LEFT, C-RIGHT: trace 10 pixels from cursor in the respective direction
1359 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
1360 ((ev.kstate and TFUIEvent.ModCtrl) <> 0) then
1361 begin
1362 ev.eat();
1363 dx := pmsCurMapX;
1364 dy := pmsCurMapY;
1365 case ev.scan of
1366 SDL_SCANCODE_UP: dy -= 120;
1367 SDL_SCANCODE_DOWN: dy += 120;
1368 SDL_SCANCODE_LEFT: dx -= 120;
1369 SDL_SCANCODE_RIGHT: dx += 120;
1370 end;
1371 {$IF DEFINED(D2F_DEBUG)}
1372 //mapGrid.dbgRayTraceTileHitCB := dummyWallTrc;
1373 mapGrid.dbgShowTraceLog := true;
1374 {$ENDIF}
1375 pan := g_Map_traceToNearest(pmsCurMapX, pmsCurMapY, dx, dy, (GridTagWall or GridTagDoor or GridTagStep or GridTagAcid1 or GridTagAcid2 or GridTagWater), @ex, @ey);
1376 {$IF DEFINED(D2F_DEBUG)}
1377 //mapGrid.dbgRayTraceTileHitCB := nil;
1378 mapGrid.dbgShowTraceLog := false;
1379 {$ENDIF}
1380 e_LogWritefln('v-trace: (%d,%d)-(%d,%d); end=(%d,%d); hit=%d', [pmsCurMapX, pmsCurMapY, dx, dy, ex, ey, (pan <> nil)]);
1381 exit;
1382 end;
1383 {$ENDIF}
1384 end;
1385 end;
1388 // ////////////////////////////////////////////////////////////////////////// //
1389 procedure g_Holmes_OnEvent (var ev: TFUIEvent);
1390 {$IF not DEFINED(HEADLESS)}
1391 var
1392 doeat: Boolean = false;
1393 {$ENDIF}
1394 begin
1395 {$IF not DEFINED(HEADLESS)}
1396 if g_Game_IsNet then exit;
1397 if not g_holmes_enabled then exit;
1398 if g_holmes_imfunctional then exit;
1400 holmesInitCommands();
1401 holmesInitBinds();
1403 msB := ev.bstate;
1404 kbS := ev.kstate;
1406 if (ev.key) then
1407 begin
1408 case ev.scan of
1409 SDL_SCANCODE_LCTRL, SDL_SCANCODE_RCTRL,
1410 SDL_SCANCODE_LALT, SDL_SCANCODE_RALT,
1411 SDL_SCANCODE_LSHIFT, SDL_SCANCODE_RSHIFT:
1412 doeat := true;
1413 end;
1414 end
1415 else if (ev.mouse) then
1416 begin
1417 msX := ev.x;
1418 msY := ev.y;
1419 msB := ev.bstate;
1420 kbS := ev.kstate;
1421 msB := msB;
1422 end;
1424 uiDispatchEvent(ev);
1425 if (not ev.alive) then exit;
1427 if (ev.mouse) then
1428 begin
1429 if (gPlayer1 <> nil) and (vpSet) then msbindExecute(ev);
1430 ev.eat();
1431 end
1432 else
1433 begin
1434 if keybindExecute(ev) then ev.eat();
1435 if (ev.alive) then onKeyEvent(ev);
1436 end;
1438 if (doeat) then ev.eat();
1439 {$ENDIF}
1440 end;
1443 // ////////////////////////////////////////////////////////////////////////// //
1444 procedure g_Holmes_Draw ();
1445 begin
1446 if g_Game_IsNet then exit;
1447 if not g_holmes_enabled then exit;
1448 if g_holmes_imfunctional then exit;
1450 {$IF not DEFINED(HEADLESS)}
1451 holmesInitCommands();
1452 holmesInitBinds();
1454 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
1455 glDisable(GL_STENCIL_TEST);
1456 glDisable(GL_BLEND);
1457 glDisable(GL_SCISSOR_TEST);
1458 glDisable(GL_TEXTURE_2D);
1460 if gGameOn then plrDebugDraw();
1461 {$ENDIF}
1463 laserSet := false;
1464 end;
1467 procedure g_Holmes_DrawUI ();
1468 begin
1469 if g_Game_IsNet then exit;
1470 if not g_holmes_enabled then exit;
1471 if g_holmes_imfunctional then exit;
1473 {$IF not DEFINED(HEADLESS)}
1474 gGfxDoClear := false;
1475 //if assigned(prerenderFrameCB) then prerenderFrameCB();
1476 uiDraw();
1477 glMatrixMode(GL_MODELVIEW);
1478 glPushMatrix();
1479 try
1480 //glLoadIdentity();
1481 if assigned(postrenderFrameCB) then postrenderFrameCB();
1482 finally
1483 glPopMatrix();
1484 end;
1485 {$ENDIF}
1486 end;
1489 // ////////////////////////////////////////////////////////////////////////// //
1490 procedure bcOneMonsterThinkStep (); begin gmon_debug_think := false; gmon_debug_one_think_step := true; end;
1491 procedure bcOneMPlatThinkStep (); begin g_dbgpan_mplat_active := false; g_dbgpan_mplat_step := true; end;
1492 procedure bcMPlatToggle (); begin g_dbgpan_mplat_active := not g_dbgpan_mplat_active; end;
1494 procedure bcToggleMonsterInfo (arg: Integer=-1); begin if (arg < 0) then showMonsInfo := not showMonsInfo else showMonsInfo := (arg > 0); end;
1495 procedure bcToggleMonsterLOSPlr (arg: Integer=-1); begin if (arg < 0) then showMonsLOS2Plr := not showMonsLOS2Plr else showMonsLOS2Plr := (arg > 0); end;
1496 procedure bcToggleMonsterCells (arg: Integer=-1); begin if (arg < 0) then showAllMonsCells := not showAllMonsCells else showAllMonsCells := (arg > 0); end;
1497 procedure bcToggleDrawTriggers (arg: Integer=-1); begin if (arg < 0) then showTriggers := not showTriggers else showTriggers := (arg > 0); end;
1499 procedure bcToggleCurPos (arg: Integer=-1); begin if (arg < 0) then showMapCurPos := not showMapCurPos else showMapCurPos := (arg > 0); end;
1500 procedure bcToggleGrid (arg: Integer=-1); begin if (arg < 0) then showGrid := not showGrid else showGrid := (arg > 0); end;
1502 procedure bcMonsterSpawn (s: AnsiString);
1503 var
1504 mon: TMonster;
1505 begin
1506 if not gGameOn or g_Game_IsClient then
1507 begin
1508 conwriteln('cannot spawn monster in this mode');
1509 exit;
1510 end;
1511 mon := g_Mons_SpawnAt(s, pmsCurMapX, pmsCurMapY);
1512 if (mon = nil) then begin conwritefln('unknown monster id: ''%s''', [s]); exit; end;
1513 monMarkedUID := mon.UID;
1514 end;
1516 procedure bcMonsterWakeup ();
1517 var
1518 mon: TMonster;
1519 begin
1520 if (monMarkedUID <> -1) then
1521 begin
1522 mon := g_Monsters_ByUID(monMarkedUID);
1523 if (mon <> nil) then mon.WakeUp();
1524 end;
1525 end;
1527 procedure bcPlayerTeleport ();
1528 var
1529 x, y, w, h: Integer;
1530 begin
1531 //e_WriteLog(Format('TELEPORT: (%d,%d)', [pmsCurMapX, pmsCurMapY]), MSG_NOTIFY);
1532 if (gPlayers[0] <> nil) then
1533 begin
1534 gPlayers[0].getMapBox(x, y, w, h);
1535 gPlayers[0].TeleportTo(pmsCurMapX-w div 2, pmsCurMapY-h div 2, true, 69); // 69: don't change dir
1536 end;
1537 end;
1539 procedure dbgToggleTraceBox (arg: Integer=-1); begin if (arg < 0) then showTraceBox := not showTraceBox else showTraceBox := (arg > 0); end;
1541 procedure dbgToggleHolmesPause (arg: Integer=-1); begin if (arg < 0) then g_Game_HolmesPause(not gPauseHolmes) else g_Game_HolmesPause(arg > 0); end;
1543 procedure cbAtcurSelectMonster ();
1544 function monsAtDump (mon: TMonster{; tag: Integer}): Boolean;
1545 begin
1546 result := true; // stop
1547 e_WriteLog(Format('monster #%d (UID:%u) (proxyid:%d)', [mon.arrIdx, mon.UID, mon.proxyId]), TMsgType.Notify);
1548 monMarkedUID := mon.UID;
1549 dumpPublishedProperties(mon);
1550 end;
1551 var
1552 plr: TPlayer;
1553 x, y, w, h: Integer;
1554 mit: PMonster;
1555 it: TMonsterGrid.Iter;
1556 begin
1557 monMarkedUID := -1;
1558 if (Length(gPlayers) > 0) then
1559 begin
1560 plr := gPlayers[0];
1561 if (plr <> nil) then
1562 begin
1563 plr.getMapBox(x, y, w, h);
1564 if (pmsCurMapX >= x) and (pmsCurMapY >= y) and (pmsCurMapX < x+w) and (pmsCurMapY < y+h) then
1565 begin
1566 dumpPublishedProperties(plr);
1567 end;
1568 end;
1569 end;
1570 //e_WriteLog('===========================', MSG_NOTIFY);
1571 it := monsGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY);
1572 for mit in it do monsAtDump(mit^);
1573 it.release();
1574 //e_WriteLog('---------------------------', MSG_NOTIFY);
1575 end;
1577 procedure cbAtcurDumpMonsters ();
1578 function monsAtDump (mon: TMonster{; tag: Integer}): Boolean;
1579 begin
1580 result := false; // don't stop
1581 e_WriteLog(Format('monster #%d (UID:%u) (proxyid:%d)', [mon.arrIdx, mon.UID, mon.proxyId]), TMsgType.Notify);
1582 end;
1583 var
1584 mit: PMonster;
1585 it: TMonsterGrid.Iter;
1586 begin
1587 it := monsGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY);
1588 if (it.length > 0) then
1589 begin
1590 e_WriteLog('===========================', TMsgType.Notify);
1591 for mit in it do monsAtDump(mit^);
1592 e_WriteLog('---------------------------', TMsgType.Notify);
1593 end;
1594 it.release();
1595 end;
1597 procedure cbAtcurDumpWalls ();
1598 function wallToggle (pan: TPanel{; tag: Integer}): Boolean;
1599 begin
1600 result := false; // don't stop
1601 if (platMarkedGUID = -1) then platMarkedGUID := pan.guid;
1602 e_LogWritefln('wall ''%s'' #%d(%d); enabled=%d (%d); (%d,%d)-(%d,%d)', [pan.mapId, pan.arrIdx, pan.proxyId, Integer(pan.Enabled), Integer(mapGrid.proxyEnabled[pan.proxyId]), pan.X, pan.Y, pan.Width, pan.Height]);
1603 dumpPublishedProperties(pan);
1604 end;
1605 var
1606 hasTrigs: Boolean = false;
1607 f: Integer;
1608 trig: PTrigger;
1609 mwit: PPanel;
1610 it: TPanelGrid.Iter;
1611 begin
1612 platMarkedGUID := -1;
1613 it := mapGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY, (GridTagWall or GridTagDoor));
1614 if (it.length > 0) then
1615 begin
1616 e_WriteLog('=== TOGGLE WALL ===', TMsgType.Notify);
1617 for mwit in it do wallToggle(mwit^);
1618 e_WriteLog('--- toggle wall ---', TMsgType.Notify);
1619 end;
1620 it.release();
1621 if showTriggers then
1622 begin
1623 for f := 0 to High(gTriggers) do
1624 begin
1625 trig := @gTriggers[f];
1626 if (pmsCurMapX >= trig.x) and (pmsCurMapY >= trig.y) and (pmsCurMapX < trig.x+trig.width) and (pmsCurMapY < trig.y+trig.height) then
1627 begin
1628 if not hasTrigs then begin writeln('=== TRIGGERS ==='); hasTrigs := true; end;
1629 writeln('trigger ''', trig.mapId, ''' of type ''', trigType2Str(trig.TriggerType), '''');
1630 end;
1631 end;
1632 if hasTrigs then writeln('--- triggers ---');
1633 end;
1634 end;
1636 procedure cbAtcurToggleWalls ();
1637 function wallToggle (pan: TPanel{; tag: Integer}): Boolean;
1638 begin
1639 result := false; // don't stop
1640 //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);
1641 if pan.Enabled then g_Map_DisableWallGUID(pan.guid) else g_Map_EnableWallGUID(pan.guid);
1642 end;
1643 var
1644 mwit: PPanel;
1645 it: TPanelGrid.Iter;
1646 begin
1647 //e_WriteLog('=== TOGGLE WALL ===', MSG_NOTIFY);
1648 //e_WriteLog('--- toggle wall ---', MSG_NOTIFY);
1649 it := mapGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY, (GridTagWall or GridTagDoor));
1650 for mwit in it do wallToggle(mwit^);
1651 it.release();
1652 end;
1655 // ////////////////////////////////////////////////////////////////////////// //
1656 procedure holmesInitCommands ();
1657 begin
1658 if (cmdlist <> nil) then exit;
1659 cmdAdd('win_layers', toggleLayersWindow, 'toggle layers window', 'window control');
1660 cmdAdd('win_outline', toggleOutlineWindow, 'toggle outline window', 'window control');
1661 cmdAdd('win_help', toggleHelpWindow, 'toggle help window', 'window control');
1662 cmdAdd('win_options', toggleOptionsWindow, 'toggle options window', 'window control');
1664 cmdAdd('mon_think_step', bcOneMonsterThinkStep, 'one monster think step', 'monster control');
1665 cmdAdd('mon_info', bcToggleMonsterInfo, 'toggle monster info', 'monster control');
1666 cmdAdd('mon_los_plr', bcToggleMonsterLOSPlr, 'toggle monster LOS to player', 'monster control');
1667 cmdAdd('mon_cells', bcToggleMonsterCells, 'toggle "show all cells occupied by monsters" (SLOW!)', 'monster control');
1668 cmdAdd('mon_wakeup', bcMonsterWakeup, 'wake up selected monster', 'monster control');
1670 cmdAdd('mon_spawn', bcMonsterSpawn, 'spawn monster', 'monster control');
1672 cmdAdd('mplat_step', bcOneMPlatThinkStep, 'one mplat think step', 'mplat control');
1673 cmdAdd('mplat_toggle', bcMPlatToggle, 'activate/deactivate moving platforms', 'mplat control');
1675 cmdAdd('plr_teleport', bcPlayerTeleport, 'teleport player', 'player control');
1677 cmdAdd('dbg_curpos', bcToggleCurPos, 'toggle "show cursor position on the map"', 'various');
1678 cmdAdd('dbg_grid', bcToggleGrid, 'toggle grid', 'various');
1679 cmdAdd('dbg_triggers', bcToggleDrawTriggers, 'show/hide triggers (SLOW!)', 'various');
1681 cmdAdd('atcur_select_monster', cbAtcurSelectMonster, 'select monster to operate', 'monster control');
1682 cmdAdd('atcur_dump_monsters', cbAtcurDumpMonsters, 'dump monsters in cell', 'monster control');
1683 cmdAdd('atcur_dump_walls', cbAtcurDumpWalls, 'dump walls in cell', 'wall control');
1684 cmdAdd('atcur_disable_walls', cbAtcurToggleWalls, 'disable walls', 'wall control');
1686 cmdAdd('dbg_tracebox', dbgToggleTraceBox, 'test traceBox()', 'player control');
1688 cmdAdd('hlm_pause', dbgToggleHolmesPause, '"Holmes" pause mode', 'game control');
1689 end;
1692 procedure holmesInitBinds ();
1693 var
1694 st: TStream = nil;
1695 pr: TTextParser = nil;
1696 s, kn, v: AnsiString;
1697 kmods: Byte;
1698 mbuts: Byte;
1699 begin
1700 kbS := kbS;
1701 if not keybindsInited then
1702 begin
1703 // keyboard
1704 keybindAdd('F1', 'win_help');
1705 keybindAdd('M-F1', 'win_options');
1706 keybindAdd('C-O', 'win_outline');
1707 keybindAdd('C-L', 'win_layers');
1709 keybindAdd('M-M', 'mon_think_step');
1710 keybindAdd('M-I', 'mon_info');
1711 keybindAdd('M-L', 'mon_los_plr');
1712 keybindAdd('M-G', 'mon_cells');
1713 keybindAdd('M-A', 'mon_wakeup');
1715 keybindAdd('M-P', 'mplat_step');
1716 keybindAdd('M-O', 'mplat_toggle');
1718 keybindAdd('C-T', 'plr_teleport');
1719 keybindAdd('M-T', 'dbg_tracebox');
1721 keybindAdd('C-P', 'dbg_curpos');
1722 keybindAdd('C-G', 'dbg_grid');
1723 keybindAdd('C-X', 'dbg_triggers');
1725 keybindAdd('C-1', 'mon_spawn zombie');
1727 keybindAdd('C-S-P', 'hlm_pause');
1729 // mouse
1730 msbindAdd('LMB', 'atcur_select_monster');
1731 msbindAdd('M-LMB', 'atcur_dump_monsters');
1732 msbindAdd('RMB', 'atcur_dump_walls');
1733 msbindAdd('M-RMB', 'atcur_disable_walls');
1735 // load bindings from file
1736 try
1737 st := openDiskFileRO(GameDir+'holmes.rc');
1738 pr := TFileTextParser.Create(st);
1739 conwriteln('parsing "holmes.rc"...');
1740 while (pr.tokType <> pr.TTEOF) do
1741 begin
1742 s := pr.expectId();
1743 if (s = 'stop') then break
1744 else if (s = 'unbind_keys') then keybinds := nil
1745 else if (s = 'unbind_mouse') then msbinds := nil
1746 else if (s = 'bind') then
1747 begin
1748 if (pr.tokType = pr.TTStr) then s := pr.expectStr(false)
1749 else if (pr.tokType = pr.TTInt) then s := Format('%d', [pr.expectInt()])
1750 else s := pr.expectId();
1752 if (pr.tokType = pr.TTStr) then v := pr.expectStr(false)
1753 else if (pr.tokType = pr.TTInt) then v := Format('%d', [pr.expectInt()])
1754 else v := pr.expectId();
1756 kn := parseModKeys(s, kmods, mbuts);
1757 if (CompareText(kn, 'lmb') = 0) or (CompareText(kn, 'rmb') = 0) or (CompareText(kn, 'mmb') = 0) or (CompareText(kn, 'None') = 0) then
1758 begin
1759 msbindAdd(s, v);
1760 end
1761 else
1762 begin
1763 keybindAdd(s, v);
1764 end;
1765 end;
1766 end;
1767 except on e: Exception do // sorry
1768 if (pr <> nil) then conwritefln('Holmes config parse error at (%s,%s): %s', [pr.tokLine, pr.tokCol, e.message]);
1769 end;
1770 if (pr <> nil) then pr.Free() else st.Free(); // ownership
1771 end;
1772 end;
1775 begin
1776 // shut up, fpc!
1777 msB := msB;
1778 vpSet := vpSet;
1780 fuiEventCB := g_Holmes_OnEvent;
1781 //uiContext.font := 'win14';
1783 conRegVar('hlm_ui_scale', @fuiRenderScale, 0.01, 5.0, 'Holmes UI scale', '', false);
1784 end.