DEADSOFTWARE

"hlm_ui_scale" convar; "--holmes_ui_scale" cli arg; (fgsfds request)
[d2df-sdl.git] / src / game / g_holmes.pas
index 23c4b13d16ee07817d48508006086f0d16661c82..9f98ca3172d7c9588605a5d5115aebe4db45f114 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,14 @@ var
   msY: Integer = -666;
   msB: Word = 0; // button state
   kbS: Word = 0; // keyboard modifiers state
-  showGrid: Boolean = true;
+  showGrid: Boolean = false;
   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}
@@ -1041,12 +1042,12 @@ procedure plrDebugDraw ();
 
   procedure drawTrigger (var trig: TTrigger);
 
-    procedure drawPanelDest (var parr: TPanelArray; idx: Integer);
+    procedure drawPanelDest (pguid: Integer);
     var
       pan: TPanel;
     begin
-      if (idx < 0) or (idx >= Length(parr)) then exit;
-      pan := parr[idx];
+      pan := g_Map_PanelByGUID(pguid);
+      if (pan = nil) then exit;
       drawLine(
         trig.trigCenter.x, trig.trigCenter.y,
         pan.x+pan.width div 2, pan.y+pan.height div 2,
@@ -1065,32 +1066,36 @@ procedure plrDebugDraw ();
     tx := trig.x+(trig.width-Length(trig.mapId)*6) div 2;
     darkenRect(tx-2, trig.y-20, Length(trig.mapId)*6+4, 10, 64);
     drawText6(tx, trig.y-19, trig.mapId, 255, 255, 0);
+    drawPanelDest(trig.trigPanelGUID);
     case trig.TriggerType of
       TRIGGER_NONE: begin end;
       TRIGGER_EXIT: begin end;
       TRIGGER_TELEPORT: begin end;
-      TRIGGER_OPENDOOR: begin drawPanelDest(gWalls, trig.trigPanelId); end;
-      TRIGGER_CLOSEDOOR: begin drawPanelDest(gWalls, trig.trigPanelId); end;
-      TRIGGER_DOOR: begin drawPanelDest(gWalls, trig.trigPanelId); end;
-      TRIGGER_DOOR5: begin drawPanelDest(gWalls, trig.trigPanelId); end;
-      TRIGGER_CLOSETRAP: begin drawPanelDest(gWalls, trig.trigPanelId); end;
-      TRIGGER_TRAP: begin drawPanelDest(gWalls, trig.trigPanelId); end;
+      TRIGGER_OPENDOOR: begin end;
+      TRIGGER_CLOSEDOOR: begin end;
+      TRIGGER_DOOR: begin end;
+      TRIGGER_DOOR5: begin end;
+      TRIGGER_CLOSETRAP: begin end;
+      TRIGGER_TRAP: begin end;
       TRIGGER_SECRET: begin end;
-      TRIGGER_LIFTUP: begin drawPanelDest(gLifts, trig.trigPanelId); end;
-      TRIGGER_LIFTDOWN: begin drawPanelDest(gLifts, trig.trigPanelId); end;
-      TRIGGER_LIFT: begin drawPanelDest(gLifts, trig.trigPanelId); end;
+      TRIGGER_LIFTUP: begin end;
+      TRIGGER_LIFTDOWN: begin end;
+      TRIGGER_LIFT: begin end;
       TRIGGER_TEXTURE: begin end;
       TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF, TRIGGER_PRESS:
         begin
-        fillRect(
-          trig.trigData.trigTX, trig.trigData.trigTY,
-          trig.trigData.trigTWidth, trig.trigData.trigTHeight,
-          0, 255, 255, 42);
-        drawLine(
-          trig.trigCenter.x, trig.trigCenter.y,
-          trig.trigData.trigTX+trig.trigData.trigTWidth div 2,
-          trig.trigData.trigTY+trig.trigData.trigTHeight div 2,
-          255, 0, 255, 220);
+          if (trig.trigData.trigTWidth > 0) and (trig.trigData.trigTHeight > 0) then
+          begin
+            fillRect(
+              trig.trigData.trigTX, trig.trigData.trigTY,
+              trig.trigData.trigTWidth, trig.trigData.trigTHeight,
+              0, 255, 255, 42);
+            drawLine(
+              trig.trigCenter.x, trig.trigCenter.y,
+              trig.trigData.trigTX+trig.trigData.trigTWidth div 2,
+              trig.trigData.trigTY+trig.trigData.trigTHeight div 2,
+              255, 0, 255, 220);
+          end;
         end;
       TRIGGER_SOUND: begin end;
       TRIGGER_SPAWNMONSTER: begin end;
@@ -1158,16 +1163,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;
 
 
@@ -1258,8 +1268,11 @@ 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;
 
@@ -1374,7 +1387,7 @@ procedure cbAtcurToggleWalls ();
   begin
     result := false; // don't stop
     //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);
-    if pan.Enabled then g_Map_DisableWall(pan.arrIdx) else g_Map_EnableWall(pan.arrIdx);
+    if pan.Enabled then g_Map_DisableWallGUID(pan.guid) else g_Map_EnableWallGUID(pan.guid);
   end;
 begin
   //e_WriteLog('=== TOGGLE WALL ===', MSG_NOTIFY);
@@ -1486,4 +1499,6 @@ begin
 end;
 
 
+begin
+  conRegVar('hlm_ui_scale', @g_holmes_ui_scale, 0.01, 5.0, 'Holmes UI scale', '', false);
 end.