changhong/lua_probject/base_project/Game/View/NewGroup/GroupSettingView.lua

132 lines
3.8 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

--牌友圈设置View对象
--author--
local CreateGroupView = import(".CreateGroupView")
local GroupSettingView = {}
local M = GroupSettingView
function GroupSettingView.new(blur_view)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "GroupSettingView"
self._close_destroy = true
self._blur_view = blur_view
self:init("ui://NewGroup/Win_GroupSetting")
return self
end
local function __removeGroup(self,msg,curData)
local fgCtr = ControllerManager.GetController(NewGroupController)
local _curren_msg = MsgWindow.new(self._root_view, msg, MsgWindow.MsgMode.OkAndCancel)
_curren_msg.onOk:Add(function()
ViewUtil.ShowModalWait(self._root_view)
local func = curData.owner == DataManager.SelfUser.account_id and fgCtr.FG_RemoveGroup or fgCtr.FG_ExitGroup
func(fgCtr, curData.id, function(res)
if self._is_destroy then
return
end
ViewUtil.CloseModalWait()
if res.ReturnCode == 0 then
self.change = true
local groups = DataManager.groups.groupList
if #groups > 0 then
self:FillData()
else
self:Destroy()
end
else
ViewUtil.ErrorTip(res.ReturnCode,"删除大联盟失败!")
end
end)
end)
_curren_msg:Show()
end
function M:init(url)
BaseWindow.init(self,url)
local lst_group = self._view:GetChild("lst_group")
local btn_remove = self._view:GetChild("btn_remove")
btn_remove.onClick:Set(function()
local group = lst_group:GetChildAt(lst_group.selectedIndex).data
__removeGroup(self,"您确定解散该大联盟吗?",group)
end)
local btn_exit = self._view:GetChild("btn_exit")
btn_exit.onClick:Set(function()
local group = lst_group:GetChildAt(lst_group.selectedIndex).data
__removeGroup(self,"您确定退出该大联盟吗?",group)
end)
lst_group.onClickItem:Add(function(context)
local group = context.data.data
if group.lev == 1 then
self._view:GetController("opt").selectedIndex = 2
else
local option = group.option or 0
if bit:_and(option,2) > 0 then
self._view:GetController("opt").selectedIndex = 1
else
self._view:GetController("opt").selectedIndex = 0
end
end
end)
end
function M:FillData()
local groups = DataManager.groups.groupList
local lst_group = self._view:GetChild("lst_group")
lst_group:RemoveChildrenToPool()
local fgCtr = ControllerManager.GetController(NewGroupController)
for i = 1, #groups do
local group = groups[i]
local item = lst_group:AddItemFromPool()
item:GetChild("tex_name").text = group.name
item:GetChild("tex_id").text = group.id
item:GetChild("tex_nick").text ="创建人:" .. group.o_nick
item.data = group
end
if #groups > 0 and lst_group.selectedIndex == -1 then
lst_group.selectedIndex = 0
if groups[1].lev == 1 then
self._view:GetController("opt").selectedIndex = 2
else
local option = groups[1].option or 0
if bit:_and(option,2) > 0 then
self._view:GetController("opt").selectedIndex = 1
else
self._view:GetController("opt").selectedIndex = 0
end
end
end
if #groups == 0 then
self._view:GetController("opt").selectedIndex = 0
end
end
function M:SetCallback(callback)
self.callback = callback
end
-- 销毁窗口
function M:Destroy(remove_map)
if self.change and self.callback then
self.callback()
end
BaseWindow.Destroy(self,remove_map)
end
return M