miduo_client/Assets/ManagedResources/~Lua/Modules/Guild/GuildCreatePopup.lua

99 lines
3.6 KiB
Lua

require("Base/BasePanel")
local GuildCreatePopup = Inherit(BasePanel)
local this = GuildCreatePopup
--初始化组件(用于子类重写)
function GuildCreatePopup:InitComponent()
this.spLoader = SpriteLoader.New()
this.btnBack = Util.GetGameObject(self.transform, "tipImage/btnClose")
this.btnCreate = Util.GetGameObject(self.transform, "tipImage/btnCreate")
this.inputName = Util.GetGameObject(self.transform, "tipImage/name"):GetComponent("InputField")
this.inputAnnounce = Util.GetGameObject(self.transform, "tipImage/content"):GetComponent("InputField")
this.costTip = Util.GetGameObject(self.transform, "tipImage/costTips"):GetComponent("Text")
this.text1 = Util.GetGameObject(self.transform, "tipImage/name/Text"):GetComponent("Text")
this.text2 = Util.GetGameObject(self.transform, "tipImage/content/Text"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function GuildCreatePopup:BindEvent()
Util.AddClick(this.btnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
this:ClosePanel()
end)
-- 搜索
Util.AddClick(this.btnCreate, function()
local name = this.inputName.text
local announce = this.inputAnnounce.text
if name == "" then
PopupTipPanel.ShowTip(Language[10843])
return
end
local config = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1)
local minLen, maxLen = config.NameSize[1], config.NameSize[2]
local len = StringWidth(name)
if len < minLen or len > maxLen then
PopupTipPanel.ShowTip(Language[10844])
return
end
local cost = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1).CreatCost
CostConfirmPopup.Show(cost[1][1], cost[1][2], Language[10845], nil, function()
local haveNum = BagManager.GetItemCountById(cost[1][1])
if haveNum < cost[1][2] then
PopupTipPanel.ShowTip(Language[10846])
return
end
GuildManager.RequestCreateGuild(name, announce, function()
this:ClosePanel()
NetManager.RequestRedPacketData()
if this.successFunc then this.successFunc() end
UIManager.OpenPanel(UIName.GuildMainCityPanel)
PopupTipPanel.ShowTip(Language[10847])
end)
end)
end)
end
--添加事件监听(用于子类重写)
function GuildCreatePopup:AddListener()
end
--移除事件监听(用于子类重写)
function GuildCreatePopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function GuildCreatePopup:OnOpen(successFunc)
local defaultAnnounce = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.GuildSetting, 1).DefaultDeclaration)
this.inputName.text = ""
this.inputAnnounce.text = defaultAnnounce
this.successFunc = successFunc
-- 创建消耗
local cost = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1).CreatCost
local costName = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig, cost[1][1]).Name)
this.costTip.text = string.format(Language[10848], cost[1][2], costName)
this.text1.fontSize = GetCurLanguage() ~= 2 and 48 or 40
this.text2.fontSize = GetCurLanguage() ~= 2 and 48 or 40
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function GuildCreatePopup:OnShow()
end
--界面关闭时调用(用于子类重写)
function GuildCreatePopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function GuildCreatePopup:OnDestroy()
this.spLoader:Destroy()
end
return GuildCreatePopup