local UIHeroFundAdvancedPanel = UIViewClass() local HeroHalfCardImagePath = ConstAssetPathConfig.HeroPicPath local VerticalNameImagePath = "UI_NameCard/%s.png" local GoldIngotRebate1 = DataSheetManager.ConstData:GetDataByID("GoldIngotRebate1").IntValue local GoldIngotRebate2 = DataSheetManager.ConstData:GetDataByID("GoldIngotRebate2").IntValue function UIHeroFundAdvancedPanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_HeroFund_RefreshPanel, self.RefreshHeroFundAdvanced) self.type = context.type self:RefreshHeroFundAdvanced() end function UIHeroFundAdvancedPanel:RefreshHeroFundAdvanced() local type = self.type local fundID = MDL.HeroFund.GetFundID(type) local titleName, localTitleIDS local typeName = CTL.HeroFund.GetTypeName(type) if self.lab_Lv1 then UIUtils.SetLabelText(self.lab_Lv1, Const_IDS[string.format("IDS_%sFund_Level2", typeName)]) end if self.lab_Lv2 then UIUtils.SetLabelText(self.lab_Lv2, Const_IDS[string.format("IDS_%sFund_Level3", typeName)]) end self.hasFundID = fundID and fundID > 0 --元宝战令没有state_Fund控件,无需设置;不用选择干货,所以hasFundID设置为true if type == LuaConst.ShowGoldenType.GoldIngot then self.hasFundID = true else self.state_Fund:SetState(type - 1) end --左侧立绘展示,三种界面分别处理 if type == LuaConst.ShowGoldenType.Hero then titleName = "sjmj_msz_01.png" localTitleIDS = "IDS_HeroFund_Title" if self.hasFundID then self.state_Hero:SetState(0) local heroData = DataSheetManager.HeroNum:GetDataByID(fundID) UIUtils.SetImageByAssetBundle(self.img_Hero, string.format(HeroHalfCardImagePath, heroData.HalfCardImage)) UIUtils.SetLabelText(self.txt_HeroName, Const_IDS[heroData.NameIDS]) UTL.Item.SetLocalizationImage(self.loc_HeroName, self.img_HeroName, string.format(VerticalNameImagePath, heroData.HeadImageVertical)) else self.state_Hero:SetState(1) end elseif type == LuaConst.ShowGoldenType.Horse then titleName = "mjzl_msz_04.png" localTitleIDS = "IDS_HorseFund_Title" if self.hasFundID then self.state_Horse:SetState(0) local horseData = DataSheetManager.HorseData:GetDataByHorseID(fundID) UIUtils.SetImageByAssetBundle(self.img_Horse, horseData.HorsePicture) UIUtils.SetLabelText(self.txt_HorseName, Const_IDS[horseData.HorseName]) else self.state_Horse:SetState(1) end elseif type == LuaConst.ShowGoldenType.Treasure then titleName = "mjzl_msz_05.png" localTitleIDS = "IDS_TreasureFund_Title" if self.hasFundID then self.state_Treasure:SetState(0) local treasureData = DataSheetManager.TreasureData:GetDataByTreasureID(fundID) UIUtils.SetImageByAssetBundle(self.img_Treasure, treasureData.TreasurePicture) self.img_Treasure:SetNativeSize() UIUtils.SetLabelText(self.txt_TreasureName, Const_IDS[treasureData.TreasureName]) else self.state_Treasure:SetState(1) end elseif type == LuaConst.ShowGoldenType.GoldIngot then titleName = "ybzl_msz_01.png" localTitleIDS = "IDS_GoldIngotFund_Title" end UTL.Item.SetLocalizationImage(self.loc_Title, self.img_Title, titleName) self.img_Title:SetNativeSize() UIUtils.SetLabelText(self.txt_Title, Const_IDS[localTitleIDS]) --右侧信息 local threeLineDatas = MDL.HeroFund.GetFundShowData(type) local combineRewards self.iapIndex = { threeLineDatas[2].IAPID, threeLineDatas[3].IAPID } --第二档的显示 UIUtils.SetImageByAssetBundle(self.img_Lv1Icon, threeLineDatas[2].Pic) if MDL.HeroFund.IsGearUnlock(type, 2) then self.btn_Lv1:SetGray(true) UIUtils.SetLabelText(self.text_Lv1, Const_IDS.IDS_HeroFund_AlreadyBuy) else self.btn_Lv1:SetGray(false) UIUtils.SetLabel(self.text_Lv1, string.FormatByIdsId(Const_IDS.IDS_HeroFund_Buy, MDL.Currency.GetFullyIAPPrice(self.iapIndex[1]))) end UIUtils.SetLabel(self.lab_RechargePoints1, string.FormatByIdsId(Const_IDS.IDS_HeroFund_RechargeScore, MDL.Currency.GetAmountByIAPIndex(self.iapIndex[1]))) combineRewards = MDL.HeroFund.GetCompinedFundShowData(type, 2) if type == LuaConst.ShowGoldenType.GoldIngot then UIUtils.SetLabel(self.txt_Level1Value, string.FormatByIdsId(Const_IDS.IDS_GoldIngotFund_Rebate, GoldIngotRebate1)) if(self.group_HFAdvancedLv1Item and self.group_HFAdvancedLv1Item.item_AdvancedLv1) then local id, num = next(combineRewards) UTL.Item.SetItemCell(self.group_HFAdvancedLv1Item.item_AdvancedLv1, id, num) end else UIUtils.SetLabel(self.txt_Level1Value, threeLineDatas[2].ShowPrice) self.loop_HFAdvancedLv1:ClearCells() for k, v in pairs(combineRewards) do self.loop_HFAdvancedLv1:AddData({ ItemID = k, ItemNum = v }, 0) end end --第三档的显示 UIUtils.SetImageByAssetBundle(self.img_Lv2Icon, threeLineDatas[3].Pic) if MDL.HeroFund.IsGearUnlock(type, 3) then self.btn_Lv2:SetGray(true) UIUtils.SetLabelText(self.text_Lv2, Const_IDS.IDS_HeroFund_AlreadyBuy) else self.btn_Lv2:SetGray(false) UIUtils.SetLabel(self.text_Lv2, string.FormatByIdsId(Const_IDS.IDS_HeroFund_Buy, MDL.Currency.GetFullyIAPPrice(self.iapIndex[2]))) end UIUtils.SetLabel(self.lab_RechargePoints2, string.FormatByIdsId(Const_IDS.IDS_HeroFund_RechargeScore, MDL.Currency.GetAmountByIAPIndex(self.iapIndex[2]))) combineRewards = MDL.HeroFund.GetCompinedFundShowData(type, 3) if type == LuaConst.ShowGoldenType.GoldIngot then UIUtils.SetLabel(self.txt_Level2Value, string.FormatByIdsId(Const_IDS.IDS_GoldIngotFund_Rebate, GoldIngotRebate2)) if(self.group_HFAdvancedLv2Item and self.group_HFAdvancedLv2Item.item_AdvancedLv2) then local id, num = next(combineRewards) UTL.Item.SetItemCell(self.group_HFAdvancedLv2Item.item_AdvancedLv2, id, num) end else UIUtils.SetLabel(self.txt_Level2Value, threeLineDatas[3].ShowPrice) if self.loop_HFAdvancedLv2 then self.loop_HFAdvancedLv2:ClearCells() for k, v in pairs(combineRewards) do self.loop_HFAdvancedLv2:AddData({ ItemID = k, ItemNum = v }, 0) end end end if GameAppInfo.IsJapanesePackage() and type ~= LuaConst.ShowGoldenType.GoldIngot then UIUtils.SetLabel(self.txt_Level1Value_JP, threeLineDatas[2].ShowPrice) UIUtils.SetLabel(self.txt_Level2Value_JP, threeLineDatas[3].ShowPrice) self:UILanguagesAdjustForJP() end end function UIHeroFundAdvancedPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_HFAdvancedLv1 then UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) elseif scrollRect == self.loop_HFAdvancedLv2 then UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) end end function UIHeroFundAdvancedPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_HFAdvancedLv1 or scrollRect == self.loop_HFAdvancedLv2 then UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end function UIHeroFundAdvancedPanel:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIHeroFundAdvancedPanel:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.btn_Unselected_Hero or comp == self.btn_Unselected_Treasure or comp == self.btn_Unselected_Horse then -- 打开选X界面 UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroFundChoosePanel, { type = self.type }) elseif comp == self.btn_Lv1 or comp == self.btn_Lv2 then if self.hasFundID then if comp == self.btn_Lv1 then MDL.Currency.GetOrderIDReq(self.iapIndex[1], MDL.Currency.PayType.HeroFund, 2) elseif comp == self.btn_Lv2 then MDL.Currency.GetOrderIDReq(self.iapIndex[2], MDL.Currency.PayType.HeroFund, 3) end else local typeName = CTL.HeroFund.GetTypeName(self.type) CTL.Tips.AddTipsMsg(Const_IDS[string.format("IDS_%sFund_ChooseTips",typeName)]) end end end function UIHeroFundAdvancedPanel:UILanguagesAdjustForJP() --日本因为语序问题,使用自己的预设组件 UIUtils.SetActive(self.img_Lv1ValueBg, false) UIUtils.SetActive(self.img_Lv1ValueBg_JP, true) UIUtils.SetActive(self.img_Lv2ValueBg, false) UIUtils.SetActive(self.img_Lv2ValueBg_JP, true) end return UIHeroFundAdvancedPanel