BlockSettingView = BlockSettingView or BaseClass(BaseItem) -- 挂机设置界面 function BlockSettingView:__init(parent) self.base_file = "setting" self.layout_file = "BlockSettingView" self.block_item_list = {} self.block_item_list_2 = {} self.block_list = {} self.block_list_2 = {} self.model = GameSettingModel:GetInstance() self:Load() end function BlockSettingView:Load_callback() self:LoadSuccess() self:InitEvent() end function BlockSettingView:LoadSuccess() self.block_con = self:GetChild("block_con") self.block_con_2 = self:GetChild("block_con_2") self.help_btn = self:GetChild("help_btn").gameObject self:InitBlockItem() if self.need_refreshData then self:SetData() end end function BlockSettingView:InitBlockItem() for k,v in pairs(Config.ConfigBlockSetting.Blocklist) do if v.id <= 6 then table.insert(self.block_list,v) else table.insert(self.block_list_2,v) end end if self.block_list == nil or #self.block_list == 0 then return end if self.block_list_2 == nil or #self.block_list_2 == 0 then return end local item local call_back = function(symbol,state) self:SetBlock(symbol,state) end for i,v in pairs(self.block_list) do if self.block_item_list[i] == nil then item = BlockSettingItem.New(self.block_con) self.block_item_list[i] = item end item = self.block_item_list[i] item:SetData(v,call_back) end for i,v in pairs(self.block_list_2) do if self.block_item_list_2[i] == nil then item = BlockSettingItem.New(self.block_con_2) self.block_item_list_2[i] = item end item = self.block_item_list_2[i] item:SetData(v,call_back) end end function BlockSettingView:SetBlock(symbol,state) lua_settingM:SetBlockProperty(symbol,state) CookieWrapper.Instance:WriteAll() end function BlockSettingView:InitEvent() local on_click = function ( click_obj ) if self.help_btn == click_obj then EventSystem.Fire(GlobalEventSystem,EventName.OPEN_INSTRUCTION_VIEW, "102@2") end end AddClickEvent(self.help_btn, on_click) local function return_default(cur_index) if not self.is_loaded then return end if cur_index == GameSettingModel.TabData.BLOCK then self:ReturnDefault() end end self:BindEvent(GameSettingModel:GetInstance(), GameSettingModel.RETURN_ALL_DEFAULT, return_default) end function BlockSettingView:SetData() if self.is_loaded then self:SetBlockData() self.need_refreshData = false else self.need_refreshData = true end end function BlockSettingView:SetBlockData() if self.block_list == nil then return end local state if self.block_list_2 == nil then return end local state_2 for i,v in pairs(self.block_list) do if self.block_item_list[i] then state = lua_settingM:GetBlockProperty(v.block_str) self.block_item_list[i]:SetState(state) end end for i,v in pairs(self.block_list_2) do if self.block_item_list_2[i] then state_2 = lua_settingM:GetBlockProperty(v.block_str) self.block_item_list_2[i]:SetState(state_2) end end end function BlockSettingView:__delete() -- 界面销毁 for i,item in pairs(self.block_item_list) do item:DeleteMe() item = nil end self.block_item_list = {} for i,item in pairs(self.block_item_list_2) do item:DeleteMe() item = nil end self.block_item_list_2 = {} end function BlockSettingView:ReturnDefault() -- 屏蔽设置 if self.block_list == nil then return end local state if self.block_list_2 == nil then return end local state_2 for i,v in ipairs(self.block_list) do if self.block_item_list[i] then state = lua_settingM:GetBlockDefualt(v.block_str) self.block_item_list[i]:SetState(state) lua_settingM:SetBlockProperty(v.block_str,lua_settingM:GetBlockDefualt(v.block_str)) end end for i,v in ipairs(self.block_list_2) do if self.block_item_list_2[i] then state_2 = lua_settingM:GetBlockDefualt(v.block_str) self.block_item_list_2[i]:SetState(state_2) lua_settingM:SetBlockProperty(v.block_str,lua_settingM:GetBlockDefualt(v.block_str)) end end end