warscript 0.0.1-dev.9e72e49 → 0.0.1-dev.9ee7706

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/config.d.ts +5 -0
  2. package/config.lua +10 -0
  3. package/core/types/effect.d.ts +13 -3
  4. package/core/types/effect.lua +116 -17
  5. package/core/types/frame.d.ts +4 -0
  6. package/core/types/frame.lua +71 -0
  7. package/core/types/sound.d.ts +17 -24
  8. package/core/types/sound.lua +94 -24
  9. package/core/util.d.ts +1 -1
  10. package/core/util.lua +18 -1
  11. package/engine/behavior.d.ts +2 -2
  12. package/engine/behavior.lua +6 -6
  13. package/engine/behaviour/ability/always-enabled.d.ts +7 -0
  14. package/engine/behaviour/ability/always-enabled.lua +31 -0
  15. package/engine/behaviour/ability/apply-buff.d.ts +5 -0
  16. package/engine/behaviour/ability/apply-buff.lua +32 -0
  17. package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
  18. package/engine/behaviour/ability/damage.d.ts +3 -0
  19. package/engine/behaviour/ability/damage.lua +2 -2
  20. package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
  21. package/engine/behaviour/ability/emulate-impact.lua +28 -0
  22. package/engine/behaviour/ability/instant-impact.d.ts +2 -2
  23. package/engine/behaviour/ability/instant-impact.lua +4 -19
  24. package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
  25. package/engine/behaviour/ability/on-command-impact.lua +25 -0
  26. package/engine/behaviour/ability/remove-buffs.d.ts +16 -0
  27. package/engine/behaviour/ability/remove-buffs.lua +28 -0
  28. package/engine/behaviour/ability.d.ts +16 -3
  29. package/engine/behaviour/ability.lua +105 -34
  30. package/engine/behaviour/unit.d.ts +7 -0
  31. package/engine/behaviour/unit.lua +20 -0
  32. package/engine/buff.d.ts +62 -42
  33. package/engine/buff.lua +312 -234
  34. package/engine/internal/ability.d.ts +16 -13
  35. package/engine/internal/ability.lua +80 -76
  36. package/engine/internal/item/ability.lua +106 -0
  37. package/engine/internal/item+owner.lua +2 -2
  38. package/engine/internal/item.d.ts +2 -2
  39. package/engine/internal/item.lua +56 -25
  40. package/engine/internal/mechanics/ability-duration.lua +1 -1
  41. package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
  42. package/engine/internal/misc/ability-disable-counter.lua +13 -0
  43. package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
  44. package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
  45. package/engine/internal/object-data/evasion-probability.d.ts +2 -0
  46. package/engine/internal/object-data/evasion-probability.lua +16 -0
  47. package/engine/internal/unit/ability.d.ts +10 -1
  48. package/engine/internal/unit/ability.lua +36 -14
  49. package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
  50. package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
  51. package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
  52. package/engine/internal/unit/add-item-to-slot.lua +52 -0
  53. package/engine/internal/unit/bonus.d.ts +2 -0
  54. package/engine/internal/unit/bonus.lua +17 -0
  55. package/engine/internal/unit/ignore-events-items.d.ts +2 -0
  56. package/engine/internal/unit/ignore-events-items.lua +5 -0
  57. package/engine/internal/unit/item.d.ts +24 -0
  58. package/engine/internal/unit/item.lua +78 -0
  59. package/engine/internal/unit/main-selected.d.ts +13 -0
  60. package/engine/internal/unit/main-selected.lua +51 -0
  61. package/engine/internal/unit+ability.lua +2 -2
  62. package/engine/internal/unit-missile-launch.lua +24 -5
  63. package/engine/internal/unit.d.ts +30 -10
  64. package/engine/internal/unit.lua +169 -83
  65. package/engine/internal/utility.lua +12 -0
  66. package/engine/lightning.d.ts +12 -5
  67. package/engine/lightning.lua +48 -14
  68. package/engine/local-client.d.ts +7 -2
  69. package/engine/local-client.lua +82 -0
  70. package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
  71. package/engine/object-data/auxiliary/animation-name.lua +16 -0
  72. package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
  73. package/engine/object-data/auxiliary/sound-eax.lua +2 -0
  74. package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
  75. package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
  76. package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
  77. package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
  78. package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
  79. package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
  80. package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
  81. package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
  82. package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
  83. package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
  84. package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
  85. package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
  86. package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
  87. package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
  88. package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
  89. package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
  90. package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
  91. package/engine/object-data/entry/ability-type/web.d.ts +12 -0
  92. package/engine/object-data/entry/ability-type/web.lua +52 -0
  93. package/engine/object-data/entry/ability-type.d.ts +8 -6
  94. package/engine/object-data/entry/ability-type.lua +62 -27
  95. package/engine/object-data/entry/buff-type/applicable.lua +13 -37
  96. package/engine/object-data/entry/buff-type.d.ts +1 -1
  97. package/engine/object-data/entry/buff-type.lua +2 -2
  98. package/engine/object-data/entry/destructible-type.d.ts +1 -1
  99. package/engine/object-data/entry/item-type.d.ts +15 -1
  100. package/engine/object-data/entry/item-type.lua +93 -2
  101. package/engine/object-data/entry/lightning-type.d.ts +1 -1
  102. package/engine/object-data/entry/sound-preset.d.ts +33 -0
  103. package/engine/object-data/entry/sound-preset.lua +140 -0
  104. package/engine/object-data/entry/unit-type.d.ts +8 -1
  105. package/engine/object-data/entry/unit-type.lua +61 -8
  106. package/engine/object-data/entry/upgrade.d.ts +1 -1
  107. package/engine/object-data/entry/upgrade.lua +4 -4
  108. package/engine/object-data/entry.d.ts +16 -14
  109. package/engine/object-data/entry.lua +60 -32
  110. package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
  111. package/engine/object-field/ability.d.ts +9 -3
  112. package/engine/object-field/ability.lua +4 -1
  113. package/engine/object-field.d.ts +2 -2
  114. package/engine/object-field.lua +4 -0
  115. package/engine/standard/entries/sound-preset.d.ts +10 -0
  116. package/engine/standard/entries/sound-preset.lua +10 -0
  117. package/engine/standard/fields/ability.d.ts +2 -0
  118. package/engine/standard/fields/ability.lua +2 -0
  119. package/engine/unit.d.ts +3 -0
  120. package/engine/unit.lua +3 -0
  121. package/index.d.ts +1 -0
  122. package/index.lua +1 -0
  123. package/objutil/buff.lua +1 -1
  124. package/objutil/unit.lua +8 -0
  125. package/package.json +2 -2
  126. package/patch-lua.d.ts +0 -0
  127. package/patch-lua.lua +10 -0
  128. package/utility/arrays.d.ts +8 -1
  129. package/utility/arrays.lua +34 -3
  130. package/utility/lazy.d.ts +2 -0
  131. package/utility/lazy.lua +14 -0
  132. package/utility/reflection.lua +11 -7
