Initial version - 1.2.0.60
EN: 1.2.0.60 CN: 1.2.0.61 JP: 1.2.0.63 KR: 1.2.0.67
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
local GameResourceLoader = require("Game.Common.Resource.GameResourceLoader")
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local AvgManager = {}
|
||||
local objAvgPanel, objAvgBubblePanel
|
||||
local nTransitionType = 0
|
||||
local bInAvg = false
|
||||
local OnEvent_AvgBBEnd = function(_)
|
||||
if objAvgBubblePanel ~= nil then
|
||||
objAvgBubblePanel:_PreExit()
|
||||
objAvgBubblePanel:_Exit()
|
||||
objAvgBubblePanel:_Destroy()
|
||||
objAvgBubblePanel = nil
|
||||
end
|
||||
end
|
||||
local OnEvent_AvgBBStart = function(_, sAvgId, sGroupId, sLanguage, sVoLan)
|
||||
OnEvent_AvgBBEnd(_)
|
||||
local AvgBubblePanel = require("Game.UI.AvgBubble.AvgBubblePanel")
|
||||
if sLanguage == nil then
|
||||
sLanguage = Settings.sCurrentTxtLanguage
|
||||
end
|
||||
if sVoLan == nil then
|
||||
sVoLan = Settings.sCurrentVoLanguage
|
||||
end
|
||||
objAvgBubblePanel = AvgBubblePanel.new(AllEnum.UI_SORTING_ORDER.AVG_Bubble, PanelId.AvgBB, {
|
||||
sAvgId,
|
||||
sGroupId,
|
||||
sLanguage,
|
||||
sVoLan
|
||||
})
|
||||
objAvgBubblePanel:_PreEnter()
|
||||
objAvgBubblePanel:_Enter()
|
||||
end
|
||||
local OnEvent_AvgSTStart = function(_, sAvgId, sLanguage, sVoLan, sGroupId, nStartCMDID, sTransStyle)
|
||||
local nStyle = 11
|
||||
if type(sTransStyle) == "string" and sTransStyle ~= "" then
|
||||
local sStyle = string.gsub(sTransStyle, "style_", "")
|
||||
local _n = tonumber(sStyle)
|
||||
if type(_n) == "number" then
|
||||
nStyle = _n
|
||||
end
|
||||
end
|
||||
bInAvg = true
|
||||
local func_DoStart = function()
|
||||
if sLanguage == nil then
|
||||
sLanguage = Settings.sCurrentTxtLanguage
|
||||
end
|
||||
if sVoLan == nil then
|
||||
sVoLan = Settings.sCurrentVoLanguage
|
||||
end
|
||||
OnEvent_AvgBBEnd(_)
|
||||
local AvgPanel = require("Game.UI.Avg.AvgPanel")
|
||||
objAvgPanel = AvgPanel.new(AllEnum.UI_SORTING_ORDER.AVG_ST, PanelId.AvgST, {
|
||||
sAvgId,
|
||||
sLanguage,
|
||||
sVoLan,
|
||||
sGroupId,
|
||||
nStartCMDID
|
||||
})
|
||||
objAvgPanel:_PreEnter()
|
||||
objAvgPanel:_Enter()
|
||||
end
|
||||
local func_OnEvent_TransAnimInClear = function()
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
func_DoStart()
|
||||
end
|
||||
if AVG_EDITOR == true then
|
||||
func_DoStart()
|
||||
elseif sAvgId == Settings.sPrologueAvgId1 or sAvgId == Settings.sPrologueAvgId2 then
|
||||
EventManager.Hit(EventId.HideProloguePanle, false)
|
||||
EventManager.Hit("__CloseLoadingView", nil, nil, 0.5)
|
||||
func_DoStart()
|
||||
else
|
||||
local sAvgIdHead = string.sub(sAvgId, 1, 2)
|
||||
if sAvgIdHead == "ST" or sAvgIdHead == "CG" or sAvgIdHead == "DP" then
|
||||
nTransitionType = sAvgIdHead == "DP" and 12 or nStyle
|
||||
EventManager.Hit(EventId.SetTransition, nTransitionType, func_OnEvent_TransAnimInClear)
|
||||
else
|
||||
func_DoStart()
|
||||
end
|
||||
end
|
||||
end
|
||||
local OnEvent_AvgSTEnd = function(_)
|
||||
local func_DoEnd = function()
|
||||
NovaAPI.DispatchEventWithData("StoryDialog_DialogEnd")
|
||||
if objAvgPanel ~= nil then
|
||||
objAvgPanel:_PreExit()
|
||||
objAvgPanel:_Exit()
|
||||
objAvgPanel:_Destroy()
|
||||
objAvgPanel = nil
|
||||
NovaAPI.SetScreenSleepTimeout(false)
|
||||
end
|
||||
if AVG_EDITOR ~= true then
|
||||
GameResourceLoader.Unload("UI", "ui_avg")
|
||||
end
|
||||
GameResourceLoader.Unload("ImageAvg")
|
||||
GameResourceLoader.Unload("Actor2DAvg")
|
||||
bInAvg = false
|
||||
end
|
||||
local func_OnEvent_TransAnimInClear = function()
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
func_DoEnd()
|
||||
end
|
||||
if nTransitionType ~= 0 then
|
||||
if nTransitionType == 12 then
|
||||
func_DoEnd()
|
||||
else
|
||||
EventManager.Hit(EventId.SetTransition, nTransitionType, func_OnEvent_TransAnimInClear)
|
||||
end
|
||||
nTransitionType = 0
|
||||
else
|
||||
func_DoEnd()
|
||||
end
|
||||
end
|
||||
local function Uninit(_)
|
||||
if objAvgPanel ~= nil then
|
||||
OnEvent_AvgSTEnd(_)
|
||||
end
|
||||
EventManager.Remove("StoryDialog_DialogStart", AvgManager, OnEvent_AvgSTStart)
|
||||
EventManager.Remove("StoryDialog_DialogEnd", AvgManager, OnEvent_AvgSTEnd)
|
||||
OnEvent_AvgBBEnd(_)
|
||||
EventManager.Remove(EventId.AvgBubbleShow, AvgManager, OnEvent_AvgBBStart)
|
||||
EventManager.Remove(EventId.AvgBubbleExit, AvgManager, OnEvent_AvgBBEnd)
|
||||
EventManager.Remove(EventId.CSLuaManagerShutdown, AvgManager, Uninit)
|
||||
end
|
||||
function AvgManager.Init()
|
||||
EventManager.Add("StoryDialog_DialogStart", AvgManager, OnEvent_AvgSTStart)
|
||||
EventManager.Add("StoryDialog_DialogEnd", AvgManager, OnEvent_AvgSTEnd)
|
||||
EventManager.Add(EventId.AvgBubbleShow, AvgManager, OnEvent_AvgBBStart)
|
||||
EventManager.Add(EventId.AvgBubbleExit, AvgManager, OnEvent_AvgBBEnd)
|
||||
EventManager.Add(EventId.CSLuaManagerShutdown, AvgManager, Uninit)
|
||||
end
|
||||
function AvgManager.CheckInAvg()
|
||||
return bInAvg
|
||||
end
|
||||
return AvgManager
|
||||
@@ -0,0 +1,467 @@
|
||||
local GamepadUIManager = {}
|
||||
local InputManager = CS.InputManager
|
||||
local ClientManager = CS.ClientManager.Instance
|
||||
local sRootPath = Settings.AB_ROOT_PATH
|
||||
local nCurUIType = AllEnum.GamepadUIType.Other
|
||||
local sCurUIName
|
||||
local tbHistory = {}
|
||||
local mapGamepadUI = {}
|
||||
local mapMouseConfig = {}
|
||||
local bEnableInput = false
|
||||
local bBlockUI = false
|
||||
local bFirstInputEnable = false
|
||||
local SetGamepadIcon = function(img, sAction)
|
||||
local sIcon
|
||||
if nCurUIType == AllEnum.GamepadUIType.PS then
|
||||
sIcon = ConfigTable.GetField("GamepadAction", sAction, "PlayStationIcon")
|
||||
elseif nCurUIType == AllEnum.GamepadUIType.Xbox then
|
||||
sIcon = ConfigTable.GetField("GamepadAction", sAction, "XboxIcon")
|
||||
elseif nCurUIType == AllEnum.GamepadUIType.Keyboard or nCurUIType == AllEnum.GamepadUIType.Mouse then
|
||||
sIcon = ConfigTable.GetField("GamepadAction", sAction, "KeyboardIcon")
|
||||
end
|
||||
if sIcon == "" then
|
||||
img.gameObject:SetActive(false)
|
||||
return
|
||||
end
|
||||
img.gameObject:SetActive(true)
|
||||
sIcon = sRootPath .. sIcon .. ".png"
|
||||
NovaAPI.SetImageSprite(img, sIcon)
|
||||
NovaAPI.SetImageNativeSize(img)
|
||||
end
|
||||
local RefreshCurTypeUINode = function(v)
|
||||
if not v.sAction then
|
||||
return
|
||||
end
|
||||
if v.sComponentName == "NaviButton" then
|
||||
if v.mapNode:IsNull() then
|
||||
return
|
||||
end
|
||||
local trRoot = v.mapNode.gameObject:GetComponent("Transform"):Find("AnimRoot")
|
||||
if trRoot then
|
||||
local Other = trRoot:Find("Other")
|
||||
if not Other then
|
||||
return
|
||||
end
|
||||
local General = trRoot:Find("General")
|
||||
local Xbox = trRoot:Find("Xbox")
|
||||
local PS = trRoot:Find("PS")
|
||||
local Keyboard = trRoot:Find("Keyboard")
|
||||
if General then
|
||||
if Xbox then
|
||||
Xbox.gameObject:SetActive(false)
|
||||
end
|
||||
if PS then
|
||||
PS.gameObject:SetActive(false)
|
||||
end
|
||||
if Keyboard then
|
||||
Keyboard.gameObject:SetActive(false)
|
||||
end
|
||||
General.gameObject:SetActive(nCurUIType ~= AllEnum.GamepadUIType.Other)
|
||||
Other.gameObject:SetActive(nCurUIType == AllEnum.GamepadUIType.Other)
|
||||
if nCurUIType ~= AllEnum.GamepadUIType.Other then
|
||||
local icon = General:Find("imgAction")
|
||||
if icon then
|
||||
SetGamepadIcon(icon:GetComponent("Image"), v.sAction)
|
||||
end
|
||||
end
|
||||
elseif not General and Xbox and PS and Keyboard then
|
||||
Xbox.gameObject:SetActive(nCurUIType == AllEnum.GamepadUIType.Xbox)
|
||||
PS.gameObject:SetActive(nCurUIType == AllEnum.GamepadUIType.PS)
|
||||
Keyboard.gameObject:SetActive(nCurUIType == AllEnum.GamepadUIType.Keyboard or nCurUIType == AllEnum.GamepadUIType.Mouse)
|
||||
Other.gameObject:SetActive(nCurUIType == AllEnum.GamepadUIType.Other)
|
||||
local icon
|
||||
if nCurUIType == AllEnum.GamepadUIType.Xbox then
|
||||
icon = Xbox:Find("imgAction")
|
||||
elseif nCurUIType == AllEnum.GamepadUIType.PS then
|
||||
icon = PS:Find("imgAction")
|
||||
elseif nCurUIType == AllEnum.GamepadUIType.Keyboard or nCurUIType == AllEnum.GamepadUIType.Mouse then
|
||||
icon = Keyboard:Find("imgAction")
|
||||
end
|
||||
if icon then
|
||||
SetGamepadIcon(icon:GetComponent("Image"), v.sAction)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif v.sComponentName == "GamepadScroll" then
|
||||
if v.mapNode:IsNull() then
|
||||
return
|
||||
end
|
||||
local trRoot = v.mapNode.gameObject:GetComponent("Transform"):Find("Scrollbar")
|
||||
if trRoot then
|
||||
local icon = trRoot:Find("imgAction")
|
||||
if icon then
|
||||
icon.gameObject:SetActive(nCurUIType ~= AllEnum.GamepadUIType.Other)
|
||||
if nCurUIType ~= AllEnum.GamepadUIType.Other then
|
||||
SetGamepadIcon(icon:GetComponent("Image"), v.sAction)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local RefreshCurTypeUI = function()
|
||||
if not sCurUIName then
|
||||
return
|
||||
end
|
||||
local tbNode = mapGamepadUI[sCurUIName]
|
||||
if (tbNode == nil or next(tbNode) == nil) and mapMouseConfig[sCurUIName] == nil then
|
||||
printWarn("GamepadUIManager:当前UI内节点刷新失败,可能该UI从来没有打开过:" .. sCurUIName)
|
||||
return
|
||||
end
|
||||
for _, v in pairs(tbNode) do
|
||||
RefreshCurTypeUINode(v)
|
||||
end
|
||||
end
|
||||
local ChangeUIType = function(nAfterType)
|
||||
if nAfterType == nCurUIType then
|
||||
return
|
||||
end
|
||||
local nBeforeType = nCurUIType
|
||||
nCurUIType = nAfterType
|
||||
EventManager.Hit("GamepadUIChange", sCurUIName, nBeforeType, nAfterType)
|
||||
RefreshCurTypeUI()
|
||||
end
|
||||
local GetUITypeByGamepad = function()
|
||||
local nType = InputManager.Instance:CheckGamepadType()
|
||||
local nAfterType = AllEnum.GamepadUIType.Other
|
||||
if nType == InputManager.GamepadType.PS then
|
||||
nAfterType = AllEnum.GamepadUIType.PS
|
||||
elseif nType == InputManager.GamepadType.XBox or nType == InputManager.GamepadType.Switch or nType == InputManager.GamepadType.Other then
|
||||
nAfterType = AllEnum.GamepadUIType.Xbox
|
||||
elseif nType == InputManager.GamepadType.None then
|
||||
nAfterType = AllEnum.GamepadUIType.Other
|
||||
end
|
||||
return nAfterType
|
||||
end
|
||||
local OnEvent_LastInputDeviceChange = function(_, nType)
|
||||
local bMobile = NovaAPI.IsMobilePlatform()
|
||||
local bTable = ClientManager.isTabletDevice
|
||||
local nAfterType = AllEnum.GamepadUIType.Other
|
||||
if nType == InputManager.InputDeviceType.PSGamepad then
|
||||
nAfterType = AllEnum.GamepadUIType.PS
|
||||
elseif nType == InputManager.InputDeviceType.XBoxGamepad then
|
||||
nAfterType = AllEnum.GamepadUIType.Xbox
|
||||
elseif nType == InputManager.InputDeviceType.Keyboard and (not bMobile or bTable) then
|
||||
nAfterType = AllEnum.GamepadUIType.Keyboard
|
||||
elseif nType == InputManager.InputDeviceType.Mouse and (not bMobile or bTable) then
|
||||
nAfterType = AllEnum.GamepadUIType.Mouse
|
||||
elseif nType == InputManager.InputDeviceType.Other then
|
||||
nAfterType = GetUITypeByGamepad()
|
||||
elseif nType == InputManager.InputDeviceType.None then
|
||||
nAfterType = AllEnum.GamepadUIType.Other
|
||||
end
|
||||
ChangeUIType(nAfterType)
|
||||
end
|
||||
local GetUITypeByInputDevice = function()
|
||||
local bMobile = NovaAPI.IsMobilePlatform()
|
||||
local nType = InputManager.Instance:CheckInputDeviceType()
|
||||
local nAfterType = AllEnum.GamepadUIType.Other
|
||||
if nType == InputManager.InputDeviceType.PSGamepad then
|
||||
nAfterType = AllEnum.GamepadUIType.PS
|
||||
elseif nType == InputManager.InputDeviceType.XBoxGamepad then
|
||||
nAfterType = AllEnum.GamepadUIType.Xbox
|
||||
elseif nType == InputManager.InputDeviceType.Keyboard and not bMobile then
|
||||
nAfterType = AllEnum.GamepadUIType.Keyboard
|
||||
elseif nType == InputManager.InputDeviceType.Mouse and not bMobile then
|
||||
nAfterType = AllEnum.GamepadUIType.Mouse
|
||||
elseif nType == InputManager.InputDeviceType.Other then
|
||||
nAfterType = GetUITypeByGamepad()
|
||||
elseif nType == InputManager.InputDeviceType.None then
|
||||
nAfterType = AllEnum.GamepadUIType.Other
|
||||
end
|
||||
return nAfterType
|
||||
end
|
||||
local OnEvent_OnDeviceChange = function(_, changeType)
|
||||
if changeType.value__ == 0 or changeType.value__ == 1 then
|
||||
local nAfterType = GetUITypeByInputDevice()
|
||||
ChangeUIType(nAfterType)
|
||||
end
|
||||
end
|
||||
local OnEvent_BlockGamepadUI = function(_, bBlock)
|
||||
bBlockUI = bBlock
|
||||
if not sCurUIName then
|
||||
return
|
||||
end
|
||||
local tbNode = mapGamepadUI[sCurUIName]
|
||||
if tbNode == nil or next(tbNode) == nil then
|
||||
return
|
||||
end
|
||||
for _, v in pairs(tbNode) do
|
||||
if v.mapNode:IsNull() == false then
|
||||
if bFirstInputEnable then
|
||||
NovaAPI.SetComponentEnable(v.mapNode, not bBlock)
|
||||
else
|
||||
NovaAPI.SetComponentEnable(v.mapNode, false)
|
||||
end
|
||||
else
|
||||
printWarn("GamepadUIManager:当前UI实例已销毁,无需屏蔽:" .. sCurUIName)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
local EnableNode = function(sCtrlName)
|
||||
if not sCtrlName then
|
||||
printWarn("GamepadUIManager:当前UI内节点打开失败,CtrlName为空")
|
||||
return
|
||||
end
|
||||
if NovaAPI.IsEditorPlatform() then
|
||||
printLog("GamepadUIManager:Enable UI " .. sCtrlName)
|
||||
end
|
||||
local tbNode = mapGamepadUI[sCtrlName]
|
||||
if (tbNode == nil or next(tbNode) == nil) and mapMouseConfig[sCurUIName] == nil then
|
||||
printWarn("GamepadUIManager:当前UI内节点打开失败,可能该UI从来没有打开过:" .. sCtrlName)
|
||||
return
|
||||
end
|
||||
for _, v in pairs(tbNode) do
|
||||
if v.mapNode:IsNull() then
|
||||
printError("GamepadUIManager:当前UI内节点打开失败,UI实例已销毁:" .. sCtrlName)
|
||||
return
|
||||
end
|
||||
if not bBlockUI and bFirstInputEnable then
|
||||
if v.mapNode.enabled == true then
|
||||
NovaAPI.SetComponentEnable(v.mapNode, false)
|
||||
end
|
||||
NovaAPI.SetComponentEnable(v.mapNode, true)
|
||||
else
|
||||
NovaAPI.SetComponentEnable(v.mapNode, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
local DisableNode = function(sCtrlName)
|
||||
if not sCtrlName then
|
||||
printWarn("GamepadUIManager:当前UI内节点关闭失败,CtrlName为空")
|
||||
return
|
||||
end
|
||||
if NovaAPI.IsEditorPlatform() then
|
||||
printLog("GamepadUIManager:Disable UI " .. sCtrlName)
|
||||
end
|
||||
local tbNode = mapGamepadUI[sCtrlName]
|
||||
if (tbNode == nil or next(tbNode) == nil) and mapMouseConfig[sCurUIName] == nil then
|
||||
printWarn("GamepadUIManager:当前UI内节点关闭失败,可能该UI从来没有打开过:" .. sCtrlName)
|
||||
return
|
||||
end
|
||||
for _, v in pairs(tbNode) do
|
||||
if v.mapNode:IsNull() then
|
||||
printError("GamepadUIManager:当前UI内节点关闭失败,UI实例已销毁:" .. sCtrlName)
|
||||
return
|
||||
end
|
||||
NovaAPI.SetComponentEnable(v.mapNode, false)
|
||||
end
|
||||
end
|
||||
local OnEvent_FirstInputEnable = function()
|
||||
bFirstInputEnable = true
|
||||
if sCurUIName then
|
||||
EnableNode(sCurUIName)
|
||||
end
|
||||
end
|
||||
local OnEvent_OpenBuiltinAlert = function(_, bOpen, _okBtn, _confirmBtn, _cancelBtn)
|
||||
if not bEnableInput then
|
||||
NovaAPI.SetNaviButtonAction(_okBtn, false)
|
||||
NovaAPI.SetNaviButtonAction(_confirmBtn, false)
|
||||
NovaAPI.SetNaviButtonAction(_cancelBtn, false)
|
||||
return
|
||||
end
|
||||
if bOpen then
|
||||
local tbGamepadUINode = {
|
||||
[1] = {
|
||||
mapNode = _okBtn,
|
||||
sComponentName = "NaviButton",
|
||||
sAction = "buttonSouth"
|
||||
},
|
||||
[2] = {
|
||||
mapNode = _confirmBtn,
|
||||
sComponentName = "NaviButton",
|
||||
sAction = "buttonSouth"
|
||||
},
|
||||
[3] = {
|
||||
mapNode = _cancelBtn,
|
||||
sComponentName = "NaviButton",
|
||||
sAction = "buttonEast"
|
||||
}
|
||||
}
|
||||
GamepadUIManager.EnableGamepadUI("BuiltinUI", tbGamepadUINode)
|
||||
NovaAPI.SetNaviButtonAction(_okBtn, true)
|
||||
NovaAPI.SetNaviButtonAction(_confirmBtn, true)
|
||||
NovaAPI.SetNaviButtonAction(_cancelBtn, true)
|
||||
else
|
||||
GamepadUIManager.DisableGamepadUI("BuiltinUI")
|
||||
end
|
||||
end
|
||||
local function Uninit(_)
|
||||
EventManager.Remove("LuaEventName_OnDeviceChange", GamepadUIManager, OnEvent_OnDeviceChange)
|
||||
EventManager.Remove("LuaEventName_LastInputDeviceChange", GamepadUIManager, OnEvent_LastInputDeviceChange)
|
||||
EventManager.Remove("__BlockGamepadUI", GamepadUIManager, OnEvent_BlockGamepadUI)
|
||||
EventManager.Remove("FirstInputEnable", GamepadUIManager, OnEvent_FirstInputEnable)
|
||||
EventManager.Remove("__OpenBuiltinAlert", GamepadUIManager, OnEvent_OpenBuiltinAlert)
|
||||
EventManager.Remove(EventId.CSLuaManagerShutdown, GamepadUIManager, Uninit)
|
||||
end
|
||||
function GamepadUIManager.Init()
|
||||
nCurUIType = GetUITypeByInputDevice()
|
||||
EventManager.Add("LuaEventName_OnDeviceChange", GamepadUIManager, OnEvent_OnDeviceChange)
|
||||
EventManager.Add("LuaEventName_LastInputDeviceChange", GamepadUIManager, OnEvent_LastInputDeviceChange)
|
||||
EventManager.Add("__BlockGamepadUI", GamepadUIManager, OnEvent_BlockGamepadUI)
|
||||
EventManager.Add("FirstInputEnable", GamepadUIManager, OnEvent_FirstInputEnable)
|
||||
EventManager.Add("__OpenBuiltinAlert", GamepadUIManager, OnEvent_OpenBuiltinAlert)
|
||||
EventManager.Add(EventId.CSLuaManagerShutdown, GamepadUIManager, Uninit)
|
||||
end
|
||||
function GamepadUIManager.EnableGamepadUI(sCtrlName, tbNode, goDefaultSelected, bEnableVirtualMouse, bBlockCursor)
|
||||
if sCurUIName == sCtrlName then
|
||||
printWarn("GamepadUIManager:重复打开Gamepad UI:" .. sCtrlName)
|
||||
return
|
||||
end
|
||||
NovaAPI.ClearSelectedUI()
|
||||
if goDefaultSelected then
|
||||
NovaAPI.SetSelectedUI(goDefaultSelected)
|
||||
end
|
||||
InputManager.Instance.IsVirtualMouseEnabled = bEnableVirtualMouse == true
|
||||
InputManager.Instance.IsBlockCursor = bBlockCursor == true
|
||||
local bSwitch = false
|
||||
if sCurUIName then
|
||||
DisableNode(sCurUIName)
|
||||
bSwitch = true
|
||||
end
|
||||
sCurUIName = sCtrlName
|
||||
mapGamepadUI[sCurUIName] = clone(tbNode)
|
||||
if not mapMouseConfig[sCurUIName] then
|
||||
mapMouseConfig[sCurUIName] = {}
|
||||
end
|
||||
mapMouseConfig[sCurUIName].VirtualMouse = bEnableVirtualMouse == true
|
||||
mapMouseConfig[sCurUIName].BlockCursor = bBlockCursor == true
|
||||
table.insert(tbHistory, sCurUIName)
|
||||
RefreshCurTypeUI()
|
||||
if bSwitch then
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
EnableNode(sCurUIName)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
else
|
||||
EnableNode(sCurUIName)
|
||||
end
|
||||
end
|
||||
function GamepadUIManager.DisableGamepadUI(sCtrlName)
|
||||
local nIndex = table.indexof(tbHistory, sCtrlName)
|
||||
if nIndex == 0 then
|
||||
return
|
||||
end
|
||||
if sCurUIName == sCtrlName then
|
||||
DisableNode(sCtrlName)
|
||||
mapGamepadUI[sCtrlName] = nil
|
||||
mapMouseConfig[sCtrlName] = nil
|
||||
table.remove(tbHistory, nIndex)
|
||||
sCurUIName = nil
|
||||
if next(tbHistory) ~= nil then
|
||||
sCurUIName = tbHistory[#tbHistory]
|
||||
InputManager.Instance.IsVirtualMouseEnabled = mapMouseConfig[sCurUIName].VirtualMouse
|
||||
InputManager.Instance.IsBlockCursor = mapMouseConfig[sCurUIName].BlockCursor
|
||||
RefreshCurTypeUI()
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
if sCurUIName then
|
||||
EnableNode(sCurUIName)
|
||||
EventManager.Hit("GamepadUIReopen", sCurUIName)
|
||||
else
|
||||
printWarn("GamepadUIManager:关闭历史未找到对应ctrl")
|
||||
end
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
end
|
||||
else
|
||||
mapGamepadUI[sCtrlName] = nil
|
||||
mapMouseConfig[sCtrlName] = nil
|
||||
table.remove(tbHistory, nIndex)
|
||||
end
|
||||
end
|
||||
function GamepadUIManager.AddGamepadUINode(sCtrlName, tbNode)
|
||||
if not mapGamepadUI or not mapGamepadUI[sCtrlName] then
|
||||
printWarn("GamepadUIManager:当前ui不存在,添加节点失败Gamepad UI:" .. sCtrlName)
|
||||
return
|
||||
end
|
||||
for _, v in pairs(tbNode) do
|
||||
table.insert(mapGamepadUI[sCtrlName], v)
|
||||
end
|
||||
if sCurUIName == sCtrlName then
|
||||
EnableNode(sCtrlName)
|
||||
for _, v in pairs(tbNode) do
|
||||
RefreshCurTypeUINode(v)
|
||||
end
|
||||
else
|
||||
DisableNode(sCtrlName)
|
||||
end
|
||||
end
|
||||
function GamepadUIManager.SetSelectedUI(goSelected)
|
||||
NovaAPI.SetSelectedUI(goSelected)
|
||||
end
|
||||
function GamepadUIManager.ClearSelectedUI()
|
||||
NovaAPI.ClearSelectedUI()
|
||||
end
|
||||
function GamepadUIManager.SetNavigation(tbUIObj, bHorizontal, bLoop)
|
||||
if bHorizontal == nil then
|
||||
bHorizontal = true
|
||||
end
|
||||
if bLoop == nil then
|
||||
bLoop = true
|
||||
end
|
||||
NovaAPI.SetGamepadUINavigation(tbUIObj, bHorizontal, bLoop)
|
||||
end
|
||||
function GamepadUIManager.GetCurUIType()
|
||||
return nCurUIType
|
||||
end
|
||||
function GamepadUIManager.GetCurUIName()
|
||||
return sCurUIName
|
||||
end
|
||||
function GamepadUIManager.GetInputState()
|
||||
return bEnableInput
|
||||
end
|
||||
function GamepadUIManager.GetPrveUIName()
|
||||
if next(tbHistory) == nil then
|
||||
return
|
||||
end
|
||||
local nCount = #tbHistory
|
||||
if 1 < nCount then
|
||||
return tbHistory[nCount - 1]
|
||||
end
|
||||
end
|
||||
function GamepadUIManager.EnterAdventure(bSkipFirstInputEnable)
|
||||
InputManager.Instance.IsVirtualMouseEnabled = false
|
||||
InputManager.Instance.IsBlockCursor = false
|
||||
InputManager.Instance.IsBattleSubmit = true
|
||||
sCurUIName = nil
|
||||
tbHistory = {}
|
||||
mapGamepadUI = {}
|
||||
mapMouseConfig = {}
|
||||
bEnableInput = true
|
||||
bFirstInputEnable = bSkipFirstInputEnable
|
||||
end
|
||||
function GamepadUIManager.QuitAdventure()
|
||||
InputManager.Instance.IsVirtualMouseEnabled = true
|
||||
InputManager.Instance.IsBlockCursor = false
|
||||
InputManager.Instance.IsBattleSubmit = false
|
||||
sCurUIName = nil
|
||||
tbHistory = {}
|
||||
mapGamepadUI = {}
|
||||
mapMouseConfig = {}
|
||||
bEnableInput = false
|
||||
bFirstInputEnable = false
|
||||
end
|
||||
function GamepadUIManager.GetInputName(mapInput)
|
||||
if not mapInput.name or not mapInput.displayName then
|
||||
return
|
||||
end
|
||||
local sName = mapInput.displayName
|
||||
if string.find(mapInput.name, "left") then
|
||||
sName = string.gsub(mapInput.name, "left", "L-")
|
||||
elseif string.find(mapInput.name, "right") then
|
||||
sName = string.gsub(mapInput.name, "right", "R-")
|
||||
elseif sName == "Num Del" then
|
||||
sName = "Num."
|
||||
elseif string.find(mapInput.name, "numpad") then
|
||||
local position = string.find(sName, " ")
|
||||
if position then
|
||||
sName = "Num" .. string.sub(sName, position + 1)
|
||||
else
|
||||
sName = "Num" .. sName
|
||||
end
|
||||
end
|
||||
return sName
|
||||
end
|
||||
return GamepadUIManager
|
||||
@@ -0,0 +1,64 @@
|
||||
local LampNoticeManager = {}
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local Event = require("GameCore.Event.Event")
|
||||
local objNoticePanel, totalTimer, intervalTimer
|
||||
local CreateLampNoticePanel = function()
|
||||
local noticePanel = require("Game.UI.LampNotice.LampNoticePanel")
|
||||
objNoticePanel = noticePanel.new(AllEnum.UI_SORTING_ORDER.LampNotice, PanelId.LampNoticePanel, {})
|
||||
objNoticePanel:_PreEnter()
|
||||
objNoticePanel:_Enter()
|
||||
end
|
||||
local HideLampNotice = function(_, isDelay)
|
||||
if intervalTimer ~= nil then
|
||||
intervalTimer:_Stop()
|
||||
intervalTimer = nil
|
||||
end
|
||||
if totalTimer ~= nil then
|
||||
totalTimer:_Stop()
|
||||
totalTimer = nil
|
||||
end
|
||||
EventManager.Hit("CloseLampNotice", isDelay)
|
||||
end
|
||||
local ShowLampNotice = function(_, noticeData)
|
||||
HideLampNotice(nil, false)
|
||||
local stopLampNotice = function()
|
||||
HideLampNotice(nil, false)
|
||||
end
|
||||
totalTimer = TimerManager.Add(1, noticeData.nTotalTime, nil, stopLampNotice, true, true, false, nil)
|
||||
local showNoticeUI = function()
|
||||
EventManager.Hit("ShowNoticeContent", noticeData.sContent, noticeData.nShowTime)
|
||||
end
|
||||
local nCount = noticeData.nTotalTime // noticeData.nIntervalTime
|
||||
intervalTimer = TimerManager.Add(nCount, noticeData.nIntervalTime, nil, showNoticeUI, true, true, false, nil)
|
||||
EventManager.Hit("ShowNoticeContent", noticeData.sContent, noticeData.nShowTime)
|
||||
end
|
||||
local NoticeChangeNotify = function(_, msgData)
|
||||
if not UTILS.CheckChannelList_Notice(msgData.Channel) then
|
||||
return
|
||||
end
|
||||
if msgData.IsStop then
|
||||
HideLampNotice(nil, false)
|
||||
return
|
||||
end
|
||||
local noticeData = {
|
||||
sContent = msgData.Content,
|
||||
nShowTime = msgData.Duration,
|
||||
nIntervalTime = msgData.Interval,
|
||||
nTotalTime = msgData.EndTime - CS.ClientManager.Instance.serverTimeStamp
|
||||
}
|
||||
ShowLampNotice(_, noticeData)
|
||||
end
|
||||
local function Uninit()
|
||||
EventManager.Remove("NoticeChangeNotify", LampNoticeManager, NoticeChangeNotify)
|
||||
EventManager.Remove(EventId.OpenLampNotice, LampNoticeManager, ShowLampNotice)
|
||||
EventManager.Remove(EventId.CloseLampNotice, LampNoticeManager, HideLampNotice)
|
||||
EventManager.Remove(EventId.CSLuaManagerShutdown, LampNoticeManager, Uninit)
|
||||
end
|
||||
function LampNoticeManager.Init()
|
||||
CreateLampNoticePanel()
|
||||
EventManager.Add("NoticeChangeNotify", LampNoticeManager, NoticeChangeNotify)
|
||||
EventManager.Add(EventId.OpenLampNotice, LampNoticeManager, ShowLampNotice)
|
||||
EventManager.Add(EventId.CloseLampNotice, LampNoticeManager, HideLampNotice)
|
||||
EventManager.Add(EventId.CSLuaManagerShutdown, LampNoticeManager, Uninit)
|
||||
end
|
||||
return LampNoticeManager
|
||||
@@ -0,0 +1,117 @@
|
||||
local MessageBoxManager = {}
|
||||
local objMessageBoxPanel, objPopupTipsPanel, objSideBannerPanel, objOrderWaitPanel
|
||||
local OnEvent_Open = function(_, mapMsg, sLanguageId)
|
||||
if type(mapMsg) == "string" then
|
||||
mapMsg = {
|
||||
nType = AllEnum.MessageBox.Tips,
|
||||
bPositive = false,
|
||||
sContent = mapMsg
|
||||
}
|
||||
elseif mapMsg == true then
|
||||
mapMsg = {
|
||||
nType = AllEnum.MessageBox.Tips,
|
||||
bPositive = true,
|
||||
sContent = ConfigTable.GetUIText(sLanguageId)
|
||||
}
|
||||
end
|
||||
if mapMsg.nType == AllEnum.MessageBox.Tips then
|
||||
if objPopupTipsPanel == nil then
|
||||
local PopupTipsPanel = require("Game.UI.MessageBoxEx.PopupTipsPanel")
|
||||
objPopupTipsPanel = PopupTipsPanel.new(AllEnum.UI_SORTING_ORDER.MessageBoxOverlay, 0, mapMsg)
|
||||
objPopupTipsPanel:_PreEnter()
|
||||
objPopupTipsPanel:_Enter()
|
||||
else
|
||||
EventManager.Hit("ContinuePopupTips", mapMsg)
|
||||
end
|
||||
elseif objMessageBoxPanel == nil then
|
||||
local MessageBoxPanel = require("Game.UI.MessageBoxEx.MessageBoxPanel")
|
||||
objMessageBoxPanel = MessageBoxPanel.new(AllEnum.UI_SORTING_ORDER.MessageBox, 0, mapMsg)
|
||||
objMessageBoxPanel:_PreEnter()
|
||||
objMessageBoxPanel:_Enter()
|
||||
else
|
||||
EventManager.Hit("ContinueMessageBox", mapMsg)
|
||||
end
|
||||
end
|
||||
local OnEvent_ClosePopupTips = function(_)
|
||||
if objPopupTipsPanel then
|
||||
objPopupTipsPanel:_PreExit()
|
||||
objPopupTipsPanel:_Exit()
|
||||
objPopupTipsPanel:_Destroy()
|
||||
objPopupTipsPanel = nil
|
||||
end
|
||||
end
|
||||
local OnEvent_CloseMessageBox = function(_)
|
||||
if objMessageBoxPanel then
|
||||
objMessageBoxPanel:_PreExit()
|
||||
objMessageBoxPanel:_Exit()
|
||||
objMessageBoxPanel:_Destroy()
|
||||
objMessageBoxPanel = nil
|
||||
end
|
||||
end
|
||||
local OpenSideBannerPanel = function(mapMsg)
|
||||
local SideBannerPanel = require("Game.UI.SideBanner.SideBannerPanel")
|
||||
objSideBannerPanel = SideBannerPanel.new(AllEnum.UI_SORTING_ORDER.MessageBoxOverlay, 0, mapMsg)
|
||||
objSideBannerPanel:_PreEnter()
|
||||
objSideBannerPanel:_Enter()
|
||||
end
|
||||
local OnEvent_CloseSideBanner = function(_)
|
||||
if objSideBannerPanel then
|
||||
objSideBannerPanel:_PreExit()
|
||||
objSideBannerPanel:_Exit()
|
||||
objSideBannerPanel:_Destroy()
|
||||
objSideBannerPanel = nil
|
||||
end
|
||||
end
|
||||
local OnEvent_OpenSideBanner = function(_, mapMsg)
|
||||
if objSideBannerPanel == nil then
|
||||
OpenSideBannerPanel(mapMsg)
|
||||
else
|
||||
OnEvent_CloseSideBanner()
|
||||
OpenSideBannerPanel(mapMsg)
|
||||
end
|
||||
end
|
||||
local OpenOrderWaitPanel = function(mapMsg)
|
||||
local OrderWaitPanel = require("Game.UI.Mall.OrderWaitPanel")
|
||||
objOrderWaitPanel = OrderWaitPanel.new(AllEnum.UI_SORTING_ORDER.MessageBox, 0, mapMsg)
|
||||
objOrderWaitPanel:_PreEnter()
|
||||
objOrderWaitPanel:_Enter()
|
||||
end
|
||||
local OnEvent_CloseOrderWait = function(_)
|
||||
if objOrderWaitPanel then
|
||||
objOrderWaitPanel:_PreExit()
|
||||
objOrderWaitPanel:_Exit()
|
||||
objOrderWaitPanel:_Destroy()
|
||||
objOrderWaitPanel = nil
|
||||
end
|
||||
end
|
||||
local OnEvent_OpenOrderWait = function(_, mapMsg)
|
||||
if objOrderWaitPanel == nil then
|
||||
OpenOrderWaitPanel(mapMsg)
|
||||
else
|
||||
OnEvent_CloseOrderWait()
|
||||
OpenOrderWaitPanel(mapMsg)
|
||||
end
|
||||
end
|
||||
local function Uninit(_)
|
||||
EventManager.Remove(EventId.OpenMessageBox, MessageBoxManager, OnEvent_Open)
|
||||
EventManager.Remove(EventId.CloseMessageBox, MessageBoxManager, OnEvent_CloseMessageBox)
|
||||
EventManager.Remove("OpenSideBanner", MessageBoxManager, OnEvent_OpenSideBanner)
|
||||
EventManager.Remove("CloseSideBanner", MessageBoxManager, OnEvent_CloseSideBanner)
|
||||
EventManager.Remove("OpenOrderWait", MessageBoxManager, OnEvent_OpenOrderWait)
|
||||
EventManager.Remove("CloseOrderWait", MessageBoxManager, OnEvent_CloseOrderWait)
|
||||
EventManager.Remove(EventId.CSLuaManagerShutdown, MessageBoxManager, Uninit)
|
||||
end
|
||||
function MessageBoxManager.CheckOrderWaitOpen()
|
||||
return objOrderWaitPanel ~= nil
|
||||
end
|
||||
function MessageBoxManager.Init()
|
||||
EventManager.Add(EventId.OpenMessageBox, MessageBoxManager, OnEvent_Open)
|
||||
EventManager.Add(EventId.CloseMessageBox, MessageBoxManager, OnEvent_CloseMessageBox)
|
||||
EventManager.Add(EventId.ClosePopupTips, MessageBoxManager, OnEvent_ClosePopupTips)
|
||||
EventManager.Add("OpenSideBanner", MessageBoxManager, OnEvent_OpenSideBanner)
|
||||
EventManager.Add("CloseSideBanner", MessageBoxManager, OnEvent_CloseSideBanner)
|
||||
EventManager.Add("OpenOrderWait", MessageBoxManager, OnEvent_OpenOrderWait)
|
||||
EventManager.Add("CloseOrderWait", MessageBoxManager, OnEvent_CloseOrderWait)
|
||||
EventManager.Add(EventId.CSLuaManagerShutdown, MessageBoxManager, Uninit)
|
||||
end
|
||||
return MessageBoxManager
|
||||
@@ -0,0 +1,70 @@
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local ModuleManager = {}
|
||||
local bAdventure, curModuleName
|
||||
local GamepadUIManager = require("GameCore.Module.GamepadUIManager")
|
||||
local actor2dManager = require("Game.Actor2D.Actor2DManager")
|
||||
local OnEvent_EnterModule = function(moduleMgr, sExitModuleName, sEnterModuleName)
|
||||
bAdventure = false
|
||||
if sEnterModuleName == "MainMenuModuleScene" then
|
||||
if PlayerData.back2Login then
|
||||
PlayerData.back2Login = false
|
||||
PanelManager.OnConfirmBackToLogIn()
|
||||
elseif PlayerData.back2Home then
|
||||
PlayerData.back2Home = false
|
||||
PanelManager.Home()
|
||||
else
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.MainView)
|
||||
end
|
||||
PlayerData.Base:OnBackToMainMenuModule()
|
||||
elseif sEnterModuleName == "AdventureModuleScene" then
|
||||
NovaAPI.ShutdownDirtyWords()
|
||||
bAdventure = true
|
||||
PanelManager.Release()
|
||||
actor2dManager.ClearAll()
|
||||
PanelManager.ClearInputState()
|
||||
end
|
||||
end
|
||||
local OnEvent_ExitModule = function(moduleMgr, sExitModuleName, sEnterModuleName)
|
||||
if sExitModuleName == "AdventureModuleScene" then
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.Hud)
|
||||
end
|
||||
end
|
||||
local OnEvent_AfterEnterModule = function(moduleMgr, sEnterModuleName)
|
||||
curModuleName = sEnterModuleName
|
||||
if sEnterModuleName == "LoginModuleScene" then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Login)
|
||||
elseif sEnterModuleName == "MainMenuModuleScene" then
|
||||
EventManager.Hit(EventId.AfterEnterMain)
|
||||
CS.WwiseAudioManager.Instance:PostEvent("ui_loading_combatSFX_active", nil, false)
|
||||
elseif sEnterModuleName == "AdventureModuleScene" then
|
||||
if PlayerData.nCurGameType == AllEnum.WorldMapNodeType.Mainline then
|
||||
EventManager.Hit(EventId.EnterMainline)
|
||||
elseif PlayerData.nCurGameType == AllEnum.WorldMapNodeType.Roguelike then
|
||||
EventManager.Hit(EventId.EnterRoguelike)
|
||||
end
|
||||
end
|
||||
collectgarbage("collect")
|
||||
end
|
||||
local OnEvent_AdventureModuleEnter = function()
|
||||
end
|
||||
local function Uninit(moduleMgr)
|
||||
EventManager.Remove(EventId.CSLuaManagerShutdown, ModuleManager, Uninit)
|
||||
EventManager.Remove("ExitModule", ModuleManager, OnEvent_ExitModule)
|
||||
EventManager.Remove("EnterModule", ModuleManager, OnEvent_EnterModule)
|
||||
EventManager.Remove("AfterEnterModule", ModuleManager, OnEvent_AfterEnterModule)
|
||||
EventManager.Remove("AdventureModuleEnter", ModuleManager, OnEvent_AdventureModuleEnter)
|
||||
end
|
||||
function ModuleManager.Init()
|
||||
EventManager.Add(EventId.CSLuaManagerShutdown, ModuleManager, Uninit)
|
||||
EventManager.Add("ExitModule", ModuleManager, OnEvent_ExitModule)
|
||||
EventManager.Add("EnterModule", ModuleManager, OnEvent_EnterModule)
|
||||
EventManager.Add("AfterEnterModule", ModuleManager, OnEvent_AfterEnterModule)
|
||||
EventManager.Add("AdventureModuleEnter", ModuleManager, OnEvent_AdventureModuleEnter)
|
||||
end
|
||||
function ModuleManager.GetIsAdventure()
|
||||
return bAdventure
|
||||
end
|
||||
function ModuleManager.GetCurModuleName()
|
||||
return curModuleName
|
||||
end
|
||||
return ModuleManager
|
||||
Reference in New Issue
Block a user