hengyang_client/lua_probject/base_project/Game/View/Common/BaseView.lua

79 lines
1.6 KiB
Lua
Raw Normal View History

2025-04-01 10:48:36 +08:00
--view 基类
--author--
---
--@type BaseView
BaseView = {
-- Id View ID
Id = 0,
-- View 是否被销毁
_is_destroy = false,
--关闭摧毁
_close_destroy = false,
-- 全屏
_full = false,
--全屏偏移
_full_offset = true,
--view description
_view = nil,
}
local M = BaseView
local view_url = {
"ui://Common/Gcm_BaseView",
"ui://Common/Gcm_BaseView_Full"
}
---
--@function [parent=#BaseView] InitView
--@param self
--@param #string url
function M:InitView(url)
self._root_view = UIPackage.CreateObjectFromURL(self._full and view_url[2] or view_url[1])
local contentPane = self._root_view:GetChild("contentPane")
self._view = UIPackage.CreateObjectFromURL(url)
printlog(self._view)
self._close_destroy = true
-- self._view.fairyBatching = true
self._view:AddRelation(contentPane, RelationType.Size)
contentPane:AddChild(self._view)
self._contentPane = contentPane
end
function M:Show()
self._root_view.visible = true
if not self._root_view.parent then
AddPanel(self._root_view)
if self._full then
local offset = get_offset(self._full_offset)
self._contentPane.width = GRoot.inst.width - (offset * 2)
self._contentPane.height = GRoot.inst.height
self._contentPane.x = offset
end
end
end
function M:Close()
self._root_view.visible = false
end
--游戏暂停
function M:OnApplicationPause()
end
--游戏暂停
function M:OnApplicationActive()
end
---
--@function [parent=#BaseView] Destroy
--@param self
function M:Destroy()
self._is_destroy = true
self._root_view:Dispose()
end