-- <* -- @Author: Saber -- @Description: 圣物系统装甲背包界面 -- *> PsionicArmorView = PsionicArmorView or BaseClass(BaseItem) local PsionicArmorView = PsionicArmorView function PsionicArmorView:__init(parent_wnd,prefab_asset,layer_name) self.base_file = "psionic" self.layout_file = "PsionicArmorView" self.parent_wnd = parent_wnd self.layer_name = layer_name self.sort_goods_up = true -- 道具排序flag true = 品质降序 false = 品质升序 self.model = PsionicModel:getInstance() self:Load() end function PsionicArmorView:Load_callback() local nodes = { "resolve_btn:obj", "resolve_btn/resolve_red:img", "receive_btn:obj", "item_scroll", "item_scroll/Viewport/item_con", } self:GetChildren(nodes) self:AddEvents() self:UpdateView() end function PsionicArmorView:AddEvents( ) local function click_event(target, x, y) if target == self.resolve_btn_obj then self.model:Fire(PsionicConst.OPEN_RESOLVE_VIEW, true) elseif target == self.receive_btn_obj then local draw_open, cfg = GetModuleIsOpen(139, 7) if draw_open then OpenFun.Open(139, 7) else local str = string.format("圣物寻宝将在开服第%s天开启!", cfg and cfg.open_day or 0) Message.show(str, "fault") end end end AddClickEvent(self.resolve_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE) AddClickEvent(self.receive_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE) local function on_update_equip_bag() self:UpdatePsionicArmorItem() end self:BindEvent(self.model, PsionicConst.UPDATE_PISIONIC_BAG_ARMOR, on_update_equip_bag) local function update_resolve_btn_red(tab_id) if tab_id and tab_id == PsionicConst.TabId.PArmor then self:UpdateResolveBtnRed() end end self:BindEvent(self.model, PsionicConst.UPDATE_RED_BY_TABID, update_resolve_btn_red) end function PsionicArmorView:UpdateView( ) self:ChangeSortFlag(self.sort_goods_up) self:UpdateResolveBtnRed() end function PsionicArmorView:ChangeSortFlag(flag) self.sort_goods_up = flag self:UpdatePsionicArmorItem() end function PsionicArmorView:UpdatePsionicArmorItem( ) -- print("Saber:PsionicArmorView [57] self.sort_goods_up: ",self.sort_goods_up) local data = self.model:GetPsionicBagData(self.sort_goods_up) local data_length = #data local empty_data = {is_empty = true} local need_full_num if data_length < 24 then -- 补全24个位置 need_full_num = 24 elseif data_length % 4 ~= 0 then -- 有空白格子,补全成无数据格子 need_full_num = math.ceil(data_length / 4) * 4 end if need_full_num then for i = data_length + 1, need_full_num do data[i] = empty_data end end self.bag_item_creator = self.bag_item_creator or self:AddUIComponent(UI.ItemListCreator) local info = { data_list = data, item_con = self.item_con, scroll_view = self.item_scroll, item_class = PsionicArmorItem, item_width = 78, item_height = 78, start_x = 9, start_y = -9, space_x = 12, space_y = 12, create_frequency = 0.01, alignment = UnityEngine.TextAnchor.UpperLeft, on_update_item = function(item, i, v) item:SetData(v, PsionicConst.ArmorItemFlag.Bag,nil,nil,i) end, } self.bag_item_creator:UpdateItems(info) end function PsionicArmorView:UpdateResolveBtnRed( ) local bool = self.model:GetPsionicResolveBtnRed() self.resolve_red_img.enabled = bool end function PsionicArmorView:__delete( ) end