local private = {} local MessageBox_Utility = {} local type = type local EventSystem = require('Event/EventSystem') MessageBox_Utility.BoxType = { OnlyOk = 1, OKCancel = 2, WithToggle = 3, OnlyOkNoClose = 4, OKCancelNoClose = 5, } MessageBox_Utility.DisplayType = { ReconnectTip = 1, ExitGameTip = 2, PauseBattle = 3, KCPReconnectTip = 4, SDKLoginFailed = 5, } private.waitingQueue = {} private.isOpenWaiting = false local DisplayTypeView = {}; --[[ @desc: author:{author} time:2020-04-09 10:27:45 --@title:提示框标题 --@content:提示框显示内容 --@okCB:提示框点击按钮之后的回调 --@btnText: 提示框按钮文字 可以不填 默认为确定 @return: ]] function MessageBox_Utility.ShowOnlyOkBox(title,content,okCB,btnText, displayType) if displayType then if DisplayTypeView[displayType] then return; end DisplayTypeView[displayType] = true; end local context = {} context.title = private.GetTitle(title) context.content = content context.okCB = private.GetLuaFunc(okCB) context.type = MessageBox_Utility.BoxType.OnlyOk context.okBtnText = btnText or private.GetOkText() context.displayType = displayType UIManager.OpenView(Const_UI_Lua.UIEnum.UIMessageBoxView,context) end --[[ @desc: author:{author} time:2020-04-09 10:27:45 --@title:提示框标题 --@content:提示框显示内容 --@okCB:提示框点击按钮之后的回调 --@btnText: 提示框按钮文字 可以不填 默认为确定 @return: ]] function MessageBox_Utility.ShowOnlyOkNoCloseBox(title,content,okCB,btnText, displayType) if displayType then if DisplayTypeView[displayType] then return; end DisplayTypeView[displayType] = true; end local context = {} context.title = private.GetTitle(title) context.content = content context.okCB = private.GetLuaFunc(okCB) context.type = MessageBox_Utility.BoxType.OnlyOkNoClose context.okBtnText = btnText or private.GetOkText() context.displayType = displayType UIManager.OpenView(Const_UI_Lua.UIEnum.UIMessageBoxView,context) end --[[ @desc: author:{author} time:2020-04-09 10:40:07 --@title:提示框标题 --@content:提示框显示内容 --@okCB:提示框点击右边按钮之后的回调 --@cancelCB:提示框点击左边按钮的回调 --@okBtnText:右边按钮文字 默认为确定 --@cancelBtnText: 左边按钮文字 默认为取消 --@displayType: --@prefabUse[option]:包装使用的Prefab,默认nil @return: ]] function MessageBox_Utility.ShowOKCancelBox(title, content, okCB, cancelCB, okBtnText, cancelBtnText, displayType, prefabUse) if displayType then if DisplayTypeView[displayType] then return end DisplayTypeView[displayType] = true end local context = {} context.title = private.GetTitle(title) context.content = content context.okCB = private.GetLuaFunc(okCB) context.cancelCB = private.GetLuaFunc(cancelCB) context.okBtnText = okBtnText or private.GetOkText() context.cancelBtnText = cancelBtnText or private.GetCancelText() context.type = MessageBox_Utility.BoxType.OKCancel context.displayType = displayType UIManager.OpenView(Const_UI_Lua.UIEnum.UIMessageBoxView, context, prefabUse) end function MessageBox_Utility.ShowSettingOKCancelBox(title,content,okCB,cancelCB,okBtnText,cancelBtnText, displayType) if displayType then if DisplayTypeView[displayType] then return; end DisplayTypeView[displayType] = true; end local context = {} context.title = private.GetTitle(title) context.content = content context.okCB = private.GetLuaFunc(okCB) context.cancelCB = private.GetLuaFunc(cancelCB) context.okBtnText = okBtnText or private.GetOkText() context.cancelBtnText = cancelBtnText or private.GetCancelText() context.type = MessageBox_Utility.BoxType.OKCancel context.displayType = displayType UIManager.OpenView(Const_UI_Lua.UIEnum.UIMessageBoxSettingView, context, "MessageBox/UIMessageBoxView") end function MessageBox_Utility.ShowSettingOnlyOKBox(title, content, okCB, okBtnText, displayType) if displayType then if DisplayTypeView[displayType] then return; end DisplayTypeView[displayType] = true; end local context = {} context.title = private.GetTitle(title) context.content = content context.okCB = private.GetLuaFunc(okCB) context.okBtnText = okBtnText or private.GetOkText() context.type = MessageBox_Utility.BoxType.OnlyOk context.displayType = displayType UIManager.OpenView(Const_UI_Lua.UIEnum.UIMessageBoxSettingView, context, "MessageBox/UIMessageBoxView") end function MessageBox_Utility.ShowOKCancelNoCloseBox(title,content,okCB,cancelCB,okBtnText,cancelBtnText,displayType) if displayType then if DisplayTypeView[displayType] then return; end DisplayTypeView[displayType] = true; end local context = {} context.title = private.GetTitle(title) context.content = content context.okCB = private.GetLuaFunc(okCB) context.cancelCB = private.GetLuaFunc(cancelCB) context.okBtnText = okBtnText or private.GetOkText() context.cancelBtnText = cancelBtnText or private.GetCancelText() context.type = MessageBox_Utility.BoxType.OKCancelNoClose context.displayType = displayType UIManager.OpenView(Const_UI_Lua.UIEnum.UIMessageBoxView,context) end --[[ @desc: author:{author} time:2020-04-09 10:41:24 --@title:提示框标题 --@content:提示框显示内容 --@toggleContent: toggle文字 --@okCB():提示框点击右边按钮之后的回调 --@cancelCB:提示框点击左边按钮的回调 --@toggleCB:toggle回调 --@okBtnText:右边按钮文字 默认为确定 --@cancelBtnText: 左边按钮文字 默认为取消 @return: ]] function MessageBox_Utility.ShowOKCancelToggleBox(title, content, toggleContent, okCB, toggleCB, cancelCB, okBtnText,cancelBtnText) local context = {} context.title = private.GetTitle(title) context.content = content context.toggleContent = toggleContent or private.GetToggleContent() context.okCB = private.GetLuaFunc(okCB) context.cancelCB = private.GetLuaFunc(cancelCB) context.toggleCB = private.GetLuaFunc(toggleCB) context.okBtnText = okBtnText or private.GetOkText() context.cancelBtnText = cancelBtnText or private.GetCancelText() context.type = MessageBox_Utility.BoxType.WithToggle UIManager.OpenView(Const_UI_Lua.UIEnum.UIMessageBoxView,context) end function MessageBox_Utility.OnCloseBoxView(displayType) if not displayType then return; end DisplayTypeView[displayType] = nil; end --@title:提示框标题 --@content1:提示框显示内容1 --@content2:提示框显示内容2 --@okCB:提示框点击右边按钮之后的回调 --@cancelCB:提示框点击左边按钮的回调 --@okBtnText:右边按钮文字 默认为确定 --@cancelBtnText: 左边按钮文字 默认为取消 --@unClickContent: 无法点击时飘字内容,不为空时后面参数无用 --@freeContent: 右边按钮上方显示文字,不为空时后面参数无用 --@coinType: 右边按钮上方显示货币类型,传枚举值MDL.Currency.CurrencyType --@coinValue: 右边按钮上方显示货币值,当前货币足够显示绿色,不足显示红色且按钮置灰 --@isHideCoin:是否隐藏按钮上方货币或者文字 function MessageBox_Utility.ShowPurchaseView(title,content1,content2,okCB,cancelCB,okBtnText,cancelBtnText,unClickContent,freeContent,coinType,coinValue,isHideCoin) local context = {} context.title = private.GetTitle(title) context.content1 = content1 context.content2 = content2 context.okCB = okCB context.cancelCB = cancelCB context.okBtnText = okBtnText or private.GetOkText() context.cancelBtnText = cancelBtnText or private.GetCancelText() context.unClickContent = unClickContent context.freeContent = freeContent context.coinType = coinType context.coinValue = coinValue context.isHideCoin = isHideCoin UIManager.OpenView(Const_UI_Lua.UIEnum.UIMessageConsumeView,context) end function MessageBox_Utility.ShowInputOkBox(title,okCB,btnText,defaultInputText) local context = {} context.title = private.GetTitle(title) context.okCB = private.GetLuaFunc(okCB) context.okBtnText = btnText or private.GetOkText() context.cancelBtnText = private.GetCancelText() context.defaultInputText = defaultInputText or Const_IDS.IDS_Chat_Hint1 UIManager.OpenView(Const_UI_Lua.UIEnum.UIMessageInputView,context) end function MessageBox_Utility.ShowCountDownBox(title,content,okCB,cancelCB,okBtnText,cancelBtnText,time) local context = {} context.title = private.GetTitle(title) context.content = content context.okCB = private.GetLuaFunc(okCB) context.cancelCB = private.GetLuaFunc(cancelCB) context.okBtnText = okBtnText or private.GetOkText() context.cancelBtnText = cancelBtnText or private.GetCancelText() context.time = time UIManager.OpenView(Const_UI_Lua.UIEnum.UIMessageBoxCountDownView,context) end function private.IsTabType(value) return type(value) == 'table' end function MessageBox_Utility.ShowWaitingWithDelay(id, context) table.insert(private.waitingQueue, id) if private.isOpenWaiting == false then private.isOpenWaiting = true UIManager.OpenSpecialView(Const_UI_Lua.UIEnum.UIWaitingWithDelayView, context) else EventSystem.Dispatch(EventID.UI_Refresh_WaitingDelay, context) end end function MessageBox_Utility.CloseWaitingWithDelay(id) if private.isOpenWaiting == false then return end --id可能是数组 local isTab = private.IsTabType(id) for i, v in ipairs(private.waitingQueue) do if private.IsTabType(v) and isTab == false then for _,vv in ipairs(v) do if vv == id then table.remove(private.waitingQueue, i) break end end else if v == id then table.remove(private.waitingQueue, i) break end end end if #private.waitingQueue == 0 then private.isOpenWaiting = false UIManager.CloseSpecialView(Const_UI_Lua.UIEnum.UIWaitingWithDelayView) end end function MessageBox_Utility.ForceCloseWaiting() if private.isOpenWaiting then private.isOpenWaiting = false table.clearArray(private.waitingQueue) UIManager.CloseSpecialView(Const_UI_Lua.UIEnum.UIWaitingWithDelayView) end end function private.GetOkText() return Const_IDS.IDS_BUTTON_CONFIRM end function private.GetCancelText() return Const_IDS.IDS_BUTTON_CANCEL end function private.GetToggleContent() return UIUtils.GetLocalizedTxt(Const_IDS.IDS_NewClimbTower_NoTips) end function private.GetTitle(title) if string.isNilOrEmpty(title) then return Const_IDS.IDS_COMMON_PROMPT else return title end end function private.GetLuaFunc(func) if type(func) == "userdata" then return function ( ) func:Call() end end return func end function MessageBox_Utility.RecoverPostion(uiCommonPopView) UIUtils.SetRectPosition(uiCommonPopView.btn_1, 261, -280) uiCommonPopView.btn_1:SetText(Const_IDS.IDS_BUTTON_CONFIRM) uiCommonPopView.btn_2:SetText(Const_IDS.IDS_BUTTON_CANCEL) end return MessageBox_Utility