package/config.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /** @noSelfInFile */
2
+ export declare class WarscriptConfig {
3
+ private constructor();
4
+ static AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH: boolean;
5
+ }
package/config.lua ADDED
@@ -0,0 +1,10 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local ____exports = {}
4
+ ____exports.WarscriptConfig = __TS__Class()
5
+ local WarscriptConfig = ____exports.WarscriptConfig
6
+ WarscriptConfig.name = "WarscriptConfig"
7
+ function WarscriptConfig.prototype.____constructor(self)
8
+ end
9
+ WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH = true
10
+ return ____exports
@@ -4,15 +4,23 @@ import { Widget } from "./widget";
4
4
  import { PlayerColor } from "./playerColor";
5
5
  declare const enum EffectPropertyKey {
6
6
  COLOR = 100,
7
- PITCH = 101
7
+ PITCH = 101,
8
+ ROLL = 102
8
9
  }
9
10
  export type EffectParameters = {
11
+ readonly delay?: number;
10
12
  readonly scale?: number;
11
13
  readonly color?: PlayerColor;
14
+ readonly pitch?: number;
15
+ readonly roll?: number;
16
+ readonly detached?: boolean;
17
+ readonly zOffset?: number;
18
+ readonly scaleZOffset?: boolean;
12
19
  };
