DEADSOFTWARE

Holmes: option to highlight panel cells in grid
[d2df-sdl.git] / src / game / g_holmes.pas
index 2f643136c929aa4ab98848e0f5398ce34de69735..a534e7a3919ec48467373a5df82975b55632ed91 100644 (file)
@@ -96,6 +96,7 @@ operator = (const s: AnsiString; constref ev: THMouseEvent): Boolean;
 
 var
   g_holmes_enabled: Boolean = {$IF DEFINED(D2F_DEBUG)}true{$ELSE}false{$ENDIF};
+  g_holmes_ui_scale: Single = 1.0;
 
 
 implementation
@@ -113,14 +114,15 @@ var
   msY: Integer = -666;
   msB: Word = 0; // button state
   kbS: Word = 0; // keyboard modifiers state
-  showGrid: Boolean = true;
+  showGrid: Boolean = {$IF DEFINED(D2F_DEBUG)}true{$ELSE}false{$ENDIF};
   showMonsInfo: Boolean = false;
   showMonsLOS2Plr: Boolean = false;
   showAllMonsCells: Boolean = false;
   showMapCurPos: Boolean = false;
   showLayersWindow: Boolean = false;
   showOutlineWindow: Boolean = false;
-  showTriggers: Boolean = {$IF DEFINED(D2F_DEBUG)}true{$ELSE}false{$ENDIF};
+  showTriggers: Boolean = {$IF DEFINED(D2F_DEBUG)}false{$ELSE}false{$ENDIF};
+
 
 // ////////////////////////////////////////////////////////////////////////// //
 {$INCLUDE g_holmes.inc}
@@ -650,6 +652,7 @@ var
   laserSet: Boolean = false;
   laserX0, laserY0, laserX1, laserY1: Integer;
   monMarkedUID: Integer = -1;
+  platMarkedGUID: Integer = -1;
 
 
 procedure g_Holmes_plrView (viewPortX, viewPortY, viewPortW, viewPortH: Integer);
@@ -1039,6 +1042,17 @@ procedure plrDebugDraw ();
     monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
   end;
 
+  procedure drawSelectedPlatformCells ();
+  var
+    pan: TPanel;
+  begin
+    if not showGrid then exit;
+    pan := g_Map_PanelByGUID(platMarkedGUID);
+    if (pan = nil) then exit;
+    mapGrid.forEachBodyCell(pan.proxyId, hilightCell);
+    drawRect(pan.x, pan.y, pan.width, pan.height, 0, 200, 0, 200);
+  end;
+
   procedure drawTrigger (var trig: TTrigger);
 
     procedure drawPanelDest (pguid: Integer);
@@ -1149,8 +1163,9 @@ begin
     end;
   end;
 
-  if showAllMonsCells then g_Mons_ForEach(highlightAllMonsterCells);
+  if showAllMonsCells and showGrid then g_Mons_ForEach(highlightAllMonsterCells);
   if showTriggers then drawTriggers();
+  if showGrid then drawSelectedPlatformCells();
 
   glPopMatrix();
 
@@ -1162,16 +1177,21 @@ end;
 
 // ////////////////////////////////////////////////////////////////////////// //
 function g_Holmes_MouseEvent (var ev: THMouseEvent): Boolean;
+var
+  he: THMouseEvent;
 begin
   holmesInitCommands();
   holmesInitBinds();
   result := true;
-  msX := ev.x;
-  msY := ev.y;
+  msX := trunc(ev.x/g_holmes_ui_scale);
+  msY := trunc(ev.y/g_holmes_ui_scale);
   msB := ev.bstate;
   kbS := ev.kstate;
   msB := msB;
-  if not uiMouseEvent(ev) then plrDebugMouse(ev);
+  he := ev;
+  he.x := trunc(he.x/g_holmes_ui_scale);
+  he.y := trunc(he.y/g_holmes_ui_scale);
+  if not uiMouseEvent(he) then plrDebugMouse(he);
 end;
 
 
@@ -1262,14 +1282,20 @@ end;
 procedure g_Holmes_DrawUI ();
 begin
   {$IF not DEFINED(HEADLESS)}
+  glPushMatrix();
+  glScalef(g_holmes_ui_scale, g_holmes_ui_scale, 1.0);
   uiDraw();
   drawCursor();
+  glPopMatrix();
   {$ENDIF}
 end;
 
 
 // ////////////////////////////////////////////////////////////////////////// //
 procedure bcOneMonsterThinkStep (); begin gmon_debug_think := false; gmon_debug_one_think_step := true; end;
+procedure bcOneMPlatThinkStep (); begin g_dbgpan_mplat_active := false; g_dbgpan_mplat_step := true; end;
+procedure bcMPlatToggle (); begin g_dbgpan_mplat_active := not g_dbgpan_mplat_active; end;
+
 procedure bcToggleMonsterInfo (arg: Integer=-1); begin if (arg < 0) then showMonsInfo := not showMonsInfo else showMonsInfo := (arg > 0); end;
 procedure bcToggleMonsterLOSPlr (arg: Integer=-1); begin if (arg < 0) then showMonsLOS2Plr := not showMonsLOS2Plr else showMonsLOS2Plr := (arg > 0); end;
 procedure bcToggleMonsterCells (arg: Integer=-1); begin if (arg < 0) then showAllMonsCells := not showAllMonsCells else showAllMonsCells := (arg > 0); end;
@@ -1347,6 +1373,7 @@ procedure cbAtcurDumpWalls ();
   function wallToggle (pan: TPanel; tag: Integer): Boolean;
   begin
     result := false; // don't stop
+    if (platMarkedGUID = -1) then platMarkedGUID := pan.guid;
     e_LogWritefln('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]);
     dumpPublishedProperties(pan);
   end;
@@ -1355,6 +1382,7 @@ var
   f: Integer;
   trig: PTrigger;
 begin
+  platMarkedGUID := -1;
   e_WriteLog('=== TOGGLE WALL ===', MSG_NOTIFY);
   mapGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY, wallToggle, (GridTagWall or GridTagDoor));
   e_WriteLog('--- toggle wall ---', MSG_NOTIFY);
@@ -1402,6 +1430,9 @@ begin
   cmdAdd('mon_cells', bcToggleMonsterCells, 'toggle "show all cells occupied by monsters" (SLOW!)', 'monster control');
   cmdAdd('mon_wakeup', bcMonsterWakeup, 'toggle "show all cells occupied by monsters" (SLOW!)', 'monster control');
 
+  cmdAdd('mplat_step', bcOneMPlatThinkStep, 'one mplat think step', 'mplat control');
+  cmdAdd('mplat_toggle', bcMPlatToggle, 'activate/deactivate moving platforms', 'mplat control');
+
   cmdAdd('plr_teleport', bcPlayerTeleport, 'teleport player', 'player control');
 
   cmdAdd('dbg_curpos', bcToggleCurPos, 'toggle "show cursor position on the map"', 'various');
@@ -1438,6 +1469,9 @@ begin
     keybindAdd('M-G', 'mon_cells');
     keybindAdd('M-A', 'mon_wakeup');
 
+    keybindAdd('M-P', 'mplat_step');
+    keybindAdd('M-O', 'mplat_toggle');
+
     keybindAdd('C-T', 'plr_teleport');
 
     keybindAdd('C-P', 'dbg_curpos');
@@ -1490,4 +1524,6 @@ begin
 end;
 
 
+begin
+  conRegVar('hlm_ui_scale', @g_holmes_ui_scale, 0.01, 5.0, 'Holmes UI scale', '', false);
 end.