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

99 lines
3.6 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
local GuildCreatePopup = Inherit(BasePanel)
local this = GuildCreatePopup
--初始化组件(用于子类重写)
function GuildCreatePopup:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
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")
2021-02-24 20:24:58 +08:00
this.text1 = Util.GetGameObject(self.transform, "tipImage/name/Text"):GetComponent("Text")
this.text2 = Util.GetGameObject(self.transform, "tipImage/content/Text"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
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
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10843])
2020-05-09 13:31:21 +08:00
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
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10844])
2020-05-09 13:31:21 +08:00
return
end
local cost = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1).CreatCost
2021-03-02 16:53:12 +08:00
CostConfirmPopup.Show(cost[1][1], cost[1][2], Language[10845], nil, function()
2020-05-09 13:31:21 +08:00
local haveNum = BagManager.GetItemCountById(cost[1][1])
if haveNum < cost[1][2] then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10846])
2020-05-09 13:31:21 +08:00
return
end
GuildManager.RequestCreateGuild(name, announce, function()
this:ClosePanel()
2021-05-28 12:36:39 +08:00
NetManager.RequestRedPacketData()
2020-05-09 13:31:21 +08:00
if this.successFunc then this.successFunc() end
UIManager.OpenPanel(UIName.GuildMainCityPanel)
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10847])
2020-05-09 13:31:21 +08:00
end)
end)
end)
end
--添加事件监听(用于子类重写)
function GuildCreatePopup:AddListener()
end
--移除事件监听(用于子类重写)
function GuildCreatePopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function GuildCreatePopup:OnOpen(successFunc)
2021-01-26 17:08:39 +08:00
local defaultAnnounce = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.GuildSetting, 1).DefaultDeclaration)
2020-05-09 13:31:21 +08:00
this.inputName.text = ""
this.inputAnnounce.text = defaultAnnounce
this.successFunc = successFunc
-- 创建消耗
local cost = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1).CreatCost
2021-01-26 17:08:39 +08:00
local costName = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig, cost[1][1]).Name)
2021-03-02 16:53:12 +08:00
this.costTip.text = string.format(Language[10848], cost[1][2], costName)
2021-02-24 20:24:58 +08:00
this.text1.fontSize = GetCurLanguage() ~= 2 and 48 or 40
this.text2.fontSize = GetCurLanguage() ~= 2 and 48 or 40
2020-05-09 13:31:21 +08:00
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function GuildCreatePopup:OnShow()
end
--界面关闭时调用(用于子类重写)
function GuildCreatePopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function GuildCreatePopup:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
end
2020-06-23 18:36:24 +08:00
return GuildCreatePopup