GameSettingProxy.lua 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  1. local RemoteProxy = requireProxy("remote/RemoteProxy")
  2. local GameSettingProxy = class("GameSettingProxy", RemoteProxy)
  3. GameSettingProxy.NAME = global.ProxyTable.GameSettingProxy
  4. local skillUtils = requireProxy("skillUtils")
  5. local cjson = require("cjson")
  6. GameSettingProxy.syncTable = {
  7. [16] = {key = "ZDLH", job = 3}, -- 自动烈火
  8. [35] = {key = "ZDZR", job = 3}, -- 自动逐日
  9. [53] = {key = "ZDKTZ", job = 3}, -- 自动开天斩
  10. [54] = {key = "ZDZR", job = 3}, -- 自动逐日
  11. [118] = {key = "ZDLYJF", job = 3}, -- 龙影剑法
  12. [119] = {key = "ZDLTJF", job = 3}, -- 雷霆剑法
  13. [120] = {key = "ZDZHJS", job = 3}, -- 纵横剑术
  14. [200] = {key = "ZDLJ"}, -- 自动连击
  15. [3011] = {key = "HERO_FOLLOW_ATTACK"}, -- 自动跟随主角攻击
  16. [3012] = {key = "HERO_ATTACK_DODGE"}, -- 英雄打怪躲避
  17. [41] = {key = "BB_FOLLOW_ATTACK"}, -- 宝宝自动跟随主角攻击
  18. }
  19. local discard =
  20. {
  21. [global.MMO.SETTING_IDX_FRAME_RATE_TYPE_HIGH] = 1
  22. }
  23. function GameSettingProxy:ctor()
  24. GameSettingProxy.super.ctor(self)
  25. self._data = {}
  26. self._config = {}
  27. self._pickConfig = {}--组配置
  28. self._pickData = {}--拾取的设置
  29. self._pickHangUpData = {} -- 总开关数据
  30. self._itemConfig = {} --拾取相关的改为由服务器发 这个是默认选项
  31. self._innerChangedSize = false
  32. self._bossTipsData = {} --Boss提醒配置
  33. self._bossTipsDataKey = {}
  34. self._bossTypeData = {"BOSS","大BOSS","超级BOSS" } -- boss type
  35. self._RankData = {} --保护数据
  36. self._hideReportBtn = false -- 是否隐藏举报按钮
  37. end
  38. function GameSettingProxy:LoadConfig()
  39. self._config = requireGameConfig("cfg_setup")
  40. self:readLocalData()
  41. -- pick config
  42. self._pickConfig = requireGameConfig("cfg_pick_set")
  43. local GameConfigMgrProxy = global.Facade:retrieveProxy(global.ProxyTable.GameConfigMgrProxy)
  44. local configKey = "cfg_serverItemCfg"
  45. local itemConfig = GameConfigMgrProxy:getConfigByKey(configKey)
  46. if not itemConfig then
  47. itemConfig = {}
  48. end
  49. self._itemConfig = itemConfig
  50. end
  51. function GameSettingProxy:OnPropertyInited()
  52. self:refSyncData()
  53. self:SyncDataToServer()
  54. self:readLocalPickData()
  55. self:readLocalGroupPickData()
  56. self:readLocalBossTipsData()
  57. self:readLocalBossTypeData()
  58. self:readLocalProtectData()
  59. self:initSomeSetting()
  60. global.Facade:sendNotification(global.NoticeTable.GameSettingInited)
  61. end
  62. function GameSettingProxy:OnReConnectInited()
  63. self:SyncDataToServer()
  64. end
  65. function GameSettingProxy:refSyncData()
  66. local skillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  67. local configs = skillProxy:GetConfigs()
  68. for i,v in pairs(configs) do
  69. if v.MagicID > 1000 and (v.job == 0 or v.job == 3) and skillProxy:IsOnoffSkill(v.MagicID) then --自定义战士开关技能
  70. self.syncTable[10000+v.MagicID] = {key = "ZD"..v.MagicID, job =v.job}
  71. end
  72. end
  73. end
  74. function GameSettingProxy:SyncDataToServer()
  75. local PlayerProperty = global.Facade:retrieveProxy( global.ProxyTable.PlayerProperty )
  76. local roleJob = PlayerProperty:GetRoleJob()
  77. local jsonData = {}
  78. for k, v in pairs(self.syncTable) do
  79. if (not v.job) or (v.job == 3) or (roleJob == v.job) then
  80. table.insert(jsonData, {key = v.key, value = (CHECK_SETTING(k) == 1 and 1 or 0)})
  81. end
  82. end
  83. -- 掉落屏蔽 "1,2,3"
  84. local ChatProxy = global.Facade:retrieveProxy(global.ProxyTable.Chat)
  85. local list = ChatProxy:GetDropTypeShield()
  86. local dropShield = table.concat(list, ",")
  87. table.insert(jsonData, {key = "MSGFILTER", value = dropShield})
  88. SendTableToServer(global.MsgType.MSG_CS_GAME_SETTING_CHANGE, jsonData)
  89. end
  90. function GameSettingProxy:readLocalData()
  91. local LoginProxy = global.Facade:retrieveProxy( global.ProxyTable.Login )
  92. local mainPlayerID = LoginProxy:GetSelectedRoleID()
  93. local path = "setting_UserData" .. mainPlayerID
  94. local key = "setting"
  95. local userData = UserData:new(path)
  96. local jsonStr = userData:getStringForKey(key, "")
  97. if not jsonStr or string.len(jsonStr) == 0 then
  98. return false
  99. end
  100. local jsonData = cjson.decode(jsonStr)
  101. if not jsonData then
  102. return false
  103. end
  104. --
  105. self._data = jsonData
  106. return true
  107. end
  108. function GameSettingProxy:saveLocalData()
  109. if not self._data then
  110. return false
  111. end
  112. local LoginProxy = global.Facade:retrieveProxy( global.ProxyTable.Login )
  113. local mainPlayerID = LoginProxy:GetSelectedRoleID()
  114. local path = "setting_UserData" .. mainPlayerID
  115. local key = "setting"
  116. local userData = UserData:new(path)
  117. local writeData = {}
  118. for key, value in pairs(self._data) do
  119. if discard[tonumber(key)] ~= 1 then
  120. writeData[key] = value
  121. end
  122. end
  123. local jsonStr = cjson.encode(writeData)
  124. userData:setStringForKey(key, jsonStr)
  125. return true
  126. end
  127. function GameSettingProxy:GetValue(id)
  128. id = tostring(id)
  129. local config = self:GetConfigByID(id)
  130. if not config then
  131. return {}
  132. end
  133. local platform = config and config.platform or nil
  134. if platform ~= 0 and platform ~= 99 and platform ~= global.OperatingMode then --判断平台
  135. return {}
  136. end
  137. --挂机忽略怪物列表不走default
  138. if not self._data[id] and id ~= global.MMO.SETTING_IDX_IGNORE_MONSTER then
  139. return {config.default, config.default1, config.default2, config.default3}
  140. end
  141. local data = self._data[id]
  142. return data
  143. end
  144. function GameSettingProxy:SetValue(id, value)
  145. id = tostring(id)
  146. self._data[id] = self._data[id] or {}
  147. if type(value) == "table" then
  148. self._data[id] = value
  149. else
  150. local data = self._data[id]
  151. data[1] = value
  152. end
  153. local numID = tonumber(id)
  154. if self.syncTable[numID] or self.syncTable[numID+10000] then
  155. self:SyncDataToServer()
  156. end
  157. self:saveLocalData()
  158. end
  159. function GameSettingProxy:GetConfigByID(id)
  160. id = tonumber(id)
  161. return self._config[id]
  162. end
  163. function GameSettingProxy:GetConfigByGroup(group)
  164. local config = {}
  165. for i, v in pairs(self._config) do
  166. if v.group == group and (v.platform == 0 or v.platform == global.OperatingMode) then
  167. table.insert(config, v)
  168. end
  169. end
  170. table.sort(config, function(a, b)
  171. return a.order and b.order and a.order < b.order
  172. end)
  173. return config
  174. end
  175. function GameSettingProxy:GetMainOptions()
  176. local PlayerProperty = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  177. local roleJob = PlayerProperty:GetRoleJob()
  178. local items = {}
  179. for i, v in pairs(self._config) do
  180. if v.mainpos and v.mainpos ~= "" and (v.platform == 0 or v.platform == global.OperatingMode) then
  181. local normalAndPress = string.split(v.mainpos, "&")
  182. local item = {}
  183. local has = false
  184. local filterJob = true
  185. if normalAndPress and normalAndPress[3] and normalAndPress[3] ~= "" then
  186. local job = tonumber(normalAndPress[3])
  187. if job and roleJob ~= job then
  188. filterJob = false
  189. end
  190. end
  191. --normal
  192. if normalAndPress and normalAndPress[1] and normalAndPress[1] ~= "" then
  193. local slicesPos = string.split(normalAndPress[1], "|")
  194. -- 移动1
  195. if not global.isWinPlayMode and slicesPos[1] and slicesPos[1] ~= "" then
  196. local slicesPosM = string.split(slicesPos[1], "#")
  197. has = true
  198. item.id = v.id
  199. item.lid = tonumber(slicesPosM[2]) or 0
  200. item.x = tonumber(slicesPosM[3]) or 0
  201. item.y = tonumber(slicesPosM[4]) or 0
  202. item.brightPath = string.format("%s%s","private/new_setting/icon/",slicesPosM[1])
  203. end
  204. -- PC
  205. if global.isWinPlayMode and slicesPos[2] and slicesPos[2] ~= "" then
  206. local slicesPosP = string.split(slicesPos[2], "#")
  207. has = true
  208. item.id = v.id
  209. item.lid = tonumber(slicesPosP[2]) or 0
  210. item.x = tonumber(slicesPosP[3]) or 0
  211. item.y = tonumber(slicesPosP[4]) or 0
  212. item.brightPath = string.format("%s%s","private/new_setting/icon/",slicesPosP[1])
  213. end
  214. end
  215. --press
  216. if normalAndPress and normalAndPress[2] and normalAndPress[2] ~= "" then
  217. local slicesPos = string.split(normalAndPress[2], "|")
  218. -- 移动1
  219. if not global.isWinPlayMode and slicesPos[1] and slicesPos[1] ~= "" then
  220. local slicesPosM = string.split(slicesPos[1], "#")
  221. has = true
  222. item.id = v.id
  223. item.off_lid = tonumber(slicesPosM[2]) or 0
  224. item.off_x = tonumber(slicesPosM[3]) or 0
  225. item.off_y = tonumber(slicesPosM[4]) or 0
  226. item.normalPath = string.format("%s%s","private/new_setting/icon/",slicesPosM[1])
  227. end
  228. -- PC
  229. if global.isWinPlayMode and slicesPos[2] and slicesPos[2] ~= "" then
  230. local slicesPosP = string.split(slicesPos[2], "#")
  231. has = true
  232. item.id = v.id
  233. item.off_lid = tonumber(slicesPosP[2]) or 0
  234. item.off_x = tonumber(slicesPosP[3]) or 0
  235. item.off_y = tonumber(slicesPosP[4]) or 0
  236. item.normalPath = string.format("%s%s","private/new_setting/icon/",slicesPosP[1])
  237. end
  238. end
  239. if has and filterJob then
  240. table.insert(items,item)
  241. end
  242. end
  243. end
  244. return items
  245. end
  246. --------------------------------------------------------
  247. --boss提醒
  248. function GameSettingProxy:readLocalBossTipsData()
  249. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  250. local path = "setting_UserData" .. mainPlayerID
  251. local key = "bossTips_setting"
  252. local userData = UserData:new(path)
  253. local jsonStr = userData:getStringForKey(key, "")
  254. if not jsonStr or string.len(jsonStr) == 0 then
  255. return false
  256. end
  257. local jsonData = cjson.decode(jsonStr)
  258. if not jsonData then
  259. return false
  260. end
  261. self._bossTipsSetting = true
  262. self._bossTipsData = jsonData
  263. for i,v in ipairs(self._bossTipsData) do
  264. self._bossTipsDataKey[v[1]] = v
  265. end
  266. return true
  267. end
  268. function GameSettingProxy:saveLocalBossTipsData()
  269. -- 延迟存储,防卡顿
  270. if self._bossTipStorageTimer then
  271. UnSchedule(self._bossTipStorageTimer)
  272. self._bossTipStorageTimer = nil
  273. end
  274. self._bossTipStorageTimer = PerformWithDelayGlobal(function()
  275. self._bossTipStorageTimer = nil
  276. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  277. local path = "setting_UserData" .. mainPlayerID
  278. local key = "bossTips_setting"
  279. local userData = UserData:new(path)
  280. local jsonStr = cjson.encode(self._bossTipsData)
  281. userData:setStringForKey(key, jsonStr)
  282. end, 0.01)
  283. return true
  284. end
  285. function GameSettingProxy:readLocalBossTypeData()
  286. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  287. local path = "setting_UserData" .. mainPlayerID
  288. local key = "bossType_setting"
  289. local userData = UserData:new(path)
  290. local jsonStr = userData:getStringForKey(key, "")
  291. if not jsonStr or string.len(jsonStr) == 0 then
  292. return false
  293. end
  294. local jsonData = cjson.decode(jsonStr)
  295. if not jsonData then
  296. return false
  297. end
  298. self._bossTypeData = jsonData
  299. return true
  300. end
  301. function GameSettingProxy:saveLocalBossTypeData()
  302. -- 延迟存储,防卡顿
  303. if self._bossTypeStorageTimer then
  304. UnSchedule(self._bossTypeStorageTimer)
  305. self._bossTypeStorageTimer = nil
  306. end
  307. self._bossTypeStorageTimer = PerformWithDelayGlobal(function()
  308. self._bossTypeStorageTimer = nil
  309. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  310. local path = "setting_UserData" .. mainPlayerID
  311. local key = "bossType_setting"
  312. local userData = UserData:new(path)
  313. local jsonStr = cjson.encode(self._bossTypeData)
  314. userData:setStringForKey(key, jsonStr)
  315. end, 0.01)
  316. return true
  317. end
  318. function GameSettingProxy:GetBossTipsValues()
  319. return self._bossTipsData
  320. end
  321. function GameSettingProxy:SetBossTipsValues(values)
  322. self._bossTipsData = values
  323. for i,v in ipairs(self._bossTipsData) do
  324. self._bossTipsDataKey[v[1]] = v
  325. end
  326. self:saveLocalBossTipsData()
  327. end
  328. function GameSettingProxy:GetBossType()
  329. return self._bossTypeData
  330. end
  331. function GameSettingProxy:SetBossType(values)
  332. self._bossTypeData = values
  333. self:saveLocalBossTypeData()
  334. end
  335. function GameSettingProxy:getNeedTipsMonsterData(name)
  336. return self._bossTipsDataKey[name]
  337. end
  338. function CHECK_SETTING_BOSSTIPS(name)
  339. if not name then
  340. return
  341. end
  342. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  343. return GameSettingProxy:getNeedTipsMonsterData(name)
  344. end
  345. --------------------------------------------------------
  346. --- 手动拾取
  347. --------------------------------------------------------
  348. function GameSettingProxy:readLocalPickData()
  349. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  350. local path = "setting_UserData" .. mainPlayerID
  351. local key = "pick_setting"
  352. local userData = UserData:new(path)
  353. local jsonStr = userData:getStringForKey(key, "")
  354. if not jsonStr or string.len(jsonStr) == 0 then
  355. return false
  356. end
  357. local jsonData = cjson.decode(jsonStr)
  358. if not jsonData then
  359. return false
  360. end
  361. --
  362. self._pickData = jsonData
  363. return true
  364. end
  365. function GameSettingProxy:saveLocalPickData()
  366. -- 延迟存储,防卡顿
  367. if self._pickStorageTimer then
  368. UnSchedule(self._pickStorageTimer)
  369. self._pickStorageTimer = nil
  370. end
  371. self._pickStorageTimer = PerformWithDelayGlobal(function()
  372. self._pickStorageTimer = nil
  373. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  374. local path = "setting_UserData" .. mainPlayerID
  375. local key = "pick_setting"
  376. local userData = UserData:new(path)
  377. local jsonStr = cjson.encode(self._pickData)
  378. userData:setStringForKey(key, jsonStr)
  379. end, 0.01)
  380. return true
  381. end
  382. function GameSettingProxy:readLocalGroupPickData()
  383. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  384. local path = "setting_UserData" .. mainPlayerID
  385. local key = "grouppick_setting"
  386. local userData = UserData:new(path)
  387. local jsonStr = userData:getStringForKey(key, "")
  388. if not jsonStr or string.len(jsonStr) == 0 then
  389. return false
  390. end
  391. local jsonData = cjson.decode(jsonStr)
  392. if not jsonData then
  393. return false
  394. end
  395. --
  396. self._pickHangUpData = jsonData
  397. return true
  398. end
  399. function GameSettingProxy:saveLocalGroupPickData()
  400. -- 延迟存储,防卡顿
  401. if self._pickGroupStorageTimer then
  402. UnSchedule(self._pickGroupStorageTimer)
  403. self._pickGroupStorageTimer = nil
  404. end
  405. self._pickGroupStorageTimer = PerformWithDelayGlobal(function()
  406. self._pickGroupStorageTimer = nil
  407. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  408. local path = "setting_UserData" .. mainPlayerID
  409. local key = "grouppick_setting"
  410. local userData = UserData:new(path)
  411. local jsonStr = cjson.encode(self._pickHangUpData)
  412. userData:setStringForKey(key, jsonStr)
  413. end, 0.01)
  414. return true
  415. end
  416. ------------------
  417. function GameSettingProxy:GetPickConfig()
  418. return self._pickConfig
  419. end
  420. function GameSettingProxy:GetPickGroupValue(id)--拾取组设置
  421. id = tostring(id)
  422. --掉落显示#手动拾取#挂机捡取
  423. local set = self._pickHangUpData[id] or {1,1,1}
  424. return set
  425. end
  426. function GameSettingProxy:GetPickValue(id)--拾取设置
  427. id = tostring(id)
  428. --组类别#掉落显示#手动拾取#挂机捡取
  429. local set = {}
  430. if not self._pickData[id] then
  431. local find = false
  432. for i,v in ipairs(self._itemConfig) do--服务器的为默认配置 道具表控制是否可以 设置
  433. if v.Index == tonumber(id) then
  434. find = true
  435. set = {v.ShowName or 1,v.AutoPick or 1 ,v.HideMode or 1}
  436. break
  437. end
  438. end
  439. if not find then
  440. set = {1,1,1}
  441. end
  442. else
  443. set = clone(self._pickData[id])
  444. end
  445. set[1] = set[1] or 1
  446. set[2] = set[2] or 1
  447. set[3] = set[3] or 1
  448. local config = self:GetPickCanSet(id)--不能勾选的当不能拾取
  449. for i,v in ipairs(config) do
  450. if v == 0 then
  451. set[i] = 0
  452. end
  453. end
  454. return set
  455. end
  456. function GameSettingProxy:GetPickCanSet(id)--道具表 配置能否勾选
  457. id = tostring(id)
  458. --组类别#掉落显示#手动拾取#挂机捡取
  459. local ItemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
  460. local itemConfig = ItemConfigProxy:GetItemDataByIndex(tonumber(id))
  461. if itemConfig.pickset and string.len(itemConfig.pickset) > 0 then--先读道具表
  462. local slices = string.split(tostring(itemConfig.pickset), "#")
  463. local value = {tonumber(slices[2]) or 0, tonumber(slices[3]) or 0, tonumber(slices[4]) or 0}
  464. return value
  465. end
  466. return {1,1,1}
  467. end
  468. function GameSettingProxy:GetGroupIdByIndex(Index)
  469. local id = tonumber(Index)
  470. --组类别#掉落显示#手动拾取#挂机捡取
  471. local ItemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
  472. local itemConfig = ItemConfigProxy:GetItemDataByIndex(id)
  473. if itemConfig and itemConfig.pickset and string.len(itemConfig.pickset) > 0 then--先读道具表
  474. local slices = string.split(tostring(itemConfig.pickset), "#")
  475. return slices[1]
  476. end
  477. return nil
  478. end
  479. function GameSettingProxy:SetPickValue(id, value)
  480. id = tostring(id)
  481. self._pickData[id] = value
  482. self:saveLocalPickData()
  483. end
  484. function GameSettingProxy:SetPickGroupValue(id, value)
  485. id = tostring(id)
  486. self._pickHangUpData[id] = value
  487. self:saveLocalGroupPickData()
  488. end
  489. function GameSettingProxy:readLocalProtectData()
  490. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  491. local path = "setting_UserData" .. mainPlayerID
  492. local key = "RankData_setting"
  493. local userData = UserData:new(path)
  494. local jsonStr = userData:getStringForKey(key, "")
  495. if not jsonStr or string.len(jsonStr) == 0 then
  496. return false
  497. end
  498. local jsonData = cjson.decode(jsonStr)
  499. if not jsonData then
  500. return false
  501. end
  502. self._RankData = jsonData
  503. return true
  504. end
  505. function GameSettingProxy:saveLocalProtectData()
  506. -- 延迟存储,防卡顿
  507. if self._protectDataStorageTimer then
  508. UnSchedule(self._protectDataStorageTimer)
  509. self._protectDataStorageTimer = nil
  510. end
  511. self._protectDataStorageTimer = PerformWithDelayGlobal(function()
  512. self._protectDataStorageTimer = nil
  513. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  514. local path = "setting_UserData" .. mainPlayerID
  515. local key = "RankData_setting"
  516. local userData = UserData:new(path)
  517. local jsonStr = cjson.encode(self._RankData)
  518. userData:setStringForKey(key, jsonStr)
  519. end, 0.01)
  520. return true
  521. end
  522. --某些排序的设置
  523. function GameSettingProxy:getRankData(id)
  524. if not id then
  525. return {}
  526. end
  527. id = tostring(id)
  528. local config = self:GetConfigByID(id)
  529. if not config then
  530. return {indexs = {} ,time = 1000,oriStr = ""}
  531. end
  532. if self._RankData[id] then
  533. local oriStr = self._RankData[id].oriStr
  534. local indexs = config.indexs
  535. if indexs and indexs ~= "" and oriStr ~= indexs then --发现之前的配置跟现在不一样 清除之前的排序数据
  536. self:setRankData(id,{indexs = {} ,time = 1000,oriStr = config.indexs})
  537. else
  538. return self._RankData[id]
  539. end
  540. end
  541. if not config.indexs then
  542. config.indexs = ""
  543. end
  544. if not config.time then
  545. config.time = 1000
  546. end
  547. self._RankData[id] = {indexs = {} ,time = 1000,oriStr = config.indexs}
  548. self._RankData[id].time = config.default2 or config.time
  549. if id == tostring(global.MMO.SETTING_IDX_AUTO_GROUPSKILL) or id == tostring(global.MMO.SETTING_IDX_AUTO_SIMPSKILL) then
  550. else
  551. local indexs = string.split(config.indexs,"#")
  552. for i,index in ipairs(indexs) do
  553. table.insert(self._RankData[id].indexs, tonumber(index))
  554. end
  555. end
  556. return self._RankData[id]
  557. end
  558. function GameSettingProxy:setRankData(id,value)
  559. id = tostring(id)
  560. self._RankData[id] = value
  561. self:saveLocalProtectData()
  562. end
  563. function GameSettingProxy:initSomeSetting()
  564. --global.MMO.SETTING_IDX_IGNORE_MONSTER --忽略怪物
  565. local value = GET_SETTING(global.MMO.SETTING_IDX_IGNORE_MONSTER)
  566. if not (value and (type(value) == "table")) then
  567. local config = self:GetConfigByID(global.MMO.SETTING_IDX_IGNORE_MONSTER)
  568. if config and config.names then
  569. local names = string.split(config.names,"#")
  570. local t = {}
  571. for i,name in ipairs(names) do
  572. t[name] = 1
  573. end
  574. CHANGE_SETTING(global.MMO.SETTING_IDX_IGNORE_MONSTER, {t})
  575. end
  576. end
  577. --global.MMO.SETTING_IDX_BOSS_TIPS --boss提醒
  578. local values = self:GetBossTipsValues()
  579. if not (values and #values>0 ) and not self._bossTipsSetting then
  580. local config = self:GetConfigByID(global.MMO.SETTING_IDX_BOSS_TIPS)
  581. if config and config.names then
  582. local names = string.split(config.names,"#")
  583. local t = {}
  584. for i,name in ipairs(names) do
  585. table.insert(t,{name,1,"BOSS"})
  586. end
  587. self:SetBossTipsValues(t)
  588. end
  589. end
  590. local protect =
  591. {
  592. --人物
  593. global.MMO.SETTING_IDX_HP_PROTECT1 , -- hp保护1
  594. global.MMO.SETTING_IDX_HP_PROTECT2 , -- hp保护2
  595. global.MMO.SETTING_IDX_HP_PROTECT3 , -- hp保护3
  596. global.MMO.SETTING_IDX_HP_PROTECT4 , -- hp保护4
  597. global.MMO.SETTING_IDX_MP_PROTECT1 , -- mp保护1
  598. global.MMO.SETTING_IDX_MP_PROTECT2 , -- mp保护2
  599. global.MMO.SETTING_IDX_MP_PROTECT3 , -- mp保护3
  600. global.MMO.SETTING_IDX_MP_PROTECT4 , -- mp保护4
  601. --hero
  602. global.MMO.SETTING_IDX_HERO_HP_PROTECT1 , -- hp保护1
  603. global.MMO.SETTING_IDX_HERO_HP_PROTECT2 , -- hp保护2
  604. global.MMO.SETTING_IDX_HERO_HP_PROTECT3 , -- hp保护3
  605. global.MMO.SETTING_IDX_HERO_HP_PROTECT4 , -- hp保护4
  606. global.MMO.SETTING_IDX_HERO_MP_PROTECT1 , -- mp保护1
  607. global.MMO.SETTING_IDX_HERO_MP_PROTECT2 , -- mp保护2
  608. global.MMO.SETTING_IDX_HERO_MP_PROTECT3 , -- mp保护3
  609. global.MMO.SETTING_IDX_HERO_MP_PROTECT4 , -- mp保护4
  610. --红名保护
  611. global.MMO.SETTING_IDX_PK_PROTECT , --红名保护
  612. }
  613. for i,id in ipairs(protect) do
  614. local values = self:getRankData(id)
  615. local config = self:GetConfigByID(id)
  616. local minTime = config and config.time or 1000
  617. if values and values.time and values.time < minTime then
  618. values.time = minTime
  619. end
  620. self:setRankData(id,values)
  621. end
  622. end
  623. -- 判断是否可挂机拾取
  624. -- function GameSettingProxy:IsAutoPick(id)
  625. -- id = tostring(id)
  626. -- local ItemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
  627. -- local itemConfig = ItemConfigProxy:GetItemDataByIndex(tonumber(id))
  628. -- local slices = string.split(tostring(itemConfig.pickset), "#")
  629. -- if slices[1] and self._pickHangUpData[slices[1]] and self._pickHangUpData[ slices[1]][3] == 1 then --外面的总开关要开着才能设置有效
  630. -- return CHECK_ITEM_AUTO_PICK(id)
  631. -- end
  632. -- return false
  633. -- end
  634. function CHECK_GROUPSETTING_PICK(id)
  635. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  636. return GameSettingProxy:GetPickGroupValue(id)
  637. end
  638. function CHANGE_GROUPSETTING_PICK(id, value)
  639. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  640. GameSettingProxy:SetPickGroupValue(id, value)
  641. end
  642. function CHECK_SETTING_PICK(id)
  643. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  644. return GameSettingProxy:GetPickValue(id)
  645. end
  646. function CHANGE_SETTING_PICK(id, value)
  647. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  648. GameSettingProxy:SetPickValue(id, value)
  649. global.Facade:sendNotification(global.NoticeTable.GamePickSettingChange)
  650. end
  651. --检测掉落物显示
  652. function CHECK_ITEM_DROP_SHOW(id)
  653. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  654. local value = GameSettingProxy:GetPickValue(id)
  655. local groupid = GameSettingProxy:GetGroupIdByIndex(id)
  656. local groupOK = true
  657. if groupid then
  658. local groupvalue = GameSettingProxy:GetPickGroupValue(groupid)
  659. groupOK = groupvalue[1] == 1
  660. end
  661. return value[1] == 1 and groupOK
  662. end
  663. -- 检测手动拾取
  664. function CHECK_ITEM_PICK(id)
  665. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  666. local value = GameSettingProxy:GetPickValue(id)
  667. local groupid = GameSettingProxy:GetGroupIdByIndex(id)
  668. local groupOK = true
  669. if groupid then
  670. local groupvalue = GameSettingProxy:GetPickGroupValue(groupid)
  671. groupOK = groupvalue[2] == 1
  672. end
  673. return value[2] == 1 and groupOK
  674. end
  675. -- 检测自动拾取
  676. function CHECK_ITEM_AUTO_PICK(id)
  677. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  678. local value = GameSettingProxy:GetPickValue(id)
  679. local groupid = GameSettingProxy:GetGroupIdByIndex(id)
  680. local groupOK = true
  681. if groupid then
  682. local groupvalue = GameSettingProxy:GetPickGroupValue(groupid)
  683. groupOK = groupvalue[3] == 1
  684. end
  685. return value[3] == 1 and groupOK
  686. end
  687. function CHECK_ITEM_PICK_CANSET(id)
  688. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  689. local value = GameSettingProxy:GetPickCanSet(id)
  690. return value
  691. end
  692. --------------------------------------------------------
  693. --- 手动拾取
  694. --------------------------------------------------------
  695. function GameSettingProxy:ResponseSettingChange(msg)
  696. end
  697. function GameSettingProxy:RegisterMsgHandler()
  698. GameSettingProxy.super.RegisterMsgHandler(self)
  699. local msgType = global.MsgType
  700. end
  701. function CHECK_SETTING(id)
  702. local data = GET_SETTING(id)
  703. local enable = data[1]
  704. return enable
  705. end
  706. function GET_SETTING(id)
  707. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  708. return GameSettingProxy:GetValue(id)
  709. end
  710. function CHANGE_SETTING(id, values)
  711. local data = GET_SETTING(id)
  712. for i=1,4 do
  713. if data and data[i] then
  714. values[i] = values[i] or data[i]
  715. end
  716. end
  717. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  718. GameSettingProxy:SetValue(id, values)
  719. global.Facade:sendNotification(global.NoticeTable.GameSettingChange, {id = id, value = values})
  720. SLBridge:onLUAEvent(LUA_EVENT_SETTING_CAHNGE, {id = id, values = values})
  721. end
  722. ------------------------------------------------------
  723. --- 内部改动尺寸标识
  724. function GameSettingProxy:IsInnerChangedSize()
  725. return self._innerChangedSize
  726. end
  727. function GameSettingProxy:SetInnerChangedSize(boolean)
  728. self._innerChangedSize = boolean
  729. end
  730. function GameSettingProxy:RequestNotifySizeChange(width, height)
  731. if not width or not height then
  732. return
  733. end
  734. LuaSendMsg(global.MsgType.MSG_CS_MODIFY_RESOLUTION, width, height)
  735. end
  736. ------------------------------------------------------
  737. --- 举报
  738. function GameSettingProxy:IsHideReportBtn( ... )
  739. return self._hideReportBtn
  740. end
  741. function GameSettingProxy:SetHideReportBtn(state)
  742. self._hideReportBtn = state
  743. end
  744. return GameSettingProxy