DEADSOFTWARE

the game is able to read text maps now (WARNING! the feature is still experimental!)
[d2df-sdl.git] / src / game / g_game.pas
index 24f6324b56bc27a00db40c43d9dce0f735cfc26b..93368940da0d943a1223f77191f923c7432b5bfd 100644 (file)
@@ -315,6 +315,15 @@ var
   g_profile_los: Boolean = false;
   g_profile_history_size: Integer = 1000;
 
+  g_rlayer_back: Boolean = true;
+  g_rlayer_step: Boolean = true;
+  g_rlayer_wall: Boolean = true;
+  g_rlayer_door: Boolean = true;
+  g_rlayer_acid1: Boolean = true;
+  g_rlayer_acid2: Boolean = true;
+  g_rlayer_water: Boolean = true;
+  g_rlayer_fore: Boolean = true;
+
 
 procedure g_ResetDynlights ();
 procedure g_AddDynLight (x, y, radius: Integer; r, g, b, a: Single);
@@ -451,7 +460,8 @@ begin
   if (y < 0) then y := gScreenHeight-(hgt-1)+y;
   // background
   //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
-  e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
+  //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
+  e_DarkenQuadWH(x, y, wdt, hgt, 150);
   // title
   yy := y+2;
   for ii := 0 to High(prof.bars) do
@@ -982,6 +992,17 @@ begin
     gExit := 0;
 end;
 
+procedure drawTime(X, Y: Integer); inline;
+begin
+  e_TextureFontPrint(x, y,
+                     Format('%d:%.2d:%.2d', [
+                       gTime div 1000 div 3600,
+                       (gTime div 1000 div 60) mod 60,
+                       gTime div 1000 mod 60
+                     ]),
+                     gStdFont);
+end;
+
 procedure DrawStat();
 var
   pc, x, y, w, h: Integer;
@@ -1011,6 +1032,8 @@ begin
   e_DrawFillQuad(x, y, x+w-1, y+h-1, 64, 64, 64, 32);
   e_DrawQuad(x, y, x+w-1, y+h-1, 255, 127, 0);
 
+  drawTime(x+w-78, y+8);
+
   wad := g_ExtractWadNameNoPath(gMapInfo.Map);
   map := g_ExtractFileName(gMapInfo.Map);
   mapstr := wad + ':\' + map + ' - ' + gMapInfo.Name;
@@ -1967,7 +1990,11 @@ begin
     UPSTime := Time;
   end;
 
-  if gGameOn then g_Weapon_AddDynLights();
+  if gGameOn then
+  begin
+    g_Weapon_AddDynLights();
+    g_Items_AddDynLights();
+  end;
 end;
 
 procedure g_Game_LoadData();
@@ -2687,6 +2714,7 @@ begin
     if ly-sY-lrad >= gPlayerScreenSize.Y then continue;
 
     // set scissor to optimize drawing
+    //FIXME: broken for splitscreen mode
     glScissor((lx-sX)-lrad+2, gPlayerScreenSize.Y-(ly-sY)-lrad-1+2, lrad*2-4, lrad*2-4);
     // no need to clear stencil buffer, light blitting will do it for us
     glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
