local UICountrySalaryTreasure = UIViewClass() function UICountrySalaryTreasure:OnOpened(context) self:RegistSystemEvent(EventID.Country_OnSalaryTreasureInfo, self.OnSalaryTreasureInfo) MDL.Country.CountrySalaryTreasureInfoReq() self.txt.text = string.FormatByIdsId(Const_IDS.IDS_Stockroom_EpicSpoilIntro, unpack(self:GetJobNames())) MDL.Country.RecordTreasureReq() self:RegistSystemEvent(EventID.Country_OnSalaryRecordInfo, self.OnSalaryRecordInfo) self:RegistSystemEvent(EventID.Country_SalaryGiveOut, self.OnSalaryGiveOut) end function UICountrySalaryTreasure:GetJobNames() local jobNames = {} for _, d in DataSheetManager.GuildJob:GetEnumerator() do local exist = false for i, v in ipairs(d.JobID) do if v == MDL.Guild.AuthorityEnum.GuildSpoil then local str = UIUtils.GetLocalizedTxt(Const_IDS[d.JobName]) table.insert(jobNames, str) end end end return jobNames end function UICountrySalaryTreasure:OnSalaryGiveOut() MDL.Country.RecordTreasureReq() end function UICountrySalaryTreasure:OnSalaryRecordInfo(msg) local list = CTL.Country.SortRecordList(msg.Record, 2) self.LoopScroll_Info:ReloadAll(list) end local function SortFunc(a, b) local rewardDataA = DataSheetManager.CountryRewards:GetDataByID(a.CountryRewardID) local rewardDataB = DataSheetManager.CountryRewards:GetDataByID(b.CountryRewardID) return rewardDataA.sortID > rewardDataB.sortID end function UICountrySalaryTreasure:OnSalaryTreasureInfo(msg) self.LoopRewards:ClearCells() local sortList ={} for i, v in ipairs(msg.Treasure) do table.insert(sortList, v) end table.sort(sortList, SortFunc) self.LoopRewards:ReloadAll(sortList) self.LoopRewards:SelectIndex(0) end function UICountrySalaryTreasure:OnButtonClicked(comp) if comp == self.event_Send then if self:IsHasPermission() then UIManager.OpenView(Const_UI_Lua.UIEnum.UICountrySalarySend, { isGuild = true, rewardId = self.curRewardID }) else CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_Guild_CommonFail4) end elseif comp == self.event_Share then if self:IsHasPermission() then UIManager.OpenView(Const_UI_Lua.UIEnum.UICountrySalarySend, { isGuild = false, rewardId = self.curRewardID }) else CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_Guild_CommonFail4) end end end function UICountrySalaryTreasure:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_More then local rewardData = DataSheetManager.CountryRewards:GetDataByID(data.CountryRewardID) UTL.ItemTips.ShowCommonTipsById(rewardData.ItemID) end end function UICountrySalaryTreasure:OnCellSelect(scrollRect, index, cellTable, data) self.curRewardID = data.CountryRewardID self.lab_Num.text = string.FormatByIdsId(Const_IDS.IDS_Stockroom_BondNum, data.BindNum) .. " " .. string.FormatByIdsId(Const_IDS.IDS_Stockroom_UnbondNum, data.NotBindNum) local rewardData = DataSheetManager.CountryRewards:GetDataByID(data.CountryRewardID) cellTable.effect_Selected:PlayUIEffect(rewardData.SelectEffect, -1) end function UICountrySalaryTreasure:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.LoopRewards then local rewardData = DataSheetManager.CountryRewards:GetDataByID(data.CountryRewardID) local itemData = DataSheetManager.ItemData:GetDataByID(rewardData.ItemID) --道具名称 BoxPath BasePath ImagePath EffectPath UIUtils.SetImageByAssetBundle(cellTable.img_Box, rewardData.BoxPath) UIUtils.SetImageByAssetBundle(cellTable.img_Pad, rewardData.BasePath) cellTable.state_Image:SetState(rewardData.ImagType - 1) if rewardData.ImagType == 1 then UIUtils.SetImageByAssetBundle(cellTable.img_Hero, rewardData.ImagePath) elseif rewardData.ImagType == 2 then UIUtils.SetImageByAssetBundle(cellTable.img_Horse, rewardData.ImagePath) elseif rewardData.ImagType == 3 then UIUtils.SetImageByAssetBundle(cellTable.img_Weapon, rewardData.ImagePath) end -- UIUtils.SetImageByAssetBundle(cellTable.Image, rewardData.ImagePath) cellTable.effect_Value:PlayUIEffect(rewardData.EffectPath, -1) local colorText = UTL.Color.FormatQualityText(UTL.Item.GetItemDataSpliceByType(rewardData.ItemID).Name, itemData.Color) cellTable.txt_Name.text = colorText else local excelData = DataSheetManager.StockroomEvent:GetDataByID(data.EventId) local params = CTL.Country.GetRecordParams(data.Params) cellTable.txt_Date.text = os.date(UTL.Time.FormatDateEnum.YMD, data.RecordTime) cellTable.txt_Time.text = os.date(UTL.Time.FormatDateEnum.HM, data.RecordTime) cellTable.txt_Info.text = string.FormatByIdsId(Const_IDS[excelData.EventText], unpack(params)) end end function UICountrySalaryTreasure:IsHasPermission() return MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle, MDL.Guild.AuthorityEnum.GuildSpoil) end return UICountrySalaryTreasure