NPCCommand.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. local NPCCommand = class('NPCCommand', framework.SimpleCommand)
  2. local STATE_TAG = 99
  3. function NPCCommand:ctor()
  4. end
  5. function NPCCommand:execute(notification)
  6. local data = notification:getBody()
  7. end
  8. -------------------------------------------下面代码勿删勿删 ---------------------------------------------------
  9. -------------------------------------------下面代码勿删勿删 ---------------------------------------------------
  10. -------------------------------------------下面代码勿删勿删 ---------------------------------------------------
  11. -- require "UlSystems/Common/IDefine"
  12. -- require 'Common/StackList'
  13. UIManager = {}
  14. local this = UIManager
  15. local ctrlList = {}
  16. local panelStack = nil
  17. --[[
  18. 对table运用mm L<度要求
  19. ]]
  20. function this.Init()
  21. logWarn("ctrl mgr init Ctrl len is :")
  22. panelStack = StackList:New()
  23. for panelName, path in pairs(UlPanels) do
  24. require (path.. panelName)
  25. --log('req panel name : ' .. panelName)
  26. local panel = panelName
  27. --替换字符串
  28. local ctrlName = string.gsub(panelName, 'Panel', 'Ctrl')
  29. local ctrl = require(path.. ctrlName)
  30. if type(ctrl) == 'boolean' then
  31. error (" require Ctrl error, 找不至lj lua 文件 path: *.. path.. ctrlName")
  32. end
  33. ctrlList[panelName] = ctrl
  34. --attempt to index a boolean value
  35. --出碰上面那个错,说明require路径没写对
  36. ctrlList[panelName].panelName = panel--这里赋值 panel 给 UlCtrl
  37. ctrlList[panelName].Init()
  38. end
  39. end
  40. local curPanelCtrl = nil
  41. function this.ShowPanel(panelName, data)
  42. --local topPaneLName = this. panelStack:GetTop()
  43. local beforePanelCtrl = curPanelCtrl
  44. local openPanelCtrl = ctrlList[panelName]
  45. if openPanelCtrl.uiShowType == nil then
  46. openPanelCtrl.uiShowType = UiShowType.ShowOnly
  47. end
  48. local showType = openPanelCtrl.uiShowType
  49. if showType == UiShowType.Switch and beforePanelCtrl ~= nil then
  50. beforePanelCtrl:HidePanel()
  51. end
  52. if showType == UiShowType.Top then
  53. -- openPEinelClrl. genneObject:SetAsLastSibling()
  54. end
  55. if showType ~= UiShowType.Stack then
  56. --如果没有根,push BasePanel,作为根Panel
  57. if panelStack:Comit() == 0 then
  58. panelStack:Push(beforePanelCtrl.panelName)
  59. end
  60. this.PushPanelStack(openPanelCtrl.panelName)
  61. end
  62. if showType == UIShowType.HideOthers then
  63. end
  64. -- panelStack:ToString()
  65. openPanelCtrl:ShowPanel(data)
  66. curPanelCtrl = openPanelCtrl
  67. --this.panelStack:Push(panelNamc)
  68. --this.panelStack:ToString()
  69. end
  70. function this.PushPanelStack(panelName)
  71. panelStack:Push(panelName)
  72. end
  73. function this.IlideTopPanel()
  74. local topPanelName = this.panelStack:GetTop()
  75. this.HidePanel(topPanelName)
  76. end
  77. function this.GetPanelCtrl(panelName)
  78. return ctrlList[panelName]
  79. end
  80. function this.HidePanel(panelName, data)
  81. local panelCtrl = ctrlList[panelName]
  82. if panelCtrl.uiShowType == UIShowType.Stack then
  83. local popPaneIName = panelStack:Pop()
  84. if panelName ~= popPanelName then
  85. logError('Pop panel name error'.. popPanelName)
  86. panelStack:Push(popPanelName)
  87. else
  88. --正常pop
  89. local parentCtrlName = panelStack:GctTop()
  90. local parentCtrl = ctrlList[parentCtrlName]
  91. -- pop时反向传值给父Panel
  92. if parentCtrl.OnPopPanel ~= nil and type(parentCtrl. OnPopPanel) == 'function' then
  93. parentCtrl.OnPopPanel(panelName, data)
  94. end
  95. ctrlList[panelName]:HidePanel()
  96. end
  97. else
  98. ctrlList[panelName]:HidePanel()
  99. end
  100. --只有一个了,留着无意义了
  101. if panelStack:Count() <= 1 then
  102. panelStack:Clear()
  103. end
  104. --panelStack:ToString()
  105. end
  106. function this.DestroyPanel(panelName)
  107. ctrlList[panelName]:DestroyPanel()
  108. end
  109. -- return {
  110. -- versioninfo =
  111. -- date = * 2017-1-16 16:54:22',
  112. -- checkvalue = ' d882d8b2d51a75dacbl7cfc6cda432455, version = 1484556862,
  113. -- creater = ' JUN'
  114. -- },
  115. return NPCCommand