dezhou_client/lua_probject/base_project/Game/View/HeadView.lua

125 lines
4.3 KiB
Lua

--玩家头像窗口
HeadView = {}
local M = HeadView
function HeadView.new(blur_view, user, isHideIpAdds)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = 'HeadView'
self._blur_view = blur_view
self._user = user
self._isHideIpAdds = isHideIpAdds
self:init('ui://Common/Win_headinfo')
return self
end
function M:init(url)
BaseWindow.init(self, url)
self._close_destroy = true
self._close_zone = true
local view = self._view
local ct_state = view:GetController('state')
view:GetChild('tex_nickname').text = self._user.nick_name
local str_playerid = ViewUtil.HideID(self._user.account_id)
if DataManager.SelfUser.account_id == self._user.account_id or DataManager.CurrenRoom.lev < 3 then
str_playerid = self._user.account_id
end
view:GetChild('tex_id').text = str_playerid
view:GetChild('tex_ip').text = self._user.host_ip
local tex_add = view:GetChild('tex_add')
if self._isHideIpAdds then
view:GetChild('tex_ip').visible = false
view:GetChild('n12').visible = false
view:GetChild('n54').visible = false
tex_add.visible = false
else
view:GetChild('tex_ip').visible = true
view:GetChild('n12').visible = true
view:GetChild('n54').visible = true
tex_add.visible = true
end
-- view:GetChild("tex_distance").text = ""
local btn_head = view:GetChild('btn_head')
ImageLoad.Load(self._user.head_url, btn_head._iconObject)
if DataManager.CurrenRoom and not DataManager.CurrenRoom.playback then
-- 显示3人、4人玩法距离
-- local n = 0
-- if DataManager.CurrenRoom.room_config.people_num <= 4 and DataManager.CurrenRoom.room_config.people_num >= 3 then
-- n = 2
-- -- 显示玩家间距离
-- self:ShowPlayerDistance()
-- end
if DataManager.CurrenRoom.self_player.seat ~= 0 then
-- if self._user.account_id ~= DataManager.SelfUser.account_id and DataManager.CurrenRoom.self_player.seat ~= 0 then
ct_state.selectedIndex = 1
if self._user.account_id == DataManager.SelfUser.account_id then
view:GetChild('btn_all').selected = true
view:GetChild('btn_all').touchable = false
end
-- 桌面投掷物面板
local lst_missile = view:GetChild('lst_missile')
lst_missile.onClickItem:Add(
function(context)
if os.time() - DataManager.InteractTime > 3 then
local bAll = view:GetChild('btn_all').selected
local targetId = self._user.account_id
if bAll then
targetId = DataManager.SelfUser.account_id
end
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:SendInteraction(
DataManager.SelfUser.account_id,
5,
context.data.name .. '_' .. targetId
)
-- cd
DataManager.InteractTime = os.time()
ct_state.selectedIndex = 3
end
self:Destroy()
end
)
else
ct_state.selectedIndex = 2
end
-- 显示详细地址
-- self._user.location:GetAddress()
if self._user.location and not self._user.location.default then
self._user.location:GetAddress(tex_add)
else
tex_add.text = '无法获取玩家位置'
end
end
if os.time() - DataManager.InteractTime < 3 and DataManager.CurrenRoom.self_player.seat ~= 0 then
ct_state.selectedIndex = 3
UpdateBeat:Add(self.OnUpdate, self)
end
end
function M:OnUpdate()
if os.time() - DataManager.InteractTime > 3 and DataManager.CurrenRoom.self_player.seat ~= 0 then
self._view:GetController('state').selectedIndex = 1
-- UpdateBeat.Remove(self.OnUpdate, self)
end
end
function M:Destroy()
if self._verifyView then
self._verifyView:Destroy()
end
BaseWindow.Destroy(self)
UpdateBeat:Remove(self.OnUpdate, self)
end