SettingLogic.lua 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. local NoticeExcel = require("excel.notice")
  2. local HeroExcel = require("excel.hero")
  3. local Util = require("common.Util")
  4. local Lang = require("common.Lang")
  5. local Msg = require("core.Msg")
  6. DEFAULT_SYSTEM_SET = 0 -- 默认设置
  7. FAQ_TYPE_1 = 1 -- 1:faq
  8. FAQ_TYPE_2 = 2 -- 2:help
  9. -- 客户端设置
  10. function set(human, flag)
  11. human.db.systemSet = flag
  12. if human.db.systemSet == DEFAULT_SYSTEM_SET then
  13. human.db.systemSet = nil
  14. end
  15. query(human)
  16. end
  17. -- 客户端设置查询
  18. function query(human)
  19. local msgRet = Msg.gc.GC_SETTING_SYSTEM
  20. msgRet.flag = human.db.systemSet or DEFAULT_SYSTEM_SET
  21. Msg.send(msgRet, human.fd)
  22. end
  23. -- 帮助分类查询
  24. function faqQueryBase(human)
  25. local config = NoticeExcel.faq
  26. local msgRet = Msg.gc.GC_FAQ_QUERY_BASE
  27. msgRet.list[0] = #config
  28. for i = 1, #config do
  29. msgRet.list[i].id = i
  30. msgRet.list[i].title = config[i].title
  31. end
  32. Msg.send(msgRet, human.fd)
  33. end
  34. -- 帮助分类具体内容查询
  35. function faqQueryDetail(human, id)
  36. local config = NoticeExcel.faq
  37. local msgRet = Msg.gc.GC_FAQ_QUERY_DETAIL
  38. msgRet.id = id
  39. msgRet.content = config[id].content
  40. Msg.send(msgRet, human.fd)
  41. end
  42. -- 通用的问号叹号面板查询
  43. function helpMiscQuery(human, id)
  44. local config = NoticeExcel.tips[id]
  45. if config == nil then
  46. assert(nil)
  47. end
  48. local msgRet = Msg.gc.GC_HELP_MISC_QUERY
  49. msgRet.id = id
  50. msgRet.title = config.title
  51. msgRet.type = config.type
  52. msgRet.content = config.content
  53. Msg.send(msgRet, human.fd)
  54. end
  55. ----------------------------------------------
  56. -------------- 设置相关具体功能---------------
  57. ----------------------------------------------
  58. function isNoShowVip(human)
  59. local flag = human.db.systemSet or DEFAULT_SYSTEM_SET
  60. local isNoShow = Util.getBit(flag, 3)
  61. if isNoShow == 1 then
  62. return true
  63. end
  64. end
  65. function isNoPrivateChat(human)
  66. local flag = human.db.systemSet or DEFAULT_SYSTEM_SET
  67. local isNoPrivateChat = Util.getBit(flag, 4)
  68. if isNoPrivateChat == 1 then
  69. return true
  70. end
  71. end
  72. function explainDetail(human, id)
  73. local config = NoticeExcel.strategy[id]
  74. if config == nil then
  75. assert(nil)
  76. end
  77. local msgRet = Msg.gc.GC_EXPLAIN_DETAIL
  78. msgRet.id = id
  79. msgRet.title = config.title
  80. msgRet.content = config.content
  81. Msg.send(msgRet, human.fd)
  82. end
  83. local function wrapperGetwayInfo(human, net, id, conf)
  84. if not conf then
  85. conf = NoticeExcel.resource[id]
  86. end
  87. net.id = id
  88. net.title = tostring(conf.title)
  89. net.desc = tostring(conf.desc)
  90. net.icon = tostring(conf.icon)
  91. net.funlist[0] = 0
  92. for _,v in ipairs(conf.func) do
  93. net.funlist[0] = net.funlist[0] + 1
  94. net.funlist[net.funlist[0]].id = v[1]
  95. net.funlist[net.funlist[0]].name = tostring(v[2])
  96. net.funlist[net.funlist[0]].desc = v[3] and tostring(v[3]) or ""
  97. end
  98. end
  99. function resourceQuery(human)
  100. local msgRet = Msg.gc.GC_RESOURCE_QUERY
  101. msgRet.list[0] = 0
  102. for id, conf in Util.pairsByKeys(NoticeExcel.resource) do
  103. msgRet.list[0] = msgRet.list[0] + 1
  104. wrapperGetwayInfo(human, msgRet.list[msgRet.list[0]], id, conf)
  105. end
  106. Msg.send(msgRet, human.fd)
  107. end
  108. function strategyQuery(human)
  109. local config = NoticeExcel.strategy
  110. local msgRet = Msg.gc.GC_STRATEGY_QUERY
  111. local len = #config
  112. msgRet.list[0] = len
  113. for i = 1, len do
  114. local index = 0
  115. msgRet.list[i].id = i
  116. msgRet.list[i].name = config[i].name
  117. msgRet.list[i].desc = config[i].desc or ""
  118. if config[i].team then
  119. local teamLen = #config[i].team
  120. for j = 1,teamLen do
  121. local heroID = config[i].team[j]
  122. local heroMsg = HeroExcel.hero[heroID]
  123. index = index + 1
  124. msgRet.list[i].team[index].icon = heroMsg.head
  125. msgRet.list[i].team[index].lv = 100
  126. msgRet.list[i].team[index].camp = heroMsg.camp
  127. msgRet.list[i].team[index].star = heroMsg.star
  128. msgRet.list[i].team[index].id = heroID
  129. msgRet.list[i].team[index].label = heroMsg.label
  130. end
  131. end
  132. msgRet.list[i].team[0] = index
  133. end
  134. Msg.send(msgRet, human.fd)
  135. end
  136. -- 声音设置
  137. function settingSound(human, music, acoustic, voice, isSend)
  138. human.db.systemSound = human.db.systemSound or {}
  139. human.db.systemSound.music = music
  140. human.db.systemSound.acoustic = acoustic
  141. human.db.systemSound.voice = voice
  142. if isSend then
  143. settingSoundQuery(human)
  144. end
  145. end
  146. -- 发送声音设置
  147. function settingSoundQuery(human)
  148. if not human.db.systemSound then return end
  149. if not human.db.systemSound.music then return end
  150. local msgRet = Msg.gc.GC_SETTING_SOUND
  151. msgRet.music = human.db.systemSound.music or 0
  152. msgRet.acoustic = human.db.systemSound.acoustic or 0
  153. msgRet.voice = human.db.systemSound.voice or 0
  154. Msg.send(msgRet, human.fd)
  155. end
  156. -- 语言设置
  157. function settingLang(human, lang)
  158. human.db.systemSound = human.db.systemSound or {}
  159. human.db.systemSound.lang = lang
  160. settingLangQuery(human)
  161. end
  162. -- 发送语言设置
  163. function settingLangQuery(human)
  164. if not human.db.systemSound then return end
  165. local msgRet = Msg.gc.GC_SETTING_LANGUAGE
  166. msgRet.lang = human.db.systemSound.lang or 0
  167. Msg.send(msgRet, human.fd)
  168. end
  169. function onLogin(human)
  170. settingSoundQuery(human)
  171. settingLangQuery(human)
  172. end