function SetLayout(minimap) if not controls.group then controls.group = Group(controls.controlClusterGroup, "MFD Group") controls.group.OnHide = function(self, hidden) if not hidden then if minimap then controls.displayGroup:Show() else controls.displayGroup:Hide() end SetLayout(UIUtil.currentLayout) end end controls.group:DisableHitTest() end if not controls.displayGroup then controls.displayGroup = Group(GetFrame(0),"MFD Display Group") controls.displayGroup.Depth:Set(3) end if not controls.miniMap then controls.miniMap = import('/lua/modules/ui/controls/worldview.lua').WorldView(controls.displayGroup, 'MiniMap', 2, true, 'WorldCamera') -- depth value is above minimap controls.miniMap:SetName("Minimap") controls.miniMap:SetRenderPass(UIUtil.UIRP_UnderWorld) -- don't change this or the camera will lag one frame behind controls.miniMap.Depth:Set(10) controls.miniMap:SetNeedsFrameUpdate(true) -- defer the camera reset one frame so a view is created, this causes a fully zoomed out map local frameCount = 0 controls.miniMap.OnFrame = function(self, elapsedTime) if frameCount == 1 then controls.miniMap:CameraReset() controls.miniMap.OnFrame = nil -- we want the control to continue to get frame updates in the engine, but not in Lua. PLEASE DON'T CHANGE THIS OR IT BREAKS CAMERA DRAGGING end frameCount = frameCount + 1 end LayoutHelpers.FillParent(controls.miniMap, controls.displayGroup) end controls.group.Top:Set(function() return controls.controlClusterGroup.Top() - 2 end) controls.group.Left:Set(controls.controlClusterGroup.Left) controls.group.Right:Set(controls.controlClusterGroup.Right) LayoutHelpers.ResetBottom(controls.group) controls.miniMap.Left:Set(function() return 0 end) controls.miniMap.Top:Set(function() return 0 end) LayoutHelpers.AtLeftTopIn(controls.displayGroup, controls.miniMap) controls.displayGroup.Height:Set(180) controls.displayGroup.Width:Set(180) if minimap then controls.group.Height:Set(function() return controls.miniMap.Height() end) else controls.group.Height:Set(function() return 0 end) end LayoutHelpers.ResetBottom(controls.group) LayoutHelpers.ResetWidth(controls.group) end