13
20
  export declare class Effect extends Handle<jeffect> {
14
21
  private [EffectPropertyKey.COLOR]?;
15
22
  private [EffectPropertyKey.PITCH]?;
23
+ private [EffectPropertyKey.ROLL]?;
16
24
  protected onDestroy(): HandleDestructor;
17
25
  get color(): PlayerColor;
18
26
  set color(color: PlayerColor);
@@ -20,11 +28,13 @@ export declare class Effect extends Handle<jeffect> {
20
28
  set scale(scale: number);
21
29
  get pitch(): number;
22
30
  set pitch(pitch: number);
31
+ get roll(): number;
32
+ set roll(roll: number);
23
33
  static create<T extends Effect>(this: typeof Effect & (new (handle: jeffect) => T), model: string, pos: Vec2): T;
24
34
  static createTarget<T extends Effect>(this: typeof Effect & (new (handle: jeffect) => T), model: string, target: Widget, attachPoint: string): T;
25
35
  static flash(modelPath: string, ...args: [
26
- ...pointOrWidget: [x: number, y: number] | [widget: Widget, attachmentPoint: string],
27
- ...parametersOrDuration: [parameters?: EffectParameters] | [duration?: number, parameters?: EffectParameters]
36
+ ...pointOrWidget: [x: number, y: number] | [widget: Widget, attachmentPoint?: string],
37
+ ...parametersOrDuration: [parametersOrDuration?: EffectParameters | number] | [duration?: number, parameters?: EffectParameters]
28
38
  ]): void;
29
39
  static flashTarget(model: string, target: Widget, attachPoint: string, duration?: number): void;
30
40
  }
@@ -2,8 +2,9 @@ local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
4
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
+ local __TS__InstanceOf = ____lualib.__TS__InstanceOf
5
6
  local ____exports = {}
6
- local dummyPlayer
7
+ local dummyPlayer, flash
7
8
  local ____handle = require("core.types.handle")
8
9
  local Handle = ____handle.Handle
9
10
  local ____playerColor = require("core.types.playerColor")
@@ -12,6 +13,8 @@ local ____player = require("core.types.player")
12
13
  local Player = ____player.Player
13
14
  local ____timer = require("core.types.timer")
14
15
  local Timer = ____timer.Timer
16
+ local ____unit = require("engine.internal.unit")
17
+ local Unit = ____unit.Unit
15
18
  local ____pairs = _G.pairs
16
19
  local select = _G.select
17
20
  local mathRad = math.rad
@@ -22,10 +25,28 @@ local getSpecialEffectScale = BlzGetSpecialEffectScale
22
25
  local playSpecialEffect = BlzPlaySpecialEffect
23
26
  local setSpecialEffectScale = BlzSetSpecialEffectScale
24
27
  local setSpecialEffectPitch = BlzSetSpecialEffectPitch
28
+ local setSpecialEffectRoll = BlzSetSpecialEffectRoll
25
29
  local setSpecialEffectColorByPlayer = BlzSetSpecialEffectColorByPlayer
26
30
  local specialEffectAddSubAnimation = BlzSpecialEffectAddSubAnimation
27
31
  local specialEffectClearSubAnimations = BlzSpecialEffectClearSubAnimations
28
32
  local specialEffectRemoveSubAnimation = BlzSpecialEffectRemoveSubAnimation
33
+ local setSpecialEffectZ = BlzSetSpecialEffectZ
34
+ local getLocationZ = GetLocationZ
35
+ local getUnitZ = BlzGetUnitZ
36
+ local moveLocation = MoveLocation
37
+ local location = Location(0, 0)
38
+ local function setSpecialEffectPitchDegrees(effect, pitch)
39
+ setSpecialEffectPitch(
40
+ effect,
41
+ -mathRad(pitch)
42
+ )
43
+ end
44
+ local function setSpecialEffectRollDegrees(effect, roll)
45
+ setSpecialEffectRoll(
46
+ effect,
47
+ -mathRad(roll)
48
+ )
49
+ end
29
50
  local animTypeByAnimationName = {
30
51
  attack = ANIM_TYPE_ATTACK,
31
52
  birth = ANIM_TYPE_BIRTH,
@@ -97,11 +118,18 @@ local function setSpecialEffectColor(effect, color)
97
118
  setSpecialEffectColorByPlayer(effect, dummyPlayer.handle)
98
119
  dummyPlayer.color = dummyColor
99
120
  end
100
- local setters = {scale = setSpecialEffectScale, color = setSpecialEffectColor}
121
+ local setters = {scale = setSpecialEffectScale, color = setSpecialEffectColor, pitch = setSpecialEffectPitchDegrees, roll = setSpecialEffectRollDegrees}
101
122
  dummyPlayer = Player.neutralExtra
102
123
  local temporaryEffects = {}
103
124
  local temporaryEffectsDurations = {}
104
125
  local temporaryEffectsCount = 0
126
+ local delayedEffectsModelPath = {}
127
+ local delayedEffectsXOrWidget = {}
128
+ local delayedEffectsYOrAttachmentPoint = {}
129
+ local delayedEffectsDuration = {}
130
+ local delayedEffectsParameters = {}
131
+ local delayedEffectsDelay = {}
132
+ local delayedEffectsCount = 0
105
133
  local period = 1 / 32
106
134
  Timer.onPeriod[period]:addListener(function()
107
135
  local i = 1
@@ -110,12 +138,36 @@ Timer.onPeriod[period]:addListener(function()
110
138
  if duration <= 0 then
111
139
  destroyEffect(temporaryEffects[i])
112
140
  temporaryEffects[i] = temporaryEffects[temporaryEffectsCount]
141
+ temporaryEffectsDurations[i] = temporaryEffectsDurations[temporaryEffectsCount]
113
142
  temporaryEffectsCount = temporaryEffectsCount - 1
114
143
  else
115
144
  temporaryEffectsDurations[i] = duration - period
116
145
  i = i + 1
117
146
  end
118
147
  end
148
+ i = 1
149
+ while i <= delayedEffectsCount do
150
+ local delay = delayedEffectsDelay[i]
151
+ if delay <= 0 then
152
+ flash(
153
+ delayedEffectsModelPath[i],
154
+ delayedEffectsXOrWidget[i],
155
+ delayedEffectsYOrAttachmentPoint[i],
156
+ delayedEffectsDuration[i],
157
+ delayedEffectsParameters[i]
158
+ )
159
+ delayedEffectsModelPath[i] = delayedEffectsModelPath[delayedEffectsCount]
160
+ delayedEffectsXOrWidget[i] = delayedEffectsXOrWidget[delayedEffectsCount]
161
+ delayedEffectsYOrAttachmentPoint[i] = delayedEffectsYOrAttachmentPoint[delayedEffectsCount]
162
+ delayedEffectsDuration[i] = delayedEffectsDuration[delayedEffectsCount]
163
+ delayedEffectsParameters[i] = delayedEffectsParameters[delayedEffectsCount]
164
+ delayedEffectsDelay[i] = delayedEffectsDelay[delayedEffectsCount]
165
+ delayedEffectsCount = delayedEffectsCount - 1
166
+ else
167
+ delayedEffectsDelay[i] = delay - period
168
+ i = i + 1
169
+ end
170
+ end
119
171
  end)
120
172
  ____exports.Effect = __TS__Class()
121
173
  local Effect = ____exports.Effect
@@ -136,19 +188,23 @@ function Effect.flash(self, modelPath, xOrWidget, yOrOrAttachmentPoint, paramete
136
188
  parameters = parametersOrDuration
137
189
  parametersOrDuration = nil
138
190
  end
139
- local effect = type(xOrWidget) == "number" and addSpecialEffect(modelPath, xOrWidget, yOrOrAttachmentPoint) or addSpecialEffectTarget(modelPath, xOrWidget.handle, yOrOrAttachmentPoint)
140
- if parameters ~= nil then
141
- for key, value in ____pairs(parameters) do
142
- setters[key](effect, value)
143
- end
144
- end
145
- if parametersOrDuration ~= nil and parametersOrDuration > 0 then
146
- temporaryEffectsCount = temporaryEffectsCount + 1
147
- temporaryEffects[temporaryEffectsCount] = effect
148
- temporaryEffectsDurations[temporaryEffectsCount] = parametersOrDuration
191
+ if parameters and (parameters.delay or 0) > 0 then
192
+ delayedEffectsCount = delayedEffectsCount + 1
193
+ delayedEffectsModelPath[delayedEffectsCount] = modelPath
194
+ delayedEffectsXOrWidget[delayedEffectsCount] = xOrWidget
195
+ delayedEffectsYOrAttachmentPoint[delayedEffectsCount] = yOrOrAttachmentPoint
196
+ delayedEffectsDuration[delayedEffectsCount] = parametersOrDuration
197
+ delayedEffectsParameters[delayedEffectsCount] = parameters
198
+ delayedEffectsDelay[delayedEffectsCount] = parameters.delay
149
199
  return
150
200
  end
151
- destroyEffect(effect)
201
+ flash(
202
+ modelPath,
203
+ xOrWidget,
204
+ yOrOrAttachmentPoint,
205
+ parametersOrDuration,
206
+ parameters
207
+ )
152
208
  end
153
209
  function Effect.flashTarget(self, model, target, attachPoint, duration)
154
210
  local effect = addSpecialEffectTarget(model, target.handle, attachPoint)
@@ -197,13 +253,56 @@ __TS__SetDescriptor(
197
253
  return self[101] or 0
198
254
  end,
199
255
  set = function(self, pitch)
200
- setSpecialEffectPitch(
201
- self.handle,
202
- -mathRad(pitch)
203
- )
256
+ setSpecialEffectPitchDegrees(self.handle, pitch)
204
257
  self[101] = pitch
205
258
  end
206
259
  },
207
260
  true
208
261
  )
262
+ __TS__SetDescriptor(
263
+ Effect.prototype,
264
+ "roll",
265
+ {
266
+ get = function(self)
267
+ return self[102] or 0
268
+ end,
269
+ set = function(self, roll)
270
+ setSpecialEffectRollDegrees(self.handle, roll)
271
+ self[102] = roll
272
+ end
273
+ },
274
+ true
275
+ )
276
+ flash = function(modelPath, xOrWidget, yOrOrAttachmentPoint, duration, parameters)
277
+ local coordinatesProvided = type(xOrWidget) == "number"
278
+ local isPositional = coordinatesProvided or (parameters and parameters.detached) == true
279
+ local x = not isPositional and 0 or (coordinatesProvided and xOrWidget or xOrWidget.x)
280
+ local y = not isPositional and 0 or (coordinatesProvided and yOrOrAttachmentPoint or xOrWidget.y)
281
+ local effect = isPositional and addSpecialEffect(modelPath, x, y) or addSpecialEffectTarget(modelPath, xOrWidget.handle, yOrOrAttachmentPoint or "origin")
282
+ if isPositional and not coordinatesProvided and (parameters and parameters.scale) == nil and __TS__InstanceOf(xOrWidget, Unit) then
283
+ setSpecialEffectScale(effect, xOrWidget.scale)
284
+ end
285
+ if parameters ~= nil then
286
+ for key, value in ____pairs(parameters) do
287
+ if key ~= "zOffset" and key ~= "detached" and key ~= "scaleZOffset" and key ~= "delay" then
288
+ setters[key](effect, value)
289
+ end
290
+ end
291
+ if isPositional and parameters.zOffset ~= nil then
292
+ moveLocation(location, x, y)
293
+ local z = __TS__InstanceOf(xOrWidget, Unit) and getLocationZ(location) + xOrWidget.flyHeight or getLocationZ(location)
294
+ BlzSetSpecialEffectZ(
295
+ effect,
296
+ z + parameters.zOffset * (parameters.scaleZOffset and getSpecialEffectScale(effect) or 1)
297
+ )
298
+ end
299
+ end
300
+ if duration ~= nil and duration > 0 then
301
+ temporaryEffectsCount = temporaryEffectsCount + 1
302
+ temporaryEffects[temporaryEffectsCount] = effect
303
+ temporaryEffectsDurations[temporaryEffectsCount] = duration
304
+ return
305
+ end
306
+ destroyEffect(effect)
307
+ end
209
308
  return ____exports
@@ -31,6 +31,7 @@ export declare class Frame extends Handle<jframehandle> {
31
31
  static readonly WORLD: Frame;
32
32
  static readonly CHAT: Frame;
33
33
  static readonly TIME_OF_DAY_CLOCK: Frame;
34
+ private static readonly SIMPLE_FRAME_TEST_CHILD;
34
35
  static get uiScale(): number;
35
36
  static get leftBorder(): Frame;
36
37
  static get rightBorder(): Frame;
@@ -79,6 +80,8 @@ export declare class Frame extends Handle<jframehandle> {
79
80
  get onMouseLeave(): FrameEvent;
80
81
  get onMouseUp(): FrameEvent;
81
82
  get onMouseWheel(): FrameEvent<[number]>;
83
+ get mouseEnterLocalEvent(): Event;
84
+ get mouseLeaveLocalEvent(): Event;
82
85
  get popupMenuItemChangeEvent(): FrameEvent<[
83
86
  popupMenu: Frame,
84
87
  previousValue: number,
@@ -108,6 +111,7 @@ export declare class Frame extends Handle<jframehandle> {
108
111
  enable(): void;
109
112
  addText(text: string): void;
110
113
  clearAllPoints(): void;
114
+ get children(): Frame[];
111
115
  getChild(index: number): Frame;
112
116
  getChildrenCount(): number;
113
117
  setSize(width: number, height: number): void;
@@ -122,6 +122,7 @@ do
122
122
  FramePoint.BOTTOM = FRAMEPOINT_BOTTOM
123
123
  FramePoint.BOTTOM_RIGHT = FRAMEPOINT_BOTTOMRIGHT
124
124
  end
125
+ local tooltipByFrame = setmetatable({}, {__mode = "k"})
125
126
  ____exports.Frame = __TS__Class()
126
127
  local Frame = ____exports.Frame
127
128
  Frame.name = "Frame"
@@ -242,6 +243,7 @@ function Frame.prototype.setTextColor(self, color)
242
243
  end
243
244
  function Frame.prototype.setTooltip(self, tooltip)
244
245
  BlzFrameSetTooltip(self.handle, tooltip.handle)
246
+ tooltipByFrame[self] = tooltip
245
247
  end
246
248
  function Frame.prototype.setMinMaxValue(self, minValue, maxValue)
247
249
  BlzFrameSetMinMaxValue(self.handle, minValue, maxValue)
@@ -310,6 +312,7 @@ Frame.CONSOLE_BOTTOM_BAR = ____exports.Frame:byName("ConsoleBottomBar")
310
312
  Frame.WORLD = ____exports.Frame:byOrigin(ORIGIN_FRAME_WORLD_FRAME)
311
313
  Frame.CHAT = ____exports.Frame:byOrigin(ORIGIN_FRAME_CHAT_MSG)
312
314
  Frame.TIME_OF_DAY_CLOCK = ____exports.Frame.GAME_UI:getChild(5):getChild(0)
315
+ Frame.SIMPLE_FRAME_TEST_CHILD = ____exports.Frame:createByType("SIMPLEFRAME", "SimpleFrameTestParent", ____exports.Frame.CONSOLE_UI)
313
316
  __TS__ObjectDefineProperty(
314
317
  Frame,
315
318
  "uiScale",
@@ -618,6 +621,62 @@ __TS__SetDescriptor(
618
621
  end},
619
622
  true
620
623
  )
624
+ __TS__SetDescriptor(
625
+ Frame.prototype,
626
+ "mouseEnterLocalEvent",
627
+ {get = function(self)
628
+ local event = __TS__New(Event)
629
+ if not (tooltipByFrame[self] ~= nil) then
630
+ ____exports.Frame.SIMPLE_FRAME_TEST_CHILD.parent = self
631
+ local tooltip = ____exports.Frame.SIMPLE_FRAME_TEST_CHILD.parent == self and ____exports.Frame:createByType("SIMPLEFRAME", "", ____exports.Frame.CONSOLE_UI) or ____exports.Frame:createByType("FRAME", "", ____exports.Frame.GAME_UI)
632
+ ____exports.Frame.SIMPLE_FRAME_TEST_CHILD.parent = ____exports.Frame.CONSOLE_UI
633
+ self:setTooltip(tooltip)
634
+ end
635
+ local isMouseInside = false
636
+ Timer.onPeriod[1 / 64]:addListener(function()
637
+ local tooltip = tooltipByFrame[self]
638
+ if tooltip and tooltip.visible then
639
+ if not isMouseInside then
640
+ isMouseInside = true
641
+ Event.invoke(event)
642
+ end
643
+ else
644
+ isMouseInside = false
645
+ end
646
+ end)
647
+ rawset(self, "mouseEnterLocalEvent", event)
648
+ return event
649
+ end},
650
+ true
651
+ )
652
+ __TS__SetDescriptor(
653
+ Frame.prototype,
654
+ "mouseLeaveLocalEvent",
655
+ {get = function(self)
656
+ local event = __TS__New(Event)
657
+ if not (tooltipByFrame[self] ~= nil) then
658
+ ____exports.Frame.SIMPLE_FRAME_TEST_CHILD.parent = self
659
+ local tooltip = ____exports.Frame.SIMPLE_FRAME_TEST_CHILD.parent == self and ____exports.Frame:createByType("SIMPLEFRAME", "", ____exports.Frame.CONSOLE_UI) or ____exports.Frame:createByType("FRAME", "", ____exports.Frame.GAME_UI)
660
+ ____exports.Frame.SIMPLE_FRAME_TEST_CHILD.parent = ____exports.Frame.CONSOLE_UI
661
+ self:setTooltip(tooltip)
662
+ end
663
+ local isMouseInside = false
664
+ Timer.onPeriod[1 / 64]:addListener(function()
665
+ local tooltip = tooltipByFrame[self]
666
+ if tooltip and tooltip.visible then
667
+ isMouseInside = true
668
+ else
669
+ if isMouseInside then
670
+ isMouseInside = false
671
+ Event.invoke(event)
672
+ end
673
+ end
674
+ end)
675
+ rawset(self, "mouseLeaveLocalEvent", event)
676
+ return event
677
+ end},
678
+ true
679
+ )
621
680
  __TS__SetDescriptor(
622
681
  Frame.prototype,
623
682
  "popupMenuItemChangeEvent",
@@ -720,6 +779,18 @@ __TS__SetDescriptor(
720
779
  end},
721
780
  true
722
781
  )
782
+ __TS__SetDescriptor(
783
+ Frame.prototype,
784
+ "children",
785
+ {get = function(self)
786
+ local children = {}
787
+ for i = 0, self:getChildrenCount() - 1 do
788
+ children[i + 1] = self:getChild(i)
789
+ end
790
+ return children
791
+ end},
792
+ true
793
+ )
723
794
  __TS__ObjectDefineProperty(
724
795
  Frame,
725
796
  "onKeyPress",
@@ -1,6 +1,7 @@
1
1
  /** @noSelfInFile */
2
2
  import { Handle, HandleDestructor } from "./handle";
3
3
  import { Unit } from "./unit";
4
+ import { SoundEax } from "../../engine/object-data/auxiliary/sound-eax";
4
5
  export declare enum SoundChannel {
5
6
  General = 0,
6
7
  UnitSelection = 1,
@@ -18,16 +19,7 @@ export declare enum SoundChannel {
18
19
  Birth = 13,
19
20
  Fire = 14
20
21
  }
21
- export declare enum SoundEax {
22
- Default = "DefaultEAXON",
23
- Acknowledgements = "HeroAcksEAX",
24
- Environment = "DoodadsEAX",
25
- Drums = "KotoDrumsEAX",
26
- Attacks = "CombatSoundsEAX",
27
- Abilities = "SpellsEAX",
28
- Missiles = "MissilesEAX"
29
- }
30
- export type SoundPreset = Readonly<{
22
+ export type SoundSettings = Readonly<{
31
23
  channel?: SoundChannel;
32
24
  eax?: SoundEax;
33
25
  fadeInRate?: number;
@@ -36,19 +28,19 @@ export type SoundPreset = Readonly<{
36
28
  volume?: number;
37
29
  pitch?: number;
38
30
  }>;
39
- export type Sound3DPreset = SoundPreset & Readonly<{
31
+ export type Sound3DSettings = SoundSettings & Readonly<{
40
32
  stopWhenOutOfRange?: boolean;
41
33
  minDistance?: number;
42
34
  maxDistance?: number;
43
35
  distanceCutoff?: number;
44
36
  }>;
45
- export declare namespace SoundPreset {
46
- const UI: SoundPreset;
47
- const Music: SoundPreset;
48
- const Attack: Sound3DPreset;
49
- const Ability: Sound3DPreset;
50
- const AbilityLooping: Sound3DPreset;
51
- const Missile: Sound3DPreset;
37
+ export declare namespace SoundSettings {
38
+ const UI: SoundSettings;
39
+ const Music: SoundSettings;
40
+ const Attack: Sound3DSettings;
41
+ const Ability: Sound3DSettings;
42
+ const AbilityLooping: Sound3DSettings;
43
+ const Missile: Sound3DSettings;
52
44
  }
53
45
  export declare class Sound extends Handle<jsound, [fadeOut?: boolean]> {
54
46
  private _volume?;
@@ -58,12 +50,13 @@ export declare class Sound extends Handle<jsound, [fadeOut?: boolean]> {
58
50
  start(milliseconds?: number): void;
59
51
  stop(fadeOut?: boolean): void;
60
52
  restart(milliseconds?: number): void;
61
- static play(fileName: string, preset: SoundPreset): void;
62
- static create(fileName: string, preset: SoundPreset): Sound;
53
+ static play(fileName: string, preset: SoundSettings): void;
54
+ static create(fileName: string, preset: SoundSettings): Sound;
63
55
  }
64
56
  export declare class Sound3D extends Sound {
65
- static playAtPosition(fileName: string, preset: Sound3DPreset, x?: number, y?: number, z?: number): void;
66
- static playOnUnit(fileName: string, preset: Sound3DPreset, unit: Unit): void;
67
- static createAtPosition(fileName: string, preset: Sound3DPreset, x?: number, y?: number, z?: number): Sound3D;
68
- static createOnUnit(fileName: string, preset: Sound3DPreset, unit: Unit): Sound3D;
57
+ static playAtPosition(fileName: string, preset: Sound3DSettings, x?: number, y?: number, z?: number): void;
58
+ static playOnUnit(fileName: string, preset: Sound3DSettings, unit: Unit): void;
59
+ static playFromLabel(label: string, preset: Sound3DSettings, ...positionOrUnit: [Unit] | [number, number, number?]): void;
60
+ static createAtPosition(fileName: string, preset: Sound3DSettings, x?: number, y?: number, z?: number): Sound3D;
61
+ static createOnUnit(fileName: string, preset: Sound3DSettings, unit: Unit): Sound3D;
69
62
  }
@@ -5,15 +5,18 @@ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
5
  local ____exports = {}
6
6
  local ____handle = require("core.types.handle")
7
7
  local Handle = ____handle.Handle
8
+ local ____sound_2Dpreset = require("engine.object-data.entry.sound-preset")
9
+ local SoundPreset = ____sound_2Dpreset.SoundPreset
10
+ local ____random = require("engine.random")
11
+ local randomInteger = ____random.randomInteger
8
12
  local createSound = CreateSound
13
+ local createSoundFromLabel = CreateSoundFromLabel
9
14
  local setSoundPitch = SetSoundPitch
10
15
  local setSoundChannel = SetSoundChannel
11
16
  local setSoundPosition = SetSoundPosition
12
17
  local setSoundVolume = SetSoundVolume
13
18
  local setSoundDistances = SetSoundDistances
14
19
  local setSoundDistanceCutoff = SetSoundDistanceCutoff
15
- local setSoundConeAngles = SetSoundConeAngles
16
- local setSoundConeOrientation = SetSoundConeOrientation
17
20
  local startSound = StartSound
18
21
  local setSoundPlayPosition = SetSoundPlayPosition
19
22
  local stopSound = StopSound
@@ -50,29 +53,21 @@ ____exports.SoundChannel.Birth = 13
50
53
  ____exports.SoundChannel[____exports.SoundChannel.Birth] = "Birth"
51
54
  ____exports.SoundChannel.Fire = 14
52
55
  ____exports.SoundChannel[____exports.SoundChannel.Fire] = "Fire"
53
- ____exports.SoundEax = SoundEax or ({})
54
- ____exports.SoundEax.Default = "DefaultEAXON"
55
- ____exports.SoundEax.Acknowledgements = "HeroAcksEAX"
56
- ____exports.SoundEax.Environment = "DoodadsEAX"
57
- ____exports.SoundEax.Drums = "KotoDrumsEAX"
58
- ____exports.SoundEax.Attacks = "CombatSoundsEAX"
59
- ____exports.SoundEax.Abilities = "SpellsEAX"
60
- ____exports.SoundEax.Missiles = "MissilesEAX"
61
- ____exports.SoundPreset = {}
62
- local SoundPreset = ____exports.SoundPreset
56
+ ____exports.SoundSettings = {}
57
+ local SoundSettings = ____exports.SoundSettings
63
58
  do
64
- SoundPreset.UI = {channel = ____exports.SoundChannel.UI, eax = ____exports.SoundEax.Default, fadeInRate = 12700, fadeOutRate = 12700}
65
- SoundPreset.Music = {
59
+ SoundSettings.UI = {channel = ____exports.SoundChannel.UI, eax = "DefaultEAXON", fadeInRate = 12700, fadeOutRate = 12700}
60
+ SoundSettings.Music = {
66
61
  channel = ____exports.SoundChannel.Music,
67
- eax = ____exports.SoundEax.Default,
62
+ eax = "DefaultEAXON",
68
63
  fadeInRate = 12700,
69
64
  fadeOutRate = 12700,
70
65
  looping = true
71
66
  }
72
- SoundPreset.Attack = {channel = ____exports.SoundChannel.Combat, eax = ____exports.SoundEax.Attacks, fadeInRate = 10, fadeOutRate = 10}
73
- SoundPreset.Ability = {
67
+ SoundSettings.Attack = {channel = ____exports.SoundChannel.Combat, eax = "CombatSoundsEAX", fadeInRate = 10, fadeOutRate = 10}
68
+ SoundSettings.Ability = {
74
69
  channel = ____exports.SoundChannel.Animations,
75
- eax = ____exports.SoundEax.Abilities,
70
+ eax = "SpellsEAX",
76
71
  stopWhenOutOfRange = true,
77
72
  volume = 127,
78
73
  fadeInRate = 1,
@@ -82,9 +77,9 @@ do
82
77
  maxDistance = 3500,
83
78
  distanceCutoff = 3000
84
79
  }
85
- SoundPreset.AbilityLooping = {
80
+ SoundSettings.AbilityLooping = {
86
81
  channel = ____exports.SoundChannel.Birth,
87
- eax = ____exports.SoundEax.Abilities,
82
+ eax = "SpellsEAX",
88
83
  looping = true,
89
84
  stopWhenOutOfRange = true,
90
85
  volume = 127,
@@ -95,9 +90,9 @@ do
95
90
  maxDistance = 3000,
96
91
  distanceCutoff = 3000
97
92
  }
98
- SoundPreset.Missile = {
93
+ SoundSettings.Missile = {
99
94
  channel = ____exports.SoundChannel.Animations,
100
- eax = ____exports.SoundEax.Missiles,
95
+ eax = "MissilesEAX",
101
96
  stopWhenOutOfRange = true,
102
97
  volume = 127,
103
98
  fadeInRate = 1,
@@ -108,6 +103,24 @@ do
108
103
  distanceCutoff = 3000
109
104
  }
110
105
  end
106
+ local customSoundPresetDataByLabel = postcompile(function()
107
+ local customSoundPresetDataByLabel = {}
108
+ for ____, soundPreset in ipairs(SoundPreset:getAll()) do
109
+ if soundPreset.isCustom then
110
+ customSoundPresetDataByLabel[soundPreset.id] = {
111
+ filePaths = soundPreset.filePaths,
112
+ volume = soundPreset.volume,
113
+ pitch = soundPreset.pitch,
114
+ channel = soundPreset.channel,
115
+ minimumDistance = soundPreset.minimumDistance,
116
+ maximumDistance = soundPreset.maximumDistance,
117
+ distanceCutoff = soundPreset.distanceCutoff,
118
+ eax = soundPreset.eax
119
+ }
120
+ end
121
+ end
122
+ return customSoundPresetDataByLabel
123
+ end)
111
124
  local function createPresetSound(fileName, preset)
112
125
  local ____fileName_1 = fileName
113
126
  local ____preset_looping_0 = preset.looping
@@ -121,7 +134,7 @@ local function createPresetSound(fileName, preset)
121
134
  true,
122
135
  preset.fadeInRate or 12700,
123
136
  preset.fadeOutRate or 12700,
124
- preset.eax or ____exports.SoundEax.Default
137
+ preset.eax or "DefaultEAXON"
125
138
  )
126
139
  setSoundChannel(sound, preset.channel or ____exports.SoundChannel.General)
127
140
  setSoundVolume(sound, preset.volume or 127)
@@ -144,7 +157,7 @@ local function createPreset3DSound(fileName, preset)
144
157
  ____preset_stopWhenOutOfRange_3,
145
158
  preset.fadeInRate or 12700,
146
159
  preset.fadeOutRate or 12700,
147
- preset.eax or ____exports.SoundEax.Default
160
+ preset.eax or "DefaultEAXON"
148
161
  )
149
162
  setSoundChannel(sound, preset.channel or ____exports.SoundChannel.General)
150
163
  setSoundVolume(sound, preset.volume or 127)
@@ -153,6 +166,53 @@ local function createPreset3DSound(fileName, preset)
153
166
  setSoundDistanceCutoff(sound, preset.distanceCutoff or 1500)
154
167
  return sound
155
168
  end
169
+ local function createPreset3DSoundFromLabel(label, preset)
170
+ local customSoundPresetData = customSoundPresetDataByLabel[label]
171
+ if customSoundPresetData == nil then
172
+ local ____label_7 = label
173
+ local ____preset_looping_5 = preset.looping
174
+ if ____preset_looping_5 == nil then
175
+ ____preset_looping_5 = false
176
+ end
177
+ local ____preset_stopWhenOutOfRange_6 = preset.stopWhenOutOfRange
178
+ if ____preset_stopWhenOutOfRange_6 == nil then
179
+ ____preset_stopWhenOutOfRange_6 = true
180
+ end
181
+ return createSoundFromLabel(
182
+ ____label_7,
183
+ ____preset_looping_5,
184
+ true,
185
+ ____preset_stopWhenOutOfRange_6,
186
+ preset.fadeInRate or 12700,
187
+ preset.fadeOutRate or 12700
188
+ )
189
+ else
190
+ local ____customSoundPresetData_filePaths_index_10 = customSoundPresetData.filePaths[randomInteger(#customSoundPresetData.filePaths - 1) + 1]
191
+ local ____preset_looping_8 = preset.looping
192
+ if ____preset_looping_8 == nil then
193
+ ____preset_looping_8 = false
194
+ end
195
+ local ____preset_stopWhenOutOfRange_9 = preset.stopWhenOutOfRange
196
+ if ____preset_stopWhenOutOfRange_9 == nil then
197
+ ____preset_stopWhenOutOfRange_9 = true
198
+ end
199
+ local sound = createSound(
200
+ ____customSoundPresetData_filePaths_index_10,
201
+ ____preset_looping_8,
202
+ true,
203
+ ____preset_stopWhenOutOfRange_9,
204
+ preset.fadeInRate or 12700,
205
+ preset.fadeOutRate or 12700,
206
+ customSoundPresetData.eax
207
+ )
208
+ setSoundChannel(sound, customSoundPresetData.channel)
209
+ setSoundVolume(sound, customSoundPresetData.volume)
210
+ setSoundPitch(sound, customSoundPresetData.pitch)
211
+ setSoundDistances(sound, customSoundPresetData.minimumDistance, customSoundPresetData.maximumDistance)
212
+ setSoundDistanceCutoff(sound, customSoundPresetData.distanceCutoff)
213
+ return sound
214
+ end
215
+ end
156
216
  ____exports.Sound = __TS__Class()
157
217
  local Sound = ____exports.Sound
158
218
  Sound.name = "Sound"
@@ -225,6 +285,16 @@ function Sound3D.playOnUnit(self, fileName, preset, unit)
225
285
  startSound(sound)
226
286
  killSoundWhenDone(sound)
227
287
  end
288
+ function Sound3D.playFromLabel(self, label, preset, unitOrX, y, z)
289
+ local sound = createPreset3DSoundFromLabel(label, preset)
290
+ if type(unitOrX) ~= "number" then
291
+ attachSoundToUnit(sound, unitOrX.handle)
292
+ else
293
+ setSoundPosition(sound, unitOrX, y or 0, z or 0)
294
+ end
295
+ startSound(sound)
296
+ killSoundWhenDone(sound)
297
+ end
228
298
  function Sound3D.createAtPosition(self, fileName, preset, x, y, z)
229
299
  if x == nil then
230
300
  x = 0