From: Ketmar Dark Date: Thu, 24 Aug 2017 16:16:34 +0000 (+0300) Subject: forcing centering of small maps (BlackDoomer request) X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=cb39caa8b879b70aa096476a2e919d4a298f1fa5;p=d2df-sdl.git forcing centering of small maps (BlackDoomer request) --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index a2f74cd..02a46f2 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -2855,8 +2855,19 @@ begin if px > gMapInfo.Width-(gPlayerScreenSize.X div 2) then a := -gMapInfo.Width+gPlayerScreenSize.X; if py > gMapInfo.Height-(gPlayerScreenSize.Y div 2) then b := -gMapInfo.Height+gPlayerScreenSize.Y; - if gMapInfo.Width <= gPlayerScreenSize.X then a := 0; - if gMapInfo.Height <= gPlayerScreenSize.Y then b := 0; + if (gMapInfo.Width = gPlayerScreenSize.X) then a := 0 + else if (gMapInfo.Width < gPlayerScreenSize.X) then + begin + // hcenter + a := (gPlayerScreenSize.X-gMapInfo.Width) div 2; + end; + + if (gMapInfo.Height = gPlayerScreenSize.Y) then b := 0 + else if (gMapInfo.Height < gPlayerScreenSize.Y) then + begin + // vcenter + b := (gPlayerScreenSize.Y-gMapInfo.Height) div 2; + end; if p.IncCam <> 0 then begin diff --git a/src/game/g_map.pas b/src/game/g_map.pas index f0419bf..b9da59d 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -198,7 +198,7 @@ type TPanelGrid = specialize TBodyGridBase; var - mapGrid: TPanelGrid = nil; + mapGrid: TPanelGrid = nil; // DO NOT USE! public for debugging only! implementation @@ -1226,6 +1226,7 @@ begin if (mapY1 < gMapInfo.Height-1) then mapY1 := gMapInfo.Height-1; mapGrid := TPanelGrid.Create(mapX0-128, mapY0-128, mapX1-mapX0+1+128*2, mapY1-mapY0+1+128*2); + //mapGrid := TPanelGrid.Create(0, 0, gMapInfo.Width, gMapInfo.Height); addPanelsToGrid(gWalls); addPanelsToGrid(gRenderBackgrounds); diff --git a/src/game/g_monsters.pas b/src/game/g_monsters.pas index 280dc56..8c2f2d7 100644 --- a/src/game/g_monsters.pas +++ b/src/game/g_monsters.pas @@ -235,7 +235,7 @@ type TMonsterGrid = specialize TBodyGridBase; var - monsGrid: TMonsterGrid = nil; + monsGrid: TMonsterGrid = nil; // DO NOT USE! public for debugging only! var