TradingBankCaptureOtherCommand.lua 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  1. local TradingBankCaptureOtherCommand = class('TradingBankCaptureOtherCommand', framework.SimpleCommand)
  2. function TradingBankCaptureOtherCommand:ctor()
  3. end
  4. function TradingBankCaptureOtherCommand:execute(notification)
  5. local typenum = nil
  6. local action = nil
  7. local typeAction = nil
  8. local testCapture = nil
  9. self.publishImage = {}
  10. self.tableDataUrl = {}
  11. local databody = notification:getBody()
  12. if databody then
  13. typenum = databody.type
  14. if typenum == 1 then
  15. local otherTradingBankProxy = global.Facade:retrieveProxy(global.ProxyTable.OtherTradingBankProxy)
  16. self.tableDataUrl = otherTradingBankProxy:getPublishTableData()
  17. else
  18. action = typenum.action or nil
  19. typeAction = typenum.type or nil
  20. testCapture = typenum.testCapture or nil
  21. end
  22. end
  23. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBankCaptureMaskLayer_Open)
  24. local NPCStorageProxy = global.Facade:retrieveProxy(global.ProxyTable.NPCStorageProxy)
  25. NPCStorageProxy:RequestStorageData()--请求仓库数据
  26. local NT = global.NoticeTable
  27. local message = {
  28. { open = NT.Layer_Player_Open, close = NT.Layer_Player_Close, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_EQUIP }, mediator = "PlayerFrameMediator", position = "equip", delay = true },
  29. { open = NT.Layer_Player_Open, close = NT.Layer_Player_Close, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_EQUIP,bigImage = true }, mediator = "PlayerFrameMediator", position = "equip", delay = true },
  30. { open = NT.Layer_Player_Open, close = NT.Layer_Player_Close, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_BASE_ATTRI }, mediator = "PlayerFrameMediator", position = "status", delay = true },
  31. { open = NT.Layer_Player_Open, close = NT.Layer_Player_Close, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_EXTRA_ATTRO,typeCapture = 1 }, mediator = "PlayerFrameMediator", position = "attribute", delay = true },
  32. { open = NT.Layer_Player_Open, close = NT.Layer_Player_Close, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_SKILL,typeCapture = 1 }, mediator = "PlayerFrameMediator", position = "skill", delay = true },
  33. { open = NT.Layer_Player_Open, close = NT.Layer_Player_Close, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_TITLE ,typeCapture = 1 }, mediator = "PlayerFrameMediator", position = "title", delay = true },
  34. { open = NT.Layer_Player_Open, close = NT.Layer_Player_Close, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_SUPER_EQUIP }, mediator = "PlayerFrameMediator", position = "clothes", delay = true },
  35. { open = NT.Layer_Player_Open, close = NT.Layer_Player_Close, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_SUPER_EQUIP,bigImage = true }, mediator = "PlayerFrameMediator", position = "clothes", delay = true },
  36. -- {open = NT.Layer_Bag_Open, close = NT.Layer_Bag_Close, extent = {pos = {x = 0, y = 0}},mediator = "BagLayerMediator",node = "panel",position = "bag"},
  37. --{ open = NT.Layer_NPC_Storage_Open, close = NT.Layer_NPC_Storage_Close, extent = { noShowBag = true }, mediator = "NPCStorageMediator", position = "warehouse" },
  38. }
  39. if action == "screenshots" and typeAction == "prop" then
  40. message = {}
  41. end
  42. -----------------------------------------------------
  43. local ItemMoveProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemMoveProxy)
  44. local EquipProxy = global.Facade:retrieveProxy(global.ProxyTable.Equip)
  45. local data = {}
  46. --玩家身上的装备
  47. data = EquipProxy:GetEquipData()
  48. for k, v in pairs(data) do
  49. local val = {}
  50. val.itemData = v
  51. val.pos = cc.p(0, 0)--equipPanel:getWorldPosition()
  52. val.from = ItemMoveProxy.ItemFrom.PALYER_EQUIP
  53. val.typeCapture = 1
  54. local t = { open = NT.Layer_ItemTips_Open, close = NT.Layer_ItemTips_Close, extent = val, mediator = "ItemTipsMediator", node = "_CaptureNode", position = "equip" }
  55. if action == "screenshots" then
  56. if typeAction == "role" then
  57. table.insert(message, t)
  58. end
  59. else
  60. table.insert(message, t)
  61. end
  62. end
  63. self.m_files = {}
  64. self.m_filesPublish = {}
  65. -------------------------------------------------------背包多页
  66. local BagProxy = global.Facade:retrieveProxy(global.ProxyTable.Bag)
  67. local bagmax = BagProxy:GetMaxBag()
  68. local pagenum = math.ceil(bagmax / global.MMO.MAX_ITEM_NUMBER)
  69. for i = 1, pagenum do
  70. local ebs = { open = NT.Layer_Bag_Open, close = NT.Layer_Bag_Close, extent = {pos = { x = 0, y = 0 }, bag_page = i }, mediator = "BagLayerMediator", node = "panel", position = "bag" }
  71. if action == "screenshots" then
  72. if typeAction == "role" then
  73. table.insert(message, ebs)
  74. end
  75. else
  76. table.insert(message, ebs)
  77. end
  78. end
  79. -------------------------------------------------------仓库
  80. local NPCStorageProxy = global.Facade:retrieveProxy(global.ProxyTable.NPCStorageProxy)
  81. local storemax = NPCStorageProxy:GetMaxPage()
  82. for i = 1,storemax do
  83. local ebs = { open = NT.Layer_NPC_Storage_Open, close = NT.Layer_NPC_Storage_Close, extent = { noShowBag = true, initPage = i }, mediator = "NPCStorageMediator", position = "warehouse" }
  84. if action == "screenshots" then
  85. if typeAction == "role" then
  86. table.insert(message, ebs)
  87. end
  88. else
  89. table.insert(message, ebs)
  90. end
  91. end
  92. -----------------------------------------------生肖
  93. local activeState = EquipProxy:GetBestRingsOpenState()
  94. if activeState then
  95. -- global.Facade:sendNotification(global.NoticeTable.Layer_PlayerBestRing_Open,{param={lookPlayer = self._playerLook}})
  96. local ebs = { open = NT.Layer_PlayerBestRing_Open, close = NT.Layer_PlayerBestRing_Close, extent = {
  97. id = global.LayerTable.PlayerBestRingLayer,
  98. param = {
  99. lookPlayer = false
  100. }
  101. }, mediator = "PlayerBestRingLayerMediator", position = "equip" }
  102. if action == "screenshots" then
  103. if typeAction == "role" then
  104. table.insert(message, ebs)
  105. end
  106. else
  107. table.insert(message, ebs)
  108. end
  109. end
  110. -----------------------------------------------------itemTips
  111. local screenshots = false
  112. if action == "screenshots" and typeAction == "prop" then
  113. screenshots = true
  114. elseif typenum ~= 1 then
  115. screenshots = true
  116. end
  117. if screenshots then
  118. --筛选背包寄售装备
  119. local dataBag = {}
  120. local bagProxy = global.Facade:retrieveProxy(global.ProxyTable.Bag)
  121. local quickUseProxy = global.Facade:retrieveProxy(global.ProxyTable.QuickUseProxy)
  122. local quickData = quickUseProxy:GetQuickUseData()
  123. local bagData = bagProxy:GetBagData()
  124. local itemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
  125. local articleType = itemConfigProxy:GetArticleType()
  126. local checkArticleType = {[articleType.TYPE_TRADE_AUCTIONA] = true}
  127. for _, vItem in pairs(quickData) do
  128. if not itemConfigProxy:GetItemArticle(vItem.Index, checkArticleType)
  129. and self:CheckConditions(vItem) then
  130. table.insert(dataBag, vItem)
  131. end
  132. end
  133. for _, vItem in pairs(bagData) do
  134. if not itemConfigProxy:GetItemArticle(vItem.Index, checkArticleType)
  135. and self:CheckConditions(vItem) then
  136. table.insert(dataBag, vItem)
  137. end
  138. end
  139. for k, v in pairs(dataBag) do
  140. local val = {}
  141. val.itemData = v
  142. val.pos = cc.p(0, 0)--equipPanel:getWorldPosition()
  143. val.from = ItemMoveProxy.ItemFrom.PALYER_EQUIP
  144. val.bag = true
  145. val.typeCapture = 1
  146. local t = { open = NT.Layer_ItemTips_Open, close = NT.Layer_ItemTips_Close, extent = val, mediator = "ItemTipsMediator", node = "_CaptureNode", position = "equip" }
  147. table.insert(message, t)
  148. end
  149. --可寄售物品装备icon图
  150. for k, v in pairs(dataBag) do
  151. local val = {}
  152. val.itemData = v
  153. val.pos = cc.p(0, 0)
  154. local t = { open = NT.Layer_ItemIcon_Open, close = NT.Layer_ItemIcon_Close, extent = val, mediator = "ItemIconMediator", node = "_CaptureNode", position = "equip" }
  155. table.insert(message, t)
  156. end
  157. end
  158. -----------------------------------------------------hero
  159. local HeroPropertyProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroPropertyProxy)
  160. if HeroPropertyProxy:IsHeroOpen() then
  161. local PlayerPropertyProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  162. if PlayerPropertyProxy:getIsMakeHero() then
  163. if not HeroPropertyProxy:HeroIsLogin() then
  164. HeroPropertyProxy:RequestHeroInOrOut()
  165. end
  166. local heromessage = {
  167. { open = NT.Layer_Player_Open_Hero, close = NT.Layer_Player_Close_Hero, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_EQUIP }, mediator = "HeroFrameMediator", position = "hero_equip" },
  168. { open = NT.Layer_Player_Open_Hero, close = NT.Layer_Player_Close_Hero, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_EQUIP,bigImage = true }, mediator = "HeroFrameMediator", position = "hero_equip" },
  169. { open = NT.Layer_Player_Open_Hero, close = NT.Layer_Player_Close_Hero, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_BASE_ATTRI }, mediator = "HeroFrameMediator", position = "hero_status" },
  170. { open = NT.Layer_Player_Open_Hero, close = NT.Layer_Player_Close_Hero, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_EXTRA_ATTRO,typeCapture = 1 }, mediator = "HeroFrameMediator", position = "hero_attribute" },
  171. { open = NT.Layer_Player_Open_Hero, close = NT.Layer_Player_Close_Hero, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_SKILL,typeCapture = 1 }, mediator = "HeroFrameMediator", position = "hero_skill" },
  172. { open = NT.Layer_Player_Open_Hero, close = NT.Layer_Player_Close_Hero, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_TITLE,typeCapture = 1 }, mediator = "HeroFrameMediator", position = "hero_title" },
  173. { open = NT.Layer_Player_Open_Hero, close = NT.Layer_Player_Close_Hero, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_SUPER_EQUIP }, mediator = "HeroFrameMediator", position = "hero_clothes" },
  174. { open = NT.Layer_Player_Open_Hero, close = NT.Layer_Player_Close_Hero, extent = { extent = SLDefine.PlayerPage.MAIN_PLAYER_LAYER_SUPER_EQUIP,bigImage = true }, mediator = "HeroFrameMediator", position = "hero_clothes" },
  175. { open = NT.Layer_HeroBag_Open, close = NT.Layer_HeroBag_Close, extent = {pos = { x = 0, y = 0 }}, mediator = "HeroBagLayerMediator", node = "panel", position = "hero_bag" },
  176. }
  177. if action == "screenshots" then
  178. if typeAction == "role" then
  179. for i, v in ipairs(heromessage) do
  180. table.insert(message, v)
  181. end
  182. end
  183. else
  184. for i, v in ipairs(heromessage) do
  185. table.insert(message, v)
  186. end
  187. end
  188. end
  189. end
  190. -----------------------------------------------hero生肖
  191. local HeroEquipProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroEquipProxy)
  192. local herodata = HeroEquipProxy:GetEquipData()
  193. local activeState = HeroEquipProxy:GetBestRingsOpenState()
  194. if activeState then
  195. -- global.Facade:sendNotification(global.NoticeTable.Layer_PlayerBestRing_Open,{param={lookPlayer = self._playerLook}})
  196. local ebs = { open = NT.Layer_PlayerBestRing_Open_Hero, close = NT.Layer_PlayerBestRing_Close_Hero, extent = {
  197. id = global.LayerTable.PlayerBestRingLayer,
  198. param = {
  199. lookPlayer = false
  200. }
  201. }, mediator = "HeroBestRingLayerMediator", position = "hero_equip" }
  202. if action == "screenshots" then
  203. if typeAction == "role" then
  204. table.insert(message, ebs)
  205. end
  206. else
  207. table.insert(message, ebs)
  208. end
  209. end
  210. -----------------------------------------------------hero itemTips
  211. local ItemMoveProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemMoveProxy)
  212. for k, v in pairs(herodata) do
  213. local val = {}
  214. val.itemData = v
  215. val.pos = cc.p(0, 0)--equipPanel:getWorldPosition()
  216. val.from = ItemMoveProxy.ItemFrom.HERO_EQUIP
  217. val.typeCapture = 1
  218. local t = { open = NT.Layer_ItemTips_Open, close = NT.Layer_ItemTips_Close, extent = val, mediator = "ItemTipsMediator", node = "_CaptureNode", position = "hero_equip" }
  219. if action == "screenshots" then
  220. if typeAction == "role" then
  221. table.insert(message, t)
  222. end
  223. else
  224. table.insert(message, t)
  225. end
  226. end
  227. --------------------------------------------------单面板特殊处理
  228. if HeroPropertyProxy:getIsMergePanelMode() then
  229. for i, v in ipairs(message) do
  230. if v.mediator == "BagLayerMediator" or v.mediator == "HeroBagLayerMediator" then
  231. v.mediator = "MergeBagLayerMediator"
  232. elseif v.mediator == "PlayerFrameMediator" or v.mediator == "HeroFrameMediator" then
  233. v.mediator = "MergePlayerLayerMediator"
  234. v.node = "_CaptureNode"
  235. end
  236. end
  237. end
  238. if SL.TradingCustomCaptureLua and type(SL.TradingCustomCaptureLua) == "table" then
  239. local TradingCustomNum = #SL.TradingCustomCaptureLua
  240. dump(TradingCustomNum,"TradingCustomNum")
  241. if TradingCustomNum >= 1 then
  242. for k, v in pairs(SL.TradingCustomCaptureLua) do
  243. local val = {}
  244. val.itemData = v
  245. local t = { open = v.open, close = v.close, extent = val, captureNode = v.getNode, position = "status", typeCustom = true }
  246. table.insert(message, t)
  247. end
  248. end
  249. end
  250. -------------------------------------------------------
  251. local index = 1
  252. local FileUtils = cc.FileUtils:getInstance()
  253. local WritablePath = FileUtils:getWritablePath()
  254. local textureCache = global.Director:getTextureCache()
  255. local repIndex = 0
  256. local repFunc
  257. local validTipsMessage = {}
  258. local validTipsNum = 0
  259. local validIconNum = 0
  260. repFunc = function()
  261. repIndex = repIndex + 1
  262. if repIndex > #message then --end
  263. dump(self.m_files,"m_files")
  264. if not testCapture then
  265. if action == "screenshots" then
  266. local OtherTradingBankProxy = global.Facade:retrieveProxy(global.ProxyTable.OtherTradingBankProxy)
  267. OtherTradingBankProxy:sendDataToH5(self.m_files,action)
  268. else
  269. if typenum ~= 1 then--h5 上传图片流程
  270. local OtherTradingBankProxy = global.Facade:retrieveProxy(global.ProxyTable.OtherTradingBankProxy)
  271. OtherTradingBankProxy:captureResult(self.m_files)
  272. else
  273. self:uploadImg() -- app上传图片流程
  274. --LockPublishRole()
  275. end
  276. end
  277. end
  278. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBankCaptureMaskLayer_Close)
  279. return
  280. end
  281. local val = message[repIndex]
  282. local position = val.position or "equip"
  283. local path = WritablePath..position..repIndex..".png"
  284. local pathPublish = position..repIndex..".png"
  285. if val.position == "clothes" or val.position == "hero_clothes" then
  286. if val.extent.bigImage then
  287. path = WritablePath..position..repIndex.."_big"..".png"
  288. pathPublish = position..repIndex.."_big"..".png"
  289. else
  290. path = WritablePath..position..repIndex.."_small"..".png"
  291. pathPublish = position..repIndex.."_small"..".png"
  292. end
  293. elseif val.position == "equip"and (val.mediator == "PlayerFrameMediator" or val.mediator == "MergePlayerLayerMediator") then
  294. if val.extent.bigImage then
  295. path = WritablePath..position..repIndex.."_big"..".png"
  296. pathPublish = position..repIndex.."_big"..".png"
  297. else
  298. path = WritablePath..position..repIndex.."_small"..".png"
  299. pathPublish = position..repIndex.."_small"..".png"
  300. end
  301. elseif val.position == "hero_equip"and (val.mediator == "HeroFrameMediator" or val.mediator == "MergePlayerLayerMediator") then
  302. if val.extent.bigImage then
  303. path = WritablePath..position..repIndex.."_big"..".png"
  304. pathPublish = position..repIndex.."_big"..".png"
  305. else
  306. path = WritablePath..position..repIndex.."_small"..".png"
  307. pathPublish = position..repIndex.."_small"..".png"
  308. end
  309. end
  310. local newbag = ""
  311. if val.mediator == "ItemTipsMediator" and val.extent.from == ItemMoveProxy.ItemFrom.PALYER_EQUIP and val.extent.bag == true then
  312. validTipsNum = validTipsNum + 1
  313. validTipsMessage[validTipsNum] = ""
  314. newbag = "bag"
  315. path = WritablePath..newbag..position..repIndex..".png"
  316. pathPublish = newbag..position..repIndex..".png"
  317. end
  318. local iconPath = ""
  319. if val.mediator == "ItemIconMediator"then
  320. validIconNum = validIconNum + 1
  321. iconPath = validTipsMessage[validIconNum] or ""
  322. path = WritablePath..position..repIndex..iconPath..".png"
  323. pathPublish = position..repIndex..iconPath..".png"
  324. end
  325. --截长图
  326. if val.position == "attribute" or val.position == "hero_attribute" then--属性
  327. path = WritablePath..position..repIndex.."_long"..".png"
  328. pathPublish = position..repIndex.."_long"..".png"
  329. elseif val.position == "skill" or val.position == "hero_skill" then--技能
  330. path = WritablePath..position..repIndex.."_long"..".png"
  331. pathPublish = position..repIndex.."_long"..".png"
  332. elseif val.position == "title" or val.position == "hero_title" then--称号
  333. path = WritablePath..position..repIndex.."_long"..".png"
  334. pathPublish = position..repIndex.."_long"..".png"
  335. end
  336. if FileUtils:isFileExist(path) then
  337. FileUtils:removeFile(path)
  338. end
  339. local nodeCustom = nil
  340. local mediator = nil
  341. local customTime = 0.1
  342. if val.delay then
  343. customTime = 0.5
  344. end
  345. if val.typeCustom then
  346. val.open(val.extent.itemData.openData)
  347. mediator = {}
  348. mediator._layer = true
  349. customTime = 0.5
  350. else
  351. global.Facade:sendNotification(val.open, val.extent)
  352. mediator = global.Facade:retrieveMediator(val.mediator)
  353. end
  354. PerformWithDelayGlobal(function ()
  355. if val.typeCustom then
  356. nodeCustom = val.captureNode()
  357. end
  358. if mediator._layer then
  359. local node = nil
  360. local time = 0.5
  361. if val.typeCustom then
  362. time = 1.0
  363. node = nodeCustom
  364. else
  365. node = val.node and mediator._layer[val.node] or mediator._layer._root
  366. end
  367. local CloseFunc = function()
  368. if val.typeCustom then
  369. val.close()
  370. else
  371. global.Facade:sendNotification(val.close)
  372. end
  373. repFunc()
  374. end
  375. PerformWithDelayGlobal (function ()
  376. if val.mediator == "BagLayerMediator" then--背包
  377. if node then
  378. local size2 = node:getContentSize()
  379. node:setContentSize(size2.width+20,size2.height+60)
  380. for i,v in ipairs(node:getChildren()) do
  381. v:setPositionY(v:getPositionY()+60)
  382. end
  383. end
  384. end
  385. --截图
  386. local str = ""
  387. if val.position == "clothes" or val.position == "hero_clothes" then
  388. if val.extent.bigImage then
  389. str = "_big"
  390. else
  391. str = "_small"
  392. end
  393. elseif val.position == "equip"and (val.mediator == "PlayerFrameMediator" or val.mediator == "MergePlayerLayerMediator") then
  394. if val.extent.bigImage then
  395. str = "_big"
  396. else
  397. str = "_small"
  398. end
  399. elseif val.position == "hero_equip"and (val.mediator == "HeroFrameMediator" or val.mediator == "MergePlayerLayerMediator") then
  400. if val.extent.bigImage then
  401. str = "_big"
  402. else
  403. str = "_small"
  404. end
  405. end
  406. if val.position == "attribute" or val.position == "hero_attribute" then--属性
  407. str = "_long"
  408. elseif val.position == "skill" or val.position == "hero_skill" then--技能
  409. str = "_long"
  410. elseif val.position == "title" or val.position == "hero_title" then--称号
  411. str = "_long"
  412. elseif (val.position == "equip" or val.position == "hero_equip") and val.mediator == "ItemTipsMediator" then--装备tips
  413. if ItemTips and ItemTips.manyHeight ~= nil and type(ItemTips.manyHeight) == "number" and ItemTips.manyHeight > 0 then
  414. if node then
  415. local size = node:getContentSize()
  416. local disY = ItemTips.manyHeight-size.height
  417. if disY > 0 then
  418. str = "_long"
  419. path = WritablePath..newbag..position..repIndex.."_long"..".png"
  420. pathPublish = newbag..position..repIndex.."_long"..".png"
  421. end
  422. end
  423. end
  424. end
  425. if node and self:CaptureNode(val,newbag..position..repIndex..iconPath..str..".png",node) then
  426. if val.mediator == "ItemTipsMediator" and val.extent.from == ItemMoveProxy.ItemFrom.PALYER_EQUIP and val.extent.bag == true then
  427. local makeindex = val.extent.itemData.MakeIndex or "nil"
  428. local maketype = val.extent.itemData.StdMode or "nil"
  429. local makenum = val.extent.itemData.OverLap or "nil"
  430. local makename = val.extent.itemData.Name or "nil"
  431. makename = string.gsub(makename, "_", "")
  432. validTipsMessage[validTipsNum] = "_"..newbag..position..repIndex.."_"..makeindex.."_"..maketype.."_"..makenum.."_"..makename
  433. end
  434. if not self.m_files[position] then
  435. self.m_files[position] = {}
  436. end
  437. if not self.m_filesPublish[position] then
  438. self.m_filesPublish[position] = {}
  439. end
  440. table.insert(self.m_files[position],path)
  441. table.insert(self.m_filesPublish[position],pathPublish)
  442. PerformWithDelayGlobal(function ()
  443. index = index+1
  444. CloseFunc()
  445. end,0.1)
  446. else
  447. CloseFunc()
  448. end
  449. end,time)
  450. else
  451. --异常 比如英雄未召唤
  452. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBankCaptureMaskLayer_Close)
  453. end
  454. end,customTime)
  455. end
  456. repFunc()
  457. end
  458. function TradingBankCaptureOtherCommand:CaptureNode(val,filename, node, pos)
  459. local res = true
  460. if tolua.isnull(node) then
  461. return
  462. end
  463. local size = node:getContentSize()
  464. --截大图
  465. if (val.position == "clothes" or val.position == "hero_clothes") and val.extent.bigImage then
  466. size.width = SL:GetMetaValue("SCREEN_WIDTH")
  467. size.height = SL:GetMetaValue("SCREEN_HEIGHT")
  468. elseif val.position == "equip" and (val.mediator == "PlayerFrameMediator" or val.mediator == "MergePlayerLayerMediator") and val.extent.bigImage then
  469. size.width = SL:GetMetaValue("SCREEN_WIDTH")
  470. size.height = SL:GetMetaValue("SCREEN_HEIGHT")
  471. elseif val.position == "hero_equip" and (val.mediator == "HeroFrameMediator" or val.mediator == "MergePlayerLayerMediator") and val.extent.bigImage then
  472. size.width = SL:GetMetaValue("SCREEN_WIDTH")
  473. size.height = SL:GetMetaValue("SCREEN_HEIGHT")
  474. else
  475. node:setPosition(cc.p(0, 0))
  476. node:setAnchorPoint(cc.p(0, 0))
  477. end
  478. --截长图
  479. local disY = 0
  480. if val.position == "attribute" then--属性
  481. if PlayerExtraAtt and PlayerExtraAtt.manyHeight ~= nil and type(PlayerExtraAtt.manyHeight) == "number" and PlayerExtraAtt.manyHeight > 0 then
  482. disY = PlayerExtraAtt.manyHeight
  483. dump(disY,"attribute_disY")
  484. if disY > 0 then
  485. disY = math.min(disY, 4000)
  486. node:setPosition(cc.p(0, size.height+disY))
  487. node:setAnchorPoint(cc.p(0, 1))
  488. else
  489. disY = 0
  490. end
  491. end
  492. elseif val.position == "skill" then--技能
  493. if PlayerSkill and PlayerSkill.manyHeight ~= nil and type(PlayerSkill.manyHeight) == "number" and PlayerSkill.manyHeight > 0 then
  494. disY = PlayerSkill.manyHeight
  495. dump(disY,"skill_disY")
  496. if disY > 0 then
  497. disY = math.min(disY, 4000)
  498. node:setPosition(cc.p(0, size.height+disY))
  499. node:setAnchorPoint(cc.p(0, 1))
  500. else
  501. disY = 0
  502. end
  503. end
  504. elseif val.position == "title" then--称号
  505. if PlayerTitle and PlayerTitle.manyHeight ~= nil and type(PlayerTitle.manyHeight) == "number" and PlayerTitle.manyHeight > 0 then
  506. disY = PlayerTitle.manyHeight
  507. dump(disY,"title_disY")
  508. if disY > 0 then
  509. disY = math.min(disY, 4000)
  510. node:setPosition(cc.p(0, size.height+disY))
  511. node:setAnchorPoint(cc.p(0, 1))
  512. else
  513. disY = 0
  514. end
  515. end
  516. elseif val.position == "equip" and val.mediator == "ItemTipsMediator" then--装备tips
  517. if ItemTips and ItemTips.manyHeight ~= nil and type(ItemTips.manyHeight) == "number" and ItemTips.manyHeight > 0 then
  518. disY = ItemTips.manyHeight-size.height
  519. dump(disY,"ItemTips_disY")
  520. if disY > 0 then
  521. disY = math.min(disY, 4000)
  522. node:setPosition(cc.p(0, size.height+disY))
  523. node:setAnchorPoint(cc.p(0, 1))
  524. else
  525. disY = 0
  526. end
  527. end
  528. end
  529. --英雄截图
  530. if val.position == "hero_attribute" then--属性
  531. if HeroExtraAtt and HeroExtraAtt.manyHeight ~= nil and type(HeroExtraAtt.manyHeight) == "number" and HeroExtraAtt.manyHeight > 0 then
  532. disY = HeroExtraAtt.manyHeight
  533. dump(disY,"hero_attribute_disY")
  534. if disY > 0 then
  535. disY = math.min(disY, 4000)
  536. node:setPosition(cc.p(0, size.height+disY))
  537. node:setAnchorPoint(cc.p(0, 1))
  538. else
  539. disY = 0
  540. end
  541. end
  542. elseif val.position == "hero_skill" then--技能
  543. if HeroSkill and HeroSkill.manyHeight ~= nil and type(HeroSkill.manyHeight) == "number" and HeroSkill.manyHeight > 0 then
  544. disY = HeroSkill.manyHeight
  545. dump(disY,"hero_skill_disY")
  546. if disY > 0 then
  547. disY = math.min(disY, 4000)
  548. node:setPosition(cc.p(0, size.height+disY))
  549. node:setAnchorPoint(cc.p(0, 1))
  550. else
  551. disY = 0
  552. end
  553. end
  554. elseif val.position == "hero_title" then--称号
  555. if HeroTitle and HeroTitle.manyHeight ~= nil and type(HeroTitle.manyHeight) == "number" and HeroTitle.manyHeight > 0 then
  556. disY = HeroTitle.manyHeight
  557. dump(disY,"hero_title_disY")
  558. if disY > 0 then
  559. disY = math.min(disY, 4000)
  560. node:setPosition(cc.p(0, size.height+disY))
  561. node:setAnchorPoint(cc.p(0, 1))
  562. else
  563. disY = 0
  564. end
  565. end
  566. elseif val.position == "hero_equip" and val.mediator == "ItemTipsMediator" then--装备tips
  567. if ItemTips and ItemTips.manyHeight ~= nil and type(ItemTips.manyHeight) == "number" and ItemTips.manyHeight > 0 then
  568. disY = ItemTips.manyHeight-size.height
  569. dump(disY,"hero_ItemTips_disY")
  570. if disY > 0 then
  571. disY = math.min(disY, 4000)
  572. node:setPosition(cc.p(0, size.height+disY))
  573. node:setAnchorPoint(cc.p(0, 1))
  574. else
  575. disY = 0
  576. end
  577. end
  578. end
  579. -- performWithDelay(node,function ()
  580. local rt = cc.RenderTexture:create(size.width, size.height+disY, cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888, gl.DEPTH24_STENCIL8_OES)
  581. rt:begin()
  582. node:visit()
  583. rt:endToLua()
  584. -- dump(filename,"filename")
  585. local FileUtils = cc.FileUtils:getInstance()
  586. local WritablePath = FileUtils:getWritablePath()
  587. local path = WritablePath .. filename
  588. if FileUtils:isFileExist(path) then
  589. FileUtils:removeFile(path)
  590. end
  591. res = rt:saveToFile(filename, cc.IMAGE_FORMAT_PNG, true)
  592. -- end,0.02)
  593. return res
  594. end
  595. function TradingBankCaptureOtherCommand:CheckConditions(itemData)
  596. local res = true
  597. --30天内寄售过的不能寄售
  598. if itemData.AddValues then
  599. for k, v in pairs(itemData.AddValues) do
  600. if v.Id == 15 then
  601. if GetServerTime() < v.Value then
  602. res = false
  603. end
  604. break
  605. end
  606. end
  607. end
  608. local itemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
  609. local bindArticleType = itemConfigProxy:GetBindArticleType()
  610. local isBind, isSelf, isMeetType = CheckItemisBind(itemData, bindArticleType.TYPE_NOSTALL)
  611. if isMeetType then
  612. res = false
  613. end
  614. return res
  615. end
  616. -------------------
  617. function TradingBankCaptureOtherCommand:uploadImg()
  618. SL:onLUAEvent(LUA_EVENT_OPEN_SETTING_FRAME_UP_LOAD_TIPS)
  619. local FileUtils = cc.FileUtils:getInstance()
  620. self.m_uploadImgIndex = 1
  621. self.m_serverPath = {}
  622. self.m_uploadImageList = {}
  623. self.m_publishImageList = {}
  624. for position, vec in pairs(self.m_files) do
  625. for i, path in ipairs(vec) do
  626. local val = {
  627. position = position,
  628. path = path
  629. }
  630. table.insert(self.m_uploadImageList, val)
  631. end
  632. end
  633. for position, vec in pairs(self.m_filesPublish) do
  634. for i, path in ipairs(vec) do
  635. local val = {
  636. position = position,
  637. path = path
  638. }
  639. table.insert(self.m_publishImageList, val)
  640. end
  641. end
  642. dump(self.m_files,"m_files2")
  643. --服务器和客户端的标识字段
  644. self.tableType = {["attribute"]=0,["bag"]=0,["clothes"]=0,["equip"]=0,["hero_attribute"]=0,["hero_bag"]=0,["hero_clothes"]=0,
  645. ["hero_equip"]=0,["hero_skill"]=0,["hero_status"]=0,["hero_title"]=0,["skill"]=0,["status"]=0,["title"]=0,["warehouse"]=0}
  646. --寄售key功能:h5交易行服务器需要
  647. -- self.publishImage = {["attribute"]={},["bag"]={},["clothes"]={},["equip"]={},["hero_attribute"]={},["hero_bag"]={},["hero_clothes"]={},
  648. -- ["hero_equip"]={},["hero_skill"]={},["hero_status"]={},["hero_title"]={},["skill"]={},["status"]={},["title"]={},["warehouse"]={}}
  649. local posname = self.m_uploadImageList[self.m_uploadImgIndex].position --找到列表中的图片类型
  650. local path = self.m_uploadImageList[self.m_uploadImgIndex].path --找到列表中的图片路径
  651. self.tableType[posname] = self.tableType[posname] + 1
  652. local otherTradingBankProxy = global.Facade:retrieveProxy(global.ProxyTable.OtherTradingBankProxy)
  653. if self.tableDataUrl.imagePrefix and self.tableDataUrl[posname][self.tableType[posname]] then
  654. local serverurl = self.tableDataUrl.imagePrefix .. self.tableDataUrl[posname][self.tableType[posname]]--确定列表中有 根据posname类型 再去找index
  655. local dataUrl = {}
  656. dataUrl.path = self.m_publishImageList[self.m_uploadImgIndex].path
  657. dataUrl.url = self.tableDataUrl[posname][self.tableType[posname]]
  658. if not self.publishImage[posname] then
  659. self.publishImage[posname] = {}
  660. end
  661. table.insert(self.publishImage[posname], dataUrl)
  662. otherTradingBankProxy:uploadImg3(self, serverurl, path, handler(self, self.ResUploadImg))
  663. else
  664. ShowSystemTips(GET_STRING(700000143))--服务器图片地址错误
  665. global.Facade:sendNotification(global.NoticeTable.Layer_LoadingBar_Close)
  666. SL:onLUAEvent(LUA_EVENT_CLOSE_SETTING_FRAME_UP_LOAD_TIPS)
  667. self.timerOne = SL:Schedule(function()
  668. SL:UnSchedule(self.timerOne)
  669. self.timerOne = nil
  670. global.gameWorldController:OnGameLeaveWorld()
  671. end, 0.5)
  672. end
  673. end
  674. function TradingBankCaptureOtherCommand:ResUploadImg(code, data, msg)
  675. local curPositionData = self.m_uploadImageList[self.m_uploadImgIndex] or {}
  676. local position = curPositionData.position
  677. if code == 200 then
  678. if data then
  679. local path = data
  680. if not self.m_serverPath[position] then
  681. self.m_serverPath[position] = {}
  682. end
  683. table.insert(self.m_serverPath[position], path)
  684. --下一张
  685. local maxLen = #self.m_uploadImageList
  686. local max = maxLen == 0 and 1 or maxLen
  687. if self.m_uploadImgIndex == maxLen then
  688. dump(self.tableType,"tableType")
  689. self:onSellRole()
  690. else
  691. self.m_uploadImgIndex = self.m_uploadImgIndex + 1
  692. local posname = self.m_uploadImageList[self.m_uploadImgIndex].position --找到列表中的图片类型
  693. local path = self.m_uploadImageList[self.m_uploadImgIndex].path --找到列表中的图片路径
  694. self.tableType[posname] = self.tableType[posname] + 1
  695. local otherTradingBankProxy = global.Facade:retrieveProxy(global.ProxyTable.OtherTradingBankProxy)
  696. if self.tableDataUrl.imagePrefix and self.tableDataUrl[posname][self.tableType[posname]] then
  697. local serverurl = self.tableDataUrl.imagePrefix .. self.tableDataUrl[posname][self.tableType[posname]]--确定列表中有 根据posname类型 再去找index
  698. local dataUrl = {}
  699. dataUrl.path = self.m_publishImageList[self.m_uploadImgIndex].path
  700. dataUrl.url = self.tableDataUrl[posname][self.tableType[posname]]
  701. if not self.publishImage[posname] then
  702. self.publishImage[posname] = {}
  703. end
  704. table.insert(self.publishImage[posname], dataUrl)
  705. otherTradingBankProxy:uploadImg3(self, serverurl, path, handler(self, self.ResUploadImg))
  706. else
  707. ShowSystemTips(GET_STRING(700000143))--服务器图片地址错误
  708. global.Facade:sendNotification(global.NoticeTable.Layer_LoadingBar_Close)
  709. SL:onLUAEvent(LUA_EVENT_CLOSE_SETTING_FRAME_UP_LOAD_TIPS)
  710. self.timerOne = SL:Schedule(function()
  711. SL:UnSchedule(self.timerOne)
  712. self.timerOne = nil
  713. global.gameWorldController:OnGameLeaveWorld()
  714. end, 0.5)
  715. end
  716. end
  717. else
  718. global.Facade:sendNotification(global.NoticeTable.SystemTips, msg or "")
  719. global.Facade:sendNotification(global.NoticeTable.Layer_LoadingBar_Close)
  720. SL:onLUAEvent(LUA_EVENT_CLOSE_SETTING_FRAME_UP_LOAD_TIPS)
  721. self.timerOne = SL:Schedule(function()
  722. SL:UnSchedule(self.timerOne)
  723. self.timerOne = nil
  724. global.gameWorldController:OnGameLeaveWorld()
  725. end, 0.5)
  726. end
  727. else
  728. global.Facade:sendNotification(global.NoticeTable.SystemTips, msg or "")
  729. global.Facade:sendNotification(global.NoticeTable.Layer_LoadingBar_Close)
  730. SL:onLUAEvent(LUA_EVENT_CLOSE_SETTING_FRAME_UP_LOAD_TIPS)
  731. self.timerOne = SL:Schedule(function()
  732. SL:UnSchedule(self.timerOne)
  733. self.timerOne = nil
  734. global.gameWorldController:OnGameLeaveWorld()
  735. end, 0.5)
  736. end
  737. end
  738. function TradingBankCaptureOtherCommand:onSellRole()
  739. SL:onLUAEvent(LUA_EVENT_CLOSE_SETTING_FRAME_UP_LOAD_TIPS)
  740. global.Facade:sendNotification(global.NoticeTable.Layer_LoadingBar_Close)
  741. local uploadSuccess = true
  742. for k, v in pairs(self.m_files) do
  743. if not self.m_serverPath[k] then--图片上传失败
  744. uploadSuccess = false
  745. ShowSystemTips(GET_STRING(600000130))
  746. break
  747. end
  748. end
  749. --冻结角色
  750. local otherTradingBankProxy = global.Facade:retrieveProxy(global.ProxyTable.OtherTradingBankProxy)
  751. local params = {
  752. prePublishLockId = otherTradingBankProxy:getPublishLockID()
  753. }
  754. otherTradingBankProxy:lockPublishRole(self, params, function(code, data, msg)
  755. if code == 200 then
  756. if data then
  757. --self:uploadImg() -- app上传图片流程
  758. if uploadSuccess then
  759. ShowSystemTips(GET_STRING(600000419))--复制成功
  760. local otherTradingBankProxy = global.Facade:retrieveProxy(global.ProxyTable.OtherTradingBankProxy)
  761. self.publishImage.key = otherTradingBankProxy:getPublishKey()
  762. dump(self.publishImage,"self.publishImage")
  763. otherTradingBankProxy:UpPublishKeyUrl(self, self.publishImage, function(code, data, msg) end)
  764. SL:SetMetaValue("CLIPBOARD_TEXT", otherTradingBankProxy:getPublishKey())
  765. end
  766. self.timerOne = SL:Schedule(function()
  767. SL:UnSchedule(self.timerOne)
  768. self.timerOne = nil
  769. global.gameWorldController:OnGameLeaveWorld()
  770. end, 0.5)
  771. else
  772. --如果冻结失败让玩家重新获取一下寄售码 保证流程畅通
  773. otherTradingBankProxy:setPublishKeyValidTime(0)
  774. otherTradingBankProxy:setPublishKey("")
  775. ShowSystemTips(GET_STRING(700000136))--冻结失败 请稍后再试 备注:服务器处理异常情况
  776. end
  777. else
  778. ShowSystemTips(msg)
  779. end
  780. end)
  781. end
  782. return TradingBankCaptureOtherCommand