All user data for FoundryVTT. Includes worlds, systems, modules, and any asset in the "foundryuserdata" directory. Does NOT include the FoundryVTT installation itself.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

254 lines
8.7 KiB

1 year ago
1 year ago
  1. const SMARTTARGET_MODULE_NAME = "smarttarget";
  2. Hooks.on("init", () => {
  3. game.smartTarget = {
  4. altModifier : false,
  5. };
  6. game.settings.register(SMARTTARGET_MODULE_NAME, "targetingMode", {
  7. name: game.i18n.localize("smarttarget.settings.targetingMode.name"),
  8. hint: game.i18n.localize("smarttarget.settings.targetingMode.hint"),
  9. scope: "client",
  10. config: true,
  11. default: 1,
  12. type: Number,
  13. choices: {
  14. 0: game.i18n.localize("smarttarget.settings.targetingMode.opt0"),
  15. 1: game.i18n.localize("smarttarget.settings.targetingMode.opt1"),
  16. 2: game.i18n.localize("smarttarget.settings.targetingMode.opt2"),
  17. },
  18. });
  19. game.settings.register(SMARTTARGET_MODULE_NAME, "release", {
  20. name: game.i18n.localize("smarttarget.settings.releaseBehaviour.name"),
  21. hint: game.i18n.localize("smarttarget.settings.releaseBehaviour.hint"),
  22. scope: "client",
  23. config: true,
  24. default: 0,
  25. type: Number,
  26. choices: {
  27. 0: game.i18n.localize("smarttarget.settings.releaseBehaviour.choice0.Standard"),
  28. 1: game.i18n.localize("smarttarget.settings.releaseBehaviour.choice0.Sticky")
  29. }
  30. });
  31. game.settings.register(SMARTTARGET_MODULE_NAME, "portraitPips", {
  32. name: game.i18n.localize("smarttarget.settings.portraitPips.name"),
  33. hint: game.i18n.localize("smarttarget.settings.portraitPips.hint"),
  34. scope: "world",
  35. config: true,
  36. default: false,
  37. type: Boolean,
  38. });
  39. game.settings.register(SMARTTARGET_MODULE_NAME, "useToken", {
  40. name: game.i18n.localize("smarttarget.settings.useToken.name"),
  41. hint: game.i18n.localize("smarttarget.settings.useToken.hint"),
  42. scope: "world",
  43. config: true,
  44. default: false,
  45. type: Boolean,
  46. });
  47. game.settings.register(SMARTTARGET_MODULE_NAME, "useTokenGm", {
  48. name: game.i18n.localize("smarttarget.settings.useTokenGm.name"),
  49. hint: game.i18n.localize("smarttarget.settings.useTokenGm.hint"),
  50. scope: "world",
  51. config: true,
  52. default: 0,
  53. type: Number,
  54. choices: {
  55. 0: game.i18n.localize("smarttarget.settings.useTokenGm.opt0"),
  56. 1: game.i18n.localize("smarttarget.settings.useTokenGm.opt1"),
  57. 2: game.i18n.localize("smarttarget.settings.useTokenGm.opt2"),
  58. },
  59. });
  60. game.settings.register(SMARTTARGET_MODULE_NAME, "pipPosition", {
  61. name: game.i18n.localize("smarttarget.settings.pipPosition.name"),
  62. hint: game.i18n.localize("smarttarget.settings.pipPosition.hint"),
  63. scope: "world",
  64. config: true,
  65. default: "topleft",
  66. type: String,
  67. choices: {
  68. "topleft": game.i18n.localize("smarttarget.settings.pipPosition.topleft"),
  69. "topright": game.i18n.localize("smarttarget.settings.pipPosition.topright"),
  70. "bottomleft": game.i18n.localize("smarttarget.settings.pipPosition.bottomleft"),
  71. "bottomright": game.i18n.localize("smarttarget.settings.pipPosition.bottomright"),
  72. "centertop": game.i18n.localize("smarttarget.settings.pipPosition.centertop"),
  73. "centerbottom": game.i18n.localize("smarttarget.settings.pipPosition.centerbottom"),
  74. "random": game.i18n.localize("smarttarget.settings.pipPosition.random"),
  75. },
  76. });
  77. game.settings.register(SMARTTARGET_MODULE_NAME, "insidePips", {
  78. name: game.i18n.localize("smarttarget.settings.insidePips.name"),
  79. hint: game.i18n.localize("smarttarget.settings.insidePips.hint"),
  80. scope: "world",
  81. config: true,
  82. default: false,
  83. type: Boolean,
  84. });
  85. game.settings.register(SMARTTARGET_MODULE_NAME, "pipImgScale", {
  86. name: game.i18n.localize("smarttarget.settings.pipImgScale.name"),
  87. hint: game.i18n.localize("smarttarget.settings.pipImgScale.hint"),
  88. scope: "world",
  89. config: true,
  90. type: Number,
  91. range: {
  92. min: 0.05,
  93. max: 10,
  94. step: 0.05,
  95. },
  96. default: 1,
  97. });
  98. game.settings.register(SMARTTARGET_MODULE_NAME, "pipOffsetManualY", {
  99. name: game.i18n.localize("smarttarget.settings.pipOffsetManualY.name"),
  100. hint: game.i18n.localize("smarttarget.settings.pipOffsetManualY.hint"),
  101. scope: "world",
  102. config: true,
  103. type: Number,
  104. range: {
  105. min: 0,
  106. max: 100,
  107. step: 0.05,
  108. },
  109. default: 0,
  110. });
  111. game.settings.register(SMARTTARGET_MODULE_NAME, "pipOffsetManualX", {
  112. name: game.i18n.localize("smarttarget.settings.pipOffsetManualX.name"),
  113. hint: game.i18n.localize("smarttarget.settings.pipOffsetManualX.hint"),
  114. scope: "world",
  115. config: true,
  116. type: Number,
  117. range: {
  118. min: 0,
  119. max: 100,
  120. step: 0.05,
  121. },
  122. default: 0,
  123. });
  124. game.settings.register(SMARTTARGET_MODULE_NAME, "pipScale", {
  125. name: game.i18n.localize("smarttarget.settings.pipScale.name"),
  126. hint: game.i18n.localize("smarttarget.settings.pipScale.hint"),
  127. scope: "world",
  128. config: true,
  129. type: Number,
  130. range: {
  131. min: 0.05,
  132. max: 100,
  133. step: 0.05,
  134. },
  135. default: 12,
  136. });
  137. game.settings.register(SMARTTARGET_MODULE_NAME, "pipOffset", {
  138. name: game.i18n.localize("smarttarget.settings.pipOffset.name"),
  139. hint: game.i18n.localize("smarttarget.settings.pipOffset.hint"),
  140. scope: "world",
  141. config: true,
  142. type: Number,
  143. range: {
  144. min: 0.05,
  145. max: 100,
  146. step: 0.05,
  147. },
  148. default: 16,
  149. });
  150. game.settings.register(SMARTTARGET_MODULE_NAME, "borderThicc", {
  151. name: game.i18n.localize("smarttarget.settings.borderThicc.name"),
  152. hint: game.i18n.localize("smarttarget.settings.borderThicc.hint"),
  153. scope: "world",
  154. config: true,
  155. type: Number,
  156. range: {
  157. min: 0,
  158. max: 10,
  159. step: 1,
  160. },
  161. default: 2,
  162. });
  163. game.settings.register(SMARTTARGET_MODULE_NAME, "crossairColor", {
  164. name: game.i18n.localize("smarttarget.settings.crossairColor.name"),
  165. hint: game.i18n.localize("smarttarget.settings.crossairColor.hint"),
  166. scope: "client",
  167. config: true,
  168. type: String,
  169. default: "",
  170. });
  171. game.settings.register(SMARTTARGET_MODULE_NAME, "target-indicator", {
  172. name: game.i18n.localize("smarttarget.settings.target-indicator.name"),
  173. hint: game.i18n.localize("smarttarget.settings.target-indicator.hint"),
  174. scope: "client",
  175. config: true,
  176. default: "0",
  177. type: String,
  178. choices: {
  179. 0: game.i18n.localize("smarttarget.settings.target-indicator-choices-0"),
  180. 1: game.i18n.localize("smarttarget.settings.target-indicator-choices-1"),
  181. 2: game.i18n.localize("smarttarget.settings.target-indicator-choices-2"),
  182. 3: game.i18n.localize("smarttarget.settings.target-indicator-choices-3"),
  183. 4: game.i18n.localize("smarttarget.settings.target-indicator-choices-4"),
  184. 5: game.i18n.localize("smarttarget.settings.target-indicator-choices-5"),
  185. },
  186. });
  187. game.settings.register(SMARTTARGET_MODULE_NAME, "use-player-color", {
  188. name: game.i18n.localize("smarttarget.settings.use-player-color.name"),
  189. hint: game.i18n.localize("smarttarget.settings.use-player-color.hint"),
  190. scope: "world",
  191. config: true,
  192. default: false,
  193. type: Boolean,
  194. });
  195. libWrapper.register(SMARTTARGET_MODULE_NAME,"Token.prototype._refreshTarget", SmartTarget._refreshTarget, "MIXED");
  196. libWrapper.register(SMARTTARGET_MODULE_NAME, "Token.prototype._onClickLeft", SmartTarget._tokenOnClickLeft, "MIXED");
  197. libWrapper.register(SMARTTARGET_MODULE_NAME, "Canvas.prototype._onClickLeft", SmartTarget.canvasOnClickLeft, "WRAPPER");
  198. libWrapper.register(SMARTTARGET_MODULE_NAME, "Token.prototype._canControl", SmartTarget._canControl, "MIXED");
  199. Hooks.on("getSceneControlButtons", function(controls) {
  200. let control = controls.find(c => c.name === 'token') || controls[0];
  201. control.tools.push({
  202. name: 'clearTargets',
  203. title: game.i18n.localize("smarttarget.controls.cleartargets.name"),
  204. icon:'fa fa-times-circle',
  205. button:true,
  206. onClick: () => {
  207. canvas.tokens.placeables[0]?.setTarget(false, { releaseOthers: true });
  208. },
  209. layer: 'TokenLayer'
  210. });
  211. },);
  212. const {SHIFT, CONTROL, ALT} = KeyboardManager.MODIFIER_KEYS;
  213. game.keybindings.register(SMARTTARGET_MODULE_NAME, "altKey", {
  214. name: game.i18n.localize("smarttarget.keybindings.altkey"),
  215. editable: [
  216. {key: "AltLeft"},
  217. {key: "AltRight"},
  218. ],
  219. onDown: () => {game.smartTarget.altModifier = true;},
  220. onUp: () => {game.smartTarget.altModifier = false;},
  221. });
  222. game.keybindings.register(SMARTTARGET_MODULE_NAME, "clearAllTargets", {
  223. name: game.i18n.localize("smarttarget.keybindings.clearAllTargets"),
  224. editable: [
  225. {key: "KeyC", modifiers: [ ALT ]}
  226. ],
  227. onDown: () => {canvas.tokens.placeables[0]?.setTarget(false, { releaseOthers: true });},
  228. });
  229. });