SUIComponentProxy.lua 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. local RemoteProxy = requireProxy("remote/RemoteProxy")
  2. local SUIComponentProxy = class("SUIComponentProxy", RemoteProxy)
  3. SUIComponentProxy.NAME = global.ProxyTable.SUIComponentProxy
  4. local cjson = require("cjson")
  5. local SUIHelper = require("sui/SUIHelper")
  6. local LexicalHelper = require("sui/LexicalHelper")
  7. function SUIComponentProxy:ctor()
  8. SUIComponentProxy.super.ctor(self)
  9. self._data = {}
  10. for _, v in pairs(global.SUIComponentTable) do
  11. self._data[v] = {}
  12. end
  13. self._triggers = {} -- 触发响应
  14. -- 自添加UI Lua
  15. self._WidgetData = {}
  16. for _, v in pairs(global.SUIComponentTable) do
  17. self._WidgetData[v] = {}
  18. end
  19. -- 用于存取脚本拉杆变量数据
  20. self._sliderWidgets = {}
  21. -------------- CUI ----------------
  22. self._cuiNameConfig = {} -- 自定义UI 名字
  23. self._originUIData = {} -- 原始UI数据
  24. self._customUIData = {} -- 自定义UI数据
  25. self._pc_customUIData = {} -- PC端自定义UI数据
  26. -----------------------------------
  27. -- 是否上报TXT脚本主界面按钮点击事件
  28. self._mainUIClickEvent = false
  29. self:initTriggers()
  30. end
  31. function SUIComponentProxy:SetMainUIClickEvent(state)
  32. self._mainUIClickEvent = true == state
  33. end
  34. function SUIComponentProxy:ClearData()
  35. self._data = {}
  36. for _, v in pairs(global.SUIComponentTable) do
  37. self._data[v] = {}
  38. end
  39. -- 自添加UI Lua
  40. self._WidgetData = {}
  41. for _, v in pairs(global.SUIComponentTable) do
  42. self._WidgetData[v] = {}
  43. end
  44. -- CUI
  45. self._cuiNameConfig = {}
  46. self._originUIData = {}
  47. self._customUIData = {}
  48. self._pc_customUIData = {}
  49. end
  50. function SUIComponentProxy:LoadConfig()
  51. -- 快捷键
  52. local config = requireGameConfig("cfg_KeyFunc")
  53. if config then
  54. for _, v in ipairs(config) do
  55. local keyCodes = {}
  56. local slices = string.split(v.Key, "+")
  57. for _, key in ipairs(slices) do
  58. table.insert(keyCodes, cc.KeyCode["KEY_" .. key])
  59. end
  60. local pressedCB = function()
  61. self:onEventKeyCode(v.ID or v.IDX)
  62. end
  63. global.userInputController:addKeyboardListener(keyCodes, pressedCB)
  64. end
  65. end
  66. -- CUI
  67. local path = "data_config/cuidata.json"
  68. if global.FileUtilCtl:isFileExist(path) then
  69. local jsonStr = global.FileUtilCtl:getDataFromFileEx(path)
  70. if not jsonStr or jsonStr == "" or jsonStr == path then
  71. else
  72. local jsonData = cjson.decode(jsonStr)
  73. self._customUIData = jsonData
  74. end
  75. end
  76. --
  77. local path = "data_config/pc_cuidata.json"
  78. if global.FileUtilCtl:isFileExist(path) then
  79. local jsonStr = global.FileUtilCtl:getDataFromFileEx(path)
  80. if not jsonStr or jsonStr == "" or jsonStr == path then
  81. else
  82. local jsonData = cjson.decode(jsonStr)
  83. if jsonData then
  84. for key, value in pairs(jsonData) do
  85. if key and value then
  86. self._customUIData[key] = value
  87. end
  88. end
  89. end
  90. end
  91. end
  92. for _, key in pairs(global.CUIKeyTable) do
  93. local keyPath = string.format("data_config/ui_config/%s.json", key)
  94. if global.FileUtilCtl:isFileExist(keyPath) then
  95. local jsonStr = global.FileUtilCtl:getDataFromFileEx(keyPath)
  96. if not jsonStr or jsonStr == "" or jsonStr == keyPath then
  97. else
  98. local jsonData = cjson.decode(jsonStr)
  99. if jsonData then
  100. self._customUIData[key] = jsonData
  101. end
  102. end
  103. end
  104. end
  105. --
  106. self:loadCUINameConfig()
  107. end
  108. function SUIComponentProxy:onEventKeyCode(id)
  109. print("function SUIComponentProxy:onEventKeyCode(id)", id)
  110. LuaSendMsg(global.MsgType.MSG_CS_KEYCODE_EVENT, id)
  111. end
  112. -----------------------------------------------------------------------------
  113. -- 挂接组件
  114. function SUIComponentProxy:updateComponent(data)
  115. if not data.index or not data.subid then
  116. return
  117. end
  118. if not self._data[data.index] then
  119. return
  120. end
  121. local index = data.index -- ui编号
  122. local subid = data.subid -- 内容编号
  123. local content = data.content -- 内容
  124. -- update
  125. self._data[index][subid] = data
  126. -- update
  127. global.Facade:sendNotification(global.NoticeTable.SUIComponentUpdate, data)
  128. end
  129. function SUIComponentProxy:removeComponent(data)
  130. if not data.index or not data.subid then
  131. return
  132. end
  133. if not self._data[data.index] then
  134. return
  135. end
  136. local index = data.index -- ui编号
  137. local subid = data.subid -- 内容编号
  138. local content = data.content -- 内容
  139. -- remove
  140. self._data[index][subid] = nil
  141. -- update
  142. global.Facade:sendNotification(global.NoticeTable.SUIComponentUpdate, data)
  143. end
  144. function SUIComponentProxy:loadSUIRender(index, subid, root)
  145. if nil == self._data[index] then
  146. return nil
  147. end
  148. if nil == self._data[index][subid] then
  149. return nil
  150. end
  151. local function linkCB(cdata)
  152. local tdata = clone(cdata)
  153. tdata.index = index
  154. tdata.subid = subid
  155. self:SubmitAct(tdata)
  156. end
  157. local function closeCB()
  158. end
  159. local mainIndex = self._mainUIClickEvent and index >= 101 and index <= 109 and index or nil
  160. local data = self._data[index][subid]
  161. local contentSize = root:getContentSize()
  162. local rootRect = cc.rect(0, 0, contentSize.width, contentSize.height)
  163. local elements = LexicalHelper:Parse(data.content)
  164. local ext = {isImmediate = true, mainIndex = mainIndex}
  165. local SUILoader = require("sui/SUILoader").new()
  166. local trunk = SUILoader:loadContent(elements, linkCB, closeCB, rootRect, ext)
  167. return trunk.render
  168. end
  169. function SUIComponentProxy:loadSUIRenderAll(index, root)
  170. if nil == self._data[index] then
  171. return nil
  172. end
  173. local data = self._data[index]
  174. local renders = {}
  175. for _, v in pairs(data) do
  176. renders[v.subid] = self:loadSUIRender(v.index, v.subid, root)
  177. end
  178. return renders
  179. end
  180. function SUIComponentProxy:RespSUIDataUpdate(msg)
  181. local header = msg:GetHeader()
  182. local jsonData = ParseRawMsgToJson(msg)
  183. if not jsonData then
  184. return nil
  185. end
  186. if header.recog == 0 then
  187. self:updateComponent(jsonData)
  188. -- print(" ++++++++++++++++++++++++ ")
  189. -- dump(jsonData)
  190. elseif header.recog == 1 then
  191. self:removeComponent(jsonData)
  192. -- print(" ------------------------ ")
  193. -- dump(jsonData)
  194. end
  195. end
  196. function SUIComponentProxy:SubmitAct(data)
  197. if not data.Act then
  198. return nil
  199. end
  200. local submitData =
  201. {
  202. index = data.index,
  203. subid = data.subid,
  204. npcid = data.npcid,
  205. act = data.Act,
  206. Input = data.Input,
  207. Slider = data.Slider,
  208. CheckBox = data.CheckBox,
  209. MenuItem = data.MenuItem,
  210. }
  211. local pattern = {string.find(data.Act, "^&(.+)")}
  212. if pattern and pattern[3] then
  213. JUMPTO(tonumber(pattern[3]))
  214. else
  215. SendTableToServer(global.MsgType.MSG_CS_SUICOMPONENT_SUBMIT, submitData)
  216. end
  217. end
  218. function SUIComponentProxy:UpdateAttachComponentByLua( data )
  219. if not data.index or not data.subid then
  220. return
  221. end
  222. if not self._WidgetData[data.index] then
  223. return
  224. end
  225. local index = data.index -- ui编号
  226. local subid = data.subid -- 内容编号
  227. local content = data.content -- 内容
  228. local type = data.type -- 类型
  229. if not type or (type and tonumber(type) == 0 ) then
  230. if not data.content then
  231. return
  232. end
  233. self._WidgetData[index][subid] = data
  234. self._WidgetData[index][subid].content:retain()
  235. elseif type and tonumber(type) == 1 then
  236. self._WidgetData[index][subid] = nil
  237. end
  238. -- update
  239. global.Facade:sendNotification(global.NoticeTable.SUIComponentUpdateByLua, data)
  240. end
  241. function SUIComponentProxy:GetWidgetData( index , subid)
  242. if not index or not self._WidgetData[index] then
  243. return nil
  244. end
  245. if not subid then
  246. return self._WidgetData[index]
  247. else
  248. return self._WidgetData[index][subid]
  249. end
  250. end
  251. -----------------------------------------------------------------------------
  252. -----------------------------------------------------------------------------
  253. -- 脚本触发
  254. function SUIComponentProxy:initTriggers()
  255. -- 背包满
  256. self._triggers[1] = {
  257. cValue = nil,
  258. isAble = false,
  259. notices =
  260. {
  261. global.NoticeTable.Bag_Oper_Data_Delay
  262. },
  263. callback = function()
  264. local BagProxy = global.Facade:retrieveProxy(global.ProxyTable.Bag)
  265. return BagProxy:isToBeFull()
  266. end
  267. }
  268. -- 背包满->空
  269. self._triggers[2] =
  270. {
  271. cValue = nil,
  272. isAble = false,
  273. notices =
  274. {
  275. global.NoticeTable.Bag_Oper_Data_Delay
  276. },
  277. callback = function()
  278. local BagProxy = global.Facade:retrieveProxy(global.ProxyTable.Bag)
  279. return not BagProxy:isToBeFull()
  280. end
  281. }
  282. end
  283. function SUIComponentProxy:RespTrigger(msg)
  284. local header = msg:GetHeader()
  285. local id = header.recog
  286. local isAble = (header.param1 == 1)
  287. if not self._triggers[id] then
  288. return
  289. end
  290. self._triggers[id].isAble = isAble
  291. --
  292. self:checkTrigger(id)
  293. end
  294. function SUIComponentProxy:checkTrigger(id)
  295. local trigger = self._triggers[id]
  296. if not trigger then
  297. return nil
  298. end
  299. if not trigger.isAble then
  300. return nil
  301. end
  302. if not trigger.callback then
  303. return nil
  304. end
  305. local enable = trigger.callback()
  306. if trigger.cValue == enable then
  307. return nil
  308. end
  309. trigger.cValue = enable
  310. -- 触发了
  311. if trigger.cValue then
  312. self:RequestNoticeTrigger(id)
  313. end
  314. end
  315. function SUIComponentProxy:checkAllTriggers(noticeID)
  316. for id, trigger in pairs(self._triggers) do
  317. for _, v in pairs(trigger.notices) do
  318. if noticeID == v then
  319. self:checkTrigger(id)
  320. break
  321. end
  322. end
  323. end
  324. end
  325. function SUIComponentProxy:RequestNoticeTrigger(id)
  326. print("-------------------SUIComponentProxy:RequestNoticeTrigger", id)
  327. LuaSendMsg(global.MsgType.MSG_CS_SCRIPT_TRIGGER, id)
  328. end
  329. -----------------------------------------------------------------------------
  330. function SUIComponentProxy:SetSUISliderValueById(sliderid, value)
  331. self._sliderWidgets[sliderid] = value
  332. end
  333. function SUIComponentProxy:GetSUISliderValueById(sliderid)
  334. return self._sliderWidgets[sliderid] or 0
  335. end
  336. function SUIComponentProxy:ClearSUISlider()
  337. self._sliderWidgets = {}
  338. end
  339. -----------------------------------------------------------------------------
  340. function SUIComponentProxy:loadCUINameConfig()
  341. local path = "data_config/SUIWidgetNameConfig.json"
  342. if global.FileUtilCtl:isFileExist(path) then
  343. local jsonStr = global.FileUtilCtl:getDataFromFileEx(path)
  344. if not jsonStr or jsonStr == "" or jsonStr == path then
  345. else
  346. local jsonData = cjson.decode(jsonStr)
  347. self._cuiNameConfig = jsonData
  348. end
  349. end
  350. end
  351. function SUIComponentProxy:findCUINameByWidgetKey(rootKey, widgetKey)
  352. if self._cuiNameConfig[rootKey] then
  353. local name = self._cuiNameConfig[rootKey][widgetKey]
  354. if name and string.len(name) > 0 then
  355. name = string.split(name,"|")[1]
  356. if name then
  357. return name
  358. end
  359. end
  360. end
  361. return widgetKey
  362. end
  363. function SUIComponentProxy:getCUIOrderDataByRoot( rootKey )
  364. local data = self._cuiNameConfig[rootKey]
  365. if data and next(data) then
  366. local t = {}
  367. for key, name in pairs(data) do
  368. local order = string.split(name, "|")[2]
  369. if order and tonumber(order) then
  370. t[tonumber(order)] = key
  371. end
  372. end
  373. return t
  374. end
  375. return {}
  376. end
  377. function SUIComponentProxy:loadOriginUIData(rootKey, root)
  378. if not (global.isDebugMode or global.isGMMode) then
  379. return nil
  380. end
  381. self._originUIData[rootKey] = {}
  382. local ouiData = self._originUIData[rootKey]
  383. local parentName = ""
  384. local childName = ""
  385. local widgetKey = ""
  386. local children = {}
  387. local function foreachChildren(parent, parentName)
  388. children = parent:getChildren()
  389. if #children > 0 then
  390. for _, child in ipairs(children) do
  391. childName = child:getName()
  392. if childName and string.len(childName) > 0 then
  393. widgetKey = parentName .. "#" .. childName
  394. if child.editMode == 1 then
  395. ouiData[widgetKey] =
  396. {
  397. key = widgetKey,
  398. widget = child,
  399. x = child:getPositionX(),
  400. y = child:getPositionY(),
  401. width = child:getContentSize().width,
  402. height = child:getContentSize().height,
  403. visible = child:isVisible(),
  404. }
  405. end
  406. foreachChildren(child, widgetKey)
  407. end
  408. end
  409. end
  410. end
  411. foreachChildren(root, root:getName())
  412. --
  413. self._customUIData[rootKey] = self._customUIData[rootKey] or {}
  414. end
  415. function SUIComponentProxy:findOriginUIData(rootKey)
  416. return self._originUIData[rootKey]
  417. end
  418. function SUIComponentProxy:writeCsutomUIData()
  419. --英雄信息栏特殊处理 保存即隐藏
  420. local rootKey = global.CUIKeyTable.HERO_STATE
  421. local heroStateData = self:findCustomUIData(rootKey)
  422. if heroStateData then
  423. if heroStateData["#Panel_1"] then heroStateData["#Panel_1"].visible = 0 end
  424. if heroStateData["#Button_hero"] then heroStateData["#Button_hero"].visible = 0 end
  425. if heroStateData["#Button_Lock"] then heroStateData["#Button_Lock"].visible = 0 end
  426. end
  427. --目标信息栏 同上处理
  428. local targetData = self:findCustomUIData(global.CUIKeyTable.MAINTARGET)
  429. if targetData and targetData["Node#Panel_1"] then
  430. targetData["Node#Panel_1"].visible = 0
  431. end
  432. -- dev
  433. local rootpath = global.FileUtilCtl:getDefaultResourceRootPath()
  434. local modulepath = rootpath .. "dev/"
  435. local writepath = modulepath .. "data_config/cuidata.json"
  436. local jsonStr = cjson.encode(self._customUIData)
  437. global.FileUtilCtl:writeStringToFile(jsonStr, writepath)
  438. -- PC自定义UI数据
  439. for key, value in pairs(self._customUIData) do
  440. if string.find(key, "^pc_") then
  441. self._pc_customUIData[key] = value
  442. end
  443. end
  444. local writepath = modulepath .. "data_config/pc_cuidata.json"
  445. local jsonStr = cjson.encode(self._pc_customUIData)
  446. global.FileUtilCtl:writeStringToFile(jsonStr, writepath)
  447. for _, key in pairs(global.CUIKeyTable) do
  448. local keyPath = string.format("data_config/ui_config/%s.json", key)
  449. local writepath = modulepath.. keyPath
  450. if self._customUIData[key] and next(self._customUIData[key]) then
  451. local jsonStr = cjson.encode(self._customUIData[key])
  452. global.FileUtilCtl:writeStringToFile(jsonStr, writepath)
  453. else
  454. if global.FileUtilCtl:isFileExist(writepath) then
  455. global.FileUtilCtl:removeFile( writepath )
  456. end
  457. end
  458. end
  459. end
  460. function SUIComponentProxy:findCustomUIData(rootKey)
  461. return self._customUIData[rootKey]
  462. end
  463. function SUIComponentProxy:resetCustomUIData(rootKey)
  464. self._customUIData[rootKey] = nil
  465. end
  466. function SUIComponentProxy:loadCustomUIData(rootKey, root, isFlag)
  467. local customData = self:findCustomUIData(rootKey)
  468. if not customData then
  469. return nil
  470. end
  471. local parentName = ""
  472. local childName = ""
  473. local widgetKey = ""
  474. local children = {}
  475. local function loadWidget(widget, cuiData, noPos)
  476. if not widget or not cuiData then
  477. return nil
  478. end
  479. local offsetx = cuiData.offsetx or 0
  480. local offsety = cuiData.offsety or 0
  481. local visible = (cuiData.visible == nil or cuiData.visible == 1) and true or false
  482. -- noPos 0 不加载坐标 1 2 仅加载X/Y坐标
  483. if not noPos then
  484. widget:setPositionX(widget:getPositionX() + offsetx)
  485. widget:setPositionY(widget:getPositionY() + offsety)
  486. end
  487. if noPos and noPos == 1 then
  488. widget:setPositionX(widget:getPositionX() + offsetx)
  489. end
  490. widget:setVisible(visible)
  491. local originWidth = widget:getContentSize().width
  492. local originHeight = widget:getContentSize().height
  493. if tolua.type(widget) ~= "ccui.Text" then
  494. if widget.ignoreContentAdaptWithSize then
  495. widget:ignoreContentAdaptWithSize(false)
  496. end
  497. end
  498. widget:setContentSize(cuiData.width or originWidth, cuiData.height or originHeight)
  499. local classname = tolua.type(widget)
  500. if classname == "ccui.ImageView" then
  501. if cuiData.img and global.FileUtilCtl:isFileExist(cuiData.img)then
  502. widget:loadTexture(cuiData.img)
  503. end
  504. elseif classname == "ccui.Button" then
  505. if cuiData.nimg and global.FileUtilCtl:isFileExist(cuiData.nimg) then
  506. widget:loadTextureNormal(cuiData.nimg)
  507. end
  508. if cuiData.pimg and global.FileUtilCtl:isFileExist(cuiData.pimg) then
  509. widget:loadTexturePressed(cuiData.pimg)
  510. end
  511. if cuiData.dimg and global.FileUtilCtl:isFileExist(cuiData.dimg) then
  512. widget:loadTextureDisabled(cuiData.dimg)
  513. end
  514. if cuiData.text and string.len(cuiData.text) ~= 0 then
  515. widget:setTitleText(cuiData.text)
  516. if widgetKey == "#Panel_1#Button_4" and string.find(cuiData.text, "#") and rootKey == global.CUIKeyTable.BAG_MERGE then
  517. local textList = string.split(cuiData.text, "#")
  518. widget:setTitleText(textList[1])
  519. end
  520. if widgetKey == "Panel_1#Button_quick" and string.find(cuiData.text, "#") and rootKey == global.CUIKeyTable.NPC_STORAGE then
  521. local textList = string.split(cuiData.text, "#")
  522. local NPCStorageProxy = global.Facade:retrieveProxy(global.ProxyTable.NPCStorageProxy)
  523. local touchType = NPCStorageProxy:GetTouchType() or 1
  524. widget:setTitleText(textList[touchType])
  525. end
  526. end
  527. --英雄召唤按钮
  528. if cuiData.nimgCall and global.FileUtilCtl:isFileExist(cuiData.nimgCall) then
  529. widget:loadTextureNormal(cuiData.nimgCall)
  530. end
  531. if cuiData.pimgCall and global.FileUtilCtl:isFileExist(cuiData.pimgCall) then
  532. widget:loadTexturePressed(cuiData.pimgCall)
  533. end
  534. elseif classname == "ccui.Text" then
  535. if cuiData.color and string.len(cuiData.color) ~= 0 then
  536. widget:setTextColor(GetColorFromHexString(cuiData.color))
  537. end
  538. if cuiData.fontSize then
  539. widget:setFontSize(cuiData.fontSize)
  540. end
  541. if cuiData.text then
  542. widget:setString(cuiData.text)
  543. end
  544. elseif classname == "ccui.LoadingBar" then
  545. if cuiData.img and global.FileUtilCtl:isFileExist(cuiData.img)then
  546. widget:loadTexture(cuiData.img)
  547. end
  548. elseif classname == "cc.Node" or classname == "ccui.Layout" then
  549. if cuiData.zorder and tonumber(cuiData.zorder) then
  550. widget:setLocalZOrder(tonumber(cuiData.zorder))
  551. end
  552. end
  553. end
  554. local function foreachChildren(parent, parentName)
  555. children = parent:getChildren()
  556. if #children > 0 then
  557. for _, child in ipairs(children) do
  558. childName = child:getName()
  559. if childName and string.len(childName) > 0 then
  560. widgetKey = parentName .. "#" .. childName
  561. if isFlag then --特殊处理2合一背包刷新
  562. if rootKey == "pc_property" then
  563. local allWidgets = {
  564. "#Panel_bg#Panel_hp",
  565. "#Panel_bg#Panel_act",
  566. }
  567. for _, key in ipairs(allWidgets) do
  568. if widgetKey == key then
  569. loadWidget(child, customData[widgetKey])
  570. end
  571. end
  572. local needCustomXWidgets = {
  573. "#Panel_bg#Panel_chat",
  574. "#Panel_bg#Panel_chat#ListView_chat",
  575. "#Panel_bg#Panel_chat#ListView_chat_ex",
  576. "#Panel_bg#Panel_chat#TextField_input",
  577. "#Panel_bg#Panel_auto_tips",
  578. "#Panel_bg#Button_pick",
  579. }
  580. for _, key in ipairs(needCustomXWidgets) do
  581. if widgetKey == key then
  582. loadWidget(child, customData[widgetKey], 1)
  583. end
  584. end
  585. else
  586. for i = 1, 3 do
  587. local strKey = string.format( "#Panel_1#Node_1#btnPanel#btn_%s#titleName",i )
  588. local strKey1 = string.format( "#Panel_1#Node_1#btnPanel#btn_%s", i )
  589. if widgetKey == strKey or widgetKey == strKey1 then
  590. loadWidget(child, customData[widgetKey], 0)
  591. end
  592. end
  593. end
  594. else
  595. loadWidget(child, customData[widgetKey])
  596. end
  597. foreachChildren(child, widgetKey)
  598. end
  599. end
  600. end
  601. end
  602. foreachChildren(root, root:getName())
  603. end
  604. -----------------------------------------------------------------------------
  605. function SUIComponentProxy:RegisterMsgHandler()
  606. SUIComponentProxy.super.RegisterMsgHandler(self)
  607. local msgType = global.MsgType
  608. LuaRegisterMsgHandler(msgType.MSG_SC_SUICOMPONENT_UPDATE, handler(self, self.RespSUIDataUpdate))
  609. LuaRegisterMsgHandler(msgType.MSG_SC_SCRIPT_TRIGGER, handler(self, self.RespTrigger))
  610. end
  611. return SUIComponentProxy