SL.lua 104 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103
  1. SL = {}
  2. require("GUI/SLReqMessage")
  3. local tconcat = table.concat
  4. local tinsert = table.insert
  5. local tkeys = table.keys
  6. local tsort = table.sort
  7. local srep = string.rep
  8. local type = type
  9. local pairs = pairs
  10. local tostring = tostring
  11. local next = next
  12. local sfind = string.find
  13. local ssub = string.sub
  14. local slen = string.len
  15. local sbyte = string.byte
  16. local sgsub = string.gsub
  17. local sformat = string.format
  18. local supper = string.upper
  19. local cjson = require("cjson")
  20. local skillUtils = requireProxy("skillUtils")
  21. local proxyUtils = requireProxy("proxyUtils")
  22. local invalidStr = { "%", "(", ")", "_", "lib", "function", "then", "end", "_G", "return", "index", "set" }
  23. SL._DEBUG = global.isWindows and (global.isDebugMode or global.isGMMode)
  24. SL.FormParam = {}
  25. SL.LocalStringCache = {} -- 将要存储的数据缓存
  26. SL.LocalStringTimerID = nil -- 存储数据定时器
  27. SL.DigitChangeTimerID = nil -- 数字滚动定时器
  28. SL.Triggers = {} -- 触发
  29. SL.CustomMapEffects = {} --添加地图特效数据
  30. SL.OpenGUITXTEditor = false
  31. SL.TradingCustomCaptureLua = {}
  32. ---------------------------------------------------------------------------
  33. local function deprecatedTip(old_name, new_name)
  34. SL:Print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********")
  35. end
  36. ---------------------------------------------------------------------------
  37. -- 基础函数
  38. function SL:release_print(...)
  39. release_print(...)
  40. end
  41. function SL:Print(...)
  42. if not SL._DEBUG then
  43. return nil
  44. end
  45. SL:release_print(...)
  46. end
  47. function SL:PrintEx(...)
  48. if not SL._DEBUG then
  49. return nil
  50. end
  51. SL:release_print(...)
  52. SL:release_print(debug.traceback())
  53. end
  54. local function dump_value_(v)
  55. if type(v) == "string" then
  56. v = "\"" .. v .. "\""
  57. end
  58. return tostring(v)
  59. end
  60. function SL:dump(value, desciption, nesting)
  61. if not SL._DEBUG then
  62. return nil
  63. end
  64. if type(nesting) ~= "number" then nesting = 3 end
  65. local lookupTable = {}
  66. local result = {}
  67. local traceback = string.split(debug.traceback("", 2), "\n")
  68. SL:Print("dump from: " .. string.trim(traceback[3]))
  69. local function dump_(value, desciption, indent, nest, keylen)
  70. desciption = desciption or "<var>"
  71. local spc = ""
  72. if type(keylen) == "number" then
  73. spc = string.rep(" ", keylen - string.len(dump_value_(desciption)))
  74. end
  75. if type(value) ~= "table" then
  76. result[#result + 1] = string.format("%s%s%s = %s", indent, dump_value_(desciption), spc, dump_value_(value))
  77. elseif lookupTable[tostring(value)] then
  78. result[#result + 1] = string.format("%s%s%s = *REF*", indent, dump_value_(desciption), spc)
  79. else
  80. lookupTable[tostring(value)] = true
  81. if nest > nesting then
  82. result[#result + 1] = string.format("%s%s = *MAX NESTING*", indent, dump_value_(desciption))
  83. else
  84. result[#result + 1] = string.format("%s%s = {", indent, dump_value_(desciption))
  85. local indent2 = indent .. " "
  86. local keys = {}
  87. local keylen = 0
  88. local values = {}
  89. for k, v in pairs(value) do
  90. keys[#keys + 1] = k
  91. local vk = dump_value_(k)
  92. local vkl = string.len(vk)
  93. if vkl > keylen then keylen = vkl end
  94. values[k] = v
  95. end
  96. tsort(keys, function(a, b)
  97. if type(a) == "number" and type(b) == "number" then
  98. return a < b
  99. else
  100. return tostring(a) < tostring(b)
  101. end
  102. end)
  103. for i, k in ipairs(keys) do
  104. dump_(values[k], k, indent2, nest + 1, keylen)
  105. end
  106. result[#result + 1] = string.format("%s}", indent)
  107. end
  108. end
  109. end
  110. dump_(value, desciption, "- ", 1)
  111. for i, line in ipairs(result) do
  112. SL:Print(line)
  113. end
  114. end
  115. function SL:PrintTraceback()
  116. local traceback = string.split(debug.traceback("", 2), "\n")
  117. SL:PrintTable(traceback)
  118. end
  119. SL.print = SL.Print
  120. SL.printEx = SL.PrintEx
  121. SL.Dump = SL.dump
  122. SL.PrintTable = SL.dump
  123. local function CheckJsonInvalid(jsonStr)
  124. for i, v in ipairs(invalidStr) do
  125. local v2 = i < 4 and "%" .. v or v
  126. if string.find(jsonStr, v2) then
  127. SL:release_print(string.format("Jeson Error: Invalid character '%s'", v))
  128. return false
  129. end
  130. end
  131. return true
  132. end
  133. -- json字符串解密
  134. -- params: json string
  135. -- return: json table
  136. function SL:JsonDecode(jsonStr, ischeck)
  137. if not jsonStr or jsonStr == "" then
  138. return nil
  139. end
  140. if ischeck then
  141. if CheckJsonInvalid(jsonStr) then
  142. return cjson.decode(jsonStr)
  143. end
  144. else
  145. return cjson.decode(jsonStr)
  146. end
  147. end
  148. -- json字符串加密
  149. -- params: json table
  150. -- return: json string
  151. function SL:JsonEncode(jsonData, ischeck)
  152. if ischeck then
  153. local jData = cjson.encode(jsonData)
  154. if CheckJsonInvalid(jData) then
  155. return jData
  156. end
  157. else
  158. return cjson.encode(jsonData)
  159. end
  160. end
  161. -- 文件路径是否存在
  162. function SL:IsFileExist(path)
  163. return global.FileUtilCtl:isFileExist(path)
  164. end
  165. -- 深拷贝
  166. function SL:CopyData(data)
  167. return clone(data)
  168. end
  169. function SL:Split(input, delimiter)
  170. return string.split(input, delimiter)
  171. end
  172. -- 注册游戏事件回调
  173. -- params: string, string, function
  174. -- return: nil
  175. function SL:RegisterLUAEvent(eventID, eventTag, eventCB, widget)
  176. if not eventID then
  177. SL:Print("[GUI ERROR] SL:RegisterLUAEvent, eventID is null", eventID, eventTag, eventCB)
  178. return
  179. end
  180. if not eventTag then
  181. SL:Print("[GUI ERROR] SL:RegisterLUAEvent, eventTag is null", eventID, eventTag, eventCB)
  182. return
  183. end
  184. if not eventCB then
  185. SL:Print("[GUI ERROR] SL:RegisterLUAEvent, eventCB is null", eventID, eventTag, eventCB)
  186. return
  187. end
  188. SLBridge.LUAEvent[eventID] = SLBridge.LUAEvent[eventID] or {}
  189. SLBridge.LUAEvent[eventID][eventTag] = eventCB
  190. if widget then
  191. GUI:Win_BindLuaEvent(widget, eventID, eventTag)
  192. end
  193. end
  194. -- 注销游戏事件回调
  195. -- params: string, string, function
  196. -- return: nil
  197. function SL:UnRegisterLUAEvent(eventID, eventTag)
  198. if not eventID then
  199. SL:Print("[GUI ERROR] SL:UnRegisterLUAEvent, eventID is null", eventID, eventTag)
  200. return
  201. end
  202. if not eventTag then
  203. SL:Print("[GUI ERROR] SL:UnRegisterLUAEvent, eventTag is null", eventID, eventTag)
  204. return
  205. end
  206. if not SLBridge.LUAEvent[eventID] then
  207. SL:Print("[GUI ERROR] SL:UnRegisterLUAEvent, can't registered", eventID)
  208. return
  209. end
  210. SLBridge.LUAEvent[eventID][eventTag] = nil
  211. end
  212. function SL:onLUAEvent(name, data)
  213. SLBridge:onLUAEvent(name, data)
  214. end
  215. function SL:SendNetMsg(msgID, p1, p2, p3, sendData)
  216. SL.NetworkUtil:SendMsg(msgID, sendData, p1, p2, p3)
  217. end
  218. function SL:RegisterNetMsg(msgID, netCB, widget)
  219. SL.NetworkUtil:RegisterNetworkHandler(msgID, netCB)
  220. if widget then
  221. GUI:Win_BindNetMsgEvent(widget, msgID)
  222. end
  223. end
  224. function SL:UnRegisterNetMsg(msgID)
  225. SL.NetworkUtil:UnRegisterNetworkHandler(msgID)
  226. end
  227. function SL:SendLuaNetMsg(msgID, p1, p2, p3, sendData)
  228. SL.NetworkUtil:SendLuaMsg(msgID, p1, p2, p3, sendData)
  229. end
  230. function SL:RegisterLuaNetMsg(msgID, netCB, widget)
  231. SL.NetworkUtil:RegisterLuaNetworkHandler(msgID, netCB)
  232. if widget then
  233. GUI:Win_BindLuaNetMsgEvent(widget, msgID)
  234. end
  235. end
  236. function SL:UnRegisterLuaNetMsg(msgID)
  237. SL.NetworkUtil:UnRegisterLuaNetworkHandler(msgID)
  238. end
  239. -- 注册触发
  240. function SL:RegisterTrigger(eventName, eventCB)
  241. SL.Triggers[eventName] = eventCB
  242. end
  243. -- 注销
  244. function SL:UnRegisterTrigger(eventName)
  245. SL.Triggers[eventName] = nil
  246. end
  247. -- 转换颜色,从16进制字符转为{r, g, b}
  248. function SL:ConvertColorFromHexString(hexString)
  249. return GetColorFromHexString(hexString)
  250. end
  251. -- 提示
  252. function SL:ShowSystemTips(str)
  253. ShowSystemTips(str)
  254. end
  255. -- 开启一个定时器
  256. -- params: function, number
  257. -- return: int
  258. function SL:Schedule(callback, interval)
  259. return cc.Director:getInstance():getScheduler():scheduleScriptFunc(callback, interval, false)
  260. end
  261. -- 开启一个定时器 时间戳 时间戳不支持毫秒级的定时器
  262. function SL:ScheduleTimeSec(callback, interval)
  263. local oldTime = GetServerTime()
  264. return cc.Director:getInstance():getScheduler():scheduleScriptFunc(function()
  265. if GetServerTime() - oldTime >= interval then
  266. oldTime = GetServerTime()
  267. if callback then
  268. callback()
  269. end
  270. end
  271. end, 1/60, false)
  272. end
  273. -- 开启一个单次定时器
  274. -- params: function, number
  275. -- return: int
  276. function SL:ScheduleOnce(listener, time)
  277. return PerformWithDelayGlobal(listener, time)
  278. end
  279. -- 停止一个定时器
  280. -- params: int
  281. function SL:UnSchedule(scheduleID)
  282. if not scheduleID then
  283. return
  284. end
  285. cc.Director:getInstance():getScheduler():unscheduleScriptEntry(scheduleID)
  286. end
  287. -- 开启一个定时器, 绑定node
  288. -- params: function, number
  289. -- return: int
  290. function SL:schedule(node, callback, delay)
  291. return schedule(node, callback, delay)
  292. end
  293. -- 开启一个单次定时器
  294. -- params: int
  295. function SL:scheduleOnce(node, callback, delay)
  296. return performWithDelay(node, callback, delay)
  297. end
  298. --哈希表转成按数组
  299. function SL:HashToSortArray(hashTab, sortFunc)
  300. return HashToSortArray(hashTab, sortFunc)
  301. end
  302. --显示提示文本
  303. function SL:SHOW_DESCTIP(str, width, worldPos, anchorPoint, swallowType)
  304. SHOW_DESCTIP(str, width, worldPos, anchorPoint, swallowType)
  305. end
  306. -- 加载文件
  307. function SL:Require(file, reload)
  308. if reload then
  309. package.loaded[file] = nil
  310. end
  311. return require(file)
  312. end
  313. -- 加载文件
  314. function SL:RequireFile(file)
  315. if SL._DEBUG then
  316. package.loaded[file] = nil
  317. end
  318. return require(file)
  319. end
  320. -- 指定分隔符拆解一个文件
  321. function SL:LoadTxtFile(path, delimiter, callBack)
  322. if nil == path or nil == callBack then
  323. print("LoadText error")
  324. return
  325. end
  326. if not global.FileUtilCtl:isFileExist(path) then
  327. release_print("LoadTxtFile path is not exist !!!")
  328. return
  329. end
  330. local strBuffer = global.FileUtilCtl:getDataFromFileEx(path)
  331. strBuffer = sgsub(strBuffer, "\r", "")
  332. local lineBreak = "\n"
  333. local lines = string.split(strBuffer, lineBreak)
  334. local len = 0
  335. local pos1 = nil
  336. for k, v in pairs(lines) do
  337. len = slen(v)
  338. if len > 0 then
  339. pos1, _ = sfind(v, "//")
  340. if not pos1 then -- skip //
  341. local dataTable
  342. if delimiter == nil or delimiter == "" or delimiter == "\n" then -- ignore "" \n
  343. dataTable = {}
  344. dataTable[1] = v
  345. else
  346. dataTable = string.split(v, delimiter)
  347. end
  348. callBack(dataTable)
  349. end
  350. end
  351. end
  352. end
  353. -- 基础函数
  354. ---------------------------------------------------------------------------
  355. -- 数字转换成万、亿单位
  356. function SL:GetSimpleNumber(n, places)
  357. local places = places or 2
  358. local fmt = "%."..places.."f%s"
  359. local pow = 10 ^ places
  360. if n >= 100000000 then
  361. return string.format(fmt, math.floor(n * pow / 100000000) / pow, GET_STRING(1045))
  362. end
  363. if n >= 100000 then
  364. return string.format("%d%s", math.floor(n/10000), GET_STRING(1005))
  365. end
  366. if n >= 10000 then
  367. return string.format(fmt, math.floor(n * pow / 10000) / pow, GET_STRING(1005))
  368. end
  369. return tostring(n)
  370. end
  371. -- 血量单位 过十亿(单位:E) 10w-99999w(单位:W)
  372. function SL:HPUnit(hp, pointBit, notCheckSet)
  373. local hpNum = tonumber(hp) or 0
  374. if hpNum < 0 then
  375. return hpNum
  376. end
  377. if notCheckSet then
  378. return hpNum
  379. elseif CHECK_SETTING(global.MMO.SETTING_IDX_HP_UNIT) ~= 1 then
  380. return hpNum
  381. end
  382. -- 小数点后几位 默认保留后两位
  383. pointBit = pointBit or 2
  384. local unitFunc = function(num)
  385. if pointBit == 0 then
  386. return math.floor(num)
  387. end
  388. local iNum, fNum = math.modf(num)
  389. local fDecimal = math.pow(10, tostring(pointBit))
  390. local newFNum = math.floor(tostring(fNum * fDecimal))
  391. local newINum = iNum + (newFNum / fDecimal)
  392. return newINum
  393. end
  394. if hpNum >= 1000000000 then
  395. hp = unitFunc(hpNum / 100000000) .. GET_STRING(310000600)
  396. elseif hpNum >= 100000 and hpNum <= 999999999 then
  397. hp = unitFunc(hpNum / 10000) .. GET_STRING(310000601)
  398. end
  399. return hp
  400. end
  401. -- 中文转换成竖着显示
  402. function SL:ChineseToVertical(str)
  403. return ChineseToVertical(str)
  404. end
  405. -- 获取字符串的byte长度
  406. function SL:GetUTF8ByteLen(str)
  407. local function chsize(char)
  408. if not char then
  409. print("not char")
  410. return 0
  411. elseif char > 240 then
  412. return 4
  413. elseif char > 225 then
  414. return 3
  415. elseif char > 192 then
  416. return 2
  417. else
  418. return 1
  419. end
  420. end
  421. local len = 0
  422. local chineseLen = 0
  423. local currentIndex = 1
  424. while currentIndex <= #str do
  425. local char = string.byte(str, currentIndex)
  426. local charS = chsize(char)
  427. currentIndex = currentIndex + charS
  428. len = len + charS
  429. if charS >= 3 then
  430. chineseLen = chineseLen + 1
  431. end
  432. end
  433. return len, chineseLen
  434. end
  435. -- 时间格式化成字符串显示
  436. function SL:TimeFormatToStr(time)
  437. return TimeFormatToString(time)
  438. end
  439. function SL:SecondToHMS(sec, isToStr, isSimple)
  440. local d = math.floor(sec / 86400)
  441. local h = math.fmod(math.floor(sec / 3600), 24)
  442. local m = math.fmod(math.floor(sec / 60), 60)
  443. local s = math.fmod(sec, 60)
  444. local time = {}
  445. time.d = d
  446. time.h = h
  447. time.m = m
  448. time.s = s
  449. if type(isToStr) == "boolean" and isToStr == true then
  450. if time.d > 0 then
  451. if isSimple then
  452. return sformat("%d天%d时", time.d, time.h)
  453. else
  454. return sformat("%d天%d时%d分%d秒", time.d, time.h, time.m, time.s)
  455. end
  456. else
  457. if time.h > 0 then
  458. if isSimple then
  459. return sformat("%d时%d分", time.h, time.m)
  460. else
  461. return sformat("%d时%d分%d秒", time.h, time.m, time.s)
  462. end
  463. else
  464. if time.m > 0 then
  465. return sformat("%d分%d秒", time.m, time.s)
  466. else
  467. return sformat("%d秒", time.s)
  468. end
  469. end
  470. end
  471. else
  472. return time
  473. end
  474. end
  475. -- 数字转化为千分位字符串
  476. function SL:GetThousandSepString(num)
  477. local formatted = ""
  478. if tonumber(num) then
  479. formatted = tostring(num)
  480. end
  481. local k
  482. while true do
  483. formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
  484. if k == 0 then break end
  485. end
  486. return formatted
  487. end
  488. -- 阿拉伯数字转中文大写
  489. function SL:NumberToChinese(szNum)
  490. return NumberToChinese(szNum)
  491. end
  492. local function writefile(str, filePath)
  493. local path = global.FileUtilCtl:getSuitableFOpen(filePath) -- io.open 读写不能是UTF-8
  494. local file = io.open(path, "w+")
  495. if file then
  496. print("open file success...", path)
  497. local tbl = string.split(str, "\n")
  498. for i = 1, #tbl do
  499. tbl[i] = sgsub(tbl[i], "!@2@!", "\\n")
  500. file:write(tbl[i] .. "\n")
  501. end
  502. print("write file complete...", string.len(str))
  503. file:close()
  504. else
  505. print("open file error...", path)
  506. end
  507. end
  508. local function dealSpecialStr(str)
  509. str = sgsub(str, '\\', '\\\\')
  510. str = sgsub(str, '"([^"]*)"', '!@1@!%1!@1@!')
  511. str = sgsub(str, '"([^"]*)"', '%1')
  512. str = sgsub(str, '!@1@!', '\\\"')
  513. return str
  514. end
  515. -- serialize table to str
  516. local function serialize(t, sortfunc, quotKey)
  517. if next(t) == nil then
  518. local serStr = "{" .. "\n" .. "}"
  519. return "local config = " .. serStr .. "\nreturn config"
  520. end
  521. local function ser_table(tbl, deep)
  522. local tmp = {}
  523. local sortList = tkeys(tbl)
  524. for _, k in ipairs(sortList) do
  525. local v = tbl[k]
  526. if type(v) == "table" then
  527. deep = deep + 1
  528. local key = type(k) == "number" and "[" .. k .. "]" or (quotKey and '["' .. k .. '"]' or k)
  529. local space = srep(" ", deep * 4)
  530. tinsert(tmp, "\n" .. space .. key .. " = " .. ser_table(v, deep))
  531. deep = deep - 1
  532. else
  533. local key2 = type(k) == "number" and "[" .. k .. "]" or k
  534. local space = "\n" .. srep(" ", (deep + 1) * 4)
  535. if type(v) == "string" then
  536. if sfind(v, "\n") then
  537. v = sgsub(v, "\n", "!@2@!")
  538. end
  539. v = dealSpecialStr(v)
  540. tinsert(tmp, space .. key2 .. '="' .. v .. '"')
  541. else
  542. tinsert(tmp, space .. key2 .. "=" .. tostring(v))
  543. end
  544. end
  545. end
  546. local concatStr = ""
  547. for index, value in ipairs(tmp) do
  548. concatStr = concatStr .. value .. ","
  549. end
  550. return "{" .. concatStr .. "\n" .. srep(" ", deep * 4) .. "}"
  551. end
  552. local sortT = tkeys(t)
  553. tsort(sortT)
  554. local finalStr = "local config = {\n"
  555. local cnt = #sortT
  556. for index, k in ipairs(sortT) do
  557. local oneStr = ser_table(t[k], 1)
  558. local key = type(k) == "number" and "[" .. k .. "]" or (quotKey and '["' .. k .. '"]' or k)
  559. local oneStr = sformat(" %s = %s,%s", key, oneStr, index == cnt and "" or "\n")
  560. finalStr = finalStr .. oneStr
  561. end
  562. finalStr = finalStr .. "\n}\n" .. "return config"
  563. return finalStr
  564. end
  565. -- lua table转成config配置表
  566. -- tab lua表, name 要保存的config名字, destPath 保存的路径(默认dev/scripts/game_config/),
  567. -- sortFunc 外层排序函数, quotKey ["key"]这种带引号的key,默认不带引号
  568. function SL:SaveTableToConfig(tab, name, destPath, sortFunc, quotKey)
  569. if not tab or type(tab) ~= "table" or not name or string.len(name) == 0 then
  570. return
  571. end
  572. print("++++++Save begin++++++", name)
  573. local startMS = GetTimeInMS()
  574. local serializeStr = serialize(tab, sortFunc, quotKey)
  575. local serMS = GetTimeInMS()
  576. print("serialize cost:" .. (serMS - startMS))
  577. local path = (destPath or "dev/scripts/game_config/") .. name .. ".lua"
  578. writefile(serializeStr, path)
  579. print("io cost:" .. (GetTimeInMS() - serMS))
  580. print("------Save end------")
  581. end
  582. -- 同步官方配置表
  583. function SL:UpdateConfig(file)
  584. local fileList = file and {file} or SLDefine.ConfigSettingFile
  585. local configPath = "scripts/game_config/"
  586. local module = global.L_ModuleManager:GetCurrentModule()
  587. -- 母包路径
  588. local motherPath = global.FileUtilCtl:getDefaultResourceRootPath() .. tostring(module:GetID()) .. "/" .. module:GetVersion() .. "/" .. configPath
  589. -- 热更路径
  590. local hotUpdatePath = module:GetStabPath() .. configPath
  591. local officalPath = {}
  592. for i, name in pairs(fileList) do
  593. local filePath = nil
  594. if global.FileUtilCtl:isFileExist(motherPath..name) then
  595. filePath = motherPath..name
  596. end
  597. if global.FileUtilCtl:isFileExist(hotUpdatePath..name) then
  598. filePath = hotUpdatePath..name
  599. end
  600. if global.FileUtilCtl:isFileExist(filePath) then -- 官方路径 先找母包 再找热更 以热更为主
  601. officalPath[name] = filePath
  602. end
  603. end
  604. local customPath = {}
  605. for i, name in pairs(fileList) do
  606. local filePath = nil
  607. local devPath = global.FileUtilCtl:getDefaultResourceRootPath() .. "dev" .. "/" .. configPath .. fileList[i]
  608. if global.FileUtilCtl:isFileExist(devPath) then
  609. filePath = devPath
  610. end
  611. if global.FileUtilCtl:isFileExist(filePath) then -- 本地路径 dev目录下
  612. customPath[name] = filePath
  613. end
  614. end
  615. local function getAddFile(path)
  616. local config = require(path)
  617. if config and next(config) then
  618. return config
  619. end
  620. end
  621. local function getUpdateFile(pathOffcial, pathCustom)
  622. local offcialCfg = require(pathOffcial)
  623. local customCfg = require(pathCustom)
  624. if offcialCfg and next(offcialCfg) and customCfg and next(customCfg) then
  625. for key, cfg in pairs(offcialCfg) do
  626. if not customCfg[key] then
  627. customCfg[key] = cfg
  628. end
  629. end
  630. end
  631. return customCfg
  632. end
  633. -- 对比 有无新增
  634. for i, name in pairs(fileList) do
  635. local newCfg = nil
  636. if not officalPath[name] and customPath[name] then -- 官方无 本地有 用本地
  637. -- do nothing
  638. end
  639. if officalPath[name] and not customPath[name] then -- 官方有 本地无 新增官方表
  640. newCfg = getAddFile(officalPath[name])
  641. end
  642. if officalPath[name] and customPath[name] then -- 官方有 本地有 对比 1.本地已有key不操作 2.本地无的key补全
  643. newCfg = getUpdateFile(officalPath[name], customPath[name])
  644. end
  645. if newCfg and next(newCfg) then
  646. local cfgName = string.gsub(name, ".lua", "")
  647. SL:SaveTableToConfig(newCfg, cfgName, nil, nil, true)
  648. global.FileUtilCtl:purgeCachedEntries()
  649. end
  650. end
  651. end
  652. -- 同步服务下发配置表
  653. function SL:UpdateServerConfig(file)
  654. local fileList = file and {file} or SLDefine.ConfigServerFile
  655. local GameConfigMgrProxy = global.Facade:retrieveProxy(global.ProxyTable.GameConfigMgrProxy)
  656. for i, name in pairs(fileList) do
  657. local clientCfg = {}
  658. local severCfg = GameConfigMgrProxy:getServerConfingByKey(name) or {}
  659. if not severCfg or next(severCfg) == nil then
  660. print("未找到服务配置"..name)
  661. end
  662. local configPath = "scripts/game_server_config/"
  663. local devPath = global.FileUtilCtl:getDefaultResourceRootPath() .. "dev/" .. configPath .. name .. ".lua"
  664. local isFile = global.FileUtilCtl:isFileExist(devPath)
  665. if isFile then
  666. clientCfg = require(devPath)
  667. end
  668. -- 对比 同步客户端修改的配置
  669. if severCfg and next(severCfg) then
  670. if clientCfg and next(clientCfg) then
  671. for key, cfg in pairs(clientCfg) do
  672. if severCfg[key] then
  673. local keys = {}
  674. keys = table.keys(cfg)
  675. for _, key2 in pairs(keys) do
  676. severCfg[key][key2] = cfg[key2] -- 服务删除字段:a.客户端有 补全, b.客户端没有不管。 服务新增字段:新增。服务修改字段:以客户端为准
  677. end
  678. else
  679. severCfg[key] = cfg -- 客户端新增key
  680. end
  681. end
  682. end
  683. local newCfg = {}
  684. newCfg = severCfg
  685. SL:SaveTableToConfig(newCfg, name)
  686. global.FileUtilCtl:purgeCachedEntries()
  687. end
  688. end
  689. end
  690. -- 十六进制转十进制
  691. function SL:HexToInt(hexStr)
  692. return tonumber(hexStr, 16)
  693. end
  694. function SL:GetStrMD5(str)
  695. return get_str_MD5(str)
  696. end
  697. function SL:GetPointDistanceSQ(pt1, pt2)
  698. return cc.pDistanceSQ(pt1, pt2)
  699. end
  700. function SL:GetPointDistance(pt1, pt2)
  701. return cc.pGetDistance(pt1, pt2)
  702. end
  703. function SL:GetPointLength(pt)
  704. return cc.pGetLength(pt)
  705. end
  706. function SL:GetPointLengthSQ(pt)
  707. return cc.pLengthSQ(pt)
  708. end
  709. function SL:GetMidPoint(pt1, pt2)
  710. return cc.pMidpoint(pt1, pt2)
  711. end
  712. function SL:GetAddPoint(pt1, pt2)
  713. return cc.pAdd(pt1, pt2)
  714. end
  715. function SL:GetSubPoint(pt1, pt2)
  716. return cc.pSub(pt1, pt2)
  717. end
  718. function SL:GetNormalizePoint(pt)
  719. return cc.pNormalize(pt)
  720. end
  721. function SL:GetPointAngle(pt1, pt2)
  722. return cc.pGetAngle(pt1, pt2)
  723. end
  724. function SL:GetPointRotate(pt1, pt2)
  725. local angle = cc.pGetAngle(pt1, pt2)
  726. return angle * 180 / math.pi
  727. end
  728. function SL:GetPointAngleSelf(pt)
  729. return cc.pToAngleSelf(pt)
  730. end
  731. function SL:GetPointRotateSelf(pt)
  732. local angle = cc.pToAngleSelf(pt)
  733. return angle * 180 / math.pi
  734. end
  735. ------------------------------游戏相关--------------------------------------
  736. -- 跳转到某个超链
  737. -- id: int param: 附加参数
  738. function SL:JumpTo(id, param)
  739. JUMPTO(id, param)
  740. end
  741. function SL:SubmitAct(data)
  742. local SUIComponentProxy = global.Facade:retrieveProxy(global.ProxyTable.SUIComponentProxy)
  743. SUIComponentProxy:SubmitAct(data)
  744. end
  745. -- 退出到选角界面
  746. function SL:ExitToRoleUI()
  747. local shiwan = global.L_GameEnvManager:GetEnvDataByKey("shiwan")
  748. if shiwan and tonumber(shiwan) == 1 then
  749. return
  750. end
  751. local data = {}
  752. data.str = GET_STRING(30003056)
  753. data.btnDesc = { GET_STRING(1001), GET_STRING(1000) }
  754. data.callback = function(bType)
  755. if bType == 1 then
  756. global.userInputController:RequestLeaveWorld()
  757. end
  758. end
  759. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  760. global.Facade:sendNotification(global.NoticeTable.Audio_Play, { type = global.MMO.SND_TYPE_LAYER_CLICK })
  761. end
  762. function SL:ForceExitToRoleUI()
  763. global.gameWorldController:OnGameLeaveWorld()
  764. end
  765. -- 退出到登录界面
  766. function SL:ExitToLoginUI(isJudgePC)
  767. global.L_NativeBridgeManager:GN_accountLogout()
  768. global.Facade:sendNotification(global.NoticeTable.RestartGame)
  769. if isJudgePC then
  770. local envProxy = global.Facade:retrieveProxy(global.ProxyTable.GameEnvironment)
  771. if envProxy:IsNeedExitGame() then
  772. global.Director:endToLua()
  773. end
  774. end
  775. end
  776. -- 退出游戏
  777. function SL:ExitGame()
  778. global.userInputController:RequestToOutGame()
  779. end
  780. -- 退出游戏
  781. function SL:ShutdownGame()
  782. global.Director:endToLua()
  783. end
  784. -- 发送GM命令到聊天
  785. function SL:SendGMMsgToChat(msg)
  786. local ChatProxy = global.Facade:retrieveProxy(global.ProxyTable.Chat)
  787. local MSG_TYPE = ChatProxy.MSG_TYPE
  788. local CHANNEL = ChatProxy.CHANNEL
  789. local input = string.format("@%s", msg)
  790. local sendData = { mt = MSG_TYPE.Normal, msg = input, channel = CHANNEL.Shout }
  791. global.Facade:sendNotification(global.NoticeTable.SendChatMsg, sendData)
  792. end
  793. -- 创建一个红点到节点
  794. function SL:CreateRedPoint(targetNode, offset)
  795. return CreateRedPoint(targetNode, offset)
  796. end
  797. function SL:GetMetaValue(key, ...)
  798. local metaValueProxy = global.Facade:retrieveProxy(global.ProxyTable.MetaValueProxy)
  799. return metaValueProxy:GetValueByKey(key, ...)
  800. end
  801. function SL:SetMetaValue(key, ...)
  802. local metaValueProxy = global.Facade:retrieveProxy(global.ProxyTable.MetaValueProxy)
  803. return metaValueProxy:SetValueByKey(key, ...)
  804. end
  805. function SL:PrintMetaKey()
  806. local metaValueProxy = global.Facade:retrieveProxy(global.ProxyTable.MetaValueProxy)
  807. metaValueProxy:PrintMetaKey()
  808. end
  809. function SL:PrintAllMetaValue()
  810. local metaValueProxy = global.Facade:retrieveProxy(global.ProxyTable.MetaValueProxy)
  811. metaValueProxy:PrintAllMetaValue()
  812. end
  813. -- 设置文本样式(按钮、文本)
  814. function SL:SetColorStyle(widget, colorID)
  815. SET_COLOR_STYLE(widget, colorID)
  816. end
  817. function SL:GetColorCfg(id)
  818. return GET_COLOR_CONFIG(id)
  819. end
  820. -- condition
  821. function SL:CheckCondition(conditionStr)
  822. local ConditionProxy = global.Facade:retrieveProxy(global.ProxyTable.ConditionProxy)
  823. return ConditionProxy:CheckCondition(conditionStr)
  824. end
  825. -- 显示气泡提醒
  826. function SL:AddBubbleTips(id, path, callback)
  827. global.Facade:sendNotification(global.NoticeTable.BubbleTipsStatusChange, { id = id, status = true, path = path, callback = callback })
  828. end
  829. -- 删除气泡提醒
  830. function SL:DelBubbleTips(id)
  831. global.Facade:sendNotification(global.NoticeTable.BubbleTipsStatusChange, { id = id, status = false })
  832. end
  833. function SL:ReloadMap()
  834. global.Facade:sendNotification(global.NoticeTable.ReloadMap)
  835. end
  836. function SL:HTTPRequestGet(url, callback)
  837. HTTPRequest(url, callback)
  838. end
  839. -- notForce: 不强行设置("Content-type", "application/x-www-form-urlencoded")
  840. function SL:HTTPRequestPost(url, callback, data, header, notForce)
  841. HTTPRequestPost(url, callback, data, header, notForce)
  842. end
  843. ------------------------------打开、关闭相关功能界面------------------------------------------------
  844. -- 打开设置界面
  845. function SL:OpenSettingUI(data)
  846. global.Facade:sendNotification(global.NoticeTable.Layer_SettingFrame_Open,data)
  847. end
  848. -- 关闭设置界面
  849. function SL:CloseSettingUI()
  850. global.Facade:sendNotification(global.NoticeTable.Layer_SettingFrame_Close)
  851. end
  852. -- 打开行会指定页签界面
  853. function SL:OpenGuildMainUI(page)
  854. global.Facade:sendNotification(global.NoticeTable.Layer_GuildFrame_Open, page)
  855. end
  856. -- 关闭行会界面
  857. function SL:CloseGuildMainUI()
  858. global.Facade:sendNotification(global.NoticeTable.Layer_GuildFrame_Close)
  859. end
  860. -- 打开行会申请界面
  861. function SL:OpenGuildApplyListUI()
  862. global.Facade:sendNotification(global.NoticeTable.Layer_Guild_ApplyList_Open)
  863. end
  864. -- 关闭行会申请界面
  865. function SL:CloseGuildApplyListUI()
  866. global.Facade:sendNotification(global.NoticeTable.Layer_Guild_ApplyList_Close)
  867. end
  868. -- 打开行会创建界面
  869. function SL:OpenGuildCreateUI()
  870. global.Facade:sendNotification(global.NoticeTable.Layer_Guild_Create_Open)
  871. end
  872. -- 关闭行会创建界面
  873. function SL:CloseGuildCreateUI()
  874. global.Facade:sendNotification(global.NoticeTable.Layer_Guild_Create_Close)
  875. end
  876. -- 打开行会结盟申请界面
  877. function SL:OpenGuildAllyApplyUI()
  878. global.Facade:sendNotification(global.NoticeTable.Layer_Guild_Ally_Apply_Open)
  879. end
  880. -- 关闭行会结盟申请界面
  881. function SL:CloseGuildAllyApplyUI()
  882. global.Facade:sendNotification(global.NoticeTable.Layer_Guild_Ally_Apply_Close)
  883. end
  884. -- 关闭行会宣战/结盟界面
  885. function SL:CloseGuildWarSponsorUI()
  886. global.Facade:sendNotification(global.NoticeTable.Layer_Guild_WarSponsor_Close)
  887. end
  888. -- 打开 试玩/确定收货 自定义属性面板
  889. function SL:OpenCustomAttUI()
  890. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBankPlayerCustomAtt_Open)
  891. end
  892. -- 关闭 试玩/确定收货 自定义属性面板
  893. function SL:CloseCustomAttUI()
  894. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBankPlayerCustomAtt_Close)
  895. end
  896. --[[
  897. data = {
  898. pos = {x = 0, y = 0}, bag_page = 1
  899. }
  900. ]]
  901. function SL:OpenBagUI(data)
  902. global.Facade:sendNotification(global.NoticeTable.Layer_Bag_Open, data)
  903. end
  904. function SL:CloseBagUI()
  905. global.Facade:sendNotification(global.NoticeTable.Layer_Bag_Close)
  906. end
  907. function SL:OpenHeroBagUI(data)
  908. global.Facade:sendNotification(global.NoticeTable.Layer_HeroBag_Open, data)
  909. end
  910. function SL:CloseHeroBagUI()
  911. global.Facade:sendNotification(global.NoticeTable.Layer_HeroBag_Close)
  912. end
  913. -- 打开拍卖行
  914. function SL:OpenAuctionUI()
  915. local mediator = global.Facade:retrieveMediator("TradingBankFrameMediator")--拍卖行和交易行不能同时使用
  916. if mediator._layer then
  917. ShowSystemTips(GET_STRING(600000702))
  918. return
  919. end
  920. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionMain_Open)
  921. end
  922. function SL:CloseAuctionUI()
  923. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionMain_Close)
  924. end
  925. -- 打开摆摊界面
  926. function SL:OpenStallLayerUI(data)
  927. local mediator = global.Facade:retrieveMediator("TradingBankFrameMediator")--摆摊和交易行不能同时使用
  928. if mediator._layer then
  929. ShowSystemTips(GET_STRING(600000701))
  930. return
  931. end
  932. local TradeProxy = global.Facade:retrieveProxy(global.ProxyTable.TradeProxy)
  933. if TradeProxy:IsTrading() then
  934. TradeProxy:RequestCancle()
  935. end
  936. global.Facade:sendNotification(global.NoticeTable.Layer_StallLayer_Open, data)
  937. end
  938. function SL:CloseStallLayerUI()
  939. local StallProxy = global.Facade:retrieveProxy(global.ProxyTable.StallProxy)
  940. if not StallProxy:GetMyTradingStatus() then
  941. StallProxy:CleanMySellData()
  942. end
  943. global.Facade:sendNotification(global.NoticeTable.Layer_StallLayer_Close)
  944. end
  945. -- 打开玩家交易界面
  946. function SL:OpenTradeUI()
  947. local TradeProxy = global.Facade:retrieveProxy(global.ProxyTable.TradeProxy)
  948. local targetId = SL:GetMetaValue("TARGET_ID")
  949. local targetName = SL:GetMetaValue("TARGET_NAME")
  950. TradeProxy:SendTradeRequest(targetId, targetName)
  951. end
  952. function SL:CloseTradeUI()
  953. global.Facade:sendNotification(global.NoticeTable.Layer_Trade_Close)
  954. end
  955. -- 打开排行榜
  956. function SL:OpenRankUI(type)
  957. global.Facade:sendNotification(global.NoticeTable.Layer_Rank_Open, type)
  958. end
  959. function SL:CloseRankUI()
  960. global.Facade:sendNotification(global.NoticeTable.Layer_Rank_Close)
  961. end
  962. -- 打开聊天
  963. function SL:OpenChatUI()
  964. global.Facade:sendNotification(global.NoticeTable.Layer_Chat_Open)
  965. end
  966. function SL:CloseChatUI()
  967. global.Facade:sendNotification(global.NoticeTable.Layer_Chat_Close)
  968. end
  969. -- 聊天拓展
  970. function SL:OpenChatExtendUI(index)
  971. global.Facade:sendNotification(global.NoticeTable.Layer_ChatExtend_Open, {group = index})
  972. end
  973. function SL:CloseChatExtendUI()
  974. global.Facade:sendNotification(global.NoticeTable.Layer_ChatExtend_Close)
  975. end
  976. --社区帖子
  977. function SL:OpenCommunityUI()
  978. global.Facade:sendNotification(global.NoticeTable.Layer_CommunityLayer_Open)
  979. end
  980. function SL:CloseCommunityUI()
  981. global.Facade:sendNotification(global.NoticeTable.Layer_CommunityLayer_Close)
  982. end
  983. -- 打开交易行
  984. function SL:OpenTradingBankUI(page)
  985. --寄售key打开情况下不能开启交易行
  986. local OtherTradingBankProxy = global.Facade:retrieveProxy(global.ProxyTable.OtherTradingBankProxy)
  987. if OtherTradingBankProxy:getPublishOpen() == 1 then
  988. return
  989. end
  990. --mac平台不能打开交易行
  991. if global.L_GameEnvManager:GetEnvDataByKey("platform") == "mac" then
  992. ShowSystemTips(GET_STRING(700000145))
  993. return
  994. end
  995. --试玩不能打开交易行
  996. local shiwan = global.L_GameEnvManager:GetEnvDataByKey("shiwan")
  997. if shiwan and tonumber(shiwan) == 1 then
  998. return
  999. end
  1000. if global.OtherTradingBank then -- 三方 交易行
  1001. local OtherTradingBankProxy = global.Facade:retrieveProxy(global.ProxyTable.OtherTradingBankProxy)
  1002. OtherTradingBankProxy:getTradingBankStatus({}, function(code, data, msg)
  1003. local isOpen = false
  1004. if code == 200 then
  1005. if data and data.openExchange == 1 then
  1006. isOpen = true
  1007. else
  1008. ShowSystemTips(GET_STRING(600000179))
  1009. end
  1010. else
  1011. ShowSystemTips(msg or GET_STRING(600000660))
  1012. end
  1013. if isOpen then
  1014. local gameToken = OtherTradingBankProxy:getGameToken()
  1015. if not gameToken or gameToken == "" or gameToken == "noToken" then
  1016. ShowSystemTips(GET_STRING(600000631))
  1017. return
  1018. end
  1019. if global.OtherTradingBankH5 then
  1020. OtherTradingBankProxy:showTradingView()
  1021. else
  1022. --是否登录
  1023. if OtherTradingBankProxy:getToken() == "" then
  1024. OtherTradingBankProxy:Login1_2(function(code, msg)
  1025. if code == 200 then
  1026. if OtherTradingBankProxy:getToken() ~= "" then
  1027. SL:OpenTradingBankUI(page)
  1028. end
  1029. else
  1030. ShowSystemTips(msg or "")
  1031. end
  1032. end)
  1033. return
  1034. end
  1035. OtherTradingBankProxy:doTrack(OtherTradingBankProxy.UpLoadData.TraingIconBtnClick)--没有请求成功没有appid 和 secret 上报不成功
  1036. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBankFrame_Open_other, {id = page} )
  1037. end
  1038. end
  1039. if OtherTradingBankProxy then
  1040. OtherTradingBankProxy:setOpenStatus(isOpen)
  1041. end
  1042. end, true)
  1043. else
  1044. local Box996Proxy = global.Facade:retrieveProxy( global.ProxyTable.Box996Proxy )
  1045. Box996Proxy:requestLogUp(Box996Proxy.OTHER_UP_EVEIT[1])
  1046. local TradingBankProxy = global.Facade:retrieveProxy(global.ProxyTable.TradingBankProxy)
  1047. TradingBankProxy:readToken()--打开交易行时读取当前账号token
  1048. TradingBankProxy:doTrack(TradingBankProxy.UpLoadData.TraingIconBtnClick, {first_entry_time = ""})
  1049. local mainPlayerID = SL:GetMetaValue("MAIN_ACTOR_ID")
  1050. if mainPlayerID then
  1051. if SL:GetMetaValue("ACTOR_IS_IN_STALL",mainPlayerID) then --摆摊状态不能打开
  1052. ShowSystemTips(GET_STRING(600000700))
  1053. return
  1054. end
  1055. end
  1056. local mediator = global.Facade:retrieveMediator("StallLayerMediator")--摆摊和交易行不能同时使用
  1057. if mediator._layer then
  1058. ShowSystemTips(GET_STRING(600000701))
  1059. return
  1060. end
  1061. local mediator = global.Facade:retrieveMediator("AuctionMainMediator")--拍卖行和交易行不能同时使用
  1062. if mediator._layer then
  1063. ShowSystemTips(GET_STRING(600000702))
  1064. return
  1065. end
  1066. TradingBankProxy:getTradingBankStatus({},function(success, response, code)
  1067. local isOpen = false
  1068. if success then
  1069. local data = cjson.decode(response)
  1070. if data and data.code == 200 and data.data and data.data.status == 0 then
  1071. isOpen = true
  1072. end
  1073. end
  1074. if isOpen then
  1075. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBankFrame_Open, {id = page})
  1076. TradingBankProxy:SetBeginTime(os.time()) --访问开始时间
  1077. else
  1078. ShowSystemTips(GET_STRING(600000179))
  1079. end
  1080. if TradingBankProxy then
  1081. TradingBankProxy:setOpenStatus(isOpen)
  1082. end
  1083. end)
  1084. end
  1085. end
  1086. -- 关闭交易行
  1087. function SL:CloseTradingBankUI()
  1088. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBankFrame_Close)
  1089. end
  1090. -- 打开商城
  1091. function SL:OpenStoreUI(page)
  1092. local shiwan = global.L_GameEnvManager:GetEnvDataByKey("shiwan")
  1093. if shiwan and tonumber(shiwan) == 1 then
  1094. return
  1095. end
  1096. global.Facade:sendNotification(global.NoticeTable.Layer_StoreFrame_Open, page)
  1097. end
  1098. function SL:CloseStoreUI()
  1099. global.Facade:sendNotification(global.NoticeTable.Layer_StoreFrame_Close)
  1100. end
  1101. function SL:OpenStoreDetailUI(storeIndex, limitStr)
  1102. if not storeIndex then
  1103. return
  1104. end
  1105. local PageStoreProxy = global.Facade:retrieveProxy(global.ProxyTable.PageStoreProxy)
  1106. local storeData = PageStoreProxy:GetItemDataByStoreIndex(storeIndex)
  1107. if not storeData or next(storeData) == nil then
  1108. return
  1109. end
  1110. local canBy = PageStoreProxy:CheckStoreLimitStatus(storeIndex)
  1111. if not canBy then
  1112. if limitStr and string.len(limitStr) > 0 then
  1113. ShowSystemTips(limitStr)
  1114. end
  1115. return
  1116. end
  1117. local buyData = {
  1118. data = storeData,
  1119. }
  1120. global.Facade:sendNotification(global.NoticeTable.Layer_StoreBuy_Open, buyData)
  1121. end
  1122. function SL:CloseStoreDetailUI()
  1123. global.Facade:sendNotification(global.NoticeTable.Layer_StoreBuy_Close)
  1124. end
  1125. -- 技能配置界面
  1126. function SL:OpenSkillSettingUI(data)
  1127. global.Facade:sendNotification(global.NoticeTable.Layer_SkillSetting_Open, data)
  1128. end
  1129. function SL:CloseSkillSettingUI()
  1130. global.Facade:sendNotification(global.NoticeTable.Layer_SkillSetting_Close)
  1131. end
  1132. -- 社交(1附近玩家、2组队、3好友、4邮件)
  1133. function SL:OpenSocialUI(page)
  1134. global.Facade:sendNotification(global.NoticeTable.Layer_Social_Open, page)
  1135. end
  1136. function SL:CloseSocialUI()
  1137. global.Facade:sendNotification(global.NoticeTable.Layer_Social_Close)
  1138. end
  1139. -- 打开 PC 分辨率修改界面
  1140. function SL:OpenResolutionSetUI()
  1141. global.Facade:sendNotification(global.NoticeTable.Layer_setResolutionSize_Open)
  1142. end
  1143. function SL:CloseResolutionSetUI()
  1144. global.Facade:sendNotification(global.NoticeTable.Layer_setResolutionSize_Close)
  1145. end
  1146. -- 打开菊花转
  1147. function SL:ShowLoadingBar(time)
  1148. ShowLoadingBar(time)
  1149. end
  1150. -- 关闭菊花转
  1151. function SL:HideLoadingBar()
  1152. HideLoadingBar()
  1153. end
  1154. -- 摇骰子界面
  1155. --[[
  1156. {
  1157. arr = table 投掷值 {xx, xx}
  1158. count = 数量
  1159. callback = @xxx 脚本触发
  1160. }
  1161. ]]
  1162. function SL:OpenPlayDice(data)
  1163. global.Facade:sendNotification(global.NoticeTable.Layer_PlayDice_Open, data)
  1164. end
  1165. function SL:ClosePlayDice()
  1166. global.Facade:sendNotification(global.NoticeTable.Layer_PlayDice_Close)
  1167. end
  1168. --------------------------------------------------------------------------------------------------------------
  1169. ---
  1170. --[[
  1171. data
  1172. {
  1173. extent = 子页id
  1174. isFast 是否pc快捷键打开
  1175. type = 类型 1基础 2内功
  1176. }
  1177. ]]
  1178. -- 打开个人人物界面
  1179. function SL:OpenMyPlayerUI(data)
  1180. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Open, data)
  1181. end
  1182. function SL:CloseMyPlayerUI()
  1183. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Close)
  1184. end
  1185. --关闭人物 子页签
  1186. function SL:CloseMyPlayerPageUI(data)
  1187. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Child_Del,data)
  1188. end
  1189. -- 打开个人英雄界面
  1190. function SL:OpenMyPlayerHeroUI(page)
  1191. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Open_Hero, page)
  1192. end
  1193. function SL:CloseMyPlayerHeroUI()
  1194. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Close_Hero)
  1195. end
  1196. --关闭英雄 子页签
  1197. function SL:CloseMyPlayerHeroPageUI(data)
  1198. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Child_Del_Hero,data)
  1199. end
  1200. -- 打开他人人物界面
  1201. function SL:OpenOtherPlayerUI(page)
  1202. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Open, page)
  1203. end
  1204. function SL:CloseOtherPlayerUI()
  1205. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Close)
  1206. end
  1207. --关闭他人 子页签
  1208. function SL:CloseOtherPlayerPageUI(data)
  1209. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Child_Del,data)
  1210. end
  1211. -- 打开他人英雄界面
  1212. function SL:OpenOtherPlayerHeroUI(page)
  1213. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Open_Hero, page)
  1214. end
  1215. function SL:CloseOtherPlayerHeroUI()
  1216. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Close_Hero)
  1217. end
  1218. --关闭他人英雄 子页签
  1219. function SL:CloseOtherPlayerHeroPageUI(data)
  1220. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Child_Del_Hero,data)
  1221. end
  1222. --关闭他人人物 子页签
  1223. function SL:CloseTradingBankPlayerPageUI(data)
  1224. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Player_Child_Del,data)
  1225. end
  1226. --关闭他人英雄 子页签
  1227. function SL:CloseTradingBankHeroPageUI(data)
  1228. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Player_Child_Del_Hero,data)
  1229. end
  1230. -------
  1231. ---
  1232. -- 打开玩家首饰盒
  1233. -- param: 1: 自己人物、2:自己英雄、11:其他玩家人物、12:其他玩家英雄、21:交易行人物、22:交易行英雄
  1234. function SL:OpenBestRingBoxUI(param, data)
  1235. if param == 1 then
  1236. global.Facade:sendNotification(global.NoticeTable.Layer_PlayerBestRing_Open, data)
  1237. elseif param == 2 then
  1238. global.Facade:sendNotification(global.NoticeTable.Layer_PlayerBestRing_Open_Hero, data)
  1239. elseif param == 11 then
  1240. global.Facade:sendNotification(global.NoticeTable.Layer_Look_PlayerBestRing_Open, data)
  1241. elseif param == 12 then
  1242. global.Facade:sendNotification(global.NoticeTable.Layer_Look_PlayerBestRing_Open_Hero, data)
  1243. elseif param == 21 then
  1244. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_PlayerBestRing_Open, data)
  1245. elseif param == 22 then
  1246. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_PlayerBestRing_Open_Hero, data)
  1247. end
  1248. end
  1249. -- 同上
  1250. function SL:CloseBestRingBoxUI(param)
  1251. if param == 1 then
  1252. global.Facade:sendNotification(global.NoticeTable.Layer_PlayerBestRing_Close)
  1253. elseif param == 2 then
  1254. global.Facade:sendNotification(global.NoticeTable.Layer_PlayerBestRing_Close_Hero)
  1255. elseif param == 11 then
  1256. global.Facade:sendNotification(global.NoticeTable.Layer_Look_PlayerBestRing_Close)
  1257. elseif param == 12 then
  1258. global.Facade:sendNotification(global.NoticeTable.Layer_Look_PlayerBestRing_Close_Hero)
  1259. elseif param == 21 then
  1260. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_PlayerBestRing_Close)
  1261. elseif param == 22 then
  1262. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_PlayerBestRing_Close_Hero)
  1263. end
  1264. end
  1265. ---打开人物装备面板
  1266. -- param: 1: 自己人物、2:自己英雄、11:其他玩家人物、12:其他玩家英雄、21:交易行人物、22:交易行英雄
  1267. function SL:OpenPlayerEquipUI(param, data)
  1268. if param == 1 then
  1269. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Equip_Open, data)
  1270. elseif param == 2 then
  1271. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Equip_Open_Hero, data)
  1272. elseif param == 11 then
  1273. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Equip_Open, data)
  1274. elseif param == 12 then
  1275. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Equip_Open_Hero, data)
  1276. elseif param == 21 then
  1277. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Player_Equip_Open, data)
  1278. elseif param == 22 then
  1279. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Player_Equip_Open_Hero, data)
  1280. end
  1281. end
  1282. ---打开人物状态面板
  1283. -- param: 1: 自己人物、2:自己英雄、11:其他玩家人物、12:其他玩家英雄、21:交易行人物、22:交易行英雄
  1284. function SL:OpenPlayerBaseAttrUI(param, data)
  1285. if param == 1 then
  1286. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Base_Att_Open,data)
  1287. elseif param == 2 then
  1288. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Base_Att_Open_Hero, data)
  1289. elseif param == 11 then
  1290. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Base_Att_Open, data)
  1291. elseif param == 12 then
  1292. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Base_Att_Open_Hero, data)
  1293. elseif param == 21 then
  1294. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Player_Base_Att_Open, data)
  1295. elseif param == 22 then
  1296. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Player_Base_Att_Open_Hero, data)
  1297. end
  1298. end
  1299. ---打开人物属性面板
  1300. -- param: 1: 自己人物、2:自己英雄、11:其他玩家人物、12:其他玩家英雄、21:交易行人物、22:交易行英雄
  1301. function SL:OpenPlayerExtraAttrUI(param, data)
  1302. if param == 1 then
  1303. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Extra_Att_Open,data)
  1304. elseif param == 2 then
  1305. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Extra_Att_Open_Hero, data)
  1306. elseif param == 11 then
  1307. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Extra_Att_Open, data)
  1308. elseif param == 12 then
  1309. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Extra_Att_Open_Hero, data)
  1310. elseif param == 21 then
  1311. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Player_Extra_Att_Open, data)
  1312. elseif param == 22 then
  1313. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Player_Extra_Att_Open_Hero, data)
  1314. end
  1315. end
  1316. ---打开人物技能面板
  1317. -- param: 1: 自己人物、2:自己英雄、11:其他玩家人物、12:其他玩家英雄、21:交易行人物、22:交易行英雄
  1318. function SL:OpenPlayerSkillUI(param, data)
  1319. if param == 1 then
  1320. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Skill_Open,data)
  1321. elseif param == 2 then
  1322. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Skill_Open_Hero, data)
  1323. elseif param == 11 then
  1324. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Skill_Open, data)
  1325. elseif param == 12 then
  1326. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Skill_Open_Hero, data)
  1327. elseif param == 21 then
  1328. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Player_Skill_Open, data)
  1329. elseif param == 22 then
  1330. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Player_Skill_Open_Hero, data)
  1331. end
  1332. end
  1333. ---打开人物称号面板
  1334. -- param: 1: 自己人物、2:自己英雄、11:其他玩家人物、12:其他玩家英雄、21:交易行人物、22:交易行英雄
  1335. function SL:OpenPlayerTitleUI(param, data)
  1336. if param == 1 then
  1337. global.Facade:sendNotification(global.NoticeTable.Layer_Title_Attach, data)
  1338. elseif param == 2 then
  1339. global.Facade:sendNotification(global.NoticeTable.Layer_Title_Attach_Hero, data)
  1340. elseif param == 11 then
  1341. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Title_Attach, data)
  1342. elseif param == 12 then
  1343. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Title_Attach_Hero, data)
  1344. elseif param == 21 then
  1345. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Title_Attach, data)
  1346. elseif param == 22 then
  1347. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Title_Attach_Hero, data)
  1348. end
  1349. end
  1350. ---打开人物时装面板
  1351. -- param: 1: 自己人物、2:自己英雄、11:其他玩家人物、12:其他玩家英雄、21:交易行人物、22:交易行英雄
  1352. function SL:OpenPlayerSuperEquipUI(param, data)
  1353. if param == 1 then
  1354. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Super_Equip_Open, data)
  1355. elseif param == 2 then
  1356. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Super_Equip_Open_Hero, data)
  1357. elseif param == 11 then
  1358. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Super_Equip_Open, data)
  1359. elseif param == 12 then
  1360. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Super_Equip_Open_Hero, data)
  1361. elseif param == 21 then
  1362. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Player_Super_Equip_Open, data)
  1363. elseif param == 22 then
  1364. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBank_Look_Player_Super_Equip_Open_Hero, data)
  1365. end
  1366. end
  1367. -- 打开人物BUFF面板 1: 自己人物、2:自己英雄、11:其他玩家人物、12:其他玩家英雄
  1368. function SL:OpenPlayerBuffUI(param, data)
  1369. if param == 1 then
  1370. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Buff_Open, data)
  1371. elseif param == 2 then
  1372. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Buff_Open_Hero, data)
  1373. elseif param == 11 then
  1374. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Player_Buff_Open, data)
  1375. elseif param == 12 then
  1376. global.Facade:sendNotification(global.NoticeTable.Layer_Look_Buff_Attach_Hero, data)
  1377. end
  1378. end
  1379. -- 打开称号提示界面
  1380. function SL:OpenTitleTipsUI(data)
  1381. global.Facade:sendNotification(global.NoticeTable.Layer_TitleTips_Open, data)
  1382. end
  1383. -- 关闭称号提示界面
  1384. function SL:CloseTitleTipsUI()
  1385. global.Facade:sendNotification(global.NoticeTable.Layer_TitleTips_Close)
  1386. end
  1387. -- 打开查看他人称号提示界面
  1388. function SL:OpenOtherTitleTipsUI(data)
  1389. global.Facade:sendNotification(global.NoticeTable.Layer_Look_TitleTips_Open, data)
  1390. end
  1391. -- 关闭查看他人称号提示界面
  1392. function SL:CloseOtherTitleTipsUI()
  1393. global.Facade:sendNotification(global.NoticeTable.Layer_Look_TitleTips_Close)
  1394. end
  1395. -- 交易行查看他人容器
  1396. function SL:CloseTradingBankLookPanelUI()
  1397. if global.OtherTradingBank then
  1398. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBankPlayerPanel_Close_other)
  1399. else
  1400. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBankPlayerPanel_Close)
  1401. end
  1402. end
  1403. -- 交易行查看他人界面
  1404. function SL:CloseTradingBankLookInfoUI()
  1405. if global.OtherTradingBank then
  1406. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBankPlayerInfo_Close_other)
  1407. else
  1408. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBankPlayerInfo_Close)
  1409. end
  1410. end
  1411. -- 打开内功状态 1:人物 2:英雄
  1412. function SL:OpenInternalStateUI(param, data)
  1413. if param == 1 then
  1414. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Internal_State_Open, data)
  1415. elseif param == 2 then
  1416. global.Facade:sendNotification(global.NoticeTable.Layer_Hero_Internal_State_Open, data)
  1417. end
  1418. end
  1419. -- 打开内功技能 1:人物 2:英雄
  1420. function SL:OpenInternalSkillUI(param, data)
  1421. if param == 1 then
  1422. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Internal_Skill_Open, data)
  1423. elseif param == 2 then
  1424. global.Facade:sendNotification(global.NoticeTable.Layer_Hero_Internal_Skill_Open, data)
  1425. end
  1426. end
  1427. -- 打开内功经络 1:人物 2:英雄
  1428. function SL:OpenInternalMerdianUI(param, data)
  1429. if param == 1 then
  1430. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Internal_Meridian_Open, data)
  1431. elseif param == 2 then
  1432. global.Facade:sendNotification(global.NoticeTable.Layer_Hero_Internal_Meridian_Open, data)
  1433. end
  1434. end
  1435. -- 打开内功连击 1:人物 2:英雄
  1436. function SL:OpenInternalComboUI(param, data)
  1437. if param == 1 then
  1438. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Internal_Combo_Open, data)
  1439. elseif param == 2 then
  1440. global.Facade:sendNotification(global.NoticeTable.Layer_Hero_Internal_Combo_Open, data)
  1441. end
  1442. end
  1443. -- 关闭人物内功 子页签
  1444. function SL:CloseMyPlayerInternalPageUI(data)
  1445. global.Facade:sendNotification(global.NoticeTable.Layer_Player_Internal_Child_Del, data)
  1446. end
  1447. -- 关闭英雄内功 子页签
  1448. function SL:CloseMyHeroInternalPageUI(data)
  1449. global.Facade:sendNotification(global.NoticeTable.Layer_Hero_Internal_Child_Del, data)
  1450. end
  1451. --------------------------------------------------------------------------------------------------------------------------------
  1452. -- 打开邀请组队界面
  1453. function SL:OpenTeamInvite()
  1454. global.Facade:sendNotification(global.NoticeTable.Layer_TeamInvite_Open)
  1455. end
  1456. function SL:CloseTeamInvite()
  1457. global.Facade:sendNotification(global.NoticeTable.Layer_TeamInvite_Close)
  1458. end
  1459. -- 打开入队申请列表
  1460. function SL:OpenTeamApply()
  1461. global.Facade:sendNotification(global.NoticeTable.Layer_TeamApply_Open)
  1462. end
  1463. function SL:CloseTeamApply()
  1464. global.Facade:sendNotification(global.NoticeTable.Layer_TeamApply_Close)
  1465. end
  1466. -- 打开被邀请组队界面
  1467. function SL:OpenTeamBeInvite(data)
  1468. global.Facade:sendNotification(global.NoticeTable.Layer_Team_BeInvite_Open, data)
  1469. end
  1470. function SL:CloseTeamBeInvite()
  1471. global.Facade:sendNotification(global.NoticeTable.Layer_Team_BeInvite_Close)
  1472. end
  1473. -- 打开小地图
  1474. function SL:OpenMiniMap()
  1475. global.Facade:sendNotification(global.NoticeTable.Layer_MiniMap_Open)
  1476. end
  1477. function SL:CloseMiniMap()
  1478. global.Facade:sendNotification(global.NoticeTable.Layer_MiniMap_Close)
  1479. end
  1480. --
  1481. function SL:OpenGuideEnter(param)
  1482. global.Facade:sendNotification(global.NoticeTable.GuideEnterTransition, { name = "GUIDE_BEGIN_SKILL_BUTTON", extent = param })
  1483. end
  1484. function SL:CloseGuideEnter()
  1485. global.Facade:sendNotification(global.NoticeTable.GuideEnterTransition, { name = "GUIDE_BEGIN_SKILL_CHANGE_BUTTON" })
  1486. end
  1487. -- 转生点
  1488. function SL:OpenReinAttrUI()
  1489. global.Facade:sendNotification(global.NoticeTable.Layer_Rein_Attr_Open)
  1490. end
  1491. function SL:CloseReinAttrUI()
  1492. global.Facade:sendNotification(global.NoticeTable.Layer_Rein_Attr_Close)
  1493. end
  1494. -- 任务栏打开
  1495. function SL:OpenAssistUI()
  1496. global.Facade:sendNotification(global.NoticeTable.Layer_Assist_ChangeHide, true)
  1497. end
  1498. function SL:CloseAssistUI()
  1499. global.Facade:sendNotification(global.NoticeTable.Layer_Assist_ChangeHide, false)
  1500. end
  1501. -- 切换到任务面板
  1502. function SL:SwitchToMainMission()
  1503. global.Facade:sendNotification(global.NoticeTable.Layer_Assist_Switch_Mission)
  1504. end
  1505. -- 小地图伸缩
  1506. function SL:OpenMiniMapChangeUI()
  1507. global.Facade:sendNotification(global.NoticeTable.MainMiniMapChange, true)
  1508. end
  1509. function SL:CloseMiniMapChangeUI()
  1510. global.Facade:sendNotification(global.NoticeTable.MainMiniMapChange, false)
  1511. end
  1512. -- 附近展示页
  1513. function SL:OpenMainNearUI()
  1514. global.Facade:sendNotification(global.NoticeTable.Layer_MainNear_Open)
  1515. end
  1516. function SL:CloseMainNearUI()
  1517. global.Facade:sendNotification(global.NoticeTable.Layer_MainNear_Close)
  1518. end
  1519. -- 直接调用支付
  1520. function SL:OpenCallPayUI()
  1521. local NativeBridgeProxy = global.Facade:retrieveProxy(global.ProxyTable.NativeBridgeProxy)
  1522. if NativeBridgeProxy then
  1523. NativeBridgeProxy:GN_PC_CallOF()
  1524. end
  1525. end
  1526. -- 打开客服UI
  1527. function SL:OpenKefuUI()
  1528. if global.modBridgeController then
  1529. global.modBridgeController:GN_kefu()
  1530. end
  1531. end
  1532. -- 打开PC私聊
  1533. function SL:OpenPCPrivateUI()
  1534. global.Facade:sendNotification(global.NoticeTable.Layer_Private_Chat_Open)
  1535. end
  1536. function SL:ClosePCPrivateUI()
  1537. global.Facade:sendNotification(global.NoticeTable.Layer_Private_Chat_Close)
  1538. end
  1539. -- PC 小地图变换
  1540. function SL:OpenPCMiniMapUI()
  1541. global.Facade:sendNotification(global.NoticeTable.Layer_MainMiniMapWin32_Tab)
  1542. end
  1543. -- 打开添加好友界面
  1544. function SL:OpenAddFriendUI()
  1545. global.Facade:sendNotification(global.NoticeTable.Layer_AddFriend_Open)
  1546. end
  1547. function SL:CloseAddFriendUI()
  1548. global.Facade:sendNotification(global.NoticeTable.Layer_AddFriend_Close)
  1549. end
  1550. -- 打开添加黑名单界面
  1551. function SL:OpenAddBlackListUI()
  1552. global.Facade:sendNotification(global.NoticeTable.Layer_AddBlackList_Open)
  1553. end
  1554. function SL:CloseAddBlackListUI()
  1555. global.Facade:sendNotification(global.NoticeTable.Layer_AddBlackList_Close)
  1556. end
  1557. -- 打开好友添加申请界面
  1558. function SL:OpenFriendApplyUI()
  1559. global.Facade:sendNotification(global.NoticeTable.Layer_FriendApply_Open)
  1560. end
  1561. function SL:CloseFriendApplyUI()
  1562. SL:RequestClearFriendApplyList()
  1563. global.Facade:sendNotification(global.NoticeTable.Layer_FriendApply_Close)
  1564. end
  1565. -- 打开拍卖行世界拍卖/行会拍卖 source 0世界拍卖 1行会拍卖
  1566. function SL:OpenAuctionWorldUI(parent, source)
  1567. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionWorld_Open, { parent = parent, source = source })
  1568. end
  1569. function SL:CloseAuctionWorldUI()
  1570. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionWorld_Close)
  1571. end
  1572. -- 打开拍卖行我的竞拍
  1573. function SL:OpenAuctionBiddingUI(parent)
  1574. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionBidding_Open, { parent = parent })
  1575. end
  1576. function SL:CloseAuctionBiddingUI()
  1577. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionBidding_Close)
  1578. end
  1579. -- 打开拍卖行我的上架
  1580. function SL:OpenAuctionPutListUI(parent)
  1581. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionPutList_Open, { parent = parent })
  1582. end
  1583. function SL:CloseAuctionPutListUI()
  1584. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionPutList_Close)
  1585. end
  1586. -- 打开拍卖行上架界面
  1587. function SL:OpenAuctionPutinUI(itemData)
  1588. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionPutin_Open, itemData)
  1589. end
  1590. function SL:CloseAuctionPutinUI()
  1591. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionPutin_Close)
  1592. end
  1593. -- 打开拍卖行下架界面
  1594. function SL:OpenAuctionPutoutUI(itemData)
  1595. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionPutout_Open, itemData)
  1596. end
  1597. function SL:CloseAuctionPutoutUI()
  1598. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionPutout_Close)
  1599. end
  1600. -- 打开拍卖行竞拍界面
  1601. function SL:OpenAuctionBidUI(itemData)
  1602. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionBid_Open, itemData)
  1603. end
  1604. function SL:CloseAuctionBidUI()
  1605. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionBid_Close)
  1606. end
  1607. -- 打开拍卖行一口价界面
  1608. function SL:OpenAuctionBuyUI(itemData)
  1609. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionBuy_Open, itemData)
  1610. end
  1611. function SL:CloseAuctionBuyUI()
  1612. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionBuy_Close)
  1613. end
  1614. -- 打开拍卖行超时界面
  1615. function SL:OpenAuctionTimeoutUI(itemData)
  1616. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionTimeout_Open, itemData)
  1617. end
  1618. function SL:CloseAuctionTimeoutUI()
  1619. global.Facade:sendNotification(global.NoticeTable.Layer_AuctionTimeout_Close)
  1620. end
  1621. -- 打开合成界面
  1622. function SL:OpenCompoundItemsUI(data)
  1623. global.Facade:sendNotification(global.NoticeTable.Layer_CompoundItemLayer_Open, data)
  1624. end
  1625. function SL:CloseCompoundItemsUI()
  1626. global.Facade:sendNotification(global.NoticeTable.Layer_CompoundItemLayer_Close)
  1627. end
  1628. --打开 boss提醒 设置界面
  1629. function SL:OpenBossTipsUI()
  1630. global.Facade:sendNotification(global.NoticeTable.Layer_BossTipsLayer_Open)
  1631. end
  1632. --关闭 boss提醒 设置界面
  1633. function SL:CloseBossTipsUI()
  1634. global.Facade:sendNotification(global.NoticeTable.Layer_BossTipsLayer_Close)
  1635. end
  1636. --打开 拾取 设置界面
  1637. function SL:OpenPickSettingUI()
  1638. global.Facade:sendNotification(global.NoticeTable.Layer_pickSettingLayer_Open)
  1639. end
  1640. --关闭 拾取 设置界面
  1641. function SL:ClosePickSettingUI()
  1642. global.Facade:sendNotification(global.NoticeTable.Layer_pickSettingLayer_Close)
  1643. end
  1644. --打开 保护 设置界面
  1645. function SL:OpenProtectSettingUI(data)
  1646. global.Facade:sendNotification(global.NoticeTable.Layer_ProtectSettingLayer_Open, data)
  1647. end
  1648. --关闭 保护 设置界面
  1649. function SL:CloseProtectSettingUI()
  1650. global.Facade:sendNotification(global.NoticeTable.Layer_ProtectSettingLayer_Close)
  1651. end
  1652. --打开 增加名字 设置界面
  1653. function SL:OpenAddNameUI(data)
  1654. global.Facade:sendNotification(global.NoticeTable.Layer_addMonsterNameLayer_Open, data)
  1655. end
  1656. --关闭 增加名字 设置界面
  1657. function SL:CloseAddNameUI()
  1658. global.Facade:sendNotification(global.NoticeTable.Layer_addMonsterNameLayer_Close)
  1659. end
  1660. --打开 增加boss类型 设置界面
  1661. function SL:OpenAddBossTypeUI()
  1662. global.Facade:sendNotification(global.NoticeTable.Layer_addMonsterTypeLayer_Open)
  1663. end
  1664. --关闭 增加boss类型 设置界面
  1665. function SL:CloseAddBossTypeUI()
  1666. global.Facade:sendNotification(global.NoticeTable.Layer_addMonsterTypeLayer_Close)
  1667. end
  1668. --打开 技能排行 设置界面
  1669. function SL:OpenSkillRankPanelUI(data)
  1670. global.Facade:sendNotification(global.NoticeTable.Layer_SkillRankPanel_Open, data)
  1671. end
  1672. --关闭 技能排行 设置界面
  1673. function SL:CloseSkillRankPanelUI()
  1674. global.Facade:sendNotification(global.NoticeTable.Layer_SkillRankPanel_Close)
  1675. end
  1676. --打开 技能 设置界面
  1677. function SL:OpenSkillPanelUI()
  1678. global.Facade:sendNotification(global.NoticeTable.Layer_SkillPanel_Open)
  1679. end
  1680. --关闭 技能 设置界面
  1681. function SL:CloseSkillPanelUI()
  1682. global.Facade:sendNotification(global.NoticeTable.Layer_SkillPanel_Close)
  1683. end
  1684. --打开 选择下拉框
  1685. --[[ list = list --下拉要显示的内容
  1686. func --回调 选中的编号 0是关闭1~n
  1687. position --初始位置
  1688. cellwidth --item 宽
  1689. cellheight--item 高
  1690. ]]
  1691. function SL:OpenSelectListUI(list, position, cellwidth, cellheight, func, extraData)
  1692. local data = {}
  1693. data.values = list
  1694. data.position = position
  1695. data.cellwidth = cellwidth
  1696. data.cellheight = cellheight
  1697. data.func = func
  1698. if extraData then
  1699. for k, v in pairs(extraData) do
  1700. data[k] = v
  1701. end
  1702. end
  1703. global.Facade:sendNotification(global.NoticeTable.Layer_Common_SelectList_Open, data)
  1704. end
  1705. -- 关闭 选择下拉框
  1706. function SL:CloseSelectListUI()
  1707. global.Facade:sendNotification(global.NoticeTable.Layer_Common_SelectList_Close)
  1708. end
  1709. -- 打开996盒子界面 index: 1: 特权称号 2: 每日礼包 3: 超级礼包 4: 会员礼包 5: SVIP
  1710. function SL:OpenBox996UI(index)
  1711. local shiwan = global.L_GameEnvManager:GetEnvDataByKey("shiwan")
  1712. if shiwan and tonumber(shiwan) == 1 then
  1713. return
  1714. end
  1715. local Box996Proxy = global.Facade:retrieveProxy(global.ProxyTable.Box996Proxy)
  1716. Box996Proxy:requestLogUp(Box996Proxy.BOX_UP_BTN[0])
  1717. global.Facade:sendNotification(global.NoticeTable.Layer_Box996Main_Open, {index = index})
  1718. end
  1719. -- 关闭996盒子界面
  1720. function SL:CloseBox996UI()
  1721. global.Facade:sendNotification(global.NoticeTable.Layer_Box996Main_Close)
  1722. end
  1723. --hero相关
  1724. -- 打开英雄状态选择界面
  1725. function SL:OpenHeroStateSelectUI(data)
  1726. global.Facade:sendNotification(global.NoticeTable.Layer_Hero_StateSelect_Open, data)
  1727. end
  1728. -- 关闭英雄状态选择界面
  1729. function SL:CloseHeroStateSelectUI(data)
  1730. global.Facade:sendNotification(global.NoticeTable.Layer_Hero_StateSelect_Close, data)
  1731. end
  1732. -- 打开快捷使用框
  1733. --[[
  1734. itemData -- table 物品数据
  1735. equipPos -- int 穿戴位置
  1736. isBook -- boolean 是否是技能书
  1737. isHero -- boolean 是否为英雄
  1738. ]]
  1739. function SL:OpenAutoUseTip(itemData, equipPos, isBook, isHero)
  1740. global.Facade:sendNotification(global.NoticeTable.Layer_Auto_Use_Attach,
  1741. {
  1742. id = itemData.MakeIndex,
  1743. item = itemData,
  1744. targetPos = equipPos,
  1745. skillBook = isBook,
  1746. isHero = isHero
  1747. })
  1748. end
  1749. -- 关闭快捷使用框
  1750. function SL:CloseAutoUseTip(makeIndex, isHero)
  1751. if not makeIndex then
  1752. return
  1753. end
  1754. global.Facade:sendNotification(global.NoticeTable.Layer_Auto_Use_UnAttach, {id = makeIndex, isHero = isHero})
  1755. end
  1756. -- 好评有礼
  1757. function SL:ReviewGift()
  1758. local NativeBridgeProxy = global.Facade:retrieveProxy(global.ProxyTable.NativeBridgeProxy)
  1759. NativeBridgeProxy:GN_ReviewGift()
  1760. end
  1761. -- 开宝箱动画页 itemData: 宝箱物品数据
  1762. function SL:OpenTreasureBoxShow(itemData)
  1763. global.Facade:sendNotification(global.NoticeTable.Layer_Treasure_Box_Open, itemData)
  1764. end
  1765. function SL:CloseTreasureBoxShow()
  1766. global.Facade:sendNotification(global.NoticeTable.Layer_Treasure_Box_Close)
  1767. end
  1768. -- 开宝箱奖励 itemData: 宝箱物品数据
  1769. function SL:OpenGoldBoxUI(itemData)
  1770. global.Facade:sendNotification(global.NoticeTable.Layer_Gold_Box_Open, itemData)
  1771. end
  1772. function SL:CloseGoldBoxUI()
  1773. global.Facade:sendNotification(global.NoticeTable.Layer_Gold_Box_Close)
  1774. end
  1775. ------ 求购
  1776. function SL:OpenPurchaseUI()
  1777. global.Facade:sendNotification(global.NoticeTable.Layer_PurchaseMain_Open)
  1778. end
  1779. function SL:ClosePurchaseUI()
  1780. global.Facade:sendNotification(global.NoticeTable.Layer_PurchaseMain_Close)
  1781. local PurchaseProxy = global.Facade:retrieveProxy(global.ProxyTable.PurchaseProxy)
  1782. PurchaseProxy:NotifyClosePurchase()
  1783. end
  1784. -- 世界求购
  1785. function SL:OpenPurchaseWorldUI(parent)
  1786. global.Facade:sendNotification(global.NoticeTable.Layer_PurchaseWorld_Open, {parent = parent})
  1787. end
  1788. function SL:ClosePurchaseWorldUI()
  1789. global.Facade:sendNotification(global.NoticeTable.Layer_PurchaseWorld_Close)
  1790. end
  1791. -- 我的求购
  1792. function SL:OpenPurchaseMyUI(parent)
  1793. global.Facade:sendNotification(global.NoticeTable.Layer_PurchaseMy_Open, {parent = parent})
  1794. end
  1795. function SL:ClosePurchaseMyUI()
  1796. global.Facade:sendNotification(global.NoticeTable.Layer_PurchaseMy_Close)
  1797. end
  1798. -- 求购- 出售
  1799. function SL:OpenPurchaseSellUI(data)
  1800. global.Facade:sendNotification(global.NoticeTable.Layer_PurchaseSell_Open, data)
  1801. end
  1802. function SL:ClosePurchaseSellUI()
  1803. global.Facade:sendNotification(global.NoticeTable.Layer_PurchaseSell_Close)
  1804. end
  1805. -- 求购- 上架
  1806. function SL:OpenPurchasePutInUI(data)
  1807. global.Facade:sendNotification(global.NoticeTable.Layer_PurchasePutIn_Open, data)
  1808. end
  1809. function SL:ClosePurchasePutInUI()
  1810. global.Facade:sendNotification(global.NoticeTable.Layer_PurchasePutIn_Close)
  1811. end
  1812. -- 仓库 - 关闭
  1813. function SL:CloseStorageUI()
  1814. global.Facade:sendNotification(global.NoticeTable.Layer_NPC_Storage_Close)
  1815. end
  1816. ------------------------------打开、关闭相关功能界面------------------------------------------------
  1817. ---------------------------------------------------------------------------
  1818. -- 通用弹窗
  1819. -- 通用 Desc 弹窗
  1820. function SL:OpenCommonDescTipsPop(data)
  1821. global.Facade:sendNotification(global.NoticeTable.Layer_Common_Desc_Open, data)
  1822. end
  1823. function SL:CloseCommonDescTipsPop()
  1824. global.Facade:sendNotification(global.NoticeTable.Layer_Common_Desc_Close)
  1825. end
  1826. -- 通用弹窗
  1827. function SL:OpenCommonTipsPop(data)
  1828. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  1829. end
  1830. function SL:CloseCommonTipsPop()
  1831. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Close)
  1832. end
  1833. -- 道具装备tips
  1834. function SL:OpenItemTips(data)
  1835. global.Facade:sendNotification(global.NoticeTable.Layer_ItemTips_Open, data)
  1836. end
  1837. function SL:CloseItemTips()
  1838. global.Facade:sendNotification(global.NoticeTable.Layer_ItemTips_Close)
  1839. end
  1840. -- 道具拆分弹窗
  1841. function SL:OpenItemSplitPop(itemData)
  1842. local BagProxy = global.Facade:retrieveProxy(global.ProxyTable.Bag)
  1843. if not BagProxy:isToBeFull(true) then
  1844. local bagItemData = BagProxy:GetItemDataByMakeIndex(itemData.MakeIndex)
  1845. local data = {
  1846. itemData = bagItemData,
  1847. closeCB = function()
  1848. global.Facade:sendNotification(global.NoticeTable.Layer_ItemTips_Close)
  1849. end
  1850. }
  1851. global.Facade:sendNotification(global.NoticeTable.Layer_Split_Open, data)
  1852. end
  1853. end
  1854. function SL:CloseItemSplitPop()
  1855. global.Facade:sendNotification(global.NoticeTable.Layer_Split_Close)
  1856. end
  1857. -- FuncDock 通用界面
  1858. function SL:OpenFuncDockTips(data)
  1859. local FuncDockProxy = global.Facade:retrieveProxy(global.ProxyTable.FuncDockProxy)
  1860. if data.type == FuncDockProxy.FuncDockType.Func_Player_Head then
  1861. global.Facade:sendNotification(global.NoticeTable.Layer_Func_Dock_RequsetInfo, data)
  1862. else
  1863. global.Facade:sendNotification(global.NoticeTable.Layer_Func_Dock_Open, data)
  1864. end
  1865. end
  1866. function SL:CloseFuncDockTips()
  1867. global.Facade:sendNotification(global.NoticeTable.Layer_Func_Dock_Close)
  1868. end
  1869. -- 进度条
  1870. function SL:OpenProgressBarUI(data)
  1871. global.Facade:sendNotification(global.NoticeTable.Layer_ProgressBar_Open, data)
  1872. end
  1873. function SL:CloseProgressBarUI()
  1874. global.Facade:sendNotification(global.NoticeTable.Layer_ProgressBar_Close)
  1875. end
  1876. -- 多条选择项弹窗提示 [组队邀请/交易请求使用]
  1877. --[[
  1878. {
  1879. pos = 位置,
  1880. list = {
  1881. {str = 文本, agreeCall = 同意按钮回调, disAgreeCall = 拒绝回调},
  1882. ...
  1883. }
  1884. }
  1885. ]]
  1886. function SL:OpenCommonBubbleInfo(data)
  1887. global.Facade:sendNotification(global.NoticeTable.Layer_CommonBubbleInfo_Open, data)
  1888. end
  1889. function SL:CloseCommonBubbleInfo()
  1890. global.Facade:sendNotification(global.NoticeTable.Layer_CommonBubbleInfo_Close)
  1891. end
  1892. -- 打开网址/链接
  1893. function SL:OpenURL(url)
  1894. if not url or string.len(url) == 0 then
  1895. return
  1896. end
  1897. cc.Application:getInstance():openURL(url)
  1898. end
  1899. -- 通用弹窗
  1900. ---------------------------------------------------------------------------
  1901. ---------------------------------------------------------------------------
  1902. -- 引导
  1903. -- 打开引导
  1904. function SL:StartGuide(data)
  1905. local guide = requireGuide("SGuideTask").new(data)
  1906. guide:Start()
  1907. return guide
  1908. end
  1909. -- 关闭引导
  1910. function SL:CloseGuide(guide)
  1911. guide:Destory()
  1912. end
  1913. -- 引导
  1914. -- 战斗相关
  1915. ---------------------------------------------------------------------------
  1916. -- 取消目标actor
  1917. function SL:ClearTarget()
  1918. deprecatedTip("SL:ClearTarget", "SL:SetMetaValue(\"SELECT_TARGET_ID\", nil)")
  1919. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  1920. inputProxy:ClearTarget()
  1921. end
  1922. --获取视野内的玩家
  1923. function SL:FindPlayerInCurrViewField(noMainPlayer)
  1924. deprecatedTip("SL:FindPlayerInCurrViewField", "SL:GetMetaValue(\"FIND_IN_VIEW_PLAYER_LIST\")")
  1925. return global.playerManager:FindPlayerInCurrViewField(noMainPlayer)
  1926. end
  1927. --获取视野内的怪物
  1928. function SL:FindMonsterInCurrViewField(noPetOfMainPlayer, noPetOfNetPlayer)
  1929. deprecatedTip("SL:FindMonsterInCurrViewField", "SL:GetMetaValue(\"FIND_IN_VIEW_MONSTER_LIST\")")
  1930. return global.monsterManager:FindMonsterInCurrViewField(noPetOfMainPlayer, noPetOfNetPlayer)
  1931. end
  1932. --检测是否可以攻击
  1933. function SL:checkLaunchTargetByID(targetID)
  1934. deprecatedTip("SL:checkLaunchTargetByID", "SL:GetMetaValue(\"TARGET_ATTACK_ENABLE\", param)")
  1935. return proxyUtils.checkLaunchTargetByID(targetID)
  1936. end
  1937. -- 快速选择目标
  1938. function SL:QuickSelectTarget(data)
  1939. global.Facade:sendNotification(global.NoticeTable.QuickSelectTarget, data)
  1940. end
  1941. -- 战斗相关
  1942. ---------------------------------------------------------------------------
  1943. ---------------------------------------------------------------------------
  1944. -- 本地存储
  1945. -- 存储字符到本地
  1946. function SL:SetLocalString(key, value)
  1947. SL.LocalStringCache[key] = value
  1948. if SL.LocalStringTimerID then
  1949. SL:UnSchedule(SL.LocalStringTimerID)
  1950. SL.LocalStringTimerID = nil
  1951. end
  1952. SL.LocalStringTimerID = SL:ScheduleOnce(function()
  1953. SL.LocalStringTimerID = nil
  1954. local LoginProxy = global.Facade:retrieveProxy(global.ProxyTable.Login)
  1955. local playerID = LoginProxy:GetSelectedRoleID()
  1956. local userData = UserData:new("GUIStorage" .. playerID)
  1957. for k, v in pairs(SL.LocalStringCache) do
  1958. userData:setStringForKey(k, v)
  1959. end
  1960. userData:writeMapDataToFile()
  1961. end, 0.5)
  1962. end
  1963. -- 从本地读取字符
  1964. function SL:GetLocalString(key)
  1965. local LoginProxy = global.Facade:retrieveProxy(global.ProxyTable.Login)
  1966. local playerID = LoginProxy:GetSelectedRoleID()
  1967. local userData = UserData:new("GUIStorage" .. playerID)
  1968. return userData:getStringForKey(key, "")
  1969. end
  1970. -- 本地存储
  1971. ---------------------------------------------------------------------------
  1972. ---------------------------------------------------------------------------
  1973. -- ITEM ITEMTIPS
  1974. -- 检测人物是否可穿戴
  1975. function SL:CheckItemUseNeed_Hero(itemData)
  1976. local canUse, conditionStr, notCheckUse = CheckItemUseNeed_Hero(itemData)
  1977. return {
  1978. canUse = canUse, conditionStr = conditionStr, notCheckUse = notCheckUse
  1979. }
  1980. end
  1981. function SL:CheckItemUseNeed(itemData)
  1982. local canUse, conditionStr, notCheckUse = CheckItemUseNeed(itemData)
  1983. return {
  1984. canUse = canUse, conditionStr = conditionStr, notCheckUse = notCheckUse
  1985. }
  1986. end
  1987. function SL:GetDiffEquip(itemData, isHero)
  1988. return GUIFunction:GetDiffEquip(itemData, isHero)
  1989. end
  1990. -- 对比传入装备和自身穿戴装备
  1991. function SL:CheckEquipPowerThanSelf(itemInfo, from)
  1992. return CheckEquipPowerThanSelf(itemInfo, from)
  1993. end
  1994. ---------------------------------------------------------------------------
  1995. -- menulayer
  1996. function SL:CheckMenuLayerConditionByID(layerid)
  1997. local JumpLayerProxy = global.Facade:retrieveProxy(global.ProxyTable.JumpLayerProxy)
  1998. local config = JumpLayerProxy:GetConfigByID(layerid)
  1999. if not config then
  2000. return true
  2001. end
  2002. return SL:CheckCondition(config.condition)
  2003. end
  2004. -- open menulayer
  2005. function SL:OpenMenuLayerByID(id, parent, extent)
  2006. local JumpLayerProxy = global.Facade:retrieveProxy(global.ProxyTable.JumpLayerProxy)
  2007. return JumpLayerProxy:OpenPanelById(id, parent, extent)
  2008. end
  2009. -- close menulayer
  2010. function SL:CloseMenuLayerByID(id)
  2011. local JumpLayerProxy = global.Facade:retrieveProxy(global.ProxyTable.JumpLayerProxy)
  2012. return JumpLayerProxy:ClosePanelById(id)
  2013. end
  2014. -- 注册控件事件
  2015. function SL:RegisterWndEvent(widget, desc, msgtype, callback)
  2016. SLHandlerEvent:RegisterWndEvent(widget, desc, msgtype, callback)
  2017. end
  2018. -- 取消控件事件
  2019. function SL:UnRegisterWndEvent(widget, desc, msgtype)
  2020. SLHandlerEvent:UnRegisterWndEvent(widget, desc, msgtype)
  2021. end
  2022. -- 添加窗体控件自定义属性
  2023. function SL:AddWndProperty(widget, desc, key, value)
  2024. SLHandlerEvent:AddWndProperty(widget, desc, key, value)
  2025. end
  2026. -- 删除窗体控件自定义属性
  2027. function SL:DelWndProperty(widget, desc, key)
  2028. SLHandlerEvent:DelWndProperty(widget, desc, key)
  2029. end
  2030. -- 获取窗体控件自定义属性
  2031. function SL:GetWndProperty(widget, desc, key)
  2032. return SLHandlerEvent:GetWndProperty(widget, desc, key)
  2033. end
  2034. -- 通过色值id获取Color3B
  2035. function SL:GetColorByStyleId(id)
  2036. return GET_COLOR_BYID_C3B(id)
  2037. end
  2038. -- 通过色值id获取hex
  2039. function SL:GetHexColorByStyleId(id)
  2040. return GET_COLOR_BYID(id)
  2041. end
  2042. -- 通过色值id获取字号
  2043. function SL:GetSizeByStyleId(id)
  2044. return GET_SIZE_BYID(id)
  2045. end
  2046. -- 通过Color3B获取hex
  2047. function SL:GetColorHexFromRGB( rgb )
  2048. return GetColorHexFromRBG(rgb)
  2049. end
  2050. -- 播放按钮点击音效
  2051. function SL:PlayBtnClickAudio()
  2052. global.Facade:sendNotification(global.NoticeTable.Audio_Play, { type = global.MMO.SND_TYPE_BTN_CLICK })
  2053. end
  2054. -- 播放登陆-选角音效
  2055. function SL:PlaySelectRoleAudio()
  2056. global.Facade:sendNotification(global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_LOGIN_SELECTONE})
  2057. end
  2058. -- 播放开宝箱音效
  2059. function SL:PlayOpenBoxAudio()
  2060. global.Facade:sendNotification(global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_OPEN_BOX})
  2061. end
  2062. -- 播放宝箱内选中音效
  2063. function SL:PlayFlashBoxAudio()
  2064. global.Facade:sendNotification(global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_FLASH_BOX})
  2065. end
  2066. -- 播放音效
  2067. function SL:PlaySound(id, isLoop)
  2068. global.Facade:sendNotification(global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_SSR_UI, index = id, isLoop = isLoop})
  2069. end
  2070. -- 停止音效
  2071. function SL:StopSound(id)
  2072. global.Facade:sendNotification(global.NoticeTable.Audio_Stop_EffectId, id)
  2073. end
  2074. -- 停止所有音效
  2075. function SL:StopAllAudio()
  2076. global.Facade:sendNotification(global.NoticeTable.Audio_Stop_All)
  2077. end
  2078. -- 下载小地图
  2079. function SL:DownloadMiniMapRes(mapId, callback)
  2080. local miniMapPath = string.format("scene/uiminimap/%06d.png", tonumber(mapId) - 1)
  2081. global.ResDownloader:download(miniMapPath, function(isOK)
  2082. callback(isOK, miniMapPath)
  2083. end)
  2084. end
  2085. -- 删除GM缓存资源
  2086. function SL:RemoveGMResFile(filePath)
  2087. local module = global.L_ModuleManager:GetCurrentModule()
  2088. local modulePath = module:GetSubModPath()
  2089. local gmCachePath = cc.FileUtils:getInstance():getWritablePath() .. modulePath
  2090. local fullPath = gmCachePath .. filePath
  2091. if not global.FileUtilCtl:isFileExist(fullPath) then
  2092. return
  2093. end
  2094. global.FileUtilCtl:removeFile(fullPath)
  2095. global.FileUtilCtl:purgeCachedEntries()
  2096. end
  2097. ---------------------------------------------------------------------------
  2098. -- 聊天
  2099. -- 输入聊天内容
  2100. function SL:SendInputMsgToChat(str)
  2101. global.Facade:sendNotification(global.NoticeTable.Layer_Chat_ReplaceInput, str)
  2102. end
  2103. -- 发送普通消息
  2104. function SL:SendNormalMsgToChat(msg, setChannel)
  2105. local ChatProxy = global.Facade:retrieveProxy(global.ProxyTable.Chat)
  2106. local MSG_TYPE = ChatProxy.MSG_TYPE
  2107. local channel = setChannel or ChatProxy:getChannel()
  2108. local sendData = {mt = MSG_TYPE.Normal, msg = msg, channel = channel}
  2109. global.Facade:sendNotification(global.NoticeTable.SendChatMsg, sendData)
  2110. end
  2111. -- 发送系统消息
  2112. function SL:SendSystemMsgToChat(data)
  2113. local ChatProxy = global.Facade:retrieveProxy(global.ProxyTable.Chat)
  2114. local mdata = {
  2115. Msg = data.Msg or "",
  2116. FColor = data.FColor or 255,
  2117. BColor = data.BColor or 255,
  2118. ChannelId = ChatProxy.CHANNEL.System,
  2119. }
  2120. global.Facade:sendNotification(global.NoticeTable.AddChatItem, mdata)
  2121. end
  2122. -- 发送装备
  2123. function SL:SendEquipMsgToChat(item, setChannel)
  2124. local ChatProxy = global.Facade:retrieveProxy(global.ProxyTable.Chat)
  2125. local MSG_TYPE = ChatProxy.MSG_TYPE
  2126. local msg = item
  2127. local channel = setChannel or ChatProxy:getChannel()
  2128. local sendData = {mt = MSG_TYPE.Equip, msg = msg, channel = channel}
  2129. global.Facade:sendNotification(global.NoticeTable.SendChatMsg, sendData)
  2130. end
  2131. -- 发送坐标
  2132. function SL:SendPosMsgToChat(setChannel)
  2133. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  2134. if not mainPlayer then
  2135. return nil
  2136. end
  2137. local MapProxy = global.Facade:retrieveProxy(global.ProxyTable.Map)
  2138. local msg = {
  2139. mapID = MapProxy:GetMapID(),
  2140. mapName = MapProxy:GetMapName(),
  2141. mapX = mainPlayer:GetMapX(),
  2142. mapY = mainPlayer:GetMapY()
  2143. }
  2144. local ChatProxy = global.Facade:retrieveProxy(global.ProxyTable.Chat)
  2145. local MSG_TYPE = ChatProxy.MSG_TYPE
  2146. local channel = setChannel or ChatProxy:getChannel()
  2147. local sendData = {mt = MSG_TYPE.Position, msg = msg, channel = channel}
  2148. global.Facade:sendNotification(global.NoticeTable.SendChatMsg, sendData)
  2149. end
  2150. -- 发送表情
  2151. function SL:SendEmojiMsgToChat(config, setChannel)
  2152. local ChatProxy = global.Facade:retrieveProxy(global.ProxyTable.Chat)
  2153. local MSG_TYPE = ChatProxy.MSG_TYPE
  2154. if config.type == 1 then -- 骰子
  2155. local msg = Random(1, 6)
  2156. local channel = setChannel or ChatProxy:getChannel()
  2157. local sendData = {mt = MSG_TYPE.Dice, msg = msg, channel = channel}
  2158. global.Facade:sendNotification(global.NoticeTable.SendChatMsg, sendData)
  2159. elseif config.type == 2 then -- 猜拳
  2160. else
  2161. global.Facade:sendNotification(global.NoticeTable.Layer_Chat_PushInput, config.replace)
  2162. end
  2163. end
  2164. -- 私聊目标
  2165. function SL:PrivateChatWithTarget(targetId, targetName)
  2166. if not targetId or not targetName then
  2167. return
  2168. end
  2169. global.Facade:sendNotification(global.NoticeTable.PrivateChatWithTarget, {name = targetName, uid = targetId})
  2170. end
  2171. -- 物品数据转化 -聊天装备展示
  2172. function SL:TransItemDataIntoChatShow(itemData)
  2173. if itemData and itemData.makeindex then
  2174. itemData = ChangeItemServersSendDatas(itemData)
  2175. end
  2176. return clone(itemData)
  2177. end
  2178. -- 新增掉落消息
  2179. function SL:AddDropChatMsgShow(data)
  2180. if not data or not data.dropType then
  2181. SL:Print("[SL ERROR] SL:AddDropChatMsgShow param dropType is nil.")
  2182. return
  2183. end
  2184. local ChatProxy = global.Facade:retrieveProxy(global.ProxyTable.Chat)
  2185. local msgParam = {
  2186. Msg = data.Msg or "",
  2187. FColor = data.FColor or 255,
  2188. BColor = data.BColor or 255,
  2189. ChannelId = ChatProxy.CHANNEL.Drop,
  2190. mt = ChatProxy.MSG_TYPE.SRText,
  2191. dropType = data.dropType
  2192. }
  2193. global.Facade:sendNotification(global.NoticeTable.AddChatItem, msgParam)
  2194. end
  2195. -- 聊天
  2196. ---------------------------------------------------------------------------
  2197. ---------------------------------------------------------------------------
  2198. -- 资源下载
  2199. function SL:DownLoadRes(path, url, downloadCB)
  2200. if path and path ~= "" then
  2201. path = string.gsub(tostring(path), "\\", "/")
  2202. path = string.gsub(tostring(path), " ", "")
  2203. end
  2204. if not url or string.len(url) == 0 then
  2205. global.ResDownloader:download(path, function(isOK)
  2206. if downloadCB then
  2207. downloadCB(isOK)
  2208. end
  2209. end)
  2210. return
  2211. end
  2212. url = string.gsub(tostring(url), "\\", "/")
  2213. url = string.gsub(tostring(url), " ", "")
  2214. global.ResDownloader:downloadEx(path, url, function(isOK)
  2215. if isOK and downloadCB then
  2216. downloadCB()
  2217. end
  2218. end)
  2219. end
  2220. -----脚本变量额外属性 添加监听更新
  2221. function SL:CustomAttrWidgetAdd(metaValue,widget)
  2222. global.Facade:sendNotification(global.NoticeTable.CustomAttrWidgetAdd, {metaValue = metaValue , widget = widget})
  2223. end
  2224. -- 用于检测goodsitem 是否在listview 并且可视
  2225. function SL:CheckNodeCanCallBack(node, mousePos)
  2226. return CheckNodeCanCallBack(node, mousePos)
  2227. end
  2228. ---------------------------------------------------------------------------
  2229. ---------------------------------------------------------------------------
  2230. -- id 必须唯一 name 按钮名字 func 跳转函数
  2231. function SL:AddUpgradeBtn(id, name, func)
  2232. local RemindUpgradeProxy = global.Facade:retrieveProxy(global.ProxyTable.RemindUpgradeProxy)
  2233. RemindUpgradeProxy:refData(id, true,{id = id, name = name, func = func})
  2234. end
  2235. function SL:RemoveUpgradeBtn(id)
  2236. local RemindUpgradeProxy = global.Facade:retrieveProxy(global.ProxyTable.RemindUpgradeProxy)
  2237. RemindUpgradeProxy:refData(id, false)
  2238. end
  2239. ---------------------------------------------------------------------------
  2240. ---------------------------------------------------------------------------
  2241. ----- 鼠标模拟事件 ---------------------------------------------------------
  2242. -- 模拟左键点击触发左键点击事件
  2243. function SL:WinClick(widget)
  2244. if not widget or tolua.isnull(widget) then
  2245. return false
  2246. end
  2247. if type(widget._clickCallBack_) == "function" then
  2248. widget._clickCallBack_()
  2249. elseif type(widget._touchCallBack_) == "function" then
  2250. widget._touchCallBack_()
  2251. end
  2252. end
  2253. ---------------------------------------------------------------------------
  2254. -- 背包 isHero:boolen 英雄背包
  2255. function SL:RefreshBagPos(isHero)
  2256. ResetBagPos(isHero)
  2257. end
  2258. -- 物品使用(通过Index)
  2259. function SL:UseItemByIndex(Index)
  2260. return UseItemByIndex(Index)
  2261. end
  2262. -- 人物装备穿戴 isFromHero:是否来自英雄背包
  2263. function SL:TakeOnPlayerEquip(itemData, pos, isFromHero)
  2264. local noticeName = isFromHero and global.NoticeTable.TakeOnRequestFromHeroBag or global.NoticeTable.TakeOnRequest
  2265. global.Facade:sendNotification(noticeName,
  2266. {
  2267. itemData = itemData,
  2268. pos = pos
  2269. })
  2270. end
  2271. -- 人物装备脱下 isToHero:是否脱到英雄背包
  2272. function SL:TakeOffPlayerEquip(itemData, isToHero)
  2273. local noticeName = isToHero and global.NoticeTable.TakeOffToHeroBagRequest or global.NoticeTable.TakeOffRequest
  2274. global.Facade:sendNotification(noticeName, itemData)
  2275. end
  2276. -- 英雄装备穿戴 isFromPlayer:是否来自人物背包
  2277. function SL:TakeOnHeroEquip(itemData, pos, isFromPlayer)
  2278. local noticeName = isFromPlayer and global.NoticeTable.HeroTakeOnRequestFromHumBag or global.NoticeTable.HeroTakeOnRequest
  2279. global.Facade:sendNotification(noticeName,
  2280. {
  2281. itemData = itemData,
  2282. pos = pos
  2283. })
  2284. end
  2285. -- 英雄装备脱下 isToPlayer:是否脱到人物背包
  2286. function SL:TakeOffHeroEquip(itemData, isToPlayer)
  2287. local noticeName = isToPlayer and global.NoticeTable.HeroTakeOffRequestToHumBag or global.NoticeTable.HeroTakeOffRequest
  2288. global.Facade:sendNotification(noticeName, itemData)
  2289. end
  2290. -- 批量勾选背包物品
  2291. function SL:SetBagItemChoose(data)
  2292. global.Facade:sendNotification(global.NoticeTable.Bag_Item_Choose_State, data)
  2293. end
  2294. -- 丢弃物品
  2295. function SL:IntoDropBagItem(itemData)
  2296. if not itemData or not next(itemData) then
  2297. return
  2298. end
  2299. global.Facade:sendNotification(global.NoticeTable.IntoDropItem, itemData)
  2300. end
  2301. ---------------------------------------------------------------------------
  2302. -- 坐标转换
  2303. function SL:ConvertWorldPos2MapPos(worldX, worldY)
  2304. return global.sceneManager:WorldPos2MapPos(cc.p(worldX, worldY))
  2305. end
  2306. function SL:ConvertMapPos2WorldPos(mapX, mapY, centerOfGrid)
  2307. return global.sceneManager:MapPos2WorldPos(mapX, mapY, centerOfGrid)
  2308. end
  2309. function SL:ConvertWorldPos2Screen(worldX, worldY)
  2310. return World2Screen(cc.p(worldX, worldY))
  2311. end
  2312. function SL:ConvertScreen2WorldPos(screenX, screenY)
  2313. return Screen2World(cc.p(screenX, screenY))
  2314. end
  2315. --------------------------与移动端/PC端交互 begin-----------------------------
  2316. -- 打开qq(移动端)
  2317. function SL:OpenQQ()
  2318. global.L_NativeBridgeManager:GN_startQQ()
  2319. end
  2320. -- 加qq(移动端)
  2321. function SL:JoinQQ(id)
  2322. global.L_NativeBridgeManager:GN_joinQQ({qqKey=id})
  2323. end
  2324. -- 加qq群(移动端)
  2325. function SL:JoinQQGroup(id)
  2326. global.L_NativeBridgeManager:GN_joinQQGroup({qqGroupKey=id})
  2327. end
  2328. -- 打开微信(移动端)
  2329. function SL:OpenWX()
  2330. global.L_NativeBridgeManager:GN_startWX()
  2331. end
  2332. -- 加微信公众号(移动端)
  2333. function SL:JoinWXGroup(id)
  2334. global.L_NativeBridgeManager:GN_joinWXGroup({wxGroupKey=id})
  2335. end
  2336. --------------------------与移动端/PC端交互 end-----------------------------
  2337. ---------------------------------------------------------------------------
  2338. -- 添加控件 - 挂接方式
  2339. function SL:AttachOrUnAttachSUI(data)
  2340. global.Facade:sendNotification(global.NoticeTable.SUIComponentAttachBySSR, data)
  2341. end
  2342. -- 有目标聊天信息的点击触发 [不必开放]
  2343. function SL:OnTriggerClickPlayerChatMsg(data, richText)
  2344. ssr.ssrBridge:OnClickChatPlayerMsg(data.SendId, data.SendName, richText)
  2345. if SL.Triggers[LUA_TRIGGER_CHAT_CLICK_PLAYER_NAME] and SL.Triggers[LUA_TRIGGER_CHAT_CLICK_PLAYER_NAME](data) then
  2346. return
  2347. end
  2348. if type(ssrGlobal_OnClickChatPlayerMsg) == "function" then
  2349. local sendData = clone(data)
  2350. sendData.widget = richText
  2351. if ssrGlobal_OnClickChatPlayerMsg(sendData) then
  2352. return
  2353. end
  2354. end
  2355. end
  2356. -- 本地公告展示 [ssr]
  2357. function SL:ShowLocalNoticeByType(jsonData)
  2358. if not jsonData or not jsonData.Type then
  2359. return
  2360. end
  2361. if jsonData.Type == 12 then
  2362. local ChatProxy = global.Facade:retrieveProxy(global.ProxyTable.Chat)
  2363. local mdata = {
  2364. Msg = jsonData.Msg,
  2365. FColor = jsonData.FColor,
  2366. BColor = jsonData.BColor,
  2367. ChannelId = ChatProxy.CHANNEL.System,
  2368. mt = ChatProxy.MSG_TYPE.SystemTips,
  2369. }
  2370. global.Facade:sendNotification(global.NoticeTable.AddChatItem, mdata)
  2371. elseif jsonData.Type == 4 then
  2372. local data = {
  2373. Msg = jsonData.Msg,
  2374. FColor = jsonData.FColor,
  2375. BColor = jsonData.BColor,
  2376. }
  2377. global.Facade:sendNotification(global.NoticeTable.ShowServerNotice, data)
  2378. elseif jsonData.Type == 5 then
  2379. local data = {
  2380. Msg = jsonData.Msg,
  2381. FColor = jsonData.FColor,
  2382. BColor = jsonData.BColor,
  2383. Y = jsonData.Y,
  2384. Count = jsonData.Count,
  2385. }
  2386. global.Facade:sendNotification(global.NoticeTable.ShowSystemNotice, data)
  2387. elseif jsonData.Type == 6 then
  2388. local data = {
  2389. Msg = jsonData.Msg,
  2390. FColor = jsonData.FColor,
  2391. BColor = jsonData.BColor,
  2392. Time = jsonData.Time,
  2393. Label = jsonData.Label
  2394. }
  2395. global.Facade:sendNotification(global.NoticeTable.ShowTimerNotice, data)
  2396. elseif jsonData.Type == 9 then
  2397. ShowSystemTips(jsonData.Msg)
  2398. elseif jsonData.Type == 10 then
  2399. local data = {
  2400. X = jsonData.X,
  2401. Y = jsonData.Y,
  2402. Msg = jsonData.Msg,
  2403. FColor = jsonData.FColor,
  2404. BColor = jsonData.BColor,
  2405. }
  2406. global.Facade:sendNotification(global.NoticeTable.ShowSystemNoticeXY, data)
  2407. elseif jsonData.Type == 11 then
  2408. local data = {
  2409. Type = jsonData.Type,
  2410. Msg = jsonData.Msg,
  2411. FColor = jsonData.FColor,
  2412. BColor = jsonData.BColor,
  2413. }
  2414. global.Facade:sendNotification(global.NoticeTable.ServerNoticeEvent, data)
  2415. elseif jsonData.Type == 13 then
  2416. local data = {
  2417. Msg = jsonData.Msg,
  2418. FColor = jsonData.FColor,
  2419. BColor = jsonData.BColor,
  2420. Y = jsonData.Y,
  2421. Count = jsonData.Count,
  2422. ShowTime = jsonData.time,
  2423. }
  2424. global.Facade:sendNotification(global.NoticeTable.ShowSystemNoticeScale, data)
  2425. elseif jsonData.Type == 14 then
  2426. local data = {
  2427. Msg = jsonData.Msg,
  2428. FColor = jsonData.FColor,
  2429. BColor = jsonData.BColor,
  2430. Time = jsonData.Time,
  2431. X = jsonData.X,
  2432. isDelete = jsonData.isDelete,
  2433. }
  2434. global.Facade:sendNotification(global.NoticeTable.ShowTimerNoticeXY, data)
  2435. end
  2436. end
  2437. -- 震屏
  2438. function SL:ShakeScene(time, distance)
  2439. local data = {
  2440. time = time,
  2441. distance = distance
  2442. }
  2443. global.Facade:sendNotification( global.NoticeTable.ShakeScene, data)
  2444. end
  2445. -- 获取16高位
  2446. function SL:GetH16Bit(value)
  2447. return H16Bit(value)
  2448. end
  2449. -- 获取16低位
  2450. function SL:GetL16Bit(value)
  2451. return L16Bit(value)
  2452. end
  2453. -- 添加地图特效
  2454. function SL:AddMapSpecialEffect(ID, mapID, sfxId, x, y, loop, showType)
  2455. if not ID or not mapID or not sfxId then
  2456. return
  2457. end
  2458. SL.CustomMapEffects = SL.CustomMapEffects or {}
  2459. SL.CustomMapEffects[mapID] = SL.CustomMapEffects[mapID] or {}
  2460. if type(loop) ~= "boolean" then
  2461. loop = true
  2462. end
  2463. local item = {
  2464. sfxId = sfxId,
  2465. x = x,
  2466. y = y,
  2467. loop = loop,
  2468. isBehind = tonumber(showType) == 0,
  2469. isFront = tonumber(showType) == 1,
  2470. }
  2471. SL.CustomMapEffects[mapID][ID] = item
  2472. local curMapID = SL:GetMetaValue("MAP_ID")
  2473. if curMapID == mapID then
  2474. local isInit = false
  2475. local actorID = ID
  2476. local mapX = item.x
  2477. local mapY = item.y
  2478. local sfxActor = global.actorManager:GetActor(actorID)
  2479. if not sfxActor then
  2480. isInit = true
  2481. local paramSfx = {}
  2482. paramSfx.sfxId = item.sfxId
  2483. paramSfx.isLoop = item.loop
  2484. paramSfx.type = global.MMO.EFFECT_TYPE_NORMAL
  2485. sfxActor = global.actorManager:CreateActor(actorID, global.MMO.ACTOR_SEFFECT, paramSfx, item.isBehind, item.isFront)
  2486. end
  2487. local actorPos = global.sceneManager:MapPos2WorldPos(mapX, mapY, true)
  2488. sfxActor:setPosition(actorPos.x, actorPos.y)
  2489. global.actorManager:SetActorMapXY(sfxActor, mapX, mapY)
  2490. global.Facade:sendNotification( global.NoticeTable.DelayDirtyFeature, {actorID = actorID, actor = sfxActor})
  2491. if isInit then
  2492. global.sceneEffectManager:AddSceneEffect(sfxActor)
  2493. end
  2494. end
  2495. end
  2496. -- 删除地图特效
  2497. function SL:RmvMapSpecialEffect(ID, mapID)
  2498. if not ID or not mapID then
  2499. return
  2500. end
  2501. local curMapID = SL:GetMetaValue("MAP_ID")
  2502. local sceneImprisonEffectProxy = global.Facade:retrieveProxy(global.ProxyTable.SceneImprisonEffectProxy)
  2503. if curMapID == mapID then
  2504. global.sceneEffectManager:RmvSceneEffect(ID)
  2505. global.actorManager:RemoveActor(ID)
  2506. sceneImprisonEffectProxy:RmImprison(ID)
  2507. end
  2508. if SL.CustomMapEffects and SL.CustomMapEffects[mapID] then
  2509. SL.CustomMapEffects[mapID][ID] = nil
  2510. end
  2511. end
  2512. --- 添加actor特效
  2513. ---@param actorID string actor id
  2514. ---@param sfxID integer 特效id
  2515. ---@param isFront boolean 是否在模型前 默认在前面
  2516. ---@param offX integer x偏移
  2517. ---@param offY integer y偏移
  2518. function SL:AddActorEffect(actorID, sfxID, isFront, offX, offY)
  2519. -- body
  2520. if isFront == nil then
  2521. isFront = true
  2522. end
  2523. local data =
  2524. {
  2525. actorID = actorID,
  2526. sfxID = tonumber(sfxID),
  2527. frame = 0,
  2528. speed = 1,
  2529. count = 0,
  2530. front = isFront,
  2531. offsetX = offX or 0,
  2532. offsetY = offY or 0,
  2533. }
  2534. global.ActorEffectManager:AddEffect(data)
  2535. end
  2536. --- 删除actor特效
  2537. ---@param actorID string actor id
  2538. ---@param sfxID integer 特效id
  2539. function SL:RmvActorEffect(actorID, sfxID)
  2540. -- body
  2541. local data = {
  2542. actorID = actorID,
  2543. sfxID = sfxID,
  2544. }
  2545. global.ActorEffectManager:RmvEffect(data)
  2546. end
  2547. ---------------------------------------------------------------------------
  2548. -- 切页
  2549. function SL:SkipPage(data, key)
  2550. local CodeDOMUIProxy = global.Facade:retrieveProxy(global.ProxyTable.CodeDOMUIProxy)
  2551. CodeDOMUIProxy:SkipPage(data, key)
  2552. end
  2553. -- 强攻
  2554. function SL:ForceAttack()
  2555. global.Facade:sendNotification(global.NoticeTable.LaunchAttackSkill)
  2556. end
  2557. -- GBK转UTF8编码
  2558. function SL:UTF8ToGBK(str)
  2559. if UTF8ToGB2312 then
  2560. return UTF8ToGB2312(str)
  2561. end
  2562. end
  2563. -- UTF8转GBK编码
  2564. function SL:GBKToUTF8(str)
  2565. if GB2312ToUTF8 then
  2566. return GB2312ToUTF8(str)
  2567. end
  2568. end
  2569. -- 搜索路径下所有文件(path: dev下面的文件路径; 例如:"res/")
  2570. function SL:GetFilesByPath(path)
  2571. local fileUtil = global.FileUtilCtl
  2572. local resourcePath = fileUtil:getDefaultResourceRootPath()
  2573. local mCachePath = global.L_ModuleManager:GetCurrentModule():GetSubModPath()
  2574. local mStabPath = global.L_ModuleManager:GetCurrentModule():GetStabPath()
  2575. local directory = "dev/" .. path
  2576. local exportFolder = resourcePath .. mStabPath .. path
  2577. local exportFolder2 = resourcePath .. mCachePath .. path
  2578. local GMFolder = resourcePath .. directory
  2579. local cacheFolder = fileUtil:getWritablePath() .. mCachePath .. path
  2580. local cacheFolder2 = fileUtil:getWritablePath() .. mStabPath .. path
  2581. local GetFileName = function (str)
  2582. local rerStr = string.reverse(str)
  2583. local _, i = sfind(rerStr, "/")
  2584. local len = slen(str)
  2585. local st = len - i + 2
  2586. return ssub(str, st, len)
  2587. end
  2588. local files = {}
  2589. local items = {}
  2590. local iflag = {}
  2591. local fflag = {}
  2592. for _, path in ipairs({GMFolder, cacheFolder, exportFolder, cacheFolder2, exportFolder2}) do
  2593. repeat
  2594. if not fileUtil:isDirectoryExist(path) then --遍历不存在的目录在ios上会崩溃
  2595. break
  2596. end
  2597. local listfiles = fileUtil:listFiles(path)
  2598. for k, info in ipairs(listfiles) do
  2599. -- 去掉末尾可能出现的 /
  2600. info = sgsub(info, "[/]+$", "")
  2601. local filename = GetFileName(info)
  2602. if filename and not sfind(filename, "^%.") then
  2603. if fileUtil:isDirectoryExist(info) then -- 是否是文件夹
  2604. if not fflag[filename] then
  2605. files[#files + 1] = filename
  2606. fflag[filename] = true
  2607. end
  2608. else
  2609. if not iflag[filename] then
  2610. items[#items + 1] = filename
  2611. iflag[filename] = true
  2612. end
  2613. end
  2614. end
  2615. end
  2616. until true
  2617. end
  2618. tsort(files, function (a, b) return supper(a) < supper(b) end)
  2619. tsort(items, function (a, b) return supper(a) < supper(b) end)
  2620. for i, v in ipairs(items) do
  2621. files[#files + 1] = v
  2622. end
  2623. return files
  2624. end
  2625. ---------------------------------------------------------------------------
  2626. -- 鸿蒙解绑账号
  2627. function SL:HarmonyUnbind()
  2628. local NativeBridgeProxy = global.Facade:retrieveProxy(global.ProxyTable.NativeBridgeProxy)
  2629. if NativeBridgeProxy then
  2630. NativeBridgeProxy:GN_unbindAccount()
  2631. end
  2632. end
  2633. -- 交易行测试截图是否报错 pc端可以调用调试 报错的话可以查看控制台日志,图片可以在当前项目cache中
  2634. function SL:TradingTestCapture()
  2635. local data = {}
  2636. data.action = "screenshots"
  2637. data.type = "role"
  2638. data.testCapture = true
  2639. global.Facade:sendNotification(global.NoticeTable.TradingBank_other_Capture,{type = data})
  2640. end
  2641. -- 交易行lua自定义截图
  2642. ---@param open function 打开当前页面
  2643. ---@param close function 关闭当前页面
  2644. ---@param getNode function 返回一个当前页面父节点panel,会截图这个父节点上所有子节点,并且这个父节点可以获取到getContentSize的可视截图大小
  2645. function SL:AddTradingCustomCaptureTaskLua(open, close, getNode)
  2646. local data = {
  2647. open = function()
  2648. open()
  2649. end,
  2650. close = function()
  2651. close()
  2652. end,
  2653. getNode = getNode
  2654. }
  2655. table.insert(SL.TradingCustomCaptureLua, data)
  2656. end
  2657. -- 删除交易行lua截图任务
  2658. function SL:RemoveTradingCustomCaptureTask()
  2659. SL.TradingCustomCaptureLua = {}
  2660. end
  2661. -- base编码
  2662. function SL:Base64Encode(str)
  2663. if not str then
  2664. return ""
  2665. end
  2666. local b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  2667. local s64 = ''
  2668. while #str > 0 do
  2669. local bytes_num = 0
  2670. local buf = 0
  2671. for byte_cnt=1,3 do
  2672. buf = (buf * 256)
  2673. if #str > 0 then
  2674. buf = buf + string.byte(str, 1, 1)
  2675. str = string.sub(str, 2)
  2676. bytes_num = bytes_num + 1
  2677. end
  2678. end
  2679. for group_cnt=1,(bytes_num+1) do
  2680. local b64char = math.fmod(math.floor(buf/262144), 64) + 1
  2681. s64 = s64 .. string.sub(b64chars, b64char, b64char)
  2682. buf = buf * 64
  2683. end
  2684. for fill_cnt=1,(3-bytes_num) do
  2685. s64 = s64 .. '='
  2686. end
  2687. end
  2688. return s64
  2689. end
  2690. -- 调用sdk接口打开第三方应用 需sdk实现
  2691. function SL:OpenThirdApp(data)
  2692. local NativeBridgeProxy = global.Facade:retrieveProxy(global.ProxyTable.NativeBridgeProxy)
  2693. if NativeBridgeProxy then
  2694. NativeBridgeProxy:GN_Third_APP( data )
  2695. end
  2696. end
  2697. ---------------------------------------------------------------------------
  2698. local optionsUtils = nil
  2699. -- 设置hud名字显示 [判定条件之一: GM层面]
  2700. function SL:SetActorHUDNameLabelVisible(actorID, visible)
  2701. if not optionsUtils then
  2702. optionsUtils = requireProxy("optionsUtils")
  2703. end
  2704. if not actorID then
  2705. return
  2706. end
  2707. local actor = global.actorManager:GetActor(actorID)
  2708. if not actor then
  2709. return nil
  2710. end
  2711. actor:SetKeyValue(global.MMO.HUD_GM_SHOW, visible)
  2712. optionsUtils:refreshHUDLabelNameVisible(actor)
  2713. end