ItemTipsProxy.lua 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. local RemoteProxy = requireProxy( "remote/RemoteProxy" )
  2. local ItemTipsProxy = class( "ItemTipsProxy", RemoteProxy )
  3. ItemTipsProxy.NAME = global.ProxyTable.ItemTipsProxy
  4. --调用场景
  5. ItemTipsProxy.posType =
  6. {
  7. from_guild_storage_bagLayer = 1, --行会仓库中的背包
  8. from_guild_storageLayer = 2, --行会仓库中的仓库
  9. }
  10. function ItemTipsProxy:ctor()
  11. self.tipsHeight = 0 --tips的高度 显示批量使用界面的时候要用
  12. self._data = {} --用来保存tips中道具的信息
  13. self._suitConfig = {}
  14. self._newSuitConfig = {} --新的套装属性表数据
  15. self._suitNameConfig = {}
  16. self._customAttConfig = {} --自定义属性表
  17. self._btn_show_switch = nil --tips 佩戴/分解/不显示使用按钮的道具类型
  18. self._extraWidget = {}
  19. ItemTipsProxy.super.ctor(self)
  20. end
  21. function ItemTipsProxy:onRegister()
  22. ItemTipsProxy.super.onRegister( self )
  23. end
  24. function ItemTipsProxy:ClearItemTipsData()
  25. self._data = {}
  26. self.tipsHeight = 0
  27. end
  28. function ItemTipsProxy:GetItemTipsData()
  29. return self._data
  30. end
  31. function ItemTipsProxy:AddItemTipsData(data)
  32. if data.itemData then
  33. self._data[data.itemData.MakeIndex] = data.itemData
  34. end
  35. end
  36. function ItemTipsProxy:GetItemTipsDataById(id)
  37. if id == nil or id == 0 then
  38. return nil
  39. end
  40. return self._data[id]
  41. end
  42. function ItemTipsProxy:setItemData( itemData )
  43. if itemData and itemData.MakeIndex then
  44. self._data[itemData.MakeIndex] = itemData
  45. end
  46. end
  47. function ItemTipsProxy:getRoleInfo( )
  48. local _proxyPlayer = global.Facade:retrieveProxy( global.ProxyTable.PlayerProperty )
  49. local data = {}
  50. local level = _proxyPlayer:GetRoleLevel()
  51. local job = _proxyPlayer:GetRoleJob()
  52. local roleType = 1
  53. data.job = job or 0
  54. data.level = level or 0
  55. data.roleType = roleType
  56. return data
  57. end
  58. function ItemTipsProxy:setTipsHeight( height )
  59. self.tipsHeight = height
  60. end
  61. function ItemTipsProxy:getTipsHeight( )
  62. return self.tipsHeight
  63. end
  64. function ItemTipsProxy:onRegister()
  65. ItemTipsProxy.super.onRegister( self )
  66. end
  67. function ItemTipsProxy:getSuitConfigById(id)
  68. return self._suitConfig[id]
  69. end
  70. function ItemTipsProxy:getSuitConfigByName(name)
  71. return self._suitNameConfig[name]
  72. end
  73. function ItemTipsProxy:getCustomDesc(id)
  74. if not self._customAttConfig then return nil end
  75. local config = self._customAttConfig[id]
  76. if config and config.value then
  77. return config.value
  78. end
  79. return nil
  80. end
  81. function ItemTipsProxy:getCustomIcon(id)
  82. if not self._customAttConfig then return nil end
  83. local config = self._customAttConfig[id]
  84. if config and config.icon and config.icon ~= "" then
  85. local tubiaoArray = string.split(config.icon or "", "=")
  86. local key = tubiaoArray[1] and tonumber(tubiaoArray[1]) or nil
  87. if key and tubiaoArray[2] and tubiaoArray[2] ~= "" then
  88. local resArray = string.split(tubiaoArray[2] or "", "#")
  89. local iconStr = global.isWinPlayMode and resArray[1] or resArray[2]
  90. local iconArray = string.split(iconStr or "", "&")
  91. return {
  92. [key] = {res = iconArray[1] or "", x = iconArray[2] and tonumber(iconArray[2]) or 0, y = iconArray[3] and tonumber(iconArray[3]) or 0}
  93. }
  94. end
  95. end
  96. return nil
  97. end
  98. function ItemTipsProxy:getSpecialDesc(id)
  99. if not self._specialAttConfig then return nil end
  100. local config = self._specialAttConfig[id]
  101. if config then
  102. return config.caption
  103. end
  104. return nil
  105. end
  106. function ItemTipsProxy:LoadConfig()
  107. local GameConfigMgrProxy = global.Facade:retrieveProxy(global.ProxyTable.GameConfigMgrProxy)
  108. local config = GameConfigMgrProxy:getConfigByKey("cfg_suit") or {}
  109. self._suitConfig = config
  110. self._suitNameConfig = {}
  111. for _, v in pairs(config) do
  112. while true do
  113. if not v.notes or string.len(v.notes) == 0 then
  114. break
  115. end
  116. local sliceStr = string.split(v.notes, "|")
  117. local suitList = {}
  118. if sliceStr[2] == "*" then
  119. --带*的表示 每个装备单独显示套装属性
  120. local title = sliceStr[1]
  121. local equipNames = {}
  122. local suitAtts = {}
  123. local names = ""
  124. for i = 3, #sliceStr do
  125. local sliceStr2 = string.split(sliceStr[i], ":")
  126. if sliceStr2[1] and sliceStr2[2] then
  127. names = names .. sliceStr2[1] .. "|"
  128. local sliceNameStr = string.split(sliceStr2[1], "/")
  129. local name = #sliceNameStr >= 2 and sliceNameStr[2] or sliceNameStr[1]
  130. table.insert(equipNames, name)
  131. table.insert(suitAtts, sliceStr2[2])
  132. end
  133. end
  134. names = string.sub(names, 1, string.len(names) - 1)
  135. for i, s in pairs(suitAtts) do
  136. table.insert(suitList, {name = equipNames[i], notes = sliceStr[1] .. "|" .. #suitAtts .. "|" .. names .. ":" .. s})
  137. end
  138. else
  139. suitList = {{notes = v.notes}}
  140. end
  141. for _, data in pairs(suitList) do
  142. local notes = data.notes
  143. local first = notes and string.find(notes, ":")
  144. if first then
  145. local oneConfig = {}
  146. oneConfig.Idx = v.Idx
  147. oneConfig.equipNameStr = string.sub(notes, 1, first - 1)
  148. oneConfig.equipAttStr = string.sub(notes, first + 1, -1)
  149. local sliceStr = string.split(oneConfig.equipNameStr, "|")
  150. local sameName = {}
  151. local name = data.name
  152. if name then
  153. sameName[name] = true
  154. else
  155. for i = 3, #sliceStr do
  156. local sliceNameStr = string.split(sliceStr[i], "/")
  157. local name = #sliceNameStr >= 2 and sliceNameStr[2] or sliceNameStr[1]
  158. --相同装备只取一个
  159. sameName[name] = true
  160. end
  161. end
  162. for name, _ in pairs(sameName) do
  163. self._suitNameConfig[name] = self._suitNameConfig[name] or {}
  164. table.insert(self._suitNameConfig[name], oneConfig)
  165. end
  166. end
  167. end
  168. break
  169. end
  170. end
  171. self._customAttConfig = {}
  172. local captionCfg = {}
  173. local captionCfg = GameConfigMgrProxy:getConfigByKey("cfg_custpro_caption") or {}
  174. local captionFile = "cfg_custpro_caption.lua"
  175. if global.FileUtilCtl:isFileExist("scripts/game_config/" .. captionFile) then
  176. captionCfg = {}
  177. captionCfg = requireGameConfig(captionFile)
  178. end
  179. for _, v in pairs(captionCfg) do
  180. self._customAttConfig[v.id] = v
  181. end
  182. local fileName = "cfg_suitex.lua"
  183. if global.FileUtilCtl:isFileExist("scripts/game_config/" .. fileName) then
  184. local newConfig = requireGameConfig(fileName)
  185. for _, v in ipairs(newConfig) do
  186. self._newSuitConfig[v.suitid] = self._newSuitConfig[v.suitid] or {}
  187. table.insert(self._newSuitConfig[v.suitid], v)
  188. end
  189. end
  190. end
  191. -- 获取新的套装属性表数据
  192. function ItemTipsProxy:GetNewSuitConfigById( suitid )
  193. return self._newSuitConfig[suitid] or {}
  194. end
  195. -- 自定义属性映射att表属性ID
  196. --[[ cusid 自定义id
  197. mappingid 映射id
  198. type 类型(0=数值 1=百分比 2=万分比)
  199. --]]
  200. function ItemTipsProxy:LoadCustAbilConfig()
  201. local GameConfigMgrProxy = global.Facade:retrieveProxy(global.ProxyTable.GameConfigMgrProxy)
  202. local config = GameConfigMgrProxy:getConfigByKey("cfg_cusabilmapping") or {}
  203. self._custAbilConfig = config
  204. self._custAbilMap = {}
  205. for i = 1, #config do
  206. if config[i] and next(config[i]) then
  207. local custId = config[i].cusid
  208. if custId then
  209. self._custAbilMap[custId] = {id = config[i].mappingid, type = config[i].type, showCustomName = config[i].showcustname == 1}
  210. end
  211. end
  212. end
  213. end
  214. function ItemTipsProxy:GetCustAbilMap()
  215. return self._custAbilMap or {}
  216. end
  217. --------------------------------------------------
  218. function ItemTipsProxy:GetExtraWidgets( ... )
  219. return self._extraWidget
  220. end
  221. function ItemTipsProxy:AddExtraWidgetByIndex( widget , Index)
  222. local widget = widget:cloneEx()
  223. widget:retain()
  224. if not self._extraWidget then
  225. self._extraWidget = {}
  226. end
  227. if not self._extraWidget[Index] then
  228. self._extraWidget[Index] = {}
  229. end
  230. table.insert( self._extraWidget[Index], widget )
  231. end
  232. function ItemTipsProxy:Cleanup()
  233. for i, extraData in pairs(self._extraWidget) do
  234. for _, widget in pairs(extraData) do
  235. if not tolua.isnull(widget) then
  236. widget:release()
  237. end
  238. end
  239. end
  240. self._extraWidget = {}
  241. end
  242. return ItemTipsProxy