SettingChangeCommand.lua 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. local SettingChangeCommand = class('SettingChangeCommand', framework.SimpleCommand)
  2. local optionsUtils = requireProxy( "optionsUtils" )
  3. local skillUtils = requireProxy("skillUtils")
  4. function SettingChangeCommand:ctor()
  5. end
  6. function SettingChangeCommand:execute(notification)
  7. local data = notification:getBody()
  8. local id = data.id
  9. local value = data.value or 0
  10. dump(data)
  11. if id == global.MMO.SETTING_IDX_PLAYER_NAME then -- 人物显名
  12. local actors, ncount = global.playerManager:GetPlayersInCurrViewField()
  13. for i = 1, ncount do
  14. local actor = actors[i]
  15. if actor then
  16. local hudParam = GetActorAttr( actor, global.MMO.ACTOR_ATTR_HUDPARAM )
  17. if hudParam and next(hudParam) then
  18. global.Facade:sendNotification(global.NoticeTable.DelayRefreshHUDLabel, { actor = actor, actorID = actor:GetID(), hudParam = hudParam })
  19. end
  20. end
  21. end
  22. local monsters, ncount = global.monsterManager:GetMonstersInCurrViewField()
  23. for i = 1, ncount do
  24. local actor = monsters[i]
  25. if actor and actor:IsHaveMaster() then
  26. optionsUtils:refreshLabelVisible(actor)
  27. end
  28. end
  29. elseif id == global.MMO.SETTING_IDX_ONLY_NAME then -- 只显人名
  30. local actors, ncount = global.playerManager:GetPlayersInCurrViewField()
  31. for i = 1, ncount do
  32. local actor = actors[i]
  33. if actor then
  34. local hudParam = GetActorAttr( actor, global.MMO.ACTOR_ATTR_HUDPARAM )
  35. if hudParam and next(hudParam) then
  36. global.Facade:sendNotification(global.NoticeTable.DelayRefreshHUDLabel, { actor = actor, actorID = actor:GetID(), hudParam = hudParam })
  37. end
  38. end
  39. end
  40. elseif id == global.MMO.SETTING_IDX_HP_NUM then -- 数字显血
  41. local actors, ncount = global.playerManager:GetPlayersInCurrViewField()
  42. for i = 1, ncount do
  43. local actor = actors[i]
  44. if actor then
  45. optionsUtils:InitHUDVisibleValue(actor, global.MMO.HUD_HMPLabel_VISIBLE)
  46. optionsUtils:refreshHUDHMpLabelVisible( actor )
  47. end
  48. end
  49. local monsters, ncount = global.monsterManager:GetMonstersInCurrViewField()
  50. for i = 1, ncount do
  51. local actor = monsters[i]
  52. if actor then
  53. optionsUtils:InitHUDVisibleValue(actor, global.MMO.HUD_HMPLabel_VISIBLE)
  54. optionsUtils:refreshHUDHMpLabelVisible( actor )
  55. end
  56. end
  57. elseif id == global.MMO.SETTING_IDX_HP_HUD then -- 显示血条
  58. local actors, ncount = global.playerManager:GetPlayersInCurrViewField()
  59. for i = 1, ncount do
  60. local actor = actors[i]
  61. if actor then
  62. optionsUtils:CheckHUDHpBarVisible( actor )
  63. optionsUtils:CheckHUDMpBarVisible( actor )
  64. end
  65. end
  66. local monsters, ncount = global.monsterManager:GetMonstersInCurrViewField()
  67. for i = 1, ncount do
  68. local actor = monsters[i]
  69. if actor then
  70. optionsUtils:CheckHUDHpBarVisible( actor )
  71. optionsUtils:CheckHUDMpBarVisible( actor )
  72. end
  73. end
  74. elseif id == global.MMO.SETTING_IDX_MONSTER_NAME then -- 怪物显名
  75. local monsters, ncount = global.monsterManager:GetMonstersInCurrViewField()
  76. for i = 1, ncount do
  77. local actor = monsters[i]
  78. if actor then
  79. optionsUtils:InitHUDVisibleValue(actor, global.MMO.HUD_NAMELabel_VISIBLE)
  80. optionsUtils:refreshHUDLabelNameVisible( actor )
  81. end
  82. end
  83. local actors, ncount = global.playerManager:GetPlayersInCurrViewField()
  84. for i = 1, ncount do
  85. local actor = actors[i]
  86. if actor and actor:IsHumanoid() then
  87. optionsUtils:InitHUDVisibleValue(actor, global.MMO.HUD_NAMELabel_VISIBLE)
  88. optionsUtils:refreshHUDLabelNameVisible( actor )
  89. optionsUtils:InitHUDVisibleValue(actor, global.MMO.HUD_GUILDLabel_VISIBLE)
  90. optionsUtils:refreshHUDLabelGuildVisible( actor )
  91. end
  92. end
  93. elseif id == global.MMO.SETTING_IDX_MONSTER_PET_VISIBLE then -- 屏蔽召唤物
  94. global.Facade:sendNotification(global.NoticeTable.SetChange_MonsterPet)
  95. elseif id == global.MMO.SETTING_IDX_EFFECT_SHOW then -- 屏蔽特效设置(技能除外)
  96. global.Facade:sendNotification(global.NoticeTable.SetChange_AllEffect)
  97. elseif id == global.MMO.SETTING_IDX_SKILL_EFFECT_SHOW then -- 屏蔽技能特效设置
  98. global.Facade:sendNotification(global.NoticeTable.SetChange_SkillEffect)
  99. elseif id == global.MMO.SETTING_IDX_PLAYER_SHOW_FRIEND then -- 屏蔽己方玩家设置
  100. global.Facade:sendNotification(global.NoticeTable.SetChange_OwnSidePlayer)
  101. elseif id == global.MMO.SETTING_IDX_PLAYER_SHOW then -- 屏蔽玩家设置
  102. global.Facade:sendNotification(global.NoticeTable.SetChange_AllPlayer)
  103. elseif id == global.MMO.SETTING_IDX_MONSTER_VISIBLE then -- 屏蔽怪物设置
  104. global.Facade:sendNotification(global.NoticeTable.SetChange_NormalMonster)
  105. local monsters, ncount = global.monsterManager:GetMonstersInCurrViewField()
  106. for i = 1, ncount do
  107. local actor = monsters[i]
  108. if actor then
  109. optionsUtils:InitHUDVisibleValue(actor, global.MMO.HUD_NAMELabel_VISIBLE)
  110. optionsUtils:refreshHUDLabelNameVisible( actor )
  111. end
  112. end
  113. local actors, ncount = global.playerManager:GetPlayersInCurrViewField()
  114. for i = 1, ncount do
  115. local actor = actors[i]
  116. if actor and actor:IsHumanoid() then
  117. optionsUtils:InitHUDVisibleValue(actor, global.MMO.HUD_NAMELabel_VISIBLE)
  118. optionsUtils:refreshHUDLabelNameVisible( actor )
  119. end
  120. end
  121. elseif id == global.MMO.SETTING_IDX_IGNORE_STALL then -- 屏蔽摆摊
  122. local actors, ncount = global.playerManager:GetPlayersInCurrViewField()
  123. for i = 1, ncount do
  124. local actor = actors[i]
  125. if actor then
  126. global.Facade:sendNotification(global.NoticeTable.RefreshActorBooth, {actorID = actor:GetID(), actor = actor})
  127. end
  128. end
  129. elseif id == global.MMO.SETTING_IDX_TITLE_VISIBLE then -- 显示称号设置
  130. local actors, ncount = global.playerManager:GetPlayersInCurrViewField()
  131. for i = 1, ncount do
  132. local actor = actors[i]
  133. if actor then
  134. optionsUtils:InitHUDVisibleValue(actor, global.MMO.HUD_TITLE_VISIBLE)
  135. optionsUtils:refreshHUDTitleVisible( actor )
  136. end
  137. end
  138. elseif id == global.MMO.SETTING_IDX_FRAME_RATE_TYPE_HIGH then -- 高帧率模式设置
  139. value = value or {}
  140. value = value[1]
  141. local newvalue = 1 - value
  142. local CheckOptions =
  143. {
  144. [global.MMO.SETTING_IDX_MONSTER_PET_VISIBLE] = newvalue, -- 屏蔽召唤物
  145. [global.MMO.SETTING_IDX_EFFECT_SHOW] = newvalue, -- 屏蔽特效
  146. [global.MMO.SETTING_IDX_SKILL_EFFECT_SHOW] = newvalue, -- 屏蔽技能特效
  147. [global.MMO.SETTING_IDX_PLAYER_SHOW_FRIEND] = newvalue, -- 屏蔽玩家设置
  148. [global.MMO.SETTING_IDX_PLAYER_SHOW] = newvalue, -- 屏蔽玩家设置
  149. [global.MMO.SETTING_IDX_MONSTER_VISIBLE] = newvalue, -- 屏蔽怪物设置
  150. [global.MMO.SETTING_IDX_TITLE_VISIBLE] = newvalue, -- 隐藏称号
  151. }
  152. for k, v in pairs(CheckOptions) do
  153. CHANGE_SETTING(k, {v})
  154. end
  155. elseif id == global.MMO.SETTING_IDX_PLAYER_JOB_LEVEL then -- 血量刷新设置
  156. local actors, ncount = global.playerManager:GetPlayersInCurrViewField()
  157. for i = 1, ncount do
  158. local actor = actors[i]
  159. if actor then
  160. global.HUDHPManager:UpdateNow(actor)
  161. end
  162. end
  163. elseif id == global.MMO.SETTING_IDX_HIDE_MONSTER_BODY then -- 清理尸体设置
  164. local monsters, ncount = global.monsterManager:GetMonstersInCurrViewField()
  165. for i = 1, ncount do
  166. local actor = monsters[i]
  167. if actor then
  168. optionsUtils:InitHUDVisibleValue(actor, global.MMO.HUD_NAMELabel_VISIBLE)
  169. optionsUtils:refreshHUDLabelNameVisible(actor)
  170. optionsUtils:InitHUDVisibleValue(actor, global.MMO.MONSTER_VISIBLE)
  171. optionsUtils:refreshMonsterVisible(actor)
  172. -- global.Facade:sendNotification( global.NoticeTable.RefreshBuffVisible, actor )
  173. end
  174. end
  175. local actors, ncount = global.playerManager:GetPlayersInCurrViewField()
  176. for i = 1, ncount do
  177. local actor = actors[i]
  178. if actor and actor:IsHumanoid() then
  179. optionsUtils:InitHUDVisibleValue(actor, global.MMO.HUD_NAMELabel_VISIBLE)
  180. optionsUtils:refreshHUDLabelNameVisible(actor)
  181. optionsUtils:InitHUDVisibleValue(actor, global.MMO.PLAYER_VISIBLE)
  182. optionsUtils:refreshPlayerVisible(actor)
  183. -- global.Facade:sendNotification( global.NoticeTable.RefreshBuffVisible, actor )
  184. end
  185. end
  186. elseif id == global.MMO.SETTING_IDX_PLAYER_SIMPLE_DRESS then -- 人物简装
  187. global.Facade:sendNotification(global.NoticeTable.SetChange_SimpleDressPlayer)
  188. elseif id == global.MMO.SETTING_IDX_MONSTER_SIMPLE_DRESS then -- 怪物简装
  189. global.Facade:sendNotification(global.NoticeTable.SetChange_SimpleDressMonster)
  190. local monsters, ncount = global.monsterManager:GetMonstersInCurrViewField()
  191. for i = 1, ncount do
  192. local actor = monsters[i]
  193. if actor then
  194. global.Facade:sendNotification( global.NoticeTable.DelayRefreshHUDTitle, { actor = actor, actorID = actor:GetID()} )
  195. end
  196. end
  197. elseif id == global.MMO.SETTING_IDX_BOSS_NO_SIMPLE_DRESS then
  198. global.Facade:sendNotification(global.NoticeTable.SetChange_SimpleDressMonsterBoss)
  199. local monsters, ncount = global.monsterManager:GetMonstersInCurrViewField()
  200. for i = 1, ncount do
  201. local actor = monsters[i]
  202. if actor and actor:IsBoss() then
  203. global.Facade:sendNotification( global.NoticeTable.DelayRefreshHUDTitle, { actor = actor, actorID = actor:GetID()} )
  204. end
  205. end
  206. elseif id == global.MMO.SETTING_IDX_HERO_HIDE then -- 屏蔽英雄
  207. global.Facade:sendNotification(global.NoticeTable.SetChange_AllHero)--英雄屏蔽
  208. elseif id == global.MMO.SETTING_IDX_ROCKER_SHOW_DISTANCE then --轮盘侧边距
  209. global.Facade:sendNotification( global.NoticeTable.Rocker_Show_Distance_Change, value )
  210. elseif id == global.MMO.SETTING_IDX_SKILL_SHOW_DISTANCE then --技能侧边距
  211. SL:onLUAEvent(LUA_EVENT_SKILLBUTTON_DISTANCE_CHANGE)
  212. elseif id == global.MMO.SETTING_IDX_NO_MONSTAER_USE then --多少秒没怪物使用
  213. local AssistProxy = global.Facade:retrieveProxy(global.ProxyTable.AssistProxy)
  214. AssistProxy:resetNoMonsterSchedule()
  215. elseif id == global.MMO.SETTING_IDX_HP_UNIT then --血量单位转换
  216. local monsters, ncount = global.monsterManager:GetMonstersInCurrViewField()
  217. for i = 1, ncount do
  218. local actor = monsters[i]
  219. if actor and actor:IsBoss() then
  220. global.HUDHPManager:UpdateNow(actor)
  221. end
  222. end
  223. local actors, ncount = global.playerManager:GetPlayersInCurrViewField()
  224. for i = 1, ncount do
  225. local actor = actors[i]
  226. if actor then
  227. global.HUDHPManager:UpdateNow(actor)
  228. end
  229. end
  230. end
  231. end
  232. return SettingChangeCommand