ruyi/fk101/lua_probject/base_project/Game/View/NewGroup/GroupMngSettingView.lua

125 lines
4.4 KiB
Lua
Raw Normal View History

2025-11-17 18:55:00 +08:00
-- 牌友圈设置界面
local GroupMngSettingView = {}
local M = GroupMngSettingView
function GroupMngSettingView.new(gid)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "GroupMngSettingView"
self._close_destroy = true
self.group_id = gid
-- self._full = true
self:init("ui://NewGroup/Win_GroupSetting")
self:FillView()
return self
end
function M:initData()
end
function M:FillView()
local tex_name = self._view:GetChild("tex_name")
local tex_notice = self._view:GetChild("tex_notice")
local ctr_ban = self._view:GetController("ban")
local ctr_dissolve_time = self._view:GetController("dissolve_time")
local ctr_kick_time = self._view:GetController("kick_time")
local ctr_apply = self._view:GetController("apply")
local ctr_alliance = self._view:GetController("alliance")
local ctr_pt = self._view:GetController("pt")
local ctr_wq = self._view:GetController("wq")
local ctr_es = self._view:GetController("es")
local ctr_ua = self._view:GetController("ua")
local ctl_show_num = self._view:GetController("showAll")
local btn_chat_input = self._view:GetChild("btn_chat_input")
local btn_chat_voice = self._view:GetChild("btn_chat_voice")
local group = DataManager.groups:get(self.group_id)
tex_name.text = group.name
tex_notice.text = group.notice
ctr_ban.selectedIndex = group.ban and 1 or 0
ctr_dissolve_time.selectedIndex = group.dissolve_opt - 1
ctr_kick_time.selectedIndex = group.kick_opt - 1
ctr_alliance.selectedIndex = group.type - 1
ctr_apply.selectedIndex = group.apply or 0
btn_chat_input.selected = not group.ban_chat1
btn_chat_voice.selected = not group.ban_chat2
if group.show_num == 0 then
ctl_show_num.selectedIndex = 0
else
ctl_show_num.selectedIndex = 1
self._view:GetChild("txt_show_num").text = tostring(group.show_num)
end
local option = group.option or 0
ctr_pt.selectedIndex = bit:_and(option,1) > 0 and 1 or 0
ctr_wq.selectedIndex = bit:_and(option,2) > 0 and 1 or 0
ctr_es.selectedIndex = bit:_and(option,4) > 0 and 1 or 0
ctr_ua.selectedIndex = bit:_and(option,8) > 0 and 1 or 0
self._view:GetChild("btn_ok").onClick:Set(function()
ViewUtil.ShowModalWait()
local gid = self.group_id
local name = tex_name.text
local notice = tex_notice.text
local ban = ctr_ban.selectedIndex == 1
local dissolve_opt = ctr_dissolve_time.selectedIndex + 1
local kick_opt = ctr_kick_time.selectedIndex + 1
local apply = ctr_alliance.selectedIndex == 1 and ctr_apply.selectedIndex or 0
local ban_chat1 = not btn_chat_input.selected
local ban_chat2 = not btn_chat_voice.selected
local fgCtr = ControllerManager.GetController(NewGroupController)
local pt = ctr_pt.selectedIndex
local wq = ctr_wq.selectedIndex
local es = ctr_es.selectedIndex
local ua = ctr_ua.selectedIndex
local option = 0
if ctr_pt.selectedIndex == 1 then
option = bit:_or(option,1)
end
if ctr_wq.selectedIndex == 1 then
option = bit:_or(option,2)
end
if ctr_es.selectedIndex == 1 then
option = bit:_or(option,4)
end
if ctr_ua.selectedIndex == 1 then
option = bit:_or(option,8)
end
local showNum = 0
if ctl_show_num.selectedIndex == 1 then
local strShowNum = self._view:GetChild("txt_show_num").text
if strShowNum ~= nil and strShowNum ~= "" then
showNum = tonumber(self._view:GetChild("txt_show_num").text)
end
end
fgCtr:FG_UpdateGroupInfo(gid, name, notice, ban, dissolve_opt, kick_opt, apply, ban_chat1, ban_chat2, option,showNum, function(res)
ViewUtil.CloseModalWait()
if res.ReturnCode ~= 0 then
ViewUtil.ErrorTip(res.ReturnCode,"设置大联盟失败。")
else
ViewUtil.ShowBannerOnScreenCenter("设置成功")
group.name = name
group.notice = notice
group.ban = ban
group.ban_ip = ban_ip
group.ban_gps = ban_gps
group.apply = apply
group.option = option
group.ban_chat1 = ban_chat1
group.ban_chat2 = ban_chat2
end
end)
end)
end
return M