From f9a268a51a0141a09addf367ed910fac605c6018 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 14 Jul 2019 23:12:22 +0200 Subject: [PATCH] improvement(camera): make getViewsDimensions a wrapper around a camutil --- gamecore/modules/world/camera/init.lua | 16 +++------------- gamecore/modules/world/camera/utils.lua | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/gamecore/modules/world/camera/init.lua b/gamecore/modules/world/camera/init.lua index 2bdeab1..fdff2ee 100644 --- a/gamecore/modules/world/camera/init.lua +++ b/gamecore/modules/world/camera/init.lua @@ -73,21 +73,11 @@ function CameraSystem:haveView() return (self:getViewNumber() == 0) end -function CameraSystem:getViewsDimensions(viewNumber) +function CameraSystem:getViewsDimensions() local basewidth, baseheight = self.views.basewidth, self.views.baseheight - local viewnumber = viewNumber or self:getViewNumber() + local viewnumber = self:getViewNumber() - if (viewnumber <= 1) then - return basewidth, baseheight - elseif (viewnumber == 2) then - if (self.verticalSplit) then - return (basewidth), (baseheight/2) - else - return (basewidth/2), (baseheight) - end - else - return (basewidth/2), (baseheight/2) - end + return camutils.getViewsDimensions(viewnumber, basewidth, baseheight, self.verticalSplit) end function CameraSystem:recalculateViewsPositions() diff --git a/gamecore/modules/world/camera/utils.lua b/gamecore/modules/world/camera/utils.lua index 6d47831..94d2306 100644 --- a/gamecore/modules/world/camera/utils.lua +++ b/gamecore/modules/world/camera/utils.lua @@ -43,4 +43,18 @@ function camutils.getViewsPositions(basewidth, baseheight, verticalSplit) return posList end +function camutils.getViewsDimensions(viewnumber, basewidth, baseheight, verticalSplit) + if (viewnumber <= 1) then + return basewidth, baseheight + elseif (viewnumber == 2) then + if (verticalSplit) then + return (basewidth), (baseheight/2) + else + return (basewidth/2), (baseheight) + end + else + return (basewidth/2), (baseheight/2) + end +end + return camutils