41 lines
		
	
	
		
			1003 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
		
		
			
		
	
	
			41 lines
		
	
	
		
			1003 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
|  | local UILayerManager = {} | ||
|  | local EWidgetLayoutType = import("EWidgetLayoutType") | ||
|  | 
 | ||
|  | function UILayerManager:ctor() | ||
|  |     self.layer_mapping = {} | ||
|  | end | ||
|  | 
 | ||
|  | function UILayerManager:OnInitialized() | ||
|  |     self.layer_mapping = { | ||
|  |         [EWidgetLayoutType.MainLayer] = self.MainLayer, | ||
|  |         [EWidgetLayoutType.PopupLayer] = self.PopupLayer, | ||
|  |         [EWidgetLayoutType.FloatLayer] = self.FloatLayer, | ||
|  |         [EWidgetLayoutType.TopLayer] = self.TopLayer, | ||
|  |     } | ||
|  | end | ||
|  | 
 | ||
|  | function UILayerManager:ShowWidget(widget, args) | ||
|  |     local layer = self.layer_mapping[widget.LayoutType] | ||
|  |     if layer == nil then | ||
|  |         return | ||
|  |     end | ||
|  |     layer:AddChild(widget) | ||
|  |     if widget.Refresh then | ||
|  |         widget:Refresh(args) | ||
|  |     end | ||
|  |     widget.Slot:SetVerticalAlignment(0) | ||
|  |     widget.Slot:SetHorizontalAlignment(0) | ||
|  |     widget:SetVisible(true) | ||
|  | end | ||
|  | 
 | ||
|  | function UILayerManager:HideWidget(widget) | ||
|  |     widget:SetVisible(false) | ||
|  | end | ||
|  | 
 | ||
|  | function UILayerManager:CloseWidget(widget) | ||
|  |     widget:SetVisible(false) | ||
|  | end | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | return Class(nil, nil, UILayerManager) |