local UIGuildCreateLevelPanel = UIViewClass() function UIGuildCreateLevelPanel:OnOpened(context) self.createLevel = {} for i, v in DataSheetManager.GuildCreate:GetEnumerator() do local collection = self.groups[i] collection.txt_TitleGuildBuildingLv.text = string.FormatByIdsId(Const_IDS.IDS_GuildCreateType_Label2,v.InitialMainBuilding) collection.txt_TitleGuildFameValue.text = string.FormatByIdsId(Const_IDS.IDS_GuildCreateType_Label1,self:GetLevelName(v.InitialReputation)) local count = MDL.Currency.GetMoneyCount(v.CreateCostType) self.createLevel[i] = {} if count < v.CreateCostNum then collection.txt_Cost.text = UTL.Color.FormatRedColor(v.CreateCostNum) else collection.txt_Cost.text = v.CreateCostNum self.createLevel[i].isEnough = true end if v.UnlockCondition and v.UnlockCondition > 0 then if MDL.Guild.GetMyGuildInfo().maxCreateType >= v.ID then collection.btn_Create:SetGray(false) collection.txt_TitleGuildBuildingCondi.text = nil else collection.btn_Create:SetGray(true,true) self.createLevel[i].UnlockCondition = true collection.txt_TitleGuildBuildingCondi.text = string.FormatByIdsId(Const_IDS.IDS_GuildCreateType_Label3,CTL.Guild.GetGuildLevelStr(v.UnlockCondition)) end end collection.txt_TitleGuildEmblem.text = self.context.emblemContend UTL.Item.SetAtlasSprite(collection.ico_GuildBg, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(self.context.emblemFrame).Image) collection.txt_TitleGuildName.text = self.context.name UTL.Item.ItemIconWithoutBg(collection.icon_Cost, v.CreateCostType) self.costName = UTL.Item.GetItemDataSpliceByType(v.CreateCostType).Name end self:RegistSystemEvent(EventID.UI_RefreshCurrency, self.RefreshInfo) end function UIGuildCreateLevelPanel:GetLevelName(levelId) local data = DataSheetManager.GuildReputation:GetDataByID(levelId) return UTL.Color.FormatTextByColor(data.Color,UIUtils.GetLocalizedTxt(Const_IDS[data.Name])) end function UIGuildCreateLevelPanel:RefreshInfo() for i, v in DataSheetManager.GuildCreate:GetEnumerator() do local count = MDL.Currency.GetMoneyCount(v.CreateCostNum) local collection = self.groups[i] if count < v.CreateCostNum then collection.txt_Cost.text = UTL.Color.FormatRedColor(v.CreateCostNum) else collection.txt_Cost.text = v.CreateCostNum self.createLevel[i].isEnough = true end end end function UIGuildCreateLevelPanel:OnBackButtonPressed() self:OnButtonClicked(self.Btn_Close) end function UIGuildCreateLevelPanel:OnButtonClicked(comp) if comp == self.groups[1].btn_Create then self:Create(1) elseif comp == self.groups[2].btn_Create then if self.createLevel[2].UnlockCondition then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildCreate_Fail1) else if self.createLevel[2].isEnough then self:Create(2) else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail1,self.costName) end end elseif comp == self.groups[3].btn_Create then if self.createLevel[3].UnlockCondition then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildCreate_Fail1) else if self.createLevel[3].isEnough then self:Create(3) else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail1,self.costName) end end elseif comp == self.Btn_Close then self:CloseView() end end function UIGuildCreateLevelPanel:Create( createType) local str = string.FormatByIdsId(Const_IDS.IDS_GuildCreateConfirm_Text,self.context.name) self.context.createType = createType UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_GuildCreate_PageTitle, str, function () MDL.Guild.GuildCreateReq(self.context) end,nil) end return UIGuildCreateLevelPanel