@@ -2727,7 +2755,7 @@ procedure renderMapInternal (backXOfs, backYOfs: Integer; transX, transY: Intege
 type
   TDrawCB = procedure ();
 
-  procedure drawPanelType (profname: AnsiString; panType: DWord);
+  procedure drawPanelType (profname: AnsiString; panType: DWord; doDraw: Boolean);
   var
     tagmask: Integer;
     pan: TPanel;
@@ -2736,28 +2764,17 @@ type
     if gdbg_map_use_accel_render then
     begin
       tagmask := panelTypeToTag(panType);
-      {$IF TRUE}
       while (gDrawPanelList.count > 0) do
       begin
         pan := TPanel(gDrawPanelList.front());
         if ((pan.tag and tagmask) = 0) then break;
-        pan.Draw();
+        if doDraw then pan.Draw();
         gDrawPanelList.popFront();
       end;
-      {$ELSE}
-      e_WriteLog(Format('=== PANELS: %d ===', [gDrawPanelList.count]), MSG_NOTIFY);
-      while (gDrawPanelList.count > 0) do
-      begin
-        pan := TPanel(gDrawPanelList.front());
-        e_WriteLog(Format('tagmask: 0x%04x; pan.tag: 0x%04x; pan.arrIdx: %d', [tagmask, pan.tag, pan.arrIdx]), MSG_NOTIFY);
-        pan.Draw();
-        gDrawPanelList.popFront();
-      end;
-      {$ENDIF}
     end
     else
     begin
-      g_Map_DrawPanels(panType);
+      if doDraw then g_Map_DrawPanels(panType);
     end;
     profileFrameDraw.sectionEnd();
   end;
@@ -2787,23 +2804,23 @@ begin
 
   if (setTransMatrix) then glTranslatef(transX, transY, 0);
 
-  drawPanelType('*back', PANEL_BACK);
-  drawPanelType('*step', PANEL_STEP);
+  drawPanelType('*back', PANEL_BACK, g_rlayer_back);
+  drawPanelType('*step', PANEL_STEP, g_rlayer_step);
   drawOther('items', @g_Items_Draw);
   drawOther('weapons', @g_Weapon_Draw);
   drawOther('shells', @g_Player_DrawShells);
   drawOther('drawall', @g_Player_DrawAll);
   drawOther('corpses', @g_Player_DrawCorpses);
-  drawPanelType('*wall', PANEL_WALL);
+  drawPanelType('*wall', PANEL_WALL, g_rlayer_wall);
   drawOther('monsters', @g_Monsters_Draw);
-  drawPanelType('*door', PANEL_CLOSEDOOR);
+  drawPanelType('*door', PANEL_CLOSEDOOR, g_rlayer_door);
   drawOther('gfx', @g_GFX_Draw);
   drawOther('flags', @g_Map_DrawFlags);
-  drawPanelType('*acid1', PANEL_ACID1);
-  drawPanelType('*acid2', PANEL_ACID2);
-  drawPanelType('*water', PANEL_WATER);
+  drawPanelType('*acid1', PANEL_ACID1, g_rlayer_acid1);
+  drawPanelType('*acid2', PANEL_ACID2, g_rlayer_acid2);
+  drawPanelType('*water', PANEL_WATER, g_rlayer_water);
   drawOther('dynlights', @renderDynLightsInternal);
-  drawPanelType('*fore', PANEL_FORE);
+  drawPanelType('*fore', PANEL_FORE, g_rlayer_fore);
 
   if g_debug_HealthBar then
   begin
@@ -3182,7 +3199,8 @@ begin
 
   if gPause and gGameOn and (g_ActiveWindow = nil) then
   begin
-    e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+    //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+    e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
 
     e_CharFont_GetSize(gMenuFont, _lc[I_MENU_PAUSE], w, h);
     e_CharFont_Print(gMenuFont, (gScreenWidth div 2)-(w div 2),
@@ -3200,11 +3218,16 @@ begin
         else e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0);
       end;
       if g_ActiveWindow <> nil then
-        e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+      begin
+        //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+        e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
+      end;
     end;
 
     if gState = STATE_FOLD then
+    begin
       e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 0, 0, 0, EndingGameCounter);
+    end;
 
     if gState = STATE_INTERCUSTOM then
     begin
@@ -3225,13 +3248,18 @@ begin
       DrawCustomStat();
 
       if g_ActiveWindow <> nil then
-        e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+      begin
+        //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+        e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
+      end;
     end;
 
     if gState = STATE_INTERSINGLE then
     begin
       if EndingGameCounter > 0 then
-        e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 0, 0, 0, EndingGameCounter)
+      begin
+        e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 0, 0, 0, EndingGameCounter);
+      end
       else
       begin
         back := 'INTER';
@@ -3244,7 +3272,10 @@ begin
         DrawSingleStat();
 
         if g_ActiveWindow <> nil then
-          e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+        begin
+          //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+          e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
+        end;
       end;
     end;
 
@@ -3260,7 +3291,10 @@ begin
         e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0);
 
       if g_ActiveWindow <> nil then
-        e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+      begin
+        //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+        e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
+      end;
     end;
 
     if gState = STATE_SLIST then
@@ -3268,7 +3302,8 @@ begin
       if g_Texture_Get('MENU_BACKGROUND', ID) then
       begin
         e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
-        e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+        //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+        e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
       end;
       g_Serverlist_Draw(slCurrent);
     end;
@@ -3277,7 +3312,10 @@ begin
   if g_ActiveWindow <> nil then
   begin
     if gGameOn then
-      e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+    begin
+      //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
+      e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
+    end;
     g_ActiveWindow.Draw();
   end;
 
@@ -3300,11 +3338,11 @@ begin
   end;
 
   if gGameOn and gShowTime and (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
-  e_TextureFontPrint(gScreenWidth-72, 0,
-                     Format('%d:%.2d:%.2d', [gTime div 1000 div 3600, (gTime div 1000 div 60) mod 60, gTime div 1000 mod 60]),
-                     gStdFont);
+    drawTime(gScreenWidth-72, gScreenHeight-16);
 
   if gGameOn then drawProfilers();
+
+  g_Holmes_DrawUI();
 end;
 
 procedure g_Game_Quit();